I am currently using onItemUse()
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
IBlockState block = worldIn.getBlockState(pos);
// CHECK AND SEE IF THE PLAYER IS HOLDING A DUST IN THEIR OFF HAND
System.out.println("Pan right clicked!");
if (block == Blocks.WATER.getDefaultState() || block == Blocks.FLOWING_WATER.getDefaultState()
|| block == Blocks.GRASS.getDefaultState()) {
System.out.println("Used on water");
if (RecipeHolder.getPanningRecipe(player.getHeldItemOffhand()).get(0) != ItemStack.EMPTY) {
System.out.println("Recipe found!");
ItemStack offHand = player.getHeldItemOffhand();
List<ItemStack> recipe = RecipeHolder.getPanningRecipe(offHand);
// The player has enough of the dust in their hand
if (offHand.getCount() >= recipe.get(0).getCount()) {
System.out.println("Recipe input confirmed!");
offHand.shrink(recipe.get(0).getCount());
for (int i = 1; i < recipe.size(); i++) {
worldIn.spawnEntity(
new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), recipe.get(i)));
}
return EnumActionResult.SUCCESS;
}
}
}
}
return EnumActionResult.FAIL;
}
Grass is in there so I could test the other functionality, and it works, but water does not work. I am assuming this is because you interact through water so it never detects the water block but what is behind it. So how would I check for water?
Thanks, James