Search in sources :

Example 1 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project SilentGems by SilentChaos512.

the class ModelGemArmor method render.

@Override
public void render(@Nonnull Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    EntityEquipmentSlot slot = bipedHead.showModel ? EntityEquipmentSlot.HEAD : !bipedBody.showModel ? EntityEquipmentSlot.FEET : bipedLeftLeg.showModel && bipedRightLeg.showModel ? EntityEquipmentSlot.LEGS : EntityEquipmentSlot.CHEST;
    switch(slot) {
        case HEAD:
            break;
        case CHEST:
            bipedBody = chestplate;
            chestplate.showModel = true;
            break;
        case LEGS:
            bipedBody = belt;
            belt.showModel = true;
            bipedLeftLeg = leftLeg;
            leftLeg.showModel = true;
            bipedRightLeg = rightLeg;
            rightLeg.showModel = true;
            break;
        case FEET:
            bipedLeftLeg = leftBoot;
            leftBoot.showModel = true;
            bipedRightLeg = rightBoot;
            leftBoot.showModel = true;
            break;
    }
    GlStateManager.enableBlend();
    super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
    GlStateManager.disableBlend();
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot)

Example 2 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project EnderIO by SleepyTrousers.

the class ContainerWiredCharger method addMachineSlots.

@Override
protected void addMachineSlots(@Nonnull InventoryPlayer playerInv) {
    addSlotToContainer(new InventorySlot(getInv(), 0, 75, 28));
    addSlotToContainer(new InventorySlot(getInv(), 1, 126, 28));
    baubles = BaublesUtil.instance().getBaubles(playerInv.player);
    if (baubles != null && BaublesUtil.WhoAmI.whoAmI(playerInv.player.world) == BaublesUtil.WhoAmI.SPCLIENT) {
        baubles = new ShadowInventory(baubles);
    }
    if (hasBaublesSlots() && (baubles == null)) {
        baubles = new ArrayInventory(getBaublesSize()) {

            @Override
            public boolean isItemValidForSlot(int i, @Nonnull ItemStack itemstack) {
                return false;
            }

            @Override
            @Nonnull
            public ItemStack getStackInSlot(int slot) {
                return new ItemStack(Blocks.BARRIER);
            }

            @Override
            @Nonnull
            public ItemStack decrStackSize(int slot, int amount) {
                return ItemStack.EMPTY;
            }

            @Override
            @Nonnull
            public ItemStack removeStackFromSlot(int index) {
                return ItemStack.EMPTY;
            }
        };
    }
    int baublesOffset = 196;
    for (final EntityEquipmentSlot slt : EntityEquipmentSlot.values()) {
        if (slt.getSlotType() == Type.ARMOR) {
            addSlotToContainer(new Slot(playerInv, 36 + slt.getIndex(), 6, 66 - slt.getIndex() * 18) {

                @Override
                public int getSlotStackLimit() {
                    return 1;
                }

                @Override
                public boolean isItemValid(@Nonnull ItemStack par1ItemStack) {
                    if (par1ItemStack.isEmpty()) {
                        return false;
                    }
                    return par1ItemStack.getItem().isValidArmor(par1ItemStack, slt, playerInv.player);
                }

                @Override
                @SideOnly(Side.CLIENT)
                public String getSlotTexture() {
                    return ItemArmor.EMPTY_SLOT_NAMES[slt.getIndex()];
                }
            });
        }
    }
    addSlotToContainer(new Slot(playerInv, 40, 6, 12 + 18 * 4) {

        @Override
        @Nullable
        @SideOnly(Side.CLIENT)
        public String getSlotTexture() {
            return "minecraft:items/empty_armor_slot_shield";
        }
    });
    if (hasBaublesSlots()) {
        for (int i = 0; i < baubles.getSizeInventory(); i++) {
            addSlotToContainer(new Slot(baubles, i, baublesOffset, 12 + i * 18) {

                @Override
                public boolean isItemValid(@Nonnull ItemStack par1ItemStack) {
                    return inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
                }

                @Override
                public boolean canTakeStack(@Nonnull EntityPlayer playerIn) {
                    ItemStack stackInSlot = inventory.getStackInSlot(getSlotIndex());
                    if (stackInSlot.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) {
                        return false;
                    }
                    return super.canTakeStack(playerIn);
                }
            });
        }
    }
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) Nonnull(javax.annotation.Nonnull) ArrayInventory(com.enderio.core.common.util.ArrayInventory) InventorySlot(crazypants.enderio.machines.machine.tank.InventorySlot) ShadowInventory(crazypants.enderio.util.ShadowInventory) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Point(java.awt.Point) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) GhostSlot(com.enderio.core.client.gui.widget.GhostSlot) InventorySlot(crazypants.enderio.machines.machine.tank.InventorySlot) GhostBackgroundItemSlot(com.enderio.core.client.gui.widget.GhostBackgroundItemSlot) Slot(net.minecraft.inventory.Slot) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 3 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project EnderIO by SleepyTrousers.

the class UpgradeRenderDispatcher method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull AbstractClientPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    NNList.of(EntityEquipmentSlot.class).apply(new Callback<EntityEquipmentSlot>() {

        @Override
        public void apply(@Nonnull EntityEquipmentSlot slot) {
            ItemStack item = player.getItemStackFromSlot(slot);
            if (item.getItem() instanceof IDarkSteelItem) {
                for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
                    if (upgrade instanceof IHasPlayerRenderer && upgrade.hasUpgrade(item)) {
                        ((IHasPlayerRenderer) upgrade).getRender().doRenderLayer(renderPlayer, slot, item, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
                    }
                }
            }
            if (item.getItem() instanceof IHasPlayerRenderer) {
                ((IHasPlayerRenderer) item.getItem()).getRender().doRenderLayer(renderPlayer, slot, item, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
            }
        }
    });
    IInventory baubles = BaublesUtil.instance().getBaubles(player);
    if (baubles != null) {
        for (int i = 0; i < baubles.getSizeInventory(); i++) {
            ItemStack piece = baubles.getStackInSlot(i);
            if (piece.getItem() instanceof IHasPlayerRenderer) {
                ((IHasPlayerRenderer) piece.getItem()).getRender().doRenderLayer(renderPlayer, null, piece, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) IHasPlayerRenderer(crazypants.enderio.api.upgrades.IHasPlayerRenderer) ItemStack(net.minecraft.item.ItemStack) IDarkSteelUpgrade(crazypants.enderio.api.upgrades.IDarkSteelUpgrade) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem)

Example 4 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project EnderIO by SleepyTrousers.

the class DarkSteelController method onPlayerTick.

@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    if (event.phase == Phase.START && !player.isSpectator()) {
        // boots
        updateStepHeightAndFallDistance(player);
        // leggings
        SpeedController.updateSpeed(player);
        NNList.of(EntityEquipmentSlot.class).apply(new Callback<EntityEquipmentSlot>() {

            @Override
            public void apply(@Nonnull EntityEquipmentSlot slot) {
                ItemStack item = player.getItemStackFromSlot(slot);
                if (item.getItem() instanceof IDarkSteelItem) {
                    for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
                        if (upgrade.hasUpgrade(item)) {
                            upgrade.onPlayerTick(item, (IDarkSteelItem) item.getItem(), player);
                        }
                    }
                }
            }
        });
    }
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) IDarkSteelUpgrade(crazypants.enderio.api.upgrades.IDarkSteelUpgrade) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with EntityEquipmentSlot

use of net.minecraft.inventory.EntityEquipmentSlot in project minecolonies by Minecolonies.

the class EntityAIWorkSmelter method getMaterialAndAmount.

/**
 * Get the material and amount of a certain stack.
 * @param stack the stack.
 * @return a tuple of the stack and the amount.
 */
private static Tuple<ItemStack, Integer> getMaterialAndAmount(final ItemStack stack) {
    int amount = 1;
    ItemStack material = ItemStackUtils.EMPTY;
    if (stack.getItem() instanceof ItemSword) {
        material = Item.ToolMaterial.valueOf(((ItemSword) stack.getItem()).getToolMaterialName()).getRepairItemStack();
    } else if (stack.getItem() instanceof ItemTool) {
        material = Item.ToolMaterial.valueOf(((ItemTool) stack.getItem()).getToolMaterialName()).getRepairItemStack();
    } else if (stack.getItem() instanceof ItemArmor) {
        material = ((ItemArmor) stack.getItem()).getArmorMaterial().getRepairItemStack();
        final EntityEquipmentSlot eq = ((ItemArmor) stack.getItem()).armorType;
        if (eq == EntityEquipmentSlot.CHEST) {
            amount = CHEST_MAT_AMOUNT;
        } else if (eq == EntityEquipmentSlot.LEGS) {
            amount = LEGS_MAT_AMOUNT;
        } else if (eq == EntityEquipmentSlot.HEAD) {
            amount = HEAD_MAT_AMOUNT;
        } else if (eq == EntityEquipmentSlot.FEET) {
            amount = FEET_MAT_AMOUNT;
        }
    }
    return new Tuple<>(material, amount);
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) Tuple(net.minecraft.util.Tuple)

Aggregations

EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)23 ItemStack (net.minecraft.item.ItemStack)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ArrayList (java.util.ArrayList)3 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 ItemArmor (net.minecraft.item.ItemArmor)3 BlockPos (net.minecraft.util.math.BlockPos)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IGuiTile (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile)2 IGuiItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem)2 IDarkSteelItem (crazypants.enderio.api.upgrades.IDarkSteelItem)2 IDarkSteelUpgrade (crazypants.enderio.api.upgrades.IDarkSteelUpgrade)2 UUID (java.util.UUID)2 Nullable (javax.annotation.Nullable)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 Item (net.minecraft.item.Item)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)1 TileEntityAlloySmelter (blusunrize.immersiveengineering.common.blocks.stone.TileEntityAlloySmelter)1