From ef0f069e34ab8a93b0dd69a2d5eb588f27e1c860 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Thu, 24 Nov 2016 23:40:19 -0500 Subject: [PATCH] Code cleanup. --- .../hdskins/DynamicTextureImage.java | 4 +- .../hdskins/HDProfileTexture.java | 5 +- .../voxelmodpack/hdskins/HDSkinManager.java | 67 +- .../hdskins/HDThreadImageDownload.java | 11 - .../hdskins/ImageBufferDownloadHD.java | 11 +- .../voxelmodpack/hdskins/PreviewTexture.java | 10 +- .../voxelmodpack/hdskins/TextureLoader.java | 7 +- .../hdskins/gui/EntityPlayerModel.java | 21 +- .../hdskins/gui/FileDropListener.java | 22 +- .../voxelmodpack/hdskins/gui/GuiSkins.java | 145 ++-- .../hdskins/gui/HDSkinsConfigPanel.java | 19 +- .../hdskins/gui/RenderPlayerModel.java | 26 +- .../hdskins/gui/color/GuiColorButton.java | 133 ---- .../hdskins/gui/color/GuiColorPicker.java | 323 --------- .../hdskins/gui/color/GuiControl.java | 631 ------------------ .../hdskins/mixin/MixinGuiMainMenu.java | 12 +- .../mixin/MixinImageBufferDownload.java | 12 +- .../hdskins/mixin/MixinPlayerInfo.java | 33 +- .../hdskins/mixin/MixinSkullRenderer.java | 13 +- .../hdskins/mod/LiteModHDSkinsMod.java | 27 +- .../hdskins/resource/ImageLoader.java | 26 +- .../hdskins/resource/SkinData.java | 8 +- .../hdskins/resource/SkinResourceManager.java | 42 +- .../upload/IUploadCompleteCallback.java | 2 +- .../upload/ThreadMultipartPostUpload.java | 75 +-- .../hdskins/upload/awt/IOpenFileCallback.java | 7 +- .../hdskins/upload/awt/ThreadOpenFile.java | 20 +- .../hdskins/upload/awt/ThreadOpenFilePNG.java | 19 +- .../voxelmenu/IPanoramaRenderer.java | 15 - src/hdskins/resources/mixin.hdskins.json | 22 +- .../minelittlepony/LiteModMineLittlePony.java | 8 +- .../com/minelittlepony/MineLittlePony.java | 21 +- src/main/java/com/minelittlepony/Pony.java | 57 +- .../java/com/minelittlepony/PonyData.java | 11 +- .../minelittlepony/PonyDataSerialzier.java | 1 - .../java/com/minelittlepony/PonyLevel.java | 2 +- .../java/com/minelittlepony/PonyManager.java | 53 +- .../java/com/minelittlepony/PonyRace.java | 2 +- .../com/minelittlepony/PonySkinModifier.java | 4 +- .../java/com/minelittlepony/TailLengths.java | 4 +- .../com/minelittlepony/forge/MLPForge.java | 2 +- .../minelittlepony/gui/PonySettingPanel.java | 110 +-- .../hdskins/gui/GuiSkinsMineLP.java | 6 +- .../mixin/MixinRenderPlayer.java | 23 +- .../minelittlepony/model/AbstractArmor.java | 8 - .../model/AbstractPonyModel.java | 195 +++--- .../minelittlepony/model/ModelHornGlow.java | 17 +- .../com/minelittlepony/model/ModelPlane.java | 21 +- .../minelittlepony/model/ModelPonyElytra.java | 6 +- .../java/com/minelittlepony/model/PMAPI.java | 4 +- .../com/minelittlepony/model/PlayerModel.java | 17 +- .../model/PonyModelConstants.java | 10 - .../model/part/PegasusWings.java | 51 +- .../model/part/UnicornHorn.java | 10 +- .../model/pony/ModelBreezie.java | 41 +- .../model/pony/ModelEvokerPony.java | 2 +- .../model/pony/ModelHumanPlayer.java | 5 - .../model/pony/ModelIllagerPony.java | 1 - .../model/pony/ModelPlayerPony.java | 94 +-- .../model/pony/ModelSkeletonPony.java | 4 +- .../model/pony/ModelVillagerPony.java | 9 +- .../model/pony/armor/ModelPonyArmor.java | 25 +- .../renderer/HornGlowRenderer.java | 1 - .../renderer/PlaneRenderer.java | 10 +- .../renderer/RenderPonyEvoker.java | 6 +- .../renderer/RenderPonyMob.java | 8 +- .../renderer/RenderPonyPigman.java | 1 - .../renderer/RenderPonySkeleton.java | 23 +- .../renderer/RenderPonyVex.java | 1 - .../renderer/RenderPonyVillager.java | 27 +- .../renderer/RenderPonyVindicator.java | 7 - .../renderer/RenderPonyZombie.java | 25 +- .../renderer/RenderPonyZombieVillager.java | 27 +- .../renderer/layer/LayerHeldPonyItem.java | 2 +- .../renderer/layer/LayerPonyArmor.java | 68 +- .../renderer/layer/LayerPonyCape.java | 7 +- .../renderer/layer/LayerPonyElytra.java | 1 - .../renderer/layer/LayerPonySkull.java | 8 +- .../renderer/layer/LayerPonyStrayOverlay.java | 1 - .../com/minelittlepony/util/MineLPLogger.java | 76 --- .../com/minelittlepony/util/PonyFields.java | 7 +- .../textures/entity/pony/bgponies.json | 8 +- src/main/resources/litemod.json | 18 +- src/main/resources/mixin.minelp.json | 16 +- 84 files changed, 731 insertions(+), 2209 deletions(-) delete mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/HDThreadImageDownload.java delete mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorButton.java delete mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorPicker.java delete mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiControl.java delete mode 100644 src/hdskins/java/com/voxelmodpack/voxelmenu/IPanoramaRenderer.java delete mode 100644 src/main/java/com/minelittlepony/util/MineLPLogger.java diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java b/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java index b4b05440..d7598b08 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java @@ -1,9 +1,9 @@ package com.voxelmodpack.hdskins; -import java.awt.image.BufferedImage; - import net.minecraft.client.renderer.texture.DynamicTexture; +import java.awt.image.BufferedImage; + public class DynamicTextureImage extends DynamicTexture { private BufferedImage image; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java index 85dfc867..0961a525 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDProfileTexture.java @@ -1,10 +1,9 @@ package com.voxelmodpack.hdskins; -import java.util.Map; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import javax.annotation.Nullable; - -import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import java.util.Map; /** * Profile texture with a custom hash which is not the file name. diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 8ddf6e70..c7c07640 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -1,23 +1,6 @@ package com.voxelmodpack.hdskins; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.annotation.Nullable; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.FileUtils; - import com.google.common.base.Charsets; -import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -36,7 +19,6 @@ import com.mojang.util.UUIDTypeAdapter; import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.voxelmodpack.hdskins.resource.SkinResourceManager; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IImageBuffer; import net.minecraft.client.renderer.ThreadDownloadImageData; @@ -47,12 +29,26 @@ import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.resources.SkinManager.SkinAvailableCallback; import net.minecraft.util.ResourceLocation; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; + +import javax.annotation.Nullable; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public final class HDSkinManager implements IResourceManagerReloadListener { public static final HDSkinManager INSTANCE = new HDSkinManager(); private static final ResourceLocation LOADING = new ResourceLocation("LOADING"); - public static final String METADATA_KEY = "hdskins.metadata"; private String gatewayUrl = "skinmanager.voxelmodpack.com"; private String skinUrl = "skins.voxelmodpack.com"; @@ -65,11 +61,12 @@ public final class HDSkinManager implements IResourceManagerReloadListener { private SkinResourceManager resources = new SkinResourceManager(); private ExecutorService executor = Executors.newCachedThreadPool(); - public HDSkinManager() {} + public HDSkinManager() { + } public Optional getSkinLocation(GameProfile profile1, final Type type, boolean loadIfAbsent) { if (!enabled) - return Optional.absent(); + return Optional.empty(); ResourceLocation skin = this.resources.getPlayerTexture(profile1, type); if (skin != null) @@ -97,29 +94,19 @@ public final class HDSkinManager implements IResourceManagerReloadListener { final GameProfile profile = profile1; if (!this.skinCache.containsKey(profile.getId())) { - this.skinCache.put(profile.getId(), Maps. newHashMap()); + this.skinCache.put(profile.getId(), Maps.newHashMap()); } skin = this.skinCache.get(profile.getId()).get(type); if (skin == null) { if (loadIfAbsent) { skinCache.get(profile.getId()).put(type, LOADING); - executor.submit(new Runnable() { - @Override - public void run() { - loadTexture(profile, type, new SkinAvailableCallback() { - @Override - public void skinAvailable(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { - skinCache.get(profile.getId()).put(type, location); - } - }); - } - }); + executor.submit(() -> loadTexture(profile, type, (type1, location, profileTexture) -> skinCache.get(profile.getId()).put(type1, location))); } - return Optional.absent(); + return Optional.empty(); } - return skin == LOADING ? Optional. absent() : Optional.of(skin); + return skin == LOADING ? Optional.empty() : Optional.of(skin); } @@ -181,11 +168,11 @@ public final class HDSkinManager implements IResourceManagerReloadListener { } private static Map getTexturesForProfile(GameProfile profile) { - LiteLoaderLogger.debug("Get textures for " + profile.getId(), new Object[0]); + LiteLoaderLogger.debug("Get textures for " + profile.getId()); Minecraft minecraft = Minecraft.getMinecraft(); MinecraftSessionService sessionService = minecraft.getSessionService(); - Map textures = null; + Map textures; try { textures = sessionService.getTextures(profile, true); @@ -208,10 +195,6 @@ public final class HDSkinManager implements IResourceManagerReloadListener { this.gatewayUrl = gatewayURL; } - public String getSkinUrl() { - return String.format("http://%s/", skinUrl); - } - public String getGatewayUrl() { return String.format("http://%s/", gatewayUrl); } @@ -254,7 +237,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener { } public static void clearSkinCache() { - LiteLoaderLogger.info("Clearing local player skin cache", new Object[0]); + LiteLoaderLogger.info("Clearing local player skin cache"); try { FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins")); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDThreadImageDownload.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDThreadImageDownload.java deleted file mode 100644 index 95cd2e27..00000000 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDThreadImageDownload.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.voxelmodpack.hdskins; - -import net.minecraft.client.renderer.texture.SimpleTexture; - -public class HDThreadImageDownload extends SimpleTexture { - - public HDThreadImageDownload() { - super(null); - } - -} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/ImageBufferDownloadHD.java b/src/hdskins/java/com/voxelmodpack/hdskins/ImageBufferDownloadHD.java index 91c15739..adcc9d9b 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/ImageBufferDownloadHD.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/ImageBufferDownloadHD.java @@ -1,10 +1,9 @@ package com.voxelmodpack.hdskins; +import net.minecraft.client.renderer.IImageBuffer; + import java.awt.Graphics; import java.awt.image.BufferedImage; -import java.awt.image.ImageObserver; - -import net.minecraft.client.renderer.IImageBuffer; public class ImageBufferDownloadHD implements IImageBuffer { @@ -13,6 +12,7 @@ public class ImageBufferDownloadHD implements IImageBuffer { private BufferedImage image; @Override + @SuppressWarnings("SuspiciousNameCombination") public BufferedImage parseUserSkin(BufferedImage downloadedImage) { if (downloadedImage == null) { return null; @@ -25,7 +25,7 @@ public class ImageBufferDownloadHD implements IImageBuffer { scale = imageWidth / 64; image = new BufferedImage(imageWidth, imageWidth, BufferedImage.TYPE_INT_ARGB); graphics = image.getGraphics(); - graphics.drawImage(downloadedImage, 0, 0, (ImageObserver) null); + graphics.drawImage(downloadedImage, 0, 0, null); // copy layers // leg @@ -58,5 +58,6 @@ public class ImageBufferDownloadHD implements IImageBuffer { } @Override - public void skinAvailable() {} + public void skinAvailable() { + } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTexture.java b/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTexture.java index 82d78520..ef520ed1 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTexture.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/PreviewTexture.java @@ -1,23 +1,21 @@ package com.voxelmodpack.hdskins; -import java.io.File; - import net.minecraft.client.renderer.IImageBuffer; import net.minecraft.client.renderer.ThreadDownloadImageData; import net.minecraft.util.ResourceLocation; public class PreviewTexture extends ThreadDownloadImageData { - + private boolean uploaded; - + public PreviewTexture(String url, ResourceLocation fallbackTexture, IImageBuffer imageBuffer) { - super((File) null, url, fallbackTexture, imageBuffer); + super(null, url, fallbackTexture, imageBuffer); } public boolean isTextureUploaded() { return uploaded && this.getGlTextureId() > -1; } - + @Override public void deleteGlTexture() { super.deleteGlTexture(); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java b/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java index 1474dee9..959e0131 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java @@ -9,11 +9,6 @@ public class TextureLoader { private static Minecraft mc = Minecraft.getMinecraft(); public static void loadTexture(final ResourceLocation textureLocation, final ITextureObject textureObj) { - mc.addScheduledTask(new Runnable() { - @Override - public void run() { - mc.getTextureManager().loadTexture(textureLocation, textureObj); - } - }); + mc.addScheduledTask((Runnable) () -> mc.getTextureManager().loadTexture(textureLocation, textureObj)); } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java index a2c095d9..22a08cd3 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java @@ -1,18 +1,11 @@ package com.voxelmodpack.hdskins.gui; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; - -import javax.imageio.ImageIO; - import com.google.common.collect.Iterables; import com.mojang.authlib.GameProfile; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.ImageBufferDownloadHD; import com.voxelmodpack.hdskins.PreviewTexture; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; @@ -22,7 +15,11 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumHandSide; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; public class EntityPlayerModel extends EntityLivingBase { public static final ResourceLocation NOSKIN = new ResourceLocation("hdskins", "textures/mob/noskin.png"); @@ -37,7 +34,7 @@ public class EntityPlayerModel extends EntityLivingBase { protected boolean hasLocalTexture = false; public EntityPlayerModel(GameProfile profile) { - super((World) null); + super(null); this.profile = profile; this.textureManager = Minecraft.getMinecraft().getTextureManager(); this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png"); @@ -79,10 +76,6 @@ public class EntityPlayerModel extends EntityLivingBase { } - public boolean usingRemoteSkin() { - return this.remoteSkin; - } - public boolean isUsingLocalTexture() { return !this.remoteSkin && this.hasLocalTexture; } @@ -93,7 +86,7 @@ public class EntityPlayerModel extends EntityLivingBase { } public boolean isTextureSetupComplete() { - return this.remoteSkin && this.remoteSkinTexture != null ? this.remoteSkinTexture.isTextureUploaded() : false; + return (this.remoteSkin && this.remoteSkinTexture != null) && this.remoteSkinTexture.isTextureUploaded(); } public void releaseTextures() { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/FileDropListener.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/FileDropListener.java index ec02fd7e..bcb11925 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/FileDropListener.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/FileDropListener.java @@ -11,35 +11,37 @@ import java.io.File; import java.io.IOException; import java.util.List; -public abstract class FileDropListener implements DropTargetListener { +public interface FileDropListener extends DropTargetListener { @Override - public void dragEnter(DropTargetDragEvent dtde) {} + default void dragEnter(DropTargetDragEvent dtde) { + } @Override - public void dragOver(DropTargetDragEvent dtde) {} + default void dragOver(DropTargetDragEvent dtde) { + } @Override - public void dropActionChanged(DropTargetDragEvent dtde) {} + default void dropActionChanged(DropTargetDragEvent dtde) { + } @Override - public void dragExit(DropTargetEvent dte) {} + default void dragExit(DropTargetEvent dte) { + } @SuppressWarnings("unchecked") @Override - public void drop(DropTargetDropEvent dtde) { + default void drop(DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_LINK); try { onDrop((List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)); dtde.getDropTargetContext().dropComplete(true); - } catch (UnsupportedFlavorException e) { - e.printStackTrace(); - } catch (IOException e) { + } catch (UnsupportedFlavorException | IOException e) { e.printStackTrace(); } } - public abstract void onDrop(List files); + void onDrop(List files); } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java index d8ed63b7..7d9f8f73 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java @@ -1,18 +1,15 @@ package com.voxelmodpack.hdskins.gui; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap; import com.mojang.authlib.GameProfile; import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.voxelmodpack.hdskins.HDSkinManager; -import com.voxelmodpack.hdskins.mod.LiteModHDSkinsMod; import com.voxelmodpack.hdskins.upload.IUploadCompleteCallback; import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload; import com.voxelmodpack.hdskins.upload.awt.IOpenFileCallback; import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG; -import com.voxelmodpack.voxelmenu.IPanoramaRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiButton; @@ -30,14 +27,19 @@ import net.minecraft.util.Session; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextFormatting; 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 javax.imageio.ImageIO; -import javax.swing.*; +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 java.awt.Color; import java.awt.Window.Type; import java.awt.dnd.DropTarget; @@ -45,17 +47,15 @@ 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.Map; import static net.minecraft.client.renderer.GlStateManager.*; -public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback, IPanoramaRenderer { +public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback { 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"), @@ -70,7 +70,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe protected EntityPlayerModel localPlayer; protected EntityPlayerModel remotePlayer; protected DoubleBuffer doubleBuffer; - private String screenTitle; + // private String screenTitle; private String uploadError; private volatile String skinMessage = I18n.format("hdskins.choose"); private String skinUploadMessage = I18n.format("hdskins.request"); @@ -81,7 +81,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe private int refreshCounter = -1; private ThreadOpenFilePNG openFileThread; private ThreadMultipartPostUpload threadSkinUpload; - private Object skinLock = new Object(); + private final Object skinLock = new Object(); private File pendingSkinFile; private File selectedSkin; private BufferedImage pendingSkinImage; @@ -90,7 +90,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe private JFrame fileDrop; // translations - private final String manager = I18n.format("hdskins.manager"); + private final String screenTitle = 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"); @@ -108,7 +108,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe public GuiSkins() { Minecraft minecraft = Minecraft.getMinecraft(); - this.screenTitle = manager; +// this.screenTitle = manager; GameProfile profile = minecraft.getSession().getProfile(); this.localPlayer = getModel(profile); this.remotePlayer = getModel(profile); @@ -118,7 +118,6 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe rm.renderViewEntity = this.localPlayer; this.reloadRemoteSkin(); this.fetchingSkin = true; - this.panoramaRenderer = LiteModHDSkinsMod.getPanoramaRenderer(this); } protected EntityPlayerModel getModel(GameProfile profile) { @@ -128,7 +127,6 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe @Override public void updateScreen() { ++this.updateCounter; - this.panoramaRenderer.updatePanorama(); this.localPlayer.updateModel(); this.remotePlayer.updateModel(); if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) { @@ -185,29 +183,10 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe } - @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) { - } - @Override public void initGui() { enableDnd(); - this.panoramaRenderer.initPanoramaRenderer(); + this.initPanoramaRenderer(); this.buttonList.clear(); this.buttonList.add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse...")); this.buttonList.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>")); @@ -221,8 +200,6 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe * @wbp.parser.entryPoint */ private void enableDnd() { - if (!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)) - return; if (fileDrop != null) { fileDrop.setVisible(true); return; @@ -247,22 +224,13 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe DropTarget dt = new DropTarget(); fileDrop.setDropTarget(dt); try { - dt.addDropTargetListener(new FileDropListener() { - @Override - public void onDrop(List files) { - File skin = Iterables.getFirst(files, null); - if (skin != null) { - loadLocalFile(skin); - } - } - }); + dt.addDropTargetListener((FileDropListener) files -> files.stream().findFirst().ifPresent(this::loadLocalFile)); fileDrop.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } - @Override public void initPanoramaRenderer() { this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama", new DynamicTexture(256, 256)); } @@ -286,12 +254,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe } private void loadLocalFile(File skinFile) { - Minecraft.getMinecraft().addScheduledTask(new Runnable() { - @Override - public void run() { - localPlayer.releaseTextures(); - } - }); + Minecraft.getMinecraft().addScheduledTask(localPlayer::releaseTextures); if (!skinFile.exists()) { this.skinMessage = unreadable; } else if (!FilenameUtils.isExtension(skinFile.getName(), new String[]{"png", "PNG"})) { @@ -492,8 +455,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe disableBlend(); } - @Override - public boolean renderPanorama(int mouseX, int mouseY, float partialTicks) { + public void renderPanorama(float partialTicks) { viewport(0, 0, 256, 256); this.renderCubeMapTexture(partialTicks); disableTexture2D(); @@ -518,7 +480,6 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe vb.pos(this.width, 0.0D, this.zLevel).tex(0.5F + uSample, 0.5F - vSample).endVertex(); vb.pos(0.0D, 0.0D, this.zLevel).tex(0.5F + uSample, 0.5F + vSample).endVertex(); tessellator.draw(); - return true; } @Override @@ -528,7 +489,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe disableFog(); this.mc.entityRenderer.disableLightmap(); - this.panoramaRenderer.renderPanorama(mouseX, mouseY, partialTick); + this.renderPanorama(partialTick); int top = 30; int bottom = this.height - 40; @@ -554,10 +515,10 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe float scale = this.height * 0.25F; mc.getTextureManager().bindTexture(this.localPlayer.getSkinTexture()); - this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, xPos1 - mouseX, yPos - scale * 1.8F - mouseY, partialTick); + this.renderPlayerModel(this.localPlayer, xPos1, yPos, scale, yPos - scale * 1.8F - mouseY, partialTick); mc.getTextureManager().bindTexture(this.remotePlayer.getSkinTexture()); - this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, xPos2 - mouseX, yPos - scale * 1.8F - mouseY, partialTick); + this.renderPlayerModel(this.remotePlayer, xPos2, yPos, scale, yPos - scale * 1.8F - mouseY, partialTick); this.disableClipping(); @@ -615,7 +576,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe int 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); + Gui.drawRect(0, 0, this.width, this.height, opacity << 24); if (this.uploadingSkin) { this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2, this.height / 2, opacity << 24 | 0xffffff); } @@ -632,7 +593,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe enableDepth(); } - public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseX, float mouseY, float partialTick) { + public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseY, float partialTick) { enableColorMaterial(); pushMatrix(); translate(xPosition, yPosition, 300.0F); @@ -684,37 +645,41 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe return number != 0 && (number & number - 1) == 0; } - private boolean clearUploadedSkin(Session session) { - if (!this.registerServerConnection(session, skinServerId)) { - return false; + private void clearUploadedSkin(Session session) { + if (this.registerServerConnection(session, skinServerId)) { + Map sourceData = getClearData(session); + this.uploadError = null; + this.uploadingSkin = true; + this.skinUploadMessage = request; + this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.INSTANCE.getGatewayUrl(), sourceData, this); + this.threadSkinUpload.start(); } - HashMap sourceData = Maps.newHashMap(); - sourceData.put("user", session.getUsername()); - sourceData.put("uuid", session.getPlayerID()); - sourceData.put("clear", "1"); - this.uploadError = null; - this.uploadingSkin = true; - this.skinUploadMessage = request; - this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.INSTANCE.getGatewayUrl(), sourceData, this); - this.threadSkinUpload.start(); - return true; } - private boolean uploadSkin(Session session, File skinFile) { - if (!this.registerServerConnection(session, skinServerId)) { - return false; + private void uploadSkin(Session session, File skinFile) { + if (this.registerServerConnection(session, skinServerId)) { + Map sourceData = getUploadData(session, skinFile); + this.uploadError = null; + this.uploadingSkin = true; + this.skinUploadMessage = upload; + this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.INSTANCE.getGatewayUrl(), sourceData, this); + this.threadSkinUpload.start(); } - HashMap sourceData = new HashMap(); - sourceData.put("user", session.getUsername()); - sourceData.put("uuid", session.getPlayerID()); - sourceData.put("skin", skinFile); - this.uploadError = null; - this.uploadingSkin = true; - this.skinUploadMessage = upload; - this.threadSkinUpload = new ThreadMultipartPostUpload(HDSkinManager.INSTANCE.getGatewayUrl(), sourceData, this); - this.threadSkinUpload.start(); + } - return true; + private Map getData(Session session, String param, Object val) { + return ImmutableMap.of( + "user", session.getUsername(), + "uuid", session.getPlayerID(), + param, val); + } + + private Map getClearData(Session session) { + return getData(session, "clear", "1"); + } + + private Map getUploadData(Session session, File skinFile) { + return getData(session, "file", skinFile); } private void setUploadError(String error) { @@ -724,7 +689,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe @Override public void onUploadComplete(String response) { - LiteLoaderLogger.info("Upload completed with: %s", new Object[]{response}); + LiteLoaderLogger.info("Upload completed with: %s", response); this.uploadingSkin = false; this.threadSkinUpload = null; if (!response.equalsIgnoreCase("OK")) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java index a03d9a87..dda96fb3 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java @@ -3,7 +3,6 @@ package com.voxelmodpack.hdskins.gui; import com.mumfrey.liteloader.modconfig.ConfigPanel; import com.mumfrey.liteloader.modconfig.ConfigPanelHost; import com.voxelmodpack.hdskins.HDSkinManager; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; @@ -40,20 +39,26 @@ public class HDSkinsConfigPanel implements ConfigPanel { } @Override - public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {} + public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) { + } @Override - public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {} + public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) { + } @Override - public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {} + public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) { + } @Override - public void onPanelHidden() {} + public void onPanelHidden() { + } @Override - public void onPanelResize(ConfigPanelHost host) {} + public void onPanelResize(ConfigPanelHost host) { + } @Override - public void onTick(ConfigPanelHost host) {} + public void onTick(ConfigPanelHost host) { + } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java index 53cd9c19..263c5dba 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java @@ -1,22 +1,24 @@ package com.voxelmodpack.hdskins.gui; -import static net.minecraft.client.renderer.GlStateManager.*; - -import java.util.Set; - -import org.lwjgl.opengl.GL11; - import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import java.util.Set; + +import static net.minecraft.client.renderer.GlStateManager.popAttrib; +import static net.minecraft.client.renderer.GlStateManager.popMatrix; +import static net.minecraft.client.renderer.GlStateManager.pushMatrix; +import static net.minecraft.client.renderer.GlStateManager.scale; public class RenderPlayerModel extends RenderLivingBase { private static final ModelPlayer FAT = new ModelPlayer(0, false); - private static final ModelPlayer THIN = new ModelPlayer(0, true); + //private static final ModelPlayer THIN = new ModelPlayer(0, true); public RenderPlayerModel(RenderManager renderer) { super(renderer, FAT, 0.0F); @@ -29,18 +31,12 @@ public class RenderPlayerModel extends RenderLiving @Override protected boolean canRenderName(M targetEntity) { - if (Minecraft.getMinecraft().player != null) { - return super.canRenderName(targetEntity); - } - return false; + return Minecraft.getMinecraft().player != null && super.canRenderName(targetEntity); } @Override protected boolean setBrightness(M entitylivingbaseIn, float partialTicks, boolean p_177092_3_) { - if (Minecraft.getMinecraft().world != null) { - return super.setBrightness(entitylivingbaseIn, partialTicks, p_177092_3_); - } - return false; + return Minecraft.getMinecraft().world != null && super.setBrightness(entitylivingbaseIn, partialTicks, p_177092_3_); } public ModelPlayer getEntityModel(M entity) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorButton.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorButton.java deleted file mode 100644 index 34a4e9f2..00000000 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorButton.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.voxelmodpack.hdskins.gui.color; - -import static com.mumfrey.liteloader.gl.GL.glColor4f; - -import java.awt.Color; - -import net.minecraft.client.Minecraft; - -/** - * Colour picker button control, spawns a colour picker when clicked - * - * @author Adam Mummery-Smith - */ -public class GuiColorButton extends GuiControl { - /** - * Picker active colour - */ - private int colour = 0xFF000000; - - private Color lineColour; - - private GuiColorPicker picker; - - private boolean pickerClicked = false; - private CloseListener closeListener; - - public GuiColorButton(Minecraft minecraft, int id, int xPosition, int yPosition, int controlWidth, int controlHeight, Color lineColour, String name, CloseListener cl) { - super(minecraft, id, xPosition, yPosition, controlWidth, controlHeight, name); - this.lineColour = lineColour; - this.updateColour(lineColour); - this.closeListener = cl; - } - - /** - * @param lineColour2 - */ - public void updateColour(Color lineColour2) { - if (lineColour2 == this.lineColour) { - this.colour = lineColour2.getRGB(); - } - } - - public int getColor() { - return this.colour; - } - - @Override - public void drawControl(Minecraft minecraft, int mouseX, int mouseY) { - if (this.visible) { - - if (this.displayString != null && this.displayString.length() > 0) { - this.drawString(minecraft.fontRendererObj, this.displayString, this.xPosition + this.width + 8, this.yPosition + (this.height - 8) / 2, 0xFFFFFFFF); - } - boolean mouseOver = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - int borderColour = mouseOver || this.picker != null ? 0xFFFFFFFF : 0xFFA0A0A0; - - drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, borderColour); - - int v = Math.min(Math.max((int) (((float) this.height / (float) this.width) * 1024F), 256), 1024); - - minecraft.getTextureManager().bindTexture(GuiColorPicker.COLOURPICKER_CHECKER); - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.drawTexturedModalRect(this.xPosition + 1, this.yPosition + 1, this.xPosition + this.width - 1, this.yPosition + this.height - 1, 0, 0, 1024, v); - - drawRect(this.xPosition + 1, this.yPosition + 1, this.xPosition + this.width - 1, this.yPosition + this.height - 1, this.colour); - - this.mouseDragged(minecraft, mouseX, mouseY); - - } - } - - public void drawPicker(Minecraft minecraft, int mouseX, int mouseY) { - if (this.visible && this.picker != null) { - this.picker.drawButton(minecraft, mouseX, mouseY); - - if (this.picker.getDialogResult() == DialogResult.OK) { - this.closePicker(true); - } else if (this.picker.getDialogResult() == DialogResult.Cancel) { - this.closePicker(false); - } - } - } - - public void closePicker(boolean getColour) { - if (getColour) - this.colour = this.picker.getColour(); - this.picker = null; - this.pickerClicked = false; - if (this.closeListener != null) - this.closeListener.onClose(); - } - - @Override - public void mouseReleased(int mouseX, int mouseY) { - if (this.pickerClicked && this.picker != null) { - this.picker.mouseReleased(mouseX, mouseY); - this.pickerClicked = false; - } - } - - @Override - public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY) { - boolean pressed = super.mousePressed(minecraft, mouseX, mouseY); - - if (this.picker == null) { - if (pressed) { - int xPos = Math.min(this.xPosition + this.width, GuiControl.lastScreenWidth - 233); - int yPos = Math.min(this.yPosition, GuiControl.lastScreenHeight - 175); - - this.picker = new GuiColorPicker(minecraft, 1, xPos, yPos, this.colour, "Choose colour"); - this.pickerClicked = false; - } - - return pressed; - } - - this.pickerClicked = this.picker.mousePressed(minecraft, mouseX, mouseY); - - if (pressed && !this.pickerClicked) { - this.closePicker(true); - } - - return this.pickerClicked; - } - - public boolean keyTyped(char keyChar, int keyCode) { - return (this.picker != null) ? this.picker.textBoxKeyTyped(keyChar, keyCode) : false; - } - - public interface CloseListener { - void onClose(); - } -} \ No newline at end of file diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorPicker.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorPicker.java deleted file mode 100644 index d4af94c9..00000000 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiColorPicker.java +++ /dev/null @@ -1,323 +0,0 @@ -package com.voxelmodpack.hdskins.gui.color; - -import static net.minecraft.client.renderer.GlStateManager.*; - -import java.awt.Color; -import java.awt.Rectangle; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.input.Keyboard; - -/** - * Colour picker flyout control, for use with the designable GUI properties - * window - * - * @author Adam Mummery-Smith - */ -public class GuiColorPicker extends GuiControl { - public static final ResourceLocation COLOURPICKER_CHECKER = new ResourceLocation("hdskins", "textures/gui/checker.png"); - public static final ResourceLocation COLOURPICKER_PICKER = new ResourceLocation("hdskins", "textures/gui/picker.png"); - - /** - * Indices into the hsb array - */ - private static final int H = 0, S = 1, B = 2; - - /** - * HSB values from Colour.RGBtoHSB, combined with opacity this is the - * authoritative version of the colour we are editing - */ - private float[] hsb; - - /** - * Original and altered RGB values - */ - private int rgb; - - /** - * Current opacity, stored as an offset byte in the usual position, eg. 0xFF - * << 24 - */ - private int opacity; - - /** - * Text boxes for manual entry - */ - private GuiTextField txtRed, txtGreen, txtBlue, txtAlpha; - - /** - * OK and cancel buttons - */ - private GuiControl btnOk, btnCancel; - - /** - * Flags to track whether dragging a slider - */ - private boolean draggingHS, draggingB, draggingA; - - /** - * Slider rects - */ - private Rectangle rectHSArea, rectBArea, rectAArea; - - /** - * Set when the user clicks ok or cancel - */ - private DialogResult result = DialogResult.None; - - private FontRenderer fontRenderer; - - public GuiColorPicker(Minecraft minecraft, int controlId, int xPos, int yPos, int initialColour, String displayText) { - super(minecraft, controlId, xPos, yPos, 231, 173, displayText); - - Color colour = new Color(initialColour); - this.hsb = Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), null); - this.opacity = initialColour & 0xFF000000; - if (this.opacity == 0x01000000) - this.opacity = 0; - - this.fontRenderer = minecraft.fontRendererObj; - this.txtRed = new GuiTextField(0, this.fontRenderer, this.xPosition + 188, this.yPosition + 10, 32, 16); - this.txtGreen = new GuiTextField(1, this.fontRenderer, this.xPosition + 188, this.yPosition + 30, 32, 16); - this.txtBlue = new GuiTextField(2, this.fontRenderer, this.xPosition + 188, this.yPosition + 50, 32, 16); - this.txtAlpha = new GuiTextField(3, this.fontRenderer, this.xPosition + 188, this.yPosition + 70, 32, 16); - - this.txtRed.setMaxStringLength(3); - this.txtGreen.setMaxStringLength(3); - this.txtBlue.setMaxStringLength(3); - this.txtAlpha.setMaxStringLength(3); - - this.rectHSArea = new Rectangle(this.xPosition + 10, this.yPosition + 10, 128, 128); - this.rectBArea = new Rectangle(this.xPosition + 143, this.yPosition + 10, 15, 128); - this.rectAArea = new Rectangle(this.xPosition + 163, this.yPosition + 10, 15, 128); - - this.btnOk = new GuiControl(minecraft, 0, this.xPosition + 9, this.yPosition + 145, 55, 20, I18n.format("gui.ok")); - this.btnCancel = new GuiControl(minecraft, 1, this.xPosition + 70, this.yPosition + 145, 65, 20, I18n.format("gui.cancel")); - - this.updateColour(); - } - - public DialogResult getDialogResult() { - return this.result; - } - - public int getColour() { - int opacity = this.opacity == 0 ? 0x01000000 : this.opacity; - int rgb = opacity | (0xFFFFFF & Color.HSBtoRGB(this.hsb[H], this.hsb[S], this.hsb[B])); - return rgb; - } - - @Override - protected void drawControl(Minecraft minecraft, int mouseX, int mouseY) { - this.mouseDragged(minecraft, mouseX, mouseY); - - // Calculate coordinates for the selectors - int hPos = this.xPosition + 10 + (int) (128F * this.hsb[H]); - int sPos = this.yPosition + 10 + (128 - (int) (128F * this.hsb[S])); - int bPos = this.yPosition + 10 + (128 - (int) (128F * this.hsb[B])); - int aPos = this.yPosition + 10 + ((256 - ((this.opacity >> 24) & 0xFF)) / 2); - - // Calculate B colour - int brightness = Color.HSBtoRGB(this.hsb[H], this.hsb[S], 1.0F) | 0xFF000000; - - // Draw backgrounds - drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0xAA000000); // Background - drawRect(this.xPosition + 9, this.yPosition + 9, this.xPosition + 139, this.yPosition + 139, 0xFFA0A0A0); // HS - // background - drawRect(this.xPosition + 142, this.yPosition + 9, this.xPosition + 159, this.yPosition + 139, 0xFFA0A0A0); // B - // background - drawRect(this.xPosition + 162, this.yPosition + 9, this.xPosition + 179, this.yPosition + 139, 0xFFA0A0A0); // A - // background - drawRect(this.xPosition + 187, this.yPosition + 105, this.xPosition + 221, this.yPosition + 139, 0xFFA0A0A0); // Preview - // background - - // Draw colour picker - this.mc.getTextureManager().bindTexture(GuiColorPicker.COLOURPICKER_PICKER); - color(1.0F, 1.0F, 1.0F, 1.0F); - this.drawTexturedModalRect(this.xPosition + 10, this.yPosition + 10, this.xPosition + 138, this.yPosition + 138, 0, 0, 256, 256); - this.drawCrossHair(hPos, sPos, 5, 1, 0xFF000000); - - // Draw brightness bar - this.drawGradientRect(this.xPosition + 143, this.yPosition + 10, this.xPosition + 158, this.yPosition + 138, brightness, 0xFF000000); - this.drawRotText(this.fontRenderer, "Luminosity", this.xPosition + 150, this.yPosition + 74, 0xFF000000, false); - drawRect(this.xPosition + 142, bPos - 1, this.xPosition + 159, bPos + 1, 0xFFFFFFFF); - - // Draw opacity bar - this.drawGradientRect(this.xPosition + 163, this.yPosition + 10, this.xPosition + 178, this.yPosition + 138, 0xFFFFFFFF, 0xFF000000); - this.drawRotText(this.fontRenderer, "Opacity", this.xPosition + 170, this.yPosition + 74, 0xFF000000, false); - drawRect(this.xPosition + 162, aPos - 1, this.xPosition + 179, aPos + 1, 0xFFFFFFFF); - - // Draw preview - this.mc.getTextureManager().bindTexture(GuiColorPicker.COLOURPICKER_CHECKER); - color(1.0F, 1.0F, 1.0F, 1.0F); - this.drawTexturedModalRect(this.xPosition + 188, this.yPosition + 106, this.xPosition + 220, this.yPosition + 138, 0, 0, 1024, 1024); - drawRect(this.xPosition + 188, this.yPosition + 106, this.xPosition + 220, this.yPosition + 138, this.rgb); - - // Draw text boxes - this.txtRed.drawTextBox(); - this.txtGreen.drawTextBox(); - this.txtBlue.drawTextBox(); - this.txtAlpha.drawTextBox(); - - this.btnOk.drawButton(minecraft, mouseX, mouseY); - this.btnCancel.drawButton(minecraft, mouseX, mouseY); - } - - public void updateCursorCounter() { - this.txtRed.updateCursorCounter(); - this.txtGreen.updateCursorCounter(); - this.txtBlue.updateCursorCounter(); - this.txtAlpha.updateCursorCounter(); - } - - protected void updateColour() { - this.rgb = this.opacity | (0xFFFFFF & Color.HSBtoRGB(this.hsb[H], this.hsb[S], this.hsb[B])); - this.txtRed.setText(String.valueOf((this.rgb >> 16) & 0xFF)); - this.txtGreen.setText(String.valueOf((this.rgb >> 8) & 0xFF)); - this.txtBlue.setText(String.valueOf(this.rgb & 0xFF)); - this.txtAlpha.setText(String.valueOf((this.opacity >> 24) & 0xFF)); - } - - protected void updateColourFromTextEntry() { - int currentRed = (this.rgb >> 16) & 0xFF; - int currentGreen = (this.rgb >> 8) & 0xFF; - int currentBlue = this.rgb & 0xFF; - int currentOpacity = (this.opacity >> 24) & 0xFF; - - currentRed = (int) clamp(this.tryParseInt(this.txtRed.getText(), currentRed), 0, 255); - currentGreen = (int) clamp(this.tryParseInt(this.txtGreen.getText(), currentGreen), 0, 255); - currentBlue = (int) clamp(this.tryParseInt(this.txtBlue.getText(), currentBlue), 0, 255); - currentOpacity = (int) clamp(this.tryParseInt(this.txtAlpha.getText(), currentOpacity), 0, 255); - - this.hsb = Color.RGBtoHSB(currentRed, currentGreen, currentBlue, null); - this.opacity = (currentOpacity << 24) & 0xFF000000; - this.updateColour(); - } - - protected int tryParseInt(String text, int defaultValue) { - try { - return Integer.parseInt(text); - } catch (Exception ex) { - return "".equals(text) ? 0 : defaultValue; - } - } - - /* - * (non-Javadoc) - * @see - * net.minecraft.src.GuiButton#mouseDragged(net.minecraft.src.Minecraft, - * int, int) - */ - @Override - protected void mouseDragged(Minecraft minecraft, int mouseX, int mouseY) { - super.mouseDragged(minecraft, mouseX, mouseY); - - if (this.draggingHS) { - this.hsb[H] = clamp(mouseX - this.xPosition - 10, 0, 128) / 128F; - this.hsb[S] = (128F - clamp(mouseY - this.yPosition - 10, 0, 128)) / 128F; - this.updateColour(); - } - - if (this.draggingB) { - this.hsb[B] = (128F - clamp(mouseY - this.yPosition - 10, 0, 128)) / 128F; - this.updateColour(); - } - - if (this.draggingA) { - this.opacity = (mouseY - this.yPosition < 11) ? 0xFF000000 : (((128 - (int) clamp(mouseY - this.yPosition - 10, 0, 128)) << 25) & 0xFF000000); - this.updateColour(); - } - } - - /* - * (non-Javadoc) - * @see - * net.minecraft.src.GuiButton#mousePressed(net.minecraft.src.Minecraft, - * int, int) - */ - @Override - public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY) { - if (super.mousePressed(minecraft, mouseX, mouseY)) { - - if (this.btnOk.mousePressed(minecraft, mouseX, mouseY)) - this.result = DialogResult.OK; - - if (this.btnCancel.mousePressed(minecraft, mouseX, mouseY)) - this.result = DialogResult.Cancel; - - if (this.rectHSArea.contains(mouseX, mouseY)) - this.draggingHS = true; - - if (this.rectBArea.contains(mouseX, mouseY)) - this.draggingB = true; - - if (this.rectAArea.contains(mouseX, mouseY)) - this.draggingA = true; - - this.txtRed.mouseClicked(mouseX, mouseY, 0); - this.txtGreen.mouseClicked(mouseX, mouseY, 0); - this.txtBlue.mouseClicked(mouseX, mouseY, 0); - this.txtAlpha.mouseClicked(mouseX, mouseY, 0); - - return true; - } else if (this.enabled) { - this.result = DialogResult.Cancel; - } - - return false; - } - - /* - * (non-Javadoc) - * @see net.minecraft.src.GuiButton#mouseReleased(int, int) - */ - @Override - public void mouseReleased(int mouseX, int mouseY) { - this.draggingHS = false; - this.draggingB = false; - this.draggingA = false; - } - - public boolean textBoxKeyTyped(char keyChar, int keyCode) { - this.txtRed.textboxKeyTyped(keyChar, keyCode); - this.txtGreen.textboxKeyTyped(keyChar, keyCode); - this.txtBlue.textboxKeyTyped(keyChar, keyCode); - this.txtAlpha.textboxKeyTyped(keyChar, keyCode); - this.updateColourFromTextEntry(); - - if (keyCode == Keyboard.KEY_TAB) { - if (this.txtRed.isFocused()) { - this.txtRed.setFocused(false); - this.txtGreen.setFocused(true); - this.txtBlue.setFocused(false); - this.txtAlpha.setFocused(false); - } else if (this.txtGreen.isFocused()) { - this.txtRed.setFocused(false); - this.txtGreen.setFocused(false); - this.txtBlue.setFocused(true); - this.txtAlpha.setFocused(false); - } else if (this.txtBlue.isFocused()) { - this.txtRed.setFocused(false); - this.txtGreen.setFocused(false); - this.txtBlue.setFocused(false); - this.txtAlpha.setFocused(true); - } else { - this.txtRed.setFocused(true); - this.txtGreen.setFocused(false); - this.txtBlue.setFocused(false); - this.txtAlpha.setFocused(false); - } - } - - return true; - } - - public static float clamp(float value, float min, float max) { - return Math.min(Math.max(value, min), max); - } -} \ No newline at end of file diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiControl.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiControl.java deleted file mode 100644 index 85f2f0f0..00000000 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/color/GuiControl.java +++ /dev/null @@ -1,631 +0,0 @@ -package com.voxelmodpack.hdskins.gui.color; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; -import static com.mumfrey.liteloader.gl.GL.*; - -/** - * GuiControlEx is the base class for additional controls. It includes some - * advanced drawing methods which are used by several derived classes - * - * @author Adam Mummery-Smith - */ -public class GuiControl extends GuiButton { - /** - * Used by some controls to indicate the manner in which they have handled a - * keypress - */ - public enum KeyHandledState { - /** - * The control did not handle the keypress - */ - None, - - /** - * The control handled the keypress and the container should do no - * further processing - */ - Handled, - - /** - * The control handled the keypress and the container should call - * actionPerformed - */ - ActionPerformed; - } - - public enum DialogResult { - /** - * No result (maybe the dialog was not closed yet?) - */ - None, - - /** - * Dialog result OK (user clicked OK or pressed RETURN) - */ - OK, - - /** - * Dialog result Cancel (user clicked Cancel or pressed ESCAPE) - */ - Cancel, - - Yes, - - No - } - - /** - * Set by parent screen to enable cursor flash etc - */ - public int updateCounter; - - /** - * Reference to the minecraft game instance - */ - protected Minecraft mc; - - /** - * Flag indicating whether an action was performed, to support GuiScreenEx's - * callback mechanism - */ - protected boolean actionPerformed; - - /** - * Flag tracking whether an item was double-clicked - */ - protected boolean doubleClicked; - - /** - * Scale factor which translates texture pixel coordinates to relative - * coordinates - */ - protected static float texMapScale = 0.00390625F; - - protected static float guiScaleFactor; - - protected static int lastScreenWidth; - protected static int lastScreenHeight; - - /** - * Override from GuiButton, handle this call and forward it to DrawControl - * for neatness - * - * @param minecraft Reference to the minecraft game instance - * @param mouseX Mouse X coordinate - * @param mouseY Mouse Y coordinate - */ - @Override - public final void drawButton(Minecraft minecraft, int mouseX, int mouseY) { - this.drawControl(minecraft, mouseX, mouseY); - } - - /** - * Draw the control - * - * @param minecraft Reference to the minecraft game instance - * @param mouseX Mouse X coordinate - * @param mouseY Mouse Y coordinate - */ - protected void drawControl(Minecraft minecraft, int mouseX, int mouseY) { - super.drawButton(minecraft, mouseX, mouseY); - } - - /** - * Constructor, passes through to GuiButton constructor - * - * @param minecraft Minecraft game instance - * @param controlId Control's ID (used for actionPerformed) - * @param xPos Control X position (left) - * @param yPos Control Y position (top) - * @param controlWidth Control width - * @param controlHeight Control height - * @param displayText Control display text - */ - public GuiControl(Minecraft minecraft, int controlId, int xPos, int yPos, int controlWidth, int controlHeight, String displayText) { - super(controlId, xPos, yPos, controlWidth, controlHeight, displayText); - this.mc = minecraft; - } - - public GuiControl(Minecraft minecraft, int controlId, int xPos, int yPos, String displayText) { - super(controlId, xPos, yPos, displayText); - this.mc = minecraft; - } - - /** - * GuiControlEx returns true from mousePressed if the mouse was captured, - * NOT if an action was performed. Containers should call this function - * afterwards to determine whether an action was performed. - * - * @return True if actionPerformed should be dispatched - */ - public boolean isActionPerformed() { - return this.actionPerformed; - } - - /** - * Get whether an actionPerformed was a double-click event - * - * @return - */ - public boolean isDoubleClicked(boolean resetDoubleClicked) { - boolean result = this.doubleClicked; - if (resetDoubleClicked) - this.doubleClicked = false; - return result; - } - - /** - * Draws a line between two points with the specified width and colour - * - * @param x1 Origin x coordinate - * @param y1 Origin y coordinate - * @param x2 End x coordinate - * @param y2 End y coordinate - * @param width Line width in pixels - * @param colour Line colour - */ - public static void drawLine(int x1, int y1, int x2, int y2, int width, int colour) { - drawArrow(x1, y1, x2, y2, 0, width, colour, false, 0); - } - - /** - * Draws an OpenGL line - * - * @param x1 Start x position - * @param y1 Start y position - * @param x2 End x position - * @param y2 End y position - * @param width Line width - * @param colour Line colour - */ - @SuppressWarnings("cast") - public static void drawNativeLine(float x1, float y1, float x2, float y2, float width, int colour) { - float f = (float) (colour >> 24 & 0xff) / 255F; - float f1 = (float) (colour >> 16 & 0xff) / 255F; - float f2 = (float) (colour >> 8 & 0xff) / 255F; - float f3 = (float) (colour & 0xff) / 255F; - - glEnableBlend(); - glDisableTexture2D(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(f1, f2, f3, f); - glLineWidth(width); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_LINES, VF_POSITION); - buf.pos(x1, y1, 0).endVertex(); - buf.pos(x2, y2, 0).endVertex(); - tessellator.draw(); - - glEnableTexture2D(); - glDisableBlend(); - } - - /** - * Draws an arrow between two points with the specified width and colour - * - * @param x1 Origin x coordinate - * @param y1 Origin y coordinate - * @param x2 End x coordinate - * @param y2 End y coordinate - * @param width Line width in pixels - * @param arrowHeadSize Size of the arrow head - * @param colour Colour - */ - public static void drawArrow(int x1, int y1, int x2, int y2, int z, int width, int arrowHeadSize, int colour) { - drawArrow(x1, y1, x2, y2, z, width, colour, true, arrowHeadSize); - } - - /** - * Internal function for drawing lines and arrows - * - * @param x1 Origin x coordinate - * @param y1 Origin y coordinate - * @param x2 End x coordinate - * @param y2 End y coordinate - * @param width Line width in pixels - * @param colour Colour - * @param arrowHead True to draw an arrow, otherwise draws a line - * @param arrowHeadSize Size of the arrow head - */ - @SuppressWarnings("cast") - public static void drawArrow(int x1, int y1, int x2, int y2, int z, int width, int colour, boolean arrowHead, int arrowHeadSize) { - // Calculate the line length and angle defined by the specified points - int length = (int) Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)); - float angle = (float) Math.toDegrees(Math.atan2(y2 - y1, x2 - x1)); - - // Local rotation - glPushMatrix(); - glTranslatef(x1, y1, 0.0f); - glRotatef(angle, 0.0f, 0.0f, 1.0f); - - // Calc coordinates for the line and arrow points - x1 = 0; - x2 = length - (arrowHead ? arrowHeadSize : 0); - y1 = (int) (width * -0.5); - y2 = y1 + width; - - // Calc colour components - float f = (float) (colour >> 24 & 0xff) / 255F; - float f1 = (float) (colour >> 16 & 0xff) / 255F; - float f2 = (float) (colour >> 8 & 0xff) / 255F; - float f3 = (float) (colour & 0xff) / 255F; - - glEnableBlend(); - glDisableTexture2D(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(f1, f2, f3, f); - - // Draw the line - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_QUADS, VF_POSITION); - buf.pos(x1, y2, z).endVertex(); - buf.pos(x2, y2, z).endVertex(); - buf.pos(x2, y1, z).endVertex(); - buf.pos(x1, y1, z).endVertex(); - tessellator.draw(); - - // If an arrow then draw the arrow head - if (arrowHead && arrowHeadSize > 0) { - buf.begin(GL_TRIANGLES, VF_POSITION); - buf.pos(x2, 0 - arrowHeadSize / 2, z).endVertex(); - buf.pos(x2, arrowHeadSize / 2, z).endVertex(); - buf.pos(length, 0, z).endVertex(); - tessellator.draw(); - } - - glEnableTexture2D(); - glDisableBlend(); - - glPopMatrix(); - } - - /** - * Set the texmap scale factor - * - * @param textureSize - */ - @SuppressWarnings("cast") - public void setTexMapSize(int textureSize) { - texMapScale = 1F / (float) textureSize; - } - - /** - * Draws a textured rectangle at 90 degrees - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - */ - @SuppressWarnings("cast") - public void drawTexturedModalRectRot(int x, int y, int x2, int y2, int u, int v, int u2, int v2) { - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_QUADS, VF_POSITION_TEX); - buf.pos(x2, y2, this.zLevel).tex((float) (u) * texMapScale, (float) (v2) * texMapScale).endVertex(); - buf.pos(x2, y, this.zLevel).tex((float) (u2) * texMapScale, (float) (v2) * texMapScale).endVertex(); - buf.pos(x, y, this.zLevel).tex((float) (u2) * texMapScale, (float) (v) * texMapScale).endVertex(); - buf.pos(x, y2, this.zLevel).tex((float) (u) * texMapScale, (float) (v) * texMapScale).endVertex(); - tessellator.draw(); - } - - /** - * Draws a textured rectangle at 90 degrees - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param width Width of texture to draw - * @param height Height of texture to draw - */ - @SuppressWarnings("cast") - public void drawTexturedModalRectRot(int x, int y, int u, int v, int width, int height) { - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_QUADS, VF_POSITION_TEX); - buf.pos(x + height, y + width, this.zLevel).tex((float) (u) * texMapScale, (float) (v + height) * texMapScale).endVertex(); - buf.pos(x + height, y, this.zLevel).tex((float) (u + width) * texMapScale, (float) (v + height) * texMapScale).endVertex(); - buf.pos(x, y, this.zLevel).tex((float) (u + width) * texMapScale, (float) (v) * texMapScale).endVertex(); - buf.pos(x, y + width, this.zLevel).tex((float) (u) * texMapScale, (float) (v) * texMapScale).endVertex(); - tessellator.draw(); - } - - /** - * Draws a tesselated rectangle where the texture is stretched horizontally - * but vertical scaling is achieved by splitting the texture in half and - * repeating the middle pixels - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - */ - public void drawTessellatedModalRectV(int x, int y, int x2, int y2, int u, int v, int u2, int v2) { - int tileSize = ((v2 - v) / 2); - int vMidTop = v + tileSize; - int vMidBtm = vMidTop + 1; - - this.drawTexturedModalRect(x, y, x2, y + tileSize, u, v, u2, vMidTop); - this.drawTexturedModalRect(x, y + tileSize, x2, y2 - tileSize + 1, u, vMidTop, u2, vMidBtm); - this.drawTexturedModalRect(x, y2 - tileSize + 1, x2, y2, u, vMidBtm, u2, v2); - } - - /** - * Draws a tesselated rectangle where the texture is stretched vertically - * but horizontal scaling is achieved by splitting the texture in half and - * repeating the middle pixels - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - */ - public void drawTessellatedModalRectH(int x, int y, int x2, int y2, int u, int v, int u2, int v2) { - int tileSize = ((u2 - u) / 2); - int uMidLeft = u + tileSize; - int uMidRight = uMidLeft + 1; - - this.drawTexturedModalRect(x, y, x + tileSize, y2, u, v, uMidLeft, v2); - this.drawTexturedModalRect(x + tileSize, y, x2 - tileSize + 1, y2, uMidLeft, v, uMidRight, v2); - this.drawTexturedModalRect(x2 - tileSize + 1, y, x2, y2, uMidRight, v, u2, v2); - } - - /** - * Draws a tesselated rectangle where the texture is stretched vertically - * and horizontally but the middle pixels are repeated whilst the joining - * pixels are stretched. - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - */ - public void drawTessellatedModalBorderRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2) { - this.drawTessellatedModalBorderRect(x, y, x2, y2, u, v, u2, v2, Math.min(((x2 - x) / 2) - 1, ((y2 - y) / 2) - 1)); - } - - /** - * Draws a tesselated rectangle where the texture is stretched vertically - * and horizontally but the middle pixels are repeated whilst the joining - * pixels are stretched. Bordersize specifies the portion of the texture - * which will remain unstretched. - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - * @param borderSize Number of pixels to leave unstretched, must be less - * than half of the width or height (whichever is smallest) - */ - public void drawTessellatedModalBorderRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2, int borderSize) { - int tileSize = Math.min(((u2 - u) / 2) - 1, ((v2 - v) / 2) - 1); - - int ul = u + tileSize, ur = u2 - tileSize, vt = v + tileSize, vb = v2 - tileSize; - int xl = x + borderSize, xr = x2 - borderSize, yt = y + borderSize, yb = y2 - borderSize; - - this.drawTexturedModalRect(x, y, xl, yt, u, v, ul, vt); - this.drawTexturedModalRect(xl, y, xr, yt, ul, v, ur, vt); - this.drawTexturedModalRect(xr, y, x2, yt, ur, v, u2, vt); - this.drawTexturedModalRect(x, yb, xl, y2, u, vb, ul, v2); - this.drawTexturedModalRect(xl, yb, xr, y2, ul, vb, ur, v2); - this.drawTexturedModalRect(xr, yb, x2, y2, ur, vb, u2, v2); - this.drawTexturedModalRect(x, yt, xl, yb, u, vt, ul, vb); - this.drawTexturedModalRect(xr, yt, x2, yb, ur, vt, u2, vb); - this.drawTexturedModalRect(xl, yt, xr, yb, ul, vt, ur, vb); - } - - /** - * Draw a string but cut it off if it's too long to fit in the specified - * width - * - * @param fontrenderer - * @param s - * @param x - * @param y - * @param width - * @param colour - */ - public static void drawStringWithEllipsis(FontRenderer fontrenderer, String s, int x, int y, int width, int colour) { - if (fontrenderer.getStringWidth(s) <= width) { - fontrenderer.drawStringWithShadow(s, x, y, colour); // func_175063_a - // drawStringWithShadow - } else if (width < 8) { - fontrenderer.drawStringWithShadow("..", x, y, colour); // func_175063_a - // drawStringWithShadow - } else { - String trimmedText = s; - - while (fontrenderer.getStringWidth(trimmedText) > width - 8 && trimmedText.length() > 0) - trimmedText = trimmedText.substring(0, trimmedText.length() - 1); - - fontrenderer.drawStringWithShadow(trimmedText + "...", x, y, colour); // func_175063_a - // drawStringWithShadow - } - } - - /** - * @param boundingBox - */ - @SuppressWarnings("cast") - protected void drawCrossHair(int x, int y, int size, int width, int colour) { - float alpha = (float) (colour >> 24 & 0xff) / 255F; - float red = (float) (colour >> 16 & 0xff) / 255F; - float green = (float) (colour >> 8 & 0xff) / 255F; - float blue = (float) (colour & 0xff) / 255F; - - glLineWidth(GuiControl.guiScaleFactor * width); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnableBlend(); - glDisableTexture2D(); - glDisableLighting(); - glColor4f(red, green, blue, alpha); - glEnableColorLogic(); - glLogicOp(GL_OR_REVERSE); - - // Draw the frame - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - - buf.begin(GL_LINES, VF_POSITION); - buf.pos(x - size, y, 0).endVertex(); - buf.pos(x + size, y, 0).endVertex(); - tessellator.draw(); - - buf.begin(GL_LINES, VF_POSITION); - buf.pos(x, y - size, 0).endVertex(); - buf.pos(x, y + size, 0).endVertex(); - tessellator.draw(); - - glDisableColorLogic(); - glEnableTexture2D(); - } - - protected void drawRotText(FontRenderer fontRenderer, String text, int xPosition, int yPosition, int colour, boolean colourOrOp) { - if (colourOrOp) { - glEnableColorLogic(); - glLogicOp(GL_OR_REVERSE); - } - - int textWidth = fontRenderer.getStringWidth(text) / 2; - - glPushMatrix(); - glTranslatef(xPosition, yPosition, 0); - glRotatef(-90, 0, 0, 1); - glTranslatef(-textWidth, -4, 0); - - fontRenderer.drawString(text, 0, 0, colour); - - glPopMatrix(); - - if (colourOrOp) { - glDisableColorLogic(); - glEnableTexture2D(); - } - } - - /** - * Draw a tooltip at the specified location and clip to screenWidth and - * screenHeight - * - * @param fontRenderer - * @param tooltipText - * @param mouseX - * @param mouseY - * @param screenWidth - * @param screenHeight - * @param colour - * @param backgroundColour - */ - protected void drawTooltip(FontRenderer fontRenderer, String tooltipText, int mouseX, int mouseY, int screenWidth, int screenHeight, int colour, int backgroundColour) { - int textSize = fontRenderer.getStringWidth(tooltipText); - mouseX = Math.max(0, Math.min(screenWidth - textSize - 6, mouseX - 6)); - mouseY = Math.max(0, Math.min(screenHeight - 16, mouseY - 18)); - - drawRect(mouseX, mouseY, mouseX + textSize + 6, mouseY + 16, backgroundColour); - this.drawString(fontRenderer, tooltipText, mouseX + 3, mouseY + 4, colour); - } - - /** - * Draws a textured rectangle with custom UV coordinates - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - */ - @SuppressWarnings("cast") - public void drawTexturedModalRect(int x, int y, int x2, int y2, int u, int v, int u2, int v2) { - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_QUADS, VF_POSITION_TEX); - buf.pos(x, y2, this.zLevel).tex((float) (u) * texMapScale, (float) (v2) * texMapScale).endVertex(); - buf.pos(x2, y2, this.zLevel).tex((float) (u2) * texMapScale, (float) (v2) * texMapScale).endVertex(); - buf.pos(x2, y, this.zLevel).tex((float) (u2) * texMapScale, (float) (v) * texMapScale).endVertex(); - buf.pos(x, y, this.zLevel).tex((float) (u) * texMapScale, (float) (v) * texMapScale).endVertex(); - tessellator.draw(); - } - - /** - * Draws a textured rectangle with custom UV coordinates - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param x2 Right edge X coordinate - * @param y2 Bottom edge Y coordinate - * @param u U coordinate - * @param v V coordinate - * @param u2 Right edge U coordinate - * @param v2 Bottom edge V coordinate - */ - public void drawTexturedModalRectF(int x, int y, int x2, int y2, float u, float v, float u2, float v2) { - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_QUADS, VF_POSITION_TEX); - buf.pos(x, y2, this.zLevel).tex(u, v2).endVertex(); - buf.pos(x2, y2, this.zLevel).tex(u2, v2).endVertex(); - buf.pos(x2, y, this.zLevel).tex(u2, v).endVertex(); - buf.pos(x, y, this.zLevel).tex(u, v).endVertex(); - tessellator.draw(); - } - - /** - * Draws a textured rectangle with the specified texture map size - * - * @param x Left edge X coordinate - * @param y Top edge Y coordinate - * @param u Texture U coordinate - * @param v Texture V coordinate - * @param width Width - * @param height Height - * @param texMapScale Texture map scale for scaling UV coordinate - */ - @SuppressWarnings("cast") - public void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float texMapScale) { - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buf = tessellator.getBuffer(); - buf.begin(GL_QUADS, VF_POSITION_TEX); - buf.pos(x + 0, y + height, this.zLevel).tex((float) (u + 0) * texMapScale, (float) (v + height) * texMapScale).endVertex(); - buf.pos(x + width, y + height, this.zLevel).tex((float) (u + width) * texMapScale, (float) (v + height) * texMapScale).endVertex(); - buf.pos(x + width, y + 0, this.zLevel).tex((float) (u + width) * texMapScale, (float) (v + 0) * texMapScale).endVertex(); - buf.pos(x + 0, y + 0, this.zLevel).tex((float) (u + 0) * texMapScale, (float) (v + 0) * texMapScale).endVertex(); - tessellator.draw(); - } - - public static void setScreenSizeAndScale(int width, int height, int scaleFactor) { - GuiControl.lastScreenWidth = width; - GuiControl.lastScreenHeight = height; - GuiControl.guiScaleFactor = scaleFactor; - } -} \ No newline at end of file diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java index a82bd655..6612e71e 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java @@ -1,17 +1,15 @@ package com.voxelmodpack.hdskins.mixin; +import com.voxelmodpack.hdskins.gui.GuiButtonSkins; +import com.voxelmodpack.hdskins.gui.GuiSkins; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.voxelmodpack.hdskins.gui.GuiButtonSkins; -import com.voxelmodpack.hdskins.gui.GuiSkins; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiMainMenu; -import net.minecraft.client.gui.GuiScreen; - @Mixin(GuiMainMenu.class) public class MixinGuiMainMenu extends GuiScreen { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java index 6ebbdb44..c105f392 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java @@ -1,8 +1,8 @@ package com.voxelmodpack.hdskins.mixin; -import java.awt.Graphics; -import java.awt.image.BufferedImage; - +import com.voxelmodpack.hdskins.HDSkinManager; +import net.minecraft.client.renderer.IImageBuffer; +import net.minecraft.client.renderer.ImageBufferDownload; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At.Shift; @@ -11,10 +11,8 @@ import org.spongepowered.asm.mixin.injection.Surrogate; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import com.voxelmodpack.hdskins.HDSkinManager; - -import net.minecraft.client.renderer.IImageBuffer; -import net.minecraft.client.renderer.ImageBufferDownload; +import java.awt.Graphics; +import java.awt.image.BufferedImage; @Mixin(ImageBufferDownload.class) public abstract class MixinImageBufferDownload implements IImageBuffer { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java index a2a18f5c..1cfd8946 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java @@ -1,19 +1,18 @@ package com.voxelmodpack.hdskins.mixin; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; +import com.voxelmodpack.hdskins.HDSkinManager; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.util.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.google.common.base.Optional; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; -import com.voxelmodpack.hdskins.HDSkinManager; - -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.util.ResourceLocation; +import java.util.Optional; @Mixin(NetworkPlayerInfo.class) public abstract class MixinPlayerInfo { @@ -44,12 +43,10 @@ public abstract class MixinPlayerInfo { private void getLocationElytra(CallbackInfoReturnable ci) { getTextureLocation(ci, Type.ELYTRA); } - + private void getTextureLocation(CallbackInfoReturnable ci, Type type) { Optional texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), type, true); - if (texture.isPresent()) { - ci.setReturnValue(texture.get()); - } + texture.ifPresent(ci::setReturnValue); } @Inject( @@ -60,12 +57,12 @@ public abstract class MixinPlayerInfo { MinecraftProfileTexture data = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN); if (data != null) { String type = data.getMetadata("model"); - boolean hasSkin = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false).isPresent(); - if (hasSkin) { - if (type == null) - type = "default"; - ci.setReturnValue(type); - } + if (type == null) + type = "default"; + String type1 = type; + Optional texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false); + + texture.ifPresent((res) -> ci.setReturnValue(type1)); } } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java index c82cc04a..56fbce66 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java @@ -1,19 +1,18 @@ package com.voxelmodpack.hdskins.mixin; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import com.google.common.base.Optional; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.HDSkinManager; - import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Optional; @Mixin(TileEntitySkullRenderer.class) public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer { @@ -25,7 +24,7 @@ public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true); if (skin.isPresent()) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mod/LiteModHDSkinsMod.java b/src/hdskins/java/com/voxelmodpack/hdskins/mod/LiteModHDSkinsMod.java index 9d204c61..466b20c7 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mod/LiteModHDSkinsMod.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mod/LiteModHDSkinsMod.java @@ -1,8 +1,5 @@ package com.voxelmodpack.hdskins.mod; -import java.io.File; -import java.lang.reflect.Method; - import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.modconfig.ConfigPanel; import com.mumfrey.liteloader.util.ModUtilities; @@ -11,11 +8,12 @@ import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.GuiSkins; import com.voxelmodpack.hdskins.gui.HDSkinsConfigPanel; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; -import com.voxelmodpack.voxelmenu.IPanoramaRenderer; - import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IReloadableResourceManager; +import java.io.File; +import java.lang.reflect.Method; + public class LiteModHDSkinsMod implements HDSkinsMod { @Override public String getName() { @@ -55,23 +53,6 @@ public class LiteModHDSkinsMod implements HDSkinsMod { @Override public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { - ModUtilities.addRenderer(EntityPlayerModel.class, new RenderPlayerModel(minecraft.getRenderManager())); - } - - public static IPanoramaRenderer getPanoramaRenderer(IPanoramaRenderer fallbackRenderer) { - try { - Class ex = Class.forName("com.thevoxelbox.voxelmenu.VoxelMenuModCore"); - Method mGetPanoramaRenderer = ex.getDeclaredMethod("getPanoramaRenderer"); - IPanoramaRenderer panoramaRenderer = (IPanoramaRenderer) mGetPanoramaRenderer.invoke(null); - if (panoramaRenderer != null) { - return panoramaRenderer; - } - } catch (ClassNotFoundException var4) { - - } catch (Exception var5) { - var5.printStackTrace(); - } - - return fallbackRenderer; + ModUtilities.addRenderer(EntityPlayerModel.class, new RenderPlayerModel<>(minecraft.getRenderManager())); } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java b/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java index a7e30700..2f4c2bf3 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java @@ -1,21 +1,18 @@ package com.voxelmodpack.hdskins.resource; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; -import java.util.concurrent.Callable; - -import javax.annotation.Nullable; - -import org.apache.commons.io.IOUtils; - import com.google.common.base.Throwables; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.ImageBufferDownloadHD; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; + +import javax.annotation.Nullable; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.Callable; public class ImageLoader implements Callable { @@ -33,14 +30,7 @@ public class ImageLoader implements Callable { final BufferedImage updated = new ImageBufferDownloadHD().parseUserSkin(image); if (updated == null) return null; - return this.mc.addScheduledTask(new Callable() { - - @Override - public ResourceLocation call() throws Exception { - return loadSkin(updated); - } - - }).get(); + return this.mc.addScheduledTask(() -> loadSkin(updated)).get(); } @Nullable diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinData.java b/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinData.java index 5745b8a7..59f46576 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinData.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinData.java @@ -1,20 +1,22 @@ package com.voxelmodpack.hdskins.resource; +import net.minecraft.util.ResourceLocation; + import java.util.List; import java.util.UUID; -import net.minecraft.util.ResourceLocation; - +@SuppressWarnings("unused") class SkinData { List skins; } +@SuppressWarnings("unused") class Skin { String name; UUID uuid; - private String skin; + String skin; public ResourceLocation getTexture() { return new ResourceLocation("hdskins", String.format("textures/skins/%s.png", skin)); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java index 82793b65..572def1a 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java @@ -1,18 +1,5 @@ package com.voxelmodpack.hdskins.resource; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import javax.annotation.Nullable; - -import org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.LogManager; - import com.google.common.collect.Maps; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -22,12 +9,22 @@ import com.google.gson.JsonParseException; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.LogManager; + +import javax.annotation.Nullable; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; public class SkinResourceManager implements IResourceManagerReloadListener { @@ -113,16 +110,13 @@ public class SkinResourceManager implements IResourceManagerReloadListener { if (this.inProgress.get(res) == null) { // read and convert in a new thread final ListenableFuture conv = executor.submit(new ImageLoader(res)); - conv.addListener(new Runnable() { - @Override - public void run() { - try { - if (!conv.isCancelled()) - converted.put(res, conv.get()); - } catch (Exception e) { - LogManager.getLogger().warn("Errored while processing " + res + ". Using original.", e); - converted.put(res, res); - } + conv.addListener(() -> { + try { + if (!conv.isCancelled()) + converted.put(res, conv.get()); + } catch (Exception e) { + LogManager.getLogger().warn("Errored while processing " + res + ". Using original.", e); + converted.put(res, res); } }, executor); this.inProgress.put(res, conv); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/IUploadCompleteCallback.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/IUploadCompleteCallback.java index 71d46c38..95e9c546 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/IUploadCompleteCallback.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/IUploadCompleteCallback.java @@ -1,5 +1,5 @@ package com.voxelmodpack.hdskins.upload; public interface IUploadCompleteCallback { - public abstract void onUploadComplete(String response); + void onUploadComplete(String response); } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java index 3cd6168f..38062f0a 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java @@ -1,10 +1,10 @@ package com.voxelmodpack.hdskins.upload; +import com.google.common.io.Files; + import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -19,7 +19,7 @@ import java.util.Map.Entry; * @author Adam Mummery-Smith */ public class ThreadMultipartPostUpload extends Thread { - protected final Map sourceData; + protected final Map sourceData; protected final String method; @@ -39,12 +39,7 @@ public class ThreadMultipartPostUpload extends Thread { public String response; - public int httpResponseCode; - - public String httpResponse; - - public ThreadMultipartPostUpload(String method, String url, Map sourceData, String authorization, - IUploadCompleteCallback callback) { + public ThreadMultipartPostUpload(String method, String url, Map sourceData, String authorization, IUploadCompleteCallback callback) { this.method = method; this.urlString = url; this.sourceData = sourceData; @@ -52,7 +47,7 @@ public class ThreadMultipartPostUpload extends Thread { this.callback = callback; } - public ThreadMultipartPostUpload(String url, Map sourceData, IUploadCompleteCallback callback) { + public ThreadMultipartPostUpload(String url, Map sourceData, IUploadCompleteCallback callback) { this("POST", url, sourceData, null, callback); } @@ -66,11 +61,6 @@ public class ThreadMultipartPostUpload extends Thread { this.uploadMultipart(); } catch (IOException ex) { ex.printStackTrace(); - - try { - this.httpResponseCode = this.httpClient.getResponseCode(); - this.httpResponse = this.httpClient.getResponseMessage(); - } catch (Exception ex1) {} } this.callback.onUploadComplete(this.getResponse()); @@ -87,12 +77,10 @@ public class ThreadMultipartPostUpload extends Thread { this.httpClient.setRequestMethod(this.method); this.httpClient.setRequestProperty("Connection", "Close"); - this.httpClient.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For - // CloudFlare + this.httpClient.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For CloudFlare if (this.sourceData.size() > 0) { - this.httpClient.setRequestProperty("Content-Type", - "multipart/form-data, boundary=" + ThreadMultipartPostUpload.boundary); + this.httpClient.setRequestProperty("Content-Type", "multipart/form-data, boundary=" + boundary); } if (this.authorization != null) { @@ -101,30 +89,27 @@ public class ThreadMultipartPostUpload extends Thread { DataOutputStream outputStream = new DataOutputStream(this.httpClient.getOutputStream()); - for (Entry data : this.sourceData.entrySet()) { - outputStream.writeBytes(ThreadMultipartPostUpload.twoHyphens + ThreadMultipartPostUpload.boundary - + ThreadMultipartPostUpload.CRLF); + for (Entry data : this.sourceData.entrySet()) { + outputStream.writeBytes(twoHyphens + boundary + CRLF); String paramName = data.getKey(); Object paramData = data.getValue(); if (paramData instanceof File) { File uploadFile = (File) paramData; - outputStream.writeBytes( - "Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + uploadFile.getName() - + "\"" + ThreadMultipartPostUpload.CRLF + ThreadMultipartPostUpload.CRLF); - this.writeFile(uploadFile, outputStream); + outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + uploadFile.getName() + "\"" + CRLF + CRLF); + + Files.asByteSource(uploadFile).copyTo(outputStream); + } else { - outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"" - + ThreadMultipartPostUpload.CRLF + ThreadMultipartPostUpload.CRLF); + outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"" + CRLF + CRLF); outputStream.writeBytes(paramData.toString()); } outputStream.writeBytes(ThreadMultipartPostUpload.CRLF); } - outputStream.writeBytes(ThreadMultipartPostUpload.twoHyphens + ThreadMultipartPostUpload.boundary - + ThreadMultipartPostUpload.twoHyphens + ThreadMultipartPostUpload.CRLF); + outputStream.writeBytes(twoHyphens + boundary + twoHyphens + CRLF); outputStream.flush(); InputStream httpStream = this.httpClient.getInputStream(); @@ -145,36 +130,6 @@ public class ThreadMultipartPostUpload extends Thread { } outputStream.close(); - - this.httpResponseCode = this.httpClient.getResponseCode(); - this.httpResponse = this.httpClient.getResponseMessage(); } - /** - * @param sourceFile - * @param outputStream - * @throws FileNotFoundException - * @throws IOException - */ - public void writeFile(File sourceFile, DataOutputStream outputStream) throws FileNotFoundException, IOException { - int bytesRead, bufferSize; - int maxBufferSize = 1 * 1024 * 1024; - - FileInputStream fileInputStream = new FileInputStream(sourceFile); - - int bytesAvailable = fileInputStream.available(); - bufferSize = Math.min(bytesAvailable, maxBufferSize); - byte[] buffer = new byte[bufferSize]; - - bytesRead = fileInputStream.read(buffer, 0, bufferSize); - - while (bytesRead > 0) { - outputStream.write(buffer, 0, bufferSize); - bytesAvailable = fileInputStream.available(); - bufferSize = Math.min(bytesAvailable, maxBufferSize); - bytesRead = fileInputStream.read(buffer, 0, bufferSize); - } - - fileInputStream.close(); - } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/IOpenFileCallback.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/IOpenFileCallback.java index 7ebeaaf3..7a0b0795 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/IOpenFileCallback.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/IOpenFileCallback.java @@ -11,10 +11,7 @@ public interface IOpenFileCallback { /** * Callback method called when the "open file" dialog is closed - * - * @param fileDialog - * @param dialogResult */ - public abstract void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult); + void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult); -} \ No newline at end of file +} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java index 4d19145d..fbd68e5d 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java @@ -1,22 +1,16 @@ package com.voxelmodpack.hdskins.upload.awt; -import java.awt.Frame; +import net.minecraft.client.Minecraft; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; -import net.minecraft.client.Minecraft; - /** * Base class for "open file" dialog threads - * + * * @author Adam Mummery-Smith */ public abstract class ThreadOpenFile extends Thread { - /** - * Minecraft's AWT parent frame - */ - protected Frame parentFrame; protected String dialogTitle; @@ -25,10 +19,6 @@ public abstract class ThreadOpenFile extends Thread { */ protected final IOpenFileCallback parentScreen; - /** - * @param minecraft - * @param callback - */ protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) throws IllegalStateException { if (minecraft.isFullScreen()) { @@ -45,15 +35,13 @@ public abstract class ThreadOpenFile extends Thread { fileDialog.setDialogTitle(this.dialogTitle); fileDialog.setFileFilter(this.getFileFilter()); - int dialogResult = fileDialog.showOpenDialog(this.parentFrame); + int dialogResult = fileDialog.showOpenDialog(null); this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult); } /** * Subclasses should override this to return a file filter - * - * @return */ protected abstract FileFilter getFileFilter(); -} \ No newline at end of file +} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFilePNG.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFilePNG.java index 60821377..2f15a7c1 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFilePNG.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFilePNG.java @@ -1,31 +1,22 @@ package com.voxelmodpack.hdskins.upload.awt; -import java.io.File; - -import javax.swing.filechooser.FileFilter; - import net.minecraft.client.Minecraft; +import javax.swing.filechooser.FileFilter; +import java.io.File; + /** * Opens an awt "Open File" dialog with a PNG file filter - * + * * @author Adam Mummery-Smith */ public class ThreadOpenFilePNG extends ThreadOpenFile { - /** - * @param minecraft - * @param dialogTitle - * @param callback - * @throws IllegalStateException - */ + public ThreadOpenFilePNG(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) throws IllegalStateException { super(minecraft, dialogTitle, callback); } - /** - * @return - */ @Override protected FileFilter getFileFilter() { return new FileFilter() { diff --git a/src/hdskins/java/com/voxelmodpack/voxelmenu/IPanoramaRenderer.java b/src/hdskins/java/com/voxelmodpack/voxelmenu/IPanoramaRenderer.java deleted file mode 100644 index b618d244..00000000 --- a/src/hdskins/java/com/voxelmodpack/voxelmenu/IPanoramaRenderer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.voxelmodpack.voxelmenu; - -import net.minecraft.client.Minecraft; - -public interface IPanoramaRenderer { - void setPanoramaResolution(Minecraft var1, int var2, int var3); - - void initPanoramaRenderer(); - - void updatePanorama(); - - boolean renderPanorama(int var1, int var2, float var3); - - int getUpdateCounter(); -} diff --git a/src/hdskins/resources/mixin.hdskins.json b/src/hdskins/resources/mixin.hdskins.json index ac5a2aba..50424bac 100644 --- a/src/hdskins/resources/mixin.hdskins.json +++ b/src/hdskins/resources/mixin.hdskins.json @@ -1,12 +1,12 @@ { - "required": true, - "minVersion": "0.4.10", - "package": "com.voxelmodpack.hdskins.mixin", - "refmap": "mixin.hdskins.refmap.json", - "mixins": [ - "MixinGuiMainMenu", - "MixinImageBufferDownload", - "MixinPlayerInfo", - "MixinSkullRenderer" - ] -} \ No newline at end of file + "required": true, + "minVersion": "0.6", + "package": "com.voxelmodpack.hdskins.mixin", + "refmap": "mixin.hdskins.refmap.json", + "mixins": [ + "MixinGuiMainMenu", + "MixinImageBufferDownload", + "MixinPlayerInfo", + "MixinSkullRenderer" + ] +} diff --git a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java index 60cc07c7..bf40a70b 100644 --- a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java +++ b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java @@ -1,13 +1,12 @@ package com.minelittlepony; -import java.io.File; - import com.mumfrey.liteloader.InitCompleteListener; import com.mumfrey.liteloader.Tickable; import com.mumfrey.liteloader.core.LiteLoader; - import net.minecraft.client.Minecraft; +import java.io.File; + public class LiteModMineLittlePony implements Tickable, InitCompleteListener { private MineLittlePony mlp; @@ -23,7 +22,8 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener { } @Override - public void upgradeSettings(String version, File configPath, File oldConfigPath) {} + public void upgradeSettings(String version, File configPath, File oldConfigPath) { + } @Override public void init(File configPath) { diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index b9f74481..75dd042b 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -12,7 +12,6 @@ import com.minelittlepony.renderer.RenderPonyVillager; import com.minelittlepony.renderer.RenderPonyVindicator; import com.minelittlepony.renderer.RenderPonyZombie; import com.minelittlepony.renderer.RenderPonyZombieVillager; -import com.minelittlepony.util.MineLPLogger; import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.util.ModUtilities; import com.voxelmodpack.hdskins.HDSkinManager; @@ -33,10 +32,15 @@ import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.passive.EntityVillager; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.lwjgl.input.Keyboard; public class MineLittlePony { + public static final Logger logger = LogManager.getLogger("MineLittlePony"); + + public static final String MOD_NAME = "Mine Little Pony"; public static final String MOD_VERSION = "@VERSION@"; @@ -77,38 +81,39 @@ public class MineLittlePony { manager.setSkinUrl(SKIN_SERVER_URL); manager.setGatewayURL(GATEWAY_URL); manager.addSkinModifier(new PonySkinModifier()); - MineLPLogger.info("Set MineLP skin server URL."); + logger.info("Set MineLP skin server URL."); RenderManager rm = minecraft.getRenderManager(); ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); if (this.config.villagers) { ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); ModUtilities.addRenderer(EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); - MineLPLogger.info("Villagers are now ponies."); + logger.info("Villagers are now ponies."); } if (this.config.zombies) { - ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm)); + ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie<>(rm)); ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm)); - MineLPLogger.info("Zombies are now ponies."); + logger.info("Zombies are now ponies."); } if (this.config.pigzombies) { ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyPigman(rm)); - MineLPLogger.info("Zombie pigmen are now ponies."); + logger.info("Zombie pigmen are now ponies."); } if (this.config.skeletons) { - ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm)); + ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton<>(rm)); ModUtilities.addRenderer(EntityStray.class, new RenderPonySkeleton.Stray(rm)); ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); - MineLPLogger.info("Skeletons are now ponies."); + logger.info("Skeletons are now ponies."); } if (this.config.illagers) { ModUtilities.addRenderer(EntityVex.class, new RenderPonyVex(rm)); ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm)); ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm)); + logger.info("Illagers are now ponies."); } } diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java index 62164da6..455d1c9b 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/Pony.java @@ -1,25 +1,9 @@ package com.minelittlepony; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.List; - -import javax.annotation.Nonnull; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.util.MineLPLogger; import com.minelittlepony.util.PonyFields; -import com.mojang.authlib.GameProfile; -import com.mumfrey.webprefs.WebPreferencesManager; -import com.mumfrey.webprefs.interfaces.IWebPreferences; import com.voxelmodpack.hdskins.DynamicTextureImage; -import com.voxelmodpack.hdskins.HDSkinManager; - import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.ThreadDownloadImageData; @@ -29,6 +13,10 @@ import net.minecraft.client.resources.IResource; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import javax.annotation.Nonnull; +import java.awt.image.BufferedImage; +import java.io.IOException; + public class Pony { private static PonyConfig config = MineLittlePony.getConfig(); @@ -36,7 +24,6 @@ public class Pony { private static int ponyCount = 0; private final int ponyId = ponyCount++; - public GameProfile profile; public ResourceLocation textureResourceLocation; public PonyData metadata = new PonyData(); @@ -44,16 +31,15 @@ public class Pony { private boolean skinChecked; public Pony(@Nonnull AbstractClientPlayer player) { - this.profile = player.getGameProfile(); this.textureResourceLocation = player.getLocationSkin(); - MineLPLogger.debug("+ Initialising new pony #%d for player %s (%s) with resource location %s.", this.ponyId, + MineLittlePony.logger.debug("+ Initialising new pony #%d for player %s (%s) with resource location %s.", this.ponyId, player.getName(), player.getUniqueID(), this.textureResourceLocation); this.checkSkin(this.textureResourceLocation); } public Pony(@Nonnull ResourceLocation aTextureResourceLocation) { this.textureResourceLocation = aTextureResourceLocation; - MineLPLogger.debug("+ Initialising new pony #%d with resource location %s.", this.ponyId, this.textureResourceLocation); + MineLittlePony.logger.debug("+ Initialising new pony #%d with resource location %s.", this.ponyId, this.textureResourceLocation); this.checkSkin(this.textureResourceLocation); } @@ -80,10 +66,9 @@ public class Pony { try { IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); - MineLPLogger.debug("Obtained skin from resource location %s", textureResourceLocation); + MineLittlePony.logger.debug("Obtained skin from resource location %s", textureResourceLocation); // this.checkSkin(skinImage); - } catch (IOException var6) { - Exception e = var6; + } catch (IOException e) { try { ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation); @@ -91,13 +76,13 @@ public class Pony { skinImage = PonyFields.downloadedImage.get((ThreadDownloadImageData) e2); if (skinImage != null) { - MineLPLogger.debug(e, "Successfully reflected downloadedImage from texture object"); + MineLittlePony.logger.debug("Successfully reflected downloadedImage from texture object", e); // this.checkSkin(skinImage); } } else if (e2 instanceof DynamicTextureImage) { skinImage = ((DynamicTextureImage) e2).getImage(); } - } catch (Exception var5) { + } catch (Exception ignored) { } } @@ -106,12 +91,13 @@ public class Pony { } public void checkSkin(BufferedImage bufferedimage) { - MineLPLogger.debug("\tStart skin check #%d for pony #%d with image %s.", ++this.skinCheckCount, this.ponyId); + MineLittlePony.logger.debug("\tStart skin check #%d for pony #%d with image %s.", ++this.skinCheckCount, this.ponyId); metadata = PonyData.parse(bufferedimage); this.skinChecked = true; } public boolean isPegasusFlying(EntityPlayer player) { + //noinspection SimplifiableIfStatement if (this.metadata.getRace() == null || !this.metadata.getRace().hasWings()) { return false; } @@ -121,14 +107,14 @@ public class Pony { public PlayerModel getModel(boolean ignorePony, boolean smallArms) { boolean is_a_pony = false; switch (ignorePony ? PonyLevel.BOTH : config.getPonyLevel()) { - case HUMANS: - is_a_pony = false; - break; - case BOTH: - is_a_pony = metadata.getRace() != null; - break; - case PONIES: - is_a_pony = true; + case HUMANS: + is_a_pony = false; + break; + case BOTH: + is_a_pony = metadata.getRace() != null; + break; + case PONIES: + is_a_pony = true; } PlayerModel model; @@ -144,7 +130,4 @@ public class Pony { return this.textureResourceLocation; } - public GameProfile getProfile() { - return profile; - } } diff --git a/src/main/java/com/minelittlepony/PonyData.java b/src/main/java/com/minelittlepony/PonyData.java index fb077160..cbd91db2 100644 --- a/src/main/java/com/minelittlepony/PonyData.java +++ b/src/main/java/com/minelittlepony/PonyData.java @@ -1,14 +1,13 @@ package com.minelittlepony; +import com.google.common.collect.ImmutableBiMap; + import java.awt.image.BufferedImage; import java.util.Map; -import com.google.common.collect.ImmutableBiMap; -import net.minecraft.client.resources.data.IMetadataSection; - public class PonyData implements IPonyData { - private static final Map RACE_COLORS = ImmutableBiMap. builder() + private static final Map RACE_COLORS = ImmutableBiMap.builder() .put(0xf9b131, PonyRace.EARTH) .put(0xd19fe4, PonyRace.UNICORN) .put(0x88caf0, PonyRace.PEGASUS) @@ -16,12 +15,12 @@ public class PonyData implements IPonyData { .put(0xd0cccf, PonyRace.ZEBRA) .put(0x282b29, PonyRace.CHANGELING) .build(); - private static final Map TAIL_COLORS = ImmutableBiMap. builder() + private static final Map TAIL_COLORS = ImmutableBiMap.builder() .put(0x425844, TailLengths.STUB) .put(0xd19fe4, TailLengths.QUARTER) .put(0x534b76, TailLengths.HALF) .put(0x8a6b7f, TailLengths.THREE_QUARTERS).build(); - private static final Map SIZE_COLORS = ImmutableBiMap. builder() + private static final Map SIZE_COLORS = ImmutableBiMap.builder() .put(0xffbe53, PonySize.FOAL) .put(0xce3254, PonySize.LARGE) .put(0x534b76, PonySize.TALL) diff --git a/src/main/java/com/minelittlepony/PonyDataSerialzier.java b/src/main/java/com/minelittlepony/PonyDataSerialzier.java index c48fe4da..4e3d4c4d 100644 --- a/src/main/java/com/minelittlepony/PonyDataSerialzier.java +++ b/src/main/java/com/minelittlepony/PonyDataSerialzier.java @@ -1,6 +1,5 @@ package com.minelittlepony; -import com.google.gson.Gson; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; diff --git a/src/main/java/com/minelittlepony/PonyLevel.java b/src/main/java/com/minelittlepony/PonyLevel.java index 6b9b8edb..cc23fb42 100644 --- a/src/main/java/com/minelittlepony/PonyLevel.java +++ b/src/main/java/com/minelittlepony/PonyLevel.java @@ -4,5 +4,5 @@ public enum PonyLevel { PONIES, HUMANS, - BOTH; + BOTH } diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 13057c2f..a064310d 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -1,27 +1,24 @@ package com.minelittlepony; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.JsonParseException; +import com.minelittlepony.model.PMAPI; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.compress.utils.IOUtils; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.util.Map; import java.util.UUID; - -import org.apache.commons.compress.utils.IOUtils; - -import com.google.common.base.Function; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.gson.Gson; -import com.google.gson.JsonParseException; -import com.minelittlepony.model.PMAPI; -import com.minelittlepony.util.MineLPLogger; - -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.resources.IResource; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.util.ResourceLocation; +import java.util.stream.Collectors; public class PonyManager implements IResourceManagerReloadListener { @@ -42,9 +39,9 @@ public class PonyManager implements IResourceManagerReloadListener { } public void initmodels() { - MineLPLogger.info("Initializing models..."); + MineLittlePony.logger.info("Initializing models..."); PMAPI.init(); - MineLPLogger.info("Done initializing models."); + MineLittlePony.logger.info("Done initializing models."); } private Pony getPonyFromResourceRegistry(ResourceLocation skinResourceLocation, AbstractClientPlayer player) { @@ -65,7 +62,7 @@ public class PonyManager implements IResourceManagerReloadListener { } public Pony getPonyFromResourceRegistry(ResourceLocation skinResourceLocation) { - return this.getPonyFromResourceRegistry(skinResourceLocation, (AbstractClientPlayer) null); + return this.getPonyFromResourceRegistry(skinResourceLocation, null); } public Pony getPonyFromResourceRegistry(AbstractClientPlayer player) { @@ -122,13 +119,13 @@ public class PonyManager implements IResourceManagerReloadListener { } this.backgroundPonyList.addAll(ponies.getPonies()); } catch (JsonParseException e) { - MineLPLogger.error(e, "Invalid bgponies.json in {}", res.getResourcePackName()); + MineLittlePony.logger.error("Invalid bgponies.json in " + res.getResourcePackName(), e); } } } catch (IOException e) { // this isn't the exception you're looking for. } - MineLPLogger.info("Detected %d background ponies installed.", getNumberOfPonies()); + MineLittlePony.logger.info("Detected %d background ponies installed.", getNumberOfPonies()); } private BackgroundPonies getBackgroundPonies(InputStream stream) { @@ -147,18 +144,22 @@ public class PonyManager implements IResourceManagerReloadListener { return backgroundPonyList.size(); } - private static class BackgroundPonies implements Function { + private static class BackgroundPonies { - public boolean override; + private boolean override; private List ponies; - @Override - public ResourceLocation apply(String input) { + private BackgroundPonies(List ponies, boolean override) { + this.ponies = ponies; + this.override = override; + } + + private ResourceLocation apply(String input) { return new ResourceLocation("minelittlepony", String.format("textures/entity/pony/%s.png", input)); } public List getPonies() { - return Lists.transform(ponies, this); + return this.ponies.stream().map(this::apply).collect(Collectors.toList()); } } } diff --git a/src/main/java/com/minelittlepony/PonyRace.java b/src/main/java/com/minelittlepony/PonyRace.java index cf2f9d22..ae0c9f5a 100644 --- a/src/main/java/com/minelittlepony/PonyRace.java +++ b/src/main/java/com/minelittlepony/PonyRace.java @@ -11,7 +11,7 @@ public enum PonyRace { private boolean wings; private boolean horn; - private PonyRace(boolean wings, boolean horn) { + PonyRace(boolean wings, boolean horn) { this.wings = wings; this.horn = horn; } diff --git a/src/main/java/com/minelittlepony/PonySkinModifier.java b/src/main/java/com/minelittlepony/PonySkinModifier.java index 70af9972..845208f5 100644 --- a/src/main/java/com/minelittlepony/PonySkinModifier.java +++ b/src/main/java/com/minelittlepony/PonySkinModifier.java @@ -1,11 +1,11 @@ package com.minelittlepony; +import com.voxelmodpack.hdskins.ISkinModifier; + import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; -import com.voxelmodpack.hdskins.ISkinModifier; - public class PonySkinModifier implements ISkinModifier { @Override diff --git a/src/main/java/com/minelittlepony/TailLengths.java b/src/main/java/com/minelittlepony/TailLengths.java index d85138ac..41542a14 100644 --- a/src/main/java/com/minelittlepony/TailLengths.java +++ b/src/main/java/com/minelittlepony/TailLengths.java @@ -10,10 +10,10 @@ public enum TailLengths { private int size; - private TailLengths(int size) { + TailLengths(int size) { this.size = size; } - + public int getSize() { return size; } diff --git a/src/main/java/com/minelittlepony/forge/MLPForge.java b/src/main/java/com/minelittlepony/forge/MLPForge.java index 63cacb65..89c6b7ac 100644 --- a/src/main/java/com/minelittlepony/forge/MLPForge.java +++ b/src/main/java/com/minelittlepony/forge/MLPForge.java @@ -1,7 +1,6 @@ package com.minelittlepony.forge; import com.minelittlepony.MineLittlePony; - import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; @@ -13,6 +12,7 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; clientSideOnly = true) public class MLPForge { + @SuppressWarnings("unused") @EventHandler public void init(FMLPostInitializationEvent init) { MLPCommonProxy.getInstance().setPonyArmors(new PonyArmors()); diff --git a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java b/src/main/java/com/minelittlepony/gui/PonySettingPanel.java index 2ef71df0..8c2ccf7d 100644 --- a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/gui/PonySettingPanel.java @@ -1,17 +1,16 @@ package com.minelittlepony.gui; -import java.io.IOException; - import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyConfig; import com.minelittlepony.PonyLevel; import com.mumfrey.liteloader.client.gui.GuiCheckbox; import com.mumfrey.liteloader.core.LiteLoader; - import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; +import java.io.IOException; + public class PonySettingPanel extends GuiScreen { private static final String _PREFIX = "minelp.options."; @@ -59,6 +58,7 @@ public class PonySettingPanel extends GuiScreen { config = MineLittlePony.getConfig(); } + @SuppressWarnings("UnusedAssignment") @Override public void initGui() { final int LEFT = width / 10 + 16; @@ -81,16 +81,16 @@ public class PonySettingPanel extends GuiScreen { this.buttonList.add(skeleton = new GuiCheckbox(SKELETONS_ID, RIGHT, row += 15, I18n.format(SKELETONS))); switch (config.getPonyLevel()) { - default: - case PONIES: - pony.checked = true; - break; - case HUMANS: - human.checked = true; - break; - case BOTH: - both.checked = true; - break; + default: + case PONIES: + pony.checked = true; + break; + case HUMANS: + human.checked = true; + break; + case BOTH: + both.checked = true; + break; } hd.checked = config.hd; sizes.checked = config.sizes; @@ -123,49 +123,49 @@ public class PonySettingPanel extends GuiScreen { ((GuiCheckbox) button).checked = checked; switch (button.id) { - case PONY_ID: - config.setPonyLevel(PonyLevel.PONIES); - ponies.checked = true; - humans.checked = false; - both.checked = false; - break; - case HUMAN_ID: - config.setPonyLevel(PonyLevel.HUMANS); - humans.checked = true; - ponies.checked = false; - both.checked = false; - break; - case BOTH_ID: - config.setPonyLevel(PonyLevel.BOTH); - both.checked = true; - ponies.checked = false; - humans.checked = false; - break; - case HD_ID: - config.hd = checked; - break; - case SIZES_ID: - config.sizes = checked; - break; - case SNUZZLES_ID: - config.snuzzles = checked; - break; - case SHOW_SCALE_ID: - config.showscale = checked; - break; + case PONY_ID: + config.setPonyLevel(PonyLevel.PONIES); + ponies.checked = true; + humans.checked = false; + both.checked = false; + break; + case HUMAN_ID: + config.setPonyLevel(PonyLevel.HUMANS); + humans.checked = true; + ponies.checked = false; + both.checked = false; + break; + case BOTH_ID: + config.setPonyLevel(PonyLevel.BOTH); + both.checked = true; + ponies.checked = false; + humans.checked = false; + break; + case HD_ID: + config.hd = checked; + break; + case SIZES_ID: + config.sizes = checked; + break; + case SNUZZLES_ID: + config.snuzzles = checked; + break; + case SHOW_SCALE_ID: + config.showscale = checked; + break; - case VILLAGERS_ID: - config.villagers = checked; - break; - case ZOMBIES_ID: - config.zombies=checked; - break; - case ZOMBIE_PIGMEN_ID: - config.pigzombies = checked; - break; - case SKELETONS_ID: - config.skeletons=checked; - break; + case VILLAGERS_ID: + config.villagers = checked; + break; + case ZOMBIES_ID: + config.zombies = checked; + break; + case ZOMBIE_PIGMEN_ID: + config.pigzombies = checked; + break; + case SKELETONS_ID: + config.skeletons = checked; + break; } } } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java index 2c7acd98..de4a59d4 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -1,7 +1,7 @@ package com.minelittlepony.hdskins.gui; +import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyManager; -import com.minelittlepony.util.MineLPLogger; import com.mojang.authlib.GameProfile; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.GuiSkins; @@ -23,13 +23,13 @@ public class GuiSkinsMineLP extends GuiSkins { @Override protected void onSetLocalSkin(BufferedImage skin) { - MineLPLogger.debug("Invalidating old local skin, checking updated local skin"); + MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); ponyManager.getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).checkSkin(skin); } @Override protected void onSetRemoteSkin() { - MineLPLogger.debug("Invalidating old remove skin, checking updated remote skin"); + MineLittlePony.logger.debug("Invalidating old remove skin, checking updated remote skin"); ponyManager.getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck(); } diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java index 97e9f852..151e23bf 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java @@ -1,16 +1,5 @@ package com.minelittlepony.mixin; -import static net.minecraft.client.renderer.GlStateManager.scale; - -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import com.minelittlepony.MineLittlePony; import com.minelittlepony.Pony; import com.minelittlepony.PonySize; @@ -24,7 +13,6 @@ import com.minelittlepony.renderer.layer.LayerPonyArmor; import com.minelittlepony.renderer.layer.LayerPonyCape; import com.minelittlepony.renderer.layer.LayerPonyElytra; import com.minelittlepony.renderer.layer.LayerPonySkull; - import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; @@ -34,6 +22,16 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.util.ResourceLocation; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.At.Shift; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static net.minecraft.client.renderer.GlStateManager.scale; @Mixin(RenderPlayer.class) public abstract class MixinRenderPlayer extends RenderLivingBase implements IRenderPony { @@ -53,7 +51,6 @@ public abstract class MixinRenderPlayer extends RenderLivingBase -9990.0F && !metadata.hasMagic()) { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } - for (int i = 0; i < this.leftWing.length; ++i) { - this.leftWing[i].rotateAngleY = bodySwingRotation * 0.2F; + for (ModelRenderer aLeftWing : this.leftWing) { + aLeftWing.rotateAngleY = bodySwingRotation * 0.2F; } - for (int i = 0; i < this.rightWing.length; ++i) { - this.rightWing[i].rotateAngleY = bodySwingRotation * 0.2F; + for (ModelRenderer aRightWing : this.rightWing) { + aRightWing.rotateAngleY = bodySwingRotation * 0.2F; } if (pony.isSneak && !pony.isFlying) { this.sneak(); @@ -118,11 +117,11 @@ public class PegasusWings implements IPonyPart, PonyModelConstants { float angle = ROTATE_90; - for (int i = 0; i < this.leftWing.length; i++) { - this.leftWing[i].rotateAngleX = angle; + for (ModelRenderer aLeftWing : this.leftWing) { + aLeftWing.rotateAngleX = angle; } - for (int i = 0; i < this.rightWing.length; i++) { - this.rightWing[i].rotateAngleX = angle; + for (ModelRenderer aRightWing : this.rightWing) { + aRightWing.rotateAngleX = angle; } // Special this.leftWingExt[1].rotateAngleX -= 0.85F; @@ -143,30 +142,30 @@ public class PegasusWings implements IPonyPart, PonyModelConstants { if (data.getRace() != null && data.getRace().hasWings()) { if (!pony.isFlying && !pony.isSneak) { - for (int k1 = 0; k1 < this.leftWing.length; ++k1) { - this.leftWing[k1].render(scale); + for (ModelRenderer aLeftWing : this.leftWing) { + aLeftWing.render(scale); } - for (int k1 = 0; k1 < this.rightWing.length; ++k1) { - this.rightWing[k1].render(scale); + for (ModelRenderer aRightWing : this.rightWing) { + aRightWing.render(scale); } } else { - for (int k1 = 0; k1 < this.leftWingExt.length; ++k1) { - this.leftWingExt[k1].render(scale); + for (ModelRenderer aLeftWingExt : this.leftWingExt) { + aLeftWingExt.render(scale); } - for (int i = 0; i < this.rightWingExt.length; ++i) { - this.rightWingExt[i].render(scale); + for (ModelRenderer aRightWingExt : this.rightWingExt) { + aRightWingExt.render(scale); } } } } private void sneak() { - for (int i = 0; i < this.leftWingExt.length; ++i) { - this.leftWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - this.leftWingExt[i].rotateAngleZ = LEFT_WING_ROTATE_ANGLE_Z_SNEAK; + for (ModelRenderer aLeftWingExt : this.leftWingExt) { + aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; + aLeftWingExt.rotateAngleZ = LEFT_WING_ROTATE_ANGLE_Z_SNEAK; } for (int i = 0; i < this.leftWingExt.length; ++i) { @@ -179,14 +178,14 @@ public class PegasusWings implements IPonyPart, PonyModelConstants { if (pony.isFlying) { float WingRotateAngleZ = MathHelper.sin(tick * 0.536F) * 1.0F; - for (int i = 0; i < this.leftWingExt.length; ++i) { - this.leftWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - this.leftWingExt[i].rotateAngleZ = -WingRotateAngleZ - ROTATE_270 - 0.4F; + for (ModelRenderer aLeftWingExt : this.leftWingExt) { + aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; + aLeftWingExt.rotateAngleZ = -WingRotateAngleZ - ROTATE_270 - 0.4F; } - for (int i = 0; i < this.rightWingExt.length; ++i) { - this.rightWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - this.rightWingExt[i].rotateAngleZ = WingRotateAngleZ + ROTATE_270 + 0.4F; + for (ModelRenderer aRightWingExt : this.rightWingExt) { + aRightWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; + aRightWingExt.rotateAngleZ = WingRotateAngleZ + ROTATE_270 + 0.4F; } } } diff --git a/src/main/java/com/minelittlepony/model/part/UnicornHorn.java b/src/main/java/com/minelittlepony/model/part/UnicornHorn.java index 3ff1ac52..3e939b86 100644 --- a/src/main/java/com/minelittlepony/model/part/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/part/UnicornHorn.java @@ -1,16 +1,14 @@ package com.minelittlepony.model.part; -import static net.minecraft.client.renderer.GlStateManager.*; - -import org.lwjgl.opengl.GL11; - import com.minelittlepony.PonyData; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.renderer.HornGlowRenderer; - import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.client.model.ModelRenderer; +import org.lwjgl.opengl.GL11; + +import static net.minecraft.client.renderer.GlStateManager.*; public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants { @@ -54,7 +52,7 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants blendFunc(GL11.GL_SRC_ALPHA, 1); this.horn.postRender(scale); - + color(red, green, blue, 0.4F); this.hornglow[0].render(scale); color(red, green, blue, 0.2F); diff --git a/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java b/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java index 61c255e9..4fbdde44 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java @@ -124,29 +124,29 @@ public class ModelBreezie extends ModelBiped { this.bipedRightArm.rotateAngleZ = 0F; switch (this.leftArmPose) { - case EMPTY: - this.bipedLeftArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedLeftArm.rotateAngleY = 0.5235988F; - break; - case ITEM: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - this.bipedLeftArm.rotateAngleY = 0.0F; + case EMPTY: + this.bipedLeftArm.rotateAngleY = 0.0F; + break; + case BLOCK: + this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; + this.bipedLeftArm.rotateAngleY = 0.5235988F; + break; + case ITEM: + this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); + this.bipedLeftArm.rotateAngleY = 0.0F; } switch (this.rightArmPose) { - case EMPTY: - this.bipedRightArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedRightArm.rotateAngleY = -0.5235988F; - break; - case ITEM: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - this.bipedRightArm.rotateAngleY = 0.0F; + case EMPTY: + this.bipedRightArm.rotateAngleY = 0.0F; + break; + case BLOCK: + this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; + this.bipedRightArm.rotateAngleY = -0.5235988F; + break; + case ITEM: + this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); + this.bipedRightArm.rotateAngleY = 0.0F; } if (this.swingProgress > 0.0F) { @@ -165,6 +165,7 @@ public class ModelBreezie extends ModelBiped { this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; + //noinspection SuspiciousNameCombination this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; f1 = 1.0F - this.swingProgress; f1 = f1 * f1; diff --git a/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java index bee76080..57447e72 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelEvokerPony.java @@ -26,7 +26,7 @@ public class ModelEvokerPony extends ModelIllagerPony { super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); EntityEvoker evoker = (EntityEvoker) entityIn; - if (evoker.isCastingSpell()) { + if (isUnicorn && evoker.isCastingSpell()) { GL11.glPushAttrib(24577); disableTexture2D(); disableLighting(); diff --git a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java index 5fb29243..3a18d313 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java @@ -2,13 +2,8 @@ package com.minelittlepony.model.pony; import com.minelittlepony.model.AbstractPonyModel; -import net.minecraft.client.model.ModelRenderer; - public class ModelHumanPlayer extends AbstractPonyModel { - public ModelRenderer bipedEars; - public ModelRenderer cloak; - public ModelHumanPlayer(boolean smallArms) { super(smallArms); } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java index 0b745d4f..6661dfe8 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java @@ -87,7 +87,6 @@ public abstract class ModelIllagerPony extends ModelBase { tail.addChild(tailStub); - } @Override diff --git a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java index 2423bca5..88c35a46 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java @@ -1,7 +1,5 @@ package com.minelittlepony.model.pony; -import static net.minecraft.client.renderer.GlStateManager.*; - import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.PonyModelConstants; @@ -10,7 +8,6 @@ import com.minelittlepony.model.part.PonyEars; import com.minelittlepony.model.part.PonySnout; import com.minelittlepony.model.part.UnicornHorn; import com.minelittlepony.renderer.PlaneRenderer; - import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; @@ -18,6 +15,9 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; +import static net.minecraft.client.renderer.GlStateManager.popMatrix; +import static net.minecraft.client.renderer.GlStateManager.pushMatrix; + public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConstants { private final boolean smallArms; @@ -103,10 +103,10 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedLeftArm.rotateAngleZ = (float) (Math.PI * -0.06); this.bipedRightArm.rotateAngleZ = (float) (Math.PI * 0.06); - for (int i = 0; i < Tail.length; ++i) { - this.Tail[i].rotationPointZ = 13; - this.Tail[i].rotationPointY = 3; - this.Tail[i].rotateAngleX = (float) (Math.PI * 0.2); + for (PlaneRenderer aTail : Tail) { + aTail.rotationPointZ = 13; + aTail.rotationPointY = 3; + aTail.rotateAngleX = (float) (Math.PI * 0.2); } } else { @@ -114,7 +114,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - this.swingArms(entity, tick); + this.swingArms(tick); this.setHead(0.0F, 0.0F, 0.0F); for (k1 = 0; k1 < tailstop; ++k1) { @@ -289,6 +289,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; + //noinspection SuspiciousNameCombination this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; this.bipedRightArm.rotationPointY = 8.0F; @@ -332,39 +333,39 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst boolean bothHoovesAreOccupied = this.leftArmPose == ArmPose.ITEM && this.rightArmPose == ArmPose.ITEM; switch (this.leftArmPose) { - case EMPTY: - this.bipedLeftArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedLeftArm.rotateAngleY = (float) (Math.PI / 6); - break; - case ITEM: - float swag = 1f; - if (!isFlying && bothHoovesAreOccupied) { - swag = (float) (1d - Math.pow(swing, 2d)); - } - float rotationMultiplier = 0.5f + 0.5f * (1f - swag); - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10F) * swag; - this.bipedLeftArm.rotateAngleY = 0.0F; + case EMPTY: + this.bipedLeftArm.rotateAngleY = 0.0F; + break; + case BLOCK: + this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; + this.bipedLeftArm.rotateAngleY = (float) (Math.PI / 6); + break; + case ITEM: + float swag = 1f; + if (!isFlying && bothHoovesAreOccupied) { + swag = (float) (1d - Math.pow(swing, 2d)); + } + float rotationMultiplier = 0.5f + 0.5f * (1f - swag); + this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10F) * swag; + this.bipedLeftArm.rotateAngleY = 0.0F; } switch (this.rightArmPose) { - case EMPTY: - this.bipedRightArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedRightArm.rotateAngleY = (float) (-Math.PI / 6); - break; - case ITEM: - float swag = 1f; - if (!isFlying && bothHoovesAreOccupied) { - swag = (float) (1d - Math.pow(swing, 2d)); - } - float rotationMultiplier = 0.5f + 0.5f * (1f - swag); - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10F) * swag; - this.bipedRightArm.rotateAngleY = 0.0F; + case EMPTY: + this.bipedRightArm.rotateAngleY = 0.0F; + break; + case BLOCK: + this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; + this.bipedRightArm.rotateAngleY = (float) (-Math.PI / 6); + break; + case ITEM: + float swag = 1f; + if (!isFlying && bothHoovesAreOccupied) { + swag = (float) (1d - Math.pow(swing, 2d)); + } + float rotationMultiplier = 0.5f + 0.5f * (1f - swag); + this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10F) * swag; + this.bipedRightArm.rotateAngleY = 0.0F; } } else if (this.metadata.hasMagic()) { @@ -411,7 +412,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } - protected void swingArms(Entity entity, float tick) { + protected void swingArms(float tick) { if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) { float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; @@ -461,10 +462,10 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { - for (int k3 = 0; k3 < this.BodypieceNeck.length; ++k3) { - this.BodypieceNeck[k3].rotateAngleX = NECK_ROT_X + rotateAngleX; - this.BodypieceNeck[k3].rotationPointY = rotationPointY; - this.BodypieceNeck[k3].rotationPointZ = rotationPointZ; + for (PlaneRenderer aBodypieceNeck : this.BodypieceNeck) { + aBodypieceNeck.rotateAngleX = NECK_ROT_X + rotateAngleX; + aBodypieceNeck.rotationPointY = rotationPointY; + aBodypieceNeck.rotationPointZ = rotationPointZ; } } @@ -564,7 +565,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.Bodypiece[13].rotateAngleX += 0.5F; } - protected void fixSpecialRotationPoints(float move) {} + protected void fixSpecialRotationPoints(float move) { + } @Override public void render() { @@ -608,8 +610,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst if (this.textureHeight == 64) { this.bipedBodyWear.render(this.scale); } - for (int k1 = 0; k1 < this.Bodypiece.length; ++k1) { - this.Bodypiece[k1].render(this.scale); + for (PlaneRenderer aBodypiece : this.Bodypiece) { + aBodypiece.render(this.scale); } } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java index 92a7a572..46341e18 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java @@ -1,11 +1,11 @@ package com.minelittlepony.model.pony; -import static net.minecraft.client.renderer.GlStateManager.*; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.MathHelper; +import static net.minecraft.client.renderer.GlStateManager.*; + public class ModelSkeletonPony extends ModelPlayerPony { public ModelSkeletonPony() { diff --git a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java index 33861dd1..12f84ebe 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java @@ -1,7 +1,6 @@ package com.minelittlepony.model.pony; import com.minelittlepony.renderer.PlaneRenderer; - import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; @@ -24,8 +23,8 @@ public class ModelVillagerPony extends ModelPlayerPony { if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } - for (int i = 0; i < this.VillagerBagPiece.length; ++i) { - this.VillagerBagPiece[i].rotateAngleY = bodySwingRotation * 0.2F; + for (PlaneRenderer aVillagerBagPiece : this.VillagerBagPiece) { + aVillagerBagPiece.rotateAngleY = bodySwingRotation * 0.2F; } this.VillagerBagPiece[4].rotateAngleY += 4.712389F; @@ -42,8 +41,8 @@ public class ModelVillagerPony extends ModelPlayerPony { this.bipedBody.postRender(scale); if (profession < 2) { - for (int i = 0; i < this.VillagerBagPiece.length; ++i) { - this.VillagerBagPiece[i].render(this.scale); + for (PlaneRenderer aVillagerBagPiece : this.VillagerBagPiece) { + aVillagerBagPiece.render(this.scale); } } else if (profession == 2) { this.VillagerTrinket.render(this.scale); diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java index c81e231f..eeb80ae9 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java @@ -1,7 +1,6 @@ package com.minelittlepony.model.pony.armor; import com.minelittlepony.model.pony.ModelPlayerPony; - import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @@ -72,7 +71,7 @@ public class ModelPonyArmor extends ModelPlayerPony { this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - this.swingArms(entity, tick); + this.swingArms(tick); this.setHead(0.0F, 0.0F, 0.0F); } @@ -120,19 +119,6 @@ public class ModelPonyArmor extends ModelPlayerPony { this.extBody.rotationPointZ = rotationPointZ; } - protected void ridingPony() { - this.setHead(this.bipedHead.rotationPointX + 0.0F, this.bipedHead.rotationPointY + RIDING_SHIFT_Y, this.bipedHead.rotationPointZ + RIDING_SHIFT_Z); - shiftRotationPoint(this.bipedBody, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.Bodypiece, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.extBody, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.bipedLeftArm, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.bipedRightArm, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.bipedLeftLeg, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.bipedRightLeg, 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.extLegs[0], 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - shiftRotationPoint(this.extLegs[1], 0.0F, RIDING_SHIFT_Y, RIDING_SHIFT_Z); - } - @Override protected void renderHead() { this.bipedHead.render(this.scale); @@ -142,7 +128,8 @@ public class ModelPonyArmor extends ModelPlayerPony { } @Override - protected void renderNeck() {} + protected void renderNeck() { + } @Override protected void renderBody() { @@ -152,7 +139,8 @@ public class ModelPonyArmor extends ModelPlayerPony { } @Override - protected void renderTail() {} + protected void renderTail() { + } @Override protected void renderLegs() { @@ -297,7 +285,8 @@ public class ModelPonyArmor extends ModelPlayerPony { } @Override - protected void setModelVisibilities(AbstractClientPlayer clientPlayer) {} + protected void setModelVisibilities(AbstractClientPlayer clientPlayer) { + } @Override public void setInvisible(boolean invisible) { diff --git a/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java b/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java index bb4e7385..363faf85 100644 --- a/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java @@ -1,7 +1,6 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.ModelHornGlow; - import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.TextureOffset; diff --git a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java b/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java index 6de768bc..101358ea 100644 --- a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java @@ -2,10 +2,10 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.ModelPlane; import com.minelittlepony.model.ModelPlane.Face; - import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; +@SuppressWarnings("unused") public class PlaneRenderer extends ModelRenderer { public boolean mirrory; @@ -14,9 +14,9 @@ public class PlaneRenderer extends ModelRenderer { private int textureOffsetX; private int textureOffsetY; - public PlaneRenderer(ModelBase model, String boxNameIn) { - super(model, boxNameIn); - } +// public PlaneRenderer(ModelBase model, String boxNameIn) { +// super(model, boxNameIn); +// } public PlaneRenderer(ModelBase model) { super(model); @@ -61,4 +61,4 @@ public class PlaneRenderer extends ModelRenderer { public void addBackPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.SOUTH); } -} \ No newline at end of file +} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java index 924a7780..edc09a53 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java @@ -34,8 +34,10 @@ public class RenderPonyEvoker extends RenderLiving { IResource resource = resources.getResource(EVOKER); if (resource.hasMetadata()) { PonyData meta = resource.getMetadata(PonyDataSerialzier.NAME); - model.isUnicorn = meta.hasMagic(); - model.glowColor = meta.getGlowColor(); + if (meta != null) { + model.isUnicorn = meta.hasMagic(); + model.glowColor = meta.getGlowColor(); + } } } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java index 3557123c..b98e1da0 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java @@ -5,13 +5,11 @@ import com.minelittlepony.PonyGender; import com.minelittlepony.PonyRace; import com.minelittlepony.TailLengths; import com.minelittlepony.ducks.IRenderPony; -import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; import com.minelittlepony.renderer.layer.LayerPonyArmor; import com.minelittlepony.renderer.layer.LayerPonySkull; import com.voxelmodpack.hdskins.HDSkinManager; - import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLiving; @@ -19,12 +17,10 @@ import net.minecraft.util.ResourceLocation; public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { - protected AbstractPonyModel mobModel; protected PlayerModel playerModel; public RenderPonyMob(RenderManager renderManager, PlayerModel playerModel) { - super(renderManager, playerModel.getModel(), playerModel.getShadowsize()); - this.mobModel = playerModel.getModel(); + super(renderManager, playerModel.getModel(), 0.5F); this.playerModel = playerModel; this.addLayer(new LayerPonyArmor(this)); @@ -35,7 +31,7 @@ public abstract class RenderPonyMob extends RenderLiving @Override public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, - float partialTicks) { + float partialTicks) { double yOrigin = yPosition; if (entity.isSneaking()) { yOrigin -= 0.125D; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java b/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java index bbe6bb8f..2838c393 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java @@ -1,7 +1,6 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.PMAPI; - import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java index 117821ca..c7945d9d 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java @@ -1,14 +1,11 @@ package com.minelittlepony.renderer; -import java.util.Random; - import com.minelittlepony.PonyGender; import com.minelittlepony.PonyRace; import com.minelittlepony.PonySize; import com.minelittlepony.TailLengths; import com.minelittlepony.model.PMAPI; import com.minelittlepony.renderer.layer.LayerPonyStrayOverlay; - import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; @@ -17,6 +14,8 @@ import net.minecraft.entity.monster.EntityStray; import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.util.ResourceLocation; +import java.util.Random; + public class RenderPonySkeleton extends RenderPonyMob { private static final ResourceLocation SKELETON = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_pony.png"); @@ -41,15 +40,15 @@ public class RenderPonySkeleton extends Rende Random rand = new Random(skeleton.getUniqueID().hashCode()); this.playerModel.getModel().metadata.setGender(rand.nextBoolean() ? PonyGender.MARE : PonyGender.STALLION); switch (rand.nextInt(4)) { - case 0: - case 1: - this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN); - break; - case 2: - this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); - break; - case 3: - this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS); + case 0: + case 1: + this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN); + break; + case 2: + this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); + break; + case 3: + this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS); } PonySize[] sizes = PonySize.values(); PonySize size = sizes[rand.nextInt(sizes.length)]; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVex.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVex.java index 1fb805d7..a3126bb3 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVex.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVex.java @@ -1,7 +1,6 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.pony.ModelBreezie; - import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.client.renderer.entity.RenderManager; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java index da5b34be..9d285b92 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java @@ -4,7 +4,6 @@ import com.minelittlepony.MineLittlePony; import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.pony.ModelVillagerPony; import com.minelittlepony.util.Villagers; - import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.passive.EntityVillager; @@ -46,19 +45,19 @@ public class RenderPonyVillager extends RenderPonyMob { private ResourceLocation getTextureForVillager(EntityVillager villager) { switch (villager.getProfession()) { - case Villagers.FARMER: - return FARMER; - case Villagers.LIBRARIAN: - return LIBRARIAN; - case Villagers.PRIEST: - return PRIEST; - case Villagers.BLACKSMITH: - return SMITH; - case Villagers.BUTCHER: - return BUTCHER; - case Villagers.GENERIC: - default: - return GENERIC; + case Villagers.FARMER: + return FARMER; + case Villagers.LIBRARIAN: + return LIBRARIAN; + case Villagers.PRIEST: + return PRIEST; + case Villagers.BLACKSMITH: + return SMITH; + case Villagers.BUTCHER: + return BUTCHER; + case Villagers.GENERIC: + default: + return GENERIC; } } } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java index 47095f51..9f996fa7 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java @@ -1,23 +1,16 @@ package com.minelittlepony.renderer; -import com.minelittlepony.PonyData; -import com.minelittlepony.PonyDataSerialzier; import com.minelittlepony.model.pony.ModelIllagerPony; import com.minelittlepony.model.pony.ModelVindicatorPony; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.IResource; -import net.minecraft.client.resources.IResourceManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityVindicator; import net.minecraft.util.EnumHandSide; import net.minecraft.util.ResourceLocation; -import java.io.IOException; - public class RenderPonyVindicator extends RenderLiving { private static final ResourceLocation VINDICATOR = new ResourceLocation("minelittlepony", "textures/entity/illager/vindicator_pony.png"); diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java index 735e1578..af2ef418 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java @@ -1,19 +1,18 @@ package com.minelittlepony.renderer; -import java.util.Random; - import com.minelittlepony.PonyGender; import com.minelittlepony.PonyRace; import com.minelittlepony.PonySize; import com.minelittlepony.TailLengths; import com.minelittlepony.model.PMAPI; - import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.util.ResourceLocation; +import java.util.Random; + public class RenderPonyZombie extends RenderPonyMob { private static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png"); @@ -33,16 +32,16 @@ public class RenderPonyZombie extends RenderPonyMob // races switch (rand.nextInt(2) + 2) { - case 0: - case 1: - this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); - break; - case 2: - this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS); - break; - case 3: - this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN); - break; + case 0: + case 1: + this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); + break; + case 2: + this.playerModel.getModel().metadata.setRace(PonyRace.PEGASUS); + break; + case 3: + this.playerModel.getModel().metadata.setRace(PonyRace.UNICORN); + break; } // Let's play the lottery! if (rand.nextInt(10000) == 0) { diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java index 74af49b6..47c8665a 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java @@ -2,7 +2,6 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.PMAPI; import com.minelittlepony.util.Villagers; - import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.util.ResourceLocation; @@ -27,19 +26,19 @@ public class RenderPonyZombieVillager extends RenderPonyMob { Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); if (isUnicorn) { - PonyData metadata = ((AbstractPonyModel)this.livingPonyEntity.getMainModel()).metadata; + PonyData metadata = ((AbstractPonyModel) this.livingPonyEntity.getMainModel()).metadata; this.renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); } GlStateManager.popMatrix(); diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java index c3a699a6..8cb186ed 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java @@ -1,8 +1,5 @@ package com.minelittlepony.renderer.layer; -import java.io.IOException; -import java.util.Map; - import com.google.common.collect.Maps; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IRenderPony; @@ -11,7 +8,6 @@ import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelHumanPlayer; import com.minelittlepony.model.pony.armor.ModelPonyArmor; - import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -26,6 +22,9 @@ import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import java.io.IOException; +import java.util.Map; + public class LayerPonyArmor implements LayerRenderer { private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png"); @@ -57,7 +56,7 @@ public class LayerPonyArmor implements LayerRenderer { } private void renderArmor(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, - EntityEquipmentSlot armorSlot) { + EntityEquipmentSlot armorSlot) { ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (itemstack != null && itemstack.getItem() instanceof ItemArmor) { @@ -117,36 +116,36 @@ public class LayerPonyArmor implements LayerRenderer { model.setInvisible(false); switch (slot) { - // feet - case FEET: - model.bipedRightArm.showModel = true; - model.bipedLeftArm.showModel = true; - model.bipedRightLeg.showModel = true; - model.bipedLeftLeg.showModel = true; - break; - // legs - case LEGS: - model.bipedRightLeg.showModel = true; - model.bipedLeftLeg.showModel = true; - model.bipedRightArm.showModel = true; - model.bipedLeftArm.showModel = true; - model.extBody.showModel = true; - break; - // chest - case CHEST: - model.extBody.showModel = true; - break; - // head - case HEAD: - model.bipedHead.showModel = true; - for (ModelRenderer m : model.extHead) { - m.showModel = true; - } + // feet + case FEET: + model.bipedRightArm.showModel = true; + model.bipedLeftArm.showModel = true; + model.bipedRightLeg.showModel = true; + model.bipedLeftLeg.showModel = true; + break; + // legs + case LEGS: + model.bipedRightLeg.showModel = true; + model.bipedLeftLeg.showModel = true; + model.bipedRightArm.showModel = true; + model.bipedLeftArm.showModel = true; + model.extBody.showModel = true; + break; + // chest + case CHEST: + model.extBody.showModel = true; + break; + // head + case HEAD: + model.bipedHead.showModel = true; + for (ModelRenderer m : model.extHead) { + m.showModel = true; + } } } private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_, float p_177183_4_, float p_177183_5_, - float p_177183_6_, float p_177183_7_, float p_177183_8_, float p_177183_9_) { + float p_177183_6_, float p_177183_7_, float p_177183_8_, float p_177183_9_) { float f7 = entitylivingbaseIn.ticksExisted + p_177183_5_; this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); @@ -185,12 +184,7 @@ public class LayerPonyArmor implements LayerRenderer { } private static ResourceLocation getHumanResource(String s1) { - ResourceLocation human = HUMAN_ARMORS.get(s1); - if (human == null) { - human = new ResourceLocation(s1); - HUMAN_ARMORS.put(s1, human); - } - return human; + return HUMAN_ARMORS.computeIfAbsent(s1, k -> new ResourceLocation(s1)); } private static ResourceLocation getPonyResource(ResourceLocation human) { diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java index da6d7f70..9b132480 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java @@ -1,12 +1,9 @@ package com.minelittlepony.renderer.layer; -import static net.minecraft.client.renderer.GlStateManager.*; - import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelHumanPlayer; - import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderPlayer; @@ -15,6 +12,8 @@ import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.util.math.MathHelper; +import static net.minecraft.client.renderer.GlStateManager.*; + public class LayerPonyCape implements LayerRenderer { private RenderLivingBase renderer; @@ -27,7 +26,7 @@ public class LayerPonyCape implements LayerRenderer { @Override public void doRenderLayer(AbstractClientPlayer clientPlayer, float p2, float p3, float ticks, float p5, float p6, - float p7, float scale) { + float p7, float scale) { PlayerModel model = ((IRenderPony) renderer).getPony(); if (model.getModel() instanceof ModelHumanPlayer) { cape.doRenderLayer(clientPlayer, p2, p3, ticks, p5, p6, p7, scale); diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java index fb1376fa..6f4c5b04 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java @@ -5,7 +5,6 @@ import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ModelPonyElytra; import com.minelittlepony.model.pony.ModelHumanPlayer; - import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderPlayer; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java index ee73ee49..1dc03b9e 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonySkull.java @@ -1,14 +1,11 @@ package com.minelittlepony.renderer.layer; -import static net.minecraft.client.renderer.GlStateManager.*; - import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelPlayerPony; import com.mojang.authlib.GameProfile; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.entity.RenderLivingBase; @@ -27,6 +24,8 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.EnumFacing; +import static net.minecraft.client.renderer.GlStateManager.*; + public class LayerPonySkull implements LayerRenderer { private RenderLivingBase renderer; @@ -37,7 +36,7 @@ public class LayerPonySkull implements LayerRenderer { @Override public void doRenderLayer(EntityLivingBase entity, float limbSwing, float p_177141_3_, - float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { + float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (itemstack != null && itemstack.getItem() != null) { AbstractPonyModel model = getModel().getModel(); @@ -86,6 +85,7 @@ public class LayerPonySkull implements LayerRenderer { if (itemstack.hasTagCompound()) { NBTTagCompound nbt = itemstack.getTagCompound(); + assert nbt != null; if (nbt.hasKey("SkullOwner", 10)) { profile = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("SkullOwner")); } else if (nbt.hasKey("SkullOwner", 8)) { diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java index c781a20f..afc39a40 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java @@ -1,7 +1,6 @@ package com.minelittlepony.renderer.layer; import com.minelittlepony.model.pony.ModelSkeletonPony; - import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.entity.monster.EntityStray; diff --git a/src/main/java/com/minelittlepony/util/MineLPLogger.java b/src/main/java/com/minelittlepony/util/MineLPLogger.java deleted file mode 100644 index e5cdc6ed..00000000 --- a/src/main/java/com/minelittlepony/util/MineLPLogger.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.minelittlepony.util; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -public class MineLPLogger { - private static Logger logger = LogManager.getLogger("MineLittlePony"); - - public static Logger getLogger() { - return logger; - } - - private static void log(Level level, String format, Object... data) { - logger.log(level, "MineLittlePony> " + String.format(format, data)); - } - - private static void log(Level level, Throwable t, String format, Object... data) { - logger.log(level, "MineLittlePony> " + String.format(format, data), t); - } - - public static void info(String message) { - log(Level.INFO, message, new Object[0]); - } - - public static void info(String message, Object... data) { - log(Level.INFO, message, data); - } - - public static void debug(String message) { - if(LiteLoaderLogger.DEBUG) { - log(Level.INFO, message, new Object[0]); - } - - } - - public static void debug(String message, Object... data) { - if(LiteLoaderLogger.DEBUG) { - log(Level.INFO, message, data); - } - - } - - public static void debug(Throwable t, String message, Object... data) { - if(LiteLoaderLogger.DEBUG) { - log(Level.INFO, message, new Object[]{data, t}); - } - - } - - public static void warn(String message) { - log(Level.WARN, message, new Object[0]); - } - - public static void warn(String message, Object... data) { - log(Level.WARN, message, data); - } - - public static void warn(Throwable t, String message, Object... data) { - log(Level.WARN, t, message, data); - } - - public static void error(String message) { - log(Level.ERROR, message, new Object[0]); - } - - public static void error(String message, Object... data) { - log(Level.ERROR, message, data); - } - - public static void error(Throwable t, String message, Object... data) { - log(Level.ERROR, t, message, data); - } -} diff --git a/src/main/java/com/minelittlepony/util/PonyFields.java b/src/main/java/com/minelittlepony/util/PonyFields.java index a470854b..602aaafd 100644 --- a/src/main/java/com/minelittlepony/util/PonyFields.java +++ b/src/main/java/com/minelittlepony/util/PonyFields.java @@ -1,12 +1,11 @@ package com.minelittlepony.util; -import java.awt.image.BufferedImage; - import com.mumfrey.liteloader.core.runtime.Obf; import com.mumfrey.liteloader.util.PrivateFields; - import net.minecraft.client.renderer.ThreadDownloadImageData; +import java.awt.image.BufferedImage; + public class PonyFields extends PrivateFields { public static final PrivateFields downloadedImage = field(ThreadDownloadImageData.class, PonyObf.downloadedImage); @@ -16,7 +15,7 @@ public class PonyFields extends PrivateFields { } private static PrivateFields field(Class

c, Obf o) { - return new PonyFields(c, o); + return new PonyFields<>(c, o); } private static class PonyObf extends Obf { diff --git a/src/main/resources/assets/minelittlepony/textures/entity/pony/bgponies.json b/src/main/resources/assets/minelittlepony/textures/entity/pony/bgponies.json index 01a85c55..060de980 100644 --- a/src/main/resources/assets/minelittlepony/textures/entity/pony/bgponies.json +++ b/src/main/resources/assets/minelittlepony/textures/entity/pony/bgponies.json @@ -1,8 +1,8 @@ { - // Removes all of the previous resourcepack's ponies - "override": false, - // A list of all the pony names without the extension - // e.g. textures/entity/pony/bpony_12.png + // Removes all of the previous resourcepack's ponies + "override": false, + // A list of all the pony names without the extension + // e.g. textures/entity/pony/bpony_12.png "ponies": [ "bpony_0", "bpony_1", diff --git a/src/main/resources/litemod.json b/src/main/resources/litemod.json index 7283764f..eb34da4f 100644 --- a/src/main/resources/litemod.json +++ b/src/main/resources/litemod.json @@ -1,11 +1,11 @@ { - "name": "minelittlepony", - "mcversion": "${mcversion}", - "version": "${version}", - "revision": "${revision}", - "description": "Mine Little Pony turns players and mobs into ponies", - "mixinConfigs": [ - "mixin.minelp.json", - "mixin.hdskins.json" - ] + "name": "minelittlepony", + "mcversion": "${mcversion}", + "version": "${version}", + "revision": "${revision}", + "description": "Mine Little Pony turns players and mobs into ponies", + "mixinConfigs": [ + "mixin.minelp.json", + "mixin.hdskins.json" + ] } diff --git a/src/main/resources/mixin.minelp.json b/src/main/resources/mixin.minelp.json index 7f49417b..97e801da 100644 --- a/src/main/resources/mixin.minelp.json +++ b/src/main/resources/mixin.minelp.json @@ -1,10 +1,10 @@ { - "required": true, - "minVersion": "0.4.10", - "package": "com.minelittlepony.mixin", - "refmap": "mixin.minelp.refmap.json", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "MixinRenderPlayer" - ] + "required": true, + "minVersion": "0.6", + "package": "com.minelittlepony.mixin", + "refmap": "mixin.minelp.refmap.json", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinRenderPlayer" + ] }