Block detection with items

Published by Crayeights on
Status
Works as designed
Issue description

I am trying to create a plant the plant fully functions and I set it up so that the plant will grow if bone meal is used witch it detects the bone meal in the players hand then removes one from inventory on player that works, The issue come in if I place a block next to the plant it will do nothing do to the plant looking for the item on player know Ill have to hold shift to place this block. its acting like a Crafting table or Furnace in this case. I wonted to know if there is another way to do this?

if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_pearleye4.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_pearleye5.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_pearleye3.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_pearleye4.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_pearleye2.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_pearleye3.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_pearleye1.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_pearleye2.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_seedStage4.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_pearleye1.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_seedStage3.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_seedStage4.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_seedStage2.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_seedStage3.block.getDefaultState(), 3);
            }
            if ((new Object() {

                public boolean blockEquals(IBlockState a, IBlockState b) {
                    try {
                        return (a.getBlock() == b.getBlock()) && (a.getBlock().getMetaFromState(a) == b.getBlock().getMetaFromState(b));
                    } catch (Exception e) {
                        return (a.getBlock() == b.getBlock());
                    }
                }
            }.blockEquals((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))), mcreator_seedStage1.block.getDefaultState()))) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 15).getItem(), 15, (int) 1, null);
                world.setBlockState(new BlockPos((int) x, (int) y, (int) z), mcreator_seedStage2.block.getDefaultState(), 3);
            }
        }
    }
}
 

Issue comments