--- ../src_base/common/net/minecraft/src/ItemBlock.java +++ ../src_work/common/net/minecraft/src/ItemBlock.java @@ -14,6 +14,7 @@ super(par1); this.blockID = par1 + 256; this.setIconIndex(Block.blocksList[par1 + 256].getBlockTextureFromSide(2)); + isDefaultTexture = Block.blocksList[par1 + 256].isDefaultTexture; } /** @@ -36,7 +37,8 @@ { par7 = 1; } - else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID) + else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID + && (Block.blocksList[var11] == null || !Block.blocksList[var11].isBlockReplaceable(par3World, par4, par5, par6))) { if (par7 == 0) { @@ -85,14 +87,8 @@ { Block var12 = Block.blocksList[this.blockID]; - if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, this.blockID, this.getMetadata(par1ItemStack.getItemDamage()))) - { - if (par3World.getBlockId(par4, par5, par6) == this.blockID) - { - Block.blocksList[this.blockID].updateBlockMetadata(par3World, par4, par5, par6, par7, par8, par9, par10); - Block.blocksList[this.blockID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer); - } - + if (placeBlockAt(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10)) + { par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var12.stepSound.getPlaceSound(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F); --par1ItemStack.stackSize; } @@ -118,7 +114,8 @@ { par5 = 1; } - else if (var8 != Block.vine.blockID && var8 != Block.tallGrass.blockID && var8 != Block.deadBush.blockID) + else if (var8 != Block.vine.blockID && var8 != Block.tallGrass.blockID && var8 != Block.deadBush.blockID + && (Block.blocksList[var8] == null || !Block.blocksList[var8].isBlockReplaceable(par1World, par2, par3, par4))) { if (par5 == 0) { @@ -183,4 +180,28 @@ { Block.blocksList[this.blockID].getSubBlocks(par1, par2CreativeTabs, par3List); } + + /** + * Called to actually place the block, after the location is determined + * and all permission checks have been made. + * + * @param stack The item stack that was used to place the block. This can be changed inside the method. + * @param player The player who is placing the block. Can be null if the block is not being placed by a player. + * @param side The side the player (or machine) right-clicked on. + */ + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + if (!world.setBlockAndMetadataWithNotify(x, y, z, this.blockID, this.getMetadata(stack.getItemDamage()))) + { + return false; + } + + if (world.getBlockId(x, y, z) == this.blockID) + { + Block.blocksList[this.blockID].updateBlockMetadata(world, x, y, z, side, hitX, hitY, hitZ); + Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player); + } + + return true; + } }