Run code cleanup

This commit is contained in:
Sollace 2018-08-01 12:00:19 +02:00
parent 4f6c14ce9f
commit e6f5d3caa6
62 changed files with 449 additions and 358 deletions

View file

@ -10,7 +10,7 @@ public class DynamicTextureImage extends DynamicTexture {
public DynamicTextureImage(BufferedImage bufferedImage) { public DynamicTextureImage(BufferedImage bufferedImage) {
super(bufferedImage); super(bufferedImage);
this.image = bufferedImage; image = bufferedImage;
} }
public BufferedImage getImage() { public BufferedImage getImage() {
@ -20,7 +20,7 @@ public class DynamicTextureImage extends DynamicTexture {
@Override @Override
public void deleteGlTexture() { public void deleteGlTexture() {
super.deleteGlTexture(); super.deleteGlTexture();
this.image = null; image = null;
} }
} }

View file

@ -22,7 +22,9 @@ public final class Later extends Thread {
@Override @Override
public void run() { public void run() {
try { try {
if (delay > 0) sleep(delay); if (delay > 0) {
sleep(delay);
}
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
super.run(); super.run();
} }

View file

@ -19,13 +19,13 @@ public class PreviewTexture extends ThreadDownloadImageData {
} }
public boolean isTextureUploaded() { public boolean isTextureUploaded() {
return uploaded && this.getGlTextureId() > -1; return uploaded && getGlTextureId() > -1;
} }
@Override @Override
public void deleteGlTexture() { public void deleteGlTexture() {
super.deleteGlTexture(); super.deleteGlTexture();
this.uploaded = true; uploaded = true;
} }
public boolean hasModel() { public boolean hasModel() {

View file

@ -34,19 +34,19 @@ public class PreviewTextureManager {
IImageBuffer buffer = new ImageBufferDownloadHD(); IImageBuffer buffer = new ImageBufferDownloadHD();
PreviewTexture skinTexture = new PreviewTexture(texture.getMetadata("model"), texture.getUrl(), def, PreviewTexture skinTexture = new PreviewTexture(texture.getMetadata("model"), texture.getUrl(), def,
type == MinecraftProfileTexture.Type.SKIN ? new IImageBuffer() { type == MinecraftProfileTexture.Type.SKIN ? new IImageBuffer() {
@Override @Override
@Nullable @Nullable
public BufferedImage parseUserSkin(BufferedImage image) { public BufferedImage parseUserSkin(BufferedImage image) {
return buffer.parseUserSkin(image); return buffer.parseUserSkin(image);
} }
@Override @Override
public void skinAvailable() { public void skinAvailable() {
if (callback != null) { if (callback != null) {
callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap())); callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap()));
} }
} }
} : null); } : null);
Minecraft.getMinecraft().getTextureManager().loadTexture(location, skinTexture); Minecraft.getMinecraft().getTextureManager().loadTexture(location, skinTexture);
return skinTexture; return skinTexture;

View file

@ -47,35 +47,36 @@ public class ThreadDownloadImageETag extends SimpleTexture {
public ThreadDownloadImageETag(@Nonnull File cacheFileIn, String imageUrlIn, ResourceLocation defLocation, @Nullable IImageBuffer imageBufferIn) { public ThreadDownloadImageETag(@Nonnull File cacheFileIn, String imageUrlIn, ResourceLocation defLocation, @Nullable IImageBuffer imageBufferIn) {
super(defLocation); super(defLocation);
this.cacheFile = cacheFileIn; cacheFile = cacheFileIn;
this.eTagFile = new File(cacheFile.getParentFile(), cacheFile.getName() + ".etag"); eTagFile = new File(cacheFile.getParentFile(), cacheFile.getName() + ".etag");
this.imageUrl = imageUrlIn; imageUrl = imageUrlIn;
this.imageBuffer = imageBufferIn; imageBuffer = imageBufferIn;
} }
private void checkTextureUploaded() { private void checkTextureUploaded() {
if (!this.textureUploaded) { if (!textureUploaded) {
if (this.bufferedImage != null) { if (bufferedImage != null) {
if (this.textureLocation != null) { if (textureLocation != null) {
this.deleteGlTexture(); deleteGlTexture();
} }
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage); TextureUtil.uploadTextureImage(super.getGlTextureId(), bufferedImage);
this.textureUploaded = true; textureUploaded = true;
} }
} }
} }
@Override
public int getGlTextureId() { public int getGlTextureId() {
this.checkTextureUploaded(); checkTextureUploaded();
return super.getGlTextureId(); return super.getGlTextureId();
} }
private void setBufferedImage(@Nonnull BufferedImage bufferedImageIn) { private void setBufferedImage(@Nonnull BufferedImage bufferedImageIn) {
this.bufferedImage = bufferedImageIn; bufferedImage = bufferedImageIn;
if (this.imageBuffer != null) { if (imageBuffer != null) {
this.imageBuffer.skinAvailable(); imageBuffer.skinAvailable();
} }
} }
@ -84,15 +85,16 @@ public class ThreadDownloadImageETag extends SimpleTexture {
return bufferedImage; return bufferedImage;
} }
@Override
public void loadTexture(IResourceManager resourceManager) throws IOException { public void loadTexture(IResourceManager resourceManager) throws IOException {
if (this.bufferedImage == null && this.textureLocation != null) { if (bufferedImage == null && textureLocation != null) {
super.loadTexture(resourceManager); super.loadTexture(resourceManager);
} }
if (this.imageThread == null) { if (imageThread == null) {
this.imageThread = new Thread(this::loadTexture, "Texture Downloader #" + THREAD_ID.incrementAndGet()); imageThread = new Thread(this::loadTexture, "Texture Downloader #" + THREAD_ID.incrementAndGet());
this.imageThread.setDaemon(true); imageThread.setDaemon(true);
this.imageThread.start(); imageThread.start();
} }
} }
@ -133,8 +135,9 @@ public class ThreadDownloadImageETag extends SimpleTexture {
} }
LOGGER.error("Couldn't load skin {} ", imageUrl, e); LOGGER.error("Couldn't load skin {} ", imageUrl, e);
} finally { } finally {
if (response != null) if (response != null) {
EntityUtils.consumeQuietly(response.getEntity()); EntityUtils.consumeQuietly(response.getEntity());
}
} }
} }
@ -149,8 +152,8 @@ public class ThreadDownloadImageETag extends SimpleTexture {
} }
private void clearCache() { private void clearCache() {
FileUtils.deleteQuietly(this.cacheFile); FileUtils.deleteQuietly(cacheFile);
FileUtils.deleteQuietly(this.eTagFile); FileUtils.deleteQuietly(eTagFile);
} }
private boolean checkETag(HttpResponse response) { private boolean checkETag(HttpResponse response) {

View file

@ -61,13 +61,13 @@ public class CubeMap {
public void setSource(String source) { public void setSource(String source) {
cubemapTextures = new ResourceLocation[] { cubemapTextures = new ResourceLocation[] {
new ResourceLocation(String.format(source, 0)), new ResourceLocation(String.format(source, 0)),
new ResourceLocation(String.format(source, 1)), new ResourceLocation(String.format(source, 1)),
new ResourceLocation(String.format(source, 2)), new ResourceLocation(String.format(source, 2)),
new ResourceLocation(String.format(source, 3)), new ResourceLocation(String.format(source, 3)),
new ResourceLocation(String.format(source, 4)), new ResourceLocation(String.format(source, 4)),
new ResourceLocation(String.format(source, 5)) new ResourceLocation(String.format(source, 5))
}; };
} }
public void init() { public void init() {
@ -107,7 +107,7 @@ public class CubeMap {
} }
private void renderCubeMapTexture(float partialTick) { private void renderCubeMapTexture(float partialTick) {
this.setupCubemapCamera(); setupCubemapCamera();
color(1, 1, 1, 1); color(1, 1, 1, 1);
rotate(180, 1, 0, 0); rotate(180, 1, 0, 0);
@ -177,7 +177,7 @@ public class CubeMap {
enableCull(); enableCull();
enableAlpha(); enableAlpha();
enableDepth(); enableDepth();
this.revertPanoramaMatrix(); revertPanoramaMatrix();
} }
private void rotateAndBlurCubemap() { private void rotateAndBlurCubemap() {

View file

@ -11,29 +11,29 @@ import net.minecraft.world.storage.WorldInfo;
public class DummyWorld extends World { public class DummyWorld extends World {
public DummyWorld() { public DummyWorld() {
super(null, new WorldInfo( super(null, new WorldInfo(
new WorldSettings(0, GameType.NOT_SET, false, false, WorldType.DEFAULT), "MpServer"), new WorldSettings(0, GameType.NOT_SET, false, false, WorldType.DEFAULT), "MpServer"),
new WorldProviderSurface(), null, true); new WorldProviderSurface(), null, true);
} }
@Override @Override
protected IChunkProvider createChunkProvider() { protected IChunkProvider createChunkProvider() {
return null; return null;
} }
@Override @Override
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) { protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
return true; return true;
} }
@Override @Override
public float getLightBrightness(BlockPos pos) { public float getLightBrightness(BlockPos pos) {
return 1; return 1;
} }
@Override @Override
public BlockPos getSpawnPoint() { public BlockPos getSpawnPoint() {
return BlockPos.ORIGIN; return BlockPos.ORIGIN;
} }
} }

View file

@ -39,7 +39,7 @@ public class EntityPlayerModel extends EntityLivingBase {
EntityEquipmentSlot.LEGS, ItemStack.EMPTY, EntityEquipmentSlot.LEGS, ItemStack.EMPTY,
EntityEquipmentSlot.FEET, ItemStack.EMPTY, EntityEquipmentSlot.FEET, ItemStack.EMPTY,
EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY
)); ));
private PreviewTexture remoteSkinTexture; private PreviewTexture remoteSkinTexture;
private ResourceLocation remoteSkinResource; private ResourceLocation remoteSkinResource;
@ -59,38 +59,38 @@ public class EntityPlayerModel extends EntityLivingBase {
public EntityPlayerModel(GameProfile profile) { public EntityPlayerModel(GameProfile profile) {
super(new DummyWorld()); super(new DummyWorld());
this.profile = profile; this.profile = profile;
this.textureManager = Minecraft.getMinecraft().getTextureManager(); textureManager = Minecraft.getMinecraft().getTextureManager();
this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png"); remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png");
this.remoteElytraResource = new ResourceLocation("elytras/preview_" + this.profile.getName() + ".png"); remoteElytraResource = new ResourceLocation("elytras/preview_" + this.profile.getName() + ".png");
this.localSkinResource = getBlankSkin(); localSkinResource = getBlankSkin();
this.localElytraResource = getBlankElytra(); localElytraResource = getBlankElytra();
this.textureManager.deleteTexture(this.remoteSkinResource); textureManager.deleteTexture(remoteSkinResource);
this.textureManager.deleteTexture(this.remoteElytraResource); textureManager.deleteTexture(remoteElytraResource);
} }
public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) { public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) {
this.remoteSkin = true; remoteSkin = true;
if (this.remoteSkinTexture != null) { if (remoteSkinTexture != null) {
this.textureManager.deleteTexture(this.remoteSkinResource); textureManager.deleteTexture(remoteSkinResource);
} }
if (this.remoteElytraTexture != null) { if (remoteElytraTexture != null) {
this.textureManager.deleteTexture(this.remoteElytraResource); textureManager.deleteTexture(remoteElytraResource);
} }
PreviewTextureManager ptm = HDSkinManager.getPreviewTextureManager(this.profile); PreviewTextureManager ptm = HDSkinManager.getPreviewTextureManager(profile);
this.remoteSkinTexture = ptm.getPreviewTexture(this.remoteSkinResource, Type.SKIN, getBlankSkin(), listener); remoteSkinTexture = ptm.getPreviewTexture(remoteSkinResource, Type.SKIN, getBlankSkin(), listener);
this.remoteElytraTexture = ptm.getPreviewTexture(this.remoteElytraResource, Type.ELYTRA, getBlankElytra(), null); remoteElytraTexture = ptm.getPreviewTexture(remoteElytraResource, Type.ELYTRA, getBlankElytra(), null);
} }
public void setLocalTexture(File skinTextureFile, Type type) { public void setLocalTexture(File skinTextureFile, Type type) {
if (skinTextureFile.exists()) { if (skinTextureFile.exists()) {
if (type == Type.SKIN) { if (type == Type.SKIN) {
this.remoteSkin = false; remoteSkin = false;
if (this.localSkinTexture != null) { if (localSkinTexture != null) {
this.textureManager.deleteTexture(this.localSkinResource); textureManager.deleteTexture(localSkinResource);
this.localSkinTexture = null; localSkinTexture = null;
} }
BufferedImage bufferedImage; BufferedImage bufferedImage;
@ -99,33 +99,33 @@ public class EntityPlayerModel extends EntityLivingBase {
bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image); bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image);
assert bufferedImage != null; assert bufferedImage != null;
} catch (IOException var4) { } catch (IOException var4) {
this.localSkinResource = getBlankSkin(); localSkinResource = getBlankSkin();
var4.printStackTrace(); var4.printStackTrace();
return; return;
} }
this.localSkinTexture = new DynamicTextureImage(bufferedImage); localSkinTexture = new DynamicTextureImage(bufferedImage);
this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview", this.localSkinTexture); localSkinResource = textureManager.getDynamicTextureLocation("localSkinPreview", localSkinTexture);
this.hasLocalTexture = true; hasLocalTexture = true;
} else if (type == Type.ELYTRA) { } else if (type == Type.ELYTRA) {
this.remoteSkin = false; remoteSkin = false;
if (this.localElytraTexture != null) { if (localElytraTexture != null) {
this.textureManager.deleteTexture(this.localElytraResource); textureManager.deleteTexture(localElytraResource);
this.localElytraTexture = null; localElytraTexture = null;
} }
BufferedImage bufferedImage; BufferedImage bufferedImage;
try { try {
bufferedImage = ImageIO.read(skinTextureFile); bufferedImage = ImageIO.read(skinTextureFile);
} catch (IOException var4) { } catch (IOException var4) {
this.localElytraResource = getBlankElytra(); localElytraResource = getBlankElytra();
var4.printStackTrace(); var4.printStackTrace();
return; return;
} }
this.localElytraTexture = new DynamicTextureImage(bufferedImage); localElytraTexture = new DynamicTextureImage(bufferedImage);
this.localElytraResource = this.textureManager.getDynamicTextureLocation("localElytraPreview", this.localElytraTexture); localElytraResource = textureManager.getDynamicTextureLocation("localElytraPreview", localElytraTexture);
this.hasLocalTexture = true; hasLocalTexture = true;
} }
} }
} }
@ -139,35 +139,35 @@ public class EntityPlayerModel extends EntityLivingBase {
} }
public boolean isUsingLocalTexture() { public boolean isUsingLocalTexture() {
return !this.remoteSkin && this.hasLocalTexture; return !remoteSkin && hasLocalTexture;
} }
public boolean isTextureSetupComplete() { public boolean isTextureSetupComplete() {
return (this.remoteSkin && this.remoteSkinTexture != null) && this.remoteSkinTexture.isTextureUploaded(); return remoteSkin && remoteSkinTexture != null && remoteSkinTexture.isTextureUploaded();
} }
public void releaseTextures() { public void releaseTextures() {
if (this.localSkinTexture != null) { if (localSkinTexture != null) {
this.textureManager.deleteTexture(this.localSkinResource); textureManager.deleteTexture(localSkinResource);
this.localSkinTexture = null; localSkinTexture = null;
this.localSkinResource = getBlankSkin(); localSkinResource = getBlankSkin();
this.hasLocalTexture = false; hasLocalTexture = false;
} }
if (this.localElytraTexture != null) { if (localElytraTexture != null) {
this.textureManager.deleteTexture(this.localElytraResource); textureManager.deleteTexture(localElytraResource);
this.localElytraTexture = null; localElytraTexture = null;
this.localElytraResource = getBlankElytra(); localElytraResource = getBlankElytra();
this.hasLocalTexture = false; hasLocalTexture = false;
} }
} }
public ResourceLocation getSkinTexture() { public ResourceLocation getSkinTexture() {
return this.remoteSkin ? (this.remoteSkinTexture != null ? this.remoteSkinResource return remoteSkin ? remoteSkinTexture != null ? remoteSkinResource
: DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : this.localSkinResource; : DefaultPlayerSkin.getDefaultSkin(entityUniqueID) : localSkinResource;
} }
public ResourceLocation getElytraTexture() { public ResourceLocation getElytraTexture() {
return this.remoteSkin && this.remoteElytraTexture != null ? this.remoteElytraResource : localElytraResource; return remoteSkin && remoteElytraTexture != null ? remoteElytraResource : localElytraResource;
} }
public void setPreviewThinArms(boolean thinArms) { public void setPreviewThinArms(boolean thinArms) {
@ -185,27 +185,27 @@ public class EntityPlayerModel extends EntityLivingBase {
@Override @Override
public void swingArm(EnumHand hand) { public void swingArm(EnumHand hand) {
super.swingArm(hand); super.swingArm(hand);
if (!this.isSwingInProgress || this.swingProgressInt >= 4 || this.swingProgressInt < 0) { if (!isSwingInProgress || swingProgressInt >= 4 || swingProgressInt < 0) {
this.swingProgressInt = -1; swingProgressInt = -1;
this.isSwingInProgress = true; isSwingInProgress = true;
this.swingingHand = hand; swingingHand = hand;
} }
} }
public void updateModel() { public void updateModel() {
this.prevSwingProgress = this.swingProgress; prevSwingProgress = swingProgress;
if (this.isSwingInProgress) { if (isSwingInProgress) {
++this.swingProgressInt; ++swingProgressInt;
if (this.swingProgressInt >= 8) { if (swingProgressInt >= 8) {
this.swingProgressInt = 0; swingProgressInt = 0;
this.isSwingInProgress = false; isSwingInProgress = false;
} }
} else { } else {
this.swingProgressInt = 0; swingProgressInt = 0;
} }
this.swingProgress = this.swingProgressInt / 8.0F; swingProgress = swingProgressInt / 8.0F;
} }
@Override @Override

View file

@ -5,7 +5,6 @@ import com.voxelmodpack.hdskins.upload.awt.FileDropper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.DefaultResourcePack; import net.minecraft.client.resources.DefaultResourcePack;
import net.minecraft.launchwrapper.injector.VanillaTweakInjector;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
@ -21,7 +20,6 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
@ -112,7 +110,7 @@ public class GLWindow extends DropTarget {
@Override @Override
public void windowClosed(WindowEvent windowEvent) { public void windowClosed(WindowEvent windowEvent) {
if (!closeRequested) { if (!closeRequested) {
for (Window w : Frame.getWindows()) { for (Window w : Window.getWindows()) {
w.dispose(); w.dispose();
} }
@ -174,7 +172,7 @@ public class GLWindow extends DropTarget {
if (isFullscreen) { if (isFullscreen) {
Display.setFullscreen(true); Display.setFullscreen(true);
} else { } else {
if ((windowState & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH) { if ((windowState & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
Display.setLocation(0, 0); Display.setLocation(0, 0);
Display.setDisplayMode(Display.getDesktopDisplayMode()); Display.setDisplayMode(Display.getDesktopDisplayMode());
} else { } else {
@ -193,7 +191,7 @@ public class GLWindow extends DropTarget {
frame.setVisible(false); frame.setVisible(false);
frame.dispose(); frame.dispose();
for (Window w : Frame.getWindows()) { for (Window w : Window.getWindows()) {
w.dispose(); w.dispose();
} }
@ -213,7 +211,7 @@ public class GLWindow extends DropTarget {
ArrayList<Image> images = Lists.newArrayList( ArrayList<Image> images = Lists.newArrayList(
ImageIO.read(pack.getInputStreamAssets(new ResourceLocation("icons/icon_16x16.png"))), ImageIO.read(pack.getInputStreamAssets(new ResourceLocation("icons/icon_16x16.png"))),
ImageIO.read(pack.getInputStreamAssets(new ResourceLocation("icons/icon_32x32.png"))) ImageIO.read(pack.getInputStreamAssets(new ResourceLocation("icons/icon_32x32.png")))
); );
Frame[] frames = Frame.getFrames(); Frame[] frames = Frame.getFrames();

View file

@ -17,6 +17,6 @@ public class GuiItemStackButton extends GuiButton {
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
super.drawButton(mc, mouseX, mouseY, partialTicks); super.drawButton(mc, mouseX, mouseY, partialTicks);
mc.getRenderItem().renderItemIntoGUI(itemStack, this.x + 2, this.y + 2); mc.getRenderItem().renderItemIntoGUI(itemStack, x + 2, y + 2);
} }
} }

View file

@ -20,20 +20,20 @@ public class HDSkinsConfigPanel implements ConfigPanel {
@Override @Override
public void onPanelShown(ConfigPanelHost host) { public void onPanelShown(ConfigPanelHost host) {
this.mod = LiteLoader.getInstance().getMod(LiteModHDSkins.class); mod = LiteLoader.getInstance().getMod(LiteModHDSkins.class);
this.button = new GuiButton(0, 40, 70, 100, 20, "Clear Skin Cache"); button = new GuiButton(0, 40, 70, 100, 20, "Clear Skin Cache");
this.checkbox = new GuiCheckbox(1, 40, 40, "Experimental Skin Drop"); checkbox = new GuiCheckbox(1, 40, 40, "Experimental Skin Drop");
this.checkbox.checked = mod.experimentalSkinDrop; checkbox.checked = mod.experimentalSkinDrop;
} }
@Override @Override
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) { public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
this.button.drawButton(mc, mouseX, mouseY, partialTicks); button.drawButton(mc, mouseX, mouseY, partialTicks);
this.checkbox.drawButton(mc, mouseX, mouseY, partialTicks); checkbox.drawButton(mc, mouseX, mouseY, partialTicks);
} }
@Override @Override

View file

@ -90,7 +90,7 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
@Override @Override
public void doRender(M par1Entity, double par2, double par4, double par6, float par8, float par9) { public void doRender(M par1Entity, double par2, double par4, double par6, float par8, float par9) {
ModelPlayer player = this.getEntityModel(par1Entity); ModelPlayer player = this.getEntityModel(par1Entity);
this.mainModel = player; mainModel = player;
Set<EnumPlayerModelParts> parts = Minecraft.getMinecraft().gameSettings.getModelParts(); Set<EnumPlayerModelParts> parts = Minecraft.getMinecraft().gameSettings.getModelParts();
player.bipedHeadwear.isHidden = !parts.contains(EnumPlayerModelParts.HAT); player.bipedHeadwear.isHidden = !parts.contains(EnumPlayerModelParts.HAT);

View file

@ -21,13 +21,13 @@ public class MixinGuiMainMenu extends GuiScreen {
private void onInit(CallbackInfo ci) { private void onInit(CallbackInfo ci) {
ItemStack itemStack = new ItemStack(Items.LEATHER_LEGGINGS); ItemStack itemStack = new ItemStack(Items.LEATHER_LEGGINGS);
Items.LEATHER_LEGGINGS.setColor(itemStack, 0x3c5dcb); Items.LEATHER_LEGGINGS.setColor(itemStack, 0x3c5dcb);
this.buttonList.add(new GuiItemStackButton(SKINS, width - 50, height - 50, itemStack)); buttonList.add(new GuiItemStackButton(SKINS, width - 50, height - 50, itemStack));
} }
@Inject(method = "actionPerformed(Lnet/minecraft/client/gui/GuiButton;)V", at = @At("RETURN")) @Inject(method = "actionPerformed(Lnet/minecraft/client/gui/GuiButton;)V", at = @At("RETURN"))
private void onActionPerformed(GuiButton button, CallbackInfo ci) { private void onActionPerformed(GuiButton button, CallbackInfo ci) {
if (button.id == SKINS) { if (button.id == SKINS) {
this.mc.displayGuiScreen(HDSkinManager.INSTANCE.createSkinsGui()); mc.displayGuiScreen(HDSkinManager.INSTANCE.createSkinsGui());
} }
} }
} }

View file

@ -17,7 +17,7 @@ public abstract class MixinImageBufferDownload implements IImageBuffer {
@Inject( @Inject(
method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;", method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;",
at = @At("RETURN"), at = @At("RETURN"),
cancellable = true) cancellable = true)
private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) { private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) {
// convert skins from mojang server // convert skins from mojang server
BufferedImage image2 = ci.getReturnValue(); BufferedImage image2 = ci.getReturnValue();

View file

@ -57,8 +57,9 @@ public abstract class MixinPlayerInfo {
MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN); MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN);
if (skin != null) { if (skin != null) {
String type = skin.getMetadata("model"); String type = skin.getMetadata("model");
if (type == null) if (type == null) {
type = "default"; type = "default";
}
String type1 = type; String type1 = type;
Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false); Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false);

View file

@ -25,15 +25,17 @@ public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer<TileE
target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V", target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V",
ordinal = 4)) ordinal = 4))
private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, EnumFacing facing, float rotation, int meta, private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, EnumFacing facing, float rotation, int meta,
@Nullable GameProfile profile, int p_180543_8_, float ticks) { @Nullable GameProfile profile, int p_180543_8_, float ticks) {
if (profile != null) { if (profile != null) {
Optional<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true); Optional<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true);
if (skin.isPresent()) if (skin.isPresent()) {
// rebind // rebind
bindTexture(skin.get()); bindTexture(skin.get());
else } else {
bindTexture(rl); bindTexture(rl);
} else }
} else {
bindTexture(rl); bindTexture(rl);
}
} }
} }

View file

@ -21,7 +21,7 @@ public class ImageLoader implements Supplier<ResourceLocation> {
private final ResourceLocation original; private final ResourceLocation original;
public ImageLoader(ResourceLocation loc) { public ImageLoader(ResourceLocation loc) {
this.original = loc; original = loc;
} }
@Override @Override
@ -34,7 +34,7 @@ public class ImageLoader implements Supplier<ResourceLocation> {
} }
if (updated == image) { if (updated == image) {
// don't load a new image // don't load a new image
return this.original; return original;
} }
return addTaskAndGet(() -> loadSkin(updated)); return addTaskAndGet(() -> loadSkin(updated));
} }

View file

@ -75,9 +75,10 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
@Nullable @Nullable
public ResourceLocation getPlayerTexture(GameProfile profile, Type type) { public ResourceLocation getPlayerTexture(GameProfile profile, Type type) {
if (type != Type.SKIN) if (type != Type.SKIN) {
// not supported // not supported
return null; return null;
}
Skin skin = getSkin(profile); Skin skin = getSkin(profile);
if (skin != null) { if (skin != null) {
@ -102,11 +103,11 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
private void loadSkinResource(@Nullable final ResourceLocation res) { private void loadSkinResource(@Nullable final ResourceLocation res) {
if (res != null) { if (res != null) {
// read and convert in a new thread // read and convert in a new thread
this.inProgress.computeIfAbsent(res, r -> CompletableFuture.supplyAsync(new ImageLoader(r), executor) inProgress.computeIfAbsent(res, r -> CompletableFuture.supplyAsync(new ImageLoader(r), executor)
.whenComplete((loc, t) -> { .whenComplete((loc, t) -> {
if (loc != null) if (loc != null) {
converted.put(res, loc); converted.put(res, loc);
else { } else {
LogManager.getLogger().warn("Errored while processing {}. Using original.", res, t); LogManager.getLogger().warn("Errored while processing {}. Using original.", res, t);
converted.put(res, res); converted.put(res, res);
} }
@ -119,9 +120,9 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
@Nullable @Nullable
private Skin getSkin(GameProfile profile) { private Skin getSkin(GameProfile profile) {
Skin skin = this.uuidSkins.get(profile.getId()); Skin skin = uuidSkins.get(profile.getId());
if (skin == null) { if (skin == null) {
skin = this.namedSkins.get(profile.getName()); skin = namedSkins.get(profile.getName());
} }
return skin; return skin;
} }

View file

@ -10,11 +10,11 @@ public class IndentedToStringStyle extends ToStringStyle {
public static final ToStringStyle INSTANCE = new IndentedToStringStyle(); public static final ToStringStyle INSTANCE = new IndentedToStringStyle();
private IndentedToStringStyle() { private IndentedToStringStyle() {
this.setContentStart(null); setContentStart(null);
this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " "); setFieldSeparator(SystemUtils.LINE_SEPARATOR + " ");
this.setFieldSeparatorAtStart(true); setFieldSeparatorAtStart(true);
this.setContentEnd(null); setContentEnd(null);
this.setUseIdentityHashCode(false); setUseIdentityHashCode(false);
this.setUseShortClassName(true); setUseShortClassName(true);
} }
} }

View file

@ -46,7 +46,7 @@ public class LegacySkinServer implements SkinServer {
@Override @Override
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) { public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) {
if (Strings.isNullOrEmpty(this.gateway)) { if (Strings.isNullOrEmpty(gateway)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = new EnumMap<>(MinecraftProfileTexture.Type.class); Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = new EnumMap<>(MinecraftProfileTexture.Type.class);
@ -61,7 +61,7 @@ public class LegacySkinServer implements SkinServer {
ImmutableMap.Builder<MinecraftProfileTexture.Type, MinecraftProfileTexture> builder = ImmutableMap.builder(); ImmutableMap.Builder<MinecraftProfileTexture.Type, MinecraftProfileTexture> builder = ImmutableMap.builder();
for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) { for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) {
String url = getPath(this.address, type, profile); String url = getPath(address, type, profile);
try { try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
if (urlConnection.getResponseCode() / 100 != 2) { if (urlConnection.getResponseCode() / 100 != 2) {
@ -76,7 +76,7 @@ public class LegacySkinServer implements SkinServer {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = builder.build(); Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = builder.build();
if (map.isEmpty()) { if (map.isEmpty()) {
logger.debug("No textures found for {} at {}", profile, this.address); logger.debug("No textures found for {} at {}", profile, address);
return Optional.empty(); return Optional.empty();
} }
@ -86,7 +86,7 @@ public class LegacySkinServer implements SkinServer {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata) { public CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata) {
if (Strings.isNullOrEmpty(this.gateway)) { if (Strings.isNullOrEmpty(gateway)) {
return CallableFutures.failedFuture(new NullPointerException("gateway url is blank")); return CallableFutures.failedFuture(new NullPointerException("gateway url is blank"));
} }
@ -94,13 +94,14 @@ public class LegacySkinServer implements SkinServer {
SkinServer.verifyServerConnection(session, SERVER_ID); SkinServer.verifyServerConnection(session, SERVER_ID);
String model = metadata.getOrDefault("model", "default"); String model = metadata.getOrDefault("model", "default");
Map<String, ?> data = image == null ? getClearData(session, type) : getUploadData(session, type, model, image); Map<String, ?> data = image == null ? getClearData(session, type) : getUploadData(session, type, model, image);
ThreadMultipartPostUpload upload = new ThreadMultipartPostUpload(this.gateway, data); ThreadMultipartPostUpload upload = new ThreadMultipartPostUpload(gateway, data);
String response = upload.uploadMultipart(); String response = upload.uploadMultipart();
if (response.startsWith("ERROR: ")) { if (response.startsWith("ERROR: ")) {
response = response.substring(7); response = response.substring(7);
} }
if (!response.equalsIgnoreCase("OK") && !response.endsWith("OK")) if (!response.equalsIgnoreCase("OK") && !response.endsWith("OK")) {
throw new IOException(response); throw new IOException(response);
}
return new SkinUploadResponse(response); return new SkinUploadResponse(response);
}, HDSkinManager.skinUploadExecutor); }, HDSkinManager.skinUploadExecutor);
@ -132,8 +133,8 @@ public class LegacySkinServer implements SkinServer {
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE)
.append("address", this.address) .append("address", address)
.append("gateway", this.gateway) .append("gateway", gateway)
.build(); .build();
} }
} }

View file

@ -26,7 +26,7 @@ import javax.annotation.Nullable;
public interface SkinServer extends Exposable { public interface SkinServer extends Exposable {
static final Gson gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter()) .registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
.create(); .create();
@ -43,7 +43,7 @@ public interface SkinServer extends Exposable {
CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata); CompletableFuture<SkinUploadResponse> uploadSkin(Session session, @Nullable URI image, MinecraftProfileTexture.Type type, Map<String, String> metadata);
public static void verifyServerConnection(Session session, String serverId) throws AuthenticationException { static void verifyServerConnection(Session session, String serverId) throws AuthenticationException {
MinecraftSessionService service = Minecraft.getMinecraft().getSessionService(); MinecraftSessionService service = Minecraft.getMinecraft().getSessionService();
service.joinServer(session.getProfile(), session.getToken(), serverId); service.joinServer(session.getProfile(), session.getToken(), serverId);
} }

View file

@ -1,6 +1,5 @@
package com.voxelmodpack.hdskins.skins; package com.voxelmodpack.hdskins.skins;
import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;

View file

@ -90,7 +90,7 @@ public class ValhallaSkinServer implements SkinServer {
private SkinUploadResponse upload(CloseableHttpClient client, Session session, @Nullable URI image, private SkinUploadResponse upload(CloseableHttpClient client, Session session, @Nullable URI image,
MinecraftProfileTexture.Type type, Map<String, String> metadata) MinecraftProfileTexture.Type type, Map<String, String> metadata)
throws IOException { throws IOException {
GameProfile profile = session.getProfile(); GameProfile profile = session.getProfile();
if (image == null) { if (image == null) {
@ -111,7 +111,7 @@ public class ValhallaSkinServer implements SkinServer {
private SkinUploadResponse resetSkin(CloseableHttpClient client, GameProfile profile, MinecraftProfileTexture.Type type) throws IOException { private SkinUploadResponse resetSkin(CloseableHttpClient client, GameProfile profile, MinecraftProfileTexture.Type type) throws IOException {
return upload(client, RequestBuilder.delete() return upload(client, RequestBuilder.delete()
.setUri(buildUserTextureUri(profile, type)) .setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken) .addHeader(HttpHeaders.AUTHORIZATION, accessToken)
.build()); .build());
} }
@ -122,7 +122,7 @@ public class ValhallaSkinServer implements SkinServer {
return upload(client, RequestBuilder.put() return upload(client, RequestBuilder.put()
.setUri(buildUserTextureUri(profile, type)) .setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken) .addHeader(HttpHeaders.AUTHORIZATION, accessToken)
.setEntity(b.build()) .setEntity(b.build())
.build()); .build());
} }
@ -131,7 +131,7 @@ public class ValhallaSkinServer implements SkinServer {
return upload(client, RequestBuilder.post() return upload(client, RequestBuilder.post()
.setUri(buildUserTextureUri(profile, type)) .setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken) .addHeader(HttpHeaders.AUTHORIZATION, accessToken)
.addParameter("file", uri.toString()) .addParameter("file", uri.toString())
.addParameters(metadata.entrySet().stream() .addParameters(metadata.entrySet().stream()
.map(entry -> new BasicNameValuePair(entry.getKey(), entry.getValue())) .map(entry -> new BasicNameValuePair(entry.getKey(), entry.getValue()))
@ -147,7 +147,7 @@ public class ValhallaSkinServer implements SkinServer {
private void authorize(CloseableHttpClient client, Session session) throws IOException, AuthenticationException { private void authorize(CloseableHttpClient client, Session session) throws IOException, AuthenticationException {
if (this.accessToken != null) { if (accessToken != null) {
return; return;
} }
GameProfile profile = session.getProfile(); GameProfile profile = session.getProfile();
@ -165,7 +165,7 @@ public class ValhallaSkinServer implements SkinServer {
if (!response.userId.equals(profile.getId())) { if (!response.userId.equals(profile.getId())) {
throw new IOException("UUID mismatch!"); // probably won't ever throw throw new IOException("UUID mismatch!"); // probably won't ever throw
} }
this.accessToken = response.accessToken; accessToken = response.accessToken;
} }
private <T> T readJson(HttpResponse resp, Class<T> cl) throws IOException { private <T> T readJson(HttpResponse resp, Class<T> cl) throws IOException {
@ -208,26 +208,26 @@ public class ValhallaSkinServer implements SkinServer {
private URI buildUserTextureUri(GameProfile profile, MinecraftProfileTexture.Type textureType) { private URI buildUserTextureUri(GameProfile profile, MinecraftProfileTexture.Type textureType) {
String user = UUIDTypeAdapter.fromUUID(profile.getId()); String user = UUIDTypeAdapter.fromUUID(profile.getId());
String skinType = textureType.name().toLowerCase(Locale.US); String skinType = textureType.name().toLowerCase(Locale.US);
return URI.create(String.format("%s/user/%s/%s", this.address, user, skinType)); return URI.create(String.format("%s/user/%s/%s", address, user, skinType));
} }
private URI getTexturesURI(GameProfile profile) { private URI getTexturesURI(GameProfile profile) {
Preconditions.checkNotNull(profile.getId(), "profile id required for skins"); Preconditions.checkNotNull(profile.getId(), "profile id required for skins");
return URI.create(String.format("%s/user/%s", this.address, UUIDTypeAdapter.fromUUID(profile.getId()))); return URI.create(String.format("%s/user/%s", address, UUIDTypeAdapter.fromUUID(profile.getId())));
} }
private URI getHandshakeURI() { private URI getHandshakeURI() {
return URI.create(String.format("%s/auth/handshake", this.address)); return URI.create(String.format("%s/auth/handshake", address));
} }
private URI getResponseURI() { private URI getResponseURI() {
return URI.create(String.format("%s/auth/response", this.address)); return URI.create(String.format("%s/auth/response", address));
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE)
.append("address", this.address) .append("address", address)
.toString(); .toString();
} }

View file

@ -45,7 +45,7 @@ public class ThreadMultipartPostUpload {
public ThreadMultipartPostUpload(String method, String url, Map<String, ?> sourceData, @Nullable String authorization) { public ThreadMultipartPostUpload(String method, String url, Map<String, ?> sourceData, @Nullable String authorization) {
this.method = method; this.method = method;
this.urlString = url; urlString = url;
this.sourceData = sourceData; this.sourceData = sourceData;
this.authorization = authorization; this.authorization = authorization;
} }
@ -56,28 +56,28 @@ public class ThreadMultipartPostUpload {
public String uploadMultipart() throws IOException { public String uploadMultipart() throws IOException {
// open a URL connection // open a URL connection
URL url = new URL(this.urlString); URL url = new URL(urlString);
// Open a HTTP connection to the URL // Open a HTTP connection to the URL
this.httpClient = (HttpURLConnection) url.openConnection(); httpClient = (HttpURLConnection) url.openConnection();
this.httpClient.setDoOutput(true); httpClient.setDoOutput(true);
this.httpClient.setUseCaches(false); httpClient.setUseCaches(false);
this.httpClient.setRequestMethod(this.method); httpClient.setRequestMethod(method);
this.httpClient.setRequestProperty("Connection", "Close"); httpClient.setRequestProperty("Connection", "Close");
this.httpClient.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For CloudFlare httpClient.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For CloudFlare
if (this.sourceData.size() > 0) { if (sourceData.size() > 0) {
this.httpClient.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); httpClient.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
} }
if (this.authorization != null) { if (authorization != null) {
this.httpClient.addRequestProperty("Authorization", this.authorization); httpClient.addRequestProperty("Authorization", authorization);
} }
try (DataOutputStream outputStream = new DataOutputStream(this.httpClient.getOutputStream())) { try (DataOutputStream outputStream = new DataOutputStream(httpClient.getOutputStream())) {
for (Entry<String, ?> data : this.sourceData.entrySet()) { for (Entry<String, ?> data : sourceData.entrySet()) {
outputStream.writeBytes(twoHyphens + boundary + CRLF); outputStream.writeBytes(twoHyphens + boundary + CRLF);
String paramName = data.getKey(); String paramName = data.getKey();
@ -103,7 +103,7 @@ public class ThreadMultipartPostUpload {
outputStream.writeBytes(twoHyphens + boundary + twoHyphens + CRLF); outputStream.writeBytes(twoHyphens + boundary + twoHyphens + CRLF);
} }
try (InputStream input = this.httpClient.getInputStream()) { try (InputStream input = httpClient.getInputStream()) {
return IOUtils.toString(input, StandardCharsets.UTF_8); return IOUtils.toString(input, StandardCharsets.UTF_8);
} }
} }

View file

@ -13,6 +13,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRootPane; import javax.swing.JRootPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
public class FileDropper extends JFrame { public class FileDropper extends JFrame {
private static final long serialVersionUID = -2945117328826695659L; private static final long serialVersionUID = -2945117328826695659L;
@ -33,7 +34,7 @@ public class FileDropper extends JFrame {
super("Skin Drop"); super("Skin Drop");
setType(Type.UTILITY); setType(Type.UTILITY);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
setResizable(false); setResizable(false);
setTitle("Skin Drop"); setTitle("Skin Drop");
setSize(256, 256); setSize(256, 256);

View file

@ -31,19 +31,19 @@ public abstract class ThreadOpenFile extends Thread {
throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!"); throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!");
} }
this.parentScreen = callback; parentScreen = callback;
this.dialogTitle = dialogTitle; this.dialogTitle = dialogTitle;
} }
@Override @Override
public void run() { public void run() {
fileDialog = new JFileChooser(); fileDialog = new JFileChooser();
fileDialog.setDialogTitle(this.dialogTitle); fileDialog.setDialogTitle(dialogTitle);
if (lastChosenFile != null) { if (lastChosenFile != null) {
fileDialog.setSelectedFile(new File(lastChosenFile)); fileDialog.setSelectedFile(new File(lastChosenFile));
} }
fileDialog.setFileFilter(this.getFileFilter()); fileDialog.setFileFilter(getFileFilter());
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext()); int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
@ -53,7 +53,7 @@ public abstract class ThreadOpenFile extends Thread {
lastChosenFile = f.getAbsolutePath(); lastChosenFile = f.getAbsolutePath();
} }
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult); parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
} }
/** /**

View file

@ -31,8 +31,9 @@ public class ForgeProxy {
* @return * @return
*/ */
public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) { public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) {
if (forgeLoaded) if (forgeLoaded) {
return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type); return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);
}
return def; return def;
} }
@ -45,8 +46,9 @@ public class ForgeProxy {
* @param def Default return value if no mods present * @param def Default return value if no mods present
*/ */
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) { public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
if (forgeLoaded) if (forgeLoaded) {
return ForgeHooksClient.getArmorModel(entity, item, slot, def); return ForgeHooksClient.getArmorModel(entity, item, slot, def);
}
return def; return def;
} }
} }

View file

@ -85,7 +85,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
ResourceLocation skin = player.getLocationSkin(); ResourceLocation skin = player.getLocationSkin();
UUID uuid = player.getGameProfile().getId(); UUID uuid = player.getGameProfile().getId();
if (skin == null) return getDefaultPony(uuid); if (skin == null) {
return getDefaultPony(uuid);
}
return getPony(skin, uuid); return getPony(skin, uuid);
} }
@ -97,7 +99,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
ResourceLocation skin = playerInfo.getLocationSkin(); ResourceLocation skin = playerInfo.getLocationSkin();
UUID uuid = playerInfo.getGameProfile().getId(); UUID uuid = playerInfo.getGameProfile().getId();
if (skin == null) return getDefaultPony(uuid); if (skin == null) {
return getDefaultPony(uuid);
}
return getPony(skin, uuid); return getPony(skin, uuid);
} }
@ -141,7 +145,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
} }
int bgi = uuid.hashCode() % getNumberOfPonies(); int bgi = uuid.hashCode() % getNumberOfPonies();
while (bgi < 0) bgi += getNumberOfPonies(); while (bgi < 0) {
bgi += getNumberOfPonies();
}
return getPony(backgroundPonyList.get(bgi), false); return getPony(backgroundPonyList.get(bgi), false);
} }
@ -163,7 +169,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
backgroundPonyList.clear(); backgroundPonyList.clear();
try { try {
for (IResource res : resourceManager.getAllResources(BGPONIES_JSON)) { for (IResource res : resourceManager.getAllResources(BGPONIES_JSON)) {
try (Reader reader = new InputStreamReader((res.getInputStream()))) { try (Reader reader = new InputStreamReader(res.getInputStream())) {
BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class); BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class);
if (ponies.override) { if (ponies.override) {
backgroundPonyList.clear(); backgroundPonyList.clear();

View file

@ -20,13 +20,15 @@ public class Label extends GuiButton {
super(0, x, y, ""); super(0, x, y, "");
this.color = color; this.color = color;
this.center = center; this.center = center;
this.text = translationString; text = translationString;
} }
@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
return false; return false;
} }
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (center) { if (center) {
drawCenteredString(mc.fontRenderer, I18n.format(text), x, y, color); drawCenteredString(mc.fontRenderer, I18n.format(text), x, y, color);

View file

@ -97,6 +97,7 @@ public class PonySettingsPanel extends GuiPonySettings implements ConfigPanel {
} }
@Override
protected boolean mustScroll() { protected boolean mustScroll() {
return true; return true;
} }

View file

@ -29,8 +29,8 @@ public class GuiSkinsMineLP extends GuiSkins {
private static final String[] panoramas = new String[] { private static final String[] panoramas = new String[] {
"minelp:textures/cubemap/sugarcubecorner_%d.png", "minelp:textures/cubemap/sugarcubecorner_%d.png",
"minelp:textures/cubemap/quillsandsofas_%d.png" "minelp:textures/cubemap/quillsandsofas_%d.png"
}; };
@Override @Override
@ -61,19 +61,19 @@ public class GuiSkinsMineLP extends GuiSkins {
protected void actionPerformed(GuiButton guiButton) { protected void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton); super.actionPerformed(guiButton);
if (guiButton.id == this.btnModeDry.id) { if (guiButton.id == btnModeDry.id) {
this.isWet = false; isWet = false;
this.localPlayer.releaseTextures(); localPlayer.releaseTextures();
} else if (guiButton.id == this.btnModeWet.id) { } else if (guiButton.id == btnModeWet.id) {
this.isWet = true; isWet = true;
this.localPlayer.releaseTextures(); localPlayer.releaseTextures();
} }
btnModeDry.enabled = isWet; btnModeDry.enabled = isWet;
btnModeWet.enabled = !isWet; btnModeWet.enabled = !isWet;
((EntityPonyModel)this.localPlayer).setWet(isWet); ((EntityPonyModel)localPlayer).setWet(isWet);
((EntityPonyModel)this.remotePlayer).setWet(isWet); ((EntityPonyModel)remotePlayer).setWet(isWet);
} }
@Override @Override

View file

@ -24,8 +24,8 @@ public class MixinItemRenderer {
//public void renderItemInFirstPerson(AbstractClientPlayer player, float p_187457_2_, float p_187457_3_, EnumHand hand, float p_187457_5_, ItemStack stack, float p_187457_7_) //public void renderItemInFirstPerson(AbstractClientPlayer player, float p_187457_2_, float p_187457_3_, EnumHand hand, float p_187457_5_, ItemStack stack, float p_187457_7_)
//public void renderItemSide(EntityLivingBase entitylivingbaseIn, ItemStack heldStack, ItemCameraTransforms.TransformType transform, boolean leftHanded) //public void renderItemSide(EntityLivingBase entitylivingbaseIn, ItemStack heldStack, ItemCameraTransforms.TransformType transform, boolean leftHanded)
@Redirect(method = "renderItemInFirstPerson(" + AbstractClientPlayer + "FF" + EnumHand + "F" + ItemStack + "F)V", @Redirect(method = "renderItemInFirstPerson(" + AbstractClientPlayer + "FF" + EnumHand + "F" + ItemStack + "F)V",
at = @At(value = "INVOKE", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemSide(" + EntityLivingBase + ItemStack + TransformType + "Z)V")) target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemSide(" + EntityLivingBase + ItemStack + TransformType + "Z)V"))
private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) { private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) {
MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left); MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left);
} }

View file

@ -33,11 +33,13 @@ public class ModelWrapper implements IModelWrapper {
return armor; return armor;
} }
@Override
public void apply(IPonyData meta) { public void apply(IPonyData meta) {
body.metadata = meta; body.metadata = meta;
armor.apply(meta); armor.apply(meta);
} }
@Override
public void init() { public void init() {
body.init(0, 0); body.init(0, 0);
armor.init(); armor.init();

View file

@ -3,69 +3,69 @@ package com.minelittlepony.model;
public final class PonyModelConstants { public final class PonyModelConstants {
public static final float public static final float
PI = (float)Math.PI, PI = (float)Math.PI,
BODY_CENTRE_X = 0, BODY_CENTRE_X = 0,
BODY_CENTRE_Y = 8, BODY_CENTRE_Y = 8,
BODY_CENTRE_Z = 6, BODY_CENTRE_Z = 6,
NECK_CENTRE_X = BODY_CENTRE_X - 2, NECK_CENTRE_X = BODY_CENTRE_X - 2,
NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8F, NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8F,
NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8F, NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8F,
BODY_ROTATE_ANGLE_X_NOTSNEAK = 0, BODY_ROTATE_ANGLE_X_NOTSNEAK = 0,
BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, BODY_ROTATE_ANGLE_X_SNEAK = 0.4F,
BODY_ROTATE_ANGLE_X_RIDING = PI * 3.8F, BODY_ROTATE_ANGLE_X_RIDING = PI * 3.8F,
BODY_RP_Y_NOTSNEAK = 0, BODY_RP_Y_NOTSNEAK = 0,
BODY_RP_Y_SNEAK = 7, BODY_RP_Y_SNEAK = 7,
BODY_RP_Y_RIDING = 1, BODY_RP_Y_RIDING = 1,
BODY_RP_Z_NOTSNEAK = 0, BODY_RP_Z_NOTSNEAK = 0,
BODY_RP_Z_SNEAK = -4, BODY_RP_Z_SNEAK = -4,
BODY_RP_Z_RIDING = 4, BODY_RP_Z_RIDING = 4,
FRONT_LEG_RP_Y_NOTSNEAK = 8, FRONT_LEG_RP_Y_NOTSNEAK = 8,
FRONT_LEG_RP_Y_SNEAK = 8, FRONT_LEG_RP_Y_SNEAK = 8,
HEAD_CENTRE_X = 0, HEAD_CENTRE_X = 0,
HEAD_CENTRE_Y = -1, HEAD_CENTRE_Y = -1,
HEAD_CENTRE_Z = -2, HEAD_CENTRE_Z = -2,
HEAD_RP_X = 0, HEAD_RP_X = 0,
HEAD_RP_Y = 0, HEAD_RP_Y = 0,
HEAD_RP_Z = 0, HEAD_RP_Z = 0,
HORN_X = HEAD_CENTRE_X - 0.5F, HORN_X = HEAD_CENTRE_X - 0.5F,
HORN_Y = HEAD_CENTRE_Y - 10, HORN_Y = HEAD_CENTRE_Y - 10,
HORN_Z = HEAD_CENTRE_Z - 1.5F, HORN_Z = HEAD_CENTRE_Z - 1.5F,
LEFT_WING_EXT_RP_X = 4.5F, LEFT_WING_EXT_RP_X = 4.5F,
LEFT_WING_EXT_RP_Y = 5.3F, LEFT_WING_EXT_RP_Y = 5.3F,
LEFT_WING_EXT_RP_Z = 6, LEFT_WING_EXT_RP_Z = 6,
LEFT_WING_ROTATE_ANGLE_Z_SNEAK = 4, LEFT_WING_ROTATE_ANGLE_Z_SNEAK = 4,
ROTATE_270 = 4.712F, ROTATE_270 = 4.712F,
ROTATE_90 = 1.571F, ROTATE_90 = 1.571F,
SNEAK_LEG_X_ROTATION_ADJUSTMENT = 0.4F, SNEAK_LEG_X_ROTATION_ADJUSTMENT = 0.4F,
TAIL_RP_X = 0, TAIL_RP_X = 0,
TAIL_RP_Y = 0, TAIL_RP_Y = 0,
TAIL_RP_Z = 0, TAIL_RP_Z = 0,
TAIL_RP_Z_NOTSNEAK = 14, TAIL_RP_Z_NOTSNEAK = 14,
TAIL_RP_Z_SNEAK = 15, TAIL_RP_Z_SNEAK = 15,
FIRSTP_ARM_CENTRE_X = -3, FIRSTP_ARM_CENTRE_X = -3,
THIRDP_ARM_CENTRE_X = 0, THIRDP_ARM_CENTRE_X = 0,
THIRDP_ARM_CENTRE_Y = 4, THIRDP_ARM_CENTRE_Y = 4,
THIRDP_ARM_CENTRE_Z = -1, THIRDP_ARM_CENTRE_Z = -1,
WING_FOLDED_RP_Y = 13, WING_FOLDED_RP_Y = 13,
WING_FOLDED_RP_Z = -3, WING_FOLDED_RP_Z = -3,
NECK_ROT_X = 0.166F; NECK_ROT_X = 0.166F;
} }

View file

@ -5,7 +5,7 @@ import java.util.Map;
public class BasicEasingInterpolator implements IInterpolator { public class BasicEasingInterpolator implements IInterpolator {
private final Map<String, Float> properties = new HashMap<String, Float>(); private final Map<String, Float> properties = new HashMap<>();
private float getLast(String key, float to) { private float getLast(String key, float to) {
if (properties.containsKey(key)) { if (properties.containsKey(key)) {

View file

@ -17,7 +17,7 @@ public interface IModelPegasus extends IModel {
default float getWingRotationFactor(float ticks) { default float getWingRotationFactor(float ticks) {
if (isSwimming()) { if (isSwimming()) {
return (MathHelper.sin(ticks * 0.136f) / 2) + ROTATE_270; return MathHelper.sin(ticks * 0.136f) / 2 + ROTATE_270;
} }
if (isFlying()) { if (isFlying()) {
return MathHelper.sin(ticks * 0.536f) + ROTATE_270 + 0.4f; return MathHelper.sin(ticks * 0.536f) + ROTATE_270 + 0.4f;

View file

@ -12,7 +12,7 @@ public class ModelDeadMau5Ears extends ModelSkeletonHead {
} }
public void setVisible(boolean show) { public void setVisible(boolean show) {
this.boxList.clear(); boxList.clear();
skeletonHead = new ModelRenderer(this, 24, 0); skeletonHead = new ModelRenderer(this, 24, 0);
skeletonHead.addBox(-9, -13, -1, 6, 6, 1, 0); skeletonHead.addBox(-9, -13, -1, 6, 6, 1, 0);

View file

@ -46,8 +46,12 @@ public class ModelEarthPony extends AbstractPonyModel {
@Override @Override
protected float getLegOutset() { protected float getLegOutset() {
if (smallArms) { if (smallArms) {
if (isSleeping()) return 2.6f; if (isSleeping()) {
if (isCrouching()) return 1; return 2.6f;
}
if (isCrouching()) {
return 1;
}
return 4; return 4;
} }
return super.getLegOutset(); return super.getLegOutset();

View file

@ -39,6 +39,7 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
unicornArmLeft.rotateAngleY = 0; unicornArmLeft.rotateAngleY = 0;
} }
@Override
protected float getWobbleAmount() { protected float getWobbleAmount() {
if (isCasting()) { if (isCasting()) {
return 0; return 0;
@ -87,7 +88,9 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
@Override @Override
protected void swingArms(float ticks) { protected void swingArms(float ticks) {
if (isSleeping()) return; if (isSleeping()) {
return;
}
if (canCast()) { if (canCast()) {
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;

View file

@ -19,6 +19,7 @@ public enum PlayerModels {
ALICORN("alicorn", "slimalicorn", () -> PMAPI.alicorn, () -> PMAPI.alicornSmall), ALICORN("alicorn", "slimalicorn", () -> PMAPI.alicorn, () -> PMAPI.alicornSmall),
ZEBRA("zebra", "slimzebra", () -> PMAPI.zebra, () -> PMAPI.zebraSmall), ZEBRA("zebra", "slimzebra", () -> PMAPI.zebra, () -> PMAPI.zebraSmall),
SEAPONY("seapony", "slimseapony", () -> PMAPI.seapony, () -> PMAPI.seapony) { SEAPONY("seapony", "slimseapony", () -> PMAPI.seapony, () -> PMAPI.seapony) {
@Override
public RenderPonyPlayer createRenderer(RenderManager manager, boolean slimArms) { public RenderPonyPlayer createRenderer(RenderManager manager, boolean slimArms) {
return new RenderSeaponyPlayer(manager, slimArms, PlayerModels.UNICORN.getModel(slimArms), getModel(slimArms)); return new RenderSeaponyPlayer(manager, slimArms, PlayerModels.UNICORN.getModel(slimArms), getModel(slimArms));
} }

View file

@ -26,14 +26,14 @@ public class ModelBreezie extends ModelBiped {
bipedHeadwear.showModel = false; bipedHeadwear.showModel = false;
bipedHead = new PonyRenderer(this) bipedHead = new PonyRenderer(this)
.child(new PonyRenderer(this) .child(new PonyRenderer(this)
.addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4) .addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4)
.tex(28, 0).addBox( 2, -7, 1, 1, 1, 1) .tex(28, 0).addBox( 2, -7, 1, 1, 1, 1)
.tex(24, 0).addBox(-3, -7, 1, 1, 1, 1) .tex(24, 0).addBox(-3, -7, 1, 1, 1, 1)
.tex(24, 9).addBox(-1, -2, -4, 2, 2, 1)) .tex(24, 9).addBox(-1, -2, -4, 2, 2, 1))
.child(new PonyRenderer(this) .child(new PonyRenderer(this)
.tex(28, 2).addBox( 1, -11, -2, 1, 6, 1) .tex(28, 2).addBox( 1, -11, -2, 1, 6, 1)
.tex(24, 2).addBox(-2, -11, -2, 1, 6, 1) .tex(24, 2).addBox(-2, -11, -2, 1, 6, 1)
.rotate(-0.2617994F, 0, 0)); .rotate(-0.2617994F, 0, 0));
bipedBody = new PonyRenderer(this, 2, 12) bipedBody = new PonyRenderer(this, 2, 12)
.addBox(0, 0, 0, 6, 7, 14).rotate(-0.5235988F, 0, 0).around(-3, 1, -3); .addBox(0, 0, 0, 6, 7, 14).rotate(-0.5235988F, 0, 0).around(-3, 1, -3);
@ -93,8 +93,8 @@ public class ModelBreezie extends ModelBiped {
bipedLeftArm.rotateAngleX += -PI / 5; bipedLeftArm.rotateAngleX += -PI / 5;
bipedRightArm.rotateAngleX += -PI / 5; bipedRightArm.rotateAngleX += -PI / 5;
rotateLegRiding(((PonyRenderer)bipedLeftLeg), -1); rotateLegRiding((PonyRenderer)bipedLeftLeg, -1);
rotateLegRiding(((PonyRenderer)bipedRightLeg), 1); rotateLegRiding((PonyRenderer)bipedRightLeg, 1);
} }
rotateArm(bipedLeftArm, leftArmPose, 1); rotateArm(bipedLeftArm, leftArmPose, 1);
@ -160,7 +160,7 @@ public class ModelBreezie extends ModelBiped {
arm.rotateAngleY = 0; arm.rotateAngleY = 0;
break; break;
case ITEM: case ITEM:
arm.rotateAngleX = arm.rotateAngleX / 2 - (PI / 10); arm.rotateAngleX = arm.rotateAngleX / 2 - PI / 10;
arm.rotateAngleY = 0; arm.rotateAngleY = 0;
case BLOCK: case BLOCK:
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F;
@ -171,10 +171,10 @@ public class ModelBreezie extends ModelBiped {
} }
protected void raiseArm(ModelRenderer up, ModelRenderer down, float factor) { protected void raiseArm(ModelRenderer up, ModelRenderer down, float factor) {
up.rotateAngleY = bipedHead.rotateAngleY + (factor / 10); up.rotateAngleY = bipedHead.rotateAngleY + factor / 10;
up.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); up.rotateAngleX = bipedHead.rotateAngleX - PI / 2;
down.rotateAngleY = bipedHead.rotateAngleY - (factor / 2); down.rotateAngleY = bipedHead.rotateAngleY - factor / 2;
down.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); down.rotateAngleX = bipedHead.rotateAngleX - PI / 2;
} }
} }

View file

@ -10,7 +10,9 @@ public class ModelZombiePony extends ModelMobPony {
@Override @Override
protected void rotateLegs(float move, float swing, float ticks, Entity entity) { protected void rotateLegs(float move, float swing, float ticks, Entity entity) {
super.rotateLegs(move, swing, ticks, entity); super.rotateLegs(move, swing, ticks, entity);
if (rightArmPose != ArmPose.EMPTY) return; if (rightArmPose != ArmPose.EMPTY) {
return;
}
if (islookAngleRight(move)) { if (islookAngleRight(move)) {
rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); rotateArmHolding(bipedRightArm, 1, swingProgress, ticks);

View file

@ -20,9 +20,11 @@ public interface ITriggerPixelMapped<T extends Enum<T> & ITriggerPixelMapped<T>>
* @param pixelValue The pixel colour to search for. * @param pixelValue The pixel colour to search for.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T extends Enum<T> & ITriggerPixelMapped<T>> T getByTriggerPixel(T type, int pixelValue) { static <T extends Enum<T> & ITriggerPixelMapped<T>> T getByTriggerPixel(T type, int pixelValue) {
for (T i : (T[])type.getClass().getEnumConstants()) { for (T i : (T[])type.getClass().getEnumConstants()) {
if (i.getTriggerPixel() == pixelValue) return i; if (i.getTriggerPixel() == pixelValue) {
return i;
}
} }
return type; return type;
} }

View file

@ -49,7 +49,9 @@ public class Pony {
private IPonyData checkSkin(ResourceLocation resource) { private IPonyData checkSkin(ResourceLocation resource) {
IPonyData data = checkPonyMeta(resource); IPonyData data = checkPonyMeta(resource);
if (data != null) return data; if (data != null) {
return data;
}
BufferedImage skinImage = getBufferedImage(resource); BufferedImage skinImage = getBufferedImage(resource);
return this.checkSkin(skinImage); return this.checkSkin(skinImage);
@ -99,7 +101,9 @@ public class Pony {
} }
private IPonyData checkSkin(BufferedImage bufferedimage) { private IPonyData checkSkin(BufferedImage bufferedimage) {
if (bufferedimage == null) return new PonyData(); if (bufferedimage == null) {
return new PonyData();
}
MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage); MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage);
return PonyData.parse(bufferedimage); return PonyData.parse(bufferedimage);
} }

View file

@ -10,6 +10,6 @@ public enum PonyLevel {
if (index < 0) { if (index < 0) {
index = 0; index = 0;
} }
return values[(int)Math.round(index) % values.length]; return values[Math.round(index) % values.length];
} }
} }

View file

@ -67,7 +67,9 @@ public enum PonyRace implements ITriggerPixelMapped<PonyRace> {
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't. * PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
*/ */
public PonyRace getEffectiveRace(PonyLevel level) { public PonyRace getEffectiveRace(PonyLevel level) {
if (level == PonyLevel.HUMANS) return HUMAN; if (level == PonyLevel.HUMANS) {
return HUMAN;
}
return this; return this;
} }

View file

@ -20,10 +20,12 @@ public enum PonyWearable implements ITriggerPixelMapped<PonyWearable> {
} }
public static PonyWearable[] flags(boolean[] flags) { public static PonyWearable[] flags(boolean[] flags) {
List<PonyWearable> wears = new ArrayList<PonyWearable>(); List<PonyWearable> wears = new ArrayList<>();
PonyWearable[] values = values(); PonyWearable[] values = values();
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (flags[i]) wears.add(values[i]); if (flags[i]) {
wears.add(values[i]);
}
} }
return wears.toArray(new PonyWearable[wears.size()]); return wears.toArray(new PonyWearable[wears.size()]);
} }

View file

@ -61,7 +61,9 @@ public enum TriggerPixels {
private <T extends Enum<T> & ITriggerPixelMapped<T>> void readFlag(boolean[] out, Channel channel, BufferedImage image) { private <T extends Enum<T> & ITriggerPixelMapped<T>> void readFlag(boolean[] out, Channel channel, BufferedImage image) {
T value = ITriggerPixelMapped.getByTriggerPixel((T)def, channel.readValue(x, y, image)); T value = ITriggerPixelMapped.getByTriggerPixel((T)def, channel.readValue(x, y, image));
if (value != def) out[value.ordinal()] = true; if (value != def) {
out[value.ordinal()] = true;
}
} }
enum Channel { enum Channel {

View file

@ -50,12 +50,12 @@ public class HornGlow extends Box<HornGlowRenderer> {
Vertex wun = vert(xMin, yMax, zMax, 8, 0); Vertex wun = vert(xMin, yMax, zMax, 8, 0);
quadList = new Quad[] { quadList = new Quad[] {
quad(texX + d + w, d, texY + d, h, edn, eds, eus, eun), quad(texX + d + w, d, texY + d, h, edn, eds, eus, eun),
quad(texX, d, texY + d, h, wds, wdn, wun, wus), quad(texX, d, texY + d, h, wds, wdn, wun, wus),
quad(texX + d, w, texY, d, edn, wdn, wds, eds), quad(texX + d, w, texY, d, edn, wdn, wds, eds),
quad(texX + d + w, w, texY + d, -d, eus, wus, wun, eun), quad(texX + d + w, w, texY + d, -d, eus, wus, wun, eun),
quad(texX + d, w, texY + d, h, eds, wds, wus, eus), quad(texX + d, w, texY + d, h, eds, wds, wus, eus),
quad(texX + d + w + d, w, texY + d, h, wdn, edn, eun, wun) quad(texX + d + w + d, w, texY + d, h, wdn, edn, eun, wun)
}; };
if (renderer.mirror) { if (renderer.mirror) {

View file

@ -27,7 +27,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
public static PonySkullRenderer ponyInstance = new PonySkullRenderer(); public static PonySkullRenderer ponyInstance = new PonySkullRenderer();
private static TileEntitySkullRenderer backup = null; private static TileEntitySkullRenderer backup = null;
private static final Map<Integer, ISkull> skullMap = new HashMap<Integer, ISkull>(); private static final Map<Integer, ISkull> skullMap = new HashMap<>();
/** /**
* Resolves the games skull renderer to either a specialised pony skull renderer * Resolves the games skull renderer to either a specialised pony skull renderer
@ -43,7 +43,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
instance = ponyInstance; instance = ponyInstance;
} }
} else { } else {
if ((instance instanceof PonySkullRenderer)) { if (instance instanceof PonySkullRenderer) {
ponyInstance = (PonySkullRenderer)instance; ponyInstance = (PonySkullRenderer)instance;
if (backup == null) { if (backup == null) {
backup = new TileEntitySkullRenderer(); backup = new TileEntitySkullRenderer();
@ -150,12 +150,12 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
*/ */
public interface ISkull { public interface ISkull {
public static final int SKELETON = 0; int SKELETON = 0;
public static final int WITHER = 1; int WITHER = 1;
public static final int ZOMBIE = 2; int ZOMBIE = 2;
public static final int PLAYER = 3; int PLAYER = 3;
public static final int CREEPER = 4; int CREEPER = 4;
public static final int DRAGON = 5; int DRAGON = 5;
void preRender(boolean transparency); void preRender(boolean transparency);

View file

@ -48,7 +48,9 @@ public class RenderPony<T extends EntityLivingBase> {
return PonyPosture.ELYTRA; return PonyPosture.ELYTRA;
} }
if (entity.isEntityAlive() && entity.isPlayerSleeping()) return null; if (entity.isEntityAlive() && entity.isPlayerSleeping()) {
return null;
}
if (ponyModel.isSwimming()) { if (ponyModel.isSwimming()) {
return PonyPosture.SWIMMING; return PonyPosture.SWIMMING;

View file

@ -24,7 +24,7 @@ import javax.annotation.Nonnull;
// and is the whole reason we had this scaling bug in the first place. // and is the whole reason we had this scaling bug in the first place.
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> { public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> {
protected final RenderPony<T> renderPony = new RenderPony<T>(this); protected final RenderPony<T> renderPony = new RenderPony<>(this);
public RenderPonyMob(RenderManager manager, ModelWrapper model) { public RenderPonyMob(RenderManager manager, ModelWrapper model) {
super(manager, model.getBody(), 0.5F); super(manager, model.getBody(), 0.5F);

View file

@ -42,18 +42,24 @@ public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> {
float motionYaw = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * scale; float motionYaw = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * scale;
double sin = MathHelper.sin(motionYaw * PI / 180); double sin = MathHelper.sin(motionYaw * PI / 180);
double cos = (-MathHelper.cos(motionYaw * PI / 180)); double cos = -MathHelper.cos(motionYaw * PI / 180);
float capeMotionY = (float) capeY * 10; float capeMotionY = (float) capeY * 10;
if (capeMotionY < -6) capeMotionY = -6; if (capeMotionY < -6) {
if (capeMotionY > 32) capeMotionY = 32; capeMotionY = -6;
}
if (capeMotionY > 32) {
capeMotionY = 32;
}
float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100; float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100;
float diagMotion = (float) (capeX * cos - capeZ * sin) * 100; float diagMotion = (float) (capeX * cos - capeZ * sin) * 100;
if (capeMotionX < 0) capeMotionX = 0; if (capeMotionX < 0) {
capeMotionX = 0;
}
float camera = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * scale; float camera = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * scale;
capeMotionY += MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * scale) * 6) * 32 * camera; capeMotionY += MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * scale) * 6) * 32 * camera;

View file

@ -58,13 +58,17 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
if (player.isPlayerInfoSet()) { if (player.isPlayerInfoSet()) {
result = player.getLocationElytra(); result = player.getLocationElytra();
if (result != null) return result; if (result != null) {
return result;
}
} }
if (player.hasPlayerInfo() && player.isWearing(EnumPlayerModelParts.CAPE)) { if (player.hasPlayerInfo() && player.isWearing(EnumPlayerModelParts.CAPE)) {
result = player.getLocationCape(); result = player.getLocationCape();
if (result != null) return result; if (result != null) {
return result;
}
} }
} }

View file

@ -77,6 +77,8 @@ public class ModelPlane extends Box<PlaneRenderer> {
@Override @Override
public void render(@Nonnull BufferBuilder buffer, float scale) { public void render(@Nonnull BufferBuilder buffer, float scale) {
if (!hidden) quad.draw(buffer, scale); if (!hidden) {
quad.draw(buffer, scale);
}
} }
} }

View file

@ -41,6 +41,7 @@ public class RenderPonyGuardian extends RenderGuardian {
ponyRenderer.preRenderCallback(entity, ticks); ponyRenderer.preRenderCallback(entity, ticks);
} }
@Override
public void doRender(EntityGuardian entity, double x, double y, double z, float entityYaw, float partialTicks) { public void doRender(EntityGuardian entity, double x, double y, double z, float entityYaw, float partialTicks) {
float origin = entity.height; float origin = entity.height;

View file

@ -61,21 +61,21 @@ public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob
public static class Giant extends RenderPonyMob<EntityGiantZombie> { public static class Giant extends RenderPonyMob<EntityGiantZombie> {
public Giant(RenderManager manager) { public Giant(RenderManager manager) {
super(manager, PMAPI.zombie); super(manager, PMAPI.zombie);
} }
@Override @Override
public void preRenderCallback(EntityGiantZombie entity, float ticks) { public void preRenderCallback(EntityGiantZombie entity, float ticks) {
super.preRenderCallback(entity, ticks); super.preRenderCallback(entity, ticks);
GlStateManager.scale(3, 3, 3); GlStateManager.scale(3, 3, 3);
} }
@Override @Override
protected ResourceLocation getTexture(EntityGiantZombie entity) { protected ResourceLocation getTexture(EntityGiantZombie entity) {
return ZOMBIE; return ZOMBIE;
} }
} }
//TODO: MC1.13 EntityDrowned //TODO: MC1.13 EntityDrowned
} }

View file

@ -11,11 +11,15 @@ public enum PonyTransformation {
NORMAL { NORMAL {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part) {
if (model.isSleeping()) translate(0, -0.61F, 0); if (model.isSleeping()) {
translate(0, -0.61F, 0);
}
switch (part) { switch (part) {
case NECK: case NECK:
if (model.isCrouching()) translate(-0.03F, 0.03F, 0.1F); if (model.isCrouching()) {
translate(-0.03F, 0.03F, 0.1F);
}
default: default:
} }
} }
@ -23,17 +27,25 @@ public enum PonyTransformation {
LARGE { LARGE {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part) {
if (model.isSleeping()) translate(0, -0.98F, 0.2F); if (model.isSleeping()) {
translate(0, -0.98F, 0.2F);
}
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, -0.15F, -0.07F); translate(0, -0.15F, -0.07F);
if (model.isCrouching()) translate(-0.03F, 0.16F, 0.07F); if (model.isCrouching()) {
translate(-0.03F, 0.16F, 0.07F);
}
break; break;
case HEAD: case HEAD:
translate(0, -0.17F, -0.04F); translate(0, -0.17F, -0.04F);
if (model.isSleeping()) translate(0, 0, -0.1F); if (model.isSleeping()) {
if (model.isCrouching()) translate(0, 0.15F, 0); translate(0, 0, -0.1F);
}
if (model.isCrouching()) {
translate(0, 0.15F, 0);
}
break; break;
case BODY: case BODY:
translate(0, -0.2F, -0.04F); translate(0, -0.2F, -0.04F);
@ -52,16 +64,24 @@ public enum PonyTransformation {
FOAL { FOAL {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.3F, 0); if (model.isCrouching()) {
if (model.isSleeping()) translate(0, -0.6F, -0.5F); translate(0, -0.3F, 0);
if (model.isRiding()) translate(0, -0.4F, 0); }
if (model.isSleeping()) {
translate(0, -0.6F, -0.5F);
}
if (model.isRiding()) {
translate(0, -0.4F, 0);
}
translate(0, 0.2F, 0); translate(0, 0.2F, 0);
switch (part) { switch (part) {
case NECK: case NECK:
scale(1.3F, 1.3F, 1.3F); scale(1.3F, 1.3F, 1.3F);
if (model.isCrouching()) translate(0, -0.01F, 0.15F); if (model.isCrouching()) {
translate(0, -0.01F, 0.15F);
}
break; break;
case HEAD: case HEAD:
scale(1.3F, 1.3F, 1.3F); scale(1.3F, 1.3F, 1.3F);
@ -77,17 +97,23 @@ public enum PonyTransformation {
TALL { TALL {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part) {
if (model.isSleeping()) translate(0, -0.5F, 0.25F); if (model.isSleeping()) {
translate(0, -0.5F, 0.25F);
}
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, -0.09F, -0.01F); translate(0, -0.09F, -0.01F);
scale(1, 1.1F, 1); scale(1, 1.1F, 1);
if (model.isCrouching()) translate(-0.02F, -0.02F, 0.1F); if (model.isCrouching()) {
translate(-0.02F, -0.02F, 0.1F);
}
break; break;
case HEAD: case HEAD:
translate(0, -0.15F, 0.01F); translate(0, -0.15F, 0.01F);
if (model.isCrouching()) translate(0, 0.05F, 0); if (model.isCrouching()) {
translate(0, 0.05F, 0);
}
break; break;
case BODY: case BODY:
translate(0, -0.1F, 0); translate(0, -0.1F, 0);
@ -98,7 +124,9 @@ public enum PonyTransformation {
case LEGS: case LEGS:
translate(0, -0.25F, 0.03F); translate(0, -0.25F, 0.03F);
scale(1, 1.18F, 1); scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0); if (model.isGoingFast()) {
translate(0, 0.05F, 0);
}
break; break;
} }
} }

View file

@ -61,6 +61,6 @@ public class PostureFlight implements PonyPosture<AbstractClientPlayer> {
roll = model.getMetadata().getInterpolator().interpolate("pegasusRoll", roll, 10); roll = model.getMetadata().getInterpolator().interpolate("pegasusRoll", roll, 10);
GlStateManager.rotate((float)roll, 0, 0, 1); GlStateManager.rotate(roll, 0, 0, 1);
} }
} }

View file

@ -3,19 +3,19 @@ package com.minelittlepony.util.coordinates;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
public interface Color { public interface Color {
public static float r(int color) { static float r(int color) {
return (color >> 16 & 255) / 255F; return (color >> 16 & 255) / 255F;
} }
public static float g(int color) { static float g(int color) {
return (color >> 8 & 255) / 255F; return (color >> 8 & 255) / 255F;
} }
public static float b(int color) { static float b(int color) {
return (color & 255) / 255F; return (color & 255) / 255F;
} }
public static void glColor(int color, float alpha) { static void glColor(int color, float alpha) {
GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha); GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha);
} }
} }

View file

@ -14,6 +14,7 @@ public class Vertex extends PositionTextureVertex {
// The MCP name is misleading. // The MCP name is misleading.
// This is meant to return a COPY with the given texture position // This is meant to return a COPY with the given texture position
@Override
public Vertex setTexturePosition(float texX, float texY) { public Vertex setTexturePosition(float texX, float texY) {
return new Vertex(this, texX, texY); return new Vertex(this, texX, texY);
} }

View file

@ -11,8 +11,12 @@ public class MathUtil {
public static float sensibleAngle(float angle) { public static float sensibleAngle(float angle) {
angle %= 360; angle %= 360;
if (angle > 180) angle -= 360; if (angle > 180) {
if (angle < -180) angle += 360; angle -= 360;
}
if (angle < -180) {
angle += 360;
}
return angle; return angle;
} }