@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack item = playerIn.getHeldItem(hand); TileEntity tileEntity = worldIn.getTileEntity(pos); if(tileEntity instanceof BaseTileEntityHarshenSingleItemInventory) if(((BaseTileEntityHarshenSingleItemInventory)tileEntity).canAddItem() && Item.getItemFromBlock(Blocks.AIR) != item.getItem()) { int i = item.getCount() - 1; if(((BaseTileEntityHarshenSingleItemInventory)tileEntity).setItem(item)) playerIn.setHeldItem(hand, new ItemStack(item.getItem(), i, item.getMetadata(), item.serializeNBT())); } else if (!((BaseTileEntityHarshenSingleItemInventory) tileEntity).canAddItem()) { ItemStack stack = ((BaseTileEntityHarshenSingleItemInventory)tileEntity).getItem(); ((BaseTileEntityHarshenSingleItemInventory)tileEntity).setItemAir(); if(!worldIn.isRemote) InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY() + 0.7f, pos.getZ(), stack); } return true; }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityInfusionAltar te = (TileEntityInfusionAltar) world.getTileEntity(pos); IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i = 0; i < cap.getSlots(); ++i) { ItemStack itemstack = cap.getStackInSlot(i); if (!itemstack.isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityAnimusMaterializer te = (TileEntityAnimusMaterializer) world.getTileEntity(pos); IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i = 0; i < cap.getSlots(); ++i) { ItemStack itemstack = cap.getStackInSlot(i); if (!itemstack.isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityAnalyzer te = (TileEntityAnalyzer) world.getTileEntity(pos); if (!te.getStack(0).isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.getStack(0).copy()); } if (!te.getStack(1).isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.getStack(1).copy()); } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityArcaneTransfigurationTable te = (TileEntityArcaneTransfigurationTable) world.getTileEntity(pos); IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i = 0; i < cap.getSlots(); ++i) { ItemStack itemstack = cap.getStackInSlot(i); if (!itemstack.isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityInfernalSmelter te = (TileEntityInfernalSmelter) world.getTileEntity(pos); IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i = 0; i < cap.getSlots(); ++i) { ItemStack itemstack = cap.getStackInSlot(i); if (!itemstack.isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityWritingDesk te = (TileEntityWritingDesk) world.getTileEntity(pos); IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i = 0; i < cap.getSlots(); ++i) { ItemStack itemstack = cap.getStackInSlot(i); if (!itemstack.isEmpty()) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof CraftiniumForgeTileEntity) { CraftiniumForgeTileEntity entity = (CraftiniumForgeTileEntity) tileEntity; InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getFuel().getStackInSlot(0)); InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getOutput().getStackInSlot(0)); InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getInput().getStackInSlot(0)); if(!entity.isBrokenByCreative()) { List<ItemStack> drops = this.getDrops(worldIn, pos, state, 0); for (ItemStack stack : drops) { spawnAsEntity(worldIn, pos, stack); } } worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
@Nullable public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { if(inventorySlots.get(slotId) != null) { if(!inventorySlots.get(slotId).getStack().isEmpty()) { if(!player.world.isRemote) { InventoryHelper.spawnItemStack(player.world, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, inventorySlots.get(slotId).getStack()); } player.world.playSound(null, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); inventorySlots.get(slotId).putStack(ItemStack.EMPTY); inventory.setInventorySlotContents(slotId, ItemStack.EMPTY); inventory.markDirty(); } } return super.slotClick(slotId, dragType, clickTypeIn, player); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tile = worldIn.getTileEntity(pos); if (tile != null) { IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if (itemHandler != null) { for (int i = 0; i < itemHandler.getSlots(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); if (!stack.isEmpty()) { InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack); } } } } super.breakBlock(worldIn, pos, state); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity!=null && tileentity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler inventory = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i=0; i<inventory.getSlots(); i++) { ItemStack itemstack = inventory.getStackInSlot(i); if (!itemstack.isEmpty()) { InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } worldIn.updateComparatorOutputLevel(pos, this); } super.breakBlock(worldIn, pos, state); }
/** * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated */ public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
@Override public void killMinecart(DamageSource source) { this.setDead(); if (this.getEntityWorld().getGameRules().getBoolean("doEntityDrops")) { ItemStack itemstack = new ItemStack(Items.MINECART, 1); if (this.getName() != null) { itemstack.setStackDisplayName(this.getName()); } this.entityDropItem(itemstack, 0.0F); if (this.dropContentsWhenDead) { if(!getEntityWorld().isRemote)InventoryHelper.dropInventoryItems(this.getEntityWorld(), this, this); } entityDropItem(new ItemStack(ModBlocks.crystalChest, 1, getChestType().ordinal()), 0.0F); } }
@Override protected void handle(final EntityPlayer sender) { if (sender.inventoryContainer != null) { ItemStack stack = sender.openContainer.getSlot(slotID).getStack(); if (stack.getItem() == QBarItems.MULTIBLOCK_BOX && stack.hasTagCompound()) { NonNullList<ItemStack> items = NonNullList .withSize(stack.getTagCompound().getTagList("Items", 10).tagCount(), ItemStack.EMPTY); ItemUtils.loadAllItems(stack.getTagCompound(), items); for (ItemStack item : items) { if (!sender.addItemStackToInventory(item)) InventoryHelper.spawnItemStack(sender.world, sender.posX, sender.posY, sender.posZ, item); } stack.setCount(0); } } }
@Override public void breakBlock(final World w, final BlockPos pos, final IBlockState state) { final ITileMultiblock tile = (ITileMultiblock) w.getTileEntity(pos); if (tile != null) { if (tile.isCore()) { if (tile instanceof IInventory) { InventoryHelper.dropInventoryItems(w, pos, (IInventory) tile); w.updateComparatorOutputLevel(pos, this); } this.dropBlockAsItem(w, pos, state, 0); } else tile.breakCore(); } super.breakBlock(w, pos, state); }
@Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (world.isRemote) return null; IFluidHandler h = FluidUtil.getFluidHandler(world, pos, side); if (h != null) { for (Entry<FluidStack, ItemStack> e : fluidToItem.entrySet()) { FluidStack drain = h.drain(new FluidStack(e.getKey(), e.getKey().amount), false); if (e.getKey().isFluidStackIdentical(drain)) { h.drain(drain, true); ItemStack s = e.getValue().copy(); stack.shrink(1); player.setHeldItem(hand, stack); if (!player.inventory.addItemStackToInventory(s)) { InventoryHelper.spawnItemStack(world, player.posX, player.posY, player.posZ, s); } player.inventoryContainer.detectAndSendChanges(); return EnumActionResult.SUCCESS; } } } return null; }
public void ejectContents(boolean ejectFuel) { if(ejectFuel) { InventoryHelper.spawnItemStack(world, getPos().getX(), getPos().getY(), getPos().getZ(), this.getStackInSlot(FUEL_SLOT)); this.setInventorySlotContents(FUEL_SLOT, ItemStack.EMPTY); } else { for(int i = TOOL_SLOT; i < this.getSizeInventory(); i++) { if(i == OUTPUT_SLOT && cookingTimer > 0) { continue; } InventoryHelper.spawnItemStack(world, getPos().getX(), getPos().getY(), getPos().getZ(), this.getStackInSlot(i)); this.setInventorySlotContents(i, ItemStack.EMPTY); } } }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityTeleporter tileEntityTeleporter = (TileEntityTeleporter)world.getTileEntity(pos); if (tileEntityTeleporter != null) { tileEntityTeleporter.removeFromNetwork(); if (tileEntityTeleporter.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler handler = tileEntityTeleporter.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); ItemStack stack = handler.getStackInSlot(0); if (!stack.isEmpty()) { stack = stack.copy(); InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), stack); } } } // super _must_ be called last because it removes the tile entity super.breakBlock(world, pos, state); }
public void breakBlockRecall(World world, World nextWorld, BlockPos pos, BlockPos nextPos, IBlockState state, EntityPlayerMP player) { TileEntityTeleporter tileEntityTeleporter = (TileEntityTeleporter)world.getTileEntity(pos); if (tileEntityTeleporter != null) { tileEntityTeleporter.removeFromNetwork(); if (tileEntityTeleporter.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler handler = tileEntityTeleporter.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); ItemStack stack = handler.getStackInSlot(0); if (!stack.isEmpty()) { InventoryHelper.spawnItemStack(nextWorld, nextPos.getX(), nextPos.getY()+1, nextPos.getZ(), stack); } } } InventoryHelper.spawnItemStack(nextWorld, nextPos.getX(), nextPos.getY()+1, nextPos.getZ(), new ItemStack(ModBlocks.TELEPORTER,1,getMetaFromState(state))); world.setBlockToAir(pos); while(world.getTileEntity(pos) != null) { world.removeTileEntity(pos); } }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityCrusher) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityCrusher) tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityAlloy) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityAlloy) tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityMelter) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMelter) tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntitySplitter) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntitySplitter) tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
private void doQuickMove(int howMany, EntityPlayerMP player, ItemResource targetResource, ItemStorageListener listener) { if(howMany == 0) return; int toMove = 0; try { toMove = LogisticsService.ITEM_SERVICE.executor.submit( () -> { return (int) listener.takeUpTo(targetResource, howMany, false, null); }, true).get(); } catch (Exception e) { Log.error("Error in open container item handling", e); } if(toMove == 0) return; ItemStack newStack = targetResource.sampleItemStack(); newStack.setCount(toMove); player.inventory.addItemStackToInventory(newStack); if(!newStack.isEmpty()) { InventoryHelper.spawnItemStack(player.world, player.posX, player.posY, player.posZ, newStack);; } }
public boolean checkForDrop(World world, BlockPos pos, IBlockState state) { if (this.canPlaceAt(world, pos, EnumFacing.UP)) { return true; } else { if (world.getBlockState(pos).getBlock() == this) { TileEntity te = world.getTileEntity(pos); if (te instanceof OfferingBoxTileEntity) { InventoryHelper.dropInventoryItems(world, pos, (OfferingBoxTileEntity) te); } this.dropBlockAsItem(world, pos, state, 0); world.setBlockToAir(pos); } return false; } }
@Override public void breakBlock(World par1World, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntityCrystallizer tileentitycrystallizer = (TileEntityCrystallizer)par1World.getTileEntity(pos); if (tileentitycrystallizer != null) { InventoryHelper.dropInventoryItems(par1World, pos, tileentitycrystallizer); par1World.updateComparatorOutputLevel(pos, this);; } } super.breakBlock(par1World, pos, state); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityLoom) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityLoom)tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if(!keepInventory) { TileEntity tileentity = world.getTileEntity(pos); if(tileentity instanceof TileEntityFurnace) { InventoryHelper.dropInventoryItems(world, pos, (TileEntityFurnace)tileentity); world.updateComparatorOutputLevel(pos, this); } } super.breakBlock(world, pos, state); }
@Override public void breakBlock(World world, BlockPos pos, IBlockState state) { // Drop any items we have if necessary TileEntity te = world.getTileEntity(pos); if (te != null && te instanceof IInventory) { InventoryHelper.dropInventoryItems(world, pos, (IInventory)te); } super.breakBlock(world, pos, state); world.removeTileEntity(pos); }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { notifyNeighbors(worldIn, pos, state); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityMinecoprocessor) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMinecoprocessor) tileentity); } super.breakBlock(worldIn, pos, state); }
public void dropItems() { for (ItemStackHandler items : new ItemStackHandler[]{input, storage, output}) { for (int i = 0; i < items.getSlots(); ++i) { ItemStack stack = items.getStackInSlot(i); if (!stack.isEmpty()) { InventoryHelper.spawnItemStack(this.getWorld(), pos.getX(), pos.getY(), pos.getZ(), stack); } } } }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { BaseTileEntityHarshenSingleItemInventory te = (BaseTileEntityHarshenSingleItemInventory) worldIn.getTileEntity(pos); IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if(!worldIn.isRemote) if(isBreakNBT(handler.getStackInSlot(0))) { ItemStackHandler handlerStack = new ItemStackHandler(1); handlerStack.setStackInSlot(0, handler.getStackInSlot(0)); ItemStack stack = new ItemStack(this); String stackName = ""; NBTTagCompound nbttagcompound = new NBTTagCompound(); if(handlerStack.getStackInSlot(0).getItem() != Items.AIR) { nbttagcompound.setTag("ItemStackHandler", handlerStack.serializeNBT()); stackName += I18n.translateToLocal(handlerStack.getStackInSlot(0).getItem().getUnlocalizedName() + ".name"); } addNBT(handler.getStackInSlot(0), nbttagcompound, worldIn, pos); if(!nbttagcompound.getKeySet().isEmpty() || !handlerStack.getStackInSlot(0).isEmpty()) { stack.setTagCompound(nbttagcompound); stackName += extraName(nbttagcompound, handlerStack.getStackInSlot(0).getItem() != Items.AIR); stackName = stackName.equals("")? "�r" + getLocalizedName() : "�r" + getLocalizedName() + " (" + stackName + ")"; stack.setStackDisplayName(stackName); } if(!creativeBreakMap.containsKey(pos) || !creativeBreakMap.get(pos)) worldIn.spawnEntity(new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack)); creativeBreakMap.remove(pos); } else InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(0)); super.breakBlock(worldIn, pos, state); }
@Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { if(player.capabilities.isCreativeMode) { super.onBlockHarvested(worldIn, pos, state, player); return; } ItemStack item = player.inventory.getCurrentItem(); if(item.getItem() instanceof SoulHarsherPickaxe) { if(!worldIn.isRemote) { InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(HarshenItems.HARSHEN_SOUL_FRAGMENT)); super.onBlockHarvested(worldIn, pos, state, player); player.sendMessage((ITextComponent) new TextComponentTranslation("message.success")); } } else { player.attackEntityFrom(DamageSource.MAGIC, 21); if(!worldIn.isRemote) { player.sendMessage((ITextComponent) new TextComponentTranslation("message.failed")); } } }
@Override protected void finishedTicking() { handler.setStackInSlot(0, new ItemStack(Blocks.AIR)); if(world.isRemote || workingRecipe == null) return; BlockPos pos = workingRecipe.getPositionOfRitual(); if(workingRecipe.lightning()) world.addWeatherEffect(new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true)); InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), workingRecipe.getOutput().copy()); HarshenNetwork.sendToPlayersInWorld(world, new MessagePacketKillAllWithTag(workingRecipe.getTag())); workingRecipe = null; }
public void deactivate() { HarshenNetwork.sendToPlayersInWorld(world, new MessagePacketUpdateCauldron(pos, false, -1)); if(isLeader()) for(int i = 0; i < handler.getSlots(); i++) { if(!world.isRemote) InventoryHelper.spawnItemStack(world, pos.getX() + MathHelper.clamp(new Random().nextInt(getSize() < 1 ? 1 : getSize()), 0.5f, getSize() - 0.5f), pos.getY() + getSize(), pos.getZ() + MathHelper.clamp(new Random().nextInt(getSize() < 1 ? 1 : getSize()), 0.5f, getSize() - 0.5f), handler.getStackInSlot(i)); handler.setStackInSlot(i, ItemStack.EMPTY); } controller = null; }
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntityChalkBase te = (TileEntityChalkBase)worldIn.getTileEntity(pos); if(te == null)return false; if(hand == EnumHand.OFF_HAND)return false; if(heldItem==null&&te.hasItem()) { if(worldIn.isRemote) { te.markDirty(); te.removeStackFromSlot(0); return true; } InventoryHelper.dropInventoryItems(worldIn,playerIn,te); te.setInventorySlotContents(0,null); return true; } else if(!worldIn.isRemote&&heldItem!=null&&heldItem.getItem()!= ModItems.defaultChalkItem &&!te.hasItem()&&te.isItemValidForSlot(0,heldItem)) { ItemStack newItem = heldItem.copy(); newItem.stackSize = 1; heldItem.stackSize--; if(heldItem.stackSize<1)heldItem=null; te.setInventorySlotContents(0,newItem); te.updateRendering(); return true; } return false; }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntityChalkBase te = (TileEntityChalkBase)worldIn.getTileEntity(pos); InventoryHelper.dropInventoryItems(worldIn, pos, te); for(DefaultDustSymbol dust : te.dustList) { te.dustList.remove(dust); for (DustIOSymbol ioDustChild : dust.ioDusts) { ioDustChild.removeConnections(); } } super.breakBlock(worldIn, pos, state); }
public void breakBlock(){ if(!this.world.isRemote){ List<IItemHandler> cached = new ArrayList<>(); for(EnumFacing side : EnumFacing.values()){ IItemHandler inv = this.getInventory(side); if(inv != null && !cached.contains(inv)){ for(int i = 0; i < inv.getSlots(); i++){ InventoryHelper.spawnItemStack(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), inv.getStackInSlot(i)); } cached.add(inv); } } cached.clear(); } }