diff --git a/src/minecraft/biomesoplenty/blocks/BlockGrave.java b/src/minecraft/biomesoplenty/blocks/BlockGrave.java index 06f03bf36..4d984a7c3 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockGrave.java +++ b/src/minecraft/biomesoplenty/blocks/BlockGrave.java @@ -2,10 +2,17 @@ package biomesoplenty.blocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.particle.EntityDiggingFX; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import biomesoplenty.BiomesOPlenty; import biomesoplenty.tileentity.TileEntityGrave; +import cpw.mods.fml.client.FMLClientHandler; public class BlockGrave extends Block { @@ -14,7 +21,68 @@ public class BlockGrave extends Block super(id, Material.rock); setHardness(5f); - setCreativeTab(CreativeTabs.tabBlock); + setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity, ItemStack itemstack) + { + int o = ((MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + int fO; + + if (o == 0 || o == 2) + { + fO = 0; + } + else + { + fO = 1; + } + + if (!world.isRemote) + { + world.setBlockMetadataWithNotify(x, y, z, fO, 2); + } + } + + @Override + public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) + { + byte b0 = 4; + + for (int j1 = 0; j1 < b0; ++j1) + { + for (int k1 = 0; k1 < b0; ++k1) + { + for (int l1 = 0; l1 < b0; ++l1) + { + double d0 = (double)x + ((double)j1 + 0.5D) / (double)b0; + double d1 = (double)y + ((double)k1 + 0.5D) / (double)b0; + double d2 = (double)z + ((double)l1 + 0.5D) / (double)b0; + int i2 = world.rand.nextInt(6); + effectRenderer.addEffect(new EntityDiggingFX(world, d0, d1, d2, d0 - (double)x - 0.5D, d1 - (double)y - 0.5D, d2 - (double)z - 0.5D, Block.stone, i2, meta, FMLClientHandler.instance().getClient().renderEngine).func_70596_a(x, y, z)); + } + } + } + + return true; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4) + { + int meta = world.getBlockMetadata(par2, par3, par4); + + switch (meta) + { + case 0: + this.setBlockBounds(0.0F, 0.0F, 0.31F, 1.0F, 1.5F, 0.69F); + break; + + case 1: + this.setBlockBounds(0.31F, 0.0F, 0.0F, 0.69F, 1.5F, 1.0F); + break; + } } @Override diff --git a/src/minecraft/biomesoplenty/blocks/renderers/TileEntityGraveRenderer.java b/src/minecraft/biomesoplenty/blocks/renderers/TileEntityGraveRenderer.java index 869cd368b..f22868b9d 100644 --- a/src/minecraft/biomesoplenty/blocks/renderers/TileEntityGraveRenderer.java +++ b/src/minecraft/biomesoplenty/blocks/renderers/TileEntityGraveRenderer.java @@ -3,6 +3,7 @@ package biomesoplenty.blocks.renderers; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import org.lwjgl.opengl.GL11; @@ -17,23 +18,39 @@ public class TileEntityGraveRenderer extends TileEntitySpecialRenderer @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z,float tick) { - renderModelAt((TileEntityGrave)tileentity, x, y, z, tick); + World world = tileentity.worldObj; + + int meta = world.getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); + + if (meta == 0) + { + renderModelAt((TileEntityGrave)tileentity, x, y, z, tick, 0.0F); + } + else + { + renderModelAt((TileEntityGrave)tileentity, x, y, z, tick, 1.0F); + } } - public void renderModelAt(TileEntityGrave tileentity1, double x, double y, double z, float ticks) + public void renderModelAt(TileEntityGrave tileentity1, double x, double y, double z, float ticks, float rotation) { //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); + //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 2.25F, (float) z + 0.5F); + //This is the texture of your block. It's pathed to be the same place as your other blocks here. FMLClientHandler.instance().getClient().renderEngine.bindTexture("/mods/BiomesOPlenty/textures/models/grave.png"); + //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, rotation, 0.0F, 1.0F); GL11.glScalef(1.5F, 1.5F, 1.5F); + //A reference to your Model file. Again, very important. modelGrave.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + //Tell it to stop rendering for both the PushMatrix's GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/minecraft/biomesoplenty/configuration/BOPBlocks.java b/src/minecraft/biomesoplenty/configuration/BOPBlocks.java index 338494b64..556ba0ba4 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPBlocks.java +++ b/src/minecraft/biomesoplenty/configuration/BOPBlocks.java @@ -57,6 +57,7 @@ import biomesoplenty.items.ItemBOPFlower; import biomesoplenty.items.ItemBOPFoliage; import biomesoplenty.items.ItemBOPGlass; import biomesoplenty.items.ItemBOPGrass; +import biomesoplenty.items.ItemBOPGrave; import biomesoplenty.items.ItemBOPIvy; import biomesoplenty.items.ItemBOPLeaves; import biomesoplenty.items.ItemBOPLog; @@ -249,7 +250,7 @@ public class BOPBlocks GameRegistry.registerBlock(Blocks.glass.get(), ItemBOPGlass.class, "bop.glass"); GameRegistry.registerBlock(Blocks.altar.get(), ItemBOPAltar.class, "bop.altar"); GameRegistry.registerBlock(Blocks.puddle.get(), "bop.puddle"); - GameRegistry.registerBlock(Blocks.grave.get(), "bop.grave"); + GameRegistry.registerBlock(Blocks.grave.get(), ItemBOPGrave.class, "bop.grave"); ItemBOPSlab.setSlabs(Blocks.stoneSingleSlab.get(), Blocks.stoneDoubleSlab.get()); GameRegistry.registerBlock(Blocks.stoneDoubleSlab.get(), ItemBOPSlab.class, "bop.stoneDoubleSlab"); diff --git a/src/minecraft/biomesoplenty/items/ItemBOPGrave.java b/src/minecraft/biomesoplenty/items/ItemBOPGrave.java new file mode 100644 index 000000000..1618f3b2e --- /dev/null +++ b/src/minecraft/biomesoplenty/items/ItemBOPGrave.java @@ -0,0 +1,19 @@ +package biomesoplenty.items; + +import net.minecraft.item.ItemBlock; + +public class ItemBOPGrave extends ItemBlock +{ + public ItemBOPGrave(int par1) + { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + } + + @Override + public int getMetadata(int meta) + { + return meta & 15; + } +}