Add translations, fix some rendering in guiskins and make it modular

This commit is contained in:
Matthew Messinger 2015-08-12 20:03:54 -04:00
parent a49bae5b3b
commit f1048026b3
12 changed files with 381 additions and 872 deletions

View file

@ -149,11 +149,11 @@ public class MineLittlePony implements InitCompleteListener {
@Override
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
this.ponyManager.setPonyLevel(PonyLevel.parse(this.config.getIntProperty("ponylevel")));
this.ponyManager.setUseSizes(this.config.getIntProperty("sizes"));
this.ponyManager.setPonyArmor(this.config.getIntProperty("ponyarmor"));
this.ponyManager.setShowSnuzzles(this.config.getIntProperty("snuzzles"));
this.ponyManager.setShowScale(this.config.getIntProperty("showscale"));
this.ponyManager.setPonyLevel(PonyLevel.parse(this.config.getIntPropertySafe("ponylevel", 0, 2)));
this.ponyManager.setUseSizes(this.config.getIntPropertySafe("sizes"));
this.ponyManager.setPonyArmor(this.config.getIntPropertySafe("ponyarmor"));
this.ponyManager.setShowSnuzzles(this.config.getIntPropertySafe("snuzzles"));
this.ponyManager.setShowScale(this.config.getIntPropertySafe("showscale"));
if (inGame && minecraft.currentScreen == null && guiKeybinding.isPressed()) {
minecraft.displayGuiScreen(new MineLittlePonyGUI());
}

View file

@ -1,25 +1,43 @@
package com.minelittlepony.minelp.gui;
import com.minelittlepony.minelp.MineLittlePony;
import com.voxelmodpack.common.properties.VoxelProperty;
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
import net.minecraft.client.resources.I18n;
public class MineLittlePonyGUI extends GuiVoxelBoxSettingsPanel {
private static final String pref = "minelp.options.";
private final String title = I18n.format(pref + "title");
private final String ponylevel = I18n.format(pref + "ponylevel");
private final String options = I18n.format(pref + "options");
private final String hd = I18n.format(pref + "hd");
private final String sizes = I18n.format(pref + "sizes");
private final String ponyarmor = I18n.format(pref + "ponyarmor");
private final String snuzzles = I18n.format(pref + "snuzzles");
private final String showscale = I18n.format(pref + "showscale");
public MineLittlePonyGUI() {
// PonyManager ponyManager = PonyManager.getInstance();
this.config = MineLittlePony.getConfig();
byte col1 = 30;
this.properties.add(new VoxelPropertyIntSlider(this.config, "ponylevel", "Pony Level", PANEL_LEFT, PANEL_TOP + 24));
this.properties.add(new VoxelPropertyLabel("Pony Options", PANEL_LEFT + 15, PANEL_TOP + 58));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "hd", "Enable MineLP skin server (requires restart)", PANEL_LEFT + col1, PANEL_TOP + 72));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "sizes", "Allow all different sizes of pony", PANEL_LEFT + col1, PANEL_TOP + 90));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "ponyarmor", "Use Mine Little Pony compatible armor", PANEL_LEFT + col1, PANEL_TOP + 108));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "snuzzles", "Display snuzzles on ponies", PANEL_LEFT + col1, PANEL_TOP + 126));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "showscale", "Use show-accurate scaling", PANEL_LEFT + col1, PANEL_TOP + 144));
this.properties.add(new VoxelPropertyIntSlider(this.config, "ponylevel", ponylevel, PANEL_LEFT, PANEL_TOP + 24));
this.properties.add(new VoxelPropertyLabel(options, PANEL_LEFT + 15, PANEL_TOP + 58));
this.properties.add(check("hd", hd, PANEL_LEFT + col1, PANEL_TOP + 72));
this.properties.add(check("sizes", sizes, PANEL_LEFT + col1, PANEL_TOP + 90));
this.properties.add(check("ponyarmor", ponyarmor, PANEL_LEFT + col1, PANEL_TOP + 108));
this.properties.add(check("snuzzles", snuzzles, PANEL_LEFT + col1, PANEL_TOP + 126));
this.properties.add(check("showscale", showscale, PANEL_LEFT + col1, PANEL_TOP + 144));
}
private VoxelProperty<?> check(String binding, String text, int xPos, int yPos) {
return new FakeVoxelPropertyCheckBox(this.config, binding, text, xPos, yPos);
}
@Override
public String getPanelTitle() {
return "Mine Little Pony Settings";
return title;
}
}

View file

@ -1,24 +1,42 @@
package com.minelittlepony.minelp.gui;
import com.minelittlepony.minelp.MineLittlePony;
import com.voxelmodpack.common.properties.VoxelProperty;
import com.voxelmodpack.common.properties.VoxelPropertyLabel;
import com.voxelmodpack.common.properties.gui.GuiVoxelBoxSettingsPanel;
import net.minecraft.client.resources.I18n;
public class MineLittlePonyGUIMob extends GuiVoxelBoxSettingsPanel {
private static final String pref = "minelp.mobs.";
private final String restart1 = I18n.format("minelp.restart1");
private final String restart2 = I18n.format("minelp.restart2");
private final String title = I18n.format(pref + "title");
private final String villagers = I18n.format(pref + "villagers");
private final String zombies = I18n.format(pref + "zombies");
private final String zombiePigmen = I18n.format(pref + "zombiepigmen");
private final String skeletons = I18n.format(pref + "skeletons");
public MineLittlePonyGUIMob() {
// PonyManager ponyManager = PonyManager.getInstance();
this.config = MineLittlePony.getConfig();
byte col1 = 30;
this.properties.add(new VoxelPropertyLabel("If you make any changes here, you must restart", PANEL_LEFT + 15, PANEL_TOP + 11, 16737894));
this.properties.add(new VoxelPropertyLabel("Minecraft before they will take effect!", PANEL_LEFT + 15, PANEL_TOP + 23, 16737894));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "villagers", "Ponify villagers", PANEL_LEFT + col1, PANEL_TOP + 42));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "zombies", "Ponify zombies", PANEL_LEFT + col1, PANEL_TOP + 60));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "pigzombies", "Ponify zombie pigmen", PANEL_LEFT + col1, PANEL_TOP + 78));
this.properties.add(new FakeVoxelPropertyCheckBox(this.config, "skeletons", "Ponify skeletons", PANEL_LEFT + col1, PANEL_TOP + 96));
this.properties.add(new VoxelPropertyLabel(restart1, PANEL_LEFT + 15, PANEL_TOP + 11, 0xff6666));
this.properties.add(new VoxelPropertyLabel(restart2, PANEL_LEFT + 15, PANEL_TOP + 23, 0xff6666));
this.properties.add(check("villagers", villagers, PANEL_LEFT + col1, PANEL_TOP + 42));
this.properties.add(check("zombies", zombies, PANEL_LEFT + col1, PANEL_TOP + 60));
this.properties.add(check("pigzombies", zombiePigmen, PANEL_LEFT + col1, PANEL_TOP + 78));
this.properties.add(check("skeletons", skeletons, PANEL_LEFT + col1, PANEL_TOP + 96));
}
private VoxelProperty<?> check(String binding, String text, int xPos, int yPos) {
return new FakeVoxelPropertyCheckBox(this.config, binding, text, xPos, yPos);
}
@Override
public String getPanelTitle() {
return "Mine Little Pony Mob Settings";
return title;
}
}

View file

@ -1,764 +1,38 @@
package com.minelittlepony.minelp.hdskins.gui;
import static net.minecraft.client.renderer.GlStateManager.*;
import java.awt.Color;
import java.awt.Window.Type;
import java.awt.dnd.DropTarget;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.DoubleBuffer;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
import com.google.common.collect.Iterables;
import com.minelittlepony.minelp.PonyManager;
import com.minelittlepony.minelp.util.FileDropListener;
import com.minelittlepony.minelp.hdskins.gui.EntityPonyModel;
import com.minelittlepony.minelp.util.MineLPLogger;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.common.net.upload.IUploadCompleteCallback;
import com.voxelmodpack.common.net.upload.ThreadMultipartPostUpload;
import com.voxelmodpack.common.net.upload.awt.IOpenFileCallback;
import com.voxelmodpack.common.net.upload.awt.ThreadOpenFilePNG;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.mod.HDSkinsModCore;
import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
import com.voxelmodpack.hdskins.gui.GuiSkins;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Session;
public class GuiSkinsMineLP extends GuiSkins {
public class GuiSkinsMineLP extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback, IPanoramaRenderer {
private static final ResourceLocation vignette = new ResourceLocation("textures/misc/vignette.png");
private static final int MAX_SKIN_DIMENSION = 8192;
private static final String skinServerId = "7853dfddc358333843ad55a2c7485c4aa0380a51";
private int updateCounter = 0;
private ResourceLocation viewportTexture;
private IPanoramaRenderer panoramaRenderer;
private static final ResourceLocation[] cubemapTextures = {
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_0.png"),
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_1.png"),
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_2.png"),
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_3.png"),
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_4.png"),
new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_5.png") };
private GuiButton btnBrowse;
private GuiButton btnUpload;
private GuiButton btnClear;
private GuiButton btnBack;
private EntityPonyModel localPlayer;
private EntityPonyModel remotePlayer;
protected DoubleBuffer doubleBuffer;
private String screenTitle;
private String uploadError;
private volatile String skinMessage = "Choose a file";
private String skinUploadMessage = "Uploading skin please wait...";
private volatile boolean fetchingSkin;
private volatile boolean uploadingSkin;
private volatile boolean pendingRemoteSkinRefresh;
private volatile boolean throttledByMojang;
private int refreshCounter = -1;
private ThreadOpenFilePNG openFileThread;
private ThreadMultipartPostUpload threadSkinUpload;
private Object skinLock = new Object();
private File pendingSkinFile;
private File selectedSkin;
private BufferedImage pendingSkinImage;
private float uploadOpacity = 0.0F;
private float lastPartialTick;
private JFrame fileDrop;
public GuiSkinsMineLP() {
Minecraft minecraft = Minecraft.getMinecraft();
this.screenTitle = "Skin Manager";
GameProfile profile = minecraft.getSession().getProfile();
this.localPlayer = new EntityPonyModel(profile);
this.remotePlayer = new EntityPonyModel(profile);
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
rm.renderEngine = minecraft.getTextureManager();
rm.options = minecraft.gameSettings;
rm.livingPlayer = this.localPlayer;
this.setRemoteSkin();
this.fetchingSkin = true;
this.panoramaRenderer = HDSkinsModCore.getPanoramaRenderer(this);
@Override
protected EntityPlayerModel getModel(GameProfile profile) {
return new EntityPonyModel(profile);
}
@Override
public void updateScreen() {
++this.updateCounter;
this.panoramaRenderer.updatePanorama();
this.localPlayer.updateModel();
this.remotePlayer.updateModel();
if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) {
this.fetchingSkin = false;
this.btnClear.enabled = true;
}
synchronized (this.skinLock) {
if (this.pendingSkinFile != null) {
this.localPlayer.setLocalSkin(this.pendingSkinFile);
this.selectedSkin = this.pendingSkinFile;
this.pendingSkinFile = null;
protected void onSetLocalSkin(BufferedImage skin) {
MineLPLogger.debug("Invalidating old local skin, checking updated local skin");
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture())
.checkSkin(this.pendingSkinImage);
this.pendingSkinImage = null;
this.btnUpload.enabled = true;
}
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).checkSkin(skin);
}
if (this.pendingRemoteSkinRefresh) {
this.pendingRemoteSkinRefresh = false;
this.fetchingSkin = true;
this.btnClear.enabled = false;
this.setRemoteSkin();
@Override
protected void onSetRemoteSkin() {
MineLPLogger.debug("Invalidating old remove skin, checking updated remote skin");
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture())
.invalidateSkinCheck();
}
if (this.throttledByMojang) {
if (this.refreshCounter == -1) {
this.refreshCounter = 200;
} else if (this.refreshCounter > 0) {
--this.refreshCounter;
} else {
this.refreshCounter = -1;
this.throttledByMojang = false;
this.setRemoteSkin();
}
}
}
private void setRemoteSkin() {
try {
this.remotePlayer.setRemoteSkin();
} catch (Exception var2) {
var2.printStackTrace();
this.throttledByMojang = true;
}
}
@Override
public void updatePanorama() {}
@Override
public int getUpdateCounter() {
return this.updateCounter;
}
@Override
public void setWorldAndResolution(Minecraft par1Minecraft, int par2, int par3) {
super.setWorldAndResolution(par1Minecraft, par2, par3);
this.panoramaRenderer.setPanoramaResolution(par1Minecraft, par2, par3);
}
@Override
public void setPanoramaResolution(Minecraft minecraft, int width, int height) {}
protected List<GuiButton> getControlList() {
return this.buttonList;
}
@Override
public void initGui() {
enableDnd();
this.panoramaRenderer.initPanoramaRenderer();
this.getControlList().clear();
this.getControlList().add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse..."));
this.getControlList()
.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>"));
this.getControlList().add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear"));
this.getControlList()
.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close"));
this.btnUpload.enabled = false;
this.btnBrowse.enabled = !this.mc.isFullScreen();
}
/**
* @wbp.parser.entryPoint
*/
private void enableDnd() {
if (!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7))
return;
if (fileDrop != null) {
fileDrop.setVisible(true);
return;
}
fileDrop = new JFrame("Skin Drop");
fileDrop.setType(Type.UTILITY);
fileDrop.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
fileDrop.setResizable(false);
fileDrop.setTitle("Skin Drop");
fileDrop.setSize(256, 256);
fileDrop.setAlwaysOnTop(true);
fileDrop.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));
panel.setBounds(10, 11, 230, 205);
fileDrop.getContentPane().add(panel);
JLabel txtInst = new JLabel("Drop skin file here");
txtInst.setHorizontalAlignment(SwingConstants.CENTER);
txtInst.setVerticalAlignment(SwingConstants.CENTER);
panel.add(txtInst);
DropTarget dt = new DropTarget();
fileDrop.setDropTarget(dt);
try {
dt.addDropTargetListener(new FileDropListener() {
@Override
public void onDrop(List<File> files) {
File skin = Iterables.getFirst(files, null);
if (skin != null) {
loadLocalFile(skin);
}
}
});
fileDrop.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void initPanoramaRenderer() {
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama",
new DynamicTexture(256, 256));
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
if (this.fileDrop != null)
this.fileDrop.dispose();
this.localPlayer.releaseTextures();
this.remotePlayer.releaseTextures();
PonyManager.getInstance().getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).invalidateSkinCheck();
PonyManager.getInstance().getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck();
}
@Override
public void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
this.openFileThread = null;
this.btnBrowse.enabled = true;
if (dialogResult == 0) {
this.loadLocalFile(fileDialog.getSelectedFile());
}
}
private void loadLocalFile(File skinFile) {
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
@Override
public void run() {
localPlayer.releaseTextures();
}
});
if (!skinFile.exists()) {
this.skinMessage = "File not readable";
} else if (!FilenameUtils.isExtension(skinFile.getName(), new String[] { "png", "PNG" })) {
this.skinMessage = "File not PNG";
} else {
BufferedImage chosenImage;
try {
chosenImage = ImageIO.read(skinFile);
} catch (IOException var6) {
this.skinMessage = "Error opening skin file";
var6.printStackTrace();
return;
}
if (chosenImage == null) {
this.skinMessage = "Error opening skin file";
} else if (isPowerOfTwo(chosenImage.getWidth())
&& (chosenImage.getWidth() == chosenImage.getHeight() * 2
|| chosenImage.getWidth() == chosenImage.getHeight())
&& chosenImage.getWidth() <= MAX_SKIN_DIMENSION
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
synchronized (this.skinLock) {
this.pendingSkinFile = skinFile;
this.pendingSkinImage = chosenImage;
}
} else {
this.skinMessage = "Not a valid skin file";
}
}
}
@Override
protected void actionPerformed(GuiButton guiButton) {
if (this.openFileThread == null && !this.uploadingSkin) {
if (this.uploadError != null) {
this.uploadError = null;
} else {
if (guiButton.id == this.btnBrowse.id) {
this.selectedSkin = null;
this.localPlayer.releaseTextures();
this.openFileThread = new ThreadOpenFilePNG(this.mc, "Choose skin", this);
this.openFileThread.start();
guiButton.enabled = false;
}
if (guiButton.id == this.btnUpload.id) {
if (this.selectedSkin != null) {
this.uploadSkin(this.mc.getSession(), this.selectedSkin);
this.btnUpload.enabled = false;
} else {
this.setUploadError("Please select a skin first");
}
}
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) {
this.clearUploadedSkin(this.mc.getSession());
this.btnUpload.enabled = this.selectedSkin != null;
}
if (guiButton.id == this.btnBack.id) {
this.mc.displayGuiScreen(new GuiMainMenu());
}
}
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
if (this.uploadError != null) {
this.uploadError = null;
} else {
super.mouseClicked(mouseX, mouseY, button);
byte top = 30;
int bottom = this.height - 40;
int mid = this.width / 2;
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top
&& mouseY < bottom) {
this.localPlayer.swingArm();
this.remotePlayer.swingArm();
}
}
}
@Override
protected void keyTyped(char keyChar, int keyCode) throws IOException {
if (this.openFileThread == null && !this.uploadingSkin) {
super.keyTyped(keyChar, keyCode);
}
}
public void setupCubemapCamera() {
matrixMode(5889);
pushMatrix();
loadIdentity();
GLU.gluPerspective(150.0F, 1.0F, 0.05F, 10.0F);
matrixMode(5888);
pushMatrix();
loadIdentity();
}
public void revertPanoramaMatrix() {
matrixMode(5889);
popMatrix();
matrixMode(5888);
popMatrix();
}
private void renderCubeMapTexture(int mouseX, int mouseY, float partialTick) {
this.setupCubemapCamera();
color(1.0F, 1.0F, 1.0F, 1.0F);
rotate(180.0F, 1.0F, 0.0F, 0.0F);
GL11.glEnable(3042);
GL11.glDisable(3008);
GL11.glDisable(2884);
depthMask(false);
blendFunc(770, 771);
byte blendIterations = 8;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
for (int blendPass = 0; blendPass < blendIterations * blendIterations; ++blendPass) {
pushMatrix();
float offsetX = ((float) (blendPass % blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
float offsetY = ((float) (blendPass / blendIterations) / (float) blendIterations - 0.5F) / 64.0F;
float offsetZ = 0.0F;
translate(offsetX, offsetY, offsetZ);
rotate(MathHelper.sin((this.updateCounter + 200 + partialTick) / 400.0F) * 25.0F + 20.0F, 1.0F,
0.0F, 0.0F);
rotate(-(this.updateCounter + 200 + partialTick) * 0.1F, 0.0F, 1.0F, 0.0F);
for (int cubeSide = 0; cubeSide < 6; ++cubeSide) {
pushMatrix();
if (cubeSide == 1) {
rotate(90.0F, 0.0F, 1.0F, 0.0F);
}
if (cubeSide == 2) {
rotate(180.0F, 0.0F, 1.0F, 0.0F);
}
if (cubeSide == 3) {
rotate(-90.0F, 0.0F, 1.0F, 0.0F);
}
if (cubeSide == 4) {
rotate(90.0F, 1.0F, 0.0F, 0.0F);
}
if (cubeSide == 5) {
rotate(-90.0F, 1.0F, 0.0F, 0.0F);
}
this.mc.getTextureManager().bindTexture(cubemapTextures[cubeSide]);
wr.startDrawingQuads();
wr.setColorRGBA_I(16777215, 255 / (blendPass + 1));
wr.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0D, 0.0D);
wr.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0D, 0.0D);
wr.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0D, 1.0D);
wr.addVertexWithUV(-1.0D, 1.0D, 1.0D, 0.0D, 1.0D);
tessellator.draw();
popMatrix();
}
popMatrix();
colorMask(true, true, true, false);
}
wr.setTranslation(0.0D, 0.0D, 0.0D);
colorMask(true, true, true, true);
depthMask(true);
GL11.glEnable(2884);
GL11.glEnable(3008);
GL11.glEnable(2929);
this.revertPanoramaMatrix();
}
private void rotateAndBlurCubemap(float partialTick) {
this.mc.getTextureManager().bindTexture(this.viewportTexture);
GL11.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, 256, 256);
GL11.glEnable(3042);
blendFunc(770, 771);
colorMask(true, true, true, false);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads();
byte blurPasses = 4;
for (int blurPass = 0; blurPass < blurPasses; ++blurPass) {
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (blurPass + 1));
float var7 = (blurPass - blurPasses / 2) / 256.0F;
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.0F + var7, 0.0D);
wr.addVertexWithUV(this.width, 0.0D, this.zLevel, 1.0F + var7, 0.0D);
wr.addVertexWithUV(0.0D, 0.0D, this.zLevel, 1.0F + var7, 1.0D);
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.0F + var7, 1.0D);
}
tessellator.draw();
colorMask(true, true, true, true);
GL11.glDisable(3042);
}
@Override
public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) {
GL11.glViewport(0, 0, 256, 256);
this.renderCubeMapTexture(mouseX, mouseY, partialTicks);
GL11.glDisable(3553);
GL11.glEnable(3553);
for (int tessellator = 0; tessellator < 8; ++tessellator) {
this.rotateAndBlurCubemap(partialTicks);
}
GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads();
float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height;
float uSample = this.height * aspect / 256.0F;
float vSample = this.width * aspect / 256.0F;
GL11.glTexParameteri(3553, 10241, 9729);
GL11.glTexParameteri(3553, 10240, 9729);
wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
wr.addVertexWithUV(0.0D, this.height, this.zLevel, 0.5F - uSample, 0.5F + vSample);
wr.addVertexWithUV(this.width, this.height, this.zLevel, 0.5F - uSample, 0.5F - vSample);
wr.addVertexWithUV(this.width, 0.0D, this.zLevel, 0.5F + uSample, 0.5F - vSample);
wr.addVertexWithUV(0.0D, 0.0D, this.zLevel, 0.5F + uSample, 0.5F + vSample);
tessellator.draw();
return true;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTick) {
float deltaTime = this.updateCounter + partialTick - this.lastPartialTick;
this.lastPartialTick = this.updateCounter + partialTick;
GL11.glDisable(2912);
this.mc.entityRenderer.disableLightmap();
this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick);
byte top = 30;
int bottom = this.height - 40;
int mid = this.width / 2;
int horizon = this.height / 2 + this.height / 5;
GL11.glPushAttrib(1048575);
Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE);
Gui.drawRect(mid + 30, top, this.width - 30, bottom, Integer.MIN_VALUE);
this.drawGradientRect(30, horizon, mid - 30, bottom, -2130706433, 16777215);
this.drawGradientRect(mid + 30, horizon, this.width - 30, bottom, -2130706433, 16777215);
super.drawScreen(mouseX, mouseY, partialTick);
popAttrib();
this.enableClipping(30, bottom);
float yPos = this.height * 0.75F;
float xPos1 = this.width * 0.25F;
float xPos2 = this.width * 0.75F;
float scale = this.height * 0.25F;
this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, xPos1 - mouseX, yPos - scale * 1.8F - mouseY,
partialTick);
this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, xPos2 - mouseX, yPos - scale * 1.8F - mouseY,
partialTick);
this.disableClipping();
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 10, 16777215);
this.fontRendererObj.drawStringWithShadow("Local Skin", 34, 34, 16777215);
this.fontRendererObj.drawStringWithShadow("Server Skin", this.width / 2 + 34, 34, 16777215);
GL11.glDisable(2929);
depthMask(false);
this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 0, -520093697);
this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, -520093697);
int labelwidth = (this.width / 2 - 80) / 2;
int opacity;
if (!this.localPlayer.isUsingLocalTexture()) {
opacity = this.fontRendererObj.getStringWidth(this.skinMessage) / 2;
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, -1342177280);
this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4,
16777215);
}
if (this.fetchingSkin) {
String opacity1;
if (this.throttledByMojang) {
opacity1 = "\u00a7cMojang API Error!";
String stringWidth = "Please wait 1 minute";
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16,
-1342177280);
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10,
16777215);
this.fontRendererObj.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2),
this.height / 2 + 2, 16777215);
} else {
opacity1 = "Fetching skin...";
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12,
-1342177280);
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4,
16777215);
}
}
if (this.uploadingSkin || this.uploadOpacity > 0.0F) {
if (!this.uploadingSkin) {
this.uploadOpacity -= deltaTime * 0.05F;
} else if (this.uploadOpacity < 1.0F) {
this.uploadOpacity += deltaTime * 0.1F;
}
if (this.uploadOpacity > 1.0F) {
this.uploadOpacity = 1.0F;
}
opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255;
if (this.uploadOpacity > 0.0F) {
Gui.drawRect(0, 0, this.width, this.height, opacity << 24 | 0);
if (this.uploadingSkin) {
this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2,
this.height / 2, opacity << 24 | 16777215);
}
}
}
if (this.uploadError != null) {
Gui.drawRect(0, 0, this.width, this.height, -1342177280);
this.drawCenteredString(this.fontRendererObj, "Uploading skin failed", this.width / 2, this.height / 2 - 10,
-171);
this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2,
-43691);
}
depthMask(true);
GL11.glEnable(2929);
}
protected void renderVignette(int mouseX, int mouseY, float partialTick) {
GL11.glDisable(2929);
depthMask(false);
blendFunc(1, 774);
color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(vignette);
GL11.glLogicOp(5386);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads();
wr.addVertexWithUV(0.0D, this.height, -90.0D, 0.0D, 1.0D);
wr.addVertexWithUV(this.width, this.height, -90.0D, 1.0D, 1.0D);
wr.addVertexWithUV(this.width, 0.0D, -90.0D, 1.0D, 0.0D);
wr.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
tessellator.draw();
depthMask(true);
GL11.glDisable(3058);
GL11.glEnable(2929);
color(1.0F, 1.0F, 1.0F, 1.0F);
blendFunc(770, 771);
}
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale,
float mouseX, float mouseY, float partialTick) {
GL11.glEnable(2903);
pushMatrix();
translate(xPosition, yPosition, 300.0F);
scale(-scale, scale, scale);
rotate(180.0F, 0.0F, 0.0F, 1.0F);
rotate(135.0F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
rotate(-135.0F, 0.0F, 1.0F, 0.0F);
rotate(15.0F, 1.0F, 0.0F, 0.0F);
rotate((this.updateCounter + partialTick) * 2.5F, 0.0F, 1.0F, 0.0F);
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
translate(0.0D, thePlayer.getYOffset(), 0.0D);
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
rm.playerViewY = 180.0F;
rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F);
popMatrix();
RenderHelper.disableStandardItemLighting();
GL11.glDisable('\u803a');
}
protected final void enableClipping(int yTop, int yBottom) {
if (this.doubleBuffer == null) {
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
}
this.doubleBuffer.clear();
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-yTop)).flip();
GL11.glClipPlane(12288, this.doubleBuffer);
this.doubleBuffer.clear();
this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip();
GL11.glClipPlane(12289, this.doubleBuffer);
GL11.glEnable(12288);
GL11.glEnable(12289);
}
protected final void disableClipping() {
GL11.glDisable(12289);
GL11.glDisable(12288);
}
public static boolean isPowerOfTwo(int number) {
return number != 0 && (number & number - 1) == 0;
}
private boolean clearUploadedSkin(Session session) {
if (!this.registerServerConnection(session, skinServerId)) {
return false;
} else {
HashMap<String, Object> sourceData = new HashMap<String, Object>();
sourceData.put("user", session.getUsername());
sourceData.put("uuid", session.getPlayerID());
sourceData.put("clear", "1");
this.uploadError = null;
this.uploadingSkin = true;
this.skinUploadMessage = "Sending request to server please wait...";
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/",
sourceData, this);
this.threadSkinUpload.start();
return true;
}
}
private boolean uploadSkin(Session session, File skinFile) {
if (!this.registerServerConnection(session, skinServerId)) {
return false;
} else {
HashMap<String, Object> sourceData = new HashMap<String, Object>();
sourceData.put("user", session.getUsername());
sourceData.put("uuid", session.getPlayerID());
sourceData.put("skin", skinFile);
this.uploadError = null;
this.uploadingSkin = true;
this.skinUploadMessage = "Uploading skin please wait...";
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/",
sourceData, this);
this.threadSkinUpload.start();
return true;
}
}
private void setUploadError(String error) {
this.uploadError = error.startsWith("ERROR: ") ? error.substring(7) : error;
this.btnUpload.enabled = true;
}
@Override
public void onUploadComplete(String response) {
LiteLoaderLogger.info("Upload completed with: %s", new Object[] { response });
this.uploadingSkin = false;
this.threadSkinUpload = null;
if (!response.equalsIgnoreCase("OK")) {
this.setUploadError(response);
} else {
this.pendingRemoteSkinRefresh = true;
}
}
private boolean registerServerConnection(Session session, String serverId) {
try {
MinecraftSessionService e = (new YggdrasilAuthenticationService(this.mc.getProxy(),
UUID.randomUUID().toString())).createMinecraftSessionService();
e.joinServer(session.getProfile(), session.getToken(), serverId);
return true;
} catch (AuthenticationException var4) {
this.setUploadError(var4.toString());
var4.printStackTrace();
return false;
}
}
static {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
}
}

View file

@ -138,7 +138,8 @@ public class LayerHeldPonyItem implements LayerRenderer {
if (!(drop.getItem() instanceof ItemBlock) || !drop.getItem().isFull3D()) {
translate(0.02F, -0.06F, -0.02F);
}
Minecraft.getMinecraft().getItemRenderer().renderItem(entity, drop, TransformType.THIRD_PERSON);
// Minecraft.getMinecraft().getItemRenderer().renderItem(entity, drop,
// TransformType.THIRD_PERSON);
popAttrib();
popMatrix();
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.minelp.util;
package com.voxelmodpack.hdskins.gui;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;

View file

@ -2,6 +2,9 @@ package com.voxelmodpack.hdskins.gui;
import static net.minecraft.client.renderer.GlStateManager.*;
import java.awt.Color;
import java.awt.Window.Type;
import java.awt.dnd.DropTarget;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@ -11,22 +14,34 @@ import java.util.List;
import java.util.UUID;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mumfrey.liteloader.gl.GL;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.common.net.upload.IUploadCompleteCallback;
import com.voxelmodpack.common.net.upload.ThreadMultipartPostUpload;
import com.voxelmodpack.common.net.upload.awt.IOpenFileCallback;
import com.voxelmodpack.common.net.upload.awt.ThreadOpenFilePNG;
import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.mod.HDSkinsModCore;
import com.voxelmodpack.voxelmenu.IPanoramaRenderer;
@ -40,12 +55,13 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Session;
public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback, IPanoramaRenderer {
private static final ResourceLocation vignette = new ResourceLocation("textures/misc/vignette.png");
private static final int MAX_SKIN_DIMENSION = 8192;
private static final String skinServerId = "7853dfddc358333843ad55a2c7485c4aa0380a51";
private int updateCounter = 0;
@ -67,23 +83,43 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
protected DoubleBuffer doubleBuffer;
private String screenTitle;
private String uploadError;
private volatile String skinMessage = "Choose a file";
private String skinUploadMessage = "Uploading skin please wait...";
private volatile String skinMessage = I18n.format("hdskins.choose");
private String skinUploadMessage = I18n.format("hdskins.request");
private volatile boolean fetchingSkin;
private volatile boolean uploadingSkin;
private volatile boolean pendingRemoteSkinRefresh;
private volatile boolean throttledByMojang;
private int refreshCounter = -1;
private ThreadOpenFilePNG openFileThread;
private ThreadMultipartPostUpload threadSkinUpload;
private Object skinLock = new Object();
private File pendingSkin;
private File pendingSkinFile;
private File selectedSkin;
private BufferedImage pendingSkinImage;
private float uploadOpacity = 0.0F;
private float lastPartialTick;
private JFrame fileDrop;
// translations
private final String manager = I18n.format("hdskins.manager");
private final String unreadable = I18n.format("hdskins.error.unreadable");
private final String ext = I18n.format("hdskins.error.ext");
private final String open = I18n.format("hdskins.error.open");
private final String invalid = I18n.format("hdskins.error.invalid");
private final String select = I18n.format("hdskins.error.select");
private final String mojang = I18n.format("hdskins.error.mojang");
private final String wait = I18n.format("hdskins.error.mojang.wait");
private final String title = I18n.format("hdskins.open.title");
private final String fetch = I18n.format("hdskins.fetch");
private final String failed = I18n.format("hdskins.failed");
private final String request = I18n.format("hdskins.request");
private final String upload = I18n.format("hdskins.upload");
private final String localSkin = I18n.format("hdskins.local");
private final String serverSkin = I18n.format("hdskins.server");
public GuiSkins() {
Minecraft minecraft = Minecraft.getMinecraft();
this.screenTitle = "Skin Manager";
this.screenTitle = manager;
GameProfile profile = minecraft.getSession().getProfile();
this.localPlayer = new EntityPlayerModel(profile);
this.remotePlayer = new EntityPlayerModel(profile);
@ -91,18 +127,15 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
rm.renderEngine = minecraft.getTextureManager();
rm.options = minecraft.gameSettings;
rm.livingPlayer = this.localPlayer;
try {
this.remotePlayer.setRemoteSkin();
} catch (Exception var4) {
var4.printStackTrace();
this.throttledByMojang = true;
}
this.setRemoteSkin();
this.fetchingSkin = true;
this.panoramaRenderer = HDSkinsModCore.getPanoramaRenderer(this);
}
protected EntityPlayerModel getModel(GameProfile profile) {
return new EntityPlayerModel(profile);
}
@Override
public void updateScreen() {
++this.updateCounter;
@ -115,29 +148,50 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
}
synchronized (this.skinLock) {
if (this.pendingSkin != null) {
this.setLocalSkin(this.pendingSkin);
this.selectedSkin = this.pendingSkin;
this.pendingSkin = null;
if (this.pendingSkinFile != null) {
this.localPlayer.setLocalSkin(this.pendingSkinFile);
this.selectedSkin = this.pendingSkinFile;
this.pendingSkinFile = null;
this.onSetLocalSkin(this.pendingSkinImage);
this.pendingSkinImage = null;
this.btnUpload.enabled = true;
}
}
this.btnUpload.enabled = this.selectedSkin != null;
if (this.pendingRemoteSkinRefresh) {
this.pendingRemoteSkinRefresh = false;
this.fetchingSkin = true;
this.btnClear.enabled = false;
this.setRemoteSkin();
this.onSetRemoteSkin();
}
if (this.throttledByMojang) {
if (this.refreshCounter == -1) {
this.refreshCounter = 200;
} else if (this.refreshCounter > 0) {
--this.refreshCounter;
} else {
this.refreshCounter = -1;
this.throttledByMojang = false;
this.setRemoteSkin();
}
}
}
protected void setLocalSkin(File pendingSkin) {
this.localPlayer.setLocalSkin(pendingSkin);
}
protected void onSetRemoteSkin() {}
protected void setRemoteSkin() {
protected void onSetLocalSkin(BufferedImage skin) {}
private void setRemoteSkin() {
try {
this.remotePlayer.setRemoteSkin();
} catch (Exception var2) {
var2.printStackTrace();
this.throttledByMojang = true;
}
}
@Override
@ -163,7 +217,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
@Override
public void initGui() {
super.initGui();
enableDnd();
this.panoramaRenderer.initPanoramaRenderer();
this.getControlList().clear();
this.getControlList().add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse..."));
@ -176,6 +230,51 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.btnBrowse.enabled = !this.mc.isFullScreen();
}
/**
* @wbp.parser.entryPoint
*/
private void enableDnd() {
if (!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7))
return;
if (fileDrop != null) {
fileDrop.setVisible(true);
return;
}
fileDrop = new JFrame("Skin Drop");
fileDrop.setType(Type.UTILITY);
fileDrop.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
fileDrop.setResizable(false);
fileDrop.setTitle("Skin Drop");
fileDrop.setSize(256, 256);
fileDrop.setAlwaysOnTop(true);
fileDrop.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));
panel.setBounds(10, 11, 230, 205);
fileDrop.getContentPane().add(panel);
JLabel txtInst = new JLabel("Drop skin file here");
txtInst.setHorizontalAlignment(SwingConstants.CENTER);
txtInst.setVerticalAlignment(SwingConstants.CENTER);
panel.add(txtInst);
DropTarget dt = new DropTarget();
fileDrop.setDropTarget(dt);
try {
dt.addDropTargetListener(new FileDropListener() {
@Override
public void onDrop(List<File> files) {
File skin = Iterables.getFirst(files, null);
if (skin != null) {
loadLocalFile(skin);
}
}
});
fileDrop.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void initPanoramaRenderer() {
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama",
@ -185,6 +284,8 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
@Override
public void onGuiClosed() {
super.onGuiClosed();
if (this.fileDrop != null)
this.fileDrop.dispose();
this.localPlayer.releaseTextures();
this.remotePlayer.releaseTextures();
}
@ -192,34 +293,48 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
@Override
public void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
this.openFileThread = null;
try {
this.btnBrowse.enabled = true;
if (dialogResult == 0) {
File ex = fileDialog.getSelectedFile();
if (!ex.exists()) {
this.skinMessage = "File not readable";
return;
}
BufferedImage chosenImage = ImageIO.read(ex);
if (!isPowerOfTwo(chosenImage.getWidth())
|| (chosenImage.getWidth() != chosenImage.getHeight() * 2
&& chosenImage.getWidth() != chosenImage.getHeight())
|| chosenImage.getWidth() > MAX_SKIN_DIMENSION
|| chosenImage.getHeight() > MAX_SKIN_DIMENSION) {
this.skinMessage = "Not a valid skin file";
this.loadLocalFile(fileDialog.getSelectedFile());
}
}
private void loadLocalFile(File skinFile) {
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
@Override
public void run() {
localPlayer.releaseTextures();
}
});
if (!skinFile.exists()) {
this.skinMessage = unreadable;
} else if (!FilenameUtils.isExtension(skinFile.getName(), new String[] { "png", "PNG" })) {
this.skinMessage = ext;
} else {
BufferedImage chosenImage;
try {
chosenImage = ImageIO.read(skinFile);
} catch (IOException var6) {
this.skinMessage = open;
var6.printStackTrace();
return;
}
if (chosenImage == null) {
this.skinMessage = open;
} else if (isPowerOfTwo(chosenImage.getWidth())
&& (chosenImage.getWidth() == chosenImage.getHeight() * 2
|| chosenImage.getWidth() == chosenImage.getHeight())
&& chosenImage.getWidth() <= MAX_SKIN_DIMENSION
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
synchronized (this.skinLock) {
this.pendingSkin = ex;
this.pendingSkinFile = skinFile;
this.pendingSkinImage = chosenImage;
}
} else {
this.skinMessage = invalid;
}
}
} catch (Exception var8) {
this.skinMessage = "Error opening skin file";
var8.printStackTrace();
}
}
@Override
@ -231,17 +346,23 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
if (guiButton.id == this.btnBrowse.id) {
this.selectedSkin = null;
this.localPlayer.releaseTextures();
this.openFileThread = new ThreadOpenFilePNG(this.mc, "Choose skin", this);
this.openFileThread = new ThreadOpenFilePNG(this.mc, title, this);
this.openFileThread.start();
guiButton.enabled = false;
}
if (guiButton.id == this.btnUpload.id && this.selectedSkin != null) {
if (guiButton.id == this.btnUpload.id) {
if (this.selectedSkin != null) {
this.uploadSkin(this.mc.getSession(), this.selectedSkin);
this.selectedSkin = null;
this.btnUpload.enabled = false;
} else {
this.setUploadError(select);
}
}
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) {
this.clearUploadedSkin(this.mc.getSession());
this.btnUpload.enabled = this.selectedSkin != null;
}
if (guiButton.id == this.btnBack.id) {
@ -264,7 +385,6 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top
&& mouseY < bottom) {
this.localPlayer.swingArm();
} else if (mouseX > mid + 30 && mouseY > top && mouseX < this.width - 30 && mouseY < bottom) {
this.remotePlayer.swingArm();
}
@ -391,7 +511,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
@Override
public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) {
viewport(0, 0, 256, 256);
GL11.glViewport(0, 0, 256, 256);
this.renderCubeMapTexture(mouseX, mouseY, partialTicks);
GL11.glDisable(3553);
GL11.glEnable(3553);
@ -400,7 +520,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
this.rotateAndBlurCubemap(partialTicks);
}
viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads();
@ -422,14 +542,14 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
public void drawScreen(int mouseX, int mouseY, float partialTick) {
float deltaTime = this.updateCounter + partialTick - this.lastPartialTick;
this.lastPartialTick = this.updateCounter + partialTick;
GL11.glDisable(2912);
GL11.glDisable(GL11.GL_FOG);
this.mc.entityRenderer.disableLightmap();
this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick);
byte top = 30;
int bottom = this.height - 40;
int mid = this.width / 2;
int horizon = this.height / 2 + this.height / 5;
GL11.glPushAttrib(1048575);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE);
Gui.drawRect(mid + 30, top, this.width - 30, bottom, Integer.MIN_VALUE);
this.drawGradientRect(30, horizon, mid - 30, bottom, -2130706433, 16777215);
@ -447,11 +567,12 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
partialTick);
this.disableClipping();
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 10, 16777215);
this.fontRendererObj.drawStringWithShadow("Local Skin", 34, 34, 16777215);
this.fontRendererObj.drawStringWithShadow("Server Skin", this.width / 2 + 34, 34, 16777215);
GL11.glDisable(2929);
this.fontRendererObj.drawStringWithShadow(localSkin, 34, 34, 16777215);
this.fontRendererObj.drawStringWithShadow(serverSkin, this.width / 2 + 34, 34, 16777215);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
depthMask(false);
this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 0, -520093697);
this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 1, 0xe0ffffff);
this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, -520093697);
int labelwidth = (this.width / 2 - 80) / 2;
int opacity;
@ -463,13 +584,27 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
}
if (this.fetchingSkin) {
String opacity1 = this.throttledByMojang ? "\u00a7cMojang API Error!" : "Fetching skin...";
int stringWidth = this.fontRendererObj.getStringWidth(opacity1) / 2;
String opacity1;
if (this.throttledByMojang) {
opacity1 = EnumChatFormatting.RED + mojang;
String stringWidth = wait;
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16,
-1342177280);
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10,
16777215);
this.fontRendererObj.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2),
this.height / 2 + 2, 16777215);
} else {
opacity1 = fetch;
int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12,
-1342177280);
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth), this.height / 2 - 4,
this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4,
16777215);
}
}
if (this.uploadingSkin || this.uploadOpacity > 0.0F) {
if (!this.uploadingSkin) {
@ -494,41 +629,19 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
if (this.uploadError != null) {
Gui.drawRect(0, 0, this.width, this.height, -1342177280);
this.drawCenteredString(this.fontRendererObj, "Uploading skin failed", this.width / 2, this.height / 2 - 10,
this.drawCenteredString(this.fontRendererObj, failed, this.width / 2, this.height / 2 - 10,
-171);
this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2,
-43691);
}
depthMask(true);
GL11.glEnable(2929);
}
protected void renderVignette(int mouseX, int mouseY, float partialTick) {
GL11.glDisable(2929);
depthMask(false);
blendFunc(1, 774);
color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(vignette);
GL11.glLogicOp(5386);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads();
wr.addVertexWithUV(0.0D, this.height, -90.0D, 0.0D, 1.0D);
wr.addVertexWithUV(this.width, this.height, -90.0D, 1.0D, 1.0D);
wr.addVertexWithUV(this.width, 0.0D, -90.0D, 1.0D, 0.0D);
wr.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
tessellator.draw();
depthMask(true);
GL11.glDisable(3058);
GL11.glEnable(2929);
color(1.0F, 1.0F, 1.0F, 1.0F);
blendFunc(770, 771);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale,
float mouseX, float mouseY, float partialTick) {
GL11.glEnable(2903);
GL11.glEnable(GL.GL_COLOR_MATERIAL);
pushMatrix();
translate(xPosition, yPosition, 300.0F);
scale(-scale, scale, scale);
@ -539,13 +652,13 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
rotate(15.0F, 1.0F, 0.0F, 0.0F);
rotate((this.updateCounter + partialTick) * 2.5F, 0.0F, 1.0F, 0.0F);
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
translate(0.0F, thePlayer.getYOffset(), 0.0F);
translate(0.0D, thePlayer.getYOffset(), 0.0D);
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
rm.playerViewY = 180.0F;
rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F);
popMatrix();
RenderHelper.disableStandardItemLighting();
GL11.glDisable('\u803a');
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
}
protected final void enableClipping(int yTop, int yBottom) {
@ -582,8 +695,9 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
sourceData.put("clear", "1");
this.uploadError = null;
this.uploadingSkin = true;
this.skinUploadMessage = "Sending request to server please wait...";
this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.getGatewayUrl(), sourceData, this);
this.skinUploadMessage = request;
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/",
sourceData, this);
this.threadSkinUpload.start();
return true;
}
@ -599,8 +713,9 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
sourceData.put("skin", skinFile);
this.uploadError = null;
this.uploadingSkin = true;
this.skinUploadMessage = "Uploading skin please wait...";
this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.getGatewayUrl(), sourceData, this);
this.skinUploadMessage = upload;
this.threadSkinUpload = new ThreadMultipartPostUpload("http://minelpskinmanager.voxelmodpack.com/",
sourceData, this);
this.threadSkinUpload.start();
return true;
}
@ -635,4 +750,12 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe
return false;
}
}
static {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,18 @@
#HD Skins en_US.lang file
hdskins.choose=Choose a file
hdskins.manager=Skin Manager
hdskins.error.unreadable=File not readable
hdskins.error.ext=File not PNG
hdskins.error.open=Error opening skin file
hdskins.error.invalid=Not a valid skin file
hdskins.error.select=Please select a skin first
hdskins.error.mojang=Mojang API Error
hdskins.error.mojang.wait=Please wait 1 minute
hdskins.open.title=Choose skin
hdskins.fetch=Fetching skin...
hdskins.failed=Uploading skin failed
hdskins.request=Sending request to server please wait...
hdskins.upload=Uploading skin please wait...
hdskins.local=Local Skin
hdskins.server=Server Skin

View file

@ -0,0 +1,15 @@
# HD Skins fr_FR.lang file
# Provided by Dalfio (PinkishPie)
hdskins.choose=Choisissez un fichier
hdskins.manager=Skin Manager HD
hdskins.error.unreadable=Fichier non lisible
hdskins.error.ext=Fichier non PNG
hdskins.error.open=Erreur d'ouverture du fichier
hdskins.error.invalid=Pas un fichier valide
hdskins.error.select=S.V.P. sélectionner un skin en premier
hdskins.error.mojang=Erreur d'API Mojang
hdskins.open.title=Choisissez un skin
hdskins.fetch=Chargement du skin...
hdskins.failed=Ajout du skin échoué
hdskins.request=Envoi de la requête au serveur S.V.P. patientez ...
hdskins.upload=Ajout du skin, S.V.P. patientez ...

View file

@ -0,0 +1,20 @@
minelp.restart1=If you make any changes here, you must restart
minelp.restart2=Minecraft before they will take effect!
minelp.options.title=Mine Little Pony Settings
minelp.options.ponylevel=Pony Level
minelp.options.ponylevel.pony=Ponies
minelp.options.ponylevel.human=Humans
minelp.options.ponylevel.mix=Mix
minelp.options.options=Pony Options (Dsd)
minelp.options.hd=Enable MineLP skin server (requries restart)
minelp.options.sizes=Allow all different sizes of pony
minelp.options.ponyarmor=Use Mine Little Pony compatible armor
minelp.options.snuzzles=Display snuzzles on ponies
minelp.options.showscale=Use show-accurate scaling
minelp.mobs.title=Mine Little Pony Mob Settings
minelp.mobs.villagers=Ponify villagers
minelp.mobs.zombies=Ponify zombies
minelp.mobs.zombiepigmen=Ponify zombie pigmen
minelp.mobs.skeletons=Ponify skeletons

View file

@ -0,0 +1,22 @@
# Mine Little Pony fr_FR.lang file
# Provided by Dalfio (PinkishPie)
minelp.restart1=Si vous apportez des modifications ici, vous devez redémarrer
minelp.restart2=Minecraft avant qu'ils prennent effet!
minelp.options.title=Options Mine Little Pony
minelp.options.ponylevel=Niveau Poney
minelp.options.ponylevel.pony=Poneys
minelp.options.ponylevel.human=Humains
minelp.options.ponylevel.mix=Mix
minelp.options.options=Options Poney
minelp.options.hd=Activer MineLP serveur de skin (nécessite un redémarrage)
minelp.options.sizes=Autoriser tous les différentes tailles de poney
minelp.options.ponyarmor=Utiliser armure compatible de MineLP
minelp.options.snuzzles=Afficher museau sur les poneys
minelp.options.showscale=Utiliser échelle fidèle à MLP
minelp.mobs.title=Options de mobs Mine Little Pony
minelp.mobs.villagers=Ponifier villageois
minelp.mobs.zombies=Ponifier zombies
minelp.mobs.zombiepigmen=Ponifier zombie pigmen
minelp.mobs.skeletons=Ponifier squelettes

View file

@ -2,7 +2,7 @@
"name": "minelp",
"mcversion": "1.8",
"version": "1.8-UNOFFICIAL",
"revision": "185.18",
"revision": "185.2",
"author": "Verdana, Rene_Z, Mumfrey, JoyJoy",
"voxelCommonJarName": "voxelcommon-2.4.0.jar",
"classTransformerClasses": "com.minelittlepony.minelp.transformers.RenderPlayerTransformer",