@Override public boolean onBlockActivated( World world, int par2, int par3, int par4, EntityPlayer player, int par6, float par7, float par8, float par9) { ItemStack hold = player.inventory.getCurrentItem(); int currentMeta = world.getBlockMetadata(par2, par3, par4); Block bottomBlock = world.getBlock(par2, par3 - 1, par4); TileEntity tile = world.getTileEntity(par2, par3, par4); TileFilledSoupPan pan = null; if (tile != null && tile instanceof TileFilledSoupPan) { pan = (TileFilledSoupPan) tile; } else { return false; } if (hold == null) { return false; } else { // old recipe api ItemStack chocolate = RecipeRegisterManager.chocoRecipe.getOutput(hold); // new recipe IFondueRecipe food = RecipeRegisterManager.fondueRecipe.getRecipe(hold, pan.getType()); if (pan.getType() == SoupType.CHOCO && chocolate != null && chocolate.getItem() != null) { this.getRecipeFood(world, par2, par3, par4, player, hold, chocolate); this.reduceRemain(world, par2, par3, par4, pan); return true; } else if (food != null && food.getOutput() != null && food.getType() == pan.getType()) { this.getRecipeFood(world, par2, par3, par4, player, hold, food.getOutput()); this.reduceRemain(world, par2, par3, par4, pan); return true; } else { if (world.isRemote) player.addChatMessage( new ChatComponentText( StatCollector.translateToLocal("dc.panMessage.noFondueRecipe"))); return true; } } }
// change soup type @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (world.isRemote || !this.onFurnace(world, x, y, z) || entity == null) return; TileEntity tile = world.getTileEntity(x, y, z); if (tile == null || !(tile instanceof TileFilledSoupPan)) return; TileFilledSoupPan pan = (TileFilledSoupPan) tile; boolean flag = false; if (entity instanceof EntityItem) { ItemStack input = ((EntityItem) entity).getEntityItem(); IFondueSource recipe = RecipeRegisterManager.fondueRecipe.getType(input); if (recipe != null && recipe.beforeType() == pan.getType() && recipe.matches(input)) { this.setSoupType(world, x, y, z, pan, recipe.afterType()); world.playSoundAtEntity(entity, "random.pop", 0.4F, 1.8F); ItemStack container = null; if (FluidContainerRegistry.isFilledContainer(input)) { container = FluidContainerRegistry.drainFluidContainer(input); } else { container = input.getItem().getContainerItem(input); } if (container != null) { EntityItem cont = new EntityItem(world, x, y + 1.0D, z, container); world.spawnEntityInWorld(cont); } if (input.stackSize > 1) { ((EntityItem) entity).getEntityItem().stackSize--; } else { entity.setDead(); } } } }