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

View file

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

View file

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

View file

@ -34,19 +34,19 @@ public class PreviewTextureManager {
IImageBuffer buffer = new ImageBufferDownloadHD();
PreviewTexture skinTexture = new PreviewTexture(texture.getMetadata("model"), texture.getUrl(), def,
type == MinecraftProfileTexture.Type.SKIN ? new IImageBuffer() {
@Override
@Nullable
public BufferedImage parseUserSkin(BufferedImage image) {
return buffer.parseUserSkin(image);
}
@Override
@Nullable
public BufferedImage parseUserSkin(BufferedImage image) {
return buffer.parseUserSkin(image);
}
@Override
public void skinAvailable() {
if (callback != null) {
callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap()));
}
}
} : null);
@Override
public void skinAvailable() {
if (callback != null) {
callback.skinAvailable(type, location, new MinecraftProfileTexture(texture.getUrl(), Maps.newHashMap()));
}
}
} : null);
Minecraft.getMinecraft().getTextureManager().loadTexture(location, 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) {
super(defLocation);
this.cacheFile = cacheFileIn;
this.eTagFile = new File(cacheFile.getParentFile(), cacheFile.getName() + ".etag");
this.imageUrl = imageUrlIn;
this.imageBuffer = imageBufferIn;
cacheFile = cacheFileIn;
eTagFile = new File(cacheFile.getParentFile(), cacheFile.getName() + ".etag");
imageUrl = imageUrlIn;
imageBuffer = imageBufferIn;
}
private void checkTextureUploaded() {
if (!this.textureUploaded) {
if (this.bufferedImage != null) {
if (this.textureLocation != null) {
this.deleteGlTexture();
if (!textureUploaded) {
if (bufferedImage != null) {
if (textureLocation != null) {
deleteGlTexture();
}
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
this.textureUploaded = true;
TextureUtil.uploadTextureImage(super.getGlTextureId(), bufferedImage);
textureUploaded = true;
}
}
}
@Override
public int getGlTextureId() {
this.checkTextureUploaded();
checkTextureUploaded();
return super.getGlTextureId();
}
private void setBufferedImage(@Nonnull BufferedImage bufferedImageIn) {
this.bufferedImage = bufferedImageIn;
bufferedImage = bufferedImageIn;
if (this.imageBuffer != null) {
this.imageBuffer.skinAvailable();
if (imageBuffer != null) {
imageBuffer.skinAvailable();
}
}
@ -84,15 +85,16 @@ public class ThreadDownloadImageETag extends SimpleTexture {
return bufferedImage;
}
@Override
public void loadTexture(IResourceManager resourceManager) throws IOException {
if (this.bufferedImage == null && this.textureLocation != null) {
if (bufferedImage == null && textureLocation != null) {
super.loadTexture(resourceManager);
}
if (this.imageThread == null) {
this.imageThread = new Thread(this::loadTexture, "Texture Downloader #" + THREAD_ID.incrementAndGet());
this.imageThread.setDaemon(true);
this.imageThread.start();
if (imageThread == null) {
imageThread = new Thread(this::loadTexture, "Texture Downloader #" + THREAD_ID.incrementAndGet());
imageThread.setDaemon(true);
imageThread.start();
}
}
@ -133,8 +135,9 @@ public class ThreadDownloadImageETag extends SimpleTexture {
}
LOGGER.error("Couldn't load skin {} ", imageUrl, e);
} finally {
if (response != null)
if (response != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
}
}
@ -149,8 +152,8 @@ public class ThreadDownloadImageETag extends SimpleTexture {
}
private void clearCache() {
FileUtils.deleteQuietly(this.cacheFile);
FileUtils.deleteQuietly(this.eTagFile);
FileUtils.deleteQuietly(cacheFile);
FileUtils.deleteQuietly(eTagFile);
}
private boolean checkETag(HttpResponse response) {

View file

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

View file

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

View file

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

View file

@ -5,7 +5,6 @@ import com.voxelmodpack.hdskins.upload.awt.FileDropper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.DefaultResourcePack;
import net.minecraft.launchwrapper.injector.VanillaTweakInjector;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
@ -21,7 +20,6 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.TooManyListenersException;
@ -112,7 +110,7 @@ public class GLWindow extends DropTarget {
@Override
public void windowClosed(WindowEvent windowEvent) {
if (!closeRequested) {
for (Window w : Frame.getWindows()) {
for (Window w : Window.getWindows()) {
w.dispose();
}
@ -174,7 +172,7 @@ public class GLWindow extends DropTarget {
if (isFullscreen) {
Display.setFullscreen(true);
} else {
if ((windowState & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH) {
if ((windowState & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
Display.setLocation(0, 0);
Display.setDisplayMode(Display.getDesktopDisplayMode());
} else {
@ -193,7 +191,7 @@ public class GLWindow extends DropTarget {
frame.setVisible(false);
frame.dispose();
for (Window w : Frame.getWindows()) {
for (Window w : Window.getWindows()) {
w.dispose();
}
@ -213,7 +211,7 @@ public class GLWindow extends DropTarget {
ArrayList<Image> images = Lists.newArrayList(
ImageIO.read(pack.getInputStreamAssets(new ResourceLocation("icons/icon_16x16.png"))),
ImageIO.read(pack.getInputStreamAssets(new ResourceLocation("icons/icon_32x32.png")))
);
);
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) {
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
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");
this.checkbox = new GuiCheckbox(1, 40, 40, "Experimental Skin Drop");
button = new GuiButton(0, 40, 70, 100, 20, "Clear Skin Cache");
checkbox = new GuiCheckbox(1, 40, 40, "Experimental Skin Drop");
this.checkbox.checked = mod.experimentalSkinDrop;
checkbox.checked = mod.experimentalSkinDrop;
}
@Override
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
this.button.drawButton(mc, mouseX, mouseY, partialTicks);
this.checkbox.drawButton(mc, mouseX, mouseY, partialTicks);
button.drawButton(mc, mouseX, mouseY, partialTicks);
checkbox.drawButton(mc, mouseX, mouseY, partialTicks);
}
@Override

View file

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

View file

@ -21,13 +21,13 @@ public class MixinGuiMainMenu extends GuiScreen {
private void onInit(CallbackInfo ci) {
ItemStack itemStack = new ItemStack(Items.LEATHER_LEGGINGS);
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"))
private void onActionPerformed(GuiButton button, CallbackInfo ci) {
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(
method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;",
at = @At("RETURN"),
cancellable = true)
cancellable = true)
private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) {
// convert skins from mojang server
BufferedImage image2 = ci.getReturnValue();

View file

@ -57,8 +57,9 @@ public abstract class MixinPlayerInfo {
MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN);
if (skin != null) {
String type = skin.getMetadata("model");
if (type == null)
if (type == null) {
type = "default";
}
String type1 = type;
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",
ordinal = 4))
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) {
Optional<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true);
if (skin.isPresent())
if (skin.isPresent()) {
// rebind
bindTexture(skin.get());
else
} else {
bindTexture(rl);
} else
}
} else {
bindTexture(rl);
}
}
}

View file

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

View file

@ -75,9 +75,10 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
@Nullable
public ResourceLocation getPlayerTexture(GameProfile profile, Type type) {
if (type != Type.SKIN)
if (type != Type.SKIN) {
// not supported
return null;
}
Skin skin = getSkin(profile);
if (skin != null) {
@ -102,11 +103,11 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
private void loadSkinResource(@Nullable final ResourceLocation res) {
if (res != null) {
// 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) -> {
if (loc != null)
if (loc != null) {
converted.put(res, loc);
else {
} else {
LogManager.getLogger().warn("Errored while processing {}. Using original.", res, t);
converted.put(res, res);
}
@ -119,9 +120,9 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
@Nullable
private Skin getSkin(GameProfile profile) {
Skin skin = this.uuidSkins.get(profile.getId());
Skin skin = uuidSkins.get(profile.getId());
if (skin == null) {
skin = this.namedSkins.get(profile.getName());
skin = namedSkins.get(profile.getName());
}
return skin;
}

View file

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

View file

@ -46,7 +46,7 @@ public class LegacySkinServer implements SkinServer {
@Override
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getPreviewTextures(GameProfile profile) {
if (Strings.isNullOrEmpty(this.gateway)) {
if (Strings.isNullOrEmpty(gateway)) {
return Collections.emptyMap();
}
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();
for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) {
String url = getPath(this.address, type, profile);
String url = getPath(address, type, profile);
try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
if (urlConnection.getResponseCode() / 100 != 2) {
@ -76,7 +76,7 @@ public class LegacySkinServer implements SkinServer {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = builder.build();
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();
}
@ -86,7 +86,7 @@ public class LegacySkinServer implements SkinServer {
@SuppressWarnings("deprecation")
@Override
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"));
}
@ -94,13 +94,14 @@ public class LegacySkinServer implements SkinServer {
SkinServer.verifyServerConnection(session, SERVER_ID);
String model = metadata.getOrDefault("model", "default");
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();
if (response.startsWith("ERROR: ")) {
response = response.substring(7);
}
if (!response.equalsIgnoreCase("OK") && !response.endsWith("OK"))
if (!response.equalsIgnoreCase("OK") && !response.endsWith("OK")) {
throw new IOException(response);
}
return new SkinUploadResponse(response);
}, HDSkinManager.skinUploadExecutor);
@ -132,8 +133,8 @@ public class LegacySkinServer implements SkinServer {
@Override
public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE)
.append("address", this.address)
.append("gateway", this.gateway)
.append("address", address)
.append("gateway", gateway)
.build();
}
}

View file

@ -26,7 +26,7 @@ import javax.annotation.Nullable;
public interface SkinServer extends Exposable {
static final Gson gson = new GsonBuilder()
Gson gson = new GsonBuilder()
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
.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);
public static void verifyServerConnection(Session session, String serverId) throws AuthenticationException {
static void verifyServerConnection(Session session, String serverId) throws AuthenticationException {
MinecraftSessionService service = Minecraft.getMinecraft().getSessionService();
service.joinServer(session.getProfile(), session.getToken(), serverId);
}

View file

@ -1,6 +1,5 @@
package com.voxelmodpack.hdskins.skins;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
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,
MinecraftProfileTexture.Type type, Map<String, String> metadata)
throws IOException {
throws IOException {
GameProfile profile = session.getProfile();
if (image == null) {
@ -111,7 +111,7 @@ public class ValhallaSkinServer implements SkinServer {
private SkinUploadResponse resetSkin(CloseableHttpClient client, GameProfile profile, MinecraftProfileTexture.Type type) throws IOException {
return upload(client, RequestBuilder.delete()
.setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken)
.addHeader(HttpHeaders.AUTHORIZATION, accessToken)
.build());
}
@ -122,7 +122,7 @@ public class ValhallaSkinServer implements SkinServer {
return upload(client, RequestBuilder.put()
.setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken)
.addHeader(HttpHeaders.AUTHORIZATION, accessToken)
.setEntity(b.build())
.build());
}
@ -131,7 +131,7 @@ public class ValhallaSkinServer implements SkinServer {
return upload(client, RequestBuilder.post()
.setUri(buildUserTextureUri(profile, type))
.addHeader(HttpHeaders.AUTHORIZATION, this.accessToken)
.addHeader(HttpHeaders.AUTHORIZATION, accessToken)
.addParameter("file", uri.toString())
.addParameters(metadata.entrySet().stream()
.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 {
if (this.accessToken != null) {
if (accessToken != null) {
return;
}
GameProfile profile = session.getProfile();
@ -165,7 +165,7 @@ public class ValhallaSkinServer implements SkinServer {
if (!response.userId.equals(profile.getId())) {
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 {
@ -208,26 +208,26 @@ public class ValhallaSkinServer implements SkinServer {
private URI buildUserTextureUri(GameProfile profile, MinecraftProfileTexture.Type textureType) {
String user = UUIDTypeAdapter.fromUUID(profile.getId());
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) {
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() {
return URI.create(String.format("%s/auth/handshake", this.address));
return URI.create(String.format("%s/auth/handshake", address));
}
private URI getResponseURI() {
return URI.create(String.format("%s/auth/response", this.address));
return URI.create(String.format("%s/auth/response", address));
}
@Override
public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE)
.append("address", this.address)
.append("address", address)
.toString();
}

View file

@ -45,7 +45,7 @@ public class ThreadMultipartPostUpload {
public ThreadMultipartPostUpload(String method, String url, Map<String, ?> sourceData, @Nullable String authorization) {
this.method = method;
this.urlString = url;
urlString = url;
this.sourceData = sourceData;
this.authorization = authorization;
}
@ -56,28 +56,28 @@ public class ThreadMultipartPostUpload {
public String uploadMultipart() throws IOException {
// open a URL connection
URL url = new URL(this.urlString);
URL url = new URL(urlString);
// Open a HTTP connection to the URL
this.httpClient = (HttpURLConnection) url.openConnection();
this.httpClient.setDoOutput(true);
this.httpClient.setUseCaches(false);
httpClient = (HttpURLConnection) url.openConnection();
httpClient.setDoOutput(true);
httpClient.setUseCaches(false);
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
httpClient.setRequestMethod(method);
httpClient.setRequestProperty("Connection", "Close");
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=" + boundary);
if (sourceData.size() > 0) {
httpClient.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
}
if (this.authorization != null) {
this.httpClient.addRequestProperty("Authorization", this.authorization);
if (authorization != null) {
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);
String paramName = data.getKey();
@ -103,7 +103,7 @@ public class ThreadMultipartPostUpload {
outputStream.writeBytes(twoHyphens + boundary + twoHyphens + CRLF);
}
try (InputStream input = this.httpClient.getInputStream()) {
try (InputStream input = httpClient.getInputStream()) {
return IOUtils.toString(input, StandardCharsets.UTF_8);
}
}

View file

@ -13,6 +13,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
public class FileDropper extends JFrame {
private static final long serialVersionUID = -2945117328826695659L;
@ -33,7 +34,7 @@ public class FileDropper extends JFrame {
super("Skin Drop");
setType(Type.UTILITY);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
setResizable(false);
setTitle("Skin Drop");
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!");
}
this.parentScreen = callback;
parentScreen = callback;
this.dialogTitle = dialogTitle;
}
@Override
public void run() {
fileDialog = new JFileChooser();
fileDialog.setDialogTitle(this.dialogTitle);
fileDialog.setDialogTitle(dialogTitle);
if (lastChosenFile != null) {
fileDialog.setSelectedFile(new File(lastChosenFile));
}
fileDialog.setFileFilter(this.getFileFilter());
fileDialog.setFileFilter(getFileFilter());
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
@ -53,7 +53,7 @@ public abstract class ThreadOpenFile extends Thread {
lastChosenFile = f.getAbsolutePath();
}
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
}
/**

View file

@ -31,8 +31,9 @@ public class ForgeProxy {
* @return
*/
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 def;
}
@ -45,8 +46,9 @@ public class ForgeProxy {
* @param def Default return value if no mods present
*/
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
if (forgeLoaded)
if (forgeLoaded) {
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
}
return def;
}
}

View file

@ -85,7 +85,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
ResourceLocation skin = player.getLocationSkin();
UUID uuid = player.getGameProfile().getId();
if (skin == null) return getDefaultPony(uuid);
if (skin == null) {
return getDefaultPony(uuid);
}
return getPony(skin, uuid);
}
@ -97,7 +99,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
ResourceLocation skin = playerInfo.getLocationSkin();
UUID uuid = playerInfo.getGameProfile().getId();
if (skin == null) return getDefaultPony(uuid);
if (skin == null) {
return getDefaultPony(uuid);
}
return getPony(skin, uuid);
}
@ -141,7 +145,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
}
int bgi = uuid.hashCode() % getNumberOfPonies();
while (bgi < 0) bgi += getNumberOfPonies();
while (bgi < 0) {
bgi += getNumberOfPonies();
}
return getPony(backgroundPonyList.get(bgi), false);
}
@ -163,7 +169,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
backgroundPonyList.clear();
try {
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);
if (ponies.override) {
backgroundPonyList.clear();

View file

@ -20,13 +20,15 @@ public class Label extends GuiButton {
super(0, x, y, "");
this.color = color;
this.center = center;
this.text = translationString;
text = translationString;
}
@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
return false;
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (center) {
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() {
return true;
}

View file

@ -29,8 +29,8 @@ public class GuiSkinsMineLP extends GuiSkins {
private static final String[] panoramas = new String[] {
"minelp:textures/cubemap/sugarcubecorner_%d.png",
"minelp:textures/cubemap/quillsandsofas_%d.png"
"minelp:textures/cubemap/sugarcubecorner_%d.png",
"minelp:textures/cubemap/quillsandsofas_%d.png"
};
@Override
@ -61,19 +61,19 @@ public class GuiSkinsMineLP extends GuiSkins {
protected void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == this.btnModeDry.id) {
this.isWet = false;
this.localPlayer.releaseTextures();
} else if (guiButton.id == this.btnModeWet.id) {
this.isWet = true;
this.localPlayer.releaseTextures();
if (guiButton.id == btnModeDry.id) {
isWet = false;
localPlayer.releaseTextures();
} else if (guiButton.id == btnModeWet.id) {
isWet = true;
localPlayer.releaseTextures();
}
btnModeDry.enabled = isWet;
btnModeWet.enabled = !isWet;
((EntityPonyModel)this.localPlayer).setWet(isWet);
((EntityPonyModel)this.remotePlayer).setWet(isWet);
((EntityPonyModel)localPlayer).setWet(isWet);
((EntityPonyModel)remotePlayer).setWet(isWet);
}
@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 renderItemSide(EntityLivingBase entitylivingbaseIn, ItemStack heldStack, ItemCameraTransforms.TransformType transform, boolean leftHanded)
@Redirect(method = "renderItemInFirstPerson(" + AbstractClientPlayer + "FF" + EnumHand + "F" + ItemStack + "F)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemSide(" + EntityLivingBase + ItemStack + TransformType + "Z)V"))
at = @At(value = "INVOKE",
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) {
MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left);
}

View file

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

View file

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

View file

@ -17,7 +17,7 @@ public interface IModelPegasus extends IModel {
default float getWingRotationFactor(float ticks) {
if (isSwimming()) {
return (MathHelper.sin(ticks * 0.136f) / 2) + ROTATE_270;
return MathHelper.sin(ticks * 0.136f) / 2 + ROTATE_270;
}
if (isFlying()) {
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) {
this.boxList.clear();
boxList.clear();
skeletonHead = new ModelRenderer(this, 24, 0);
skeletonHead.addBox(-9, -13, -1, 6, 6, 1, 0);

View file

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

View file

@ -39,6 +39,7 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
unicornArmLeft.rotateAngleY = 0;
}
@Override
protected float getWobbleAmount() {
if (isCasting()) {
return 0;
@ -87,7 +88,9 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
@Override
protected void swingArms(float ticks) {
if (isSleeping()) return;
if (isSleeping()) {
return;
}
if (canCast()) {
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),
ZEBRA("zebra", "slimzebra", () -> PMAPI.zebra, () -> PMAPI.zebraSmall),
SEAPONY("seapony", "slimseapony", () -> PMAPI.seapony, () -> PMAPI.seapony) {
@Override
public RenderPonyPlayer createRenderer(RenderManager manager, boolean 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;
bipedHead = new PonyRenderer(this)
.child(new PonyRenderer(this)
.addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4)
.tex(28, 0).addBox( 2, -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))
.addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4)
.tex(28, 0).addBox( 2, -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))
.child(new PonyRenderer(this)
.tex(28, 2).addBox( 1, -11, -2, 1, 6, 1)
.tex(24, 2).addBox(-2, -11, -2, 1, 6, 1)
.rotate(-0.2617994F, 0, 0));
.tex(28, 2).addBox( 1, -11, -2, 1, 6, 1)
.tex(24, 2).addBox(-2, -11, -2, 1, 6, 1)
.rotate(-0.2617994F, 0, 0));
bipedBody = new PonyRenderer(this, 2, 12)
.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;
bipedRightArm.rotateAngleX += -PI / 5;
rotateLegRiding(((PonyRenderer)bipedLeftLeg), -1);
rotateLegRiding(((PonyRenderer)bipedRightLeg), 1);
rotateLegRiding((PonyRenderer)bipedLeftLeg, -1);
rotateLegRiding((PonyRenderer)bipedRightLeg, 1);
}
rotateArm(bipedLeftArm, leftArmPose, 1);
@ -160,7 +160,7 @@ public class ModelBreezie extends ModelBiped {
arm.rotateAngleY = 0;
break;
case ITEM:
arm.rotateAngleX = arm.rotateAngleX / 2 - (PI / 10);
arm.rotateAngleX = arm.rotateAngleX / 2 - PI / 10;
arm.rotateAngleY = 0;
case BLOCK:
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) {
up.rotateAngleY = bipedHead.rotateAngleY + (factor / 10);
up.rotateAngleX = bipedHead.rotateAngleX - (PI / 2);
up.rotateAngleY = bipedHead.rotateAngleY + factor / 10;
up.rotateAngleX = bipedHead.rotateAngleX - PI / 2;
down.rotateAngleY = bipedHead.rotateAngleY - (factor / 2);
down.rotateAngleX = bipedHead.rotateAngleX - (PI / 2);
down.rotateAngleY = bipedHead.rotateAngleY - factor / 2;
down.rotateAngleX = bipedHead.rotateAngleX - PI / 2;
}
}

View file

@ -10,7 +10,9 @@ public class ModelZombiePony extends ModelMobPony {
@Override
protected void rotateLegs(float move, float swing, float ticks, Entity entity) {
super.rotateLegs(move, swing, ticks, entity);
if (rightArmPose != ArmPose.EMPTY) return;
if (rightArmPose != ArmPose.EMPTY) {
return;
}
if (islookAngleRight(move)) {
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.
*/
@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()) {
if (i.getTriggerPixel() == pixelValue) return i;
if (i.getTriggerPixel() == pixelValue) {
return i;
}
}
return type;
}

View file

@ -49,7 +49,9 @@ public class Pony {
private IPonyData checkSkin(ResourceLocation resource) {
IPonyData data = checkPonyMeta(resource);
if (data != null) return data;
if (data != null) {
return data;
}
BufferedImage skinImage = getBufferedImage(resource);
return this.checkSkin(skinImage);
@ -99,7 +101,9 @@ public class Pony {
}
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);
return PonyData.parse(bufferedimage);
}

View file

@ -10,6 +10,6 @@ public enum PonyLevel {
if (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.
*/
public PonyRace getEffectiveRace(PonyLevel level) {
if (level == PonyLevel.HUMANS) return HUMAN;
if (level == PonyLevel.HUMANS) {
return HUMAN;
}
return this;
}

View file

@ -20,10 +20,12 @@ public enum PonyWearable implements ITriggerPixelMapped<PonyWearable> {
}
public static PonyWearable[] flags(boolean[] flags) {
List<PonyWearable> wears = new ArrayList<PonyWearable>();
List<PonyWearable> wears = new ArrayList<>();
PonyWearable[] values = values();
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()]);
}

View file

@ -61,7 +61,9 @@ public enum TriggerPixels {
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));
if (value != def) out[value.ordinal()] = true;
if (value != def) {
out[value.ordinal()] = true;
}
}
enum Channel {

View file

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

View file

@ -27,7 +27,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
public static PonySkullRenderer ponyInstance = new PonySkullRenderer();
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
@ -43,7 +43,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
instance = ponyInstance;
}
} else {
if ((instance instanceof PonySkullRenderer)) {
if (instance instanceof PonySkullRenderer) {
ponyInstance = (PonySkullRenderer)instance;
if (backup == null) {
backup = new TileEntitySkullRenderer();
@ -150,12 +150,12 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
*/
public interface ISkull {
public static final int SKELETON = 0;
public static final int WITHER = 1;
public static final int ZOMBIE = 2;
public static final int PLAYER = 3;
public static final int CREEPER = 4;
public static final int DRAGON = 5;
int SKELETON = 0;
int WITHER = 1;
int ZOMBIE = 2;
int PLAYER = 3;
int CREEPER = 4;
int DRAGON = 5;
void preRender(boolean transparency);

View file

@ -48,7 +48,9 @@ public class RenderPony<T extends EntityLivingBase> {
return PonyPosture.ELYTRA;
}
if (entity.isEntityAlive() && entity.isPlayerSleeping()) return null;
if (entity.isEntityAlive() && entity.isPlayerSleeping()) {
return null;
}
if (ponyModel.isSwimming()) {
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.
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) {
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;
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;
if (capeMotionY < -6) capeMotionY = -6;
if (capeMotionY > 32) capeMotionY = 32;
if (capeMotionY < -6) {
capeMotionY = -6;
}
if (capeMotionY > 32) {
capeMotionY = 32;
}
float capeMotionX = (float) (capeX * sin + capeZ * cos) * 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;
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()) {
result = player.getLocationElytra();
if (result != null) return result;
if (result != null) {
return result;
}
}
if (player.hasPlayerInfo() && player.isWearing(EnumPlayerModelParts.CAPE)) {
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
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);
}
@Override
public void doRender(EntityGuardian entity, double x, double y, double z, float entityYaw, float partialTicks) {
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 Giant(RenderManager manager) {
super(manager, PMAPI.zombie);
}
public Giant(RenderManager manager) {
super(manager, PMAPI.zombie);
}
@Override
public void preRenderCallback(EntityGiantZombie entity, float ticks) {
super.preRenderCallback(entity, ticks);
GlStateManager.scale(3, 3, 3);
}
@Override
public void preRenderCallback(EntityGiantZombie entity, float ticks) {
super.preRenderCallback(entity, ticks);
GlStateManager.scale(3, 3, 3);
}
@Override
protected ResourceLocation getTexture(EntityGiantZombie entity) {
return ZOMBIE;
}
@Override
protected ResourceLocation getTexture(EntityGiantZombie entity) {
return ZOMBIE;
}
}
//TODO: MC1.13 EntityDrowned
//TODO: MC1.13 EntityDrowned
}

View file

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

View file

@ -61,6 +61,6 @@ public class PostureFlight implements PonyPosture<AbstractClientPlayer> {
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;
public interface Color {
public static float r(int color) {
static float r(int color) {
return (color >> 16 & 255) / 255F;
}
public static float g(int color) {
static float g(int color) {
return (color >> 8 & 255) / 255F;
}
public static float b(int color) {
static float b(int color) {
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);
}
}

View file

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

View file

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