diff --git a/.gitignore b/.gitignore index c52f7d5f..ac2f12d4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ run/ .factorypath logs/ .idea/ +*.iml classes/ +out/ diff --git a/build.gradle b/build.gradle index be293bdc..a23ba919 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT' } } @@ -20,34 +20,31 @@ apply plugin: 'net.minecraftforge.gradle.liteloader' apply plugin: 'org.spongepowered.mixin' group = 'com.minelittlepony' -version = '1.11.2.3' +version = '1.12_0' description = 'Mine Little Pony' targetCompatibility = 1.8 sourceCompatibility = 1.8 minecraft { - version = "1.11.2" - mappings = 'snapshot_20161224' + version = "1.12" + mappings = 'snapshot_20170611' runDir = 'run' replace '@VERSION@', project.version } sourceSets { - def deps = [ - configurations.forgeGradleMcDeps, - configurations.forgeGradleMc, - configurations.compile, - ] hdskins { - compileClasspath += files deps - refMap = 'mixin.hdskins.refmap.json' + compileClasspath += main.compileClasspath } main { - refMap = 'mixin.minelp.refmap.json' compileClasspath += hdskins.output } +} +mixin { + add sourceSets.main, 'mixin.minelp.refmap.json' + add sourceSets.hdskins, 'mixin.hdskins.refmap.json' } litemod.json { diff --git a/build.number b/build.number index 8e630431..82aa30bc 100644 --- a/build.number +++ b/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Tue Mar 28 02:04:51 EDT 2017 -build.number=312 +#Tue Jun 13 01:29:43 EDT 2017 +build.number=344 diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 738c86ed..28a009f7 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -232,9 +232,10 @@ public final class HDSkinManager implements IResourceManagerReloadListener { skinModifiers.add(modifier); } - @Nullable + @Nonnull public ResourceLocation getConvertedSkin(@Nullable ResourceLocation res) { - return resources.getConvertedResource(res); + ResourceLocation loc = resources.getConvertedResource(res); + return loc == null ? res : loc; } public void convertSkin(BufferedImage image, Graphics dest) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java index 305cd47e..9ae7c8cc 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java @@ -91,6 +91,7 @@ public class EntityPlayerModel extends EntityLivingBase { try { BufferedImage image = ImageIO.read(skinTextureFile); bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image); + assert bufferedImage != null; } catch (IOException var4) { this.localSkinResource = NO_SKIN; var4.printStackTrace(); @@ -127,7 +128,7 @@ public class EntityPlayerModel extends EntityLivingBase { return !this.remoteSkin && this.hasLocalTexture; } - @Override +// @Override TODO public float getBrightness(float par1) { return 1.0F; } @@ -188,9 +189,9 @@ public class EntityPlayerModel extends EntityLivingBase { return Minecraft.getMinecraft().gameSettings.mainHand; } - @Override +// @Override TODO public int getBrightnessForRender(float partialTicks) { - return 15728880; + return 0xf000f0; } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java index 187bca49..66cfe0b5 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java @@ -4,21 +4,20 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.item.ItemStack; -import javax.annotation.Nonnull; - public class GuiItemStackButton extends GuiButton { private ItemStack itemStack; - public GuiItemStackButton(int buttonId, int x, int y, @Nonnull ItemStack itemStack) { + public GuiItemStackButton(int buttonId, int x, int y, ItemStack itemStack) { super(buttonId, x, y, 20, 20, ""); this.itemStack = itemStack; } + // drawButton @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY) { - super.drawButton(mc, mouseX, mouseY); + public void func_191745_a(Minecraft mc, int mouseX, int mouseY, float partialTicks) { + super.func_191745_a(mc, mouseX, mouseY, partialTicks); - mc.getRenderItem().renderItemIntoGUI(itemStack, this.xPosition + 2, this.yPosition + 2); + mc.getRenderItem().renderItemIntoGUI(itemStack, this.x + 2, this.y + 2); } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java index 1d071cf6..5c6b346d 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java @@ -7,18 +7,16 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.voxelmodpack.hdskins.HDSkinManager; -import com.voxelmodpack.hdskins.upload.IUploadCompleteCallback; import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload; -import com.voxelmodpack.hdskins.upload.awt.IOpenFileCallback; import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -392,7 +390,7 @@ public class GuiSkins extends GuiScreen { blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); byte blendIterations = 8; Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer vb = tessellator.getBuffer(); + BufferBuilder vb = tessellator.getBuffer(); for (int blendPass = 0; blendPass < blendIterations * blendIterations; ++blendPass) { pushMatrix(); @@ -456,7 +454,7 @@ public class GuiSkins extends GuiScreen { blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); colorMask(true, true, true, false); Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer vb = tessellator.getBuffer(); + BufferBuilder vb = tessellator.getBuffer(); vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); byte blurPasses = 4; @@ -485,7 +483,7 @@ public class GuiSkins extends GuiScreen { viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer vb = tessellator.getBuffer(); + BufferBuilder vb = tessellator.getBuffer(); vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height; float uSample = this.height * aspect / 256.0F; @@ -540,10 +538,10 @@ public class GuiSkins extends GuiScreen { this.disableClipping(); - this.drawCenteredString(this.fontRendererObj, I18n.format("hdskins.manager"), this.width / 2, 10, 0xffffff); + this.drawCenteredString(this.fontRenderer, I18n.format("hdskins.manager"), this.width / 2, 10, 0xffffff); - this.fontRendererObj.drawStringWithShadow(I18n.format("hdskins.local"), 34, 34, 0xffffff); - this.fontRendererObj.drawStringWithShadow(I18n.format("hdskins.server"), this.width / 2 + 34, 34, 0xffffff); + this.fontRenderer.drawStringWithShadow(I18n.format("hdskins.local"), 34, 34, 0xffffff); + this.fontRenderer.drawStringWithShadow(I18n.format("hdskins.server"), this.width / 2 + 34, 34, 0xffffff); disableDepth(); enableBlend(); @@ -556,19 +554,19 @@ public class GuiSkins extends GuiScreen { int labelwidth = (this.width / 2 - 80) / 2; if (!this.localPlayer.isUsingLocalTexture()) { - int opacity = this.fontRendererObj.getStringWidth(this.skinMessage) / 2; + int opacity = this.fontRenderer.getStringWidth(this.skinMessage) / 2; Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, 0xB0000000); - this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff); + this.fontRenderer.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff); } if (this.btnModeSkin.isMouseOver() || this.btnModeElytra.isMouseOver()) { int y = Math.max(mouseY, 16); String text; if (this.btnModeSkin.isMouseOver()) { text = "hdskins.mode.skin"; - } else{ + } else { text = "hdskins.mode.elytra"; } - this.drawCreativeTabHoveringText(I18n.format(text), mouseX, y); + this.drawHoveringText(I18n.format(text), mouseX, y); } if (this.fetchingSkin) { @@ -576,18 +574,18 @@ public class GuiSkins extends GuiScreen { if (this.throttledByMojang) { opacity1 = TextFormatting.RED + I18n.format("hdskins.error.mojang"); String stringWidth = I18n.format("hdskins.error.mojang.wait"); - int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2; - int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2; + int stringWidth1 = this.fontRenderer.getStringWidth(opacity1) / 2; + int stringWidth2 = this.fontRenderer.getStringWidth(stringWidth) / 2; Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16, 0xB0000000); - this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10, 0xffffff); - this.fontRendererObj.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), this.height / 2 + 2, 0xffffff); + this.fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10, 0xffffff); + this.fontRenderer.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), this.height / 2 + 2, 0xffffff); } else { opacity1 = I18n.format("hdskins.fetch"); - int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2; + int stringWidth1 = this.fontRenderer.getStringWidth(opacity1) / 2; Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12, 0xB0000000); - this.fontRendererObj.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4, 0xffffff); + this.fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4, 0xffffff); } } @@ -606,15 +604,15 @@ public class GuiSkins extends GuiScreen { if (this.uploadOpacity > 0.0F) { Gui.drawRect(0, 0, this.width, this.height, opacity << 24); if (this.uploadingSkin) { - this.drawCenteredString(this.fontRendererObj, this.skinUploadMessage, this.width / 2, this.height / 2, opacity << 24 | 0xffffff); + this.drawCenteredString(this.fontRenderer, this.skinUploadMessage, this.width / 2, this.height / 2, opacity << 24 | 0xffffff); } } } if (this.uploadError != null) { Gui.drawRect(0, 0, this.width, this.height, 0xB0000000); - this.drawCenteredString(this.fontRendererObj, I18n.format("hdskins.failed"), this.width / 2, this.height / 2 - 10, 0xFFFFFF55); - this.drawCenteredString(this.fontRendererObj, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555); + this.drawCenteredString(this.fontRenderer, I18n.format("hdskins.failed"), this.width / 2, this.height / 2 - 10, 0xFFFFFF55); + this.drawCenteredString(this.fontRenderer, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555); } depthMask(true); @@ -672,7 +670,7 @@ public class GuiSkins extends GuiScreen { public static boolean isPowerOfTwo(int number) { return number != 0 && (number & number - 1) == 0; } - + private void clearUploadedSkin(Session session) { if (this.registerServerConnection(session, skinServerId)) { Map sourceData = getClearData(session); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java index dda96fb3..3f1b0711 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/HDSkinsConfigPanel.java @@ -18,7 +18,8 @@ public class HDSkinsConfigPanel implements ConfigPanel { @Override public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) { - this.button.drawButton(Minecraft.getMinecraft(), mouseX, mouseY); + // TODO drawButton + this.button.func_191745_a(Minecraft.getMinecraft(), mouseX, mouseY, partialTicks); } @Override diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java b/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java index 2f4c2bf3..df184d9f 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java @@ -1,6 +1,5 @@ package com.voxelmodpack.hdskins.resource; -import com.google.common.base.Throwables; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.ImageBufferDownloadHD; import net.minecraft.client.Minecraft; @@ -12,9 +11,9 @@ import javax.annotation.Nullable; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; -import java.util.concurrent.Callable; +import java.util.function.Supplier; -public class ImageLoader implements Callable { +public class ImageLoader implements Supplier { private Minecraft mc = Minecraft.getMinecraft(); @@ -25,11 +24,17 @@ public class ImageLoader implements Callable { } @Override - public ResourceLocation call() throws Exception { + @Nullable + public ResourceLocation get() { BufferedImage image = getImage(original); final BufferedImage updated = new ImageBufferDownloadHD().parseUserSkin(image); - if (updated == null) + if (updated == null) { return null; + } + if (updated == image) { + // don't load a new image + return this.original; + } return this.mc.addScheduledTask(() -> loadSkin(updated)).get(); } @@ -43,16 +48,16 @@ public class ImageLoader implements Callable { IOUtils.closeQuietly(in); } } catch (IOException e) { - Throwables.propagate(e); + return null; } - return null; } + @Nullable private ResourceLocation loadSkin(BufferedImage image) { ResourceLocation conv = new ResourceLocation(original.getResourceDomain() + "-converted", original.getResourcePath()); - this.mc.getTextureManager().loadTexture(conv, new DynamicTextureImage(image)); - return conv; + boolean success= this.mc.getTextureManager().loadTexture(conv, new DynamicTextureImage(image)); + return success ? conv : null; } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java index 572def1a..bd5cc0d9 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resource/SkinResourceManager.java @@ -1,15 +1,11 @@ package com.voxelmodpack.hdskins.resource; import com.google.common.collect.Maps; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; import com.google.gson.Gson; import com.google.gson.JsonParseException; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; @@ -23,12 +19,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.Map; import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; public class SkinResourceManager implements IResourceManagerReloadListener { - private ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); + private ExecutorService executor = Executors.newSingleThreadExecutor(); private Map uuidSkins = Maps.newHashMap(); private Map namedSkins = Maps.newHashMap(); @@ -39,13 +37,8 @@ public class SkinResourceManager implements IResourceManagerReloadListener { public void onResourceManagerReload(IResourceManager resourceManager) { uuidSkins.clear(); namedSkins.clear(); - for (Future loc : inProgress.values()) { - loc.cancel(true); - } + executor.shutdownNow(); inProgress.clear(); - for (ResourceLocation res : converted.values()) { - Minecraft.getMinecraft().getTextureManager().deleteTexture(res); - } converted.clear(); for (String domain : resourceManager.getResourceDomains()) { try { @@ -107,21 +100,20 @@ public class SkinResourceManager implements IResourceManagerReloadListener { private void loadSkinResource(@Nullable final ResourceLocation res) { if (res != null) { - if (this.inProgress.get(res) == null) { - // read and convert in a new thread - final ListenableFuture conv = executor.submit(new ImageLoader(res)); - conv.addListener(() -> { - try { - if (!conv.isCancelled()) - converted.put(res, conv.get()); - } catch (Exception e) { - LogManager.getLogger().warn("Errored while processing " + res + ". Using original.", e); - converted.put(res, res); - } - }, executor); - this.inProgress.put(res, conv); - } + // read and convert in a new thread + this.inProgress.computeIfAbsent(res, r -> CompletableFuture.supplyAsync(new ImageLoader(r), executor) + .whenComplete((loc, t) -> { + if (loc != null) + converted.put(res, loc); + else { + LogManager.getLogger().warn("Errored while processing {}. Using original.", res, t); + converted.put(res, res); + } + })); + + } + } @Nullable diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index e2053a1a..a1d7a54d 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -6,6 +6,7 @@ import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; import com.minelittlepony.hdskins.gui.RenderPonyModel; import com.minelittlepony.renderer.RenderPonyEvoker; +import com.minelittlepony.renderer.RenderPonyIllusionIllager; import com.minelittlepony.renderer.RenderPonyPigman; import com.minelittlepony.renderer.RenderPonySkeleton; import com.minelittlepony.renderer.RenderPonyVex; @@ -26,6 +27,7 @@ import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityEvoker; import net.minecraft.entity.monster.EntityHusk; +import net.minecraft.entity.monster.EntityIllusionIllager; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityStray; @@ -96,21 +98,26 @@ public class MineLittlePony { private void saveCurrentRenderers(RenderManager rm) { // villagers - this.renderMap.put(EntityVillager.class, rm.getEntityClassRenderObject(EntityVillager.class)); - this.renderMap.put(EntityZombieVillager.class, rm.getEntityClassRenderObject(EntityZombieVillager.class)); + saveRenderer(rm, EntityVillager.class); + saveRenderer(rm, EntityZombieVillager.class); // zombies - this.renderMap.put(EntityZombie.class, rm.getEntityClassRenderObject(EntityZombie.class)); - this.renderMap.put(EntityHusk.class, rm.getEntityClassRenderObject(EntityHusk.class)); + saveRenderer(rm, EntityZombie.class); + saveRenderer(rm, EntityHusk.class); // pig zombie - this.renderMap.put(EntityPigZombie.class, rm.getEntityClassRenderObject(EntityPigZombie.class)); + saveRenderer(rm, EntityPigZombie.class); // skeletons - this.renderMap.put(EntitySkeleton.class, rm.getEntityClassRenderObject(EntitySkeleton.class)); - this.renderMap.put(EntityStray.class, rm.getEntityClassRenderObject(EntityStray.class)); - this.renderMap.put(EntityWitherSkeleton.class, rm.getEntityClassRenderObject(EntityWitherSkeleton.class)); + saveRenderer(rm, EntitySkeleton.class); + saveRenderer(rm, EntityStray.class); + saveRenderer(rm, EntityWitherSkeleton.class); // illagers - this.renderMap.put(EntityVex.class, rm.getEntityClassRenderObject(EntityVex.class)); - this.renderMap.put(EntityEvoker.class, rm.getEntityClassRenderObject(EntityEvoker.class)); - this.renderMap.put(EntityVindicator.class, rm.getEntityClassRenderObject(EntityVindicator.class)); + saveRenderer(rm, EntityVex.class); + saveRenderer(rm, EntityEvoker.class); + saveRenderer(rm, EntityVindicator.class); + saveRenderer(rm, EntityIllusionIllager.class); + } + + private void saveRenderer(RenderManager rm, Class cl) { + this.renderMap.put(cl, rm.getEntityClassRenderObject(cl)); } @SuppressWarnings("unchecked") @@ -162,11 +169,13 @@ public class MineLittlePony { ModUtilities.addRenderer(EntityVex.class, new RenderPonyVex(rm)); ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm)); ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm)); + ModUtilities.addRenderer(EntityIllusionIllager.class, new RenderPonyIllusionIllager(rm)); logger.info("Illagers are now ponies."); } else { ModUtilities.addRenderer(EntityVex.class, getRenderer(EntityVex.class)); ModUtilities.addRenderer(EntityEvoker.class, getRenderer(EntityEvoker.class)); ModUtilities.addRenderer(EntityVindicator.class, getRenderer(EntityVindicator.class)); + ModUtilities.addRenderer(EntityIllusionIllager.class, getRenderer(EntityIllusionIllager.class)); } } diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java index 997cc79d..83b9120b 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/Pony.java @@ -15,32 +15,32 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; public class Pony { - private static PonyConfig config = MineLittlePony.getConfig(); + private static final AtomicInteger ponyCount = new AtomicInteger(); + private final int ponyId = ponyCount.getAndIncrement(); - private static int ponyCount = 0; - private final int ponyId = ponyCount++; - - public ResourceLocation textureResourceLocation; + private ResourceLocation textureResourceLocation; public PonyData metadata = new PonyData(); private int skinCheckCount; private boolean skinChecked; - public Pony(@Nonnull AbstractClientPlayer player) { + public Pony(AbstractClientPlayer player) { this.textureResourceLocation = player.getLocationSkin(); - MineLittlePony.logger.debug("+ Initialising new pony #%d for player %s (%s) with resource location %s.", this.ponyId, + MineLittlePony.logger.debug("+ Initialising new pony #{} for player {} ({}) with resource location {}.", this.ponyId, player.getName(), player.getUniqueID(), this.textureResourceLocation); this.checkSkin(this.textureResourceLocation); } - public Pony(@Nonnull ResourceLocation aTextureResourceLocation) { + public Pony(ResourceLocation aTextureResourceLocation) { this.textureResourceLocation = aTextureResourceLocation; - MineLittlePony.logger.debug("+ Initialising new pony #%d with resource location %s.", this.ponyId, this.textureResourceLocation); + MineLittlePony.logger.debug("+ Initialising new pony #{} with resource location {}.", this.ponyId, this.textureResourceLocation); this.checkSkin(this.textureResourceLocation); } @@ -55,19 +55,39 @@ public class Pony { } } - public void checkSkin(ResourceLocation textureResourceLocation) { - BufferedImage skinImage = this.getBufferedImage(textureResourceLocation); - if (skinImage != null) { - this.checkSkin(skinImage); + private void checkSkin(ResourceLocation textureResourceLocation) { + if(!checkPonyMeta(textureResourceLocation)) { + BufferedImage skinImage = this.getBufferedImage(textureResourceLocation); + if (skinImage != null) { + this.checkSkin(skinImage); + } } } - public BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { + private boolean checkPonyMeta(ResourceLocation location) { + try { + IResource res = Minecraft.getMinecraft().getResourceManager().getResource(location); + if (res.hasMetadata()) { + PonyData data = res.getMetadata(PonyDataSerialzier.NAME); + if (data != null) { + metadata = data; + this.skinChecked = true; + } + return true; + } + } catch (IOException e) { + MineLittlePony.logger.warn("Unable to read {} metadata", location, e); + } + return false; + } + + @Nullable + private BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { BufferedImage skinImage = null; try { IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); - MineLittlePony.logger.debug("Obtained skin from resource location %s", textureResourceLocation); + MineLittlePony.logger.debug("Obtained skin from resource location {}", textureResourceLocation); // this.checkSkin(skinImage); } catch (IOException e) { @@ -94,14 +114,14 @@ public class Pony { } public void checkSkin(BufferedImage bufferedimage) { - MineLittlePony.logger.debug("\tStart skin check #%d for pony #%d with image %s.", ++this.skinCheckCount, this.ponyId); + MineLittlePony.logger.debug("\tStart skin check #{} for pony #{} with image {}.", ++this.skinCheckCount, this.ponyId, bufferedimage); metadata = PonyData.parse(bufferedimage); this.skinChecked = true; } public boolean isPegasusFlying(EntityPlayer player) { //noinspection SimplifiableIfStatement - if (this.metadata.getRace() == null || !this.metadata.getRace().hasWings()) { + if (!this.metadata.getRace().hasWings()) { return false; } return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater() || player.isElytraFlying()); @@ -109,12 +129,12 @@ public class Pony { public PlayerModel getModel(boolean ignorePony, boolean smallArms) { boolean is_a_pony = false; - switch (ignorePony ? PonyLevel.BOTH : config.getPonyLevel()) { + switch (ignorePony ? PonyLevel.BOTH : MineLittlePony.getConfig().getPonyLevel()) { case HUMANS: is_a_pony = false; break; case BOTH: - is_a_pony = metadata.getRace() != null; + is_a_pony = metadata.getRace() != PonyRace.HUMAN; break; case PONIES: is_a_pony = true; diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 5e56dc17..ce1dff2e 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -10,11 +10,10 @@ import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.util.ResourceLocation; -import org.apache.commons.compress.utils.IOUtils; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Reader; import java.util.List; import java.util.Map; import java.util.UUID; @@ -26,6 +25,9 @@ public class PonyManager implements IResourceManagerReloadListener { public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"); private static final ResourceLocation BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json"); + + private static final Gson GSON = new Gson(); + private List backgroundPonyList = Lists.newArrayList(); private PonyConfig config; @@ -44,37 +46,22 @@ public class PonyManager implements IResourceManagerReloadListener { MineLittlePony.logger.info("Done initializing models."); } - private Pony getPonyFromResourceRegistry(ResourceLocation skinResourceLocation, AbstractClientPlayer player) { - Pony myLittlePony; - if (!this.poniesCache.containsKey(skinResourceLocation)) { - if (player != null) { - myLittlePony = new Pony(player); - } else { - myLittlePony = new Pony(skinResourceLocation); - } - - this.poniesCache.put(skinResourceLocation, myLittlePony); - } else { - myLittlePony = this.poniesCache.get(skinResourceLocation); - } - - return myLittlePony; - } - public Pony getPonyFromResourceRegistry(ResourceLocation skinResourceLocation) { - return this.getPonyFromResourceRegistry(skinResourceLocation, null); + return this.poniesCache.computeIfAbsent(skinResourceLocation, Pony::new); } public Pony getPonyFromResourceRegistry(AbstractClientPlayer player) { - Pony myLittlePony = this.getPonyFromResourceRegistry(player.getLocationSkin(), player); - if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.metadata.getRace() == null) { + + Pony myLittlePony = this.poniesCache.computeIfAbsent(player.getLocationSkin(), res -> new Pony(player)); + + if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.metadata.getRace() == PonyRace.HUMAN) { myLittlePony = this.getPonyFromBackgroundResourceRegistry(player); } return myLittlePony; } - public ResourceLocation getBackgroundPonyResource(UUID id) { + private ResourceLocation getBackgroundPonyResource(UUID id) { if (getNumberOfPonies() > 0) { int backgroundIndex = id.hashCode() % this.getNumberOfPonies(); if (backgroundIndex < 0) { @@ -86,7 +73,7 @@ public class PonyManager implements IResourceManagerReloadListener { return STEVE; } - public Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) { + private Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) { ResourceLocation textureResourceLocation; if (player.isUser()) { textureResourceLocation = getDefaultSkin(player.getUniqueID()); @@ -107,13 +94,13 @@ public class PonyManager implements IResourceManagerReloadListener { @Override public void onResourceManagerReload(IResourceManager resourceManager) { - // TODO Auto-generated method stub + this.poniesCache.clear(); this.backgroudPoniesCache.clear(); this.backgroundPonyList.clear(); try { for (IResource res : resourceManager.getAllResources(BGPONIES_JSON)) { - try { - BackgroundPonies ponies = getBackgroundPonies(res.getInputStream()); + try (Reader reader = new InputStreamReader((res.getInputStream()))) { + BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class); if (ponies.override) { this.backgroundPonyList.clear(); } @@ -128,14 +115,6 @@ public class PonyManager implements IResourceManagerReloadListener { MineLittlePony.logger.info("Detected {} background ponies installed.", getNumberOfPonies()); } - private BackgroundPonies getBackgroundPonies(InputStream stream) { - try { - return new Gson().fromJson(new InputStreamReader(stream), BackgroundPonies.class); - } finally { - IOUtils.closeQuietly(stream); - } - } - private ResourceLocation getDefaultSkin(UUID uuid) { return (uuid.hashCode() & 1) == 0 ? STEVE : ALEX; } diff --git a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java b/src/main/java/com/minelittlepony/gui/PonySettingPanel.java index 8c7fecc0..f7745153 100644 --- a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/gui/PonySettingPanel.java @@ -108,11 +108,11 @@ public class PonySettingPanel extends GuiScreen { public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); - this.drawCenteredString(mc.fontRendererObj, I18n.format(TITLE), width / 2, 12, -1); + this.drawCenteredString(mc.fontRenderer, I18n.format(TITLE), width / 2, 12, -1); - this.drawString(mc.fontRendererObj, I18n.format(MOB_TITLE), width - width / 3 - 16, 32, -1); - this.drawString(mc.fontRendererObj, I18n.format(PONY_LEVEL), width / 10, 32, -1); - this.drawString(mc.fontRendererObj, I18n.format(OPTIONS), width / 10, 94, -1); + this.drawString(mc.fontRenderer, I18n.format(MOB_TITLE), width - width / 3 - 16, 32, -1); + this.drawString(mc.fontRenderer, I18n.format(PONY_LEVEL), width / 10, 32, -1); + this.drawString(mc.fontRenderer, I18n.format(OPTIONS), width / 10, 94, -1); super.drawScreen(mouseX, mouseY, partialTicks); } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index dedacb20..224123cf 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -6,7 +6,7 @@ import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ModelPonyElytra; import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.pony.ModelHumanPlayer; +import com.minelittlepony.renderer.layer.AbstractPonyLayer; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.renderer.GlStateManager; @@ -40,14 +40,11 @@ public class RenderPonyModel extends RenderPlayerModel { protected LayerRenderer getElytraLayer() { final LayerRenderer elytra = super.getElytraLayer(); final ModelPonyElytra modelElytra = new ModelPonyElytra(); - return new LayerRenderer() { + return new AbstractPonyLayer(this, elytra) { @Override - public void doRenderLayer(EntityLivingBase entityBase, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { - if (mainModel instanceof ModelHumanPlayer) { - elytra.doRenderLayer(entityBase, swing, swingAmount, ticks, age, yaw, head, scale); - return; - } + public void doPonyRender(EntityLivingBase entityBase, float swing, float swingAmount, float ticks, float age, float yaw, float head, + float scale) { EntityPonyModel entity = (EntityPonyModel) entityBase; @@ -60,8 +57,7 @@ public class RenderPonyModel extends RenderPlayerModel { GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, 0.25F, 0.125F); - if (mainModel instanceof AbstractPonyModel) - ((AbstractPonyModel) mainModel).transform(BodyPart.BODY); + ((AbstractPonyModel) mainModel).transform(BodyPart.BODY); modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); @@ -71,11 +67,6 @@ public class RenderPonyModel extends RenderPlayerModel { } } - @Override - public boolean shouldCombineTextures() { - return false; - } - }; } } diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java index 83330036..9cd2f55c 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java @@ -9,7 +9,12 @@ import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelHumanPlayer; import com.minelittlepony.model.pony.ModelPlayerPony; -import com.minelittlepony.renderer.layer.*; +import com.minelittlepony.renderer.layer.LayerEntityOnPonyShoulder; +import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import com.minelittlepony.renderer.layer.LayerPonyArmor; +import com.minelittlepony.renderer.layer.LayerPonyCape; +import com.minelittlepony.renderer.layer.LayerPonyCustomHead; +import com.minelittlepony.renderer.layer.LayerPonyElytra; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; @@ -30,6 +35,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import javax.annotation.Nonnull; + @Mixin(RenderPlayer.class) public abstract class MixinRenderPlayer extends RenderLivingBase implements IRenderPony { @@ -57,7 +63,9 @@ public abstract class MixinRenderPlayer extends RenderLivingBase> 16 & 255) / 255.0F; - float green = (glowColor >> 8 & 255) / 255.0F; - float blue = (glowColor & 255) / 255.0F; - blendFunc(GL11.GL_SRC_ALPHA, 1); - - this.illagerHead.postRender(scale); - this.horn.postRender(scale); - - color(red, green, blue, 0.4F); - this.hornglow[0].render(scale); - color(red, green, blue, 0.2F); - this.hornglow[1].render(scale); - - enableTexture2D(); - enableLighting(); - disableBlend(); - popAttrib(); - } - } - -} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java index 6661dfe8..5cce4923 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java @@ -1,171 +1,76 @@ package com.minelittlepony.model.pony; -import com.minelittlepony.model.PonyModelConstants; -import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.AbstractIllager; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; -public abstract class ModelIllagerPony extends ModelBase { - - public boolean isUnicorn; - public int glowColor; - - public ModelRenderer illagerHead; - public ModelRenderer illagerBody; - public ModelRenderer leftForeLeg; - public ModelRenderer rightForeLeg; - public ModelRenderer leftHindLeg; - public ModelRenderer rightHindLeg; - public ModelRenderer tail; - public ModelRenderer horn; - - ModelIllagerPony() { - textureWidth = 64; - textureHeight = 64; - - this.setTextureOffset("head.ear1", 24, 4); - this.setTextureOffset("head.ear2", 0, 4); - this.setTextureOffset("head.snuzzle.mare1", 48, 21); - this.setTextureOffset("head.snuzzle.mare2", 49, 20); - this.setTextureOffset("head.snuzzle.stallion", 48, 16); - - illagerHead = new ModelRenderer(this, "head"); - illagerHead.setRotationPoint(0F, 1F, -5F); - illagerHead.setTextureOffset(0, 0).addBox(-4F, -6F, -5F, 8, 8, 8); - // headwear - illagerHead.setTextureOffset(32, 0).addBox(-4F, -6F, -5F, 8, 8, 8, 0.5F); - illagerHead.addBox("ear1", 2F, -8F, 0F, 2, 2, 2); - illagerHead.addBox("ear2", -4F, -8F, 0F, 2, 2, 2); - illagerHead.addBox("snuzzle.mare1", -2F, -0F, -6F, 4, 2, 1); - illagerHead.addBox("snuzzle.mare2", -1F, -1F, -6F, 2, 1, 1); - illagerHead.addBox("snuzzle.stallion", -2F, -1F, -6F, 4, 3, 1); - - horn = new ModelRenderer(this, 60, 3); - horn.addBox(-0.5F, -11.0F, -2F, 1, 4, 1); - horn.rotateAngleX = 0.5F; - - this.illagerHead.addChild(horn); - - ModelRenderer illagerNeck = new ModelRenderer(this, 0, 40); - illagerNeck.addBox(-2F, 0F, -6F, 4, 4, 4); - illagerNeck.rotateAngleX = PonyModelConstants.NECK_ROT_X; - - illagerBody = new ModelRenderer(this); - illagerBody.setTextureOffset(0, 16).addBox(-4F, 4F, -5F, 8, 8, 16); - illagerBody.addChild(illagerNeck); - - leftForeLeg = new ModelRenderer(this, 32, 16); - leftForeLeg.addBox(0F, 0F, -2F, 4, 12, 4).setRotationPoint(0F, 12F, -3F); - - rightForeLeg = new ModelRenderer(this, 32, 48); - rightForeLeg.addBox(-2F, 0F, -2F, 4, 12, 4).setRotationPoint(-2F, 12F, -3F); - - leftHindLeg = new ModelRenderer(this, 0, 16); - leftHindLeg.addBox(-2F, 0F, -2F, 4, 12, 4).setRotationPoint(2F, 12F, 8F); - - rightHindLeg = new ModelRenderer(this, 0, 48); - rightHindLeg.addBox(-2F, 0F, -2F, 4, 12, 4).setRotationPoint(-2F, 12F, 8F); - - ModelRenderer tailStub = new ModelRenderer(this, 52, 24); - tailStub.addBox(-0.5F, -1F, -0.5F, 2, 4, 2).setRotationPoint(0F, 0F, 2F); - tailStub.rotateAngleX = (float) Math.PI / -3; - - - this.setTextureOffset("tail.1qtr", 48, 24); - this.setTextureOffset("tail.half", 48, 32); - this.setTextureOffset("tail.3qtr", 48, 40); - this.setTextureOffset("tail.full", 48, 48); - - tail = new ModelRenderer(this, "tail"); - tail.setRotationPoint(0F, 4F, 11F); - tail.addBox("1qtr", -1.5F, -2F, 2F, 4, 4, 4); - tail.addBox("half", -1.5F, 2F, 2F, 4, 4, 4); - tail.addBox("3qtr", -1.5F, 6F, 2F, 4, 4, 4); - tail.addBox("full", -1.5F, 10F, 2F, 4, 4, 4); - tail.addChild(tailStub); - +public class ModelIllagerPony extends ModelPlayerPony { + public ModelIllagerPony() { + super(false); } @Override - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); + public void setRotationAngles(float swing, float move, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - illagerHead.render(scale); - illagerBody.render(scale); - leftForeLeg.render(scale); - rightForeLeg.render(scale); - leftHindLeg.render(scale); - rightHindLeg.render(scale); - tail.render(scale); + super.setRotationAngles(swing, move, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + AbstractIllager illager = (AbstractIllager) entityIn; + AbstractIllager.IllagerArmPose pose = illager.func_193077_p(); -// mr.render(scale); - } + boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; - @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + if (pose == AbstractIllager.IllagerArmPose.ATTACKING) { + // vindicator attacking + float f = MathHelper.sin(this.swingProgress * (float) Math.PI); + float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI); + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = 0.15707964F; + this.bipedLeftArm.rotateAngleY = -0.15707964F; - final float PI = (float) Math.PI; + if (rightHanded) { + this.bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; + this.bipedRightArm.rotateAngleX += f * 2.2F - f1 * 0.4F; + } else { + this.bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; + this.bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F; + } - float headRotateAngleY = netHeadYaw * PI / 180; - float headRotateAngleX = headPitch * PI / 180; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; + } else if (pose == AbstractIllager.IllagerArmPose.SPELLCASTING) { + if (this.metadata.hasMagic()) { + this.horn.setUsingMagic(true); + } + // waving arms! + if (rightHanded) { +// this.bipedRightArm.rotationPointZ = 0.0F; +// this.bipedRightArm.rotationPointX = -5.0F; + this.bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI); + this.bipedRightArm.rotateAngleZ = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F; + this.bipedRightArm.rotateAngleY = 1.1F; + } else { +// this.bipedLeftArm.rotationPointZ = 0.0F; +// this.bipedLeftArm.rotationPointX = 5.0F; + this.bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI); + this.bipedLeftArm.rotateAngleZ = -MathHelper.cos(ageInTicks * 0.6662F) * 0.25F; + this.bipedLeftArm.rotateAngleY = -1.1F; + } - final float max = 0.5f; - final float min = -1.25f; - headRotateAngleX = Math.min(headRotateAngleX, max); - headRotateAngleX = Math.max(headRotateAngleX, min); - this.illagerHead.rotateAngleY = headRotateAngleY; - this.illagerHead.rotateAngleX = headRotateAngleX; - - this.tail.rotateAngleZ = MathHelper.cos(limbSwing * 0.8F) * 0.2F * limbSwingAmount; - - float bodySwingRotation = 0.0F; - if (this.swingProgress > -9990.0F) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * PI * 2.0F) * 0.2F; + } else if (pose == AbstractIllager.IllagerArmPose.BOW_AND_ARROW) { + if (rightHanded) { + aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, ageInTicks); + } else { + aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, ageInTicks); + } } - - this.illagerBody.rotateAngleY = bodySwingRotation * 0.2F; - this.illagerBody.rotateAngleY = bodySwingRotation * 0.2F; - - - this.tail.rotateAngleY = bodySwingRotation; - - - this.setLegs(limbSwing, limbSwingAmount); - this.tail.rotateAngleX = 0.5F * limbSwingAmount; - - - this.tail.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; - - } - private void setLegs(float move, float swing) { - this.rotateLegs(move, swing); -// this.adjustLegs(); - } - - private void rotateLegs(float move, float swing) { - final float PI = (float) Math.PI; - float swag = (float) Math.pow(swing, 16.0D); - float raQuad = PI * swag * 0.5F; - float laQuad = PI * swag; - float rlQuad = PI * swag * 0.2F; - float llQuad = PI * swag * -0.4F; - - - this.rightForeLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + (float) Math.PI + raQuad) * 0.45F * swing; - this.leftForeLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.45F * swing; - this.rightHindLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing; - this.leftHindLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + PI + llQuad) * 0.45F * swing; - this.rightForeLeg.rotateAngleZ = 0.0F; - - this.leftForeLeg.rotateAngleZ = 0.0F; - } - - public ModelRenderer getArm(EnumHandSide side) { - return side == EnumHandSide.LEFT ? this.leftForeLeg : this.rightForeLeg; + public ModelRenderer getArmForSide(EnumHandSide side) { + return super.getArmForSide(side); } } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java index 4690a3f0..12b9ad6b 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java @@ -1,6 +1,11 @@ package com.minelittlepony.model.pony; -import com.minelittlepony.model.*; +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.PegasusWings; +import com.minelittlepony.model.PonyModelConstants; +import com.minelittlepony.model.PonySnout; +import com.minelittlepony.model.UnicornHorn; import com.minelittlepony.renderer.PlaneRenderer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; @@ -24,9 +29,9 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst public ModelRenderer unicornArmRight; public ModelRenderer unicornArmLeft; public PlaneRenderer[] Tail; - private PonySnout snout; - private UnicornHorn horn; - private PegasusWings wings; + public PonySnout snout; + public UnicornHorn horn; + public PegasusWings wings; public ModelPlayerPony(boolean smallArms) { super(smallArms); @@ -41,7 +46,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, + Entity entityIn) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); this.checkRainboom(entityIn, limbSwingAmount); @@ -165,7 +171,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void checkRainboom(Entity entity, float swing) { - boolean flying = this.metadata.getRace() != null && this.metadata.getRace().hasWings() && this.isFlying + boolean flying = this.metadata.getRace().hasWings() && this.isFlying || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying(); this.rainboom = flying && swing >= 0.9999F; @@ -207,7 +213,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst float leftArmRotateAngleX; float rightLegRotateAngleX; float leftLegRotateAngleX; - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { + if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity) + .isElytraFlying()) { if (this.rainboom) { rightArmRotateAngleX = ROTATE_270; leftArmRotateAngleX = ROTATE_270; @@ -381,6 +388,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.unicornArmRight.rotateAngleX = this.unicornArmRight.rotateAngleX * 0.5F - 0.9424779F; } } + + this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); } protected void swingItem(Entity entity, float swingProgress) { @@ -596,7 +605,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst popMatrix(); } - protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, + float scale) { this.bipedHead.render(this.scale); this.bipedHeadwear.render(this.scale); this.bipedHead.postRender(scale); @@ -611,7 +621,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } } - protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, + float scale) { this.bipedBody.render(this.scale); if (this.textureHeight == 64) { this.bipedBodyWear.render(this.scale); @@ -631,7 +642,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst var3 = 0; } -// this.bipedBody.postRender(this.scale); + // this.bipedBody.postRender(this.scale); for (int k = 0; k < var3; ++k) { this.Tail[k].render(this.scale); @@ -640,8 +651,9 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void renderLegs() { - if (!this.isSneak) + if (!this.isSneak) { this.bipedBody.postRender(this.scale); + } this.bipedLeftArm.render(this.scale); this.bipedRightArm.render(this.scale); @@ -778,42 +790,42 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedBodyWear.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch + 0.25F); this.bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[0].addWestPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 0, 8, 8, stretch); + this.Bodypiece[0].addWestPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 8, stretch); this.Bodypiece[0].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[1].addEastPlane(4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 0, 8, 8, stretch); + this.Bodypiece[1].addEastPlane(4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 8, stretch); this.Bodypiece[1].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[2].addTopPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 0, 12, stretch); + this.Bodypiece[2].addTopPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 12, stretch); this.Bodypiece[2].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[3].addBottomPlane(-4.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 0, 8, stretch); + this.Bodypiece[3].addBottomPlane(-4.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 8, stretch); this.Bodypiece[3].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[4].addWestPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 0, 8, 4, stretch); + this.Bodypiece[4].addWestPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 8, 4, stretch); this.Bodypiece[4].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[5].addEastPlane(4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 0, 8, 4, stretch); + this.Bodypiece[5].addEastPlane(4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 8, 4, stretch); this.Bodypiece[5].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[6].addBackPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 8, 4, 0, stretch); + this.Bodypiece[6].addBackPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 8, 4, stretch); this.Bodypiece[6].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[7].addBackPlane(-4.0F + BODY_CENTRE_X, 0.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 8, 4, 0, stretch); + this.Bodypiece[7].addBackPlane(-4.0F + BODY_CENTRE_X, 0.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 8, 4, stretch); this.Bodypiece[7].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[8].addBottomPlane(-4.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 8, 0, 4, stretch); + this.Bodypiece[8].addBottomPlane(-4.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 8, 4, stretch); this.Bodypiece[8].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[9].addTopPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 0, 6, stretch); + this.Bodypiece[9].addTopPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 6, stretch); this.Bodypiece[9].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[10].addBottomPlane(-1.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 0, 6, stretch); + this.Bodypiece[10].addBottomPlane(-1.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 6, stretch); this.Bodypiece[10].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[11].addWestPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 0, 2, 6, stretch); + this.Bodypiece[11].addWestPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 6, stretch); this.Bodypiece[11].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[12].addEastPlane(1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 0, 2, 6, stretch); + this.Bodypiece[12].addEastPlane(1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 6, stretch); this.Bodypiece[12].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece[13].addBackPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 2, 2, 0, stretch); + this.Bodypiece[13].addBackPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 2, 2, stretch); this.Bodypiece[13].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.BodypieceNeck[0].addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, 0, stretch); + this.BodypieceNeck[0].addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck[0].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.BodypieceNeck[1].addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -4.8F + BODY_CENTRE_Z, 4, 4, 0, stretch); + this.BodypieceNeck[1].addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -4.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck[1].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.BodypieceNeck[2].addWestPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 0, 4, 4, stretch); + this.BodypieceNeck[2].addWestPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck[2].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.BodypieceNeck[3].addEastPlane(2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 0, 4, 4, stretch); + this.BodypieceNeck[3].addEastPlane(2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck[3].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); this.BodypieceNeck[0].rotateAngleX = NECK_ROT_X; this.BodypieceNeck[1].rotateAngleX = NECK_ROT_X; @@ -826,26 +838,30 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedRightArm.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch); this.bipedRightArm.setRotationPoint(-2.0F, 8.5F + yOffset, 0.0F); if (bipedRightArmwear != null) { - this.bipedRightArmwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch + 0.25f); + this.bipedRightArmwear + .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch + 0.25f); this.bipedRightArmwear.setRotationPoint(-3.0F, 8.5F + yOffset, 0.0F); } this.bipedLeftArm.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch); this.bipedLeftArm.setRotationPoint(3.0F, 8.5F + yOffset, 0.0F); if (this.bipedLeftArmwear != null) { - this.bipedLeftArmwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch + 0.25f); + this.bipedLeftArmwear + .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 3, 12, 4, stretch + 0.25f); this.bipedLeftArmwear.setRotationPoint(3.0F, 8.5F + yOffset, 0.0F); } } else { this.bipedRightArm.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); this.bipedRightArm.setRotationPoint(-3.0F, 8.0F + yOffset, 0.0F); if (bipedRightArmwear != null) { - this.bipedRightArmwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); + this.bipedRightArmwear + .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); this.bipedRightArmwear.setRotationPoint(-3.0F, 8.0F + yOffset, 0.0F); } this.bipedLeftArm.addBox(-3.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); this.bipedLeftArm.setRotationPoint(3.0F, 8.0F + yOffset, 0.0F); if (this.bipedLeftArmwear != null) { - this.bipedLeftArmwear.addBox(-3.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); + this.bipedLeftArmwear + .addBox(-3.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); this.bipedLeftArmwear.setRotationPoint(3.0F, 8.0F + yOffset, 0.0F); } } @@ -853,14 +869,16 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedRightLeg.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); if (bipedRightLegwear != null) { - this.bipedRightLegwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); + this.bipedRightLegwear + .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); this.bipedRightLegwear.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); } this.bipedLeftLeg.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); if (this.bipedLeftLegwear != null) { - this.bipedLeftLegwear.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); + this.bipedLeftLegwear + .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch + 0.25f); } this.unicornArmRight.addBox(-2.0F + FIRSTP_ARM_CENTRE_X, -6.0F + FIRSTP_ARM_CENTRE_Y, -2.0F + FIRSTP_ARM_CENTRE_Z, 4, 12, 4, stretch + .25f); this.unicornArmRight.setRotationPoint(-5.0F, 2.0F + yOffset, 0.0F); @@ -870,47 +888,47 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void initTailPositions(float yOffset, float stretch) { - this.Tail[0].addTopPlane(-2.0F, 1.0F, 2.0F, 4, 0, 4, stretch); + this.Tail[0].addTopPlane(-2.0F, 1.0F, 2.0F, 4, 4, stretch); this.Tail[0].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[1].addWestPlane(-2.0F, 1.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[1].addWestPlane(-2.0F, 1.0F, 2.0F, 4, 4, stretch); this.Tail[1].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[2].addBackPlane(-2.0F, 1.0F, 2.0F, 4, 4, 0, stretch); + this.Tail[2].addBackPlane(-2.0F, 1.0F, 2.0F, 4, 4, stretch); this.Tail[2].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[3].addEastPlane(2.0F, 1.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[3].addEastPlane(2.0F, 1.0F, 2.0F, 4, 4, stretch); this.Tail[3].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[4].addBackPlane(-2.0F, 1.0F, 6.0F, 4, 4, 0, stretch); + this.Tail[4].addBackPlane(-2.0F, 1.0F, 6.0F, 4, 4, stretch); this.Tail[4].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[5].addTopPlane(-2.0F, 5.0F, 2.0F, 4, 0, 4, stretch); + this.Tail[5].addTopPlane(-2.0F, 5.0F, 2.0F, 4, 4, stretch); this.Tail[5].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[6].addWestPlane(-2.0F, 5.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[6].addWestPlane(-2.0F, 5.0F, 2.0F, 4, 4, stretch); this.Tail[6].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[7].addBackPlane(-2.0F, 5.0F, 2.0F, 4, 4, 0, stretch); + this.Tail[7].addBackPlane(-2.0F, 5.0F, 2.0F, 4, 4, stretch); this.Tail[7].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[8].addEastPlane(2.0F, 5.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[8].addEastPlane(2.0F, 5.0F, 2.0F, 4, 4, stretch); this.Tail[8].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[9].addBackPlane(-2.0F, 5.0F, 6.0F, 4, 4, 0, stretch); + this.Tail[9].addBackPlane(-2.0F, 5.0F, 6.0F, 4, 4, stretch); this.Tail[9].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[10].addTopPlane(-2.0F, 9.0F, 2.0F, 4, 0, 4, stretch); + this.Tail[10].addTopPlane(-2.0F, 9.0F, 2.0F, 4, 4, stretch); this.Tail[10].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[11].addWestPlane(-2.0F, 9.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[11].addWestPlane(-2.0F, 9.0F, 2.0F, 4, 4, stretch); this.Tail[11].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[12].addBackPlane(-2.0F, 9.0F, 2.0F, 4, 4, 0, stretch); + this.Tail[12].addBackPlane(-2.0F, 9.0F, 2.0F, 4, 4, stretch); this.Tail[12].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[13].addEastPlane(2.0F, 9.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[13].addEastPlane(2.0F, 9.0F, 2.0F, 4, 4, stretch); this.Tail[13].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[14].addBackPlane(-2.0F, 9.0F, 6.0F, 4, 4, 0, stretch); + this.Tail[14].addBackPlane(-2.0F, 9.0F, 6.0F, 4, 4, stretch); this.Tail[14].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[15].addTopPlane(-2.0F, 13.0F, 2.0F, 4, 0, 4, stretch); + this.Tail[15].addTopPlane(-2.0F, 13.0F, 2.0F, 4, 4, stretch); this.Tail[15].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[16].addWestPlane(-2.0F, 13.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[16].addWestPlane(-2.0F, 13.0F, 2.0F, 4, 4, stretch); this.Tail[16].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[17].addBackPlane(-2.0F, 13.0F, 2.0F, 4, 4, 0, stretch); + this.Tail[17].addBackPlane(-2.0F, 13.0F, 2.0F, 4, 4, stretch); this.Tail[17].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[18].addEastPlane(2.0F, 13.0F, 2.0F, 0, 4, 4, stretch); + this.Tail[18].addEastPlane(2.0F, 13.0F, 2.0F, 4, 4, stretch); this.Tail[18].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[19].addBackPlane(-2.0F, 13.0F, 6.0F, 4, 4, 0, stretch); + this.Tail[19].addBackPlane(-2.0F, 13.0F, 6.0F, 4, 4, stretch); this.Tail[19].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - this.Tail[20].addTopPlane(-2.0F, 17.0F, 2.0F, 4, 0, 4, stretch); + this.Tail[20].addTopPlane(-2.0F, 17.0F, 2.0F, 4, 4, stretch); this.Tail[20].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java index d0e07a23..b56048b5 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java @@ -77,37 +77,37 @@ public class ModelVillagerPony extends ModelPlayerPony { @Override protected void initPositions(float yOffset, float stretch) { super.initPositions(yOffset, stretch); - this.VillagerBagPiece[0].addWestPlane(-7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 0, 6, 8, stretch); + this.VillagerBagPiece[0].addWestPlane(-7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 6, 8, stretch); this.VillagerBagPiece[0].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[1].addWestPlane(-4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 0, 6, 8, stretch); + this.VillagerBagPiece[1].addWestPlane(-4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 6, 8, stretch); this.VillagerBagPiece[1].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[2].addWestPlane(4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 0, 6, 8, stretch); + this.VillagerBagPiece[2].addWestPlane(4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 6, 8, stretch); this.VillagerBagPiece[2].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[3].addWestPlane(7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 0, 6, 8, stretch); + this.VillagerBagPiece[3].addWestPlane(7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 6, 8, stretch); this.VillagerBagPiece[3].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[4].addTopPlane(2.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -2.0F + BODY_CENTRE_Z, 8, 0, 3, stretch); + this.VillagerBagPiece[4].addTopPlane(2.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -2.0F + BODY_CENTRE_Z, 8, 3, stretch); this.VillagerBagPiece[4].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[5].addTopPlane(2.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -13.0F + BODY_CENTRE_Z, 8, 0, 3, stretch); + this.VillagerBagPiece[5].addTopPlane(2.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -13.0F + BODY_CENTRE_Z, 8, 3, stretch); this.VillagerBagPiece[5].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[6].addBottomPlane(2.0F + BODY_CENTRE_X, 1.0F + BODY_CENTRE_Y, -2.0F + BODY_CENTRE_Z, 8, 0, 3, stretch); + this.VillagerBagPiece[6].addBottomPlane(2.0F + BODY_CENTRE_X, 1.0F + BODY_CENTRE_Y, -2.0F + BODY_CENTRE_Z, 8, 3, stretch); this.VillagerBagPiece[6].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[7].addBottomPlane(2.0F + BODY_CENTRE_X, 1.0F + BODY_CENTRE_Y, -13.0F + BODY_CENTRE_Z, 8, 0, 3, stretch); + this.VillagerBagPiece[7].addBottomPlane(2.0F + BODY_CENTRE_X, 1.0F + BODY_CENTRE_Y, -13.0F + BODY_CENTRE_Z, 8, 3, stretch); this.VillagerBagPiece[7].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[8].addBackPlane(-7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 3, 6, 0, stretch); + this.VillagerBagPiece[8].addBackPlane(-7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 3, 6, stretch); this.VillagerBagPiece[8].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[9].addBackPlane(4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 3, 6, 0, stretch); + this.VillagerBagPiece[9].addBackPlane(4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 3, 6, stretch); this.VillagerBagPiece[9].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[10].addBackPlane(-7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 3, 6, 0, stretch); + this.VillagerBagPiece[10].addBackPlane(-7.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 3, 6, stretch); this.VillagerBagPiece[10].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[11].addBackPlane(4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 3, 6, 0, stretch); + this.VillagerBagPiece[11].addBackPlane(4.0F + BODY_CENTRE_X, -5.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 3, 6, stretch); this.VillagerBagPiece[11].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[12].addTopPlane(-4.0F + BODY_CENTRE_X, -4.5F + BODY_CENTRE_Y, -1.0F + BODY_CENTRE_Z, 8, 0, 1, stretch); + this.VillagerBagPiece[12].addTopPlane(-4.0F + BODY_CENTRE_X, -4.5F + BODY_CENTRE_Y, -1.0F + BODY_CENTRE_Z, 8, 1, stretch); this.VillagerBagPiece[13].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerBagPiece[13].addTopPlane(-4.0F + BODY_CENTRE_X, -4.5F + BODY_CENTRE_Y, 0.0F + BODY_CENTRE_Z, 8, 0, 1, stretch); + this.VillagerBagPiece[13].addTopPlane(-4.0F + BODY_CENTRE_X, -4.5F + BODY_CENTRE_Y, 0.0F + BODY_CENTRE_Z, 8, 1, stretch); this.VillagerBagPiece[13].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerApron.addBackPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -9.0F + BODY_CENTRE_Z, 8, 10, 0, stretch); + this.VillagerApron.addBackPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -9.0F + BODY_CENTRE_Z, 8, 10, stretch); this.VillagerApron.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.VillagerTrinket.addBackPlane(-2.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -9.0F + BODY_CENTRE_Z, 4, 5, 0, stretch); + this.VillagerTrinket.addBackPlane(-2.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -9.0F + BODY_CENTRE_Z, 4, 5, stretch); this.VillagerTrinket.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); } } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java b/src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java deleted file mode 100644 index 3533c0fd..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelVindicatorPony.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.minelittlepony.model.pony; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityVindicator; -import net.minecraft.util.EnumHandSide; -import net.minecraft.util.math.MathHelper; - -public class ModelVindicatorPony extends ModelIllagerPony { - - @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); - - EntityVindicator vindicator = (EntityVindicator) entityIn; - if (vindicator.isAggressive()) { - float f = MathHelper.sin(this.swingProgress * (float) Math.PI); - float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI); - this.rightForeLeg.rotateAngleZ = 0.0F; - this.leftForeLeg.rotateAngleZ = 0.0F; - - if (((EntityLivingBase) entityIn).getPrimaryHand() == EnumHandSide.RIGHT) { - this.rightForeLeg.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; -// this.leftForeLeg.rotateAngleX = -0.0F + MathHelper.cos(ageInTicks * 0.19F) * 0.5F; - this.rightForeLeg.rotateAngleX += f * 2.2F - f1 * 0.4F; -// this.leftForeLeg.rotateAngleX += f * 1.2F - f1 * 0.4F; - } else { -// this.rightForeLeg.rotateAngleX = -0.0F + MathHelper.cos(ageInTicks * 0.19F) * 0.5F; - this.leftForeLeg.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; -// this.rightForeLeg.rotateAngleX += f * 1.2F - f1 * 0.4F; - this.leftForeLeg.rotateAngleX += f * 2.2F - f1 * 0.4F; - } - - this.rightForeLeg.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; - this.leftForeLeg.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; - this.rightForeLeg.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; - this.leftForeLeg.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; - } - } - -} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java index df0af606..098c7d99 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java @@ -39,13 +39,9 @@ public class ModelZombiePony extends ModelPlayerPony { this.bipedLeftLeg.rotateAngleY = 0.2F; } else { var8 = (float) Math.pow(swing, 16.0D); - this.getClass(); var9 = 3.1415927F * var8 * 0.5F; - this.getClass(); float laQuad = 3.1415927F * var8; - this.getClass(); float rlQuad = 3.1415927F * var8 * 0.2F; - this.getClass(); float llQuad = 3.1415927F * var8 * -0.4F; rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.45F * swing; leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.45F * swing; diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java index 0646ed70..d5725c8e 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java @@ -264,9 +264,8 @@ public class ModelPonyArmor extends ModelPlayerPony { this.syncLegs(); } - @Override - public void setInvisible(boolean invisible) { - super.setInvisible(invisible); + public void setVisible(boolean invisible) { + super.setVisible(invisible); this.Bodypiece.showModel = invisible; extBody.showModel = invisible; for (ModelRenderer m : extHead) { diff --git a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java b/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java index 101358ea..d74ae86c 100644 --- a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java @@ -14,10 +14,6 @@ public class PlaneRenderer extends ModelRenderer { private int textureOffsetX; private int textureOffsetY; -// public PlaneRenderer(ModelBase model, String boxNameIn) { -// super(model, boxNameIn); -// } - public PlaneRenderer(ModelBase model) { super(model); } @@ -38,27 +34,27 @@ public class PlaneRenderer extends ModelRenderer { this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, offX, offY, offZ, width, height, depth, scale, face)); } - public void addTopPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { - this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.UP); + public void addTopPlane(float offX, float offY, float offZ, int width, int depth, float scale) { + this.addPlane(offX, offY, offZ, width, 0, depth, scale, Face.UP); } - public void addBottomPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { - this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.DOWN); + public void addBottomPlane(float offX, float offY, float offZ, int width, int depth, float scale) { + this.addPlane(offX, offY, offZ, width, 0, depth, scale, Face.DOWN); } - public void addWestPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { - this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.WEST); + public void addWestPlane(float offX, float offY, float offZ, int height, int depth, float scale) { + this.addPlane(offX, offY, offZ, 0, height, depth, scale, Face.WEST); } - public void addEastPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { - this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.EAST); + public void addEastPlane(float offX, float offY, float offZ, int height, int depth, float scale) { + this.addPlane(offX, offY, offZ, 0, height, depth, scale, Face.EAST); } - public void addFrontPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { - this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.NORTH); + public void addFrontPlane(float offX, float offY, float offZ, int width, int height, float scale) { + this.addPlane(offX, offY, offZ, width, height, 0, scale, Face.NORTH); } - public void addBackPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale) { - this.addPlane(offX, offY, offZ, width, height, depth, scale, Face.SOUTH); + public void addBackPlane(float offX, float offY, float offZ, int width, int height, float scale) { + this.addPlane(offX, offY, offZ, width, height, 0, scale, Face.SOUTH); } } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java index edc09a53..4a8ac9de 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java @@ -1,53 +1,41 @@ package com.minelittlepony.renderer; -import com.minelittlepony.PonyData; -import com.minelittlepony.PonyDataSerialzier; -import com.minelittlepony.model.pony.ModelEvokerPony; +import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.pony.ModelIllagerPony; -import net.minecraft.client.Minecraft; +import com.minelittlepony.renderer.layer.LayerHeldPonyItem; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.IResource; -import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityEvoker; +import net.minecraft.entity.monster.EntitySpellcasterIllager; +import net.minecraft.util.EnumHandSide; import net.minecraft.util.ResourceLocation; -import java.io.IOException; - -public class RenderPonyEvoker extends RenderLiving { +public class RenderPonyEvoker extends RenderPonyMob { private static final ResourceLocation EVOKER = new ResourceLocation("minelittlepony", "textures/entity/illager/evoker_pony.png"); public RenderPonyEvoker(RenderManager rendermanagerIn) { - super(rendermanagerIn, new ModelEvokerPony(), 0.5F); + super(rendermanagerIn, PMAPI.illager); } @Override - public void doRender(EntityEvoker entity, double x, double y, double z, float entityYaw, float partialTicks) { - ModelIllagerPony model = (ModelIllagerPony) this.getMainModel(); - - IResourceManager resources = Minecraft.getMinecraft().getResourceManager(); - try { - model.glowColor = 0x4444aa; - model.isUnicorn = false; - IResource resource = resources.getResource(EVOKER); - if (resource.hasMetadata()) { - PonyData meta = resource.getMetadata(PonyDataSerialzier.NAME); - if (meta != null) { - model.isUnicorn = meta.hasMagic(); - model.glowColor = meta.getGlowColor(); + protected void addLayers() { + this.addLayer(new LayerHeldPonyItem(this) { + public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (((EntitySpellcasterIllager) entitylivingbaseIn).func_193082_dl()) { + super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); } } - } catch (IOException e) { - e.printStackTrace(); - } - super.doRender(entity, x, y, z, entityYaw, partialTicks); + protected void translateToHand(EnumHandSide p_191361_1_) { + ((ModelIllagerPony) this.getRenderer().getMainModel()).getArmForSide(p_191361_1_).postRender(0.0625F); + } + }); } @Override - protected ResourceLocation getEntityTexture(EntityEvoker entity) { + protected ResourceLocation getTexture(EntityEvoker entity) { return EVOKER; } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java new file mode 100644 index 00000000..cccf68cf --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java @@ -0,0 +1,65 @@ +package com.minelittlepony.renderer; + +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.model.pony.ModelIllagerPony; +import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIllusionIllager; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; + + +public class RenderPonyIllusionIllager extends RenderPonyMob { + + private static final ResourceLocation TEXTURE = new ResourceLocation("minelittlepony", "textures/entity/illager/illusionist_pony.png"); + + public RenderPonyIllusionIllager(RenderManager renderManager) { + super(renderManager, PMAPI.illager); + } + + @Override + protected void addLayers() { + this.addLayer(new LayerHeldPonyItem(this) { + public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, + float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (((EntityIllusionIllager) entitylivingbaseIn).func_193082_dl() || ((EntityIllusionIllager) entitylivingbaseIn).func_193096_dj()) { + super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + } + } + + protected void translateToHand(EnumHandSide p_191361_1_) { + ((ModelIllagerPony) this.getRenderer().getMainModel()).getArmForSide(p_191361_1_).postRender(0.0625F); + } + }); + } + + @Override + protected ResourceLocation getTexture(EntityIllusionIllager entity) { + return TEXTURE; + } + + @Override + public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float partialTicks) { + if (entity.isInvisible()) { + Vec3d[] avec3d = entity.func_193098_a(partialTicks); + float f = this.handleRotationFloat(entity, partialTicks); + + for (int i = 0; i < avec3d.length; ++i) { + super.doRender(entity, + x + avec3d[i].x + (double) MathHelper.cos((float) i + f * 0.5F) * 0.025D, + y + avec3d[i].y + (double) MathHelper.cos((float) i + f * 0.75F) * 0.0125D, + z + avec3d[i].z + (double) MathHelper.cos((float) i + f * 0.7F) * 0.025D, + yaw, partialTicks); + } + } else { + super.doRender(entity, x, y, z, yaw, partialTicks); + } + } + + protected boolean func_193115_c(EntityIllusionIllager p_193115_1_) { + return true; + } +} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java index 6a5d721c..0b01349a 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java @@ -1,21 +1,20 @@ package com.minelittlepony.renderer; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.PonyGender; -import com.minelittlepony.PonyRace; -import com.minelittlepony.TailLengths; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; import com.minelittlepony.renderer.layer.LayerPonyArmor; -import com.minelittlepony.renderer.layer.LayerPonyElytra; import com.minelittlepony.renderer.layer.LayerPonyCustomHead; +import com.minelittlepony.renderer.layer.LayerPonyElytra; import com.voxelmodpack.hdskins.HDSkinManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; +import javax.annotation.Nonnull; + public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { protected PlayerModel playerModel; @@ -24,6 +23,11 @@ public abstract class RenderPonyMob extends RenderLiving super(renderManager, playerModel.getModel(), 0.5F); this.playerModel = playerModel; + addLayers(); + } + + protected void addLayers() { + this.addLayer(new LayerPonyArmor(this)); this.addLayer(new LayerHeldPonyItem(this)); // this.addLayer(new LayerArrow(this)); @@ -33,7 +37,7 @@ public abstract class RenderPonyMob extends RenderLiving @Override public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, - float partialTicks) { + float partialTicks) { double yOrigin = yPosition; if (entity.isSneaking()) { yOrigin -= 0.125D; @@ -47,12 +51,15 @@ public abstract class RenderPonyMob extends RenderLiving this.playerModel.getModel().isFlying = false; this.playerModel.getModel().isSleeping = false; - this.playerModel.getModel().metadata.setRace(PonyRace.EARTH); - this.playerModel.getModel().metadata.setGender(PonyGender.MARE); - this.playerModel.getModel().metadata.setTail(TailLengths.FULL); + ResourceLocation loc = getEntityTexture(entity); + if (loc != null) { + this.playerModel.apply(MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(loc).metadata); + } if (MineLittlePony.getConfig().showscale) { this.shadowSize = 0.4F; + } else { + this.shadowSize = 0.5F; } } @@ -61,7 +68,11 @@ public abstract class RenderPonyMob extends RenderLiving return playerModel; } - protected ResourceLocation getTexture(ResourceLocation res) { - return HDSkinManager.INSTANCE.getConvertedSkin(res); + @Override + @Nonnull + protected final ResourceLocation getEntityTexture(T entity) { + return HDSkinManager.INSTANCE.getConvertedSkin(getTexture(entity)); } + + protected abstract ResourceLocation getTexture(T entity); } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java b/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java index 2838c393..6d9a45b0 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java @@ -14,8 +14,8 @@ public class RenderPonyPigman extends RenderPonyMob { } @Override - protected ResourceLocation getEntityTexture(EntityPigZombie entity) { - return getTexture(PIGMAN); + protected ResourceLocation getTexture(EntityPigZombie entity) { + return PIGMAN; } } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java index c7945d9d..23736ac0 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java @@ -58,8 +58,8 @@ public class RenderPonySkeleton extends Rende } @Override - protected ResourceLocation getEntityTexture(Skeleton entity) { - return getTexture(SKELETON); + protected ResourceLocation getTexture(Skeleton entity) { + return SKELETON; } public static class Stray extends RenderPonySkeleton { @@ -70,8 +70,8 @@ public class RenderPonySkeleton extends Rende } @Override - protected ResourceLocation getEntityTexture(EntityStray entity) { - return getTexture(STRAY); + protected ResourceLocation getTexture(EntityStray entity) { + return STRAY; } } @@ -82,8 +82,8 @@ public class RenderPonySkeleton extends Rende } @Override - protected ResourceLocation getEntityTexture(EntityWitherSkeleton entity) { - return getTexture(WITHER); + protected ResourceLocation getTexture(EntityWitherSkeleton entity) { + return WITHER; } @Override diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java index 9d285b92..11bab18a 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java @@ -39,12 +39,12 @@ public class RenderPonyVillager extends RenderPonyMob { } @Override - protected ResourceLocation getEntityTexture(EntityVillager villager) { - return getTexture(getTextureForVillager(villager)); + protected ResourceLocation getTexture(EntityVillager villager) { + return getTextureForVillager(villager.getProfession()); } - private ResourceLocation getTextureForVillager(EntityVillager villager) { - switch (villager.getProfession()) { + private ResourceLocation getTextureForVillager(int profession) { + switch (profession) { case Villagers.FARMER: return FARMER; case Villagers.LIBRARIAN: diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java index 9f996fa7..5a8cc3fb 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java @@ -1,41 +1,45 @@ package com.minelittlepony.renderer; +import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.model.pony.ModelVindicatorPony; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityVindicator; import net.minecraft.util.EnumHandSide; import net.minecraft.util.ResourceLocation; -public class RenderPonyVindicator extends RenderLiving { +public class RenderPonyVindicator extends RenderPonyMob { private static final ResourceLocation VINDICATOR = new ResourceLocation("minelittlepony", "textures/entity/illager/vindicator_pony.png"); public RenderPonyVindicator(RenderManager renderManager) { - super(renderManager, new ModelVindicatorPony(), 0.5F); + super(renderManager, PMAPI.illager); + } + + @Override + protected void addLayers() { this.addLayer(new LayerHeldPonyItem(this) { @Override - public void doRenderLayer(EntityLivingBase vindicator, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void doPonyRender(EntityLivingBase vindicator, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, + float netHeadYaw, float headPitch, float scale) { if (((EntityVindicator) vindicator).isAggressive()) { - super.doRenderLayer(vindicator, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + super.doPonyRender(vindicator, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); } } @Override protected void translateToHand(EnumHandSide side) { - ((ModelIllagerPony) this.livingPonyEntity.getMainModel()).getArm(side).postRender(0.0625F); + ((ModelIllagerPony) this.getRenderer().getMainModel()).getArmForSide(side).postRender(0.0625F); } }); } @Override - protected ResourceLocation getEntityTexture(EntityVindicator entity) { + protected ResourceLocation getTexture(EntityVindicator entity) { return VINDICATOR; } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java index af2ef418..36822192 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java @@ -67,8 +67,8 @@ public class RenderPonyZombie extends RenderPonyMob } @Override - protected ResourceLocation getEntityTexture(Zombie zombie) { - return getTexture(ZOMBIE); + protected ResourceLocation getTexture(Zombie zombie) { + return ZOMBIE; } public static class Husk extends RenderPonyZombie { @@ -84,8 +84,8 @@ public class RenderPonyZombie extends RenderPonyMob } @Override - protected ResourceLocation getEntityTexture(EntityHusk zombie) { - return getTexture(HUSK); + protected ResourceLocation getTexture(EntityHusk zombie) { + return HUSK; } } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java index 47c8665a..36cae438 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java @@ -20,12 +20,12 @@ public class RenderPonyZombieVillager extends RenderPonyMob implements LayerRenderer { + + private final RenderLivingBase renderer; + private LayerRenderer layer; + + public AbstractPonyLayer(RenderLivingBase renderer, LayerRenderer humanLayer) { + this.renderer = renderer; + this.layer = humanLayer; + } + + public final void doRenderLayer(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, + float netHeadYaw, float headPitch, float scale) { + PlayerModel model = ((IRenderPony) renderer).getPony(); + if (model.getModel() instanceof ModelHumanPlayer) { + // render the human layer + layer.doRenderLayer(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); + } else { + // render the pony layer + doPonyRender(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); + } + } + + protected abstract void doPonyRender(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale); + + protected RenderLivingBase getRenderer() { + return renderer; + } + + @Override + public boolean shouldCombineTextures() { + return false; + } +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java new file mode 100644 index 00000000..e3ab3756 --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java @@ -0,0 +1,124 @@ +package com.minelittlepony.renderer.layer; + +import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.pony.ModelPlayerPony; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelParrot; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderParrot; +import net.minecraft.client.renderer.entity.layers.LayerEntityOnShoulder; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityParrot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nullable; +import java.util.UUID; + +public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { + + private final RenderManager rm; + private ShoulderEntity leftEntity; + private ShoulderEntity rightEntity; + + public LayerEntityOnPonyShoulder(RenderManager rm, RenderLivingBase renderer) { + super(renderer, new LayerEntityOnShoulder(rm)); + this.rm = rm; + } + + public void doPonyRender(EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, + float headPitch, float scale) { + + GlStateManager.enableRescaleNormal(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + + NBTTagCompound leftTag = player.func_192023_dk(); + + if (!leftTag.hasNoTags()) { + this.leftEntity = this.renderShoulderEntity(player, leftTag, this.leftEntity, + limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale, true); + } + + NBTTagCompound rightTag = player.func_192025_dl(); + + if (!rightTag.hasNoTags()) { + this.rightEntity = + this.renderShoulderEntity(player, rightTag, this.rightEntity, + limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale, false); + } + + GlStateManager.disableRescaleNormal(); + } + + @Nullable + private ShoulderEntity renderShoulderEntity(EntityPlayer player, NBTTagCompound tag, @Nullable ShoulderEntity shoulder, + float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, + boolean left) { + + if (shoulder == null || !shoulder.uuid.equals(tag.getUniqueId("UUID"))) { + UUID uuid = tag.getUniqueId("UUID"); + Class clazz = EntityList.func_192839_a(tag.getString("id")); + + // this wan't an entity + if (uuid == null || clazz == null) { + return null; + } + + if (clazz == EntityParrot.class) { + RenderLiving renderer = new RenderParrot(this.rm); + ModelBase model = new ModelParrot(); + ResourceLocation resource = RenderParrot.field_192862_a[tag.getInteger("Variant")]; + shoulder = new ShoulderEntity(uuid, renderer, model, resource, clazz); + } else { + // not supported? TODO experiment with other mobs, probably will be changed by forge + return null; + } + } + + shoulder.renderer.bindTexture(shoulder.resource); + GlStateManager.pushMatrix(); + float f = -1.8F; + float f1 = left ? 0.2F : -0.2F; + ModelPlayerPony model = ((ModelPlayerPony)getRenderer().getMainModel()); + model.transform(BodyPart.HEAD); + model.bipedHead.postRender(scale); + GlStateManager.translate(f1, f, -0.2F); + + if (shoulder.clazz == EntityParrot.class) { + ageInTicks = 0.0F; + netHeadYaw = 0; + } + + shoulder.model.setLivingAnimations(player, limbSwing, limbSwingAmount, partialTicks); + shoulder.model.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, player); + shoulder.model.render(player, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + + GlStateManager.popMatrix(); + + return shoulder; + } + + private class ShoulderEntity { + + public UUID uuid; + public RenderLivingBase renderer; + public ModelBase model; + public ResourceLocation resource; + public Class clazz; + + public ShoulderEntity(UUID uuid, RenderLivingBase renderer, + ModelBase model, ResourceLocation res, Class clazz) { + this.uuid = uuid; + this.renderer = renderer; + this.model = model; + this.resource = res; + this.clazz = clazz; + } + } +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java index 8ce6d503..e1c9f9f2 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java @@ -5,7 +5,6 @@ import com.minelittlepony.ducks.IRenderItem; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.pony.ModelHumanPlayer; import com.minelittlepony.model.pony.ModelPlayerPony; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; @@ -16,33 +15,26 @@ import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHandSide; import org.lwjgl.opengl.GL14; +import javax.annotation.Nullable; + import static net.minecraft.client.renderer.GlStateManager.*; -public class LayerHeldPonyItem implements LayerRenderer { - - protected final RenderLivingBase livingPonyEntity; - private LayerHeldItem held; +public class LayerHeldPonyItem extends AbstractPonyLayer { public LayerHeldPonyItem(RenderLivingBase livingPony) { - this.livingPonyEntity = livingPony; - this.held = new LayerHeldItem(livingPony); + super(livingPony, new LayerHeldItem(livingPony)); } @Override - public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, - float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { - ModelBase model = livingPonyEntity.getMainModel(); - if (model instanceof ModelHumanPlayer) { - held.doRenderLayer(entity, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, - p_177141_7_, scale); - return; - } + public void doPonyRender(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, + float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { + ModelBase model = getRenderer().getMainModel(); boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; ItemStack itemMain = entity.getHeldItemMainhand(); ItemStack itemOff = entity.getHeldItemOffhand(); @@ -55,7 +47,7 @@ public class LayerHeldPonyItem implements LayerRenderer { ((AbstractPonyModel) model).transform(BodyPart.LEGS); } - if (this.livingPonyEntity.getMainModel().isChild) { + if (model.isChild) { translate(0, 0.625, 0); rotate(-20, -1, 0, 0); scale(.5, .5, .5); @@ -79,7 +71,7 @@ public class LayerHeldPonyItem implements LayerRenderer { GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); - boolean isUnicorn = isUnicorn(this.livingPonyEntity.getMainModel()); + boolean isUnicorn = isUnicorn(this.getRenderer().getMainModel()); boolean isLeft = hand == EnumHandSide.LEFT; if (isUnicorn) { GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -.5); @@ -89,7 +81,7 @@ public class LayerHeldPonyItem implements LayerRenderer { Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); if (isUnicorn) { - PonyData metadata = ((AbstractPonyModel) this.livingPonyEntity.getMainModel()).metadata; + PonyData metadata = ((AbstractPonyModel) this.getRenderer().getMainModel()).metadata; this.renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); } GlStateManager.popMatrix(); @@ -101,23 +93,24 @@ public class LayerHeldPonyItem implements LayerRenderer { } protected void translateToHand(EnumHandSide hand) { - AbstractPonyModel thePony = ((IRenderPony) this.livingPonyEntity).getPony().getModel(); + AbstractPonyModel thePony = ((IRenderPony) this.getRenderer()).getPony().getModel(); if (thePony.metadata.hasMagic()) { ModelPlayerPony playerModel = (ModelPlayerPony) thePony; ModelRenderer unicornarm = hand == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; unicornarm.postRender(0.0625F); } else { - ((ModelBiped) this.livingPonyEntity.getMainModel()).postRenderArm(0.0625F, hand); + ((ModelBiped) this.getRenderer().getMainModel()).postRenderArm(0.0625F, hand); } } - public void renderItemGlow(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand, int glowColor) { + public void renderItemGlow(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand, + int glowColor) { // enchantments mess up the rendering ItemStack drop2 = drop.copy(); - if (drop2.hasEffect()) - drop2.setTagInfo("ench", null); - + if (drop2.hasEffect()) { + removeEnch(drop2.getTagCompound()); + } float red = (glowColor >> 16 & 255) / 255.0F; float green = (glowColor >> 8 & 255) / 255.0F; float blue = (glowColor & 255) / 255.0F; @@ -129,7 +122,7 @@ public class LayerHeldPonyItem implements LayerRenderer { GL14.glBlendColor(red, green, blue, alpha); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - ((IRenderItem)renderItem).useTransparency(true); + ((IRenderItem) renderItem).useTransparency(true); scale(1.1, 1.1, 1.1); @@ -138,13 +131,19 @@ public class LayerHeldPonyItem implements LayerRenderer { translate(.01, -.01, -.02); renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); - ((IRenderItem)renderItem).useTransparency(false); + ((IRenderItem) renderItem).useTransparency(false); enableLighting(); popMatrix(); // I hate rendering } + private void removeEnch(@Nullable NBTTagCompound tag) { + if (tag != null) { + tag.removeTag("ench"); + } + } + @Override public boolean shouldCombineTextures() { return false; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java index e47f176f..e038930e 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java @@ -5,7 +5,6 @@ import com.minelittlepony.ForgeProxy; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.pony.ModelHumanPlayer; import com.minelittlepony.model.pony.armor.ModelPonyArmor; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; @@ -13,7 +12,6 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.resources.ResourcePackRepository; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.EntityEquipmentSlot; @@ -23,41 +21,34 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; +import javax.annotation.Nullable; import java.io.IOException; import java.util.Map; -public class LayerPonyArmor implements LayerRenderer { +public class LayerPonyArmor extends AbstractPonyLayer { private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private static final Map HUMAN_ARMORS = Maps.newHashMap(); private static final Map PONY_ARMORS = Maps.newHashMap(); - private RenderLivingBase renderer; - private LayerBipedArmor humanArmor; private PlayerModel pony; - public LayerPonyArmor(RenderLivingBase entity) { - this.renderer = entity; - this.humanArmor = new LayerBipedArmor(entity); + public LayerPonyArmor(RenderLivingBase renderer) { + super(renderer, new LayerBipedArmor(renderer)); } @Override - public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - pony = ((IRenderPony) renderer).getPony(); - if (pony.getModel() instanceof ModelHumanPlayer) { - humanArmor.doRenderLayer(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); - } else { - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.FEET); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.LEGS); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.CHEST); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.HEAD); + public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + pony = ((IRenderPony) getRenderer()).getPony(); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.FEET); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.LEGS); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.CHEST); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.HEAD); - } } - private void renderArmor(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, - EntityEquipmentSlot armorSlot) { + private void renderArmor(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { @@ -77,16 +68,16 @@ public class LayerPonyArmor implements LayerRenderer { Tuple armors = getArmorTexture(entity, itemstack, armorSlot, null); prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond()); - this.renderer.bindTexture(armors.getFirst()); + this.getRenderer().bindTexture(armors.getFirst()); if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { - int j = itemarmor.getColor(itemstack); - float f7 = (j >> 16 & 255) / 255.0F; - float f8 = (j >> 8 & 255) / 255.0F; - float f9 = (j & 255) / 255.0F; - GlStateManager.color(f7, f8, f9, 1); + int color = itemarmor.getColor(itemstack); + float r = (color >> 16 & 255) / 255.0F; + float g = (color >> 8 & 255) / 255.0F; + float b = (color & 255) / 255.0F; + GlStateManager.color(r, g, b, 1); modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); - this.renderer.bindTexture(armors.getFirst()); + this.getRenderer().bindTexture(armors.getFirst()); } GlStateManager.color(1, 1, 1, 1); modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); @@ -97,7 +88,7 @@ public class LayerPonyArmor implements LayerRenderer { } } - private Tuple getArmorTexture(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, String type) { + private Tuple getArmorTexture(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, @Nullable String type) { ItemArmor item = (ItemArmor) itemstack.getItem(); String texture = item.getArmorMaterial().getName(); String domain = "minecraft"; @@ -133,7 +124,7 @@ public class LayerPonyArmor implements LayerRenderer { @SuppressWarnings("incomplete-switch") private void prepareToRender(ModelPonyArmor model, EntityEquipmentSlot slot, boolean isPony) { - model.setInvisible(false); + model.setVisible(false); switch (slot) { // feet @@ -177,7 +168,7 @@ public class LayerPonyArmor implements LayerRenderer { private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_, float p_177183_4_, float p_177183_5_, float p_177183_6_, float p_177183_7_, float p_177183_8_, float p_177183_9_) { float f7 = entitylivingbaseIn.ticksExisted + p_177183_5_; - this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES); + this.getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); GlStateManager.depthFunc(514); GlStateManager.depthMask(false); @@ -208,11 +199,6 @@ public class LayerPonyArmor implements LayerRenderer { GlStateManager.disableBlend(); } - @Override - public boolean shouldCombineTextures() { - return false; - } - private static ResourceLocation getHumanResource(String s1) { return HUMAN_ARMORS.computeIfAbsent(s1, ResourceLocation::new); } @@ -233,7 +219,7 @@ public class LayerPonyArmor implements LayerRenderer { return pony; } - private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, EntityEquipmentSlot slot, String type) { + private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) { return ForgeProxy.getArmorTexture(entity, item, def, slot, type); } diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java index 2490a79f..e6bd38b5 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java @@ -3,12 +3,10 @@ package com.minelittlepony.renderer.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.pony.ModelHumanPlayer; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.renderer.entity.layers.LayerCape; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; @@ -18,22 +16,16 @@ import javax.annotation.Nonnull; import static net.minecraft.client.renderer.GlStateManager.*; -public class LayerPonyCape implements LayerRenderer { - - private RenderLivingBase renderer; - private LayerCape cape; +public class LayerPonyCape extends AbstractPonyLayer { public LayerPonyCape(RenderLivingBase entity) { - renderer = entity; - this.cape = new LayerCape((RenderPlayer) entity); + super(entity, new LayerCape((RenderPlayer) entity)); } @Override - public void doRenderLayer(@Nonnull AbstractClientPlayer clientPlayer, float p2, float p3, float ticks, float p5, float p6, float p7, float scale) { - PlayerModel model = ((IRenderPony) renderer).getPony(); - if (model.getModel() instanceof ModelHumanPlayer) { - cape.doRenderLayer(clientPlayer, p2, p3, ticks, p5, p6, p7, scale); - } else if (clientPlayer.hasPlayerInfo() && !clientPlayer.isInvisible() + public void doPonyRender(@Nonnull AbstractClientPlayer clientPlayer, float p2, float p3, float ticks, float p5, float p6, float p7, float scale) { + PlayerModel model = ((IRenderPony) getRenderer()).getPony(); + if (clientPlayer.hasPlayerInfo() && !clientPlayer.isInvisible() && clientPlayer.isWearing(EnumPlayerModelParts.CAPE) && clientPlayer.getLocationCape() != null && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { pushMatrix(); @@ -70,7 +62,7 @@ public class LayerPonyCape implements LayerRenderer { rotate(-f14 / 2.0F, 0.0F, 1.0F, 0.0F); rotate(180.0F, 0.0F, 0.0F, 1.0F); rotate(90.0F, 1.0F, 0.0F, 0.0F); - this.renderer.bindTexture(clientPlayer.getLocationCape()); + this.getRenderer().bindTexture(clientPlayer.getLocationCape()); model.getModel().renderCape(0.0625F); popMatrix(); } diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java index 51685c21..b6672a54 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java @@ -4,13 +4,11 @@ import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ModelPonyElytra; -import com.minelittlepony.model.pony.ModelHumanPlayer; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerArmorBase; import net.minecraft.client.renderer.entity.layers.LayerElytra; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Items; @@ -20,27 +18,19 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -public class LayerPonyElytra implements LayerRenderer { +public class LayerPonyElytra extends AbstractPonyLayer { private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); - private RenderLivingBase renderPlayer; private ModelPonyElytra modelElytra = new ModelPonyElytra(); - private LayerElytra elytra; - public LayerPonyElytra(RenderLivingBase rp) { - this.renderPlayer = rp; - this.elytra = new LayerElytra(rp); + super(rp, new LayerElytra(rp)); } @Override - public void doRenderLayer(@Nonnull EntityLivingBase entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { + public void doPonyRender(@Nonnull EntityLivingBase entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { - AbstractPonyModel model = ((IRenderPony) this.renderPlayer).getPony().getModel(); - if (model instanceof ModelHumanPlayer) { - this.elytra.doRenderLayer(entity, swing, swingAmount, ticks, age, yaw, head, scale); - return; - } + AbstractPonyModel model = ((IRenderPony) this.getRenderer()).getPony().getModel(); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); @@ -51,14 +41,14 @@ public class LayerPonyElytra implements LayerRenderer { AbstractClientPlayer player = (AbstractClientPlayer) entity; if (player.isPlayerInfoSet() && player.getLocationElytra() != null) { - this.renderPlayer.bindTexture(player.getLocationElytra()); + this.getRenderer().bindTexture(player.getLocationElytra()); } else if (player.hasPlayerInfo() && player.getLocationCape() != null && player.isWearing(EnumPlayerModelParts.CAPE)) { - this.renderPlayer.bindTexture(player.getLocationCape()); + this.getRenderer().bindTexture(player.getLocationCape()); } else { - this.renderPlayer.bindTexture(TEXTURE_ELYTRA); + this.getRenderer().bindTexture(TEXTURE_ELYTRA); } } else { - this.renderPlayer.bindTexture(TEXTURE_ELYTRA); + this.getRenderer().bindTexture(TEXTURE_ELYTRA); } GlStateManager.pushMatrix(); @@ -68,7 +58,7 @@ public class LayerPonyElytra implements LayerRenderer { this.modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); if (itemstack.isItemEnchanted()) { - LayerArmorBase.renderEnchantedGlint(this.renderPlayer, entity, this.modelElytra, swing, swingAmount, ticks, age, yaw, head, scale); + LayerArmorBase.renderEnchantedGlint(this.getRenderer(), entity, this.modelElytra, swing, swingAmount, ticks, age, yaw, head, scale); } GlStateManager.popMatrix(); diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png index 7df9cf23..767e4994 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta b/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta deleted file mode 100644 index 6a6d5d41..00000000 --- a/src/main/resources/assets/minelittlepony/textures/entity/illager/evoker_pony.png.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pony": { - "race": "unicorn", - "glowColor": 3730130 - } -} \ No newline at end of file diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/illusionist_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/illager/illusionist_pony.png new file mode 100644 index 00000000..bf777cbd Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/entity/illager/illusionist_pony.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png index 2818f105..dd4d94ef 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/illager/vindicator_pony.png differ