Search in sources :

Example 1 with IEntityEquipment

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

the class RenderSkinnedArrow method doRender.

@Override
public void doRender(EntityArrow entityArrow, double x, double y, double z, float yaw, float partialTickTime) {
    if (entityArrow.shootingEntity != null && entityArrow.shootingEntity instanceof EntityClientPlayerMP) {
        EntityClientPlayerMP player = (EntityClientPlayerMP) entityArrow.shootingEntity;
        IEntityEquipment entityEquipment = equipmentModelRenderer.getPlayerCustomEquipmentData(player);
        if (entityEquipment != null && entityEquipment.haveEquipment(SkinTypeRegistry.skinBow, 0)) {
            ISkinPointer skinPointer = entityEquipment.getSkinPointer(SkinTypeRegistry.skinBow, 0);
            if (ClientSkinCache.INSTANCE.isSkinInCache(skinPointer)) {
                Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
                if (skin != null) {
                    SkinPart skinPart = skin.getPart("armourers:bow.arrow");
                    if (skinPart != null) {
                        ModRenderHelper.enableAlphaBlend();
                        renderArrowSkin(entityArrow, x, y, z, partialTickTime, skinPart, skinPointer.getSkinDye());
                        ModRenderHelper.disableAlphaBlend();
                        return;
                    }
                }
            } else {
                ClientSkinCache.INSTANCE.requestSkinFromServer(skinPointer);
            }
        }
    }
    super.doRender(entityArrow, x, y, z, yaw, partialTickTime);
}
Also used : EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IEntityEquipment(riskyken.armourersWorkshop.api.common.skin.IEntityEquipment) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 2 with IEntityEquipment

use of riskyken.armourersWorkshop.api.common.skin.IEntityEquipment 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)

Aggregations

IEntityEquipment (riskyken.armourersWorkshop.api.common.skin.IEntityEquipment)2 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)2 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)2 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 RenderBlocks (net.minecraft.client.renderer.RenderBlocks)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)1 ModelSkinBow (riskyken.armourersWorkshop.client.model.skin.ModelSkinBow)1 CubeMarkerData (riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData)1 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)1