public void setSoupType(World world, int x, int y, int z, TileFilledSoupPan pan, SoupType type) { if (pan == null) return; pan.setType(type); pan.setRemainByte((byte) 8); world.playAuxSFX(2005, x, y, z, 0); world.markBlockForUpdate(x, y, z); }
public void reduceRemain(World world, int x, int y, int z, TileFilledSoupPan pan) { if (!world.isRemote && pan != null) { int rem = pan.getRemainByte(); if (rem > 1) { pan.setRemainByte((byte) (rem - 1)); } else { world.removeTileEntity(x, y, z); world.setBlock(x, y, z, DCsAppleMilk.emptyPanGaiden, 0, 2); } world.markBlockForUpdate(x, y, z); } }
@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(); } } } }
@Override public void onBlockPlacedBy( World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int playerFacing = MathHelper.floor_double((double) ((par5EntityLivingBase.rotationYaw * 4F) / 360F) + 0.5D) & 3; boolean facing = false; if (playerFacing == 1 || playerFacing == 3) { facing = true; } TileEntity tile = par1World.getTileEntity(par2, par3, par4); if (tile instanceof TileFilledSoupPan && par6ItemStack != null && par6ItemStack.getItem() == Item.getItemFromBlock(DCsAppleMilk.filledSoupPan)) { ((TileFilledSoupPan) tile).setDirection(facing); } }