Search in sources :

Example 6 with SkinPointer

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

the class RenderItemBowSkin method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
    if (canRenderModel(stack) & type != ItemRenderType.INVENTORY) {
        if (type != ItemRenderType.ENTITY) {
            GL11.glPopMatrix();
        // GL11.glPopMatrix();
        // GL11.glRotatef(-135, 0, 1, 0);
        // GL11.glRotatef(-10, 0, 0, 1);
        }
        GL11.glPushMatrix();
        AbstractClientPlayer player = null;
        int useCount = 0;
        boolean hasArrow = false;
        if (data.length >= 2) {
            if (data[1] instanceof AbstractClientPlayer & data[0] instanceof RenderBlocks) {
                RenderBlocks renderBlocks = (RenderBlocks) data[0];
                player = (AbstractClientPlayer) data[1];
                useCount = player.getItemInUseDuration();
                hasArrow = player.inventory.hasItem(Items.arrow);
                IEntityEquipment entityEquipment = SkinModelRenderer.INSTANCE.getPlayerCustomEquipmentData(player);
                if (!hasArrow) {
                    if (player.capabilities.isCreativeMode) {
                        hasArrow = true;
                    }
                }
            }
        }
        float scale = 0.0625F;
        float angle = (float) (((double) System.currentTimeMillis() / 5) % 360F);
        switch(type) {
            case EQUIPPED:
                GL11.glScalef(1F, -1F, 1F);
                GL11.glScalef(1.6F, 1.6F, 1.6F);
                GL11.glRotatef(-135, 0, 1, 0);
                GL11.glRotatef(10, 0, 0, 1);
                GL11.glRotatef(-20, 1, 0, 0);
                GL11.glRotatef(90, 0, 1, 0);
                GL11.glTranslatef(0F * scale, -6F * scale, 1F * scale);
                break;
            case ENTITY:
                GL11.glRotatef(180, 0, 0, 1);
                GL11.glTranslatef(0F, -10F * scale, 0F);
                break;
            case EQUIPPED_FIRST_PERSON:
                GL11.glScalef(1.6F, 1.6F, 1.6F);
                GL11.glRotatef(-135, 0, 1, 0);
                GL11.glRotatef(180, 0, 0, 1);
                GL11.glRotatef(-90, 0, 1, 0);
                // Back tilt
                GL11.glRotatef(-17, 1, 0, 0);
                GL11.glRotatef(2, 0, 0, 1);
                GL11.glTranslatef(0F * scale, -2F * scale, 1F * scale);
                if (useCount > 0) {
                    GL11.glTranslatef(-5 * scale, 3 * scale, 1 * scale);
                    GL11.glRotatef(-6, 1, 0, 0);
                    GL11.glRotatef(-16, 0, 1, 0);
                    GL11.glRotatef(2, 0, 0, 1);
                }
                break;
            default:
                break;
        }
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        ModRenderHelper.enableAlphaBlend();
        ModelSkinBow model = SkinModelRenderer.INSTANCE.customBow;
        model.frame = getAnimationFrame(useCount);
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        model.render(player, skin, false, skinPointer.getSkinDye(), null, false, 0, false);
        if (hasArrow & useCount > 0) {
            GL11.glTranslatef(1 * scale, 1 * scale, -12 * scale);
            int tarPart = getAnimationFrame(useCount);
            if (skin.getParts().get(tarPart).getMarkerBlocks().size() > 0) {
                CubeMarkerData cmd = skin.getParts().get(tarPart).getMarkerBlocks().get(0);
                ForgeDirection dir = ForgeDirection.getOrientation(cmd.meta - 1);
                GL11.glTranslatef((-dir.offsetX + cmd.x) * scale, (-dir.offsetY + cmd.y) * scale, (dir.offsetZ + cmd.z) * scale);
                // Shift the arrow a little to stop z fighting.
                GL11.glTranslatef(-0.01F * scale, 0.01F * scale, -0.01F * scale);
                SkinPart skinPartArrow = skin.getPart("armourers:bow.arrow");
                if (skinPartArrow != null) {
                    SkinPartRenderer.INSTANCE.renderPart(skinPartArrow, scale, skinPointer.getSkinDye(), null, false);
                } else {
                    ModelArrow.MODEL.render(scale, false);
                }
            }
        }
        GL11.glPopAttrib();
        GL11.glPopMatrix();
        if (type != ItemRenderType.ENTITY) {
            // GL11.glPushMatrix();
            GL11.glPushMatrix();
        }
    } else {
        if (itemRenderer != null) {
            itemRenderer.renderItem(type, stack, data);
        } else {
            renderNomalIcon(stack);
        }
    }
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) RenderBlocks(net.minecraft.client.renderer.RenderBlocks) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) CubeMarkerData(riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData) IEntityEquipment(riskyken.armourersWorkshop.api.common.skin.IEntityEquipment) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ModelSkinBow(riskyken.armourersWorkshop.client.model.skin.ModelSkinBow) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 7 with SkinPointer

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

the class RenderItemSwordSkin method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
    if (canRenderModel(stack) & type != ItemRenderType.INVENTORY) {
        if (type != ItemRenderType.ENTITY) {
            GL11.glPopMatrix();
            GL11.glRotatef(-135, 0, 1, 0);
            GL11.glRotatef(-10, 0, 0, 1);
        }
        GL11.glPushMatrix();
        GL11.glScalef(1F, -1F, 1F);
        GL11.glScalef(1.6F, 1.6F, 1.6F);
        boolean isBlocking = false;
        if (data.length >= 2) {
            if (data[1] instanceof AbstractClientPlayer & data[0] instanceof RenderBlocks) {
                RenderBlocks renderBlocks = (RenderBlocks) data[0];
                AbstractClientPlayer player = (AbstractClientPlayer) data[1];
                isBlocking = player.isBlocking();
            }
        }
        float scale = 0.0625F;
        switch(type) {
            case EQUIPPED:
                GL11.glTranslatef(2F * scale, -1F * scale, 0F * scale);
                if (isBlocking) {
                    GL11.glTranslatef(-0F * scale, 2F * scale, 1F * scale);
                }
                GL11.glRotatef(90F, 0F, 1F, 0F);
                break;
            case ENTITY:
                GL11.glScalef(-1F, 1F, 1F);
                GL11.glTranslatef(0F, -10F * scale, 0F);
                break;
            case EQUIPPED_FIRST_PERSON:
                GL11.glScalef(-1F, 1F, 1F);
                GL11.glRotatef(-90F, 0F, 1F, 0F);
                break;
            default:
                break;
        }
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        ModRenderHelper.enableAlphaBlend();
        ModAddonManager.onWeaponRender(type, EventState.PRE);
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin != null) {
            ItemStackRenderHelper.renderSkinWithHelper(skin, skinPointer, false, false);
        }
        ModAddonManager.onWeaponRender(type, EventState.POST);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
        if (type != ItemRenderType.ENTITY) {
            GL11.glPushMatrix();
        }
    } else {
        if (itemRenderer != null) {
            itemRenderer.renderItem(type, stack, data);
        } else {
            renderNomalIcon(stack);
        }
    }
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) RenderBlocks(net.minecraft.client.renderer.RenderBlocks) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Example 8 with SkinPointer

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

the class ItemStackRenderHelper method renderItemAsArmourModel.

@Deprecated
public static void renderItemAsArmourModel(ItemStack stack, boolean showSkinPaint) {
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
        renderItemModelFromSkinPointer(skinPointer, showSkinPaint, false);
    }
}
Also used : ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

Example 9 with SkinPointer

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

the class SkinPreviewHandler method onDrawScreenPost.

@SubscribeEvent
public void onDrawScreenPost(DrawScreenEvent.Pre event) {
    if (!ConfigHandlerClient.skinPreEnabled) {
        return;
    }
    if (ConfigHandlerClient.skinPreLocFollowMouse) {
        return;
    }
    SkinPointer skinPointer = lastSkinPointer;
    List<String> list = lastList;
    lastSkinPointer = null;
    lastList = null;
    if (skinPointer != null & list != null) {
        Minecraft mc = Minecraft.getMinecraft();
        float skinPreSize = ConfigHandlerClient.skinPreSize;
        float skinPreLocHorizontal = ConfigHandlerClient.skinPreLocHorizontal;
        float skinPreLocVertical = ConfigHandlerClient.skinPreLocVertical;
        ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
        double widthClip = sr.getScaledWidth_double() - skinPreSize;
        double heightClip = sr.getScaledHeight_double() - skinPreSize;
        int x = MathHelper.ceiling_double_int(widthClip * skinPreLocHorizontal);
        int y = MathHelper.ceiling_double_int(heightClip * skinPreLocVertical);
        drawSkinBox(mc, x, y, skinPreSize, skinPointer);
        skinPointer = null;
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 10 with SkinPointer

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

the class EntitySkinHandler method giveRandomSkin.

public void giveRandomSkin(ExPropsEntityEquipmentData entityEquipmentData) {
    if (entityEquipmentData == null) {
        return;
    }
    if (ConfigHandler.enitiySpawnWithSkinsChance <= 0) {
        return;
    }
    ArrayList<ISkinType> skinTypes = entityEquipmentData.getSkinInventory().getSkinTypes();
    for (int i = 0; i < skinTypes.size(); i++) {
        int rnd = entityEquipmentData.getEntity().worldObj.rand.nextInt(99) + 1;
        if (rnd >= ConfigHandler.enitiySpawnWithSkinsChance) {
            continue;
        }
        ISkinType skinType = skinTypes.get(i);
        LibraryFile libraryFile = getRandomSkinOfType(skinType);
        if (libraryFile == null) {
            continue;
        }
        SkinIdentifier identifier = new SkinIdentifier(0, libraryFile, 0, skinType);
        ItemStack skinStack = SkinNBTHelper.makeEquipmentSkinStack(new SkinPointer(identifier));
        if (skinStack == null) {
            continue;
        }
        entityEquipmentData.getSkinInventory().setInventorySlotContents(i, skinStack);
    }
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) ItemStack(net.minecraft.item.ItemStack) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

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