Search in sources :

Example 11 with ISkinDye

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinDye in project Armourers-Workshop by RiskyKen.

the class ContainerDyeTable method putDyesInSlots.

/**
 * Reads the output slot and adds dye bottles to their slots.
 */
private void putDyesInSlots() {
    if (tileEntity.getWorldObj().isRemote) {
        return;
    }
    ItemStack outStack = getSlot(45).getStack();
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(outStack);
    ISkinDye dye = skinPointer.getSkinDye();
    for (int i = 0; i < 8; i++) {
        if (dye.haveDyeInSlot(i)) {
            byte[] rgbt = dye.getDyeColour(i);
            ItemStack bottle = new ItemStack(ModItems.dyeBottle, 1, 1);
            PaintingHelper.setToolPaintColour(bottle, rgbt);
            PaintingHelper.setToolPaint(bottle, PaintType.getPaintTypeFormSKey(rgbt[3]));
            if (dye.hasName(i)) {
                bottle.setStackDisplayName(dye.getDyeName(i));
            }
            putStackInSlot(37 + i, bottle);
        } else {
            putStackInSlot(37 + i, null);
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ItemStack(net.minecraft.item.ItemStack)

Example 12 with ISkinDye

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinDye in project Armourers-Workshop by RiskyKen.

the class ContainerDyeTable method updateLockedSlots.

/**
 * Reads the input slot and locks dye slots that are in use.
 * @param stack
 */
private void updateLockedSlots(ItemStack stack) {
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
    ISkinDye dye = skinPointer.getSkinDye();
    for (int i = 0; i < 8; i++) {
        if (dye.haveDyeInSlot(i)) {
            ((SlotDyeBottle) getSlot(37 + i)).setLocked(true);
        } else {
            ((SlotDyeBottle) getSlot(37 + i)).setLocked(false);
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) SlotDyeBottle(riskyken.armourersWorkshop.common.inventory.slot.SlotDyeBottle)

Example 13 with ISkinDye

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinDye in project Armourers-Workshop by RiskyKen.

the class RecipeSkinDye method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
    ItemStack skinStack = null;
    ItemStack dyeStack = null;
    for (int slotId = 0; slotId < invCrafting.getSizeInventory(); slotId++) {
        ItemStack stack = invCrafting.getStackInSlot(slotId);
        if (stack != null) {
            Item item = stack.getItem();
            if (item == ModItems.dyeBottle) {
                if (dyeStack != null) {
                    return null;
                }
                if (PaintingHelper.getToolHasPaint(stack)) {
                    dyeStack = stack;
                } else {
                    return null;
                }
            } else if (item == ModItems.equipmentSkin) {
                if (skinStack != null) {
                    return null;
                }
                SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
                if (skinPointer != null) {
                    if (skinPointer.getSkinDye().getNumberOfDyes() < SkinDye.MAX_SKIN_DYES) {
                        skinStack = stack;
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            }
        }
    }
    if (skinStack != null && dyeStack != null) {
        ItemStack returnStack = skinStack.copy();
        byte[] rgbt = PaintingHelper.getToolPaintData(dyeStack);
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(returnStack);
        ISkinDye dye = skinPointer.getSkinDye();
        dye.addDye(rgbt);
        SkinNBTHelper.addSkinDataToStack(returnStack, skinPointer);
        return returnStack;
    }
    return null;
}
Also used : Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)13 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)8 ItemStack (net.minecraft.item.ItemStack)6 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)4 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)4 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)3 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)3 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 Color (java.awt.Color)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 Item (net.minecraft.item.Item)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)2 EntityTextureInfo (riskyken.armourersWorkshop.client.render.EntityTextureInfo)2 GameProfile (com.mojang.authlib.GameProfile)1 RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 Point3D (riskyken.armourersWorkshop.api.common.skin.Point3D)1 GuiMannequin (riskyken.armourersWorkshop.client.gui.mannequin.GuiMannequin)1