From d160d58a4491261ad7993645eedfbf230cdab6fa Mon Sep 17 00:00:00 2001 From: Adubbz Date: Wed, 10 Jul 2013 08:27:36 +1000 Subject: [PATCH] Finished the new graves --- .../biomesoplenty/textures/blocks/grave.png | Bin 0 -> 330 bytes .../textures/blocks/item_grave.png | Bin 0 -> 571 bytes .../biomesoplenty/blocks/BlockGrave.java | 78 +++++++----- .../blocks/renderers/GraveRenderer.java | 83 +++++++------ .../itemblocks/ItemBlockGrave.java | 113 ++++++++++++++++++ 5 files changed, 201 insertions(+), 73 deletions(-) create mode 100644 src/minecraft/assets/biomesoplenty/textures/blocks/grave.png create mode 100644 src/minecraft/assets/biomesoplenty/textures/blocks/item_grave.png diff --git a/src/minecraft/assets/biomesoplenty/textures/blocks/grave.png b/src/minecraft/assets/biomesoplenty/textures/blocks/grave.png new file mode 100644 index 0000000000000000000000000000000000000000..11a31fae7132831378371e69df268da5c809df64 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvR?Tx;Tbd_~%YE6gsTH!}3$Bm3!5n{ihF|N^jcS>RxW8nRMxx#C5h$ zn_ukxTwDH}L1I!?T=+}V9G+sn1-?rdifYa>UP|I~X*m7JLZ%>#;neS=VF|IDH(v9d z;;?r<->GLSco!5}EMWdDeyVyd_mZP|G{9+kypG4N*PjK(--~AOpF&=ShY^#G54>D WmK9yU>{NiBVDNPHb6Mw<&;$S*Tzvxo literal 0 HcmV?d00001 diff --git a/src/minecraft/assets/biomesoplenty/textures/blocks/item_grave.png b/src/minecraft/assets/biomesoplenty/textures/blocks/item_grave.png new file mode 100644 index 0000000000000000000000000000000000000000..1f9d8aefcb7810f1091da3e476adc625cc3bb2d6 GIT binary patch literal 571 zcmV-B0>u4^P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv00051Nkl9jdc6XN z1>!ef*aj4|98Cb>B498Wc-3lE>h-!9D_{*RCvb9}&u4X#FdPoOR4OHzOvZhB7beDR z^3)*da=EBuyWI-dY&LrCb~{-vm$KjQWipw#@OLqC{)n?)uVp+QiyJ{kqmlG_Jx%QQ z`%)|xUC29G8QAPDSg~5Iq|@nWU?dWeL?WRYP@r5ct3M3ye!r_xtJQ>=p-cC4IxVeM zOG>4ZWV2aigB^`V#rJ(V9*?S3z<>gDI~)#5mq2`#N=0(HoJ^-vVJpdGQW}khOZj17 z23j!FVzH2RyR8B7cwF-NyxQGvR}0SPbKMX=ph>(s040=%t_xC75K&>(Y&M0Fjdf7K zE_{G0w3(Mj1YPcI;9n6b5PoU1*$l2k%p-@m3h{uZgb~>H( zv@rrB{PzLWX05D~_h7=o#8~JW%`hz}giTO*G;4$p7T*oU`vTH9pl!(dH^2Y@002ov JPDHLkV1mf=@6P}L literal 0 HcmV?d00001 diff --git a/src/minecraft/biomesoplenty/blocks/BlockGrave.java b/src/minecraft/biomesoplenty/blocks/BlockGrave.java index 435d818f0..28fd54f88 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockGrave.java +++ b/src/minecraft/biomesoplenty/blocks/BlockGrave.java @@ -1,20 +1,16 @@ package biomesoplenty.blocks; +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.particle.EffectRenderer; -import net.minecraft.client.particle.EntityDiggingFX; import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import biomesoplenty.BiomesOPlenty; +import biomesoplenty.api.Blocks; import biomesoplenty.blocks.renderers.RenderUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockGrave extends Block { @@ -29,29 +25,8 @@ public class BlockGrave extends Block @Override public void registerIcons(IconRegister iconRegister) { - blockIcon = iconRegister.registerIcon("stone"); + blockIcon = iconRegister.registerIcon("biomesoplenty:grave"); } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase 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 void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4) @@ -61,14 +36,55 @@ public class BlockGrave extends Block switch (meta) { case 0: - this.setBlockBounds(0.0F, 0.0F, 0.31F, 1.0F, 1.625F, 0.69F); + this.setBlockBounds(0.0F, 0.0F, 0.31F, 1.0F, 1.6875F, 0.69F); break; case 1: - this.setBlockBounds(0.0F, -1.0F, 0.31F, 1.0F, 0.625F, 0.69F); + this.setBlockBounds(0.0F, -1.0F, 0.31F, 1.0F, 0.6875F, 0.69F); + break; + + case 2: + this.setBlockBounds(0.31F, 0.0F, 0.0F, 0.69F, 1.6875F, 1.0F); + break; + + case 3: + this.setBlockBounds(0.31F, -1.0F, 0.0F, 0.69F, 0.6875F, 1.0F); break; } } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID) + { + if (neighbourID == Blocks.grave.get().blockID) + { + if (world.getBlockMetadata(x, y, z) == 0 || world.getBlockMetadata(x, y, z) == 2) + { + if (world.getBlockId(x, y + 1, z) != Blocks.grave.get().blockID) + { + world.destroyBlock(x, y, z, true); + } + } + else + { + if (world.getBlockId(x, y - 1, z) != Blocks.grave.get().blockID) + { + world.destroyBlock(x, y, z, true); + } + } + } + } + + @Override + public ArrayList getBlockDropped(World world, int x, int y, int z, int meta, int fortune) + { + ArrayList ret = new ArrayList(); + + if (meta == 0) ret.add(new ItemStack(Blocks.grave.get(), 1)); + else if (meta == 2) ret.add(new ItemStack(Blocks.grave.get(), 1)); + + return ret; + } @Override public boolean renderAsNormalBlock() diff --git a/src/minecraft/biomesoplenty/blocks/renderers/GraveRenderer.java b/src/minecraft/biomesoplenty/blocks/renderers/GraveRenderer.java index ce9197a2d..e677a175e 100644 --- a/src/minecraft/biomesoplenty/blocks/renderers/GraveRenderer.java +++ b/src/minecraft/biomesoplenty/blocks/renderers/GraveRenderer.java @@ -2,7 +2,6 @@ package biomesoplenty.blocks.renderers; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; @@ -56,6 +55,46 @@ public class GraveRenderer implements ISimpleBlockRenderingHandler renderer.setRenderBounds(0, pixel*8, pixel*5, pixel*16, pixel*11, pixel*11); renderer.renderStandardBlock(block, x, y, z); } + else if (meta == 2) + { + //Base + renderer.setRenderBounds(pixel*5, 0, pixel*5, pixel*11, pixel*3, pixel*11); + renderer.renderStandardBlock(block, x, y, z); + + //Base pole + renderer.setRenderBounds(pixel*6, pixel*3, pixel*6, pixel*10, pixel*11, pixel*10); + renderer.renderStandardBlock(block, x, y, z); + + //Head horizontal bottom + renderer.setRenderBounds(pixel*5, pixel*11, 0, pixel*11, pixel*14, pixel*16); + renderer.renderStandardBlock(block, x, y, z); + } + else if (meta == 3) + { + //Head vertical side 0 + renderer.setRenderBounds(pixel*5, pixel*-2, pixel*13, pixel*11, pixel*8, pixel*16); + renderer.renderStandardBlock(block, x, y, z); + + //Head vertical side 1 + renderer.setRenderBounds(pixel*5, pixel*-2, 0, pixel*11, pixel*8, pixel*3); + renderer.renderStandardBlock(block, x, y, z); + + //Cross vertical side 1 + renderer.setRenderBounds(pixel*7, pixel*-3, pixel*6, pixel*9, pixel*14, pixel*10); + renderer.renderStandardBlock(block, x, y, z); + + //Head horizontal middle 0 + renderer.setRenderBounds(pixel*7, pixel*1, pixel*-4, pixel*9, pixel*5, pixel*6); + renderer.renderStandardBlock(block, x, y, z); + + //Head horizontal middle 1 + renderer.setRenderBounds(pixel*7, pixel*1, pixel*10, pixel*9, pixel*5, pixel*20); + renderer.renderStandardBlock(block, x, y, z); + + //Head horizontal top + renderer.setRenderBounds(pixel*5, pixel*8, 0, pixel*11, pixel*11, pixel*16); + renderer.renderStandardBlock(block, x, y, z); + } } return true; } @@ -63,52 +102,12 @@ public class GraveRenderer implements ISimpleBlockRenderingHandler @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - if (modelID == RenderUtils.graveModel) - { - Tessellator tessellator = Tessellator.instance; - - if (metadata == 0) - { - renderer.setRenderBounds(0.374F, 0.0F, 0.374F, 0.626F, 1.0F, 0.626F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - else if (metadata == 1) - { - renderer.setRenderBounds(0.187F, 0.0F, 0.187F, 0.813F, 1.0F, 0.813F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - else if (metadata == 3) - { - renderer.setRenderBounds(0.374F, 0.374F, 0.0F, 0.626F, 0.626F, 1.0F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - else if (metadata == 4) - { - renderer.setRenderBounds(0.0F, 0.374F, 0.374F, 1.0F, 0.626F, 0.626F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - else if (metadata == 5) - { - renderer.setRenderBounds(0.187F, 0.187F, 0.0F, 0.813F, 0.813F, 1.0F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - else if (metadata == 6) - { - renderer.setRenderBounds(0.0F, 0.187F, 0.187F, 1.0F, 0.813F, 0.813F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - else - { - renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - RenderUtils.renderStandardInvBlock(renderer, block, metadata); - } - } } @Override public boolean shouldRender3DInInventory() { - return true; + return false; } @Override diff --git a/src/minecraft/biomesoplenty/itemblocks/ItemBlockGrave.java b/src/minecraft/biomesoplenty/itemblocks/ItemBlockGrave.java index 9e93185f3..7e90298fc 100644 --- a/src/minecraft/biomesoplenty/itemblocks/ItemBlockGrave.java +++ b/src/minecraft/biomesoplenty/itemblocks/ItemBlockGrave.java @@ -1,19 +1,132 @@ package biomesoplenty.itemblocks; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockGrave extends ItemBlock { + private Icon grave; + public ItemBlockGrave(int par1) { super(par1); setMaxDamage(0); setHasSubtypes(true); } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) + { + grave = iconRegister.registerIcon("biomesoplenty:item_grave"); + } + + @Override + public Icon getIconFromDamage(int meta) + { + return grave; + } @Override public int getMetadata(int meta) { return meta & 15; } + + @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[itemID].blockMaterial.isSolid()) + return false; + else if (world.canPlaceEntityOnSide(itemID, x, y, z, false, side, player, itemstack)) + { + Block block = Block.blocksList[itemID]; + int o = ((MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + int fO; + + if (o == 0 || o == 2) + { + fO = 0; + } + else + { + fO = 2; + } + + if (placeGrave(itemstack, player, block, world, x, y, z, fO, side, par8, par9, par10)) return true; + } + + return false; + } + + private boolean placeGrave(ItemStack itemstack, EntityPlayer player, Block block, World world, int x, int y, int z, int meta, int side, float par8, float par9, float par10) + { + if (world.isAirBlock(x, y + 1, z)) + { + int k1 = Block.blocksList[itemID].onBlockPlaced(world, x, y, z, side, par8, par9, par10, meta); + int k2 = Block.blocksList[itemID].onBlockPlaced(world, x, y, z, side, par8, par9, par10, meta + 1); + + if (placeBlockAt(itemstack, player, world, x, y, z, side, par8, par9, par10, k1) && placeBlockAt(itemstack, player, world, x, y + 1, z, side, par8, par9, par10, k2)) + { + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + --itemstack.stackSize; + } + + return true; + } + + return false; + } }