Search in sources :

Example 16 with SkinPointer

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

the class RenderBlockSkinnable method renderTileEntityAt.

public void renderTileEntityAt(TileEntitySkinnable tileEntity, double x, double y, double z, float partialTickTime) {
    ModRenderHelper.setLightingForBlock(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
    SkinPointer skinPointer = tileEntity.getSkinPointer();
    if (skinPointer != null) {
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin != null) {
            renderSkin(tileEntity, x, y, z, skin);
        } else {
            ClientSkinCache.INSTANCE.requestSkinFromServer(skinPointer);
            GL11.glPushMatrix();
            GL11.glTranslated(x + 0.5F, y + 0.5F, z + 0.5F);
            loadingModel.render(tileEntity, partialTickTime, 0.0625F);
            GL11.glPopMatrix();
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Example 17 with SkinPointer

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

the class RecipeClearDye method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
    ItemStack skinStack = null;
    ItemStack soapStack = null;
    for (int slotId = 0; slotId < invCrafting.getSizeInventory(); slotId++) {
        ItemStack stack = invCrafting.getStackInSlot(slotId);
        if (stack == null) {
            continue;
        }
        Item item = stack.getItem();
        if (item == ModItems.soap) {
            if (soapStack != null) {
                return null;
            }
            soapStack = stack;
        } else if (item == ModItems.equipmentSkin) {
            if (skinStack != null) {
                return null;
            }
            if (SkinNBTHelper.stackHasSkinData(stack)) {
                skinStack = stack;
            } else {
                return null;
            }
        }
    }
    if (skinStack != null && soapStack != null) {
        ItemStack returnStack = skinStack.copy();
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(returnStack);
        ISkinDye dye = skinPointer.getSkinDye();
        for (int i = 0; i < 8; i++) {
            dye.removeDye(i);
        }
        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)

Example 18 with SkinPointer

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

the class BlockSkinnable method getPickBlock.

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
    SkinPointer skinPointer = getSkinPointer(world, x, y, z);
    if (skinPointer != null) {
        ItemStack returnStack = new ItemStack(ModItems.equipmentSkin, 1);
        SkinNBTHelper.addSkinDataToStack(returnStack, skinPointer);
        return returnStack;
    }
    return null;
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack)

Example 19 with SkinPointer

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

the class BlockSkinnable method dropSkin.

private void dropSkin(World world, int x, int y, int z, boolean isCreativeMode) {
    TileEntitySkinnable te = getTileEntity(world, x, y, z);
    if (te != null) {
        SkinPointer skinPointer = te.getSkinPointer();
        if (skinPointer != null) {
            if (!isCreativeMode) {
                ItemStack skinStack = new ItemStack(ModItems.equipmentSkin, 1);
                SkinNBTHelper.addSkinDataToStack(skinStack, skinPointer);
                UtilItems.spawnItemInWorld(world, x, y, z, skinStack);
            }
            te.killChildren(world);
        } else {
            ModLogger.log(Level.WARN, String.format("Block skin at x:%d y:%d z:%d had no skin data.", x, y, z));
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack) TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Example 20 with SkinPointer

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

the class SkinDataHandler method saveSkinPointerOnStack.

@Override
public void saveSkinPointerOnStack(ISkinPointer skinPointer, ItemStack stack) {
    if (stack == null) {
        return;
    }
    SkinPointer sp = new SkinPointer(skinPointer);
    SkinNBTHelper.addSkinDataToStack(stack, sp);
}
Also used : ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

Aggregations

SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)64 ItemStack (net.minecraft.item.ItemStack)28 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)19 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)15 Item (net.minecraft.item.Item)13 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)7 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)7 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)6 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)4 Minecraft (net.minecraft.client.Minecraft)3 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 ItemBlock (net.minecraft.item.ItemBlock)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)3 MessageServerLibrarySendSkin (riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin)3 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2