use of riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData in project Armourers-Workshop by RiskyKen.
the class EquipmentWardrobeHandler method onRender.
@SubscribeEvent(priority = EventPriority.HIGH)
public void onRender(RenderPlayerEvent.SetArmorModel event) {
int slot = -event.slot + 3;
if (slot > 3) {
return;
}
EntityPlayer player = event.entityPlayer;
if (player instanceof MannequinFakePlayer) {
return;
}
if (player.getGameProfile() == null) {
return;
}
if (player instanceof FakePlayer) {
return;
}
int result = -1;
// Hide the armour if it had been skinned.
ItemStack stack = player.getCurrentArmor(event.slot);
if (SkinNBTHelper.stackHasSkinData(stack)) {
result = -2;
}
// Hide the armour if the player has turned it off.
PlayerPointer playerPointer = new PlayerPointer(player);
if (equipmentWardrobeMap.containsKey(playerPointer)) {
EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
if (ewd.armourOverride.get(slot)) {
result = -2;
}
}
event.result = result;
}
use of riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData in project Armourers-Workshop by RiskyKen.
the class EquipmentWardrobeHandler method onRender.
@SubscribeEvent
public void onRender(RenderPlayerEvent.Pre event) {
EntityPlayer player = event.entityPlayer;
if (player instanceof MannequinFakePlayer) {
return;
}
if (player.getGameProfile() == null) {
return;
}
if (player instanceof FakePlayer) {
return;
}
// Hide the head overlay if the player has turned it off.
PlayerPointer playerPointer = new PlayerPointer(player);
RenderPlayer renderer = event.renderer;
if (equipmentWardrobeMap.containsKey(playerPointer)) {
EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
renderer.modelBipedMain.bipedHeadwear.isHidden = ewd.headOverlay;
if (!ewd.headOverlay) {
if (SkinModelRenderer.INSTANCE.playerHasCustomHead(player)) {
renderer.modelBipedMain.bipedHeadwear.isHidden = true;
}
}
}
}
use of riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData in project Armourers-Workshop by RiskyKen.
the class ModelRendererAttachment method render.
@Override
public void render(float scale) {
if (ClientProxy.getSkinRenderType() != SkinRenderType.MODEL_ATTACHMENT) {
return;
}
mc.mcProfiler.startSection("armourers player render");
SkinModelRenderer modelRenderer = SkinModelRenderer.INSTANCE;
EntityPlayer player = modelRenderer.targetPlayer;
if (player == null) {
mc.mcProfiler.endSection();
return;
}
if (player instanceof MannequinFakePlayer) {
mc.mcProfiler.endSection();
return;
}
double distance = Minecraft.getMinecraft().thePlayer.getDistance(player.posX, player.posY, player.posZ);
if (distance > ConfigHandlerClient.maxSkinRenderDistance) {
return;
}
EquipmentWardrobeData ewd = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(new PlayerPointer(player));
byte[] extraColours = null;
if (ewd != null) {
Color skinColour = new Color(ewd.skinColour);
Color hairColour = new Color(ewd.hairColour);
extraColours = new byte[] { (byte) skinColour.getRed(), (byte) skinColour.getGreen(), (byte) skinColour.getBlue(), (byte) hairColour.getRed(), (byte) hairColour.getGreen(), (byte) hairColour.getBlue() };
}
for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
Skin data = modelRenderer.getPlayerCustomArmour(player, skinType, skinIndex);
if (data == null) {
continue;
}
ISkinDye skinDye = modelRenderer.getPlayerDyeData(player, skinType, skinIndex);
MovementType movmentType = MovementType.valueOf(SkinProperties.PROP_WINGS_MOVMENT_TYPE.getValue(data.getProperties()));
int size = data.getParts().size();
for (int i = 0; i < size; i++) {
SkinPart partData = data.getParts().get(i);
if (partData.getPartType() == skinPart) {
GL11.glPushMatrix();
if (skinType == SkinTypeRegistry.skinLegs && skinPart.getRegistryName().equals("armourers:legs.skirt")) {
GL11.glTranslatef(0, 12 * scale, 0);
if (player.isSneaking()) {
GL11.glRotatef(-30, 1, 0, 0);
GL11.glTranslatef(0, -1.25F * scale, -2F * scale);
}
if (player.isRiding()) {
GL11.glRotated(-70, 1F, 0F, 0F);
}
}
if (skinType == SkinTypeRegistry.skinWings) {
GL11.glTranslated(0, 0, scale * 2);
double angle = SkinUtils.getFlapAngleForWings(player, data);
Point3D point = new Point3D(0, 0, 0);
ForgeDirection axis = ForgeDirection.DOWN;
if (partData.getMarkerCount() > 0) {
point = partData.getMarker(0);
axis = partData.getMarkerSide(0);
}
GL11.glTranslated(scale * 0.5F, scale * 0.5F, scale * 0.5F);
GL11.glTranslated(scale * point.getX(), scale * point.getY(), scale * point.getZ());
if (skinPart.getRegistryName().equals("armourers:wings.rightWing")) {
angle = -angle;
}
switch(axis) {
case UP:
GL11.glRotated(angle, 0, 1, 0);
break;
case DOWN:
GL11.glRotated(angle, 0, -1, 0);
break;
case SOUTH:
GL11.glRotated(angle, 0, 0, -1);
break;
case NORTH:
GL11.glRotated(angle, 0, 0, 1);
break;
case EAST:
GL11.glRotated(angle, 1, 0, 0);
break;
case WEST:
GL11.glRotated(angle, -1, 0, 0);
break;
case UNKNOWN:
break;
}
GL11.glTranslated(scale * -point.getX(), scale * -point.getY(), scale * -point.getZ());
GL11.glTranslated(scale * -0.5F, scale * -0.5F, scale * -0.5F);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_BLEND);
SkinPartRenderer.INSTANCE.renderPart(partData, scale, skinDye, extraColours, distance, true);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
break;
}
}
}
if (ClientProxy.useSafeTextureRender()) {
if (player instanceof AbstractClientPlayer) {
AbstractClientPlayer clientPlayer = (AbstractClientPlayer) player;
Minecraft.getMinecraft().renderEngine.bindTexture(clientPlayer.getLocationSkin());
}
}
mc.mcProfiler.endSection();
}
use of riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData in project Armourers-Workshop by RiskyKen.
the class CommandSetWardrobeOption method processCommand.
@Override
public void processCommand(ICommandSender commandSender, String[] currentCommand) {
if (currentCommand.length != 4) {
throw new WrongUsageException(getCommandUsage(commandSender), (Object) currentCommand);
}
EntityPlayerMP player = getPlayer(commandSender, currentCommand[1]);
if (player == null) {
return;
}
String subOption = currentCommand[2];
boolean value = parseBoolean(commandSender, currentCommand[3]);
int subOptionIndex = -1;
for (int i = 0; i < SUB_OPTIONS.length; i++) {
if (subOption.equals(SUB_OPTIONS[i])) {
subOptionIndex = i;
break;
}
}
if (subOptionIndex == -1) {
throw new WrongUsageException(getCommandUsage(commandSender), (Object) currentCommand);
}
ExPropsPlayerSkinData playerEquipmentData = ExPropsPlayerSkinData.get(player);
if (playerEquipmentData != null) {
EquipmentWardrobeData ewd = playerEquipmentData.getEquipmentWardrobeData();
if (subOptionIndex < 4) {
ewd.armourOverride.set(subOptionIndex, !value);
}
if (subOptionIndex == 4) {
ewd.headOverlay = !value;
}
playerEquipmentData.setSkinInfo(ewd, true);
}
}
Aggregations