Finished bone blocks

This commit is contained in:
Adubbz 2013-05-23 19:06:58 +10:00
parent 4bf8c5bdbe
commit 79628f1ecd
4 changed files with 175 additions and 13 deletions

View file

@ -23,6 +23,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBones extends Block {
//Meta 3 & 4 used by alternate medium bone rotations
private static final String[] boneTypes = new String[] {"bones_small", "bones_medium", "bones_large"};
private Icon[] textures;
@ -49,10 +50,13 @@ public class BlockBones extends Block {
if (meta < 0 || meta >= textures.length)
meta = 0;
if (meta == 3 || meta == 4)
meta = 1;
return textures[meta];
}
/*@Override
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
@ -61,9 +65,17 @@ public class BlockBones extends Block {
{
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
}
if (meta == 1)
else if (meta == 1)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 1.0D, (double) z + 0.875D);
}
else if (meta == 3)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y + 0.125D, (double) z, (double) x + 0.875D, (double) y + 0.875D, (double) z + 1.00D);
}
else if (meta == 4)
{
return AxisAlignedBB.getBoundingBox((double) x, y + 0.125D, (double) z + 0.125D, (double) x + 1.00D, (double) y + 0.875D, (double) z + 0.875D);
}
else
{
@ -82,7 +94,15 @@ public class BlockBones extends Block {
}
else if (meta == 1)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 1.00D, (double) z + 0.875D);
}
else if (meta == 3)
{
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y + 0.125D, (double) z, (double) x + 0.875D, (double) y + 0.875D, (double) z + 1.00D);
}
else if (meta == 4)
{
return AxisAlignedBB.getBoundingBox((double) x, y + 0.125D, (double) z + 0.125D, (double) x + 1.00D, (double) y + 0.875D, (double) z + 0.875D);
}
else
{
@ -96,7 +116,7 @@ public class BlockBones extends Block {
int meta = iblockaccess.getBlockMetadata(x, y, z);
float minX;
float minY = 0F;
float minY;
float minZ;
float maxX;
float maxY;
@ -104,31 +124,43 @@ public class BlockBones extends Block {
if (meta == 0)
{
minY = 0F;
minX = minZ = 0.25F;
maxX = maxZ = 0.75F;
maxY = 0.5F;
}
else if (meta == 1)
{
minY = 0F;
minX = minZ = 0.125F;
maxX = maxZ = 0.875F;
maxY = 0.75F;
maxY = 1.00F;
}
else
{
minY = 0F;
minX = minZ = 0.0F;
maxX = maxZ = 1.0F;
maxY = 1.0F;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}*/
}
@Override
public int getDamageValue(World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 3 || meta == 4)
meta = 1;
return meta;
}
@Override
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
{
for (int i = 0; i < boneTypes.length; ++i)
list.add(new ItemStack(blockID, 1, i));
}/*
}
@Override
public boolean isOpaqueCube()
@ -152,11 +184,13 @@ public class BlockBones extends Block {
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return true;
}*/
}
@Override
public int damageDropped(int meta)
{
if (meta == 3 || meta == 4)
meta = 1;
return meta;
}
}

View file

@ -29,7 +29,17 @@ public class SmallBlockRenderer implements ISimpleBlockRenderingHandler
}
else if (meta == 1)
{
renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F);
renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F);
renderer.renderStandardBlock(block, x, y, z);
}
else if (meta == 3)
{
renderer.setRenderBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 1.0F);
renderer.renderStandardBlock(block, x, y, z);
}
else if (meta == 4)
{
renderer.setRenderBounds(0.0F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
renderer.renderStandardBlock(block, x, y, z);
}
else
@ -47,8 +57,32 @@ public class SmallBlockRenderer implements ISimpleBlockRenderingHandler
if (modelID == bonesModel)
{
Tessellator tessellator = Tessellator.instance;
renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata);
if (metadata == 0)
{
renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 1)
{
renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F);
BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 3)
{
renderer.setRenderBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 1.0F);
BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 4)
{
renderer.setRenderBounds(0.0F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata);
}
else
{
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
BiomesOPlenty.proxy.renderStandardInvBlock(renderer, block, metadata);
}
}
}

View file

@ -385,6 +385,8 @@ public class BOPBlocks {
LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 0), "Small Bone Segment");
LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 1), "Medium Bone Segment");
LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 2), "Large Bone Segment");
LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 3), "Medium Bone Segment");
LanguageRegistry.addName(new ItemStack(Blocks.bones.get(), 1, 4), "Medium Bone Segment");
LanguageRegistry.addName(new ItemStack(Blocks.planks.get(), 1, 0), "Acacia Wood Planks");
LanguageRegistry.addName(new ItemStack(Blocks.planks.get(), 1, 1), "Cherry Wood Planks");

View file

@ -1,11 +1,14 @@
package biomesoplenty.items;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemBOPBones extends ItemBlock
{
private static final String[] types = new String[] {"bones_small", "bones_medium", "bones_large"};
private static final String[] types = new String[] {"bones_small", "bones_medium", "bones_large", "bones_medium_side_1", "bones_medium_side_2"};
public ItemBOPBones(int par1)
{
@ -28,4 +31,93 @@ public class ItemBOPBones extends ItemBlock
return types[meta];
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
{
int id = world.getBlockId(x, y, z);
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1)
{
side = 1;
}
else if (id != Block.vine.blockID && id != Block.tallGrass.blockID && id != Block.deadBush.blockID
&& (Block.blocksList[id] == null || !Block.blocksList[id].isBlockReplaceable(world, x, y, z)))
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (itemstack.stackSize == 0)
{
return false;
}
else if (!player.canPlayerEdit(x, y, z, side, itemstack))
{
return false;
}
else if (y == 255 && Block.blocksList[this.itemID].blockMaterial.isSolid())
{
return false;
}
else if (world.canPlaceEntityOnSide(this.itemID, x, y, z, false, side, player, itemstack))
{
Block block = Block.blocksList[this.itemID];
int j1 = this.getMetadata(itemstack.getItemDamage());
if (itemstack.getItemDamage() == 1)
{
if (side == 2 || side == 3)
{
j1 = 3;
}
if (side == 4 || side == 5)
{
j1 = 4;
}
}
int k1 = Block.blocksList[this.itemID].onBlockPlaced(world, x, y, z, side, par8, par9, par10, j1);
if (placeBlockAt(itemstack, player, world, x, y, z, side, par8, par9, par10, k1))
{
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
--itemstack.stackSize;
}
return true;
}
else
{
return false;
}
}
}