Search in sources :

Example 6 with AbstractClientPlayer

use of net.minecraft.client.entity.AbstractClientPlayer in project Armourers-Workshop by RiskyKen.

the class PlayerTextureHandler method onRender.

@SubscribeEvent(priority = EventPriority.LOW)
public void onRender(RenderPlayerEvent.Pre event) {
    useTexturePainting = ClientProxy.useTexturePainting();
    if (!useTexturePainting) {
        return;
    }
    if (!(event.entityPlayer instanceof AbstractClientPlayer)) {
        return;
    }
    AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
    if (player instanceof MannequinFakePlayer) {
        return;
    }
    if (player.getGameProfile() == null) {
        return;
    }
    PlayerPointer playerPointer = new PlayerPointer(player);
    EquipmentWardrobeData ewd = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(playerPointer);
    if (ewd == null) {
        return;
    }
    profiler.startSection("textureBuild");
    if (playerTextureMap.containsKey(playerPointer)) {
        EntityTextureInfo textureInfo = playerTextureMap.get(playerPointer);
        textureInfo.updateTexture(player.getLocationSkin());
        textureInfo.updateHairColour(ewd.hairColour);
        textureInfo.updateSkinColour(ewd.skinColour);
        Skin[] skins = new Skin[4 * ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE];
        for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
            skins[0 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinHead, skinIndex);
            skins[1 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinChest, skinIndex);
            skins[2 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinLegs, skinIndex);
            skins[3 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinFeet, skinIndex);
        }
        ISkinDye[] dyes = new ISkinDye[4 * ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE];
        for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
            dyes[0 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinHead, skinIndex);
            dyes[1 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinChest, skinIndex);
            dyes[2 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinLegs, skinIndex);
            dyes[3 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinFeet, skinIndex);
        }
        textureInfo.updateSkins(skins);
        textureInfo.updateDyes(dyes);
        ResourceLocation replacmentTexture = textureInfo.preRender();
        player.func_152121_a(Type.SKIN, replacmentTexture);
    }
    profiler.endSection();
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) EntityTextureInfo(riskyken.armourersWorkshop.client.render.EntityTextureInfo) PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ResourceLocation(net.minecraft.util.ResourceLocation) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 7 with AbstractClientPlayer

use of net.minecraft.client.entity.AbstractClientPlayer in project Armourers-Workshop by RiskyKen.

the class PlayerTextureHandler method onRender.

@SubscribeEvent(priority = EventPriority.HIGH)
public void onRender(RenderPlayerEvent.Post event) {
    if (!useTexturePainting) {
        return;
    }
    if (!(event.entityPlayer instanceof AbstractClientPlayer)) {
        return;
    }
    AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
    if (player instanceof MannequinFakePlayer) {
        return;
    }
    if (player.getGameProfile() == null) {
        return;
    }
    PlayerPointer playerPointer = new PlayerPointer(player);
    EquipmentWardrobeData ewd = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(playerPointer);
    if (ewd == null) {
        return;
    }
    profiler.startSection("textureReset");
    if (playerTextureMap.containsKey(playerPointer)) {
        EntityTextureInfo textureInfo = playerTextureMap.get(playerPointer);
        ResourceLocation replacmentTexture = textureInfo.postRender();
        player.func_152121_a(Type.SKIN, replacmentTexture);
    } else {
        playerTextureMap.put(playerPointer, new EntityTextureInfo());
    }
    profiler.endSection();
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) EntityTextureInfo(riskyken.armourersWorkshop.client.render.EntityTextureInfo) PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 8 with AbstractClientPlayer

use of net.minecraft.client.entity.AbstractClientPlayer 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 9 with AbstractClientPlayer

use of net.minecraft.client.entity.AbstractClientPlayer in project Armourers-Workshop by RiskyKen.

the class RenderItemMannequin method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();
    GL11.glScalef(-1, -1, 1);
    GL11.glTranslatef(0, -0.5F, 0);
    float headPitch = 0F;
    float headTilt = 0F;
    float limbWobble = 0F;
    switch(type) {
        case EQUIPPED_FIRST_PERSON:
            GL11.glTranslatef(-0.6F, -0.5F, 0.6F);
            GL11.glRotatef(-60, 0, 1, 0);
            headPitch = -40F;
            headTilt = -10F;
            if (data.length >= 2) {
                if (data[1] instanceof AbstractClientPlayer & data[0] instanceof RenderBlocks) {
                    RenderBlocks renderBlocks = (RenderBlocks) data[0];
                    AbstractClientPlayer player = (AbstractClientPlayer) data[1];
                    World world = player.worldObj;
                    float partialTickTime = ModClientFMLEventHandler.renderTickTime;
                    float pitchTime = (world.getTotalWorldTime() % 10L) + partialTickTime;
                    float tiltTime = (world.getTotalWorldTime() % 8L) + partialTickTime;
                    float limbTime = (world.getTotalWorldTime() % 6L) + partialTickTime;
                    pitchTime = (pitchTime / 5) - 1;
                    tiltTime = (tiltTime / 4) - 1;
                    limbTime = (limbTime / 3) - 1;
                    float lastDistance = player.distanceWalkedModified - player.prevDistanceWalkedModified;
                    headTilt += Math.sin(tiltTime * Math.PI) * 80F * lastDistance;
                    headPitch += Math.sin(pitchTime * Math.PI) * 40F * lastDistance;
                    limbWobble += Math.sin(limbTime * Math.PI) * lastDistance / 10F;
                }
            }
            break;
        case ENTITY:
            GL11.glScalef(1.4F, 1.4F, 1.4F);
            GL11.glTranslatef(0, -0.8F, 0);
            break;
        case EQUIPPED:
            GL11.glScalef(1.2F, 1.2F, 1.2F);
            GL11.glTranslatef(-0.6F, -0.5F, 0.6F);
            GL11.glRotatef(-60, 0, 1, 0);
            break;
        case INVENTORY:
            GL11.glTranslatef(0, 0.1F, 0);
            GL11.glScalef(0.9F, 0.9F, 0.9F);
            GL11.glRotatef(180, 0, 1, 0);
            break;
        default:
            break;
    }
    PlayerTexture playerTexture = MannequinTextureHelper.getMannequinTexture(item);
    Minecraft.getMinecraft().renderEngine.bindTexture(playerTexture.getResourceLocation());
    if (item.getItem() == Item.getItemFromBlock(ModBlocks.doll)) {
        float dollScale = 0.5F;
        GL11.glScalef(dollScale, dollScale, dollScale);
    }
    float scale = 0.0625F;
    GL11.glColor3f(1F, 1F, 1F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (playerTexture.isSlimModel()) {
        modelAlex.render(null, 0, limbWobble, 0, headPitch, headTilt, scale, true);
    } else {
        modelSteve.render(null, 0, limbWobble, 0, headPitch, headTilt, scale, true);
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) RenderBlocks(net.minecraft.client.renderer.RenderBlocks) PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) World(net.minecraft.world.World)

Example 10 with AbstractClientPlayer

use of net.minecraft.client.entity.AbstractClientPlayer 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)

Aggregations

AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)16 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)7 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 EntityEquipmentData (riskyken.armourersWorkshop.common.skin.EntityEquipmentData)4 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)4 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)4 RenderBlocks (net.minecraft.client.renderer.RenderBlocks)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)3 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)3 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 ItemStack (net.minecraft.item.ItemStack)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)2 EntityTextureInfo (riskyken.armourersWorkshop.client.render.EntityTextureInfo)2 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)2 ICape (com.jadarstudios.developercapes.cape.ICape)1 User (com.jadarstudios.developercapes.user.User)1 UserManager (com.jadarstudios.developercapes.user.UserManager)1