Search in sources :

Example 1 with ISkinPointer

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

the class SkinModelRenderer method getPlayerCustomArmour.

public Skin getPlayerCustomArmour(Entity entity, ISkinType skinType, int slotIndex) {
    if (!(entity instanceof AbstractClientPlayer)) {
        return null;
    }
    AbstractClientPlayer player = (AbstractClientPlayer) entity;
    EntityEquipmentData equipmentData = playerEquipmentMap.get(new PlayerPointer(player));
    // Look for skinned armourer.
    if (skinType.getVanillaArmourSlotId() >= 0 && skinType.getVanillaArmourSlotId() < 4 && slotIndex == 0) {
        int slot = 3 - skinType.getVanillaArmourSlotId();
        ItemStack armourStack = player.getCurrentArmor(slot);
        if (SkinNBTHelper.stackHasSkinData(armourStack)) {
            SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(armourStack);
            return getCustomArmourItemData(sp);
        }
    }
    // No skinned armour found checking the equipment wardrobe.
    if (equipmentData == null) {
        return null;
    }
    if (!equipmentData.haveEquipment(skinType, slotIndex)) {
        return null;
    }
    ISkinPointer skinPointer = equipmentData.getSkinPointer(skinType, slotIndex);
    return getCustomArmourItemData(skinPointer);
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) EntityEquipmentData(riskyken.armourersWorkshop.common.skin.EntityEquipmentData) PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) ItemStack(net.minecraft.item.ItemStack) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)

Example 2 with ISkinPointer

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer 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 3 with ISkinPointer

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

the class SkinnableEntityChickenRenderer method renderEquipmentType.

private void renderEquipmentType(EntityLivingBase entity, RendererLivingEntity renderer, ISkinType skinType, IEntityEquipment equipmentData) {
    if (equipmentData.haveEquipment(skinType, 0)) {
        ISkinPointer skinPointer = equipmentData.getSkinPointer(skinType, 0);
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin == null) {
            return;
        }
        GL11.glEnable(GL11.GL_NORMALIZE);
        float scale = 1F / 16F;
        for (int i = 0; i < skin.getParts().size(); i++) {
            SkinPartRenderer.INSTANCE.renderPart(skin.getParts().get(i), scale, skinPointer.getSkinDye(), null, false);
        }
        GL11.glDisable(GL11.GL_NORMALIZE);
    }
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)

Example 4 with ISkinPointer

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

the class BlockHighlightRenderHandler method onDrawBlockHighlightEvent.

@SubscribeEvent
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) {
    EntityPlayer player = event.player;
    World world = event.player.worldObj;
    MovingObjectPosition target = event.target;
    if (target != null && target.typeOfHit != MovingObjectType.BLOCK) {
        return;
    }
    int x = target.blockX;
    int y = target.blockY;
    int z = target.blockZ;
    int side = target.sideHit;
    Block block = world.getBlock(x, y, z);
    if (block == ModBlocks.mannequin) {
        drawMannequinBlockBounds(world, x, y, z, player, block, event.partialTicks);
        event.setCanceled(true);
    }
    if (event.currentItem != null && event.currentItem.getItem() == ModItems.equipmentSkin) {
        ISkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(event.currentItem);
        ForgeDirection sideDir = ForgeDirection.getOrientation(side);
        if (skinPointer != null && skinPointer.getIdentifier().getSkinType() == SkinTypeRegistry.skinBlock) {
            x += sideDir.offsetX;
            y += sideDir.offsetY;
            z += sideDir.offsetZ;
            drawSkinnableBlockHelper(world, x, y, z, side, player, event.partialTicks, skinPointer);
        }
    }
}
Also used : MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) World(net.minecraft.world.World) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 5 with ISkinPointer

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

the class SkinnableEntitySlimeRenderer method renderEquipmentType.

private void renderEquipmentType(EntityLivingBase entity, RendererLivingEntity renderer, ISkinType skinType, IEntityEquipment equipmentData) {
    if (equipmentData.haveEquipment(skinType, 0)) {
        ISkinPointer skinPointer = equipmentData.getSkinPointer(skinType, 0);
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin == null) {
            return;
        }
        GL11.glEnable(GL11.GL_NORMALIZE);
        float scale = 1F / 16F;
        for (int i = 0; i < skin.getParts().size(); i++) {
            SkinPartRenderer.INSTANCE.renderPart(skin.getParts().get(i), scale, skinPointer.getSkinDye(), null, false);
        }
        GL11.glDisable(GL11.GL_NORMALIZE);
    }
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)

Aggregations

ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)15 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)8 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)4 ItemStack (net.minecraft.item.ItemStack)3 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)2 GameProfile (com.mojang.authlib.GameProfile)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Color (java.awt.Color)1 Block (net.minecraft.block.Block)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 ModelZombieVillager (net.minecraft.client.model.ModelZombieVillager)1 RenderSkeleton (net.minecraft.client.renderer.entity.RenderSkeleton)1 RenderZombie (net.minecraft.client.renderer.entity.RenderZombie)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Slot (net.minecraft.inventory.Slot)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 World (net.minecraft.world.World)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1