Search in sources :

Example 6 with PlayerPointer

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

the class EquipmentWardrobeHandler method setEquipmentWardrobeData.

public void setEquipmentWardrobeData(PlayerPointer playerPointer, EquipmentWardrobeData ewd) {
    synchronized (threadLock) {
        if (equipmentWardrobeMap.containsKey(playerPointer)) {
            equipmentWardrobeMap.remove(playerPointer);
        }
        equipmentWardrobeMap.put(playerPointer, ewd);
    }
    EntityPlayer localPlayer = Minecraft.getMinecraft().thePlayer;
    PlayerPointer localPointer = new PlayerPointer(localPlayer);
    if (playerPointer.equals(localPointer)) {
        ExPropsPlayerSkinData.get(localPlayer).setSkinInfo(ewd, false);
    }
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 7 with PlayerPointer

use of riskyken.armourersWorkshop.common.data.PlayerPointer 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 8 with PlayerPointer

use of riskyken.armourersWorkshop.common.data.PlayerPointer 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 9 with PlayerPointer

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

the class EntityEquipmentDataManager method onStopTracking.

@SubscribeEvent
public void onStopTracking(PlayerEvent.StopTracking event) {
    if (event.target instanceof EntityPlayerMP) {
        EntityPlayerMP target = (EntityPlayerMP) event.target;
        MessageServerPlayerLeftTrackingRange message = new MessageServerPlayerLeftTrackingRange(new PlayerPointer(target));
        PacketHandler.networkWrapper.sendTo(message, (EntityPlayerMP) event.entityPlayer);
    }
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MessageServerPlayerLeftTrackingRange(riskyken.armourersWorkshop.common.network.messages.server.MessageServerPlayerLeftTrackingRange) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 10 with PlayerPointer

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

the class ExPropsPlayerSkinData method checkAndSendCustomArmourDataTo.

private void checkAndSendCustomArmourDataTo(EntityPlayerMP targetPlayer) {
    PlayerPointer playerPointer = new PlayerPointer(player);
    PacketHandler.networkWrapper.sendTo(new MessageServerSkinInfoUpdate(playerPointer, equipmentData), targetPlayer);
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MessageServerSkinInfoUpdate(riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinInfoUpdate)

Aggregations

PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)24 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)8 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)6 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)4 EntityEquipmentData (riskyken.armourersWorkshop.common.skin.EntityEquipmentData)4 RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 FakePlayer (net.minecraftforge.common.util.FakePlayer)3 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)3 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Color (java.awt.Color)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)2 EntityTextureInfo (riskyken.armourersWorkshop.client.render.EntityTextureInfo)2 MessageServerSkinInfoUpdate (riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinInfoUpdate)2 MessageServerSkinWardrobeUpdate (riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinWardrobeUpdate)2