Search in sources :

Example 1 with IItemHandler

use of net.minecraftforge.items.IItemHandler in project ImmersiveEngineering by BluSunrize.

the class Utils method canInsertStackIntoInventory.

public static boolean canInsertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side) {
    if (stack != null && inventory != null && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
        IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
        ItemStack temp = ItemHandlerHelper.insertItem(handler, stack.copy(), true);
        if (temp == null || temp.stackSize < stack.stackSize)
            return true;
    }
    return false;
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IItemHandler

use of net.minecraftforge.items.IItemHandler in project ImmersiveEngineering by BluSunrize.

the class ApiUtils method canInsertStackIntoInventory.

public static boolean canInsertStackIntoInventory(TileEntity inventory, ItemStack stack, EnumFacing side) {
    if (stack != null && inventory != null && inventory.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
        IItemHandler handler = inventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
        ItemStack temp = ItemHandlerHelper.insertItem(handler, stack.copy(), true);
        if (temp == null || temp.stackSize < stack.stackSize)
            return true;
    }
    return false;
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IItemHandler

use of net.minecraftforge.items.IItemHandler in project ConvenientAdditions by Necr0.

the class EventHandlerSoulbound method onPlayerClone.

@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone e) {
    if (e.getEntityPlayer().getEntityWorld().isRemote || e.getEntityPlayer().getEntityWorld().getGameRules().getBoolean("keepInventory"))
        return;
    EntityPlayer original = e.getOriginal();
    EntityPlayer clone = e.getEntityPlayer();
    IItemHandler h = original.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
    for (int slot = 0; slot < h.getSlots(); slot++) {
        ItemStack stack = h.getStackInSlot(slot);
        if (stack != null && stack.getItem() instanceof ISoulbound && ((ISoulbound) stack.getItem()).isSoulbound(stack, original)) {
            IItemHandler h2 = clone.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
            ItemStack out = tryInsert(stack, h2);
            if (out == null) {
                h.extractItem(slot, 64, false);
            } else {
                stack.setCount(out.getCount());
            }
        }
    }
}
Also used : ISoulbound(convenientadditions.api.item.ISoulbound) IItemHandler(net.minecraftforge.items.IItemHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with IItemHandler

use of net.minecraftforge.items.IItemHandler in project VoodooCraft by Mod-DevCafeTeam.

the class TileDollPedestal method update.

/**
	 * Should be used to tick the doll inside of it.
	 */
@Override
public void update() {
    if (world.isRemote)
        return;
    IItemHandler tileinv = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    ItemStack stack = tileinv.getStackInSlot(0);
    if (stack != null && stack.getItem() instanceof ItemDoll) {
    //TODO Tick the doll inside
    }
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack) ItemDoll(mdc.voodoocraft.items.ItemDoll)

Example 5 with IItemHandler

use of net.minecraftforge.items.IItemHandler in project VoodooCraft by Mod-DevCafeTeam.

the class TileDollPedestalRender method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileDollPedestal te, double x, double y, double z, float partialTick, int destroyStage) {
    IItemHandler tileinv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    if (tileinv != null) {
        ItemStack stack = tileinv.getStackInSlot(0);
        if (stack != null) {
            GlStateManager.pushMatrix();
            {
                GlStateManager.translate(x, y, z);
                GlStateManager.translate(0.5, 0.95, 0.5);
                float angle = (((float) te.getWorld().getTotalWorldTime() + partialTick) / 20.0F) * (180F / (float) Math.PI);
                GlStateManager.rotate(angle, 0, 1, 0);
                Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.GROUND);
            }
            GlStateManager.popMatrix();
        }
    }
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IItemHandler (net.minecraftforge.items.IItemHandler)18 ItemStack (net.minecraft.item.ItemStack)16 TileEntity (net.minecraft.tileentity.TileEntity)3 ISoulbound (convenientadditions.api.item.ISoulbound)2 ItemDoll (mdc.voodoocraft.items.ItemDoll)2 TileDollPedestal (mdc.voodoocraft.tile.TileDollPedestal)2 TileEntityTeleporter (net.dyeo.teleporter.tileentity.TileEntityTeleporter)2 EntityItem (net.minecraft.entity.item.EntityItem)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)1 IEInventoryHandler (blusunrize.immersiveengineering.common.util.inventory.IEInventoryHandler)1 IIEInventory (blusunrize.immersiveengineering.common.util.inventory.IIEInventory)1 Nonnull (javax.annotation.Nonnull)1 Block (net.minecraft.block.Block)1 SoundType (net.minecraft.block.SoundType)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemBlock (net.minecraft.item.ItemBlock)1 BlockPos (net.minecraft.util.math.BlockPos)1 BlockSnapshot (net.minecraftforge.common.util.BlockSnapshot)1