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;
}
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;
}
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());
}
}
}
}
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
}
}
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();
}
}
}
Aggregations