use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.
the class TileEntityArmourer method readCommonFromNBT.
@Override
public void readCommonFromNBT(NBTTagCompound compound) {
super.readCommonFromNBT(compound);
direction = ForgeDirection.getOrientation(compound.getByte(TAG_DIRECTION));
skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(compound.getString(TAG_TYPE));
// Update code for old saves
if (skinType == null && compound.hasKey(TAG_TYPE_OLD)) {
skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromLegacyId(compound.getInteger(TAG_TYPE_OLD) - 1);
}
if (compound.hasKey(TAG_OWNER_OLD, NBT.TAG_COMPOUND)) {
GameProfile gameProfile = NBTUtil.func_152459_a(compound.getCompoundTag(TAG_OWNER_OLD));
texture = new PlayerTexture(gameProfile.getName(), TextureType.USER);
}
showGuides = compound.getBoolean(TAG_SHOW_GUIDES);
showOverlay = compound.getBoolean(TAG_SHOW_OVERLAY);
if (compound.hasKey(TAG_SHOW_HELPER)) {
showHelper = compound.getBoolean(TAG_SHOW_HELPER);
}
skinProps = new SkinProperties();
skinProps.readFromNBT(compound);
if (compound.hasKey(TAG_TEXTURE, NBT.TAG_COMPOUND)) {
texture = PlayerTexture.fromNBT(compound.getCompoundTag(TAG_TEXTURE));
}
if (compound.hasKey(TAG_PAINT_DATA)) {
paintData = compound.getIntArray(TAG_PAINT_DATA);
}
}
use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.
the class RenderBlockMannequin method renderTileEntityAt.
public void renderTileEntityAt(TileEntityMannequin te, double x, double y, double z, float partialTickTime) {
mc.mcProfiler.startSection("armourersMannequin");
mc.mcProfiler.startSection("holidayCheck");
isHalloweenSeason = HolidayHelper.halloween_season.isHolidayActive();
isHalloween = HolidayHelper.halloween.isHolidayActive();
MannequinFakePlayer fakePlayer = te.getFakePlayer();
mc.mcProfiler.endStartSection("move");
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
ModRenderHelper.disableAlphaBlend();
int rotaion = te.getRotation();
GL11.glTranslated(x + 0.5D + te.getOffsetX(), y + 1.0D + te.getOffsetY(), z + 0.5D + te.getOffsetZ());
BipedRotations rots = te.getBipedRotations();
GL11.glRotated(Math.toDegrees(rots.chest.rotationX), 1F, 0F, 0F);
GL11.glRotated(Math.toDegrees(rots.chest.rotationY), 0F, 1F, 0F);
GL11.glRotated(Math.toDegrees(rots.chest.rotationZ), 0F, 0F, 1F);
GL11.glTranslated(0, 0.5D, 0);
GL11.glScalef(SCALE * 15, SCALE * 15, SCALE * 15);
GL11.glTranslated(0, SCALE * -1.6F, 0);
GL11.glScalef(-1, -1, 1);
GL11.glRotatef(rotaion * 22.5F, 0, 1, 0);
if (te.getIsDoll()) {
float dollScale = 0.5F;
GL11.glScalef(dollScale, dollScale, dollScale);
GL11.glTranslatef(0, SCALE * 24, 0);
}
mc.mcProfiler.endStartSection("getTexture");
ResourceLocation rl;
boolean slimModel = false;
boolean download;
PlayerTexture playerTexture = MannequinTextureHelper.getMannequinTexture(te);
rl = playerTexture.getResourceLocation();
slimModel = playerTexture.isSlimModel();
download = playerTexture.isDownloaded();
ModelMannequin model = modelSteve;
if (slimModel) {
model = modelAlex;
}
mc.mcProfiler.endStartSection("fakePlayer");
if (mannequinFakePlayer == null) {
mannequinFakePlayer = new MannequinFakePlayer(te.getWorldObj(), new GameProfile(null, "[Mannequin]"));
mannequinFakePlayer.posX = x;
mannequinFakePlayer.posY = y;
mannequinFakePlayer.posZ = z;
mannequinFakePlayer.prevPosX = x;
mannequinFakePlayer.prevPosY = y;
mannequinFakePlayer.prevPosZ = z;
}
if (te.getGameProfile() != null) {
if (te.getWorldObj() != null & fakePlayer != null) {
fakePlayer.setEntityId(te.xCoord * 31 * -te.zCoord);
fakePlayer.isAirBorne = te.isFlying();
fakePlayer.capabilities.isFlying = te.isFlying();
}
} else {
mannequinFakePlayer.setEntityId(te.xCoord * 31 * -te.zCoord);
mannequinFakePlayer.isAirBorne = te.isFlying();
mannequinFakePlayer.capabilities.isFlying = te.isFlying();
}
if (fakePlayer != null) {
fakePlayer.setEntityId(te.xCoord * 31 * -te.zCoord);
fakePlayer.isAirBorne = te.isFlying();
fakePlayer.capabilities.isFlying = te.isFlying();
}
if (te.getBipedRotations() != null) {
te.getBipedRotations().applyRotationsToBiped(model);
te.getBipedRotations().applyRotationsToBiped(renderPlayer.modelArmor);
te.getBipedRotations().applyRotationsToBiped(renderPlayer.modelArmorChestplate);
}
ApiRegistrar.INSTANCE.onRenderMannequin(te, te.getGameProfile());
model.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F);
model.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F);
model.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F);
model.bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F);
model.bipedRightLeg.setRotationPoint(-1.9F, 12.0F, 0.0F);
model.bipedLeftLeg.setRotationPoint(1.9F, 12.0F, 0.0F);
rots.applyRotationsToBiped(model);
model.bipedBody.rotateAngleX = 0;
model.bipedBody.rotateAngleY = 0;
model.bipedBody.rotateAngleZ = 0;
if (isHalloween) {
double dX = -x - 0.5F;
double dY = -y - 1.72F;
double dZ = -z - 0.5F;
double yaw = Math.atan2(dZ, dX);
double pitch = Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI;
yaw -= Math.toRadians(rotaion * 22.5F - 90F);
pitch += Math.PI / 2D;
model.bipedHead.rotateAngleX = (float) (pitch);
model.bipedHead.rotateAngleY = (float) (yaw);
model.bipedHeadwear.rotateAngleX = model.bipedHead.rotateAngleX;
model.bipedHeadwear.rotateAngleY = model.bipedHead.rotateAngleY;
}
mc.mcProfiler.endStartSection("textureBuild");
if (te.haveSkinsUpdated()) {
te.sp = getSkinPointers(te);
}
if (te.sp != null) {
ISkinPointer[] sp = te.sp;
Skin[] skins = new Skin[sp.length];
ISkinDye[] dyes = new ISkinDye[sp.length];
boolean hasPaintedSkin = false;
for (int i = 0; i < sp.length; i++) {
if (sp[i] != null) {
skins[i] = ClientSkinCache.INSTANCE.getSkin(sp[i]);
dyes[i] = sp[i].getSkinDye();
if (skins[i] != null) {
if (skins[i].hasPaintData() | SkinProperties.PROP_ARMOUR_OVERRIDE.getValue(skins[i].getProperties())) {
hasPaintedSkin = true;
}
}
}
}
if (hasPaintedSkin) {
if (te.skinTexture == null) {
te.skinTexture = new EntityTextureInfo();
}
te.skinTexture.updateTexture(rl);
te.skinTexture.updateSkinColour(te.getSkinColour());
te.skinTexture.updateHairColour(te.getHairColour());
te.skinTexture.updateSkins(skins);
te.skinTexture.updateDyes(dyes);
if (te.skinTexture.getNeedsUpdate()) {
if (lastTextureBuild + 200L < System.currentTimeMillis()) {
lastTextureBuild = System.currentTimeMillis();
rl = te.skinTexture.preRender();
}
} else {
rl = te.skinTexture.preRender();
}
}
}
mc.mcProfiler.endStartSection("textureBind");
bindTexture(rl);
mc.mcProfiler.endStartSection("selectModelRender");
te.getBipedRotations().hasCustomHead = hasCustomHead(te);
boolean selectingColour = false;
GuiMannequinTabSkinHair tabSkinHair = null;
if (mc.currentScreen instanceof GuiMannequin) {
GuiMannequin screen = (GuiMannequin) mc.currentScreen;
if (screen.tileEntity == te) {
tabSkinHair = screen.tabSkinAndHair;
if (tabSkinHair.selectingSkinColour | tabSkinHair.selectingHairColour) {
selectingColour = true;
}
}
}
if (selectingColour) {
GL11.glDisable(GL11.GL_LIGHTING);
if (te.isVisible() & !(te.getGameProfile() != null && te.getGameProfile().getName().equalsIgnoreCase("null"))) {
renderModel(te, model, fakePlayer);
}
tabSkinHair.hoverColour = getColourAtPos(Mouse.getX(), Mouse.getY());
GL11.glEnable(GL11.GL_LIGHTING);
}
mc.mcProfiler.endStartSection("modelRender");
if (te.isVisible() & !(te.getGameProfile() != null && te.getGameProfile().getName().equalsIgnoreCase("null"))) {
long time = System.currentTimeMillis();
int fadeTime = 1000;
int fade = (int) (time - playerTexture.getDownloadTime());
if (playerTexture.isDownloaded() & fade < fadeTime) {
bindTexture(AbstractClientPlayer.locationStevePng);
renderModel(te, model, fakePlayer);
bindTexture(rl);
ModRenderHelper.enableAlphaBlend();
GL11.glColor4f(1, 1, 1, fade / 1000F);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPolygonOffset(-3F, -3F);
renderModel(te, model, fakePlayer);
GL11.glPolygonOffset(0F, 0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
ModRenderHelper.disableAlphaBlend();
GL11.glColor4f(1, 1, 1, 1);
} else {
renderModel(te, model, fakePlayer);
}
}
mc.mcProfiler.endStartSection("earRender");
if (te.getGameProfile() != null && te.getGameProfile().getName().equals("deadmau5")) {
GL11.glPushMatrix();
GL11.glRotated(Math.toDegrees(model.bipedHead.rotateAngleZ), 0, 0, 1);
GL11.glRotated(Math.toDegrees(model.bipedHead.rotateAngleY), 0, 1, 0);
GL11.glRotated(Math.toDegrees(model.bipedHead.rotateAngleX), 1, 0, 0);
GL11.glTranslated(-5.5F * SCALE, 0, 0);
GL11.glTranslated(0, -6.5F * SCALE, 0);
model.bipedEars.render(SCALE);
GL11.glTranslated(11F * SCALE, 0, 0);
model.bipedEars.render(SCALE);
GL11.glPopMatrix();
}
mc.mcProfiler.endStartSection("magicCircle");
// Magic circle.
if (te.isRenderExtras() & te.isVisible()) {
Contributor contributor = Contributors.INSTANCE.getContributor(te.getGameProfile());
if (contributor != null) {
int offset = te.xCoord * te.yCoord * te.zCoord;
renderMagicCircle(contributor.r, contributor.g, contributor.b, partialTickTime, offset, te.getBipedRotations().isChild);
}
}
// Render items.
mc.mcProfiler.endStartSection("equippedItems");
double distance = Minecraft.getMinecraft().thePlayer.getDistance(te.xCoord + 0.5F, te.yCoord + 0.5F, te.zCoord + 0.5F);
if (distance <= ConfigHandlerClient.mannequinMaxEquipmentRenderDistance) {
renderEquippedItems(te, fakePlayer, model, distance);
}
mc.mcProfiler.endStartSection("reset");
model.bipedLeftLeg.rotateAngleZ = 0F;
model.bipedRightLeg.rotateAngleZ = 0F;
model.bipedHead.rotateAngleZ = 0F;
model.bipedHeadwear.rotateAngleZ = 0F;
renderPlayer.modelArmor.bipedLeftLeg.rotateAngleZ = 0F;
renderPlayer.modelArmor.bipedRightLeg.rotateAngleZ = 0F;
renderPlayer.modelArmor.bipedHead.rotateAngleZ = 0F;
renderPlayer.modelArmor.bipedHeadwear.rotateAngleZ = 0F;
renderPlayer.modelArmorChestplate.bipedLeftLeg.rotateAngleZ = 0F;
renderPlayer.modelArmorChestplate.bipedRightLeg.rotateAngleZ = 0F;
renderPlayer.modelArmorChestplate.bipedHead.rotateAngleZ = 0F;
renderPlayer.modelArmorChestplate.bipedHeadwear.rotateAngleZ = 0F;
mc.mcProfiler.endStartSection("pop");
GL11.glPopAttrib();
GL11.glPopAttrib();
GL11.glPopMatrix();
mc.mcProfiler.endSection();
mc.mcProfiler.endSection();
}
use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.
the class BlockBoundingBox method getColour.
@Override
public int getColour(IBlockAccess world, int x, int y, int z, int side) {
ForgeDirection sideBlock = ForgeDirection.getOrientation(side);
if (world.getBlock(x + sideBlock.offsetX, y + sideBlock.offsetY, z + sideBlock.offsetZ) == this) {
return 0x00FFFFFF;
}
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityBoundingBox) {
TileEntityArmourer parent = ((TileEntityBoundingBox) te).getParent();
if (parent != null) {
if (((TileEntityBoundingBox) te).getSkinPart() instanceof ISkinPartTypeTextured) {
Point texturePoint = SkinTextureHelper.getTextureLocationFromWorldBlock((TileEntityBoundingBox) te, side);
int colour = parent.getPaintData(texturePoint.x, texturePoint.y);
int paintType = BitwiseUtils.getUByteFromInt(colour, 0);
if (paintType != 0) {
return colour;
} else {
if (te.getWorldObj().isRemote) {
PlayerTexture playerTexture = ClientProxy.playerTextureDownloader.getPlayerTexture(parent.getTexture());
BufferedImage playerSkin = SkinHelper.getBufferedImageSkin(playerTexture.getResourceLocation());
if (playerSkin != null) {
colour = playerSkin.getRGB(texturePoint.x, texturePoint.y);
return colour;
}
}
}
}
}
}
return 0x00FFFFFF;
}
use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.
the class TileEntityArmourer method onDataPacket.
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
NBTTagCompound compound = packet.func_148857_g();
PlayerTexture playerTexture = texture;
readBaseFromNBT(compound);
readCommonFromNBT(compound);
if (!texture.equals(playerTexture)) {
textureOld = playerTexture;
}
syncWithClients();
loadedArmourItem = true;
}
use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.
the class RenderBlockArmourer method renderTileEntityAt.
public void renderTileEntityAt(TileEntityArmourer te, double x, double y, double z, float tickTime) {
Minecraft mc = Minecraft.getMinecraft();
mc.mcProfiler.startSection("armourersArmourer");
float scale = 0.0625F;
ISkinType skinType = te.getSkinType();
mc.mcProfiler.startSection("textureBuild");
if (te.skinTexture == null) {
te.skinTexture = new SkinTexture();
}
PlayerTexture playerTexture = ClientProxy.playerTextureDownloader.getPlayerTexture(te.getTexture());
if (!playerTexture.isDownloaded()) {
playerTexture = ClientProxy.playerTextureDownloader.getPlayerTexture(te.getTextureOld());
}
te.skinTexture.updateForResourceLocation(playerTexture.getResourceLocation());
te.skinTexture.updatePaintData(te.getPaintData());
mc.mcProfiler.endSection();
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glColor3f(0.77F, 0.77F, 0.77F);
ModRenderHelper.disableLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glTranslated(x, y, z);
if (te.getDirection() != null) {
switch(te.getDirection()) {
case EAST:
GL11.glRotatef(270, 0, 1, 0);
break;
case SOUTH:
GL11.glRotatef(180, 0, 1, 0);
break;
case WEST:
GL11.glRotatef(90, 0, 1, 0);
break;
default:
break;
}
}
GL11.glTranslated(0, te.getHeightOffset(), 0);
GL11.glScalef(-1, -1, 1);
GL11.glScalef(16, 16, 16);
if (skinType != null) {
mc.mcProfiler.startSection("modelRender");
boolean hidden = false;
if (skinType.getVanillaArmourSlotId() != -1) {
if (SkinProperties.PROP_ARMOUR_OVERRIDE.getValue(te.getSkinProps())) {
hidden = true;
}
}
GL11.glPolygonOffset(3F, 3F);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
if (!hidden) {
long time = System.currentTimeMillis();
int fadeTime = 1000;
int fade = (int) (time - playerTexture.getDownloadTime());
if (playerTexture.isDownloaded() & fade < fadeTime) {
PlayerTexture oldTexture = te.getTextureOld();
oldTexture = ClientProxy.playerTextureDownloader.getPlayerTexture(oldTexture);
bindTexture(oldTexture.getResourceLocation());
SkinRenderHelper.renderBuildingGuide(skinType, scale, te.isShowOverlay(), te.isShowHelper());
te.skinTexture.bindTexture();
ModRenderHelper.enableAlphaBlend();
GL11.glColor4f(1, 1, 1, fade / 1000F);
GL11.glPolygonOffset(-6F, -6F);
SkinRenderHelper.renderBuildingGuide(skinType, scale, te.isShowOverlay(), te.isShowHelper());
GL11.glPolygonOffset(3F, 3F);
ModRenderHelper.disableAlphaBlend();
GL11.glColor4f(1, 1, 1, 1);
} else {
te.skinTexture.bindTexture();
SkinRenderHelper.renderBuildingGuide(skinType, scale, te.isShowOverlay(), te.isShowHelper());
}
}
GL11.glPolygonOffset(-3F, -3F);
mc.mcProfiler.endSection();
mc.mcProfiler.startSection("renderGuideGrid");
SkinRenderHelper.renderBuildingGrid(skinType, scale, te.isShowGuides(), hidden, SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(te.getSkinProps()));
mc.mcProfiler.endSection();
GL11.glPolygonOffset(0F, 0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
}
GL11.glPopAttrib();
GL11.glPopMatrix();
GL11.glColor3f(1F, 1F, 1F);
ModRenderHelper.enableLighting();
GL11.glEnable(GL11.GL_LIGHTING);
mc.mcProfiler.endSection();
}
Aggregations