Search in sources :

Example 41 with SkinPointer

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

the class TileEntityArmourer method loadArmourItem.

/**
 * Reads the NBT data from an item and places blocks in the world.
 * @param player The player that pressed the load button.
 */
public void loadArmourItem(EntityPlayerMP player) {
    if (getWorldObj().isRemote) {
        return;
    }
    ItemStack stackInput = this.getStackInSlot(0);
    ItemStack stackOuput = this.getStackInSlot(1);
    if (stackInput == null) {
        return;
    }
    if (stackOuput != null) {
        return;
    }
    if (!(stackInput.getItem() instanceof ItemSkin)) {
        return;
    }
    SkinPointer skinPointerInput = SkinNBTHelper.getSkinPointerFromStack(stackInput);
    if (skinPointerInput == null) {
        return;
    }
    if (skinType == null) {
        return;
    }
    if (skinType != skinPointerInput.getIdentifier().getSkinType()) {
        if (!(skinType == SkinTypeRegistry.skinLegs && skinPointerInput.getIdentifier().getSkinType() == SkinTypeRegistry.skinSkirt)) {
            return;
        }
    }
    Skin skin = CommonSkinCache.INSTANCE.getSkin(skinPointerInput);
    if (skin == null) {
        return;
    }
    setSkinProps(new SkinProperties(skin.getProperties()));
    ArmourerWorldHelper.loadSkinIntoWorld(worldObj, xCoord, yCoord + HEIGHT_OFFSET, zCoord, skin, direction);
    if (skin.hasPaintData()) {
        this.paintData = skin.getPaintData().clone();
    } else {
        clearPaintData(true);
    }
    dirtySync();
    this.setInventorySlotContents(0, null);
    this.setInventorySlotContents(1, stackInput);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ItemStack(net.minecraft.item.ItemStack) SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties)

Example 42 with SkinPointer

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

the class RenderBlockHologramProjector method renderTileEntityAt.

public void renderTileEntityAt(TileEntityHologramProjector tileEntity, double x, double y, double z, float partialTickTime) {
    if (tileEntity.getPowerMode() != PowerMode.IGNORED) {
        if (tileEntity.getPowerMode() == PowerMode.HIGH) {
            if (!tileEntity.isPowered()) {
                return;
            }
        } else {
            if (tileEntity.isPowered()) {
                return;
            }
        }
    }
    ItemStack itemStack = tileEntity.getStackInSlot(0);
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(itemStack);
    if (skinPointer == null) {
        return;
    }
    int rot = tileEntity.getBlockMetadata();
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glTranslated(x + 0.5F, y + 0.5D, z + 0.5F);
    GL11.glRotatef(180, 0, 0, 1);
    if (rot == 1) {
        GL11.glRotatef(180, 0, 0, 1);
    }
    if (rot == 2) {
        GL11.glRotatef(90, -1, 0, 0);
    }
    if (rot == 3) {
        GL11.glRotatef(90, 1, 0, 0);
    }
    if (rot == 4) {
        GL11.glRotatef(90, 0, 0, -1);
    }
    if (rot == 5) {
        GL11.glRotatef(90, 0, 0, 1);
    }
    float scale = 0.0625F;
    GL11.glTranslated(tileEntity.getOffsetX() * scale, tileEntity.getOffsetY() * scale, tileEntity.getOffsetZ() * scale);
    GL11.glScalef(-1, -1, 1);
    int speedX = tileEntity.getRotationSpeedX();
    int speedY = tileEntity.getRotationSpeedY();
    int speedZ = tileEntity.getRotationSpeedZ();
    float angleX = 0;
    float angleY = 0;
    float angleZ = 0;
    if (speedX != 0) {
        angleX = (System.currentTimeMillis() % speedX);
        angleX = angleX / speedX * 360F;
    }
    if (speedY != 0) {
        angleY = (System.currentTimeMillis() % speedY);
        angleY = angleY / speedY * 360F;
    }
    if (speedZ != 0) {
        angleZ = (System.currentTimeMillis() % speedZ);
        angleZ = angleZ / speedZ * 360F;
    }
    if (!tileEntity.isGlowing()) {
        ForgeDirection dir = ForgeDirection.getOrientation(tileEntity.getBlockMetadata());
        float xLight = tileEntity.xCoord;
        float yLight = tileEntity.yCoord;
        float zLight = tileEntity.zCoord;
        float offsetX = tileEntity.getOffsetX();
        float offsetY = tileEntity.getOffsetY();
        float offsetZ = tileEntity.getOffsetZ();
        switch(dir) {
            case UP:
                xLight += offsetX * scale;
                yLight += offsetY * scale;
                zLight += offsetZ * scale;
                break;
            case DOWN:
                xLight += -offsetX * scale;
                yLight += -offsetY * scale;
                zLight += offsetZ * scale;
                break;
            case EAST:
                xLight += offsetY * scale;
                yLight += -offsetX * scale;
                zLight += offsetZ * scale;
                break;
            case WEST:
                xLight += -offsetY * scale;
                yLight += offsetX * scale;
                zLight += offsetZ * scale;
                break;
            case NORTH:
                xLight += offsetX * scale;
                yLight += -offsetZ * scale;
                zLight += -offsetY * scale;
                break;
            case SOUTH:
                xLight += -offsetX * scale;
                yLight += offsetY * scale;
                zLight += offsetZ * scale;
                break;
            default:
                break;
        }
        ModRenderHelper.setLightingForBlock(tileEntity.getWorldObj(), (int) (xLight + 0.5F), (int) (yLight + 0.5F), (int) (zLight + 0.5F));
    }
    GL11.glPushMatrix();
    GL11.glTranslated((-tileEntity.getRotationOffsetX() + tileEntity.getRotationOffsetX()) * scale, (-tileEntity.getRotationOffsetY() + tileEntity.getRotationOffsetY()) * scale, (-tileEntity.getRotationOffsetZ() + tileEntity.getRotationOffsetZ()) * scale);
    if (tileEntity.getAngleX() != 0) {
        GL11.glRotatef(tileEntity.getAngleX(), 1F, 0F, 0F);
    }
    if (tileEntity.getAngleY() != 0) {
        GL11.glRotatef(tileEntity.getAngleY(), 0F, 1F, 0F);
    }
    if (tileEntity.getAngleZ() != 0) {
        GL11.glRotatef(tileEntity.getAngleZ(), 0F, 0F, 1F);
    }
    if (angleX != 0) {
        GL11.glRotatef((float) angleX, 1, 0, 0);
    }
    if (angleY != 0) {
        GL11.glRotatef((float) angleY, 0, 1, 0);
    }
    if (angleZ != 0) {
        GL11.glRotatef((float) angleZ, 0, 0, 1);
    }
    GL11.glTranslated(tileEntity.getRotationOffsetX() * scale, tileEntity.getRotationOffsetY() * scale, tileEntity.getRotationOffsetZ() * scale);
    if (tileEntity.isGlowing()) {
        ModRenderHelper.disableLighting();
    }
    ModRenderHelper.enableAlphaBlend();
    Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
    ItemStackRenderHelper.renderSkinWithHelper(skin, skinPointer, true, false);
    GL11.glPopMatrix();
    if (tileEntity.isShowRotationPoint()) {
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(0, 0, 0, scale, scale, scale);
        renderBox(aabb, 1F, 0F, 1F);
    }
    ModRenderHelper.disableAlphaBlend();
    if (tileEntity.isGlowing()) {
        ModRenderHelper.enableLighting();
    }
    GL11.glDisable(GL11.GL_NORMALIZE);
    GL11.glPopMatrix();
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ItemStack(net.minecraft.item.ItemStack)

Example 43 with SkinPointer

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

the class RenderBlockMannequin method hasCustomHead.

private boolean hasCustomHead(IInventory inventory) {
    ItemStack stack = getStackInMannequinSlot(inventory, MannequinSlotType.HEAD);
    if (stack != null) {
        if (stack.getItem() instanceof ItemBlock) {
            return true;
        }
    }
    if (isHalloweenSeason) {
        return true;
    }
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
    if (skinPointer != null) {
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer, false);
        if (skin != null) {
            return SkinProperties.PROP_ARMOUR_OVERRIDE.getValue(skin.getProperties());
        }
    }
    return false;
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 44 with SkinPointer

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

the class RenderBlockMannequinItems method renderRightArmStack.

public void renderRightArmStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
    Item targetItem = stack.getItem();
    float blockScale = 0.5F;
    float itemScale = 1 - (float) 1 / 3;
    Tessellator tessellator = Tessellator.instance;
    // Movement
    GL11.glTranslatef(-5F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 2F * scale, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedRightArm.rotateAngleZ), 0F, 0F, 1F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedRightArm.rotateAngleY), 0F, 1F, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedRightArm.rotateAngleX), 1F, 0F, 0F);
    GL11.glTranslatef(-2F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 10F * scale, 0F);
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(stack);
        if (sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinSword | sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinBow) {
            GL11.glRotatef(90, 1, 0, 0);
            GL11.glTranslated(1 * scale, 0 * scale, 2 * scale);
            SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, null, extraColours, distance, true);
            return;
        }
    }
    GL11.glRotatef(-90, 0, 1, 0);
    GL11.glRotatef(45, 0, 0, 1);
    GL11.glScalef(itemScale, itemScale, itemScale);
    GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
    if (targetItem instanceof ItemBlock) {
        GL11.glTranslatef(-3 * scale, 4 * scale, 2 * scale);
        GL11.glScalef(-blockScale, -blockScale, blockScale);
        GL11.glRotatef(30F, 0F, 1F, 0F);
        GL11.glRotatef(130F, 1F, 0F, 0F);
    } else {
        if (!(targetItem instanceof ItemSword)) {
            // GL11.glRotatef(90F, 0F, 1F, 0F);
            GL11.glScalef(0.75F, 0.75F, 0.75F);
        }
    }
    if (targetItem.requiresMultipleRenderPasses()) {
        int passes = targetItem.getRenderPasses(stack.getItemDamage());
        for (int i = 0; i < passes; i++) {
            int c = targetItem.getColorFromItemStack(stack, i);
            float r = (float) (c >> 16 & 255) / 255.0F;
            float g = (float) (c >> 8 & 255) / 255.0F;
            float b = (float) (c & 255) / 255.0F;
            GL11.glColor4f(r, g, b, 1F);
            rm.itemRenderer.renderItem(fakePlayer, stack, i, ItemRenderType.EQUIPPED);
        }
        GL11.glColor4f(1F, 1F, 1F, 1F);
    } else {
        int c = targetItem.getColorFromItemStack(stack, 0);
        float r = (float) (c >> 16 & 255) / 255.0F;
        float g = (float) (c >> 8 & 255) / 255.0F;
        float b = (float) (c & 255) / 255.0F;
        GL11.glColor4f(r, g, b, 1F);
        rm.itemRenderer.renderItem(fakePlayer, stack, 0, ItemRenderType.EQUIPPED);
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Tessellator(net.minecraft.client.renderer.Tessellator) ItemBlock(net.minecraft.item.ItemBlock)

Example 45 with SkinPointer

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

the class RenderBlockMannequinItems method renderLeftArmStack.

public void renderLeftArmStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
    Item targetItem = stack.getItem();
    float blockScale = 0.5F;
    float itemScale = 1 - (float) 1 / 3;
    // Movement
    GL11.glTranslatef(5F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 2F * scale, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedLeftArm.rotateAngleZ), 0F, 0F, 1F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedLeftArm.rotateAngleY), 0F, 1F, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedLeftArm.rotateAngleX), 1F, 0F, 0F);
    GL11.glTranslatef(1F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 10F * scale, 0F);
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(stack);
        if (sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinSword | sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinBow) {
            GL11.glRotatef(90, 1, 0, 0);
            GL11.glTranslated(0 * scale, 0 * scale, 2 * scale);
            GL11.glScalef(-1, 1, 1);
            GL11.glCullFace(GL11.GL_FRONT);
            SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, null, extraColours, distance, true);
            GL11.glCullFace(GL11.GL_BACK);
            return;
        }
    }
    GL11.glRotatef(-90, 0, 1, 0);
    GL11.glRotatef(45, 0, 0, 1);
    GL11.glScalef(itemScale, itemScale, itemScale);
    GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
    if (targetItem instanceof ItemBlock) {
        GL11.glTranslatef(-2 * scale, 4 * scale, 2 * scale);
        GL11.glScalef(-blockScale, -blockScale, blockScale);
        GL11.glRotatef(50F, 0F, 1F, 0F);
        GL11.glRotatef(130F, 1F, 0F, 0F);
    } else {
        if (!(targetItem instanceof ItemSword)) {
            // GL11.glRotatef(-45F, 1F, 0F, 1F);
            GL11.glScalef(0.75F, 0.75F, 0.75F);
        }
    }
    if (targetItem.requiresMultipleRenderPasses()) {
        int passes = targetItem.getRenderPasses(stack.getItemDamage());
        for (int i = 0; i < passes; i++) {
            int c = targetItem.getColorFromItemStack(stack, i);
            float r = (float) (c >> 16 & 255) / 255.0F;
            float g = (float) (c >> 8 & 255) / 255.0F;
            float b = (float) (c & 255) / 255.0F;
            GL11.glColor4f(r, g, b, 1F);
            rm.itemRenderer.renderItem(fakePlayer, stack, i, ItemRenderType.EQUIPPED);
        }
        GL11.glColor4f(1F, 1F, 1F, 1F);
    } else {
        int c = targetItem.getColorFromItemStack(stack, 0);
        float r = (float) (c >> 16 & 255) / 255.0F;
        float g = (float) (c >> 8 & 255) / 255.0F;
        float b = (float) (c & 255) / 255.0F;
        GL11.glColor4f(r, g, b, 1F);
        rm.itemRenderer.renderItem(fakePlayer, stack, 0, ItemRenderType.EQUIPPED);
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemBlock(net.minecraft.item.ItemBlock)

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