From 71adfa235811387b691559c2796be4c5bfb70c67 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Tue, 16 Jul 2013 18:39:11 -0400 Subject: [PATCH] Fixed Fabric of Reality Replacement Bug Fixed the bug in BlockDimWall that would cause Fabric of Reality to replace itself when you right-clicked to place FoR against an FoR surface. This happened because we considered FoR valid for replacing FoR since it's a cube solid. Now we have an extra check to prevent that. It was a waste of blocks to have them sort of eat each other up! Also cleaned up some of the code in BlockDimWall. --- .../mod_pocketDim/blocks/BlockDimWall.java | 61 +++++++------------ 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/blocks/BlockDimWall.java b/StevenDimDoors/mod_pocketDim/blocks/BlockDimWall.java index 37910d8..1953b8c 100644 --- a/StevenDimDoors/mod_pocketDim/blocks/BlockDimWall.java +++ b/StevenDimDoors/mod_pocketDim/blocks/BlockDimWall.java @@ -22,37 +22,39 @@ import net.minecraft.world.World; public class BlockDimWall extends Block { - private Icon[] blockIcon= new Icon[2]; - public BlockDimWall(int i, int j, Material par2Material) + private static final float SUPER_HIGH_HARDNESS = 10000000000000F; + private Icon[] blockIcon = new Icon[2]; + + public BlockDimWall(int blockID, int j, Material par2Material) { - super(i, Material.ground); + super(blockID, Material.ground); setTickRandomly(true); this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab); } public float getBlockHardness(World par1World, int par2, int par3, int par4) { - if(par1World.getBlockMetadata(par2, par3, par4)==0) + if (par1World.getBlockMetadata(par2, par3, par4) == 0) { return this.blockHardness; } else { - return 10000000000000F; + return SUPER_HIGH_HARDNESS; } } public void registerIcons(IconRegister par1IconRegister) { this.blockIcon[0] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()); - this.blockIcon[1] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"perm"); + this.blockIcon[1] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2() + "perm"); } @SideOnly(Side.CLIENT) @Override public Icon getIcon(int par1, int par2) { - if(par2==1) + if (par2 == 1) { return blockIcon[par2]; } @@ -68,6 +70,7 @@ public class BlockDimWall extends Block return metadata; } + @SuppressWarnings({ "rawtypes", "unchecked" }) @SideOnly(Side.CLIENT) public void getSubBlocks(int unknown, CreativeTabs tab, List subItems) { @@ -91,50 +94,30 @@ public class BlockDimWall extends Block /** * replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable. */ - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if(entityPlayer.getCurrentEquippedItem()!=null) + if (entityPlayer.getCurrentEquippedItem() != null) { Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem(); - if(!(playerEquip instanceof ItemBlock)) + if (playerEquip instanceof ItemBlock) { - return false; - } - else - { - Block block= Block.blocksList[playerEquip.itemID]; - if(!Block.isNormalCube(playerEquip.itemID)) + Block block = Block.blocksList[playerEquip.itemID]; + if (!Block.isNormalCube(playerEquip.itemID) || block instanceof BlockContainer || block.blockID == this.blockID) { return false; } - if(block instanceof BlockContainer) + if (!world.isRemote) { - return false; + if (!entityPlayer.capabilities.isCreativeMode) + { + entityPlayer.getCurrentEquippedItem().stackSize--; + } + world.setBlock(x, y, z, entityPlayer.getCurrentEquippedItem().itemID, entityPlayer.getCurrentEquippedItem().getItemDamage(), 0); } - } - - - if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock) - { - if(par1World.isRemote) - { - return true; - } - - if(!entityPlayer.capabilities.isCreativeMode) - { - entityPlayer.getCurrentEquippedItem().stackSize--; - } - par1World.setBlock(par2, par3, par4, entityPlayer.getCurrentEquippedItem().itemID, entityPlayer.getCurrentEquippedItem().getItemDamage(),0); return true; } - } - else - { - return false; - } - return false; + return false; } }