From e93c4784eec4506071b358bfc473506d9299da0d Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 10 Apr 2018 13:56:48 +0200 Subject: [PATCH 01/96] Build/silence warnings --- build.number | 4 ++-- .../voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java | 3 ++- .../com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java | 3 ++- src/main/java/com/minelittlepony/MineLittlePony.java | 6 ++++-- .../java/com/minelittlepony/MissingRendererException.java | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build.number b/build.number index db875869..93eb7e02 100644 --- a/build.number +++ b/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Tue Jan 02 00:10:52 EST 2018 -build.number=495 +#Tue Apr 10 14:03:42 CAT 2018 +build.number=497 diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java index d65d27f2..eb3d1362 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java @@ -15,11 +15,12 @@ import java.util.UUID; * required because it has no useful constructor. This uses reflection * via Gson to create a new instance and populate the fields. */ +@SuppressWarnings("unused") public class TexturesPayloadBuilder { private static Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); - private long timestamp; + private long timestamp; private UUID profileId; private String profileName; private boolean isPublic; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java index 50046925..c23d50ce 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java @@ -14,7 +14,8 @@ import javax.annotation.Nullable; public class ValhallaSkinServer implements SkinServer { - private final String baseURL; + @SuppressWarnings("unused") + private final String baseURL; public ValhallaSkinServer(String baseURL) { this.baseURL = baseURL; diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index e9b16174..00ddc4aa 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -52,8 +52,10 @@ public class MineLittlePony { public static final String MOD_NAME = "Mine Little Pony"; public static final String MOD_VERSION = "@VERSION@"; - private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; - private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; + @SuppressWarnings("unused") + private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; + @SuppressWarnings("unused") + private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); private static MineLittlePony instance; diff --git a/src/main/java/com/minelittlepony/MissingRendererException.java b/src/main/java/com/minelittlepony/MissingRendererException.java index 34117e18..c2fdba27 100644 --- a/src/main/java/com/minelittlepony/MissingRendererException.java +++ b/src/main/java/com/minelittlepony/MissingRendererException.java @@ -1,8 +1,9 @@ package com.minelittlepony; public class MissingRendererException extends RuntimeException { + private static final long serialVersionUID = -6059469512902628663L; - public MissingRendererException(Class cl) { + public MissingRendererException(Class cl) { super("Could not find a renderer for " + cl.getName() + ". This is a bug."); } } From 694db391bb7fa35ba9c2d9982ba1d8bc6801295e Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 12 Apr 2018 16:21:19 +0200 Subject: [PATCH 02/96] Giants are now ponies --- .../com/minelittlepony/MineLittlePony.java | 4 ++++ .../java/com/minelittlepony/PonyManager.java | 2 +- .../java/com/minelittlepony/PonyRace.java | 3 +-- .../renderer/RenderPonyZombie.java | 19 +++++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index 00ddc4aa..ea915028 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -27,6 +27,7 @@ import net.minecraft.client.resources.data.MetadataSerializer; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityEvoker; +import net.minecraft.entity.monster.EntityGiantZombie; import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.monster.EntityIllusionIllager; import net.minecraft.entity.monster.EntityPigZombie; @@ -108,6 +109,7 @@ public class MineLittlePony { saveRenderer(rm, EntityZombieVillager.class); // zombies saveRenderer(rm, EntityZombie.class); + saveRenderer(rm, EntityGiantZombie.class); saveRenderer(rm, EntityHusk.class); // pig zombie saveRenderer(rm, EntityPigZombie.class); @@ -147,10 +149,12 @@ public class MineLittlePony { if (this.config.zombies) { ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie<>(rm)); ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm)); + ModUtilities.addRenderer(EntityGiantZombie.class, new RenderPonyZombie.Giant(rm)); logger.info("Zombies are now ponies."); } else { ModUtilities.addRenderer(EntityZombie.class, getRenderer(EntityZombie.class)); ModUtilities.addRenderer(EntityHusk.class, getRenderer(EntityHusk.class)); + ModUtilities.addRenderer(EntityGiantZombie.class, getRenderer(EntityGiantZombie.class)); } if (this.config.pigzombies) { diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index ed340954..8d52aa14 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -113,7 +113,7 @@ public class PonyManager implements IResourceManagerReloadListener { MineLittlePony.logger.error("Invalid bgponies.json in " + res.getResourcePackName(), e); } } - } catch (IOException e) { + } catch (IOException ignored) { // this isn't the exception you're looking for. } MineLittlePony.logger.info("Detected {} background ponies installed.", getNumberOfPonies()); diff --git a/src/main/java/com/minelittlepony/PonyRace.java b/src/main/java/com/minelittlepony/PonyRace.java index 7c775012..9fe4923d 100644 --- a/src/main/java/com/minelittlepony/PonyRace.java +++ b/src/main/java/com/minelittlepony/PonyRace.java @@ -11,8 +11,7 @@ public enum PonyRace { ZEBRA(false, false), REFORMED_CHANGELING(true, true), GRIFFIN(true, false), - HIPPOGRIFF(true, false), - ; + HIPPOGRIFF(true, false); private boolean wings; private boolean horn; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java index 23cc1df0..87936155 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java @@ -1,8 +1,10 @@ package com.minelittlepony.renderer; import com.minelittlepony.model.PMAPI; + import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.monster.EntityGiantZombie; import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.util.ResourceLocation; @@ -39,5 +41,22 @@ public class RenderPonyZombie extends RenderPonyMob } } + + public static class Giant extends RenderPonyMob { + public Giant(RenderManager renderManager) { + super(renderManager, PMAPI.zombie); + } + + @Override + protected void preRenderCallback(EntityGiantZombie entitylivingbaseIn, float partialTickTime) { + GlStateManager.scale(3, 3, 3); + super.preRenderCallback(entitylivingbaseIn, partialTickTime); + } + + @Override + protected ResourceLocation getTexture(EntityGiantZombie zombie) { + return ZOMBIE; + } + } } From fbb40134e28dd67c6838bdb75394783c9dad16f3 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Apr 2018 14:55:32 +0200 Subject: [PATCH 03/96] * Move player rendering to make use of the build in skinMap * Remove reflection * Use the interface (IPonyData) not the class --- .../java/com/minelittlepony/IPonyData.java | 10 + .../com/minelittlepony/MineLittlePony.java | 19 +- src/main/java/com/minelittlepony/Pony.java | 126 +++------ .../java/com/minelittlepony/PonyConfig.java | 37 +-- .../java/com/minelittlepony/PonyData.java | 8 +- .../java/com/minelittlepony/PonyManager.java | 43 ++- .../java/com/minelittlepony/PonyRace.java | 43 ++- .../java/com/minelittlepony/PonySize.java | 23 +- .../ducks/IDownloadImageData.java | 7 + .../com/minelittlepony/ducks/IPlayerInfo.java | 16 ++ .../minelittlepony/ducks/IRenderManager.java | 7 + .../com/minelittlepony/ducks/IRenderPony.java | 2 +- .../hdskins/gui/RenderPonyModel.java | 9 +- .../mixin/MixinNetworkPlayerInfo.java | 46 +++ .../mixin/MixinRenderManager.java | 22 ++ .../mixin/MixinRenderPlayer.java | 261 ------------------ .../mixin/MixinThreadDownloadImageData.java | 23 ++ .../minelittlepony/model/AbstractArmor.java | 4 +- .../model/AbstractPonyModel.java | 4 +- .../java/com/minelittlepony/model/PMAPI.java | 6 +- .../minelittlepony/model/PegasusWings.java | 29 +- .../com/minelittlepony/model/PlayerModel.java | 4 +- .../minelittlepony/model/PlayerModels.java | 27 ++ .../com/minelittlepony/model/UnicornHorn.java | 4 +- .../minelittlepony/model/package-info.java | 2 + .../java/com/minelittlepony/package-info.java | 2 + .../renderer/RenderPonyMob.java | 2 +- .../renderer/RenderPonySkeleton.java | 4 +- .../renderer/layer/LayerHeldPonyItem.java | 7 +- .../renderer/layer/LayerPonyArmor.java | 2 +- .../renderer/layer/LayerPonyCape.java | 2 +- .../renderer/layer/LayerPonyCustomHead.java | 2 +- .../renderer/layer/LayerPonyElytra.java | 2 +- .../renderer/player/RenderPonyBase.java | 158 +++++++++++ .../renderer/player/RenderPonyPlayer.java | 31 +++ .../com/minelittlepony/util/PonyFields.java | 30 -- .../com/minelittlepony/util/package-info.java | 7 - src/main/resources/minelp.mixin.json | 3 +- 38 files changed, 542 insertions(+), 492 deletions(-) create mode 100644 src/main/java/com/minelittlepony/ducks/IDownloadImageData.java create mode 100644 src/main/java/com/minelittlepony/ducks/IPlayerInfo.java create mode 100644 src/main/java/com/minelittlepony/ducks/IRenderManager.java create mode 100644 src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java create mode 100644 src/main/java/com/minelittlepony/mixin/MixinRenderManager.java delete mode 100644 src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java create mode 100644 src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java create mode 100644 src/main/java/com/minelittlepony/model/PlayerModels.java create mode 100644 src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java create mode 100644 src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java delete mode 100644 src/main/java/com/minelittlepony/util/PonyFields.java delete mode 100644 src/main/java/com/minelittlepony/util/package-info.java diff --git a/src/main/java/com/minelittlepony/IPonyData.java b/src/main/java/com/minelittlepony/IPonyData.java index 20b253ac..7698f168 100644 --- a/src/main/java/com/minelittlepony/IPonyData.java +++ b/src/main/java/com/minelittlepony/IPonyData.java @@ -6,5 +6,15 @@ import net.minecraft.client.resources.data.IMetadataSection; * Dummy interface so gson won't go crazy */ public interface IPonyData extends IMetadataSection { + PonyRace getRace(); + TailLengths getTail(); + + PonyGender getGender(); + + PonySize getSize(); + + int getGlowColor(); + + boolean hasMagic(); } diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index ea915028..d238c391 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -2,9 +2,8 @@ package com.minelittlepony; import com.google.common.collect.Maps; import com.minelittlepony.gui.PonySettingPanel; -import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; -import com.minelittlepony.hdskins.gui.RenderPonyModel; +import com.minelittlepony.model.PlayerModels; import com.minelittlepony.renderer.RenderPonyEvoker; import com.minelittlepony.renderer.RenderPonyIllusionIllager; import com.minelittlepony.renderer.RenderPonyPigman; @@ -14,6 +13,7 @@ import com.minelittlepony.renderer.RenderPonyVillager; import com.minelittlepony.renderer.RenderPonyVindicator; import com.minelittlepony.renderer.RenderPonyZombie; import com.minelittlepony.renderer.RenderPonyZombieVillager; +import com.minelittlepony.renderer.player.RenderPonyPlayer; import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.util.ModUtilities; import com.voxelmodpack.hdskins.HDSkinManager; @@ -49,7 +49,6 @@ public class MineLittlePony { public static final Logger logger = LogManager.getLogger("MineLittlePony"); - public static final String MOD_NAME = "Mine Little Pony"; public static final String MOD_VERSION = "@VERSION@"; @@ -98,7 +97,9 @@ public class MineLittlePony { RenderManager rm = minecraft.getRenderManager(); this.saveCurrentRenderers(rm); - ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); + //ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); + + this.initialisePlayerRenderers(rm); this.initializeMobRenderers(rm); } @@ -131,11 +132,15 @@ public class MineLittlePony { @SuppressWarnings("unchecked") private Render getRenderer(Class cl) { Render render = (Render) this.renderMap.get(cl); - if (render == null) - throw new MissingRendererException(cl); + if (render == null) throw new MissingRendererException(cl); return render; } + public void initialisePlayerRenderers(RenderManager rm) { + new RenderPonyPlayer(rm, false, PlayerModels.PONY); + new RenderPonyPlayer(rm, true, PlayerModels.PONY); + } + public void initializeMobRenderers(RenderManager rm) { if (this.config.villagers) { ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); @@ -209,7 +214,7 @@ public class MineLittlePony { } public PonyManager getManager() { - return this.ponyManager; + return ponyManager; } public static PonyConfig getConfig() { diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java index f4e24fd6..80d06751 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/Pony.java @@ -1,14 +1,11 @@ package com.minelittlepony; import com.google.common.base.MoreObjects; -import com.minelittlepony.model.PMAPI; +import com.minelittlepony.ducks.IDownloadImageData; import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.util.PonyFields; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.ThreadDownloadImageETag; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.ThreadDownloadImageData; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.IResource; @@ -27,45 +24,30 @@ import javax.annotation.concurrent.Immutable; public class Pony { private static final AtomicInteger ponyCount = new AtomicInteger(); + private final int ponyId = ponyCount.getAndIncrement(); private final ResourceLocation texture; - private final PonyData metadata; + private final IPonyData metadata; - public Pony(AbstractClientPlayer player) { - this.texture = player.getLocationSkin(); + private final boolean smallArms; + + public Pony(ResourceLocation resource, boolean slim) { + this.texture = resource; this.metadata = this.checkSkin(this.texture); - - MineLittlePony.logger.debug("+ Initialising new pony #{} for player {} ({}) with resource location {}.", - this.ponyId, player.getName(), player.getUniqueID(), this.texture); + this.smallArms = slim; } - public Pony(ResourceLocation resourceLocation) { - this(resourceLocation, null); - } + private IPonyData checkSkin(ResourceLocation textureResourceLocation) { + IPonyData data = checkPonyMeta(textureResourceLocation); + if (data != null) return data; - public Pony(ResourceLocation aTextureResourceLocation, @Nullable PonyData meta) { - this.texture = aTextureResourceLocation; - this.metadata = meta != null ? meta : this.checkSkin(this.texture); - - MineLittlePony.logger.debug("+ Initialising new pony #{} with resource location {}.", this.ponyId, this.texture); - } - - private PonyData checkSkin(ResourceLocation textureResourceLocation) { - PonyData data = checkPonyMeta(textureResourceLocation); - if (data == null) { - BufferedImage skinImage = this.getBufferedImage(textureResourceLocation); - if (skinImage != null) { - data = this.checkSkin(skinImage); - } else { - data = new PonyData(); - } - } - return data; + BufferedImage skinImage = this.getBufferedImage(textureResourceLocation); + return this.checkSkin(skinImage); } @Nullable - private PonyData checkPonyMeta(ResourceLocation location) { + private IPonyData checkPonyMeta(ResourceLocation location) { try { IResource res = Minecraft.getMinecraft().getResourceManager().getResource(location); if (res.hasMetadata()) { @@ -83,85 +65,61 @@ public class Pony { } @Nullable - private BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { - BufferedImage skinImage = null; + private BufferedImage getBufferedImage(@Nonnull ResourceLocation resource) { try { - IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); - skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); - MineLittlePony.logger.debug("Obtained skin from resource location {}", textureResourceLocation); - // this.checkSkin(skinImage); - } catch (IOException e) { + IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(resource); + BufferedImage skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); + MineLittlePony.logger.debug("Obtained skin from resource location {}", resource); - try { - ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation); - if (e2 instanceof ThreadDownloadImageData) { + return skinImage; + } catch (IOException ignored) { } - skinImage = PonyFields.downloadedImage.get((ThreadDownloadImageData) e2); - if (skinImage != null) { - MineLittlePony.logger.debug("Successfully reflected downloadedImage from texture object", e); - // this.checkSkin(skinImage); - } - } else if (e2 instanceof ThreadDownloadImageETag) { - skinImage = ((ThreadDownloadImageETag) e2).getBufferedImage(); - } else if (e2 instanceof DynamicTextureImage) { - skinImage = ((DynamicTextureImage) e2).getImage(); - } - } catch (Exception ignored) { + try { + ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(resource); + if (e2 instanceof IDownloadImageData) { + return ((IDownloadImageData) e2).getBufferedImage(); + } else if (e2 instanceof ThreadDownloadImageETag) { + return ((ThreadDownloadImageETag) e2).getBufferedImage(); + } else if (e2 instanceof DynamicTextureImage) { + return ((DynamicTextureImage) e2).getImage(); } - } + } catch (Exception ignored) { } - return skinImage; + return null; } - private PonyData checkSkin(BufferedImage bufferedimage) { + private IPonyData checkSkin(BufferedImage bufferedimage) { + if (bufferedimage == null) return new PonyData(); MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", this.ponyId, bufferedimage); return PonyData.parse(bufferedimage); } public boolean isPegasusFlying(EntityPlayer player) { //noinspection SimplifiableIfStatement - if (!this.metadata.getRace().hasWings()) { - return false; - } + if (!getRace(false).hasWings()) return false; + return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater() || player.isElytraFlying()); } - public PlayerModel getModel(boolean ignorePony, boolean smallArms) { - boolean is_a_pony = false; - switch (ignorePony ? PonyLevel.BOTH : MineLittlePony.getConfig().getPonyLevel()) { - case HUMANS: - is_a_pony = false; - break; - case BOTH: - is_a_pony = metadata.getRace() != PonyRace.HUMAN; - break; - case PONIES: - is_a_pony = true; - } + public PlayerModel getModel(boolean ignorePony) { + return getRace(ignorePony).getModel().getModel(smallArms); + } - PlayerModel model; - if (is_a_pony) { - model = smallArms ? PMAPI.ponySmall : PMAPI.pony; - } else { - model = smallArms ? PMAPI.humanSmall : PMAPI.human; - } - return model; + public PonyRace getRace(boolean ignorePony) { + return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony)); } public ResourceLocation getTexture() { - return this.texture; + return texture; } - public PonyData getMetadata() { + public IPonyData getMetadata() { return metadata; } @Override public String toString() { - return MoreObjects.toStringHelper(this) - .add("texture", texture) - .add("metadata", metadata) - .toString(); + return MoreObjects.toStringHelper(this).add("texture", texture).add("metadata", metadata).toString(); } } diff --git a/src/main/java/com/minelittlepony/PonyConfig.java b/src/main/java/com/minelittlepony/PonyConfig.java index ade2d0d1..db8ff1dd 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -8,30 +8,23 @@ import com.mumfrey.liteloader.modconfig.ExposableOptions; @ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned) public class PonyConfig implements Exposable { - @Expose - private PonyLevel ponylevel = PonyLevel.PONIES; - @Expose - public boolean sizes = true; - @Expose - public boolean snuzzles = true; - @Expose - public boolean hd = true; - @Expose - public boolean showscale = true; - @Expose - public boolean villagers = true; - @Expose - public boolean zombies = true; - @Expose - public boolean pigzombies = true; - @Expose - public boolean skeletons = true; - @Expose - public boolean illagers = true; + @Expose private PonyLevel ponylevel = PonyLevel.PONIES; + @Expose public boolean sizes = true; + @Expose public boolean snuzzles = true; + @Expose public boolean hd = true; + @Expose public boolean showscale = true; + @Expose public boolean villagers = true; + @Expose public boolean zombies = true; + @Expose public boolean pigzombies = true; + @Expose public boolean skeletons = true; + @Expose public boolean illagers = true; + + public PonyLevel getPonyLevel(boolean ignorePony) { + return ignorePony ? PonyLevel.BOTH : getPonyLevel(); + } public PonyLevel getPonyLevel() { - if (ponylevel == null) - ponylevel = PonyLevel.PONIES; + if (ponylevel == null) ponylevel = PonyLevel.PONIES; return ponylevel; } diff --git a/src/main/java/com/minelittlepony/PonyData.java b/src/main/java/com/minelittlepony/PonyData.java index d9ea3dfa..459fbe83 100644 --- a/src/main/java/com/minelittlepony/PonyData.java +++ b/src/main/java/com/minelittlepony/PonyData.java @@ -50,26 +50,32 @@ public class PonyData implements IPonyData { this.glowColor = glowColor; } + @Override public PonyRace getRace() { return race; } + @Override public TailLengths getTail() { return tailSize; } + @Override public PonyGender getGender() { return gender; } + @Override public PonySize getSize() { return MineLittlePony.getConfig().sizes ? size : PonySize.NORMAL; } + @Override public int getGlowColor() { return glowColor; } + @Override public boolean hasMagic() { return this.race != null && this.race.hasHorn() && this.glowColor != 0; } @@ -85,7 +91,7 @@ public class PonyData implements IPonyData { .toString(); } - static PonyData parse(BufferedImage image) { + static IPonyData parse(BufferedImage image) { int racePx = TriggerPixels.RACE.readColor(image); PonyRace race = RACE_COLORS.getOrDefault(racePx, PonyRace.HUMAN); diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 8d52aa14..e504dd44 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -4,7 +4,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.JsonParseException; +import com.minelittlepony.ducks.IPlayerInfo; import com.minelittlepony.model.PMAPI; + import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; @@ -32,8 +34,9 @@ public class PonyManager implements IResourceManagerReloadListener { private PonyConfig config; - private Map poniesCache = Maps.newHashMap(); - private Map backgroudPoniesCache = Maps.newHashMap(); + private Map + poniesCache = Maps.newHashMap(), + backgroudPoniesCache = Maps.newHashMap(); public PonyManager(PonyConfig config) { this.config = config; @@ -46,23 +49,27 @@ public class PonyManager implements IResourceManagerReloadListener { MineLittlePony.logger.info("Done initializing models."); } + public Pony getPony(ResourceLocation skinResourceLocation, boolean slim) { + return poniesCache.computeIfAbsent(skinResourceLocation, res -> new Pony(res, slim)); + } + + // TODO: Slim arms public Pony getPony(ResourceLocation skinResourceLocation) { - return this.poniesCache.computeIfAbsent(skinResourceLocation, Pony::new); + return getPony(skinResourceLocation, false); } public Pony getPony(AbstractClientPlayer player) { + Pony myLittlePony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms()); - Pony myLittlePony = this.poniesCache.computeIfAbsent(player.getLocationSkin(), res -> new Pony(player)); - - if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.getMetadata().getRace() == PonyRace.HUMAN) { - myLittlePony = this.getPonyFromBackgroundResourceRegistry(player); + if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.getMetadata().getRace().isHuman()) { + return this.getPonyFromBackgroundResourceRegistry(player); } return myLittlePony; } public Pony removePony(ResourceLocation location) { - return this.poniesCache.remove(location); + return poniesCache.remove(location); } private ResourceLocation getBackgroundPonyResource(UUID id) { @@ -78,22 +85,12 @@ public class PonyManager implements IResourceManagerReloadListener { } private Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) { - ResourceLocation textureResourceLocation; - if (player.isUser()) { - textureResourceLocation = getDefaultSkin(player.getUniqueID()); - } else { - textureResourceLocation = this.getBackgroundPonyResource(player.getUniqueID()); - } + return backgroudPoniesCache.computeIfAbsent(getDefaultPonyResource(player), res -> new Pony(res, false)); + } - Pony myLittlePony; - if (!this.backgroudPoniesCache.containsKey(textureResourceLocation)) { - myLittlePony = new Pony(textureResourceLocation); - this.backgroudPoniesCache.put(textureResourceLocation, myLittlePony); - } else { - myLittlePony = this.backgroudPoniesCache.get(textureResourceLocation); - } - - return myLittlePony; + private ResourceLocation getDefaultPonyResource(AbstractClientPlayer player) { + if (player.isUser()) return getDefaultSkin(player.getUniqueID()); + return getBackgroundPonyResource(player.getUniqueID()); } @Override diff --git a/src/main/java/com/minelittlepony/PonyRace.java b/src/main/java/com/minelittlepony/PonyRace.java index 9fe4923d..fa0f82b5 100644 --- a/src/main/java/com/minelittlepony/PonyRace.java +++ b/src/main/java/com/minelittlepony/PonyRace.java @@ -1,24 +1,28 @@ package com.minelittlepony; +import com.minelittlepony.model.PlayerModels; + public enum PonyRace { - HUMAN(false, false), - EARTH(false, false), - PEGASUS(true, false), - UNICORN(false, true), - ALICORN(true, true), - CHANGELING(true, true), - ZEBRA(false, false), - REFORMED_CHANGELING(true, true), - GRIFFIN(true, false), - HIPPOGRIFF(true, false); + HUMAN(PlayerModels.HUMAN, false, false), + EARTH(PlayerModels.PONY,false, false), + PEGASUS(PlayerModels.PONY, true, false), + UNICORN(PlayerModels.PONY, false, true), + ALICORN(PlayerModels.PONY, true, true), + CHANGELING(PlayerModels.PONY, true, true), + ZEBRA(PlayerModels.PONY, false, false), + REFORMED_CHANGELING(PlayerModels.PONY, true, true), + GRIFFIN(PlayerModels.PONY, true, false), + HIPPOGRIFF(PlayerModels.PONY, true, false); - private boolean wings; - private boolean horn; + private boolean wings, horn; - PonyRace(boolean wings, boolean horn) { + private PlayerModels model; + + PonyRace(PlayerModels model, boolean wings, boolean horn) { this.wings = wings; this.horn = horn; + this.model = model; } public boolean hasHorn() { @@ -28,4 +32,17 @@ public enum PonyRace { public boolean hasWings() { return wings; } + + public boolean isHuman() { + return this == HUMAN; + } + + public PlayerModels getModel() { + return model; + } + + public PonyRace getEffectiveRace(PonyLevel level) { + if (level == PonyLevel.HUMANS) return HUMAN; + return this; + } } diff --git a/src/main/java/com/minelittlepony/PonySize.java b/src/main/java/com/minelittlepony/PonySize.java index 9ac55246..400bf5f9 100644 --- a/src/main/java/com/minelittlepony/PonySize.java +++ b/src/main/java/com/minelittlepony/PonySize.java @@ -1,8 +1,23 @@ package com.minelittlepony; public enum PonySize { - NORMAL, - LARGE, - FOAL, - TALL + NORMAL(0.4f, 1f), + LARGE(0.5f, 0.8f), + FOAL(0.25f, 0.8f), + TALL(0.45f, 1f); + + private float shadowSize, scale; + + PonySize(float shadowSz, float scaleF) { + shadowSize = shadowSz; + scale = scaleF; + } + + public float getShadowSize() { + return shadowSize; + } + + public float getScaleFactor() { + return scale; + } } diff --git a/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java b/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java new file mode 100644 index 00000000..313fa923 --- /dev/null +++ b/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java @@ -0,0 +1,7 @@ +package com.minelittlepony.ducks; + +import java.awt.image.BufferedImage; + +public interface IDownloadImageData { + BufferedImage getBufferedImage(); +} diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java new file mode 100644 index 00000000..2a6a0df5 --- /dev/null +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -0,0 +1,16 @@ +package com.minelittlepony.ducks; + +import com.minelittlepony.Pony; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; + +public interface IPlayerInfo { + Pony getPony(); + + boolean usesSlimArms(); + + public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) { + return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID()); + } +} diff --git a/src/main/java/com/minelittlepony/ducks/IRenderManager.java b/src/main/java/com/minelittlepony/ducks/IRenderManager.java new file mode 100644 index 00000000..f401e645 --- /dev/null +++ b/src/main/java/com/minelittlepony/ducks/IRenderManager.java @@ -0,0 +1,7 @@ +package com.minelittlepony.ducks; + +import net.minecraft.client.renderer.entity.RenderPlayer; + +public interface IRenderManager { + void addPlayerSkin(String key, RenderPlayer render); +} diff --git a/src/main/java/com/minelittlepony/ducks/IRenderPony.java b/src/main/java/com/minelittlepony/ducks/IRenderPony.java index 439a3268..4f9e4621 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderPony.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderPony.java @@ -4,5 +4,5 @@ import com.minelittlepony.model.PlayerModel; public interface IRenderPony { - PlayerModel getPony(); + PlayerModel getPlayerModel(); } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 88b9ab81..d1b81f7d 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -26,14 +26,14 @@ public class RenderPonyModel extends RenderPlayerModel { @Override public ModelPlayer getEntityModel(EntityPonyModel playermodel) { - ResourceLocation loc = this.getEntityTexture(playermodel); + ResourceLocation loc = getEntityTexture(playermodel); if (loc == null) { return super.getEntityModel(playermodel); } + Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc); - // TODO small arms - PlayerModel pm = thePony.getModel(true, false); + PlayerModel pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); return pm.getModel(); @@ -46,8 +46,7 @@ public class RenderPonyModel extends RenderPlayerModel { return new AbstractPonyLayer(this, elytra) { @Override - public void doPonyRender(EntityLivingBase entityBase, float swing, float swingAmount, float ticks, float age, float yaw, float head, - float scale) { + public void doPonyRender(EntityLivingBase entityBase, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { EntityPonyModel entity = (EntityPonyModel) entityBase; diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java new file mode 100644 index 00000000..0d3378fc --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -0,0 +1,46 @@ +package com.minelittlepony.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.Pony; +import com.minelittlepony.ducks.IPlayerInfo; + +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.util.ResourceLocation; + +@Mixin(NetworkPlayerInfo.class) +public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { + + @Shadow + private String skinType; + + @Shadow + public abstract ResourceLocation getLocationSkin(); + + @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN")) + private void getSkinType(CallbackInfoReturnable info) { + ResourceLocation skin = getLocationSkin(); + if (skin != null) { + info.setReturnValue(getPony(skin).getRace(false).getModel().getId(usesSlimArms())); + } + } + + protected Pony getPony(ResourceLocation skin) { + return MineLittlePony.getInstance().getManager().getPony(skin, usesSlimArms()); + } + + @Override + public Pony getPony() { + return getPony(getLocationSkin()); + } + + @Override + public boolean usesSlimArms() { + return skinType == "slim"; + } +} diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java new file mode 100644 index 00000000..3ec1dbc3 --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java @@ -0,0 +1,22 @@ +package com.minelittlepony.mixin; + +import java.util.Map; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import com.minelittlepony.ducks.IRenderManager; + +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; + +@Mixin(RenderManager.class) +public abstract class MixinRenderManager implements IRenderManager { + @Shadow @Final + private Map skinMap; + + public void addPlayerSkin(String key, RenderPlayer render) { + skinMap.put(key, render); + } +} diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java deleted file mode 100644 index 7f5d519e..00000000 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderPlayer.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.minelittlepony.mixin; - -import com.minelittlepony.MineLittlePony; -import com.minelittlepony.Pony; -import com.minelittlepony.PonyRace; -import com.minelittlepony.PonySize; -import com.minelittlepony.ducks.IRenderPony; -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.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; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.entity.layers.LayerArrow; -import net.minecraft.util.ResourceLocation; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(RenderPlayer.class) -public abstract class MixinRenderPlayer extends RenderLivingBase implements IRenderPony { - - @Shadow - @Final - private boolean smallArms; - private PlayerModel playerModel; - private Pony thePony; - - @SuppressWarnings("ConstantConditions") - private MixinRenderPlayer(RenderManager renderManager) { - super(renderManager, null, 0.5F); - } - - @Inject( - method = "(Lnet/minecraft/client/renderer/entity/RenderManager;Z)V", - at = @At("RETURN")) - private void init(RenderManager renderManager, boolean useSmallArms, CallbackInfo ci) { - this.playerModel = smallArms ? PMAPI.ponySmall : PMAPI.pony; - this.mainModel = this.playerModel.getModel(); - this.layerRenderers.clear(); - - this.addLayer(new LayerPonyArmor(this)); - this.addLayer(new LayerHeldPonyItem(this)); - this.addLayer(new LayerArrow(this)); - this.addLayer(new LayerPonyCape(this)); - this.addLayer(new LayerPonyCustomHead(this)); - this.addLayer(new LayerPonyElytra(this)); - this.addLayer(new LayerEntityOnPonyShoulder(renderManager, this)); - - } - - @Inject( - method = "doRender(Lnet/minecraft/client/entity/AbstractClientPlayer;DDDFF)V", - at = @At("HEAD")) - private void onDoRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks, CallbackInfo ci) { - updateModel(player); - - this.playerModel.getModel().isSneak = player.isSneaking(); - this.playerModel.getModel().isFlying = thePony.isPegasusFlying(player); - this.playerModel.getModel().isSleeping = player.isPlayerSleeping(); - - if (MineLittlePony.getConfig().showscale && this.playerModel.getModel().metadata.getRace() != PonyRace.HUMAN) { - PonySize size = thePony.getMetadata().getSize(); - if (size == PonySize.FOAL) { - this.shadowSize = 0.25F; - } else if (size == PonySize.NORMAL) { - this.shadowSize = 0.4F; - } else if (size == PonySize.TALL) { - this.shadowSize = 0.45F; - } else { - this.shadowSize = 0.5F; - } - - } else { - this.shadowSize = 0.5F; - } - - } - - @Inject( - method = "renderLivingAt(Lnet/minecraft/client/entity/AbstractClientPlayer;DDD)V", - at = @At("RETURN")) - private void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition, CallbackInfo ci) { - - if (MineLittlePony.getConfig().showscale && !(playerModel.getModel() instanceof ModelHumanPlayer)) { - PonySize size = thePony.getMetadata().getSize(); - if (size == PonySize.LARGE) { - GlStateManager.scale(0.9F, 0.9F, 0.9F); - } else if (size == PonySize.NORMAL || size == PonySize.FOAL) { - GlStateManager.scale(0.8F, 0.8F, 0.8F); - } - } - } - - @Inject( - method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", - at = @At("HEAD")) - private void onRenderRightArm(AbstractClientPlayer player, CallbackInfo ci) { - updateModel(player); - bindEntityTexture(player); - } - - @Inject( - method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", - at = @At("HEAD")) - private void onRenderLeftArm(AbstractClientPlayer player, CallbackInfo ci) { - updateModel(player); - bindEntityTexture(player); - } - - @Redirect( - method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/model/ModelPlayer;bipedLeftArm:Lnet/minecraft/client/model/ModelRenderer;", - opcode = Opcodes.GETFIELD), - require = 2) - private ModelRenderer redirectLeftArm(ModelPlayer mr) { - return this.playerModel.getModel().steveLeftArm; - } - - @Redirect( - method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/model/ModelPlayer;bipedLeftArmwear:Lnet/minecraft/client/model/ModelRenderer;", - opcode = Opcodes.GETFIELD), - require = 2) - private ModelRenderer redirectLeftArmwear(ModelPlayer mr) { - return this.playerModel.getModel().steveLeftArmwear; - } - - @Redirect( - method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/model/ModelPlayer;bipedRightArm:Lnet/minecraft/client/model/ModelRenderer;", - opcode = Opcodes.GETFIELD), - require = 2) - private ModelRenderer redirectRightArm(ModelPlayer mr) { - return this.playerModel.getModel().steveRightArm; - } - - @Redirect( - method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/model/ModelPlayer;bipedRightArmwear:Lnet/minecraft/client/model/ModelRenderer;", - opcode = Opcodes.GETFIELD), - require = 2) - private ModelRenderer redirectRightArmwear(ModelPlayer mr) { - return this.playerModel.getModel().steveRightArmwear; - } - - @Inject( - method = "applyRotations(Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/entity/RenderLivingBase;" - + "applyRotations(Lnet/minecraft/entity/EntityLivingBase;FFF)V", - ordinal = 1, - shift = Shift.AFTER)) - private void onRotateCorpse(AbstractClientPlayer player, float yaw, float pitch, float ticks, CallbackInfo ci) { - if (this.mainModel instanceof ModelPlayerPony) { - // require arms to be stretched out (sorry mud ponies, no flight - // skills for you) - if (!((ModelPlayerPony) this.mainModel).rainboom) { - this.playerModel.getModel().motionPitch = 0; - return; - } - double motionX = player.posX - player.prevPosX; - double motionY = player.posY - player.prevPosY; - double motionZ = player.posZ - player.prevPosZ; - if (player.onGround) { - motionY = 0; - } - double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); - double angle = Math.atan2(motionY, dist); - if (!player.capabilities.isFlying) { - if (angle > 0) { - angle = 0; - } else { - angle /= 2; - } - } - - if (angle > Math.PI / 3) { - angle = Math.PI / 3; - } - if (angle < -Math.PI / 3) { - angle = -Math.PI / 3; - } - - this.playerModel.getModel().motionPitch = (float) Math.toDegrees(angle); - - GlStateManager.rotate((float) Math.toDegrees(angle), 1F, 0F, 0F); - - } - } - - @Redirect( - method = "applyRotations(Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V", - ordinal = 3)) - private void rotateRedirect(float f1, float f2, float f3, float f4) { - boolean isPony = this.playerModel.getModel() instanceof ModelPlayerPony; - if (isPony) { - f1 += 90; - } - - GlStateManager.rotate(f1, f2, f3, f4); - if (isPony) { - GlStateManager.translate(0, -1, 0); - } - } - - private void updateModel(AbstractClientPlayer player) { - this.thePony = MineLittlePony.getInstance().getManager().getPony(player); - this.playerModel = this.getModel(player); - this.mainModel = this.playerModel.getModel(); - this.playerModel.apply(thePony.getMetadata()); - } - - @Redirect( - method = "getEntityTexture(Lnet/minecraft/client/entity/AbstractClientPlayer;)Lnet/minecraft/util/ResourceLocation;", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getLocationSkin()Lnet/minecraft/util/ResourceLocation;")) - private ResourceLocation redirectEntityTexture(AbstractClientPlayer player) { - Pony thePony = MineLittlePony.getInstance().getManager().getPony(player); - return thePony.getTexture(); - } - - private PlayerModel getModel(AbstractClientPlayer player) { - ResourceLocation skin = getEntityTexture(player); - Pony thePony = MineLittlePony.getInstance().getManager().getPony(skin); - return thePony.getModel(false, this.smallArms); - } - - @Override - public PlayerModel getPony() { - return this.playerModel; - } -} diff --git a/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java new file mode 100644 index 00000000..990bc1c3 --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java @@ -0,0 +1,23 @@ +package com.minelittlepony.mixin; + +import java.awt.image.BufferedImage; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import com.minelittlepony.ducks.IDownloadImageData; + +import net.minecraft.client.renderer.ThreadDownloadImageData; +import net.minecraft.client.renderer.texture.SimpleTexture; +import net.minecraft.util.ResourceLocation; + +@Mixin(ThreadDownloadImageData.class) +public abstract class MixinThreadDownloadImageData extends SimpleTexture implements IDownloadImageData { + + private MixinThreadDownloadImageData(ResourceLocation textureResourceLocation) { + super(textureResourceLocation); + } + + @Accessor("bufferedImage") + public abstract BufferedImage getBufferedImage(); +} diff --git a/src/main/java/com/minelittlepony/model/AbstractArmor.java b/src/main/java/com/minelittlepony/model/AbstractArmor.java index 60299f09..3b620665 100644 --- a/src/main/java/com/minelittlepony/model/AbstractArmor.java +++ b/src/main/java/com/minelittlepony/model/AbstractArmor.java @@ -1,13 +1,13 @@ package com.minelittlepony.model; -import com.minelittlepony.PonyData; +import com.minelittlepony.IPonyData; public abstract class AbstractArmor { public AbstractPonyModel modelArmorChestplate; public AbstractPonyModel modelArmor; - public void apply(PonyData meta) { + public void apply(IPonyData meta) { modelArmorChestplate.metadata = meta; modelArmor.metadata = meta; } diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 6906c5b8..20f78adf 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,8 +1,10 @@ package com.minelittlepony.model; +import com.minelittlepony.IPonyData; import com.minelittlepony.PonyData; import com.minelittlepony.PonySize; import com.minelittlepony.model.pony.ModelPlayerPony; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; @@ -28,7 +30,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { public boolean isFlying; public boolean isSleeping; - public PonyData metadata = new PonyData(); + public IPonyData metadata = new PonyData(); public float motionPitch; diff --git a/src/main/java/com/minelittlepony/model/PMAPI.java b/src/main/java/com/minelittlepony/model/PMAPI.java index 1a3b3d4f..8022fd42 100644 --- a/src/main/java/com/minelittlepony/model/PMAPI.java +++ b/src/main/java/com/minelittlepony/model/PMAPI.java @@ -17,12 +17,14 @@ public final class PMAPI { public static final PlayerModel pony = new PlayerModel(new ModelPlayerPony(false)).setArmor(new PonyArmors()); public static final PlayerModel ponySmall = new PlayerModel(new ModelPlayerPony(true)).setArmor(new PonyArmors()); + + public static final PlayerModel human = new PlayerModel(new ModelHumanPlayer(false)).setArmor(new HumanArmors()); + public static final PlayerModel humanSmall = new PlayerModel(new ModelHumanPlayer(true)).setArmor(new HumanArmors()); + public static final PlayerModel zombie = new PlayerModel(new ModelZombiePony()).setArmor(new ZombiePonyArmors()); public static final PlayerModel skeleton = new PlayerModel(new ModelSkeletonPony()).setArmor(new SkeletonPonyArmors()); public static final PlayerModel villager = new PlayerModel(new ModelVillagerPony()).setArmor(new PonyArmors()); public static final PlayerModel illager = new PlayerModel(new ModelIllagerPony()).setArmor(new PonyArmors()); - public static final PlayerModel human = new PlayerModel(new ModelHumanPlayer(false)).setArmor(new HumanArmors()); - public static final PlayerModel humanSmall = new PlayerModel(new ModelHumanPlayer(true)).setArmor(new HumanArmors()); public static void init() { for (Field field : PMAPI.class.getFields()) { diff --git a/src/main/java/com/minelittlepony/model/PegasusWings.java b/src/main/java/com/minelittlepony/model/PegasusWings.java index bfe6ac5f..5c733ab5 100644 --- a/src/main/java/com/minelittlepony/model/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/PegasusWings.java @@ -5,25 +5,19 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; +// TODO: Break this down into ModelWing (one for each side) public class PegasusWings extends ModelBase implements PonyModelConstants { private final AbstractPonyModel pony; - public ModelRenderer[] leftWing; - public ModelRenderer[] rightWing; - - public ModelRenderer[] leftWingExt; - public ModelRenderer[] rightWingExt; + public ModelRenderer[] leftWing = new ModelRenderer[3], rightWing = new ModelRenderer[3], + leftWingExt = new ModelRenderer[6], rightWingExt = new ModelRenderer[6]; public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) { this.pony = pony; - this.leftWing = new ModelRenderer[3]; - this.rightWing = new ModelRenderer[3]; - this.leftWingExt = new ModelRenderer[6]; - this.rightWingExt = new ModelRenderer[6]; - + // TODO: Don't add the model to the pony if you're just going to remove it again. for (int i = 0; i < leftWing.length; i++) { this.leftWing[i] = new ModelRenderer(pony, 56, 32); this.pony.boxList.remove(this.leftWing[i]); @@ -46,21 +40,27 @@ public class PegasusWings extends ModelBase implements PonyModelConstants { this.leftWing[0].addBox(4.0F, 5.0F, 2.0F, 2, 6, 2, stretch); this.leftWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.leftWing[0].rotateAngleX = ROTATE_90; + this.leftWing[1].addBox(4.0F, 5.0F, 4.0F, 2, 8, 2, stretch); this.leftWing[1].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.leftWing[1].rotateAngleX = ROTATE_90; + this.leftWing[2].addBox(4.0F, 5.0F, 6.0F, 2, 6, 2, stretch); this.leftWing[2].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.leftWing[2].rotateAngleX = ROTATE_90; + this.rightWing[0].addBox(-6.0F, 5.0F, 2.0F, 2, 6, 2, stretch); this.rightWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.rightWing[0].rotateAngleX = ROTATE_90; + this.rightWing[1].addBox(-6.0F, 5.0F, 4.0F, 2, 8, 2, stretch); this.rightWing[1].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.rightWing[1].rotateAngleX = ROTATE_90; + this.rightWing[2].addBox(-6.0F, 5.0F, 6.0F, 2, 6, 2, stretch); this.rightWing[2].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.rightWing[2].rotateAngleX = ROTATE_90; + this.leftWingExt[0].addBox(-0.5F, 6.0F, 0.0F, 1, 8, 2, stretch + 0.1F); this.leftWingExt[0].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); this.leftWingExt[1].addBox(-0.5F, -1.2F, -0.2F, 1, 8, 2, stretch - 0.2F); @@ -163,19 +163,20 @@ public class PegasusWings extends ModelBase implements PonyModelConstants { this.rightWingExt[i].rotateAngleZ = RIGHT_WING_ROTATE_ANGLE_Z_SNEAK; } } - + + // TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box. private void unsneak(float tick) { if (pony.isFlying) { - float WingRotateAngleZ = MathHelper.sin(tick * 0.536F) * 1.0F; + float WingRotateAngleZ = (MathHelper.sin(tick * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; for (ModelRenderer aLeftWingExt : this.leftWingExt) { aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aLeftWingExt.rotateAngleZ = -WingRotateAngleZ - ROTATE_270 - 0.4F; + aLeftWingExt.rotateAngleZ = -WingRotateAngleZ; } for (ModelRenderer aRightWingExt : this.rightWingExt) { aRightWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aRightWingExt.rotateAngleZ = WingRotateAngleZ + ROTATE_270 + 0.4F; + aRightWingExt.rotateAngleZ = WingRotateAngleZ; } } } diff --git a/src/main/java/com/minelittlepony/model/PlayerModel.java b/src/main/java/com/minelittlepony/model/PlayerModel.java index dda87cf6..a0520365 100644 --- a/src/main/java/com/minelittlepony/model/PlayerModel.java +++ b/src/main/java/com/minelittlepony/model/PlayerModel.java @@ -1,6 +1,6 @@ package com.minelittlepony.model; -import com.minelittlepony.PonyData; +import com.minelittlepony.IPonyData; public class PlayerModel { @@ -31,7 +31,7 @@ public class PlayerModel { return armor; } - public void apply(PonyData meta) { + public void apply(IPonyData meta) { model.metadata = meta; armor.apply(meta); } diff --git a/src/main/java/com/minelittlepony/model/PlayerModels.java b/src/main/java/com/minelittlepony/model/PlayerModels.java new file mode 100644 index 00000000..54ddfa5d --- /dev/null +++ b/src/main/java/com/minelittlepony/model/PlayerModels.java @@ -0,0 +1,27 @@ +package com.minelittlepony.model; + +public class PlayerModels { + public static final PlayerModels + HUMAN = new PlayerModels("default", "slim", PMAPI.human, PMAPI.humanSmall), + PONY = new PlayerModels("pony", "slimpony", PMAPI.pony, PMAPI.ponySmall); + + private final PlayerModel normal, slim; + + private final String normalKey, slimKey; + + public PlayerModels(String normalKey, String slimKey, PlayerModel normal, PlayerModel slim) { + this.normalKey = normalKey; + this.slimKey = slimKey; + + this.normal = normal; + this.slim = slim; + } + + public PlayerModel getModel(boolean slim) { + return slim ? this.slim : this.normal; + } + + public String getId(boolean useSlimArms) { + return useSlimArms ? slimKey : normalKey; + } +} diff --git a/src/main/java/com/minelittlepony/model/UnicornHorn.java b/src/main/java/com/minelittlepony/model/UnicornHorn.java index 33109cab..cc1e82a8 100644 --- a/src/main/java/com/minelittlepony/model/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/UnicornHorn.java @@ -1,6 +1,6 @@ package com.minelittlepony.model; -import com.minelittlepony.PonyData; +import com.minelittlepony.IPonyData; import com.minelittlepony.renderer.HornGlowRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -37,7 +37,7 @@ public class UnicornHorn extends ModelBase implements PonyModelConstants { @Override public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - PonyData data = pony.metadata; + IPonyData data = pony.metadata; if (data.getRace().hasHorn()) { this.horn.render(scale); diff --git a/src/main/java/com/minelittlepony/model/package-info.java b/src/main/java/com/minelittlepony/model/package-info.java index 6dc6a541..40137727 100644 --- a/src/main/java/com/minelittlepony/model/package-info.java +++ b/src/main/java/com/minelittlepony/model/package-info.java @@ -5,3 +5,5 @@ package com.minelittlepony.model; import mcp.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; + +// TODO: Class/Enum/Interface names are inconsistent. \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/package-info.java b/src/main/java/com/minelittlepony/package-info.java index a1d3fc42..28e8a42d 100644 --- a/src/main/java/com/minelittlepony/package-info.java +++ b/src/main/java/com/minelittlepony/package-info.java @@ -5,3 +5,5 @@ package com.minelittlepony; import mcp.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; + +// TODO: Code style is inconsistent \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java index 55defcab..c7d098e2 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java @@ -66,7 +66,7 @@ public abstract class RenderPonyMob extends RenderLiving } @Override - public PlayerModel getPony() { + public PlayerModel getPlayerModel() { return playerModel; } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java index 5646f897..cca3441f 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java @@ -26,8 +26,8 @@ public class RenderPonySkeleton extends Rende this.addLayer(new LayerBipedArmor(this) { @Override protected void initArmor() { - this.modelLeggings = getPony().getArmor().modelArmor; - this.modelArmor = getPony().getArmor().modelArmorChestplate; + this.modelLeggings = getPlayerModel().getArmor().modelArmor; + this.modelArmor = getPlayerModel().getArmor().modelArmorChestplate; } }); } diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java index e1c9f9f2..c47061eb 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java @@ -1,11 +1,12 @@ package com.minelittlepony.renderer.layer; -import com.minelittlepony.PonyData; +import com.minelittlepony.IPonyData; 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.ModelPlayerPony; + import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; @@ -81,7 +82,7 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); if (isUnicorn) { - PonyData metadata = ((AbstractPonyModel) this.getRenderer().getMainModel()).metadata; + IPonyData metadata = ((AbstractPonyModel) this.getRenderer().getMainModel()).metadata; this.renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); } GlStateManager.popMatrix(); @@ -93,7 +94,7 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { } protected void translateToHand(EnumHandSide hand) { - AbstractPonyModel thePony = ((IRenderPony) this.getRenderer()).getPony().getModel(); + AbstractPonyModel thePony = ((IRenderPony) this.getRenderer()).getPlayerModel().getModel(); if (thePony.metadata.hasMagic()) { ModelPlayerPony playerModel = (ModelPlayerPony) thePony; ModelRenderer unicornarm = hand == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java index e038930e..f057dc88 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java @@ -40,7 +40,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { @Override public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - pony = ((IRenderPony) getRenderer()).getPony(); + pony = ((IRenderPony) getRenderer()).getPlayerModel(); 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); diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java index e6bd38b5..0ea172a6 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java @@ -24,7 +24,7 @@ public class LayerPonyCape extends AbstractPonyLayer { @Override 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(); + PlayerModel model = ((IRenderPony) getRenderer()).getPlayerModel(); if (clientPlayer.hasPlayerInfo() && !clientPlayer.isInvisible() && clientPlayer.isWearing(EnumPlayerModelParts.CAPE) && clientPlayer.getLocationCape() != null && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java index 73cf1829..0d1e011c 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java @@ -98,7 +98,7 @@ public class LayerPonyCustomHead implements LayerRenderer { } private PlayerModel getModel() { - return ((IRenderPony) renderer).getPony(); + return ((IRenderPony) renderer).getPlayerModel(); } @Override diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java index b6672a54..bb68ff74 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java @@ -30,7 +30,7 @@ public class LayerPonyElytra extends AbstractPonyLayer { @Override public void doPonyRender(@Nonnull EntityLivingBase entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { - AbstractPonyModel model = ((IRenderPony) this.getRenderer()).getPony().getModel(); + AbstractPonyModel model = ((IRenderPony) this.getRenderer()).getPlayerModel().getModel(); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java new file mode 100644 index 00000000..d2013dcc --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java @@ -0,0 +1,158 @@ +package com.minelittlepony.renderer.player; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.Pony; +import com.minelittlepony.ducks.IRenderManager; +import com.minelittlepony.ducks.IRenderPony; +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.PlayerModels; +import com.minelittlepony.model.pony.ModelPlayerPony; +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.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.renderer.entity.layers.LayerArrow; + +public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony { + + protected final boolean smallArms; + + private PlayerModel playerModel; + private AbstractPonyModel ponyModel; + + private Pony pony; + + public RenderPonyBase(RenderManager manager, boolean useSmallArms, PlayerModels model) { + super(manager, useSmallArms); + smallArms = useSmallArms; + + setPlayerModel(model.getModel(useSmallArms)); + + layerRenderers.clear(); + addExtraLayers(); + + ((IRenderManager)manager).addPlayerSkin(model.getId(useSmallArms), this); + } + + protected void addExtraLayers() { + addLayer(new LayerPonyArmor(this)); + addLayer(new LayerHeldPonyItem(this)); + addLayer(new LayerArrow(this)); + addLayer(new LayerPonyCape(this)); + addLayer(new LayerPonyCustomHead(this)); + addLayer(new LayerPonyElytra(this)); + addLayer(new LayerEntityOnPonyShoulder(renderManager, this)); + } + + @Override + protected void renderLivingAt(AbstractClientPlayer player, double x, double y, double z) { + float s = getScaleFactor(); + GlStateManager.scale(s, s, s); + super.renderLivingAt(player, x, y, z); + } + + @Override + public void doRender(AbstractClientPlayer player, double x, double y, double z, float entityYaw, float partialTicks) { + updateModel(player); + + ponyModel.isSneak = player.isSneaking(); + ponyModel.isSleeping = player.isPlayerSleeping(); + ponyModel.isFlying = pony.isPegasusFlying(player); + + shadowSize = getPonyShadowScale(); + + super.doRender(player, x, y, z, entityYaw, partialTicks); + } + + @Override + public void renderRightArm(AbstractClientPlayer player) { + updateModel(player); + super.renderRightArm(player); + } + + @Override + public void renderLeftArm(AbstractClientPlayer player) { + updateModel(player); + super.renderLeftArm(player); + } + + @Override + protected void applyRotations(AbstractClientPlayer player, float yaw, float pitch, float ticks) { + super.applyRotations(player, yaw, pitch, ticks); + + if (player.isElytraFlying()) { + transformFlying(player, yaw, pitch, ticks); + + return; + } + + if (player.isEntityAlive() && player.isPlayerSleeping()) return; + + // require arms to be stretched out (sorry mud ponies, no flight skills for you) + if (!((ModelPlayerPony) ponyModel).rainboom) { + ponyModel.motionPitch = 0; + return; + } + double motionX = player.posX - player.prevPosX; + double motionY = player.posY - player.prevPosY; + double motionZ = player.posZ - player.prevPosZ; + if (player.onGround) { + motionY = 0; + } + double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); + double angle = Math.atan2(motionY, dist); + + if (!player.capabilities.isFlying) { + if (angle > 0) { + angle = 0; + } else { + angle /= 2; + } + } + + if (angle > Math.PI / 3) angle = Math.PI / 3; + if (angle < -Math.PI / 3) angle = -Math.PI / 3; + + ponyModel.motionPitch = (float) Math.toDegrees(angle); + + GlStateManager.rotate((float) Math.toDegrees(angle), 1, 0, 0); + } + + @Override + public AbstractPonyModel getMainModel() { + return (AbstractPonyModel)super.getMainModel(); + } + + @Override + public PlayerModel getPlayerModel() { + return playerModel; + } + + protected void setPlayerModel(PlayerModel model) { + playerModel = model; + mainModel = ponyModel = playerModel.getModel(); + } + + protected void updateModel(AbstractClientPlayer player) { + pony = MineLittlePony.getInstance().getManager().getPony(player); + playerModel.apply(pony.getMetadata()); + } + + public Pony getPony() { + return pony; + } + + protected abstract float getPonyShadowScale(); + + protected abstract float getScaleFactor(); + + protected abstract void transformFlying(AbstractClientPlayer player, float yaw, float pitch, float ticks); +} diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java new file mode 100644 index 00000000..b58db2be --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java @@ -0,0 +1,31 @@ +package com.minelittlepony.renderer.player; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.model.PlayerModels; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderManager; + +public class RenderPonyPlayer extends RenderPonyBase { + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) { + super(renderManager, useSmallArms, model); + } + + @Override + protected float getPonyShadowScale() { + if (!MineLittlePony.getConfig().showscale) return .5f; + return getPony().getMetadata().getSize().getShadowSize(); + } + + @Override + protected float getScaleFactor() { + return getPony().getMetadata().getSize().getScaleFactor(); + } + + @Override + protected void transformFlying(AbstractClientPlayer player, float yaw, float pitch, float ticks) { + GlStateManager.rotate(90, 1, 0, 0); + GlStateManager.translate(0, -1, 0); + } +} diff --git a/src/main/java/com/minelittlepony/util/PonyFields.java b/src/main/java/com/minelittlepony/util/PonyFields.java deleted file mode 100644 index 30bf4e93..00000000 --- a/src/main/java/com/minelittlepony/util/PonyFields.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.minelittlepony.util; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.util.PrivateFields; -import net.minecraft.client.renderer.ThreadDownloadImageData; - -import java.awt.image.BufferedImage; - -public class PonyFields extends PrivateFields { - - public static final PrivateFields downloadedImage = field(ThreadDownloadImageData.class, PonyObf.downloadedImage); - - protected PonyFields(Class

owner, Obf obf) { - super(owner, obf); - } - - private static PrivateFields field(Class

c, Obf o) { - return new PonyFields<>(c, o); - } - - private static class PonyObf extends Obf { - - public static Obf downloadedImage = new PonyObf("field_110560_d", "l", "bufferedImage"); - - protected PonyObf(String seargeName, String obfName, String mcpName) { - super(seargeName, obfName, mcpName); - } - - } -} diff --git a/src/main/java/com/minelittlepony/util/package-info.java b/src/main/java/com/minelittlepony/util/package-info.java deleted file mode 100644 index 5463a5b9..00000000 --- a/src/main/java/com/minelittlepony/util/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package com.minelittlepony.util; - -import mcp.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index 3f7f8074..f6ca6fd4 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -5,7 +5,8 @@ "refmap": "minelp.mixin.refmap.json", "compatibilityLevel": "JAVA_8", "mixins": [ - "MixinRenderPlayer", + "MixinThreadDownloadImageData", + "MixinNetworkPlayerInfo", "MixinRenderItem" ] } From a99873f8e6d75dfbe32b2f1162f0e533d722e890 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Apr 2018 16:46:53 +0200 Subject: [PATCH 04/96] Refactor PegasusWings --- .../com/minelittlepony/model/ModelWing.java | 95 +++++++++ .../minelittlepony/model/PegasusWings.java | 181 +++--------------- 2 files changed, 120 insertions(+), 156 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/ModelWing.java diff --git a/src/main/java/com/minelittlepony/model/ModelWing.java b/src/main/java/com/minelittlepony/model/ModelWing.java new file mode 100644 index 00000000..4dc3b94b --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ModelWing.java @@ -0,0 +1,95 @@ +package com.minelittlepony.model; + +import net.minecraft.client.model.ModelRenderer; + +// TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box. +public class ModelWing implements PonyModelConstants { + public ModelRenderer[] folded = new ModelRenderer[3], + extended = new ModelRenderer[6]; + + public ModelWing(AbstractPonyModel pony, boolean mirror, float xOffset, float yOffset, float stretch, int texY) { + + // TODO: Don't add the model to the pony if you're just going to remove it again. + for (int i = 0; i < folded.length; i++) { + folded[i] = new ModelRenderer(pony, 56, texY); + pony.boxList.remove(folded[i]); + } + + for (int i = 0; i < extended.length; i++) { + extended[i] = new ModelRenderer(pony, 56, texY + 3); + pony.boxList.remove(extended[i]); + // this seems to hide the wings being a different size when folded + extended[i].mirror = mirror; + } + + init(yOffset, xOffset, stretch); + addFeathers(mirror ? -1 : 1, yOffset, stretch); + } + + private void addFeathers(float r, float y, float scale) { + addFeather(0, r, y, 6.0F, 0.0F, 8, scale + 0.1F); + addFeather(1, r, y, -1.2F, -0.2F, 8, scale + 0.2F); + addFeather(2, r, y, 1.8F, 1.3F, 8, scale - 0.1F); + addFeather(3, r, y, 5.0F, 2.0F, 8, scale); + addFeather(4, r, y, 0.0F, -0.2F, 6, scale + 0.3F); + addFeather(5, r, y, 0.0F, 0.2F, 3, scale + 0.19F); + } + + private void addFeather(int i, float r, float Y, float y, float z, int h, float scale) { + extended[i].addBox(-0.5f, y, z, 1, h, 2, scale); + extended[i].setRotationPoint(r * LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + Y, LEFT_WING_EXT_RP_Z); + } + + private void init(float x, float y, float scale) { + initFeather(folded[0], y, x, 2.0F, 6, scale); + initFeather(folded[1], y, x, 4.0F, 8, scale); + initFeather(folded[2], y, x, 6.0F, 6, scale); + } + + private void initFeather(ModelRenderer wing, float y, float x, float z, int h, float scale) { + wing.addBox(x, 5f, z, 2, h, 2, scale); + wing.setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + y, WING_FOLDED_RP_Z); + wing.rotateAngleX = ROTATE_90; + } + + public void updateModelRotation(float swing) { + for (ModelRenderer feather : folded) { + feather.rotateAngleY = swing * 0.2F; + } + } + + public void rotate(float angle) { + for (ModelRenderer feather : folded) { + feather.rotateAngleX = angle; + } + // Special + extended[1].rotateAngleX -= 0.85F; + extended[2].rotateAngleX -= 0.75F; + extended[3].rotateAngleX -= 0.5F; + extended[5].rotateAngleX -= 0.85F; + } + + private void renderWing(ModelRenderer[] wing, float scale) { + for (ModelRenderer feather : wing) { + feather.render(scale); + } + } + + public void render(boolean standing, float scale) { + renderWing(standing ? folded : extended, scale); + } + + public void rotateSneaked(float rotZ) { + for (ModelRenderer feather : extended) { + feather.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; + feather.rotateAngleZ = rotZ; + } + } + + public void rotateUnsneaked(float angle) { + for (ModelRenderer aLeftWingExt : extended) { + aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; + aLeftWingExt.rotateAngleZ = -angle; + } + } +} diff --git a/src/main/java/com/minelittlepony/model/PegasusWings.java b/src/main/java/com/minelittlepony/model/PegasusWings.java index 5c733ab5..abe89553 100644 --- a/src/main/java/com/minelittlepony/model/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/PegasusWings.java @@ -1,184 +1,53 @@ package com.minelittlepony.model; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; -// TODO: Break this down into ModelWing (one for each side) public class PegasusWings extends ModelBase implements PonyModelConstants { - private final AbstractPonyModel pony; - - public ModelRenderer[] leftWing = new ModelRenderer[3], rightWing = new ModelRenderer[3], - leftWingExt = new ModelRenderer[6], rightWingExt = new ModelRenderer[6]; - + + public final ModelWing leftWing, rightWing; + public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) { this.pony = pony; - - // TODO: Don't add the model to the pony if you're just going to remove it again. - for (int i = 0; i < leftWing.length; i++) { - this.leftWing[i] = new ModelRenderer(pony, 56, 32); - this.pony.boxList.remove(this.leftWing[i]); - } - for (int i = 0; i < rightWing.length; i++) { - this.rightWing[i] = new ModelRenderer(pony, 56, 16); - this.pony.boxList.remove(this.rightWing[i]); - } - for (int i = 0; i < leftWingExt.length; i++) { - this.leftWingExt[i] = new ModelRenderer(pony, 56, 35); - this.pony.boxList.remove(this.leftWingExt[i]); - } - for (int i = 0; i < rightWingExt.length; i++) { - this.rightWingExt[i] = new ModelRenderer(pony, 56, 19); - // this seems to hide the wings being a different size when folded - this.rightWingExt[i].mirror = true; - this.pony.boxList.remove(this.rightWingExt[i]); - } - - this.leftWing[0].addBox(4.0F, 5.0F, 2.0F, 2, 6, 2, stretch); - this.leftWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); - this.leftWing[0].rotateAngleX = ROTATE_90; - this.leftWing[1].addBox(4.0F, 5.0F, 4.0F, 2, 8, 2, stretch); - this.leftWing[1].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); - this.leftWing[1].rotateAngleX = ROTATE_90; - - this.leftWing[2].addBox(4.0F, 5.0F, 6.0F, 2, 6, 2, stretch); - this.leftWing[2].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); - this.leftWing[2].rotateAngleX = ROTATE_90; - - this.rightWing[0].addBox(-6.0F, 5.0F, 2.0F, 2, 6, 2, stretch); - this.rightWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); - this.rightWing[0].rotateAngleX = ROTATE_90; - - this.rightWing[1].addBox(-6.0F, 5.0F, 4.0F, 2, 8, 2, stretch); - this.rightWing[1].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); - this.rightWing[1].rotateAngleX = ROTATE_90; - - this.rightWing[2].addBox(-6.0F, 5.0F, 6.0F, 2, 6, 2, stretch); - this.rightWing[2].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); - this.rightWing[2].rotateAngleX = ROTATE_90; - - this.leftWingExt[0].addBox(-0.5F, 6.0F, 0.0F, 1, 8, 2, stretch + 0.1F); - this.leftWingExt[0].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); - this.leftWingExt[1].addBox(-0.5F, -1.2F, -0.2F, 1, 8, 2, stretch - 0.2F); - this.leftWingExt[1].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); - this.leftWingExt[2].addBox(-0.5F, 1.8F, 1.3F, 1, 8, 2, stretch - 0.1F); - this.leftWingExt[2].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); - this.leftWingExt[3].addBox(-0.5F, 5.0F, 2.0F, 1, 8, 2, stretch); - this.leftWingExt[3].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); - this.leftWingExt[4].addBox(-0.5F, 0.0F, -0.2F, 1, 6, 2, stretch + 0.3F); - this.leftWingExt[4].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); - this.leftWingExt[5].addBox(-0.5F, 0.0F, 0.2F, 1, 3, 2, stretch + 0.19F); - this.leftWingExt[5].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z); - this.rightWingExt[0].addBox(-0.5F, 6.0F, 0.0F, 1, 8, 2, stretch + 0.1F); - this.rightWingExt[0].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z); - this.rightWingExt[1].addBox(-0.5F, -1.2F, -0.2F, 1, 8, 2, stretch - 0.2F); - this.rightWingExt[1].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z); - this.rightWingExt[2].addBox(-0.5F, 1.8F, 1.3F, 1, 8, 2, stretch - 0.1F); - this.rightWingExt[2].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z); - this.rightWingExt[3].addBox(-0.5F, 5.0F, 2.0F, 1, 8, 2, stretch); - this.rightWingExt[3].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z); - this.rightWingExt[4].addBox(-0.5F, 0.0F, -0.2F, 1, 6, 2, stretch + 0.3F); - this.rightWingExt[4].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z); - this.rightWingExt[5].addBox(-0.5F, 0.0F, 0.2F, 1, 3, 2, stretch + 0.19F); - this.rightWingExt[5].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z); + leftWing = new ModelWing(pony, false, 4f, yOffset, stretch, 32); + rightWing = new ModelWing(pony, true, -6f, yOffset, stretch, 16); } - + @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 ticks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { float bodySwingRotation = 0.0F; if (pony.swingProgress > -9990.0F && !pony.metadata.hasMagic()) { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } - for (ModelRenderer aLeftWing : this.leftWing) { - aLeftWing.rotateAngleY = bodySwingRotation * 0.2F; - } - for (ModelRenderer aRightWing : this.rightWing) { - aRightWing.rotateAngleY = bodySwingRotation * 0.2F; - } + + leftWing.updateModelRotation(bodySwingRotation); + rightWing.updateModelRotation(bodySwingRotation); + if (pony.isSneak && !pony.isFlying) { - this.sneak(); - } else { - this.unsneak(ageInTicks); - + leftWing.rotateSneaked(LEFT_WING_ROTATE_ANGLE_Z_SNEAK); + rightWing.rotateSneaked(RIGHT_WING_ROTATE_ANGLE_Z_SNEAK); + } else if (pony.isFlying) { + float WingRotateAngleZ = (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; + + leftWing.rotateUnsneaked(-WingRotateAngleZ); + rightWing.rotateUnsneaked(WingRotateAngleZ); } - - float angle = ROTATE_90; - - for (ModelRenderer aLeftWing : this.leftWing) { - aLeftWing.rotateAngleX = angle; - } - for (ModelRenderer aRightWing : this.rightWing) { - aRightWing.rotateAngleX = angle; - } - // Special - this.leftWingExt[1].rotateAngleX -= 0.85F; - this.leftWingExt[2].rotateAngleX -= 0.75F; - this.leftWingExt[3].rotateAngleX -= 0.5F; - this.leftWingExt[5].rotateAngleX -= 0.85F; - this.rightWingExt[1].rotateAngleX -= 0.85F; - this.rightWingExt[2].rotateAngleX -= 0.75F; - this.rightWingExt[3].rotateAngleX -= 0.5F; - this.rightWingExt[5].rotateAngleX -= 0.85F; - + + leftWing.rotate(ROTATE_90); + rightWing.rotate(ROTATE_90); } - + @Override public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (pony.metadata.getRace().hasWings()) { - if (!pony.isFlying && !pony.isSneak) { - - for (ModelRenderer aLeftWing : this.leftWing) { - aLeftWing.render(scale); - } - - for (ModelRenderer aRightWing : this.rightWing) { - aRightWing.render(scale); - } - } else { - - for (ModelRenderer aLeftWingExt : this.leftWingExt) { - aLeftWingExt.render(scale); - } - - for (ModelRenderer aRightWingExt : this.rightWingExt) { - aRightWingExt.render(scale); - } - } + boolean standing = !pony.isFlying && !pony.isSneak; + leftWing.render(standing, scale); + rightWing.render(standing, scale); } } - - private void sneak() { - for (ModelRenderer aLeftWingExt : this.leftWingExt) { - aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aLeftWingExt.rotateAngleZ = LEFT_WING_ROTATE_ANGLE_Z_SNEAK; - } - - for (int i = 0; i < this.leftWingExt.length; ++i) { - this.rightWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - this.rightWingExt[i].rotateAngleZ = RIGHT_WING_ROTATE_ANGLE_Z_SNEAK; - } - } - - // TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box. - private void unsneak(float tick) { - if (pony.isFlying) { - float WingRotateAngleZ = (MathHelper.sin(tick * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; - - for (ModelRenderer aLeftWingExt : this.leftWingExt) { - aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aLeftWingExt.rotateAngleZ = -WingRotateAngleZ; - } - - for (ModelRenderer aRightWingExt : this.rightWingExt) { - aRightWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aRightWingExt.rotateAngleZ = WingRotateAngleZ; - } - } - } - } From 0657a03703caea21273d5a05063341eb408b9f81 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Apr 2018 17:12:23 +0200 Subject: [PATCH 05/96] Models now work again --- .../com/minelittlepony/MineLittlePony.java | 6 +- src/main/java/com/minelittlepony/Pony.java | 3 +- .../java/com/minelittlepony/PonyManager.java | 68 ++++++++++--------- .../hdskins/gui/RenderPonyModel.java | 2 +- .../mixin/MixinNetworkPlayerInfo.java | 25 ++++--- .../com/minelittlepony/model/ModelWing.java | 14 ++-- .../minelittlepony/model/PegasusWings.java | 8 +-- .../minelittlepony/model/PlayerModels.java | 54 ++++++++------- .../renderer/RenderPonyMob.java | 2 +- .../renderer/player/RenderPonyBase.java | 16 +++-- .../renderer/player/RenderPonyPlayer.java | 6 +- src/main/resources/minelp.mixin.json | 3 +- 12 files changed, 111 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index d238c391..1116b9f0 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -3,7 +3,7 @@ package com.minelittlepony; import com.google.common.collect.Maps; import com.minelittlepony.gui.PonySettingPanel; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; -import com.minelittlepony.model.PlayerModels; +import com.minelittlepony.model.PMAPI; import com.minelittlepony.renderer.RenderPonyEvoker; import com.minelittlepony.renderer.RenderPonyIllusionIllager; import com.minelittlepony.renderer.RenderPonyPigman; @@ -137,8 +137,8 @@ public class MineLittlePony { } public void initialisePlayerRenderers(RenderManager rm) { - new RenderPonyPlayer(rm, false, PlayerModels.PONY); - new RenderPonyPlayer(rm, true, PlayerModels.PONY); + new RenderPonyPlayer(rm, false, "pony", PMAPI.pony); + new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall); } public void initializeMobRenderers(RenderManager rm) { diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java index 80d06751..1c022a4b 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/Pony.java @@ -107,7 +107,8 @@ public class Pony { } public PonyRace getRace(boolean ignorePony) { - return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony)); + return PonyRace.ALICORN; + //return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony)); } public ResourceLocation getTexture() { diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index e504dd44..909ddb6f 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -8,6 +8,7 @@ import com.minelittlepony.ducks.IPlayerInfo; import com.minelittlepony.model.PMAPI; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; @@ -53,46 +54,47 @@ public class PonyManager implements IResourceManagerReloadListener { return poniesCache.computeIfAbsent(skinResourceLocation, res -> new Pony(res, slim)); } - // TODO: Slim arms - public Pony getPony(ResourceLocation skinResourceLocation) { - return getPony(skinResourceLocation, false); - } - public Pony getPony(AbstractClientPlayer player) { - Pony myLittlePony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms()); + Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms()); - if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.getMetadata().getRace().isHuman()) { - return this.getPonyFromBackgroundResourceRegistry(player); + if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { + return getBackgroundPony(player.getUniqueID()); } - return myLittlePony; + return pony; + } + + public Pony getPony(ResourceLocation resource, UUID uuid) { + Pony pony = getPony(resource, isSlimSkin(uuid)); + + if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { + return getBackgroundPony(uuid); + } + + return pony; + } + + public Pony getDefaultPony(UUID uuid) { + if (config.getPonyLevel() != PonyLevel.PONIES) { + return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid)); + } + + return getBackgroundPony(uuid); + } + + private Pony getBackgroundPony(UUID uuid) { + if (getNumberOfPonies() == 0) return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); + + int bgi = uuid.hashCode() % this.getNumberOfPonies(); + while (bgi < 0) bgi += this.getNumberOfPonies(); + + return getPony(backgroundPonyList.get(bgi), false); } public Pony removePony(ResourceLocation location) { return poniesCache.remove(location); } - private ResourceLocation getBackgroundPonyResource(UUID id) { - if (getNumberOfPonies() > 0) { - int backgroundIndex = id.hashCode() % this.getNumberOfPonies(); - if (backgroundIndex < 0) { - backgroundIndex += this.getNumberOfPonies(); - } - - return backgroundPonyList.get(backgroundIndex); - } - return STEVE; - } - - private Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) { - return backgroudPoniesCache.computeIfAbsent(getDefaultPonyResource(player), res -> new Pony(res, false)); - } - - private ResourceLocation getDefaultPonyResource(AbstractClientPlayer player) { - if (player.isUser()) return getDefaultSkin(player.getUniqueID()); - return getBackgroundPonyResource(player.getUniqueID()); - } - @Override public void onResourceManagerReload(IResourceManager resourceManager) { this.poniesCache.clear(); @@ -117,7 +119,11 @@ public class PonyManager implements IResourceManagerReloadListener { } private ResourceLocation getDefaultSkin(UUID uuid) { - return (uuid.hashCode() & 1) == 0 ? STEVE : ALEX; + return isSlimSkin(uuid) ? ALEX : STEVE; + } + + public static boolean isSlimSkin(UUID uuid) { + return (uuid.hashCode() & 1) == 1; } private int getNumberOfPonies() { diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index d1b81f7d..5499409b 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -31,7 +31,7 @@ public class RenderPonyModel extends RenderPlayerModel { return super.getEntityModel(playermodel); } - Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc); + Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId()); PlayerModel pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java index 0d3378fc..744e2417 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -8,7 +8,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.MineLittlePony; import com.minelittlepony.Pony; +import com.minelittlepony.PonyManager; import com.minelittlepony.ducks.IPlayerInfo; +import com.mojang.authlib.GameProfile; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.util.ResourceLocation; @@ -22,25 +24,26 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { @Shadow public abstract ResourceLocation getLocationSkin(); - @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN")) - private void getSkinType(CallbackInfoReturnable info) { - ResourceLocation skin = getLocationSkin(); - if (skin != null) { - info.setReturnValue(getPony(skin).getRace(false).getModel().getId(usesSlimArms())); - } - } + @Shadow + public abstract GameProfile getGameProfile(); - protected Pony getPony(ResourceLocation skin) { - return MineLittlePony.getInstance().getManager().getPony(skin, usesSlimArms()); + @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true) + private void getSkinType(CallbackInfoReturnable info) { + info.setReturnValue(getPony().getRace(false).getModel().getId(usesSlimArms())); } @Override public Pony getPony() { - return getPony(getLocationSkin()); + ResourceLocation skin = getLocationSkin(); + if (skin == null) { + return MineLittlePony.getInstance().getManager().getDefaultPony(getGameProfile().getId()); + } + return MineLittlePony.getInstance().getManager().getPony(skin, getGameProfile().getId()); } @Override public boolean usesSlimArms() { - return skinType == "slim"; + if (skinType == null) return PonyManager.isSlimSkin(getGameProfile().getId()); + return "slim".equals(skinType); } } diff --git a/src/main/java/com/minelittlepony/model/ModelWing.java b/src/main/java/com/minelittlepony/model/ModelWing.java index 4dc3b94b..decc273a 100644 --- a/src/main/java/com/minelittlepony/model/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/ModelWing.java @@ -41,9 +41,9 @@ public class ModelWing implements PonyModelConstants { } private void init(float x, float y, float scale) { - initFeather(folded[0], y, x, 2.0F, 6, scale); - initFeather(folded[1], y, x, 4.0F, 8, scale); - initFeather(folded[2], y, x, 6.0F, 6, scale); + initFeather(folded[0], y, x, 2F, 6, scale); + initFeather(folded[1], y, x, 4F, 8, scale); + initFeather(folded[2], y, x, 6F, 6, scale); } private void initFeather(ModelRenderer wing, float y, float x, float z, int h, float scale) { @@ -69,16 +69,12 @@ public class ModelWing implements PonyModelConstants { extended[5].rotateAngleX -= 0.85F; } - private void renderWing(ModelRenderer[] wing, float scale) { - for (ModelRenderer feather : wing) { + public void render(boolean standing, float scale) { + for (ModelRenderer feather : (standing ? folded : extended)) { feather.render(scale); } } - public void render(boolean standing, float scale) { - renderWing(standing ? folded : extended, scale); - } - public void rotateSneaked(float rotZ) { for (ModelRenderer feather : extended) { feather.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; diff --git a/src/main/java/com/minelittlepony/model/PegasusWings.java b/src/main/java/com/minelittlepony/model/PegasusWings.java index abe89553..c28b8f83 100644 --- a/src/main/java/com/minelittlepony/model/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/PegasusWings.java @@ -7,16 +7,16 @@ import net.minecraft.util.math.MathHelper; public class PegasusWings extends ModelBase implements PonyModelConstants { private final AbstractPonyModel pony; - + public final ModelWing leftWing, rightWing; - + public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) { this.pony = pony; leftWing = new ModelWing(pony, false, 4f, yOffset, stretch, 32); rightWing = new ModelWing(pony, true, -6f, yOffset, stretch, 16); } - + @Override public void setRotationAngles(float limbSwing, float limbSwingAmount, float ticks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { @@ -41,7 +41,7 @@ public class PegasusWings extends ModelBase implements PonyModelConstants { leftWing.rotate(ROTATE_90); rightWing.rotate(ROTATE_90); } - + @Override public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (pony.metadata.getRace().hasWings()) { diff --git a/src/main/java/com/minelittlepony/model/PlayerModels.java b/src/main/java/com/minelittlepony/model/PlayerModels.java index 54ddfa5d..046da213 100644 --- a/src/main/java/com/minelittlepony/model/PlayerModels.java +++ b/src/main/java/com/minelittlepony/model/PlayerModels.java @@ -1,27 +1,33 @@ package com.minelittlepony.model; -public class PlayerModels { - public static final PlayerModels - HUMAN = new PlayerModels("default", "slim", PMAPI.human, PMAPI.humanSmall), - PONY = new PlayerModels("pony", "slimpony", PMAPI.pony, PMAPI.ponySmall); - - private final PlayerModel normal, slim; - - private final String normalKey, slimKey; - - public PlayerModels(String normalKey, String slimKey, PlayerModel normal, PlayerModel slim) { - this.normalKey = normalKey; - this.slimKey = slimKey; - - this.normal = normal; - this.slim = slim; - } - - public PlayerModel getModel(boolean slim) { - return slim ? this.slim : this.normal; - } - - public String getId(boolean useSlimArms) { - return useSlimArms ? slimKey : normalKey; - } +public enum PlayerModels { + HUMAN("default", "slim", () -> PMAPI.human, () -> PMAPI.humanSmall), + PONY("pony", "slimpony", () -> PMAPI.pony, () -> PMAPI.ponySmall); + + private final ModelResolver normal, slim; + + private final String normalKey, slimKey; + + PlayerModels(String normalKey, String slimKey, ModelResolver normal, ModelResolver slim) { + this.normalKey = normalKey; + this.slimKey = slimKey; + + this.normal = normal; + this.slim = slim; + } + + public PlayerModel getModel(boolean slim) { + return slim ? this.slim.resolve() : this.normal.resolve(); + } + + public String getId(boolean useSlimArms) { + return useSlimArms ? slimKey : normalKey; + } + + /** + * FIXME: PMAPI fields are null when the game starts. + */ + static interface ModelResolver { + PlayerModel resolve(); + } } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java index c7d098e2..fbbabead 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java @@ -54,7 +54,7 @@ public abstract class RenderPonyMob extends RenderLiving this.playerModel.getModel().isSleeping = false; ResourceLocation loc = getEntityTexture(entity); - this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc).getMetadata()); + this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata()); if (mainModel.isChild) { this.shadowSize = 0.25F; diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java index d2013dcc..75ee2eec 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java @@ -6,7 +6,6 @@ import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.PlayerModels; import com.minelittlepony.model.pony.ModelPlayerPony; import com.minelittlepony.renderer.layer.LayerEntityOnPonyShoulder; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; @@ -20,6 +19,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.renderer.entity.layers.LayerArrow; +import net.minecraft.util.ResourceLocation; public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony { @@ -30,16 +30,16 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony private Pony pony; - public RenderPonyBase(RenderManager manager, boolean useSmallArms, PlayerModels model) { + public RenderPonyBase(RenderManager manager, boolean useSmallArms, String id, PlayerModel model) { super(manager, useSmallArms); smallArms = useSmallArms; - setPlayerModel(model.getModel(useSmallArms)); + setPlayerModel(model); layerRenderers.clear(); addExtraLayers(); - ((IRenderManager)manager).addPlayerSkin(model.getId(useSmallArms), this); + ((IRenderManager)manager).addPlayerSkin(id, this); } protected void addExtraLayers() { @@ -75,12 +75,14 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony @Override public void renderRightArm(AbstractClientPlayer player) { updateModel(player); + bindEntityTexture(player); super.renderRightArm(player); } @Override public void renderLeftArm(AbstractClientPlayer player) { updateModel(player); + bindEntityTexture(player); super.renderLeftArm(player); } @@ -126,9 +128,9 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony GlStateManager.rotate((float) Math.toDegrees(angle), 1, 0, 0); } - @Override - public AbstractPonyModel getMainModel() { - return (AbstractPonyModel)super.getMainModel(); + public ResourceLocation getEntityTexture(AbstractClientPlayer entity) { + updateModel(entity); + return pony.getTexture(); } @Override diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java index b58db2be..107a04ea 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java @@ -1,15 +1,15 @@ package com.minelittlepony.renderer.player; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.model.PlayerModels; +import com.minelittlepony.model.PlayerModel; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { - public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) { - super(renderManager, useSmallArms, model); + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, PlayerModel model) { + super(renderManager, useSmallArms, id, model); } @Override diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index f6ca6fd4..03138d99 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -7,6 +7,7 @@ "mixins": [ "MixinThreadDownloadImageData", "MixinNetworkPlayerInfo", - "MixinRenderItem" + "MixinRenderItem", + "MixinRenderManager" ] } From e25326eed49b79eefba155f4c69572533dcf2781 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Apr 2018 21:24:29 +0200 Subject: [PATCH 06/96] Fixed position/angle of the wings --- src/main/java/com/minelittlepony/model/ModelWing.java | 2 +- src/main/java/com/minelittlepony/model/PegasusWings.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ModelWing.java b/src/main/java/com/minelittlepony/model/ModelWing.java index decc273a..5eb5d13b 100644 --- a/src/main/java/com/minelittlepony/model/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/ModelWing.java @@ -22,7 +22,7 @@ public class ModelWing implements PonyModelConstants { extended[i].mirror = mirror; } - init(yOffset, xOffset, stretch); + init(xOffset, yOffset, stretch); addFeathers(mirror ? -1 : 1, yOffset, stretch); } diff --git a/src/main/java/com/minelittlepony/model/PegasusWings.java b/src/main/java/com/minelittlepony/model/PegasusWings.java index c28b8f83..b185c2c4 100644 --- a/src/main/java/com/minelittlepony/model/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/PegasusWings.java @@ -30,12 +30,12 @@ public class PegasusWings extends ModelBase implements PonyModelConstants { if (pony.isSneak && !pony.isFlying) { leftWing.rotateSneaked(LEFT_WING_ROTATE_ANGLE_Z_SNEAK); - rightWing.rotateSneaked(RIGHT_WING_ROTATE_ANGLE_Z_SNEAK); + rightWing.rotateSneaked(-LEFT_WING_ROTATE_ANGLE_Z_SNEAK); } else if (pony.isFlying) { float WingRotateAngleZ = (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; - leftWing.rotateUnsneaked(-WingRotateAngleZ); - rightWing.rotateUnsneaked(WingRotateAngleZ); + leftWing.rotateUnsneaked(WingRotateAngleZ); + rightWing.rotateUnsneaked(-WingRotateAngleZ); } leftWing.rotate(ROTATE_90); From 8895d52fe10b8fbefb0d1b5bf3e20c6ae0ab27c6 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Apr 2018 21:25:30 +0200 Subject: [PATCH 07/96] Fixed various bugs with the new renderer / added a flying-strafing animation --- src/main/java/com/minelittlepony/Pony.java | 3 +- .../ducks/IPonyAnimationHolder.java | 5 ++ .../mixin/MixinEntityLivingBase.java | 38 +++++++++++++ .../renderer/player/RenderPonyBase.java | 50 +++++++--------- .../renderer/player/RenderPonyPlayer.java | 57 +++++++++++++------ src/main/resources/minelp.mixin.json | 3 +- 6 files changed, 108 insertions(+), 48 deletions(-) create mode 100644 src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java create mode 100644 src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java index 1c022a4b..80d06751 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/Pony.java @@ -107,8 +107,7 @@ public class Pony { } public PonyRace getRace(boolean ignorePony) { - return PonyRace.ALICORN; - //return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony)); + return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony)); } public ResourceLocation getTexture() { diff --git a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java new file mode 100644 index 00000000..4c9f7520 --- /dev/null +++ b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java @@ -0,0 +1,5 @@ +package com.minelittlepony.ducks; + +public interface IPonyAnimationHolder { + float getStrafeAmount(float ticks); +} diff --git a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java new file mode 100644 index 00000000..bd8a9a29 --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java @@ -0,0 +1,38 @@ +package com.minelittlepony.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import com.minelittlepony.ducks.IPonyAnimationHolder; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; + +@Mixin(EntityLivingBase.class) +public abstract class MixinEntityLivingBase extends Entity implements IPonyAnimationHolder { + @Shadow + public float moveStrafing; + + private MixinEntityLivingBase(World worldIn) { + super(worldIn); + } + + // No other place to save this stuff? :'c + // Add any animations you want + // This could also go into Pony, but I'm unsure if that's a good place for it (@Immutable). + private float strafeRollAmount = 0; + + @Override + public float getStrafeAmount(float ticks) { + float strafing = this.moveStrafing; + if (strafing != 0) { + if (Math.abs(strafeRollAmount) < Math.abs(strafing)) { + strafeRollAmount += strafing/10; + } + } else { + strafeRollAmount *= 0.8; + } + return (float)Math.toDegrees(strafeRollAmount * ticks); + } +} diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java index 75ee2eec..dece3cc2 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java @@ -26,7 +26,8 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony protected final boolean smallArms; private PlayerModel playerModel; - private AbstractPonyModel ponyModel; + + protected AbstractPonyModel ponyModel; private Pony pony; @@ -72,60 +73,51 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony super.doRender(player, x, y, z, entityYaw, partialTicks); } + + // TODO: Why are there two sets of arms? @Override public void renderRightArm(AbstractClientPlayer player) { updateModel(player); bindEntityTexture(player); + GlStateManager.pushMatrix(); + GlStateManager.translate(0, -0.37, 0); super.renderRightArm(player); + GlStateManager.popMatrix(); } @Override public void renderLeftArm(AbstractClientPlayer player) { updateModel(player); bindEntityTexture(player); + GlStateManager.pushMatrix(); + GlStateManager.translate(0.06, -0.37, -0); super.renderLeftArm(player); + GlStateManager.popMatrix(); } @Override protected void applyRotations(AbstractClientPlayer player, float yaw, float pitch, float ticks) { super.applyRotations(player, yaw, pitch, ticks); + double motionX = player.posX - player.prevPosX; + double motionY = player.onGround ? 0 : player.posY - player.prevPosY; + double motionZ = player.posZ - player.prevPosZ; + if (player.isElytraFlying()) { - transformFlying(player, yaw, pitch, ticks); + transformElytraFlight(player, motionX, motionY, motionZ, ticks); return; } if (player.isEntityAlive() && player.isPlayerSleeping()) return; - // require arms to be stretched out (sorry mud ponies, no flight skills for you) - if (!((ModelPlayerPony) ponyModel).rainboom) { - ponyModel.motionPitch = 0; + if (((ModelPlayerPony) ponyModel).rainboom) { + transformPegasusFlight(player, motionX, motionY, motionZ, yaw, pitch, ticks); return; } - double motionX = player.posX - player.prevPosX; - double motionY = player.posY - player.prevPosY; - double motionZ = player.posZ - player.prevPosZ; - if (player.onGround) { - motionY = 0; - } - double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); - double angle = Math.atan2(motionY, dist); - if (!player.capabilities.isFlying) { - if (angle > 0) { - angle = 0; - } else { - angle /= 2; - } - } - - if (angle > Math.PI / 3) angle = Math.PI / 3; - if (angle < -Math.PI / 3) angle = -Math.PI / 3; - - ponyModel.motionPitch = (float) Math.toDegrees(angle); - - GlStateManager.rotate((float) Math.toDegrees(angle), 1, 0, 0); + // require arms to be stretched out (sorry mud ponies, no flight skills for you) + ponyModel.motionPitch = 0; } public ResourceLocation getEntityTexture(AbstractClientPlayer entity) { @@ -156,5 +148,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony protected abstract float getScaleFactor(); - protected abstract void transformFlying(AbstractClientPlayer player, float yaw, float pitch, float ticks); + protected abstract void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks); + + protected abstract void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks); } diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java index 107a04ea..422f4f2f 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java @@ -1,6 +1,7 @@ package com.minelittlepony.renderer.player; import com.minelittlepony.MineLittlePony; +import com.minelittlepony.ducks.IPonyAnimationHolder; import com.minelittlepony.model.PlayerModel; import net.minecraft.client.entity.AbstractClientPlayer; @@ -8,24 +9,46 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { - public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, PlayerModel model) { - super(renderManager, useSmallArms, id, model); - } + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, PlayerModel model) { + super(renderManager, useSmallArms, id, model); + } - @Override - protected float getPonyShadowScale() { - if (!MineLittlePony.getConfig().showscale) return .5f; - return getPony().getMetadata().getSize().getShadowSize(); - } + @Override + protected float getPonyShadowScale() { + if (!MineLittlePony.getConfig().showscale) return .5f; + return getPony().getMetadata().getSize().getShadowSize(); + } - @Override - protected float getScaleFactor() { - return getPony().getMetadata().getSize().getScaleFactor(); - } + @Override + protected float getScaleFactor() { + return getPony().getMetadata().getSize().getScaleFactor(); + } - @Override - protected void transformFlying(AbstractClientPlayer player, float yaw, float pitch, float ticks) { - GlStateManager.rotate(90, 1, 0, 0); - GlStateManager.translate(0, -1, 0); - } + @Override + protected void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks) { + GlStateManager.rotate(90, 1, 0, 0); + GlStateManager.translate(0, -1, 0); + } + + @Override + protected void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks) { + double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); + double angle = Math.atan2(motionY, dist); + + if (!player.capabilities.isFlying) { + if (angle > 0) { + angle = 0; + } else { + angle /= 2; + } + } + + if (angle > Math.PI / 3) angle = Math.PI / 3; + if (angle < -Math.PI / 3) angle = -Math.PI / 3; + + ponyModel.motionPitch = (float) Math.toDegrees(angle); + + GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); + GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); + } } diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index 03138d99..972824cf 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -8,6 +8,7 @@ "MixinThreadDownloadImageData", "MixinNetworkPlayerInfo", "MixinRenderItem", - "MixinRenderManager" + "MixinRenderManager", + "MixinEntityLivingBase" ] } From 1718868ca48603465911f4bf336b9baae4b30562 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 24 Apr 2018 21:35:42 +0200 Subject: [PATCH 08/96] Format PonyModelConstants --- .../model/PonyModelConstants.java | 105 ++++++++++-------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 9852ec74..8fc053bd 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -2,51 +2,64 @@ package com.minelittlepony.model; public interface PonyModelConstants { - float BODY_CENTRE_X = 0.0F; - float BODY_CENTRE_Y = 8.0F; - float BODY_CENTRE_Z = 6.0F; - float BODY_ROTATE_ANGLE_X_NOTSNEAK = 0.0F; - float BODY_ROTATE_ANGLE_X_SNEAK = 0.4F; - float BODY_ROTATE_ANGLE_X_RIDING = (float) (Math.PI * 3.8); - float BODY_RP_Y_NOTSNEAK = 0.0F; - float BODY_RP_Y_SNEAK = 7.0F; - float BODY_RP_Y_RIDING = 1; - float BODY_RP_Z_NOTSNEAK = 0.0F; - float BODY_RP_Z_SNEAK = -4.0F; - float BODY_RP_Z_RIDING = 4F; - float EXT_WING_ROTATE_ANGLE_X = 2.5F; - float FIRSTP_ARM_CENTRE_X = -1.0F; - float FIRSTP_ARM_CENTRE_Y = 4.0F; - float FIRSTP_ARM_CENTRE_Z = 0.0F; - float FRONT_LEG_RP_Y_NOTSNEAK = 8.0F; - float FRONT_LEG_RP_Y_SNEAK = 8.0F; - float HEAD_CENTRE_X = 0.0F; - float HEAD_CENTRE_Y = -1.0F; - float HEAD_CENTRE_Z = -2.0F; - float HEAD_RP_X = 0.0F; - float HEAD_RP_Y = 0.0F; - float HEAD_RP_Z = 0.0F; - float LEFT_WING_EXT_RP_X = 4.5F; - float LEFT_WING_EXT_RP_Y = 5.0F; - float LEFT_WING_EXT_RP_Z = 6.0F; - float LEFT_WING_ROTATE_ANGLE_Z_SNEAK = -6.0F; - float RIGHT_WING_EXT_RP_X = -4.5F; - float RIGHT_WING_EXT_RP_Y = 5.0F; - float RIGHT_WING_EXT_RP_Z = 6.0F; - float RIGHT_WING_ROTATE_ANGLE_Z_SNEAK = 6.0F; - float ROTATE_270 = 4.712F; - float ROTATE_90 = 1.571F; - float SNEAK_LEG_X_ROTATION_ADJUSTMENT = 0.4F; - float TAIL_RP_X = 0.0F; - float TAIL_RP_Y = 0.0F; - float TAIL_RP_Z = 0.0F; - float TAIL_RP_Z_NOTSNEAK = 14.0F; - float TAIL_RP_Z_SNEAK = 15.0F; - float THIRDP_ARM_CENTRE_X = 0.0F; - float THIRDP_ARM_CENTRE_Y = 10.0F; - float THIRDP_ARM_CENTRE_Z = 0.0F; - float WING_FOLDED_RP_Y = 13.0F; - float WING_FOLDED_RP_Z = -3.0F; - float NECK_ROT_X = 0.166F; + float + BODY_CENTRE_X = 0.0F, + BODY_CENTRE_Y = 8.0F, + BODY_CENTRE_Z = 6.0F, + BODY_ROTATE_ANGLE_X_NOTSNEAK = 0.0F, + BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, + BODY_ROTATE_ANGLE_X_RIDING = (float) (Math.PI * 3.8), + + BODY_RP_Y_NOTSNEAK = 0.0F, + BODY_RP_Y_SNEAK = 7.0F, + BODY_RP_Y_RIDING = 1, + + BODY_RP_Z_NOTSNEAK = 0.0F, + BODY_RP_Z_SNEAK = -4.0F, + BODY_RP_Z_RIDING = 4F, + + EXT_WING_ROTATE_ANGLE_X = 2.5F, + + FIRSTP_ARM_CENTRE_X = -1.0F, + FIRSTP_ARM_CENTRE_Y = 4.0F, + FIRSTP_ARM_CENTRE_Z = 0.0F, + + FRONT_LEG_RP_Y_NOTSNEAK = 8.0F, + FRONT_LEG_RP_Y_SNEAK = 8.0F, + + HEAD_CENTRE_X = 0.0F, + HEAD_CENTRE_Y = -1.0F, + HEAD_CENTRE_Z = -2.0F, + + HEAD_RP_X = 0.0F, + HEAD_RP_Y = 0.0F, + HEAD_RP_Z = 0.0F, + + LEFT_WING_EXT_RP_X = 4.5F, + LEFT_WING_EXT_RP_Y = 5.0F, + LEFT_WING_EXT_RP_Z = 6.0F, + + LEFT_WING_ROTATE_ANGLE_Z_SNEAK = -6.0F, + + ROTATE_270 = 4.712F, + ROTATE_90 = 1.571F, + + SNEAK_LEG_X_ROTATION_ADJUSTMENT = 0.4F, + + TAIL_RP_X = 0.0F, + TAIL_RP_Y = 0.0F, + TAIL_RP_Z = 0.0F, + + TAIL_RP_Z_NOTSNEAK = 14.0F, + TAIL_RP_Z_SNEAK = 15.0F, + + THIRDP_ARM_CENTRE_X = 0.0F, + THIRDP_ARM_CENTRE_Y = 10.0F, + THIRDP_ARM_CENTRE_Z = 0.0F, + + WING_FOLDED_RP_Y = 13.0F, + WING_FOLDED_RP_Z = -3.0F, + + NECK_ROT_X = 0.166F; } From 228c32b4e50e78e3a44526e6da5e9b0063c36ac5 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 09:45:41 +0200 Subject: [PATCH 09/96] Fixed Top and Bottom planes being reversed causing encorrect lighting on ponies --- .../com/minelittlepony/model/ModelPlane.java | 50 ++++++++++--------- .../renderer/PlaneRenderer.java | 8 ++- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ModelPlane.java b/src/main/java/com/minelittlepony/model/ModelPlane.java index dc82f318..7ac3575d 100644 --- a/src/main/java/com/minelittlepony/model/ModelPlane.java +++ b/src/main/java/com/minelittlepony/model/ModelPlane.java @@ -10,19 +10,17 @@ import javax.annotation.Nonnull; public class ModelPlane extends ModelBox { - private TexturedQuad[] quadList; - private final Face face; - - public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, - float x, float y, float z, int w, int h, int d, - float scale, Face face) { + private TexturedQuad quad; + + public boolean hidden = false; + + public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, float x, float y, float z, int w, int h, int d, float scale, Face face) { super(renderer, textureX, textureY, x, y, z, w, h, d, scale, false); - this.face = face; - this.quadList = new TexturedQuad[6]; float x2 = x + w; float y2 = y + h; float z2 = z + d; + x -= scale; y -= scale; z -= scale; @@ -59,53 +57,57 @@ public class ModelPlane extends ModelBox { PositionTextureVertex eun = new PositionTextureVertex(x2, y2, z2, 8.0F, 8.0F); PositionTextureVertex wun = new PositionTextureVertex(x, y2, z2, 8.0F, 0.0F); - // east - this.quadList[0] = new TexturedQuad( + if (face == Face.EAST) { + quad = new TexturedQuad( new PositionTextureVertex[]{edn, eds, eus, eun}, textureX, textureY, textureX + d, textureY + h, renderer.textureWidth, renderer.textureHeight); - // west - this.quadList[1] = new TexturedQuad( + } + if (face == Face.WEST) { + quad = new TexturedQuad( new PositionTextureVertex[]{wds, wdn, wun, wus}, textureX, textureY, textureX + d, textureY + h, renderer.textureWidth, renderer.textureHeight); - // down - this.quadList[3] = new TexturedQuad( + } + if (face == Face.UP) { + quad = new TexturedQuad( new PositionTextureVertex[]{edn, wdn, wds, eds}, textureX, textureY, textureX + w, textureY + d, renderer.textureWidth, renderer.textureHeight); - // up - this.quadList[2] = new TexturedQuad( + } + if (face == Face.DOWN) { + quad = new TexturedQuad( new PositionTextureVertex[]{eus, wus, wun, eun}, textureX, textureY, textureX + w, textureY + d, renderer.textureWidth, renderer.textureHeight); - // south - this.quadList[4] = new TexturedQuad( + } + if (face == Face.SOUTH) { + quad = new TexturedQuad( new PositionTextureVertex[]{eds, wds, wus, eus}, textureX, textureY, textureX + w, textureY + h, renderer.textureWidth, renderer.textureHeight); - // north - this.quadList[5] = new TexturedQuad( + } + if (face == Face.NORTH) { + quad = new TexturedQuad( new PositionTextureVertex[]{wdn, edn, eun, wun}, textureX, textureY, textureX + w, textureY + h, renderer.textureWidth, renderer.textureHeight); + } if (renderer.mirror || renderer.mirrory || renderer.mirrorz) { - for (TexturedQuad texturedquad : this.quadList) { - texturedquad.flipFace(); - } + quad.flipFace(); } } @Override public void render(@Nonnull BufferBuilder renderer, float scale) { - this.quadList[this.face.ordinal()].draw(renderer, scale); + if (!hidden) this.quad.draw(renderer, scale); } public enum Face { diff --git a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java b/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java index d74ae86c..43f4da60 100644 --- a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java @@ -8,11 +8,9 @@ import net.minecraft.client.model.ModelRenderer; @SuppressWarnings("unused") public class PlaneRenderer extends ModelRenderer { - public boolean mirrory; - public boolean mirrorz; + public boolean mirrory, mirrorz; - private int textureOffsetX; - private int textureOffsetY; + private int textureOffsetX, textureOffsetY; public PlaneRenderer(ModelBase model) { super(model); @@ -30,7 +28,7 @@ public class PlaneRenderer extends ModelRenderer { return this; } - public void addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) { + private void addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) { this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, offX, offY, offZ, width, height, depth, scale, face)); } From b9e9251c430ae95e4a812d2e775c5cd35db90238 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 09:48:28 +0200 Subject: [PATCH 10/96] Model rewrites wave 1, moved pony tails to their own class --- .../java/com/minelittlepony/TailLengths.java | 20 +- .../model/AbstractPonyModel.java | 21 +- .../com/minelittlepony/model/PonyTail.java | 76 ++++ .../model/pony/ModelHumanPlayer.java | 10 + .../model/pony/ModelPlayerPony.java | 392 +++++------------- .../model/pony/ModelSkeletonPony.java | 2 +- .../model/pony/armor/ModelPonyArmor.java | 12 +- .../pony/armor/ModelSkeletonPonyArmor.java | 2 +- 8 files changed, 207 insertions(+), 328 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/PonyTail.java diff --git a/src/main/java/com/minelittlepony/TailLengths.java b/src/main/java/com/minelittlepony/TailLengths.java index 41542a14..5c1cc534 100644 --- a/src/main/java/com/minelittlepony/TailLengths.java +++ b/src/main/java/com/minelittlepony/TailLengths.java @@ -2,19 +2,9 @@ package com.minelittlepony; public enum TailLengths { - STUB(4), - QUARTER(3), - HALF(2), - THREE_QUARTERS(1), - FULL(0); - - private int size; - - TailLengths(int size) { - this.size = size; - } - - public int getSize() { - return size; - } + STUB, + QUARTER, + HALF, + THREE_QUARTERS, + FULL; } diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 20f78adf..8baa53ae 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -22,17 +22,15 @@ public abstract class AbstractPonyModel extends ModelPlayer { protected float scale = 0.0625F; - public ModelRenderer steveLeftArm; - public ModelRenderer steveRightArm; - public ModelRenderer steveLeftArmwear; - public ModelRenderer steveRightArmwear; - public boolean isFlying; public boolean isSleeping; public IPonyData metadata = new PonyData(); public float motionPitch; + // TODO: Why so many arms? + public ModelRenderer steveLeftArm, steveRightArm, + steveLeftArmwear, steveRightArmwear; public AbstractPonyModel(boolean arms) { super(0, arms); @@ -47,11 +45,9 @@ public abstract class AbstractPonyModel extends ModelPlayer { this.initPositions(yOffset, stretch); } - protected void initTextures() { - } + protected abstract void initTextures(); - protected void initPositions(float yOffset, float stretch) { - } + protected abstract void initPositions(float yOffset, float stretch); @Override public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { @@ -74,12 +70,6 @@ public abstract class AbstractPonyModel extends ModelPlayer { return false; } - public static void setRotationPoint(ModelRenderer aRenderer, float setX, float setY, float setZ) { - aRenderer.rotationPointX = setX; - aRenderer.rotationPointY = setY; - aRenderer.rotationPointZ = setZ; - } - public static void shiftRotationPoint(ModelRenderer aRenderer, float shiftX, float shiftY, float shiftZ) { aRenderer.rotationPointX += shiftX; aRenderer.rotationPointY += shiftY; @@ -231,6 +221,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { } } + // TODO: This has potential to create an infinite loop. @Override public ModelRenderer getRandomModelBox(Random rand) { // empty lists cause problems diff --git a/src/main/java/com/minelittlepony/model/PonyTail.java b/src/main/java/com/minelittlepony/model/PonyTail.java new file mode 100644 index 00000000..d5ed560f --- /dev/null +++ b/src/main/java/com/minelittlepony/model/PonyTail.java @@ -0,0 +1,76 @@ +package com.minelittlepony.model; + +import com.minelittlepony.TailLengths; +import com.minelittlepony.renderer.PlaneRenderer; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.util.math.MathHelper; + +public class PonyTail extends PlaneRenderer implements PonyModelConstants { + + private final TailSegment[] segments = new TailSegment[4]; + + private final ModelBase theModel; + + public PonyTail(ModelBase model) { + super(model); + theModel = model; + } + + public void init(float yOffset, float stretch) { + for (int i = 0; i < segments.length; i++) { + addChild(segments[i] = new TailSegment(theModel, i, yOffset, stretch)); + } + } + + public void swingZ(boolean rainboom, float move, float swing) { + rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2F * swing; + } + + public void swingX(float tick) { + float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; + rotateAngleX += sinTickFactor; + } + + public void rotateSneak() { + setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK); + rotateAngleX = -BODY_ROTATE_ANGLE_X_SNEAK + 0.1F; + } + + public void render(TailLengths tail, float scale) { + int tailStop = tail.ordinal(); + + for (int i = 0; i < segments.length; i++) { + segments[i].isHidden = i >= tailStop; + } + + super.render(scale); + } + + private class TailSegment extends PlaneRenderer { + + public TailSegment(ModelBase model, int index, float yOffset, float stretch) { + super(model); + + this.offsetY = ((float)index)/4 + 0.063f; + + init(index, yOffset, stretch); + } + + public void init(int index, float yOffset, float stretch) { + int texX = (index % 2) * 4; + + if (index == 0) { + setTextureOffset(32, 0).addTopPlane(-2, 0, 2, 4, 4, stretch); + } + + setTextureOffset(36, texX).addEastPlane(2, 0, 2, 4, 4, stretch); + addWestPlane(-2, 0, 2, 4, 4, stretch); + setTextureOffset(32, texX).addBackPlane(-2, 0, 2, 4, 4, stretch); + addFrontPlane(-2, 0, 6, 4, 4, stretch); + setTextureOffset(32, 0).addBottomPlane(-2, 4, 2, 4, 4, stretch); + + setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); + } + } +} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java index 1087319c..957a1192 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java @@ -17,4 +17,14 @@ public class ModelHumanPlayer extends AbstractPonyModel { @Override public void transform(BodyPart part) { } + + @Override + protected void initTextures() { + + } + + @Override + protected void initPositions(float yOffset, float stretch) { + + } } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java index 12b9ad6b..0437915c 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java @@ -5,6 +5,7 @@ import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.PegasusWings; import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.PonySnout; +import com.minelittlepony.model.PonyTail; import com.minelittlepony.model.UnicornHorn; import com.minelittlepony.renderer.PlaneRenderer; import net.minecraft.client.model.ModelRenderer; @@ -23,12 +24,13 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst public boolean rainboom; public ModelRenderer bipedCape; - + public PlaneRenderer[] Bodypiece; - public PlaneRenderer[] BodypieceNeck; - public ModelRenderer unicornArmRight; - public ModelRenderer unicornArmLeft; - public PlaneRenderer[] Tail; + public PlaneRenderer BodypieceNeck; + + public ModelRenderer unicornArmRight, unicornArmLeft; + + public PonyTail Tail; public PonySnout snout; public UnicornHorn horn; public PegasusWings wings; @@ -52,7 +54,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.checkRainboom(entityIn, limbSwingAmount); this.rotateHead(netHeadYaw, headPitch); - this.swingTailZ(limbSwing, limbSwingAmount); + this.Tail.swingZ(rainboom, limbSwing, limbSwingAmount); float bodySwingRotation = 0.0F; if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; @@ -65,18 +67,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.Bodypiece[k1].rotateAngleY = bodySwingRotation * 0.2F; } - for (k1 = 0; k1 < this.BodypieceNeck.length; ++k1) { - this.BodypieceNeck[k1].rotateAngleY = bodySwingRotation * 0.2F; - } - - int tailstop = this.Tail.length - this.metadata.getTail().getSize() * 5; - if (tailstop <= 1) { - tailstop = 0; - } - - for (k1 = 0; k1 < tailstop; ++k1) { - this.Tail[k1].rotateAngleY = bodySwingRotation; - } + this.BodypieceNeck.rotateAngleY = bodySwingRotation * 0.2F; + this.Tail.rotateAngleY = bodySwingRotation; this.bipedHead.offsetY = 0f; this.bipedHead.offsetZ = 0f; @@ -89,7 +81,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); this.sneakLegs(); this.setHead(0.0F, 6.0F, -2.0F); - this.sneakTail(); + this.Tail.rotateSneak(); } else if (this.isRiding) { this.adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); @@ -108,11 +100,9 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedLeftArm.rotateAngleZ = (float) (Math.PI * -0.06); this.bipedRightArm.rotateAngleZ = (float) (Math.PI * 0.06); - for (PlaneRenderer aTail : Tail) { - aTail.rotationPointZ = 13; - aTail.rotationPointY = 3; - aTail.rotateAngleX = (float) (Math.PI * 0.2); - } + Tail.rotationPointZ = 13; + Tail.rotationPointY = 3; + Tail.rotateAngleX = (float) (Math.PI * 0.2); } else { this.adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); @@ -122,26 +112,21 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.swingArms(ageInTicks); this.setHead(0.0F, 0.0F, 0.0F); - for (k1 = 0; k1 < tailstop; ++k1) { - setRotationPoint(this.Tail[k1], TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); - if (this.rainboom) { - this.Tail[k1].rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(limbSwing); - } else { - this.Tail[k1].rotateAngleX = 0.5F * limbSwingAmount; - } + this.Tail.setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); + if (this.rainboom) { + this.Tail.rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(limbSwing); + } else { + this.Tail.rotateAngleX = 0.5F * limbSwingAmount; } if (!this.rainboom) { - this.swingTailX(ageInTicks); + this.Tail.swingX(ageInTicks); } } if (this.rainboom) { - - for (k1 = 0; k1 < tailstop; ++k1) { - this.Tail[k1].rotationPointY += 6.0F; - ++this.Tail[k1].rotationPointZ; - } + this.Tail.rotationPointY += 6.0F; + this.Tail.rotationPointZ++; } if (this.isSleeping) { @@ -178,8 +163,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void setHead(float posX, float posY, float posZ) { - setRotationPoint(this.bipedHead, posX, posY, posZ); - setRotationPoint(this.bipedHeadwear, posX, posY, posZ); + this.bipedHead.setRotationPoint(posX, posY, posZ); + this.bipedHeadwear.setRotationPoint(posX, posY, posZ); } protected void rotateHead(float horz, float vert) { @@ -308,35 +293,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedLeftLeg.rotationPointZ = 10.0F; } - protected void swingTailZ(float move, float swing) { - int tailstop = this.Tail.length - this.metadata.getTail().getSize() * 5; - if (tailstop <= 1) { - tailstop = 0; - } - - for (int j = 0; j < tailstop; ++j) { - if (this.rainboom) { - this.Tail[j].rotateAngleZ = 0.0F; - } else { - this.Tail[j].rotateAngleZ = MathHelper.cos(move * 0.8F) * 0.2F * swing; - } - } - - } - - protected void swingTailX(float tick) { - float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; - int tailstop = this.Tail.length - this.metadata.getTail().getSize() * 5; - if (tailstop <= 1) { - tailstop = 0; - } - - for (int l6 = 0; l6 < tailstop; ++l6) { - this.Tail[l6].rotateAngleX += sinTickFactor; - } - - } - + @SuppressWarnings("incomplete-switch") protected void holdItem(float swing) { if (!this.rainboom && !this.metadata.hasMagic()) { @@ -474,12 +431,9 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { - for (PlaneRenderer aBodypieceNeck : this.BodypieceNeck) { - aBodypieceNeck.rotateAngleX = NECK_ROT_X + rotateAngleX; - aBodypieceNeck.rotationPointY = rotationPointY; - aBodypieceNeck.rotationPointZ = rotationPointZ; - } - + BodypieceNeck.rotateAngleX = NECK_ROT_X + rotateAngleX; + BodypieceNeck.rotationPointY = rotationPointY; + BodypieceNeck.rotationPointZ = rotationPointZ; } protected void sneakLegs() { @@ -494,19 +448,6 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } - protected void sneakTail() { - int tailstop = this.Tail.length - this.metadata.getTail().getSize() * 5; - if (tailstop <= 1) { - tailstop = 0; - } - - for (int i7 = 0; i7 < tailstop; ++i7) { - setRotationPoint(this.Tail[i7], TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK); - this.Tail[i7].rotateAngleX = -BODY_ROTATE_ANGLE_X_SNEAK + 0.1F; - } - - } - protected void ponySleep() { this.bipedRightArm.rotateAngleX = ROTATE_270; this.bipedLeftArm.rotateAngleX = ROTATE_270; @@ -536,37 +477,21 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { if (this.metadata.hasMagic()) { - this.aimBowUnicorn(tick); + aimBowPony(unicornArmRight, tick, true); } else { - this.aimBowPony(leftArm, rightArm, tick); + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); } } } - protected void aimBowPony(ArmPose leftArm, ArmPose rightArm, float tick) { - if (rightArm == ArmPose.BOW_AND_ARROW) { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; - this.bipedRightArm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - shiftRotationPoint(this.bipedRightArm, 0.0F, 0.0F, 1.0F); - } else if (leftArm == ArmPose.BOW_AND_ARROW) { - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; - this.bipedLeftArm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; - this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - shiftRotationPoint(this.bipedLeftArm, 0.0F, 0.0F, 1.0F); - } - } - - protected void aimBowUnicorn(float tick) { - this.unicornArmRight.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; - this.unicornArmRight.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; - this.unicornArmRight.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.unicornArmRight.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; + protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) { + arm.rotateAngleZ = 0.0F; + arm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; + arm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; + arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; + if (shift) shiftRotationPoint(arm, 0.0F, 0.0F, 1.0F); } protected void fixSpecialRotations() { @@ -596,7 +521,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst pushMatrix(); this.transform(BodyPart.BODY); this.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - this.renderTail(); + this.Tail.render(this.metadata.getTail(), this.scale); popMatrix(); pushMatrix(); @@ -605,8 +530,7 @@ 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); @@ -616,13 +540,10 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst protected void renderNeck() { GlStateManager.scale(0.9, 0.9, 0.9); - for (PlaneRenderer element : this.BodypieceNeck) { - element.render(this.scale); - } + this.BodypieceNeck.render(this.scale); } - 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); @@ -632,22 +553,6 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } this.bipedBody.postRender(scale); this.wings.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, this.scale); - - - } - - protected void renderTail() { - int var3 = this.Tail.length - this.metadata.getTail().getSize() * 5; - if (var3 <= 1) { - var3 = 0; - } - - // this.bipedBody.postRender(this.scale); - - for (int k = 0; k < var3; ++k) { - this.Tail[k].render(this.scale); - } - } protected void renderLegs() { @@ -659,6 +564,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedRightArm.render(this.scale); this.bipedLeftLeg.render(this.scale); this.bipedRightLeg.render(this.scale); + if (this.textureHeight == 64) { this.bipedLeftArmwear.render(this.scale); this.bipedRightArmwear.render(this.scale); @@ -670,14 +576,11 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst @Override protected void initTextures() { this.boxList.clear(); - this.Tail = new PlaneRenderer[21]; - this.Bodypiece = new PlaneRenderer[14]; - this.BodypieceNeck = new PlaneRenderer[4]; this.initHeadTextures(); this.initBodyTextures(); this.initLegTextures(); - this.initTailTextures(); + this.Tail = new PonyTail(this); } protected void initHeadTextures() { @@ -688,32 +591,40 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst protected void initBodyTextures() { this.bipedBody = new ModelRenderer(this, 16, 16); + if (this.textureHeight == 64) { this.bipedBodyWear = new ModelRenderer(this, 16, 32); } + this.Bodypiece[0] = new PlaneRenderer(this, 24, 0); this.Bodypiece[0].mirrorz = true; + this.Bodypiece[1] = new PlaneRenderer(this, 24, 0); + this.Bodypiece[2] = new PlaneRenderer(this, 32, 20); this.Bodypiece[2].mirrorz = true; + this.Bodypiece[3] = new PlaneRenderer(this, 56, 0); + this.Bodypiece[4] = new PlaneRenderer(this, 4, 0); this.Bodypiece[4].mirrorz = true; + this.Bodypiece[5] = new PlaneRenderer(this, 4, 0); + this.Bodypiece[6] = new PlaneRenderer(this, 36, 16); this.Bodypiece[7] = new PlaneRenderer(this, 36, 16); this.Bodypiece[8] = new PlaneRenderer(this, 36, 16); - this.Bodypiece[9] = new PlaneRenderer(this, 32, 0); - this.Bodypiece[10] = new PlaneRenderer(this, 32, 0); + this.Bodypiece[11] = new PlaneRenderer(this, 32, 0); this.Bodypiece[11].mirror = true; + + this.Bodypiece[9] = new PlaneRenderer(this, 32, 0); + this.Bodypiece[10] = new PlaneRenderer(this, 32, 0); this.Bodypiece[12] = new PlaneRenderer(this, 32, 0); this.Bodypiece[13] = new PlaneRenderer(this, 32, 0); + // neck - this.BodypieceNeck[0] = new PlaneRenderer(this, 0, 16); - this.BodypieceNeck[1] = new PlaneRenderer(this, 0, 16); - this.BodypieceNeck[2] = new PlaneRenderer(this, 0, 16); - this.BodypieceNeck[3] = new PlaneRenderer(this, 0, 16); + this.BodypieceNeck = new PlaneRenderer(this, 0, 16); } @@ -737,37 +648,12 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.boxList.remove(this.unicornArmRight); } - protected void initTailTextures() { - // upper - this.Tail[0] = new PlaneRenderer(this, 32, 0); - this.Tail[1] = new PlaneRenderer(this, 36, 0); - this.Tail[2] = new PlaneRenderer(this, 32, 0); - this.Tail[3] = new PlaneRenderer(this, 36, 0); - this.Tail[4] = new PlaneRenderer(this, 32, 0); - this.Tail[5] = new PlaneRenderer(this, 32, 0); - this.Tail[6] = new PlaneRenderer(this, 36, 4); - this.Tail[7] = new PlaneRenderer(this, 32, 4); - this.Tail[8] = new PlaneRenderer(this, 36, 4); - this.Tail[9] = new PlaneRenderer(this, 32, 4); - this.Tail[10] = new PlaneRenderer(this, 32, 0); - this.Tail[11] = new PlaneRenderer(this, 36, 0); - this.Tail[12] = new PlaneRenderer(this, 32, 0); - this.Tail[13] = new PlaneRenderer(this, 36, 0); - this.Tail[14] = new PlaneRenderer(this, 32, 0); - this.Tail[15] = new PlaneRenderer(this, 32, 0); - this.Tail[16] = new PlaneRenderer(this, 36, 4); - this.Tail[17] = new PlaneRenderer(this, 32, 4); - this.Tail[18] = new PlaneRenderer(this, 36, 4); - this.Tail[19] = new PlaneRenderer(this, 32, 4); - this.Tail[20] = new PlaneRenderer(this, 32, 0); - } - @Override protected void initPositions(float yOffset, float stretch) { this.initHeadPositions(yOffset, stretch); this.initBodyPositions(yOffset, stretch); this.initLegPositions(yOffset, stretch); - this.initTailPositions(yOffset, stretch); + this.Tail.init(yOffset, stretch); } protected void initHeadPositions(float yOffset, float stretch) { @@ -791,145 +677,75 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, stretch); - this.Bodypiece[13].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + + for (int i = 0; i < this.Bodypiece.length; i++) { + this.Bodypiece[i].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, 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, 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, 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, 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; - this.BodypieceNeck[2].rotateAngleX = NECK_ROT_X; - this.BodypieceNeck[3].rotateAngleX = NECK_ROT_X; + this.BodypieceNeck.addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); + this.BodypieceNeck.addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -4.8F + BODY_CENTRE_Z, 4, 4, stretch); + this.BodypieceNeck.addWestPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); + this.BodypieceNeck.addEastPlane(2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); + + this.BodypieceNeck.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.BodypieceNeck.rotateAngleX = NECK_ROT_X; } protected void initLegPositions(float yOffset, float stretch) { - if (this.smallArms) { - 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.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.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.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.setRotationPoint(3.0F, 8.0F + yOffset, 0.0F); - } - } + int armWidth = this.smallArms ? 3 : 4; + float armY = this.smallArms ? 8.5f : 8f; + float armX = this.smallArms ? -2f : -3f; + + this.bipedRightArm.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch); + this.bipedLeftArm .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch); + + this.bipedRightArm.setRotationPoint(armX, yOffset + armY, 0.0F); + this.bipedLeftArm .setRotationPoint(3.0F, yOffset + armY, 0.0F); + this.bipedRightLeg.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); + 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); + 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.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.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.unicornArmLeft .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); + this.unicornArmLeft .setRotationPoint(-5.0F, 2.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, armWidth, 12, 4, stretch + 0.25f); + this.bipedRightArmwear.setRotationPoint(-3.0F, yOffset + armY, 0.0F); + } + + if (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 .setRotationPoint(3.0F, yOffset + armY, 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.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); + } - this.unicornArmLeft.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.unicornArmLeft.setRotationPoint(-5.0F, 2.0F + yOffset, 0.0F); - } + 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); + } - protected void initTailPositions(float yOffset, float 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 4, stretch); - this.Tail[20].setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); + } @Override diff --git a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java index 46341e18..76b672fc 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java @@ -116,7 +116,7 @@ public class ModelSkeletonPony extends ModelPlayerPony { @Override protected void fixSpecialRotationPoints(float move) { if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { - setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F); + this.bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); } } 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 d5725c8e..908719d9 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java @@ -76,10 +76,10 @@ public class ModelPonyArmor extends ModelPlayerPony { @Override protected void setHead(float posX, float posY, float posZ) { - setRotationPoint(this.bipedHead, posX, posY, posZ); - setRotationPoint(this.bipedHeadwear, posX, posY, posZ); - setRotationPoint(this.extHead[0], posX, posY, posZ); - setRotationPoint(this.extHead[1], posX, posY, posZ); + this.bipedHead.setRotationPoint(posX, posY, posZ); + this.bipedHeadwear.setRotationPoint(posX, posY, posZ); + this.extHead[0].setRotationPoint(posX, posY, posZ); + this.extHead[1].setRotationPoint(posX, posY, posZ); } @Override @@ -127,10 +127,6 @@ public class ModelPonyArmor extends ModelPlayerPony { this.extBody.render(this.scale); } - @Override - protected void renderTail() { - } - @Override protected void renderLegs() { if (!isSneak) { diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java index 7383fbdf..c42f8deb 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java @@ -86,7 +86,7 @@ public class ModelSkeletonPonyArmor extends ModelPonyArmor { @Override protected void fixSpecialRotationPoints(float move) { if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { - setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F); + this.bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); } } From 52e2c84b673b2cadc72c6f5f12483c58e930f134 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 12:59:18 +0200 Subject: [PATCH 11/96] Model rewrites wave 2, clean up horn rendering, plane rendering, Zombie and Skeleton models --- .../minelittlepony/model/ModelHornGlow.java | 36 +++-- .../model/PonyModelConstants.java | 4 +- .../com/minelittlepony/model/UnicornHorn.java | 73 --------- .../model/{ => components}/ModelWing.java | 8 +- .../model/{ => components}/PegasusWings.java | 8 +- .../model/{ => components}/PonySnout.java | 21 +-- .../model/{ => components}/PonyTail.java | 8 +- .../model/components/UnicornHorn.java | 71 +++++++++ .../model/entity/ModelMobPony.java | 113 ++++++++++++++ .../model/pony/ModelPlayerPony.java | 19 +-- .../model/pony/ModelSkeletonPony.java | 147 +++++------------- .../model/pony/ModelVillagerPony.java | 4 +- .../model/pony/ModelZombiePony.java | 109 ++++--------- .../model/pony/armor/ModelPonyArmor.java | 2 + .../pony/armor/ModelSkeletonPonyArmor.java | 2 + .../pony/armor/ModelZombiePonyArmor.java | 1 + .../renderer/BasePonyRenderer.java | 49 ++++++ .../renderer/HornGlowRenderer.java | 55 +++---- .../minelittlepony/renderer/plane/Face.java | 7 + .../{model => renderer/plane}/ModelPlane.java | 12 +- .../renderer/{ => plane}/PlaneRenderer.java | 22 +-- 21 files changed, 400 insertions(+), 371 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/model/UnicornHorn.java rename src/main/java/com/minelittlepony/model/{ => components}/ModelWing.java (94%) rename src/main/java/com/minelittlepony/model/{ => components}/PegasusWings.java (90%) rename src/main/java/com/minelittlepony/model/{ => components}/PonySnout.java (82%) rename src/main/java/com/minelittlepony/model/{ => components}/PonyTail.java (91%) create mode 100644 src/main/java/com/minelittlepony/model/components/UnicornHorn.java create mode 100644 src/main/java/com/minelittlepony/model/entity/ModelMobPony.java create mode 100644 src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java create mode 100644 src/main/java/com/minelittlepony/renderer/plane/Face.java rename src/main/java/com/minelittlepony/{model => renderer/plane}/ModelPlane.java (95%) rename src/main/java/com/minelittlepony/renderer/{ => plane}/PlaneRenderer.java (69%) diff --git a/src/main/java/com/minelittlepony/model/ModelHornGlow.java b/src/main/java/com/minelittlepony/model/ModelHornGlow.java index 37d8cc8f..ae2a19d2 100644 --- a/src/main/java/com/minelittlepony/model/ModelHornGlow.java +++ b/src/main/java/com/minelittlepony/model/ModelHornGlow.java @@ -10,11 +10,17 @@ import javax.annotation.Nonnull; public class ModelHornGlow extends ModelBox { + private final float alpha; + + private final HornGlowRenderer parent; + private TexturedQuad[] quadList; - public ModelHornGlow(HornGlowRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10) { - super(par1ModelRenderer, par2, par3, par4, par5, par6, par7, par8, par9, par10); - + public ModelHornGlow(HornGlowRenderer parent, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10, float alpha) { + super(parent, par2, par3, par4, par5, par6, par7, par8, par9, par10); + this.parent = parent; + this.alpha = alpha; + this.quadList = new TexturedQuad[6]; float var11 = par4 + par7; float var12 = par5 + par8; @@ -29,7 +35,7 @@ public class ModelHornGlow extends ModelBox { var11 += par10; var12 += par10; var13 += par10; - if (par1ModelRenderer.mirror) { + if (parent.mirror) { float var26 = var11; var11 = par4; par4 = var26; @@ -46,22 +52,22 @@ public class ModelHornGlow extends ModelBox { this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{var19, var15, var16, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, - par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + parent.textureWidth, parent.textureHeight); this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{var32, var18, var21, var17}, par2, - par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, - par1ModelRenderer.textureHeight); + par3 + par9, par2 + par9, par3 + par9 + par8, parent.textureWidth, + parent.textureHeight); this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{var19, var18, var32, var15}, par2 + par9, - par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + par3, par2 + par9 + par7, par3 + par9, parent.textureWidth, parent.textureHeight); this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{var16, var17, var21, var20}, - par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, - par1ModelRenderer.textureHeight); + par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, parent.textureWidth, + parent.textureHeight); this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{var15, var32, var17, var16}, par2 + par9, - par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, - par1ModelRenderer.textureHeight); + par3 + par9, par2 + par9 + par7, par3 + par9 + par8, parent.textureWidth, + parent.textureHeight); this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{var18, var19, var20, var21}, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, - par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - if (par1ModelRenderer.mirror) { + parent.textureWidth, parent.textureHeight); + if (parent.mirror) { TexturedQuad[] var22 = this.quadList; for (TexturedQuad var25 : var22) { @@ -73,6 +79,8 @@ public class ModelHornGlow extends ModelBox { @Override public void render(@Nonnull BufferBuilder buffer, float par2) { + parent.applyTint(alpha); + TexturedQuad[] var3 = this.quadList; for (TexturedQuad var6 : var3) { var6.draw(buffer, par2); diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 8fc053bd..1244d225 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -1,8 +1,8 @@ package com.minelittlepony.model; -public interface PonyModelConstants { +public final class PonyModelConstants { - float + public static final float BODY_CENTRE_X = 0.0F, BODY_CENTRE_Y = 8.0F, BODY_CENTRE_Z = 6.0F, diff --git a/src/main/java/com/minelittlepony/model/UnicornHorn.java b/src/main/java/com/minelittlepony/model/UnicornHorn.java deleted file mode 100644 index cc1e82a8..00000000 --- a/src/main/java/com/minelittlepony/model/UnicornHorn.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.IPonyData; -import com.minelittlepony.renderer.HornGlowRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; -import org.lwjgl.opengl.GL11; - -import static net.minecraft.client.renderer.GlStateManager.*; - -public class UnicornHorn extends ModelBase implements PonyModelConstants { - - protected final AbstractPonyModel pony; - private ModelRenderer horn; - private HornGlowRenderer[] hornglow; - - private boolean usingMagic; - - public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) { - this.pony = pony; - - this.horn = new ModelRenderer(pony, 0, 3); - this.hornglow = new HornGlowRenderer[2]; - for (int i = 0; i < hornglow.length; i++) { - this.hornglow[i] = new HornGlowRenderer(pony, 0, 3); - } - - this.horn.addBox(-0.5F + HEAD_CENTRE_X, -10.0F + HEAD_CENTRE_Y, -1.5F + HEAD_CENTRE_Z, 1, 4, 1, stretch); - this.horn.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.horn.rotateAngleX = 0.5F; - - this.hornglow[0].addBox(-0.5F + HEAD_CENTRE_X, -10.0F + HEAD_CENTRE_Y, -1.5F + HEAD_CENTRE_Z, 1, 4, 1, stretch + 0.5F); - this.hornglow[1].addBox(-0.5F + HEAD_CENTRE_X, -10.0F + HEAD_CENTRE_Y, -1.5F + HEAD_CENTRE_Z, 1, 3, 1, stretch + 0.8F); - } - - @Override - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - - IPonyData data = pony.metadata; - - if (data.getRace().hasHorn()) { - this.horn.render(scale); - if (usingMagic && data.hasMagic()) { - GL11.glPushAttrib(24577); - disableTexture2D(); - disableLighting(); - enableBlend(); - - float red = (data.getGlowColor() >> 16 & 255) / 255.0F; - float green = (data.getGlowColor() >> 8 & 255) / 255.0F; - float blue = (data.getGlowColor() & 255) / 255.0F; - blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - - 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(); - } - } - } - - public void setUsingMagic(boolean usingMagic) { - this.usingMagic = usingMagic; - } -} diff --git a/src/main/java/com/minelittlepony/model/ModelWing.java b/src/main/java/com/minelittlepony/model/components/ModelWing.java similarity index 94% rename from src/main/java/com/minelittlepony/model/ModelWing.java rename to src/main/java/com/minelittlepony/model/components/ModelWing.java index 5eb5d13b..95987e9b 100644 --- a/src/main/java/com/minelittlepony/model/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/components/ModelWing.java @@ -1,9 +1,13 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.components; + +import com.minelittlepony.model.AbstractPonyModel; import net.minecraft.client.model.ModelRenderer; +import static com.minelittlepony.model.PonyModelConstants.*; + // TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box. -public class ModelWing implements PonyModelConstants { +public class ModelWing { public ModelRenderer[] folded = new ModelRenderer[3], extended = new ModelRenderer[6]; diff --git a/src/main/java/com/minelittlepony/model/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java similarity index 90% rename from src/main/java/com/minelittlepony/model/PegasusWings.java rename to src/main/java/com/minelittlepony/model/components/PegasusWings.java index b185c2c4..58c739f4 100644 --- a/src/main/java/com/minelittlepony/model/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -1,10 +1,14 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.components; + +import com.minelittlepony.model.AbstractPonyModel; import net.minecraft.client.model.ModelBase; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; -public class PegasusWings extends ModelBase implements PonyModelConstants { +import static com.minelittlepony.model.PonyModelConstants.*; + +public class PegasusWings extends ModelBase { private final AbstractPonyModel pony; diff --git a/src/main/java/com/minelittlepony/model/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java similarity index 82% rename from src/main/java/com/minelittlepony/model/PonySnout.java rename to src/main/java/com/minelittlepony/model/components/PonySnout.java index 451e12d0..d032cf83 100644 --- a/src/main/java/com/minelittlepony/model/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -1,16 +1,14 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.components; import com.minelittlepony.PonyGender; -import com.minelittlepony.renderer.PlaneRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.entity.Entity; +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.renderer.plane.PlaneRenderer; -public class PonySnout extends ModelBase implements PonyModelConstants { +import static com.minelittlepony.model.PonyModelConstants.*; - private PonyGender gender; +public class PonySnout { - private PlaneRenderer mare; - private PlaneRenderer stallion; + private PlaneRenderer mare, stallion; public PonySnout(AbstractPonyModel pony, float yOffset, float stretch) { mare = new PlaneRenderer(pony); @@ -41,13 +39,8 @@ public class PonySnout extends ModelBase implements PonyModelConstants { pony.bipedHead.addChild(stallion); } - @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + public void setGender(PonyGender gender) { mare.isHidden = gender != PonyGender.MARE; stallion.isHidden = gender != PonyGender.STALLION; } - - public void setGender(PonyGender gender) { - this.gender = gender; - } } diff --git a/src/main/java/com/minelittlepony/model/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java similarity index 91% rename from src/main/java/com/minelittlepony/model/PonyTail.java rename to src/main/java/com/minelittlepony/model/components/PonyTail.java index d5ed560f..23a424d8 100644 --- a/src/main/java/com/minelittlepony/model/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -1,12 +1,14 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.components; import com.minelittlepony.TailLengths; -import com.minelittlepony.renderer.PlaneRenderer; +import com.minelittlepony.renderer.plane.PlaneRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.util.math.MathHelper; -public class PonyTail extends PlaneRenderer implements PonyModelConstants { +import static com.minelittlepony.model.PonyModelConstants.*; + +public class PonyTail extends PlaneRenderer { private final TailSegment[] segments = new TailSegment[4]; diff --git a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java new file mode 100644 index 00000000..345aeb2e --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -0,0 +1,71 @@ +package com.minelittlepony.model.components; + +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.renderer.HornGlowRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +import static org.lwjgl.opengl.GL11.*; +import static net.minecraft.client.renderer.GlStateManager.*; +import static com.minelittlepony.model.PonyModelConstants.*; + +public class UnicornHorn extends ModelBase { + static final float + hornX = HEAD_CENTRE_X - 0.5F, + hornY = HEAD_CENTRE_Y - 10, + hornZ = HEAD_CENTRE_Z - 1.5F; + + protected final AbstractPonyModel pony; + + private ModelRenderer horn; + + private HornGlowRenderer glow; + + private boolean usingMagic; + + public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) { + this.pony = pony; + + horn = new ModelRenderer(pony, 0, 3); + glow = new HornGlowRenderer(pony, 0, 3); + + horn.addBox(hornX, hornY, hornZ, 1, 4, 1, stretch); + horn.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + horn.rotateAngleX = 0.5F; + + glow.setAlpha(0.4f).addBox(hornX, hornY, hornZ, 1, 4, 1, stretch + 0.5F); + glow.setAlpha(0.2f).addBox(hornX, hornY, hornZ, 1, 3, 1, stretch + 0.8F); + } + + @Override + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (!pony.metadata.getRace().hasHorn()) return; + + this.horn.render(scale); + + if (usingMagic && pony.metadata.hasMagic()) { + renderMagic(pony.metadata.getGlowColor(), scale); + } + } + + private void renderMagic(int tint, float scale) { + glPushAttrib(24577); + disableTexture2D(); + disableLighting(); + enableBlend(); + blendFunc(GL_SRC_ALPHA, GL_ONE); + + horn.postRender(scale); + glow.setTint(tint).render(scale); + + enableTexture2D(); + enableLighting(); + disableBlend(); + popAttrib(); + } + + public void setUsingMagic(boolean usingMagic) { + this.usingMagic = usingMagic; + } +} diff --git a/src/main/java/com/minelittlepony/model/entity/ModelMobPony.java b/src/main/java/com/minelittlepony/model/entity/ModelMobPony.java new file mode 100644 index 00000000..b75c7758 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/entity/ModelMobPony.java @@ -0,0 +1,113 @@ +package com.minelittlepony.model.entity; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.pony.ModelPlayerPony; + +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.math.MathHelper; + +public class ModelMobPony extends ModelPlayerPony { + + public ModelMobPony() { + super(false); + } + + @Override + protected void rotateLegs(float move, float swing, float tick, Entity entity) { + float rightArmRotateAngleX; + float leftArmRotateAngleX; + float rightLegRotateAngleX; + float leftLegRotateAngleX; + + float var8; + float var9; + + if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { + if (this.rainboom) { + rightArmRotateAngleX = ROTATE_270; + leftArmRotateAngleX = ROTATE_270; + rightLegRotateAngleX = ROTATE_90; + leftLegRotateAngleX = ROTATE_90; + } else { + rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); + leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); + rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); + leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); + } + + this.bipedRightArm.rotateAngleY = 0.2F; + this.steveRightArm.rotateAngleY = 0.2F; + this.bipedLeftArm.rotateAngleY = -0.2F; + this.bipedRightLeg.rotateAngleY = -0.2F; + this.bipedLeftLeg.rotateAngleY = 0.2F; + } else { + var8 = (float) Math.pow(swing, 16.0D); + var9 = 3.1415927F * var8 * 0.5F; + float laQuad = 3.1415927F * var8; + float rlQuad = 3.1415927F * var8 * 0.2F; + float llQuad = 3.1415927F * var8 * -0.4F; + rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.6F * swing; + leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.6F * swing; + rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.6F * swing; + leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.6F * swing; + this.bipedRightArm.rotateAngleY = 0.0F; + this.steveRightArm.rotateAngleY = 0.0F; + this.unicornArmRight.rotateAngleY = 0.0F; + this.bipedLeftArm.rotateAngleY = 0.0F; + this.bipedRightLeg.rotateAngleY = 0.0F; + this.bipedLeftLeg.rotateAngleY = 0.0F; + } + + this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; + this.steveRightArm.rotateAngleX = rightArmRotateAngleX; + this.unicornArmRight.rotateAngleX = rightArmRotateAngleX; + this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; + this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; + this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; + this.bipedRightArm.rotateAngleZ = 0.0F; + this.steveRightArm.rotateAngleZ = 0.0F; + this.unicornArmRight.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + + var8 = MathHelper.sin(this.swingProgress * (float)Math.PI); + var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); + + rotateRightArm(var8, var9, move, tick); + rotateLeftArm(var8, var9, move, tick); + } + + protected void rotateRightArm(float var8, float var9, float move, float tick) { + if (this.rightArmPose == ArmPose.EMPTY) return; + + if (!this.metadata.hasMagic()) { + rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + } else { + this.unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmRight, 1, var8, var9, tick); + } + } + + protected static void rotateArmHolding(ModelRenderer arm, float direction, float var8, float var9, float tick) { + arm.rotateAngleZ = 0.0F; + arm.rotateAngleY = direction * (0.1F - var8 * 0.6F); + arm.rotateAngleX = -1.5707964F; + arm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; + arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; + } + + + protected void rotateLeftArm(float var8, float var9, float move, float tick) { + if (this.leftArmPose == ArmPose.EMPTY) return; + + if (!this.metadata.hasMagic()) { + rotateArmHolding(bipedLeftArm, 1, var8, var9, tick); + } else { + this.unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmLeft, 1, var8, var9, tick); + } + } +} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java index 0437915c..3df92705 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java @@ -2,12 +2,12 @@ package com.minelittlepony.model.pony; 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.PonyTail; -import com.minelittlepony.model.UnicornHorn; -import com.minelittlepony.renderer.PlaneRenderer; +import com.minelittlepony.model.components.PegasusWings; +import com.minelittlepony.model.components.PonySnout; +import com.minelittlepony.model.components.PonyTail; +import com.minelittlepony.model.components.UnicornHorn; +import com.minelittlepony.renderer.plane.PlaneRenderer; + import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; @@ -17,8 +17,9 @@ import net.minecraft.util.math.MathHelper; import static net.minecraft.client.renderer.GlStateManager.popMatrix; import static net.minecraft.client.renderer.GlStateManager.pushMatrix; +import static com.minelittlepony.model.PonyModelConstants.*; -public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConstants { +public class ModelPlayerPony extends AbstractPonyModel { private final boolean smallArms; public boolean rainboom; @@ -143,7 +144,6 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; this.snout.setGender(this.metadata.getGender()); - this.snout.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); this.wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); } @@ -477,7 +477,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { if (this.metadata.hasMagic()) { - aimBowPony(unicornArmRight, tick, true); + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); } else { if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); diff --git a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java index 76b672fc..13f91c19 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java @@ -1,136 +1,65 @@ package com.minelittlepony.model.pony; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; - import static net.minecraft.client.renderer.GlStateManager.*; -public class ModelSkeletonPony extends ModelPlayerPony { +import com.minelittlepony.model.entity.ModelMobPony; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.AbstractSkeleton; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumHandSide; + +public class ModelSkeletonPony extends ModelMobPony { public ModelSkeletonPony() { - super(false); + super(); + } + + public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { + rightArmPose = ModelBiped.ArmPose.EMPTY; + leftArmPose = ModelBiped.ArmPose.EMPTY; + ItemStack itemstack = entity.getHeldItem(EnumHand.MAIN_HAND); + + if (itemstack.getItem() == Items.BOW && ((AbstractSkeleton)entity).isSwingingArms()) + { + if (entity.getPrimaryHand() == EnumHandSide.RIGHT) { + rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW; + } else { + leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW; + } + } + + super.setLivingAnimations(entity, move, swing, ticks); } @Override protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float rightArmRotateAngleX; - float leftArmRotateAngleX; - float rightLegRotateAngleX; - float leftLegRotateAngleX; - float var8; - float var9; - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { - if (this.rainboom) { - rightArmRotateAngleX = ROTATE_270; - leftArmRotateAngleX = ROTATE_270; - rightLegRotateAngleX = ROTATE_90; - leftLegRotateAngleX = ROTATE_90; - } else { - rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); - leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); - } - - this.bipedRightArm.rotateAngleY = 0.2F; - this.steveRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.bipedRightLeg.rotateAngleY = -0.2F; - this.bipedLeftLeg.rotateAngleY = 0.2F; - } else { - var8 = (float) Math.pow(swing, 16.0D); - var9 = 3.1415927F * var8 * 0.5F; - float laQuad = 3.1415927F * var8; - float rlQuad = 3.1415927F * var8 * 0.2F; - float llQuad = 3.1415927F * var8 * -0.4F; - rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.6F * swing; - leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.6F * swing; - rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.6F * swing; - leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.6F * swing; - this.bipedRightArm.rotateAngleY = 0.0F; - this.steveRightArm.rotateAngleY = 0.0F; - this.unicornArmRight.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - } - - this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; - this.steveRightArm.rotateAngleX = rightArmRotateAngleX; - this.unicornArmRight.rotateAngleX = rightArmRotateAngleX; - this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; - this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; - this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.steveRightArm.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.rightArmPose != ArmPose.EMPTY) { - var8 = MathHelper.sin(this.swingProgress * 3.1415927F); - var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); - if (!this.metadata.hasMagic()) { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F; - this.bipedRightArm.rotateAngleX = -1.5707964F; - this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } else { - this.unicornArmRight.rotationPointX = -7.0F; - this.unicornArmRight.rotationPointY = 12.0F; - this.unicornArmRight.rotationPointZ = -2.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleY = 0.1F - var8 * 0.6F; - this.unicornArmRight.rotateAngleX = -1.5707964F; - this.unicornArmRight.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.unicornArmRight.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.unicornArmRight.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } - } - if (this.leftArmPose != ArmPose.EMPTY) { - var8 = MathHelper.sin(this.swingProgress * 3.1415927F); - var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); - if (!this.metadata.hasMagic()) { - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.1F - var8 * 0.6F; - this.bipedLeftArm.rotateAngleX = -1.5707964F; - this.bipedLeftArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } else { - this.unicornArmLeft.rotationPointX = -7.0F; - this.unicornArmLeft.rotationPointY = 12.0F; - this.unicornArmLeft.rotationPointZ = -2.0F; - this.unicornArmLeft.rotateAngleZ = 0.0F; - this.unicornArmLeft.rotateAngleY = 0.1F - var8 * 0.6F; - this.unicornArmLeft.rotateAngleX = -1.5707964F; - this.unicornArmLeft.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.unicornArmLeft.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.unicornArmLeft.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } - } - this.aimBow(this.leftArmPose, this.rightArmPose, tick); + super.rotateLegs(move, swing, tick, entity); + aimBow(leftArmPose, rightArmPose, tick); } - + @Override protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { - this.bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); + if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { + bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } - + } @Override protected void renderLegs() { pushMatrix(); - translate(0.05F, -0.21F, -0.0F); + translate(0.05F, -0.21F, 0); scale(0.5F, 1.15F, 0.5F); this.bipedLeftArm.render(this.scale); popMatrix(); pushMatrix(); - translate(-0.05F, -0.21F, -0.0F); + translate(-0.05F, -0.21F, 0); scale(0.5F, 1.2F, 0.5F); this.bipedRightArm.render(this.scale); popMatrix(); diff --git a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java index 079cb49b..660124d2 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java @@ -1,9 +1,11 @@ package com.minelittlepony.model.pony; -import com.minelittlepony.renderer.PlaneRenderer; +import com.minelittlepony.renderer.plane.PlaneRenderer; + import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.util.math.MathHelper; +import static com.minelittlepony.model.PonyModelConstants.*; public class ModelVillagerPony extends ModelPlayerPony { diff --git a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java index 098c7d99..3076f192 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java @@ -1,100 +1,43 @@ package com.minelittlepony.model.pony; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.MathHelper; -public class ModelZombiePony extends ModelPlayerPony { +import com.minelittlepony.model.entity.ModelMobPony; + +public class ModelZombiePony extends ModelMobPony { public ModelZombiePony() { - super(false); + super(); } - + + private boolean isRight(float move) { + return MathHelper.sin(move / 20f) < 0f; + } + @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float rightArmRotateAngleX; - float leftArmRotateAngleX; - float rightLegRotateAngleX; - float leftLegRotateAngleX; - float var8; - float var9; - // why are zombies flying? - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { - if (this.rainboom) { - rightArmRotateAngleX = ROTATE_270; - leftArmRotateAngleX = ROTATE_270; - rightLegRotateAngleX = ROTATE_90; - leftLegRotateAngleX = ROTATE_90; - } else { - rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); - leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); - } - - this.bipedRightArm.rotateAngleY = 0.2F; - this.steveRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.bipedRightLeg.rotateAngleY = -0.2F; - this.bipedLeftLeg.rotateAngleY = 0.2F; + protected void rotateRightArm(float var8, float var9, float move, float tick) { + if (this.rightArmPose != ArmPose.EMPTY) return; + + if (isRight(move)) { + rotateArmHolding(bipedRightArm, 1, var8, var9, tick); } else { - var8 = (float) Math.pow(swing, 16.0D); - var9 = 3.1415927F * var8 * 0.5F; - float laQuad = 3.1415927F * var8; - float rlQuad = 3.1415927F * var8 * 0.2F; - 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; - rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing; - leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.45F * swing; - this.bipedRightArm.rotateAngleY = 0.0F; - this.steveRightArm.rotateAngleY = 0.0F; - this.unicornArmRight.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; + rotateArmHolding(bipedLeftArm, -1, var8, var9, tick); } - - this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; - this.steveRightArm.rotateAngleX = rightArmRotateAngleX; - this.unicornArmRight.rotateAngleX = 0.0F; - this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; - this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; - this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.steveRightArm.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.rightArmPose == ArmPose.EMPTY) { - var8 = MathHelper.sin(this.swingProgress * (float) Math.PI); - var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI); - if (MathHelper.sin(move / 20.0F) < 0.0F) { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F; - this.bipedRightArm.rotateAngleX = -1.5707964F; - this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } else { - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleY = -(0.1F - var8 * 0.6F); - this.bipedLeftArm.rotateAngleX = -1.5707964F; - this.bipedLeftArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } - } - + } + + @Override + protected void rotateLeftArm(float var8, float var9, float move, float tick) { + } @Override protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose == ArmPose.EMPTY) { - if (MathHelper.sin(move / 20.0F) < 0.0F) { - shiftRotationPoint(this.bipedRightArm, 0.5F, 1.5F, 3.0F); - } else { - shiftRotationPoint(this.bipedLeftArm, -0.5F, 1.5F, 3.0F); - } + if (rightArmPose != ArmPose.EMPTY) return; + + if (isRight(move)) { + shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + } else { + shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); } } 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 908719d9..d6b9bdce 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java @@ -5,6 +5,8 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; +import static com.minelittlepony.model.PonyModelConstants.*; + public class ModelPonyArmor extends ModelPlayerPony { public ModelRenderer Bodypiece; diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java index c42f8deb..46a4e29d 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java @@ -4,6 +4,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.MathHelper; +import static com.minelittlepony.model.PonyModelConstants.*; + public class ModelSkeletonPonyArmor extends ModelPonyArmor { @Override diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java index b63c54c5..1657be66 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java @@ -3,6 +3,7 @@ package com.minelittlepony.model.pony.armor; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.MathHelper; +import static com.minelittlepony.model.PonyModelConstants.*; public class ModelZombiePonyArmor extends ModelPonyArmor { diff --git a/src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java b/src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java new file mode 100644 index 00000000..0df82fb9 --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java @@ -0,0 +1,49 @@ +package com.minelittlepony.renderer; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.model.TextureOffset; + +@SuppressWarnings("unchecked") +public class BasePonyRenderer> extends ModelRenderer { + + protected final ModelBase baseModel; + + protected int textureOffsetX, textureOffsetY; + + public BasePonyRenderer(ModelBase model) { + super(model); + baseModel = model; + } + + public BasePonyRenderer(ModelBase model, int x, int y) { + super(model, x, y); + baseModel = model; + } + + @Override + public T setTextureOffset(int x, int y) { + this.textureOffsetX = x; + this.textureOffsetY = y; + super.setTextureOffset(x, y); + return (T) this; + } + + @Override + public T addBox(String partName, float offX, float offY, float offZ, int width, int height, int depth) { + partName = boxName + "." + partName; + + TextureOffset tex = this.baseModel.getTextureOffset(partName); + + setTextureOffset(tex.textureOffsetX, tex.textureOffsetY).addBox(offX, offY, offZ, width, height, depth); + cubeList.get(cubeList.size() - 1).setBoxName(partName); + + return (T) this; + } + + @Override + public T addBox(float offX, float offY, float offZ, int width, int height, int depth) { + addBox(offX, offY, offZ, width, height, depth, 0); + return (T) this; + } +} diff --git a/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java b/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java index 727d85c0..cd6cec19 100644 --- a/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java @@ -1,51 +1,44 @@ package com.minelittlepony.renderer; +import static net.minecraft.client.renderer.GlStateManager.color; + import com.minelittlepony.model.ModelHornGlow; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.model.TextureOffset; -public class HornGlowRenderer extends ModelRenderer { +public class HornGlowRenderer extends BasePonyRenderer { - private int textureOffsetX; - private int textureOffsetY; - private ModelBase baseModel; - - public HornGlowRenderer(ModelBase par1ModelBase) { - super(par1ModelBase); - this.baseModel = par1ModelBase; + float r, g, b, a = 1; + + public HornGlowRenderer(ModelBase model, int x, int y) { + super(model, x, y); } - public HornGlowRenderer(ModelBase par1ModelBase, int par2, int par3) { - this(par1ModelBase); - this.setTextureSize(par2, par3); + public HornGlowRenderer setAlpha(float a) { + this.a = a; - } - - @Override - public HornGlowRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7) { - par1Str = this.boxName + "." + par1Str; - TextureOffset var8 = this.baseModel.getTextureOffset(par1Str); - this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY); - this.cubeList.add((new ModelHornGlow(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F)).setBoxName(par1Str)); return this; } - @Override - public HornGlowRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6) { - this.cubeList.add(new ModelHornGlow(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F)); + public HornGlowRenderer setTint(int tint) { + r = (tint >> 16 & 255) / 255.0F; + g = (tint >> 8 & 255) / 255.0F; + b = (tint & 255) / 255.0F; + return this; } - @Override - public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7) { - this.cubeList.add(new ModelHornGlow(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, par7)); + public void applyTint(float alpha) { + color(r, g, b, alpha); } @Override - public ModelRenderer setTextureOffset(int x, int y) { - this.textureOffsetX = x; - this.textureOffsetY = y; - return this; + public void addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { + this.cubeList.add(new ModelHornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, a)); + } + + @Override + public void render(float scale) { + super.render(scale); + color(1, 1, 1, 1); } } diff --git a/src/main/java/com/minelittlepony/renderer/plane/Face.java b/src/main/java/com/minelittlepony/renderer/plane/Face.java new file mode 100644 index 00000000..98eb9b25 --- /dev/null +++ b/src/main/java/com/minelittlepony/renderer/plane/Face.java @@ -0,0 +1,7 @@ +package com.minelittlepony.renderer.plane; + +enum Face { + WEST, EAST, + UP, DOWN, + NORTH, SOUTH +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/model/ModelPlane.java b/src/main/java/com/minelittlepony/renderer/plane/ModelPlane.java similarity index 95% rename from src/main/java/com/minelittlepony/model/ModelPlane.java rename to src/main/java/com/minelittlepony/renderer/plane/ModelPlane.java index 7ac3575d..7592da53 100644 --- a/src/main/java/com/minelittlepony/model/ModelPlane.java +++ b/src/main/java/com/minelittlepony/renderer/plane/ModelPlane.java @@ -1,6 +1,5 @@ -package com.minelittlepony.model; +package com.minelittlepony.renderer.plane; -import com.minelittlepony.renderer.PlaneRenderer; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; @@ -109,13 +108,4 @@ public class ModelPlane extends ModelBox { public void render(@Nonnull BufferBuilder renderer, float scale) { if (!hidden) this.quad.draw(renderer, scale); } - - public enum Face { - EAST, - WEST, - DOWN, - UP, - SOUTH, - NORTH - } } diff --git a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java b/src/main/java/com/minelittlepony/renderer/plane/PlaneRenderer.java similarity index 69% rename from src/main/java/com/minelittlepony/renderer/PlaneRenderer.java rename to src/main/java/com/minelittlepony/renderer/plane/PlaneRenderer.java index 43f4da60..03f9eff9 100644 --- a/src/main/java/com/minelittlepony/renderer/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/renderer/plane/PlaneRenderer.java @@ -1,17 +1,13 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.renderer.plane; + +import com.minelittlepony.renderer.BasePonyRenderer; -import com.minelittlepony.model.ModelPlane; -import com.minelittlepony.model.ModelPlane.Face; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -@SuppressWarnings("unused") -public class PlaneRenderer extends ModelRenderer { +public class PlaneRenderer extends BasePonyRenderer { public boolean mirrory, mirrorz; - private int textureOffsetX, textureOffsetY; - public PlaneRenderer(ModelBase model) { super(model); } @@ -20,16 +16,8 @@ public class PlaneRenderer extends ModelRenderer { super(model, x, y); } - @Override - public PlaneRenderer setTextureOffset(int x, int y) { - this.textureOffsetX = x; - this.textureOffsetY = y; - super.setTextureOffset(x, y); - return this; - } - private void addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) { - this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, offX, offY, offZ, width, height, depth, scale, face)); + this.cubeList.add(new ModelPlane(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scale, face)); } public void addTopPlane(float offX, float offY, float offZ, int width, int depth, float scale) { From 5da88c85511c76d5a4ba48b2bcd7d9135fea98b8 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 13:00:18 +0200 Subject: [PATCH 12/96] Wave 3, simplify trigger pixel handling --- .../java/com/minelittlepony/PonyData.java | 85 +++---------------- .../java/com/minelittlepony/PonyGender.java | 19 ++++- .../java/com/minelittlepony/PonyRace.java | 34 +++++--- .../java/com/minelittlepony/PonySize.java | 22 +++-- .../java/com/minelittlepony/TailLengths.java | 25 ++++-- .../pony/data/ITriggerPixelMapped.java | 14 +++ .../pony/data/TriggerPixels.java | 35 ++++++++ 7 files changed, 136 insertions(+), 98 deletions(-) create mode 100644 src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java create mode 100644 src/main/java/com/minelittlepony/pony/data/TriggerPixels.java diff --git a/src/main/java/com/minelittlepony/PonyData.java b/src/main/java/com/minelittlepony/PonyData.java index 459fbe83..af59130c 100644 --- a/src/main/java/com/minelittlepony/PonyData.java +++ b/src/main/java/com/minelittlepony/PonyData.java @@ -1,37 +1,13 @@ package com.minelittlepony; import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableBiMap; +import com.minelittlepony.pony.data.TriggerPixels; import java.awt.image.BufferedImage; -import java.util.Map; import javax.annotation.concurrent.Immutable; @Immutable public class PonyData implements IPonyData { - - private static final Map RACE_COLORS = ImmutableBiMap.builder() - .put(0xf9b131, PonyRace.EARTH) - .put(0xd19fe4, PonyRace.UNICORN) - .put(0x88caf0, PonyRace.PEGASUS) - .put(0xfef9fc, PonyRace.ALICORN) - .put(0xd0cccf, PonyRace.ZEBRA) - .put(0x282b29, PonyRace.CHANGELING) - .put(0xcaed5a, PonyRace.REFORMED_CHANGELING) - .put(0xae9145, PonyRace.GRIFFIN) - .put(0xd6ddac, PonyRace.HIPPOGRIFF) - .build(); - private static final Map TAIL_COLORS = ImmutableBiMap.builder() - .put(0x425844, TailLengths.STUB) - .put(0xd19fe4, TailLengths.QUARTER) - .put(0x534b76, TailLengths.HALF) - .put(0x8a6b7f, TailLengths.THREE_QUARTERS).build(); - private static final Map SIZE_COLORS = ImmutableBiMap.builder() - .put(0xffbe53, PonySize.FOAL) - .put(0xce3254, PonySize.LARGE) - .put(0x534b76, PonySize.TALL) - .build(); - private final PonyRace race; private final TailLengths tailSize; private final PonyGender gender; @@ -39,15 +15,19 @@ public class PonyData implements IPonyData { private final int glowColor; public PonyData() { - this(PonyRace.HUMAN, TailLengths.FULL, PonyGender.MARE, PonySize.NORMAL, 0x4444aa); + this.race = PonyRace.HUMAN; + this.tailSize = TailLengths.FULL; + this.gender = PonyGender.MARE; + this.size = PonySize.NORMAL; + this.glowColor = 0x4444aa; } - - private PonyData(PonyRace race, TailLengths tailSize, PonyGender gender, PonySize size, int glowColor) { - this.race = race; - this.tailSize = tailSize; - this.gender = gender; - this.size = size; - this.glowColor = glowColor; + + private PonyData(BufferedImage image) { + this.race = TriggerPixels.RACE.readValue(image); + this.tailSize = TriggerPixels.TAIL.readValue(image); + this.size = TriggerPixels.SIZE.readValue(image); + this.gender = TriggerPixels.GENDER.readValue(image); + this.glowColor = TriggerPixels.GLOW.readColor(image, -1); } @Override @@ -92,43 +72,6 @@ public class PonyData implements IPonyData { } static IPonyData parse(BufferedImage image) { - int racePx = TriggerPixels.RACE.readColor(image); - PonyRace race = RACE_COLORS.getOrDefault(racePx, PonyRace.HUMAN); - - int tailPx = TriggerPixels.TAIL.readColor(image); - TailLengths tail = TAIL_COLORS.getOrDefault(tailPx, TailLengths.FULL); - - int sizePx = TriggerPixels.SIZE.readColor(image); - PonySize size = SIZE_COLORS.getOrDefault(sizePx, PonySize.NORMAL); - - int genderPx = TriggerPixels.GENDER.readColor(image); - PonyGender gender = genderPx == 0xffffff ? PonyGender.STALLION : PonyGender.MARE; - - int glowColor = TriggerPixels.GLOW.readColor(image, -1); - - return new PonyData(race, tail, gender, size, glowColor); - } - - private enum TriggerPixels { - RACE(0, 0), - TAIL(1, 0), - GENDER(2, 0), - SIZE(3, 0), - GLOW(0, 1); - - private int x, y; - - TriggerPixels(int x, int y) { - this.x = x; - this.y = y; - } - - private int readColor(BufferedImage image) { - return readColor(image, 0xffffff); - } - - private int readColor(BufferedImage image, int mask) { - return image.getRGB(x, y) & mask; - } + return new PonyData(image); } } diff --git a/src/main/java/com/minelittlepony/PonyGender.java b/src/main/java/com/minelittlepony/PonyGender.java index 060295f3..1da3900d 100644 --- a/src/main/java/com/minelittlepony/PonyGender.java +++ b/src/main/java/com/minelittlepony/PonyGender.java @@ -1,6 +1,19 @@ package com.minelittlepony; -public enum PonyGender { - MARE, - STALLION +import com.minelittlepony.pony.data.ITriggerPixelMapped; + +public enum PonyGender implements ITriggerPixelMapped { + MARE(0), + STALLION(0xffffff); + + int triggerValue; + + PonyGender(int pixel) { + triggerValue = pixel; + } + + @Override + public int getTriggerPixel() { + return triggerValue; + } } diff --git a/src/main/java/com/minelittlepony/PonyRace.java b/src/main/java/com/minelittlepony/PonyRace.java index fa0f82b5..35846b7e 100644 --- a/src/main/java/com/minelittlepony/PonyRace.java +++ b/src/main/java/com/minelittlepony/PonyRace.java @@ -1,25 +1,30 @@ package com.minelittlepony; import com.minelittlepony.model.PlayerModels; +import com.minelittlepony.pony.data.ITriggerPixelMapped; -public enum PonyRace { +public enum PonyRace implements ITriggerPixelMapped { - HUMAN(PlayerModels.HUMAN, false, false), - EARTH(PlayerModels.PONY,false, false), - PEGASUS(PlayerModels.PONY, true, false), - UNICORN(PlayerModels.PONY, false, true), - ALICORN(PlayerModels.PONY, true, true), - CHANGELING(PlayerModels.PONY, true, true), - ZEBRA(PlayerModels.PONY, false, false), - REFORMED_CHANGELING(PlayerModels.PONY, true, true), - GRIFFIN(PlayerModels.PONY, true, false), - HIPPOGRIFF(PlayerModels.PONY, true, false); + HUMAN(0, PlayerModels.HUMAN, false, false), + EARTH(0xf9b131, PlayerModels.PONY,false, false), + PEGASUS(0x88caf0, PlayerModels.PONY, true, false), + UNICORN(0xd19fe4, PlayerModels.PONY, false, true), + ALICORN(0xfef9fc, PlayerModels.PONY, true, true), + CHANGELING(0x282b29, PlayerModels.PONY, true, true), + ZEBRA(0xd0cccf, PlayerModels.PONY, false, false), + REFORMED_CHANGELING(0xcaed5a, PlayerModels.PONY, true, true), + GRIFFIN(0xae9145, PlayerModels.PONY, true, false), + HIPPOGRIFF(0xd6ddac, PlayerModels.PONY, true, false); private boolean wings, horn; + private int triggerPixel; + private PlayerModels model; - PonyRace(PlayerModels model, boolean wings, boolean horn) { + PonyRace(int triggerPixel, PlayerModels model, boolean wings, boolean horn) { + this.triggerPixel = triggerPixel; + this.wings = wings; this.horn = horn; this.model = model; @@ -45,4 +50,9 @@ public enum PonyRace { if (level == PonyLevel.HUMANS) return HUMAN; return this; } + + @Override + public int getTriggerPixel() { + return triggerPixel; + } } diff --git a/src/main/java/com/minelittlepony/PonySize.java b/src/main/java/com/minelittlepony/PonySize.java index 400bf5f9..1c230455 100644 --- a/src/main/java/com/minelittlepony/PonySize.java +++ b/src/main/java/com/minelittlepony/PonySize.java @@ -1,14 +1,19 @@ package com.minelittlepony; -public enum PonySize { - NORMAL(0.4f, 1f), - LARGE(0.5f, 0.8f), - FOAL(0.25f, 0.8f), - TALL(0.45f, 1f); +import com.minelittlepony.pony.data.ITriggerPixelMapped; +public enum PonySize implements ITriggerPixelMapped { + NORMAL(0, 0.4f, 1f), + LARGE(0xce3254, 0.5f, 0.8f), + FOAL(0xffbe53, 0.25f, 0.8f), + TALL(0x534b76, 0.45f, 1f); + + private int triggerValue; + private float shadowSize, scale; - PonySize(float shadowSz, float scaleF) { + PonySize(int pixel, float shadowSz, float scaleF) { + triggerValue = pixel; shadowSize = shadowSz; scale = scaleF; } @@ -20,4 +25,9 @@ public enum PonySize { public float getScaleFactor() { return scale; } + + @Override + public int getTriggerPixel() { + return triggerValue; + } } diff --git a/src/main/java/com/minelittlepony/TailLengths.java b/src/main/java/com/minelittlepony/TailLengths.java index 5c1cc534..483cb977 100644 --- a/src/main/java/com/minelittlepony/TailLengths.java +++ b/src/main/java/com/minelittlepony/TailLengths.java @@ -1,10 +1,23 @@ package com.minelittlepony; -public enum TailLengths { +import com.minelittlepony.pony.data.ITriggerPixelMapped; - STUB, - QUARTER, - HALF, - THREE_QUARTERS, - FULL; +public enum TailLengths implements ITriggerPixelMapped { + + STUB(0x425844), + QUARTER(0xd19fe4), + HALF(0x534b76), + THREE_QUARTERS(0x8a6b7f), + FULL(0); + + private int triggerValue; + + TailLengths(int pixel) { + triggerValue = pixel; + } + + @Override + public int getTriggerPixel() { + return triggerValue; + } } diff --git a/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java new file mode 100644 index 00000000..9ba53aa0 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java @@ -0,0 +1,14 @@ +package com.minelittlepony.pony.data; + +public interface ITriggerPixelMapped & ITriggerPixelMapped> { + + int getTriggerPixel(); + + @SuppressWarnings("unchecked") + public static & ITriggerPixelMapped> T getByTriggerPixel(T type, int pixelValue) { + for (T i : (T[])type.getClass().getEnumConstants()) { + if (i.getTriggerPixel() == pixelValue) return i; + } + return type; + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java new file mode 100644 index 00000000..83ecd9a2 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -0,0 +1,35 @@ +package com.minelittlepony.pony.data; + +import java.awt.image.BufferedImage; + +import com.minelittlepony.PonyGender; +import com.minelittlepony.PonyRace; +import com.minelittlepony.PonySize; +import com.minelittlepony.TailLengths; + +public enum TriggerPixels { + RACE(PonyRace.HUMAN, 0, 0), + TAIL(TailLengths.FULL, 1, 0), + GENDER(PonyGender.MARE, 2, 0), + SIZE(PonySize.NORMAL, 3, 0), + GLOW(null, 0, 1); + + private int x, y; + + ITriggerPixelMapped def; + + TriggerPixels(ITriggerPixelMapped def, int x, int y) { + this.def = def; + this.x = x; + this.y = y; + } + + public int readColor(BufferedImage image, int mask) { + return image.getRGB(x, y) & mask; + } + + @SuppressWarnings("unchecked") + public & ITriggerPixelMapped> T readValue(BufferedImage image) { + return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff)); + } +} \ No newline at end of file From 403c1950073d06543f8de6f481f6d627188e6a64 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 13:02:10 +0200 Subject: [PATCH 13/96] Time to tackle packages (phase 1: separate the data from all the other carp) --- src/main/java/com/minelittlepony/MineLittlePony.java | 2 ++ src/main/java/com/minelittlepony/PonyConfig.java | 1 + src/main/java/com/minelittlepony/PonyManager.java | 2 ++ src/main/java/com/minelittlepony/ducks/IPlayerInfo.java | 2 +- src/main/java/com/minelittlepony/gui/PonySettingPanel.java | 2 +- .../com/minelittlepony/hdskins/gui/RenderPonyModel.java | 2 +- .../com/minelittlepony/mixin/MixinNetworkPlayerInfo.java | 2 +- src/main/java/com/minelittlepony/model/AbstractArmor.java | 2 +- .../java/com/minelittlepony/model/AbstractPonyModel.java | 6 +++--- src/main/java/com/minelittlepony/model/PlayerModel.java | 2 +- .../java/com/minelittlepony/model/components/PonySnout.java | 2 +- .../java/com/minelittlepony/model/components/PonyTail.java | 3 ++- .../java/com/minelittlepony/{ => pony/data}/IPonyData.java | 2 +- src/main/java/com/minelittlepony/{ => pony/data}/Pony.java | 3 ++- .../java/com/minelittlepony/{ => pony/data}/PonyData.java | 4 ++-- .../minelittlepony/{ => pony/data}/PonyDataSerialzier.java | 2 +- .../java/com/minelittlepony/{ => pony/data}/PonyGender.java | 4 +--- .../java/com/minelittlepony/{ => pony/data}/PonyLevel.java | 2 +- .../java/com/minelittlepony/{ => pony/data}/PonyRace.java | 3 +-- .../java/com/minelittlepony/{ => pony/data}/PonySize.java | 4 +--- .../com/minelittlepony/{ => pony/data}/TailLengths.java | 4 +--- .../java/com/minelittlepony/pony/data/TriggerPixels.java | 5 ----- .../minelittlepony/renderer/layer/LayerHeldPonyItem.java | 2 +- .../com/minelittlepony/renderer/player/RenderPonyBase.java | 2 +- 24 files changed, 30 insertions(+), 35 deletions(-) rename src/main/java/com/minelittlepony/{ => pony/data}/IPonyData.java (89%) rename src/main/java/com/minelittlepony/{ => pony/data}/Pony.java (98%) rename src/main/java/com/minelittlepony/{ => pony/data}/PonyData.java (96%) rename src/main/java/com/minelittlepony/{ => pony/data}/PonyDataSerialzier.java (94%) rename src/main/java/com/minelittlepony/{ => pony/data}/PonyGender.java (77%) rename src/main/java/com/minelittlepony/{ => pony/data}/PonyLevel.java (61%) rename src/main/java/com/minelittlepony/{ => pony/data}/PonyRace.java (94%) rename src/main/java/com/minelittlepony/{ => pony/data}/PonySize.java (87%) rename src/main/java/com/minelittlepony/{ => pony/data}/TailLengths.java (81%) diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index 1116b9f0..326372bd 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -4,6 +4,8 @@ import com.google.common.collect.Maps; import com.minelittlepony.gui.PonySettingPanel; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; import com.minelittlepony.model.PMAPI; +import com.minelittlepony.pony.data.IPonyData; +import com.minelittlepony.pony.data.PonyDataSerialzier; import com.minelittlepony.renderer.RenderPonyEvoker; import com.minelittlepony.renderer.RenderPonyIllusionIllager; import com.minelittlepony.renderer.RenderPonyPigman; diff --git a/src/main/java/com/minelittlepony/PonyConfig.java b/src/main/java/com/minelittlepony/PonyConfig.java index db8ff1dd..ac76072a 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -1,6 +1,7 @@ package com.minelittlepony; import com.google.gson.annotations.Expose; +import com.minelittlepony.pony.data.PonyLevel; import com.mumfrey.liteloader.modconfig.ConfigStrategy; import com.mumfrey.liteloader.modconfig.Exposable; import com.mumfrey.liteloader.modconfig.ExposableOptions; diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 909ddb6f..bfddf206 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -6,6 +6,8 @@ import com.google.gson.Gson; import com.google.gson.JsonParseException; import com.minelittlepony.ducks.IPlayerInfo; import com.minelittlepony.model.PMAPI; +import com.minelittlepony.pony.data.Pony; +import com.minelittlepony.pony.data.PonyLevel; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.resources.DefaultPlayerSkin; diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index 2a6a0df5..f2d62f55 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -1,6 +1,6 @@ package com.minelittlepony.ducks; -import com.minelittlepony.Pony; +import com.minelittlepony.pony.data.Pony; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; diff --git a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java b/src/main/java/com/minelittlepony/gui/PonySettingPanel.java index f7745153..217d1f44 100644 --- a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/gui/PonySettingPanel.java @@ -2,7 +2,7 @@ package com.minelittlepony.gui; import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyConfig; -import com.minelittlepony.PonyLevel; +import com.minelittlepony.pony.data.PonyLevel; import com.mumfrey.liteloader.client.gui.GuiCheckbox; import com.mumfrey.liteloader.core.LiteLoader; import net.minecraft.client.gui.GuiButton; diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 5499409b..021f737b 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -1,11 +1,11 @@ package com.minelittlepony.hdskins.gui; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.Pony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ModelPonyElytra; import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.pony.data.Pony; import com.minelittlepony.renderer.layer.AbstractPonyLayer; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; import net.minecraft.client.model.ModelPlayer; diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java index 744e2417..89356ba0 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -7,9 +7,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.Pony; import com.minelittlepony.PonyManager; import com.minelittlepony.ducks.IPlayerInfo; +import com.minelittlepony.pony.data.Pony; import com.mojang.authlib.GameProfile; import net.minecraft.client.network.NetworkPlayerInfo; diff --git a/src/main/java/com/minelittlepony/model/AbstractArmor.java b/src/main/java/com/minelittlepony/model/AbstractArmor.java index 3b620665..aed2b388 100644 --- a/src/main/java/com/minelittlepony/model/AbstractArmor.java +++ b/src/main/java/com/minelittlepony/model/AbstractArmor.java @@ -1,6 +1,6 @@ package com.minelittlepony.model; -import com.minelittlepony.IPonyData; +import com.minelittlepony.pony.data.IPonyData; public abstract class AbstractArmor { diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 8baa53ae..cd67a436 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,9 +1,9 @@ package com.minelittlepony.model; -import com.minelittlepony.IPonyData; -import com.minelittlepony.PonyData; -import com.minelittlepony.PonySize; import com.minelittlepony.model.pony.ModelPlayerPony; +import com.minelittlepony.pony.data.IPonyData; +import com.minelittlepony.pony.data.PonyData; +import com.minelittlepony.pony.data.PonySize; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelPlayer; diff --git a/src/main/java/com/minelittlepony/model/PlayerModel.java b/src/main/java/com/minelittlepony/model/PlayerModel.java index a0520365..9a9e5dee 100644 --- a/src/main/java/com/minelittlepony/model/PlayerModel.java +++ b/src/main/java/com/minelittlepony/model/PlayerModel.java @@ -1,6 +1,6 @@ package com.minelittlepony.model; -import com.minelittlepony.IPonyData; +import com.minelittlepony.pony.data.IPonyData; public class PlayerModel { diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java index d032cf83..d3067f28 100644 --- a/src/main/java/com/minelittlepony/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -1,7 +1,7 @@ package com.minelittlepony.model.components; -import com.minelittlepony.PonyGender; import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.pony.data.PonyGender; import com.minelittlepony.renderer.plane.PlaneRenderer; import static com.minelittlepony.model.PonyModelConstants.*; diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 23a424d8..3796747a 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -1,6 +1,5 @@ package com.minelittlepony.model.components; -import com.minelittlepony.TailLengths; import com.minelittlepony.renderer.plane.PlaneRenderer; import net.minecraft.client.model.ModelBase; @@ -8,6 +7,8 @@ import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.pony.data.TailLengths; + public class PonyTail extends PlaneRenderer { private final TailSegment[] segments = new TailSegment[4]; diff --git a/src/main/java/com/minelittlepony/IPonyData.java b/src/main/java/com/minelittlepony/pony/data/IPonyData.java similarity index 89% rename from src/main/java/com/minelittlepony/IPonyData.java rename to src/main/java/com/minelittlepony/pony/data/IPonyData.java index 7698f168..f1f23d67 100644 --- a/src/main/java/com/minelittlepony/IPonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/IPonyData.java @@ -1,4 +1,4 @@ -package com.minelittlepony; +package com.minelittlepony.pony.data; import net.minecraft.client.resources.data.IMetadataSection; diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java similarity index 98% rename from src/main/java/com/minelittlepony/Pony.java rename to src/main/java/com/minelittlepony/pony/data/Pony.java index 80d06751..1dde419c 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -1,6 +1,7 @@ -package com.minelittlepony; +package com.minelittlepony.pony.data; import com.google.common.base.MoreObjects; +import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IDownloadImageData; import com.minelittlepony.model.PlayerModel; import com.voxelmodpack.hdskins.DynamicTextureImage; diff --git a/src/main/java/com/minelittlepony/PonyData.java b/src/main/java/com/minelittlepony/pony/data/PonyData.java similarity index 96% rename from src/main/java/com/minelittlepony/PonyData.java rename to src/main/java/com/minelittlepony/pony/data/PonyData.java index af59130c..aa5e0ea0 100644 --- a/src/main/java/com/minelittlepony/PonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyData.java @@ -1,7 +1,7 @@ -package com.minelittlepony; +package com.minelittlepony.pony.data; import com.google.common.base.MoreObjects; -import com.minelittlepony.pony.data.TriggerPixels; +import com.minelittlepony.MineLittlePony; import java.awt.image.BufferedImage; import javax.annotation.concurrent.Immutable; diff --git a/src/main/java/com/minelittlepony/PonyDataSerialzier.java b/src/main/java/com/minelittlepony/pony/data/PonyDataSerialzier.java similarity index 94% rename from src/main/java/com/minelittlepony/PonyDataSerialzier.java rename to src/main/java/com/minelittlepony/pony/data/PonyDataSerialzier.java index 4e3d4c4d..a3703f3e 100644 --- a/src/main/java/com/minelittlepony/PonyDataSerialzier.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyDataSerialzier.java @@ -1,4 +1,4 @@ -package com.minelittlepony; +package com.minelittlepony.pony.data; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement; diff --git a/src/main/java/com/minelittlepony/PonyGender.java b/src/main/java/com/minelittlepony/pony/data/PonyGender.java similarity index 77% rename from src/main/java/com/minelittlepony/PonyGender.java rename to src/main/java/com/minelittlepony/pony/data/PonyGender.java index 1da3900d..f1634136 100644 --- a/src/main/java/com/minelittlepony/PonyGender.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyGender.java @@ -1,6 +1,4 @@ -package com.minelittlepony; - -import com.minelittlepony.pony.data.ITriggerPixelMapped; +package com.minelittlepony.pony.data; public enum PonyGender implements ITriggerPixelMapped { MARE(0), diff --git a/src/main/java/com/minelittlepony/PonyLevel.java b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java similarity index 61% rename from src/main/java/com/minelittlepony/PonyLevel.java rename to src/main/java/com/minelittlepony/pony/data/PonyLevel.java index cc23fb42..573f9c74 100644 --- a/src/main/java/com/minelittlepony/PonyLevel.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java @@ -1,4 +1,4 @@ -package com.minelittlepony; +package com.minelittlepony.pony.data; public enum PonyLevel { diff --git a/src/main/java/com/minelittlepony/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java similarity index 94% rename from src/main/java/com/minelittlepony/PonyRace.java rename to src/main/java/com/minelittlepony/pony/data/PonyRace.java index 35846b7e..d47897c0 100644 --- a/src/main/java/com/minelittlepony/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -1,7 +1,6 @@ -package com.minelittlepony; +package com.minelittlepony.pony.data; import com.minelittlepony.model.PlayerModels; -import com.minelittlepony.pony.data.ITriggerPixelMapped; public enum PonyRace implements ITriggerPixelMapped { diff --git a/src/main/java/com/minelittlepony/PonySize.java b/src/main/java/com/minelittlepony/pony/data/PonySize.java similarity index 87% rename from src/main/java/com/minelittlepony/PonySize.java rename to src/main/java/com/minelittlepony/pony/data/PonySize.java index 1c230455..8f4d07d6 100644 --- a/src/main/java/com/minelittlepony/PonySize.java +++ b/src/main/java/com/minelittlepony/pony/data/PonySize.java @@ -1,6 +1,4 @@ -package com.minelittlepony; - -import com.minelittlepony.pony.data.ITriggerPixelMapped; +package com.minelittlepony.pony.data; public enum PonySize implements ITriggerPixelMapped { NORMAL(0, 0.4f, 1f), diff --git a/src/main/java/com/minelittlepony/TailLengths.java b/src/main/java/com/minelittlepony/pony/data/TailLengths.java similarity index 81% rename from src/main/java/com/minelittlepony/TailLengths.java rename to src/main/java/com/minelittlepony/pony/data/TailLengths.java index 483cb977..7007e390 100644 --- a/src/main/java/com/minelittlepony/TailLengths.java +++ b/src/main/java/com/minelittlepony/pony/data/TailLengths.java @@ -1,6 +1,4 @@ -package com.minelittlepony; - -import com.minelittlepony.pony.data.ITriggerPixelMapped; +package com.minelittlepony.pony.data; public enum TailLengths implements ITriggerPixelMapped { diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java index 83ecd9a2..e1c42fca 100644 --- a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -2,11 +2,6 @@ package com.minelittlepony.pony.data; import java.awt.image.BufferedImage; -import com.minelittlepony.PonyGender; -import com.minelittlepony.PonyRace; -import com.minelittlepony.PonySize; -import com.minelittlepony.TailLengths; - public enum TriggerPixels { RACE(PonyRace.HUMAN, 0, 0), TAIL(TailLengths.FULL, 1, 0), diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java index c47061eb..f2fcb1ce 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java @@ -1,11 +1,11 @@ package com.minelittlepony.renderer.layer; -import com.minelittlepony.IPonyData; 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.ModelPlayerPony; +import com.minelittlepony.pony.data.IPonyData; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java index dece3cc2..925f929d 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java @@ -1,12 +1,12 @@ package com.minelittlepony.renderer.player; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.Pony; import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelPlayerPony; +import com.minelittlepony.pony.data.Pony; import com.minelittlepony.renderer.layer.LayerEntityOnPonyShoulder; import com.minelittlepony.renderer.layer.LayerHeldPonyItem; import com.minelittlepony.renderer.layer.LayerPonyArmor; From f151b31597cae6205db1427b4ddaf88e2e993333 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 16:40:47 +0200 Subject: [PATCH 14/96] Clean up armor/armour, clean up villager models, more package changes --- .../com/minelittlepony/MineLittlePony.java | 21 +- .../{gui => }/PonySettingPanel.java | 4 +- .../com/minelittlepony/ducks/IRenderPony.java | 4 +- .../hdskins/gui/RenderPonyModel.java | 10 +- .../minelittlepony/model/AbstractArmor.java | 15 - .../model/AbstractPonyModel.java | 16 +- .../minelittlepony/model/ModelMobPony.java | 46 +++ .../{PlayerModel.java => ModelWrapper.java} | 22 +- .../java/com/minelittlepony/model/PMAPI.java | 39 +- .../armor => armour}/ModelPonyArmor.java | 108 ++--- .../model/armour/ModelSkeletonPonyArmor.java | 23 ++ .../ModelZombiePonyArmor.java} | 18 +- .../model/armour/PonyArmor.java | 24 ++ .../HornGlow.java} | 9 +- .../model/components/ModelWing.java | 4 +- .../model/components/PegasusWings.java | 4 +- .../PonyElytra.java} | 8 +- .../model/components/PonySnout.java | 5 +- .../model/components/PonyTail.java | 37 +- .../model/components/UnicornHorn.java | 3 +- .../model/entity/ModelMobPony.java | 113 ----- .../model/{ => player}/PlayerModels.java | 9 +- .../model/{pony => ponies}/ModelBreezie.java | 2 +- .../{pony => ponies}/ModelHumanPlayer.java | 8 +- .../{pony => ponies}/ModelIllagerPony.java | 2 +- .../{pony => ponies}/ModelPlayerPony.java | 385 ++++++++---------- .../{pony => ponies}/ModelSkeletonPony.java | 11 +- .../model/ponies/ModelVillagerPony.java | 91 +++++ .../model/ponies/ModelZombiePony.java | 51 +++ .../model/{pony => ponies}/package-info.java | 2 +- .../model/pony/ModelVillagerPony.java | 117 ------ .../model/pony/armor/HumanArmors.java | 13 - .../pony/armor/ModelSkeletonPonyArmor.java | 95 ----- .../pony/armor/ModelZombiePonyArmor.java | 98 ----- .../model/pony/armor/PonyArmors.java | 11 - .../model/pony/armor/SkeletonPonyArmors.java | 11 - .../model/pony/armor/ZombiePonyArmors.java | 11 - .../model/pony/armor/package-info.java | 7 - .../com/minelittlepony/pony/data/Pony.java | 4 +- .../minelittlepony/pony/data/PonyRace.java | 2 +- .../BasePonyRenderer.java | 14 +- .../HornGlowRenderer.java | 7 +- .../{renderer => render}/RenderPonyMob.java | 18 +- .../layer/AbstractPonyLayer.java | 5 +- .../layer/LayerEntityOnPonyShoulder.java | 5 +- .../layer/LayerHeldPonyItem.java | 4 +- .../layer/LayerOverlayBase.java | 2 +- .../layer/LayerPonyArmor.java | 9 +- .../layer/LayerPonyCape.java | 7 +- .../layer/LayerPonyCustomHead.java | 8 +- .../layer/LayerPonyElytra.java | 7 +- .../layer/LayerPonyStrayOverlay.java | 5 +- .../layer}/package-info.java | 2 +- .../{gui => render}/package-info.java | 2 +- .../{renderer => render}/plane/Face.java | 2 +- .../plane/ModelPlane.java | 2 +- .../plane/PlaneRenderer.java | 4 +- .../player/RenderPonyBase.java | 26 +- .../player/RenderPonyPlayer.java | 6 +- .../ponies}/RenderPonyEvoker.java | 8 +- .../ponies}/RenderPonyIllusionIllager.java | 8 +- .../ponies}/RenderPonyPigman.java | 4 +- .../ponies}/RenderPonySkeleton.java | 6 +- .../ponies}/RenderPonyVex.java | 5 +- .../ponies}/RenderPonyVillager.java | 4 +- .../ponies}/RenderPonyVindicator.java | 8 +- .../ponies}/RenderPonyZombie.java | 3 +- .../ponies}/RenderPonyZombieVillager.java | 4 +- .../render/ponies/package-info.java | 8 + .../renderer/layer/package-info.java | 7 - 70 files changed, 709 insertions(+), 954 deletions(-) rename src/main/java/com/minelittlepony/{gui => }/PonySettingPanel.java (98%) delete mode 100644 src/main/java/com/minelittlepony/model/AbstractArmor.java create mode 100644 src/main/java/com/minelittlepony/model/ModelMobPony.java rename src/main/java/com/minelittlepony/model/{PlayerModel.java => ModelWrapper.java} (52%) rename src/main/java/com/minelittlepony/model/{pony/armor => armour}/ModelPonyArmor.java (70%) create mode 100644 src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java rename src/main/java/com/minelittlepony/model/{pony/ModelZombiePony.java => armour/ModelZombiePonyArmor.java} (77%) create mode 100644 src/main/java/com/minelittlepony/model/armour/PonyArmor.java rename src/main/java/com/minelittlepony/model/{ModelHornGlow.java => components/HornGlow.java} (92%) rename src/main/java/com/minelittlepony/model/{ModelPonyElytra.java => components/PonyElytra.java} (95%) delete mode 100644 src/main/java/com/minelittlepony/model/entity/ModelMobPony.java rename src/main/java/com/minelittlepony/model/{ => player}/PlayerModels.java (79%) rename src/main/java/com/minelittlepony/model/{pony => ponies}/ModelBreezie.java (99%) rename src/main/java/com/minelittlepony/model/{pony => ponies}/ModelHumanPlayer.java (69%) rename src/main/java/com/minelittlepony/model/{pony => ponies}/ModelIllagerPony.java (98%) rename src/main/java/com/minelittlepony/model/{pony => ponies}/ModelPlayerPony.java (71%) rename src/main/java/com/minelittlepony/model/{pony => ponies}/ModelSkeletonPony.java (86%) create mode 100644 src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java create mode 100644 src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java rename src/main/java/com/minelittlepony/model/{pony => ponies}/package-info.java (79%) delete mode 100644 src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/HumanArmors.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/PonyArmors.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/SkeletonPonyArmors.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/ZombiePonyArmors.java delete mode 100644 src/main/java/com/minelittlepony/model/pony/armor/package-info.java rename src/main/java/com/minelittlepony/{renderer => render}/BasePonyRenderer.java (82%) rename src/main/java/com/minelittlepony/{renderer => render}/HornGlowRenderer.java (80%) rename src/main/java/com/minelittlepony/{renderer => render}/RenderPonyMob.java (82%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/AbstractPonyLayer.java (94%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerEntityOnPonyShoulder.java (97%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerHeldPonyItem.java (98%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerOverlayBase.java (96%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerPonyArmor.java (98%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerPonyCape.java (95%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerPonyCustomHead.java (95%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerPonyElytra.java (94%) rename src/main/java/com/minelittlepony/{renderer => render}/layer/LayerPonyStrayOverlay.java (92%) rename src/main/java/com/minelittlepony/{renderer => render/layer}/package-info.java (79%) rename src/main/java/com/minelittlepony/{gui => render}/package-info.java (82%) rename src/main/java/com/minelittlepony/{renderer => render}/plane/Face.java (57%) rename src/main/java/com/minelittlepony/{renderer => render}/plane/ModelPlane.java (98%) rename src/main/java/com/minelittlepony/{renderer => render}/plane/PlaneRenderer.java (94%) rename src/main/java/com/minelittlepony/{renderer => render}/player/RenderPonyBase.java (87%) rename src/main/java/com/minelittlepony/{renderer => render}/player/RenderPonyPlayer.java (93%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyEvoker.java (89%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyIllusionIllager.java (93%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyPigman.java (87%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonySkeleton.java (94%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyVex.java (91%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyVillager.java (93%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyVindicator.java (89%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyZombie.java (95%) rename src/main/java/com/minelittlepony/{renderer => render/ponies}/RenderPonyZombieVillager.java (94%) create mode 100644 src/main/java/com/minelittlepony/render/ponies/package-info.java delete mode 100644 src/main/java/com/minelittlepony/renderer/layer/package-info.java diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index 326372bd..3f82fe79 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -1,21 +1,20 @@ package com.minelittlepony; import com.google.common.collect.Maps; -import com.minelittlepony.gui.PonySettingPanel; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; import com.minelittlepony.model.PMAPI; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyDataSerialzier; -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; -import com.minelittlepony.renderer.RenderPonyVillager; -import com.minelittlepony.renderer.RenderPonyVindicator; -import com.minelittlepony.renderer.RenderPonyZombie; -import com.minelittlepony.renderer.RenderPonyZombieVillager; -import com.minelittlepony.renderer.player.RenderPonyPlayer; +import com.minelittlepony.render.player.RenderPonyPlayer; +import com.minelittlepony.render.ponies.RenderPonyEvoker; +import com.minelittlepony.render.ponies.RenderPonyIllusionIllager; +import com.minelittlepony.render.ponies.RenderPonyPigman; +import com.minelittlepony.render.ponies.RenderPonySkeleton; +import com.minelittlepony.render.ponies.RenderPonyVex; +import com.minelittlepony.render.ponies.RenderPonyVillager; +import com.minelittlepony.render.ponies.RenderPonyVindicator; +import com.minelittlepony.render.ponies.RenderPonyZombie; +import com.minelittlepony.render.ponies.RenderPonyZombieVillager; import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.util.ModUtilities; import com.voxelmodpack.hdskins.HDSkinManager; diff --git a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java b/src/main/java/com/minelittlepony/PonySettingPanel.java similarity index 98% rename from src/main/java/com/minelittlepony/gui/PonySettingPanel.java rename to src/main/java/com/minelittlepony/PonySettingPanel.java index 217d1f44..e045b1a5 100644 --- a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/PonySettingPanel.java @@ -1,7 +1,5 @@ -package com.minelittlepony.gui; +package com.minelittlepony; -import com.minelittlepony.MineLittlePony; -import com.minelittlepony.PonyConfig; import com.minelittlepony.pony.data.PonyLevel; import com.mumfrey.liteloader.client.gui.GuiCheckbox; import com.mumfrey.liteloader.core.LiteLoader; diff --git a/src/main/java/com/minelittlepony/ducks/IRenderPony.java b/src/main/java/com/minelittlepony/ducks/IRenderPony.java index 4f9e4621..17ba01bf 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderPony.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderPony.java @@ -1,8 +1,8 @@ package com.minelittlepony.ducks; -import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.ModelWrapper; public interface IRenderPony { - PlayerModel getPlayerModel(); + ModelWrapper getPlayerModel(); } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 021f737b..a8b6387e 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -3,10 +3,10 @@ package com.minelittlepony.hdskins.gui; import com.minelittlepony.MineLittlePony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.ModelPonyElytra; -import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.model.components.PonyElytra; import com.minelittlepony.pony.data.Pony; -import com.minelittlepony.renderer.layer.AbstractPonyLayer; +import com.minelittlepony.render.layer.AbstractPonyLayer; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.renderer.GlStateManager; @@ -33,7 +33,7 @@ public class RenderPonyModel extends RenderPlayerModel { Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId()); - PlayerModel pm = thePony.getModel(true); + ModelWrapper pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); return pm.getModel(); @@ -42,7 +42,7 @@ public class RenderPonyModel extends RenderPlayerModel { @Override protected LayerRenderer getElytraLayer() { final LayerRenderer elytra = super.getElytraLayer(); - final ModelPonyElytra modelElytra = new ModelPonyElytra(); + final PonyElytra modelElytra = new PonyElytra(); return new AbstractPonyLayer(this, elytra) { @Override diff --git a/src/main/java/com/minelittlepony/model/AbstractArmor.java b/src/main/java/com/minelittlepony/model/AbstractArmor.java deleted file mode 100644 index aed2b388..00000000 --- a/src/main/java/com/minelittlepony/model/AbstractArmor.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.pony.data.IPonyData; - -public abstract class AbstractArmor { - - public AbstractPonyModel modelArmorChestplate; - public AbstractPonyModel modelArmor; - - public void apply(IPonyData meta) { - modelArmorChestplate.metadata = meta; - modelArmor.metadata = meta; - } - -} diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index cd67a436..63d8c2ac 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,6 +1,7 @@ package com.minelittlepony.model; -import com.minelittlepony.model.pony.ModelPlayerPony; +import com.minelittlepony.model.armour.PonyArmor; +import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyData; import com.minelittlepony.pony.data.PonySize; @@ -44,7 +45,9 @@ public abstract class AbstractPonyModel extends ModelPlayer { this.initTextures(); this.initPositions(yOffset, stretch); } - + + public abstract PonyArmor createArmour(); + protected abstract void initTextures(); protected abstract void initPositions(float yOffset, float stretch); @@ -75,6 +78,15 @@ public abstract class AbstractPonyModel extends ModelPlayer { aRenderer.rotationPointY += shiftY; aRenderer.rotationPointZ += shiftZ; } + + protected static void rotateArmHolding(ModelRenderer arm, float direction, float var8, float var9, float tick) { + arm.rotateAngleZ = 0.0F; + arm.rotateAngleY = direction * (0.1F - var8 * 0.6F); + arm.rotateAngleX = -1.5707964F; + arm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; + arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; + } public void transform(BodyPart part) { if (this.isRiding) { diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java new file mode 100644 index 00000000..3652cb6d --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -0,0 +1,46 @@ +package com.minelittlepony.model; + +import com.minelittlepony.model.ponies.ModelPlayerPony; + +import net.minecraft.entity.Entity; +import net.minecraft.util.math.MathHelper; + +public class ModelMobPony extends ModelPlayerPony { + + public ModelMobPony() { + super(false); + } + + @Override + protected void rotateLegs(float move, float swing, float tick, Entity entity) { + super.rotateLegs(move, swing, tick, entity); + + float var8 = MathHelper.sin(swingProgress * (float)Math.PI); + float var9 = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); + + rotateRightArm(var8, var9, move, tick); + rotateLeftArm(var8, var9, move, tick); + } + + protected void rotateRightArm(float var8, float var9, float move, float tick) { + if (this.rightArmPose == ArmPose.EMPTY) return; + + if (!metadata.hasMagic()) { + rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + } else { + unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmRight, 1, var8, var9, tick); + } + } + + protected void rotateLeftArm(float var8, float var9, float move, float tick) { + if (leftArmPose == ArmPose.EMPTY) return; + + if (!metadata.hasMagic()) { + rotateArmHolding(bipedLeftArm, 1, var8, var9, tick); + } else { + unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmLeft, 1, var8, var9, tick); + } + } +} diff --git a/src/main/java/com/minelittlepony/model/PlayerModel.java b/src/main/java/com/minelittlepony/model/ModelWrapper.java similarity index 52% rename from src/main/java/com/minelittlepony/model/PlayerModel.java rename to src/main/java/com/minelittlepony/model/ModelWrapper.java index 9a9e5dee..a56d83e8 100644 --- a/src/main/java/com/minelittlepony/model/PlayerModel.java +++ b/src/main/java/com/minelittlepony/model/ModelWrapper.java @@ -1,33 +1,29 @@ package com.minelittlepony.model; +import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.pony.data.IPonyData; -public class PlayerModel { +public class ModelWrapper { private final AbstractPonyModel model; - private AbstractArmor armor; + private final PonyArmor armor; - public PlayerModel(AbstractPonyModel model) { + public ModelWrapper(AbstractPonyModel model) { this.model = model; + this.armor = model.createArmour(); + this.armor.apply(model.metadata); } public AbstractPonyModel getModel() { return model; } - public PlayerModel setArmor(AbstractArmor armor) { - this.armor = armor; - this.armor.apply(model.metadata); - return this; - } - public void init() { - getModel().init(0, 0); - getArmor().modelArmorChestplate.init(0.0F, 1.0F); - getArmor().modelArmor.init(0.0F, 0.5F); + model.init(0, 0); + armor.init(); } - public AbstractArmor getArmor() { + public PonyArmor getArmor() { return armor; } diff --git a/src/main/java/com/minelittlepony/model/PMAPI.java b/src/main/java/com/minelittlepony/model/PMAPI.java index 8022fd42..1523da86 100644 --- a/src/main/java/com/minelittlepony/model/PMAPI.java +++ b/src/main/java/com/minelittlepony/model/PMAPI.java @@ -1,35 +1,36 @@ package com.minelittlepony.model; -import com.minelittlepony.model.pony.ModelHumanPlayer; -import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.model.pony.ModelPlayerPony; -import com.minelittlepony.model.pony.ModelSkeletonPony; -import com.minelittlepony.model.pony.ModelVillagerPony; -import com.minelittlepony.model.pony.ModelZombiePony; -import com.minelittlepony.model.pony.armor.HumanArmors; -import com.minelittlepony.model.pony.armor.PonyArmors; -import com.minelittlepony.model.pony.armor.SkeletonPonyArmors; -import com.minelittlepony.model.pony.armor.ZombiePonyArmors; +import com.minelittlepony.model.ponies.ModelHumanPlayer; +import com.minelittlepony.model.ponies.ModelIllagerPony; +import com.minelittlepony.model.ponies.ModelPlayerPony; +import com.minelittlepony.model.ponies.ModelSkeletonPony; +import com.minelittlepony.model.ponies.ModelVillagerPony; +import com.minelittlepony.model.ponies.ModelZombiePony; import java.lang.reflect.Field; +/** + * PMAPI - Pony Models API? + * + */ public final class PMAPI { - public static final PlayerModel pony = new PlayerModel(new ModelPlayerPony(false)).setArmor(new PonyArmors()); - public static final PlayerModel ponySmall = new PlayerModel(new ModelPlayerPony(true)).setArmor(new PonyArmors()); + public static final ModelWrapper + pony = new ModelWrapper(new ModelPlayerPony(false)), + ponySmall = new ModelWrapper(new ModelPlayerPony(true)), - public static final PlayerModel human = new PlayerModel(new ModelHumanPlayer(false)).setArmor(new HumanArmors()); - public static final PlayerModel humanSmall = new PlayerModel(new ModelHumanPlayer(true)).setArmor(new HumanArmors()); + human = new ModelWrapper(new ModelHumanPlayer(false)), + humanSmall = new ModelWrapper(new ModelHumanPlayer(true)), - public static final PlayerModel zombie = new PlayerModel(new ModelZombiePony()).setArmor(new ZombiePonyArmors()); - public static final PlayerModel skeleton = new PlayerModel(new ModelSkeletonPony()).setArmor(new SkeletonPonyArmors()); - public static final PlayerModel villager = new PlayerModel(new ModelVillagerPony()).setArmor(new PonyArmors()); - public static final PlayerModel illager = new PlayerModel(new ModelIllagerPony()).setArmor(new PonyArmors()); + zombie = new ModelWrapper(new ModelZombiePony()), + skeleton = new ModelWrapper(new ModelSkeletonPony()), + villager = new ModelWrapper(new ModelVillagerPony()), + illager = new ModelWrapper(new ModelIllagerPony()); public static void init() { for (Field field : PMAPI.class.getFields()) { try { - PlayerModel model = (PlayerModel) field.get(null); + ModelWrapper model = (ModelWrapper) field.get(null); model.init(); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java similarity index 70% rename from src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java rename to src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index d6b9bdce..86118dd8 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -1,79 +1,30 @@ -package com.minelittlepony.model.pony.armor; +package com.minelittlepony.model.armour; -import com.minelittlepony.model.pony.ModelPlayerPony; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; -public class ModelPonyArmor extends ModelPlayerPony { +import com.minelittlepony.model.ModelMobPony; - public ModelRenderer Bodypiece; - public ModelRenderer extBody; - public ModelRenderer[] extHead; - public ModelRenderer[] extLegs; +public class ModelPonyArmor extends ModelMobPony { + + public ModelRenderer Bodypiece, extBody; + public ModelRenderer[] extHead, extLegs; public ModelPonyArmor() { - super(false); + super(); this.textureHeight = 32; } - + @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - - this.checkRainboom(entityIn, limbSwingAmount); - this.rotateHead(netHeadYaw, headPitch); - float bodySwingRotation = 0.0F; - if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; - } - - this.bipedBody.rotateAngleY = bodySwingRotation * 0.2F; - - this.setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn); - this.holdItem(limbSwingAmount); - this.swingItem(entityIn, this.swingProgress); - if (this.isSneak && !this.isFlying) { - this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); - this.sneakLegs(); - this.setHead(0.0F, 6.0F, -2.0F); - } else if (this.isRiding) { - - this.adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); - this.bipedLeftLeg.rotationPointZ = 15; - this.bipedLeftLeg.rotationPointY = 10; - this.bipedLeftLeg.rotateAngleX = (float) (Math.PI * -0.25); - this.bipedLeftLeg.rotateAngleY = (float) (Math.PI * -0.2); - - this.bipedRightLeg.rotationPointZ = 15; - this.bipedRightLeg.rotationPointY = 10; - this.bipedRightLeg.rotateAngleX = (float) (Math.PI * -0.25); - this.bipedRightLeg.rotateAngleY = (float) (Math.PI * 0.2); - - - this.bipedLeftArm.rotateAngleZ = (float) (Math.PI * -0.06); - this.bipedRightArm.rotateAngleZ = (float) (Math.PI * 0.06); - - } else { - - this.adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - - this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - this.swingArms(ageInTicks); - this.setHead(0.0F, 0.0F, 0.0F); - - } - - - if (this.isSleeping) { - this.ponySleep(); - } - - this.aimBow(leftArmPose, rightArmPose, ageInTicks); - - + protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { + this.bipedBody.rotateAngleY = bodySwing * 0.2F; + } + + @Override + protected void adjustBodyRiding() { + this.adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); } @Override @@ -102,9 +53,11 @@ public class ModelPonyArmor extends ModelPlayerPony { this.bipedBody.rotateAngleX = rotateAngleX; this.bipedBody.rotationPointY = rotationPointY; this.bipedBody.rotationPointZ = rotationPointZ; + this.Bodypiece.rotateAngleX = rotateAngleX; this.Bodypiece.rotationPointY = rotationPointY; this.Bodypiece.rotationPointZ = rotationPointZ; + this.extBody.rotateAngleX = rotateAngleX; this.extBody.rotationPointY = rotationPointY; this.extBody.rotationPointZ = rotationPointZ; @@ -194,32 +147,36 @@ public class ModelPonyArmor extends ModelPlayerPony { @Override protected void initHeadPositions(float yOffset, float stretch) { - this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch * 1.1F); - this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.bipedHead .addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch * 1.1F); + this.bipedHeadwear .addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch * 1.1F + 0.5F); + this.extHead[0].addBox(-4.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch * 0.5F); - this.extHead[0].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); this.extHead[1].addBox(2.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch * 0.5F); - this.extHead[1].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.bipedHeadwear.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch * 1.1F + 0.5F); - this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + + this.bipedHead .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.bipedHeadwear .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.extHead[0] .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.extHead[1] .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); } @Override protected void initBodyPositions(float yOffset, float stretch) { this.bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch); - this.bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); this.Bodypiece.addBox(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch); - this.Bodypiece.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); this.extBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 16, stretch); - this.extBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + + this.bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.Bodypiece.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + this.extBody .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); } @Override protected void initLegPositions(float yOffset, float stretch) { super.initLegPositions(yOffset, stretch); this.extLegs[0].addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); - this.extLegs[0].setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); this.extLegs[1].addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); + + this.extLegs[0].setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); this.extLegs[1].setRotationPoint(3.0F, 0.0F + yOffset, 0.0F); } @@ -227,12 +184,15 @@ public class ModelPonyArmor extends ModelPlayerPony { this.extLegs[0].rotateAngleX = this.bipedRightLeg.rotateAngleX; this.extLegs[0].rotateAngleY = this.bipedRightLeg.rotateAngleY; this.extLegs[0].rotateAngleZ = this.bipedRightLeg.rotateAngleZ; + this.extLegs[0].rotationPointX = this.bipedRightLeg.rotationPointX; this.extLegs[0].rotationPointY = this.bipedRightLeg.rotationPointY; this.extLegs[0].rotationPointZ = this.bipedRightLeg.rotationPointZ; + this.extLegs[1].rotateAngleX = this.bipedLeftLeg.rotateAngleX; this.extLegs[1].rotateAngleY = this.bipedLeftLeg.rotateAngleY; this.extLegs[1].rotateAngleZ = this.bipedLeftLeg.rotateAngleZ; + this.extLegs[1].rotationPointX = this.bipedLeftLeg.rotationPointX; this.extLegs[1].rotationPointY = this.bipedLeftLeg.rotationPointY; this.extLegs[1].rotationPointZ = this.bipedLeftLeg.rotationPointZ; diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java new file mode 100644 index 00000000..ba0584be --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -0,0 +1,23 @@ +package com.minelittlepony.model.armour; + +public class ModelSkeletonPonyArmor extends ModelPonyArmor { + + @Override + protected void rotateRightArm(float var8, float var9, float move, float tick) { + if (this.rightArmPose == ArmPose.EMPTY) return; + + if (!this.metadata.hasMagic()) { + rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + } else { + rotateArmHolding(unicornArmRight, 1, var8, var9, tick); + } + } + + @Override + protected void fixSpecialRotationPoints(float move) { + if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { + this.bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); + } + + } +} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java similarity index 77% rename from src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java rename to src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index 3076f192..b058dde2 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -1,22 +1,16 @@ -package com.minelittlepony.model.pony; +package com.minelittlepony.model.armour; import net.minecraft.util.math.MathHelper; -import com.minelittlepony.model.entity.ModelMobPony; - -public class ModelZombiePony extends ModelMobPony { - - public ModelZombiePony() { - super(); - } +public class ModelZombiePonyArmor extends ModelPonyArmor { private boolean isRight(float move) { - return MathHelper.sin(move / 20f) < 0f; + return MathHelper.sin(move / 20f) < 0; } @Override protected void rotateRightArm(float var8, float var9, float move, float tick) { - if (this.rightArmPose != ArmPose.EMPTY) return; + if (rightArmPose != ArmPose.EMPTY) return; if (isRight(move)) { rotateArmHolding(bipedRightArm, 1, var8, var9, tick); @@ -32,13 +26,11 @@ public class ModelZombiePony extends ModelMobPony { @Override protected void fixSpecialRotationPoints(float move) { - if (rightArmPose != ArmPose.EMPTY) return; - + if (this.rightArmPose != ArmPose.EMPTY) return; if (isRight(move)) { shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); } else { shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); } - } } diff --git a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java new file mode 100644 index 00000000..d5094257 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java @@ -0,0 +1,24 @@ +package com.minelittlepony.model.armour; + +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.pony.data.IPonyData; + +public class PonyArmor { + + public final AbstractPonyModel modelArmorChestplate, modelArmor; + + public PonyArmor(AbstractPonyModel chest, AbstractPonyModel body) { + this.modelArmorChestplate = chest; + this.modelArmor = body; + } + + public void apply(IPonyData meta) { + modelArmorChestplate.metadata = meta; + modelArmor.metadata = meta; + } + + public void init() { + modelArmorChestplate.init(0, 1); + modelArmor.init(0, 0.5f); + } +} diff --git a/src/main/java/com/minelittlepony/model/ModelHornGlow.java b/src/main/java/com/minelittlepony/model/components/HornGlow.java similarity index 92% rename from src/main/java/com/minelittlepony/model/ModelHornGlow.java rename to src/main/java/com/minelittlepony/model/components/HornGlow.java index ae2a19d2..287b61cf 100644 --- a/src/main/java/com/minelittlepony/model/ModelHornGlow.java +++ b/src/main/java/com/minelittlepony/model/components/HornGlow.java @@ -1,6 +1,5 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.components; -import com.minelittlepony.renderer.HornGlowRenderer; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; @@ -8,7 +7,9 @@ import net.minecraft.client.renderer.BufferBuilder; import javax.annotation.Nonnull; -public class ModelHornGlow extends ModelBox { +import com.minelittlepony.render.HornGlowRenderer; + +public class HornGlow extends ModelBox { private final float alpha; @@ -16,7 +17,7 @@ public class ModelHornGlow extends ModelBox { private TexturedQuad[] quadList; - public ModelHornGlow(HornGlowRenderer parent, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10, float alpha) { + public HornGlow(HornGlowRenderer parent, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10, float alpha) { super(parent, par2, par3, par4, par5, par6, par7, par8, par9, par10); this.parent = parent; this.alpha = alpha; diff --git a/src/main/java/com/minelittlepony/model/components/ModelWing.java b/src/main/java/com/minelittlepony/model/components/ModelWing.java index 95987e9b..c43d31f5 100644 --- a/src/main/java/com/minelittlepony/model/components/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/components/ModelWing.java @@ -1,11 +1,11 @@ package com.minelittlepony.model.components; -import com.minelittlepony.model.AbstractPonyModel; - import net.minecraft.client.model.ModelRenderer; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.model.AbstractPonyModel; + // TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box. public class ModelWing { public ModelRenderer[] folded = new ModelRenderer[3], diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index 58c739f4..655ed09c 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -1,13 +1,13 @@ package com.minelittlepony.model.components; -import com.minelittlepony.model.AbstractPonyModel; - import net.minecraft.client.model.ModelBase; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.model.AbstractPonyModel; + public class PegasusWings extends ModelBase { private final AbstractPonyModel pony; diff --git a/src/main/java/com/minelittlepony/model/ModelPonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java similarity index 95% rename from src/main/java/com/minelittlepony/model/ModelPonyElytra.java rename to src/main/java/com/minelittlepony/model/components/PonyElytra.java index b83c6560..5cf19541 100644 --- a/src/main/java/com/minelittlepony/model/ModelPonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -1,4 +1,6 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.components; + +import com.minelittlepony.model.PonyModelConstants; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBase; @@ -8,11 +10,11 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.Vec3d; -public class ModelPonyElytra extends ModelBase { +public class PonyElytra extends ModelBase { private ModelRenderer rightWing; private ModelRenderer leftWing = new ModelRenderer(this, 22, 0); - public ModelPonyElytra() { + public PonyElytra() { this.leftWing.addBox(-10.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F); this.rightWing = new ModelRenderer(this, 22, 0); this.rightWing.mirror = true; diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java index d3067f28..f3266838 100644 --- a/src/main/java/com/minelittlepony/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -1,11 +1,12 @@ package com.minelittlepony.model.components; -import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.pony.data.PonyGender; -import com.minelittlepony.renderer.plane.PlaneRenderer; +import com.minelittlepony.render.plane.PlaneRenderer; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.model.AbstractPonyModel; + public class PonySnout { private PlaneRenderer mare, stallion; diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 3796747a..36c321a0 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -1,21 +1,21 @@ package com.minelittlepony.model.components; -import com.minelittlepony.renderer.plane.PlaneRenderer; - import net.minecraft.client.model.ModelBase; import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.pony.data.TailLengths; +import com.minelittlepony.render.plane.PlaneRenderer; public class PonyTail extends PlaneRenderer { private final TailSegment[] segments = new TailSegment[4]; - private final ModelBase theModel; + private final AbstractPonyModel theModel; - public PonyTail(ModelBase model) { + public PonyTail(AbstractPonyModel model) { super(model); theModel = model; } @@ -25,6 +25,35 @@ public class PonyTail extends PlaneRenderer { addChild(segments[i] = new TailSegment(theModel, i, yOffset, stretch)); } } + + public void setRotationAndAngles(boolean rainboom, float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { + swingZ(rainboom, limbSwing, limbSwingAmount); + rotateAngleY = bodySwing; + + if (theModel.isSneak && !theModel.isFlying && !rainboom) { + rotateSneak(); + } else if (theModel.isRiding) { + rotationPointZ = 13; + rotationPointY = 3; + rotateAngleX = (float) (Math.PI * 0.2); + } else { + setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); + if (rainboom) { + rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(limbSwing); + } else { + rotateAngleX = 0.5F * limbSwingAmount; + } + + if (!rainboom) { + swingX(ticks); + } + } + + if (rainboom) { + rotationPointY += 6.0F; + rotationPointZ++; + } + } public void swingZ(boolean rainboom, float move, float swing) { rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2F * swing; diff --git a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java index 345aeb2e..0cf53555 100644 --- a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -1,7 +1,8 @@ package com.minelittlepony.model.components; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.renderer.HornGlowRenderer; +import com.minelittlepony.render.HornGlowRenderer; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/model/entity/ModelMobPony.java b/src/main/java/com/minelittlepony/model/entity/ModelMobPony.java deleted file mode 100644 index b75c7758..00000000 --- a/src/main/java/com/minelittlepony/model/entity/ModelMobPony.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.minelittlepony.model.entity; - -import static com.minelittlepony.model.PonyModelConstants.*; - -import com.minelittlepony.model.pony.ModelPlayerPony; - -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; - -public class ModelMobPony extends ModelPlayerPony { - - public ModelMobPony() { - super(false); - } - - @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float rightArmRotateAngleX; - float leftArmRotateAngleX; - float rightLegRotateAngleX; - float leftLegRotateAngleX; - - float var8; - float var9; - - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { - if (this.rainboom) { - rightArmRotateAngleX = ROTATE_270; - leftArmRotateAngleX = ROTATE_270; - rightLegRotateAngleX = ROTATE_90; - leftLegRotateAngleX = ROTATE_90; - } else { - rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); - leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); - } - - this.bipedRightArm.rotateAngleY = 0.2F; - this.steveRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.bipedRightLeg.rotateAngleY = -0.2F; - this.bipedLeftLeg.rotateAngleY = 0.2F; - } else { - var8 = (float) Math.pow(swing, 16.0D); - var9 = 3.1415927F * var8 * 0.5F; - float laQuad = 3.1415927F * var8; - float rlQuad = 3.1415927F * var8 * 0.2F; - float llQuad = 3.1415927F * var8 * -0.4F; - rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.6F * swing; - leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.6F * swing; - rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.6F * swing; - leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.6F * swing; - this.bipedRightArm.rotateAngleY = 0.0F; - this.steveRightArm.rotateAngleY = 0.0F; - this.unicornArmRight.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - } - - this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; - this.steveRightArm.rotateAngleX = rightArmRotateAngleX; - this.unicornArmRight.rotateAngleX = rightArmRotateAngleX; - this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; - this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; - this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.steveRightArm.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - - var8 = MathHelper.sin(this.swingProgress * (float)Math.PI); - var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); - - rotateRightArm(var8, var9, move, tick); - rotateLeftArm(var8, var9, move, tick); - } - - protected void rotateRightArm(float var8, float var9, float move, float tick) { - if (this.rightArmPose == ArmPose.EMPTY) return; - - if (!this.metadata.hasMagic()) { - rotateArmHolding(bipedRightArm, 1, var8, var9, tick); - } else { - this.unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmRight, 1, var8, var9, tick); - } - } - - protected static void rotateArmHolding(ModelRenderer arm, float direction, float var8, float var9, float tick) { - arm.rotateAngleZ = 0.0F; - arm.rotateAngleY = direction * (0.1F - var8 * 0.6F); - arm.rotateAngleX = -1.5707964F; - arm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } - - - protected void rotateLeftArm(float var8, float var9, float move, float tick) { - if (this.leftArmPose == ArmPose.EMPTY) return; - - if (!this.metadata.hasMagic()) { - rotateArmHolding(bipedLeftArm, 1, var8, var9, tick); - } else { - this.unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmLeft, 1, var8, var9, tick); - } - } -} diff --git a/src/main/java/com/minelittlepony/model/PlayerModels.java b/src/main/java/com/minelittlepony/model/player/PlayerModels.java similarity index 79% rename from src/main/java/com/minelittlepony/model/PlayerModels.java rename to src/main/java/com/minelittlepony/model/player/PlayerModels.java index 046da213..c325e482 100644 --- a/src/main/java/com/minelittlepony/model/PlayerModels.java +++ b/src/main/java/com/minelittlepony/model/player/PlayerModels.java @@ -1,4 +1,7 @@ -package com.minelittlepony.model; +package com.minelittlepony.model.player; + +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.model.ModelWrapper; public enum PlayerModels { HUMAN("default", "slim", () -> PMAPI.human, () -> PMAPI.humanSmall), @@ -16,7 +19,7 @@ public enum PlayerModels { this.slim = slim; } - public PlayerModel getModel(boolean slim) { + public ModelWrapper getModel(boolean slim) { return slim ? this.slim.resolve() : this.normal.resolve(); } @@ -28,6 +31,6 @@ public enum PlayerModels { * FIXME: PMAPI fields are null when the game starts. */ static interface ModelResolver { - PlayerModel resolve(); + ModelWrapper resolve(); } } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java similarity index 99% rename from src/main/java/com/minelittlepony/model/pony/ModelBreezie.java rename to src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java index 7ec7991e..805efc24 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java @@ -1,4 +1,4 @@ -package com.minelittlepony.model.pony; +package com.minelittlepony.model.ponies; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; diff --git a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java similarity index 69% rename from src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java rename to src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java index 957a1192..c9d27a4d 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java @@ -1,7 +1,8 @@ -package com.minelittlepony.model.pony; +package com.minelittlepony.model.ponies; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.armour.PonyArmor; public class ModelHumanPlayer extends AbstractPonyModel { @@ -27,4 +28,9 @@ public class ModelHumanPlayer extends AbstractPonyModel { protected void initPositions(float yOffset, float stretch) { } + + @Override + public PonyArmor createArmour() { + return new PonyArmor(new ModelHumanPlayer(false), new ModelHumanPlayer(false)); + } } diff --git a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java similarity index 98% rename from src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java rename to src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index 067880c7..d30b697d 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -1,4 +1,4 @@ -package com.minelittlepony.model.pony; +package com.minelittlepony.model.ponies; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java similarity index 71% rename from src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java rename to src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 3df92705..4f14ef1c 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -1,12 +1,14 @@ -package com.minelittlepony.model.pony; +package com.minelittlepony.model.ponies; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.armour.ModelPonyArmor; +import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.model.components.PegasusWings; import com.minelittlepony.model.components.PonySnout; import com.minelittlepony.model.components.PonyTail; import com.minelittlepony.model.components.UnicornHorn; -import com.minelittlepony.renderer.plane.PlaneRenderer; +import com.minelittlepony.render.plane.PlaneRenderer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; @@ -40,7 +42,13 @@ public class ModelPlayerPony extends AbstractPonyModel { super(smallArms); this.smallArms = smallArms; } + + @Override + public PonyArmor createArmour() { + return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); + } + @Override public void init(float yOffset, float stretch) { super.init(yOffset, stretch); snout = new PonySnout(this, yOffset, stretch); @@ -49,32 +57,19 @@ public class ModelPlayerPony extends AbstractPonyModel { } @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); this.rotateHead(netHeadYaw, headPitch); - this.Tail.swingZ(rainboom, limbSwing, limbSwingAmount); + float bodySwingRotation = 0.0F; if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } - this.bipedBody.rotateAngleY = bodySwingRotation * 0.2F; + rotateLook(limbSwing, limbSwingAmount, bodySwingRotation, ageInTicks); - int k1; - for (k1 = 0; k1 < this.Bodypiece.length; ++k1) { - this.Bodypiece[k1].rotateAngleY = bodySwingRotation * 0.2F; - } - - this.BodypieceNeck.rotateAngleY = bodySwingRotation * 0.2F; - this.Tail.rotateAngleY = bodySwingRotation; - - this.bipedHead.offsetY = 0f; - this.bipedHead.offsetZ = 0f; - this.bipedHeadwear.offsetY = 0f; - this.bipedHeadwear.offsetZ = 0f; this.setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn); this.holdItem(limbSwingAmount); this.swingItem(entityIn, this.swingProgress); @@ -82,12 +77,8 @@ public class ModelPlayerPony extends AbstractPonyModel { this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); this.sneakLegs(); this.setHead(0.0F, 6.0F, -2.0F); - this.Tail.rotateSneak(); } else if (this.isRiding) { - - this.adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); - this.adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - this.setHead(0.0F, 0.0F, 0.0F); + this.adjustBodyRiding(); this.bipedLeftLeg.rotationPointZ = 15; this.bipedLeftLeg.rotationPointY = 10; this.bipedLeftLeg.rotateAngleX = (float) (Math.PI * -0.25); @@ -100,10 +91,6 @@ public class ModelPlayerPony extends AbstractPonyModel { this.bipedLeftArm.rotateAngleZ = (float) (Math.PI * -0.06); this.bipedRightArm.rotateAngleZ = (float) (Math.PI * 0.06); - - Tail.rotationPointZ = 13; - Tail.rotationPointY = 3; - Tail.rotateAngleX = (float) (Math.PI * 0.2); } else { this.adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); @@ -112,24 +99,8 @@ public class ModelPlayerPony extends AbstractPonyModel { this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.swingArms(ageInTicks); this.setHead(0.0F, 0.0F, 0.0F); - - this.Tail.setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); - if (this.rainboom) { - this.Tail.rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(limbSwing); - } else { - this.Tail.rotateAngleX = 0.5F * limbSwingAmount; - } - - if (!this.rainboom) { - this.Tail.swingX(ageInTicks); - } } - - if (this.rainboom) { - this.Tail.rotationPointY += 6.0F; - this.Tail.rotationPointZ++; - } - + if (this.isSleeping) { this.ponySleep(); } @@ -146,6 +117,27 @@ public class ModelPlayerPony extends AbstractPonyModel { this.snout.setGender(this.metadata.getGender()); this.wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); } + + protected void adjustBodyRiding() { + this.adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); + this.adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); + this.setHead(0.0F, 0.0F, 0.0F); + } + + protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { + this.Tail.setRotationAndAngles(rainboom, limbSwing, limbSwingAmount, bodySwing, ticks); + + for (PlaneRenderer i : this.Bodypiece) { + i.rotateAngleY = bodySwing * 0.2F; + } + + this.bipedBody.rotateAngleY = bodySwing * 0.2F; + this.BodypieceNeck.rotateAngleY = bodySwing * 0.2F; + this.bipedHead.offsetY = 0f; + this.bipedHead.offsetZ = 0f; + this.bipedHeadwear.offsetY = 0f; + this.bipedHeadwear.offsetZ = 0f; + } private void animateWears() { copyModelAngles(bipedLeftArm, bipedLeftArmwear); @@ -192,162 +184,145 @@ public class ModelPlayerPony extends AbstractPonyModel { this.rotateLegs(move, swing, tick, entity); this.adjustLegs(); } + + public boolean isFlying(Entity entity) { + return (isFlying && metadata.getRace().hasWings()) || + (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()); + } protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float rightArmRotateAngleX; - float leftArmRotateAngleX; - float rightLegRotateAngleX; - float leftLegRotateAngleX; - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity) - .isElytraFlying()) { + float leftArm, rightArm, + leftLeg, rightLeg; + + + if (isFlying(entity)) { if (this.rainboom) { - rightArmRotateAngleX = ROTATE_270; - leftArmRotateAngleX = ROTATE_270; - rightLegRotateAngleX = ROTATE_90; - leftLegRotateAngleX = ROTATE_90; + rightArm = leftArm = ROTATE_270; + rightLeg = leftLeg = ROTATE_90; } else { - rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); - leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); + rightArm = leftArm = MathHelper.sin(-swing / 2); + rightLeg = leftLeg = MathHelper.sin(swing / 2); } - this.steveRightArm.rotateAngleY = 0.2F; - this.bipedRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.bipedRightLeg.rotateAngleY = -0.2F; + steveRightArm.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F; + bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; + this.bipedLeftLeg.rotateAngleY = 0.2F; } else { - float swag = (float) Math.pow(swing, 16.0D); - float raQuad = 3.1415927F * swag * 0.5F; - float laQuad = 3.1415927F * swag; - float rlQuad = 3.1415927F * swag * 0.2F; - float llQuad = 3.1415927F * swag * -0.4F; - rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + raQuad) * 0.45F * swing; - leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.45F * swing; - rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing; - leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.45F * swing; - this.steveRightArm.rotateAngleY = 0.0F; - this.unicornArmRight.rotateAngleY = 0.0F; - this.unicornArmLeft.rotateAngleY = 0.0F; + float PI = (float)Math.PI; + float pi = PI * (float) Math.pow(swing, 16); + + float mve = move * 0.6662F; // magic number ahoy + float srt = swing / 4; + + leftArm = MathHelper.cos(mve + pi) * srt; + rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; + + leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; + rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; + + this.steveRightArm.rotateAngleY = 0; + this.unicornArmRight.rotateAngleY = 0; + this.unicornArmLeft.rotateAngleY = 0; - this.bipedRightArm.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; + this.bipedRightArm.rotateAngleY = 0; + this.bipedLeftArm.rotateAngleY = 0; + this.bipedRightLeg.rotateAngleY = 0; + this.bipedLeftLeg.rotateAngleY = 0; } - this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; - this.steveRightArm.rotateAngleX = rightArmRotateAngleX; - this.unicornArmRight.rotateAngleX = 0.0F; - this.unicornArmLeft.rotateAngleX = 0.0F; + this.bipedRightArm.rotateAngleX = rightArm; + this.steveRightArm.rotateAngleX = rightArm; + this.unicornArmRight.rotateAngleX = 0; + this.unicornArmLeft.rotateAngleX = 0; - this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; - this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; - this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; - this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleX = leftArm; + this.bipedRightLeg.rotateAngleX = rightLeg; + this.bipedLeftLeg.rotateAngleX = leftLeg; + + this.bipedRightArm.rotateAngleZ = 0; - this.steveRightArm.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.unicornArmLeft.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; + this.steveRightArm.rotateAngleZ = 0; + this.unicornArmRight.rotateAngleZ = 0; + this.unicornArmLeft.rotateAngleZ = 0; + this.bipedLeftArm.rotateAngleZ = 0; + } + + private float getLegOutset() { + if (isSleeping) return 2.6f; + if (isSneak && !isFlying) return smallArms ? 1 : 0; + return 4; } protected void adjustLegs() { - float sinBodyRotateAngleYFactor = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; - float cosBodyRotateAngleYFactor = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; - float legOutset = 4.0F; - if (this.isSneak && !this.isFlying) { - legOutset = smallArms ? 1.0F : 0F; - } + float sinBodyRotateAngleYFactor = MathHelper.sin(this.bipedBody.rotateAngleY) * 5; + float cosBodyRotateAngleYFactor = MathHelper.cos(this.bipedBody.rotateAngleY) * 5; + + + float legOutset = getLegOutset(); + float spread = rainboom ? 2 : 1; - if (this.isSleeping) { - legOutset = 2.6F; - } + this.bipedRightArm.rotationPointZ = spread + sinBodyRotateAngleYFactor; + this.steveRightArm.rotationPointZ = spread + sinBodyRotateAngleYFactor; + this.bipedLeftArm.rotationPointZ = spread - sinBodyRotateAngleYFactor; + this.steveRightArm.rotationPointX = -cosBodyRotateAngleYFactor; - if (this.rainboom) { - this.bipedRightArm.rotationPointZ = sinBodyRotateAngleYFactor + 2.0F; - this.steveRightArm.rotationPointZ = sinBodyRotateAngleYFactor + 2.0F; - this.bipedLeftArm.rotationPointZ = 0.0F - sinBodyRotateAngleYFactor + 2.0F; - } else { - this.bipedRightArm.rotationPointZ = sinBodyRotateAngleYFactor + 1.0F; - this.steveRightArm.rotationPointZ = sinBodyRotateAngleYFactor + 1.0F; - this.bipedLeftArm.rotationPointZ = 0.0F - sinBodyRotateAngleYFactor + 1.0F; - } - this.steveRightArm.rotationPointX = 0.0F - cosBodyRotateAngleYFactor; + float rpxl = legOutset - cosBodyRotateAngleYFactor - 1; + float rpxr = cosBodyRotateAngleYFactor + 2 - legOutset; + + bipedRightArm.rotationPointX = bipedRightLeg.rotationPointX = rpxl; + bipedLeftArm.rotationPointX = bipedLeftLeg.rotationPointX = rpxr; - this.bipedRightArm.rotationPointX = 0.0F - cosBodyRotateAngleYFactor - 1.0F + legOutset; - this.bipedLeftArm.rotationPointX = cosBodyRotateAngleYFactor + 2.0F - legOutset; - this.bipedRightLeg.rotationPointX = 0.0F - cosBodyRotateAngleYFactor - 1.0F + legOutset; - this.bipedLeftLeg.rotationPointX = cosBodyRotateAngleYFactor + 1.0F - legOutset; + bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; + bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; - this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; - this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; //noinspection SuspiciousNameCombination this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; - this.bipedRightArm.rotationPointY = 8.0F; - this.bipedLeftArm.rotationPointY = 8.0F; - this.bipedRightLeg.rotationPointZ = 10.0F; - this.bipedLeftLeg.rotationPointZ = 10.0F; + bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; + bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; } - @SuppressWarnings("incomplete-switch") + protected void holdItem(float swing) { if (!this.rainboom && !this.metadata.hasMagic()) { boolean bothHoovesAreOccupied = this.leftArmPose == ArmPose.ITEM && this.rightArmPose == ArmPose.ITEM; - - switch (this.leftArmPose) { - case EMPTY: - this.bipedLeftArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedLeftArm.rotateAngleY = (float) (Math.PI / 6); - break; - case ITEM: - float swag = 1f; - if (!isFlying && bothHoovesAreOccupied) { - swag = (float) (1d - Math.pow(swing, 2d)); - } - float rotationMultiplier = 0.5f + 0.5f * (1f - swag); - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10F) * swag; - this.bipedLeftArm.rotateAngleY = 0.0F; - } - - switch (this.rightArmPose) { - case EMPTY: - this.bipedRightArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedRightArm.rotateAngleY = (float) (-Math.PI / 6); - break; - case ITEM: - float swag = 1f; - if (!isFlying && bothHoovesAreOccupied) { - swag = (float) (1d - Math.pow(swing, 2d)); - } - float rotationMultiplier = 0.5f + 0.5f * (1f - swag); - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10F) * swag; - this.bipedRightArm.rotateAngleY = 0.0F; - } - + alignArmForAction(bipedLeftArm, leftArmPose, bothHoovesAreOccupied, swing); + alignArmForAction(bipedRightArm, rightArmPose, bothHoovesAreOccupied, swing); } else if (this.metadata.hasMagic()) { - if (this.leftArmPose == ArmPose.BLOCK) { - this.unicornArmLeft.rotateAngleX = this.unicornArmLeft.rotateAngleX * 0.5F - 0.9424779F; - this.unicornArmLeft.rotateAngleY = (float) (Math.PI / 6); - } - if (this.rightArmPose == ArmPose.BLOCK) { - this.unicornArmRight.rotateAngleY = (float) (-Math.PI / 6); - this.unicornArmRight.rotateAngleX = this.unicornArmRight.rotateAngleX * 0.5F - 0.9424779F; - } + if (this.leftArmPose == ArmPose.BLOCK) blockArm(unicornArmLeft); + if (this.rightArmPose == ArmPose.BLOCK) blockArm(unicornArmRight); } this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); } + + @SuppressWarnings("incomplete-switch") + private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean bothHoovesAreOccupied, float swing) { + switch (pose) { + case ITEM: + float swag = 1; + if (!isFlying && bothHoovesAreOccupied) { + swag = (float) (1 - Math.pow(swing, 2)); + } + float rotationMultiplier = 0.5f + (1 - swag)/2; + arm.rotateAngleX = this.bipedLeftArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10) * swag; + case EMPTY: + arm.rotateAngleY = 0; + break; + case BLOCK: + arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; + arm.rotateAngleY = (float) (Math.PI / 6); + break; + } + } + + private void blockArm(ModelRenderer arm) { + arm.rotateAngleX = arm.rotateAngleX * 0.5F - 0.9424779F; + arm.rotateAngleY = (float) (Math.PI / 6); + } protected void swingItem(Entity entity, float swingProgress) { if (swingProgress > -9990.0F && !this.isSleeping) { @@ -357,59 +332,56 @@ public class ModelPlayerPony extends AbstractPonyModel { float f22 = MathHelper.sin(f16 * 3.1415927F); float f28 = MathHelper.sin(swingProgress * 3.1415927F); float f33 = f28 * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; + EnumHandSide mainSide = this.getMainHand(entity); + boolean mainRight = mainSide == EnumHandSide.RIGHT; ArmPose mainPose = mainRight ? this.rightArmPose : this.leftArmPose; + if (this.metadata.hasMagic() && mainPose != ArmPose.EMPTY) { - - ModelRenderer unicornarm = mainSide == EnumHandSide.LEFT ? this.unicornArmLeft : this.unicornArmRight; - - unicornarm.rotateAngleX = (float) (this.unicornArmRight.rotateAngleX - (f22 * 1.2D + f33)); - unicornarm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; - unicornarm.rotateAngleZ = f28 * -0.4F; + swingArm(mainRight ? this.unicornArmRight : this.unicornArmLeft, f22, f33, f28); } else { - ModelRenderer bipedArm = this.getArmForSide(mainSide); - ModelRenderer steveArm = mainRight ? this.steveRightArm : this.steveLeftArm; - bipedArm.rotateAngleX = (float) (bipedArm.rotateAngleX - (f22 * 1.2D + f33)); - bipedArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; - bipedArm.rotateAngleZ = f28 * -0.4F; - steveArm.rotateAngleX = (float) (steveArm.rotateAngleX - (f22 * 1.2D + f33)); - steveArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; - steveArm.rotateAngleZ = f28 * -0.4F; + swingArm(this.getArmForSide(mainSide), f22, f33, f28); + swingArm(mainRight ? this.steveRightArm : this.steveLeftArm, f22, f33, f28); } } - + } + + private void swingArm(ModelRenderer arm, float f22, float f33, float f28) { + arm.rotateAngleX = (float) (this.unicornArmRight.rotateAngleX - (f22 * 1.2D + f33)); + arm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; + arm.rotateAngleZ = f28 * -0.4F; } protected void swingArms(float tick) { + float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) { - float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; + if (this.metadata.hasMagic()) { this.unicornArmRight.rotateAngleZ += cosTickFactor; this.unicornArmRight.rotateAngleX += sinTickFactor; } else { this.bipedRightArm.rotateAngleZ += cosTickFactor; this.bipedRightArm.rotateAngleX += sinTickFactor; + this.steveRightArm.rotateAngleZ += cosTickFactor; this.steveRightArm.rotateAngleX += sinTickFactor; } } if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) { - float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; if (this.metadata.hasMagic()) { this.unicornArmLeft.rotateAngleZ += cosTickFactor; this.unicornArmLeft.rotateAngleX += sinTickFactor; } else { this.bipedLeftArm.rotateAngleZ += cosTickFactor; this.bipedLeftArm.rotateAngleX += sinTickFactor; + this.steveLeftArm.rotateAngleZ += cosTickFactor; this.steveLeftArm.rotateAngleX += sinTickFactor; } } - } protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { @@ -421,31 +393,29 @@ public class ModelPlayerPony extends AbstractPonyModel { this.bipedBody.rotateAngleX = rotateAngleX; this.bipedBody.rotationPointY = rotationPointY; this.bipedBody.rotationPointZ = rotationPointZ; - - int k3; - for (k3 = 0; k3 < this.Bodypiece.length; ++k3) { - this.Bodypiece[k3].rotateAngleX = rotateAngleX; - this.Bodypiece[k3].rotationPointY = rotationPointY; - this.Bodypiece[k3].rotationPointZ = rotationPointZ; + + for (PlaneRenderer i : Bodypiece) { + i.rotateAngleX = rotateAngleX; + i.rotationPointY = rotationPointY; + i.rotationPointZ = rotationPointZ; } } protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { - BodypieceNeck.rotateAngleX = NECK_ROT_X + rotateAngleX; - BodypieceNeck.rotationPointY = rotationPointY; - BodypieceNeck.rotationPointZ = rotationPointZ; + BodypieceNeck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); } protected void sneakLegs() { this.steveRightArm.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + this.unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; this.unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; this.bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; + + this.bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; - } protected void ponySleep() { @@ -453,17 +423,17 @@ public class ModelPlayerPony extends AbstractPonyModel { this.bipedLeftArm.rotateAngleX = ROTATE_270; this.bipedRightLeg.rotateAngleX = ROTATE_90; this.bipedLeftLeg.rotateAngleX = ROTATE_90; - float headPosX; - float headPosY; - float headPosZ; + + float headPosX, headPosY, headPosZ; + if (this.isSneak) { - headPosY = 2.0F; - headPosZ = -1.0F; - headPosX = 1.0F; + headPosY = 2; + headPosZ = -1; + headPosX = 1; } else { - headPosY = 2.0F; - headPosZ = 1.0F; - headPosX = 1.0F; + headPosY = 2; + headPosZ = 1; + headPosX = 1; } this.setHead(headPosX, headPosY, headPosZ); @@ -624,7 +594,6 @@ public class ModelPlayerPony extends AbstractPonyModel { this.Bodypiece[12] = new PlaneRenderer(this, 32, 0); this.Bodypiece[13] = new PlaneRenderer(this, 32, 0); - // neck this.BodypieceNeck = new PlaneRenderer(this, 0, 16); } @@ -698,8 +667,8 @@ public class ModelPlayerPony extends AbstractPonyModel { this.BodypieceNeck.addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck.addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -4.8F + BODY_CENTRE_Z, 4, 4, stretch); - this.BodypieceNeck.addWestPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck.addEastPlane(2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); + this.BodypieceNeck.addWestPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); this.BodypieceNeck.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); this.BodypieceNeck.rotateAngleX = NECK_ROT_X; @@ -745,8 +714,6 @@ public class ModelPlayerPony extends AbstractPonyModel { 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); } - - } @Override diff --git a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java similarity index 86% rename from src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java rename to src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index 13f91c19..a8fea8cc 100644 --- a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -1,8 +1,10 @@ -package com.minelittlepony.model.pony; +package com.minelittlepony.model.ponies; import static net.minecraft.client.renderer.GlStateManager.*; -import com.minelittlepony.model.entity.ModelMobPony; +import com.minelittlepony.model.ModelMobPony; +import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; +import com.minelittlepony.model.armour.PonyArmor; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.Entity; @@ -19,6 +21,11 @@ public class ModelSkeletonPony extends ModelMobPony { super(); } + @Override + public PonyArmor createArmour() { + return new PonyArmor(new ModelSkeletonPonyArmor(), new ModelSkeletonPonyArmor()); + } + public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { rightArmPose = ModelBiped.ArmPose.EMPTY; leftArmPose = ModelBiped.ArmPose.EMPTY; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java new file mode 100644 index 00000000..5000142c --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -0,0 +1,91 @@ +package com.minelittlepony.model.ponies; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.util.math.MathHelper; +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.render.plane.PlaneRenderer; + +public class ModelVillagerPony extends ModelPlayerPony { + + public PlaneRenderer bag, apron, trinket; + + public ModelVillagerPony() { + super(false); + } + + @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); + + float swing = 0; + if (swingProgress > -9990.0F && !metadata.hasMagic()) { + swing = MathHelper.sin(MathHelper.sqrt(swingProgress) * (float)Math.PI * 2) * 0.04f; + } + bag.rotateAngleY = swing; + apron.rotateAngleY = swing; + trinket.rotateAngleY = swing; + } + + @Override + protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + super.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + + if (entityIn instanceof EntityVillager) { + this.bipedBody.postRender(this.scale); + int profession = ((EntityVillager) entityIn).getProfession(); + if (profession < 2) { + bag.render(scale); + } else if (profession == 2) { + trinket.render(scale); + } else if (profession > 2) { + apron.render(scale); + } + } + } + + @Override + protected void initTextures() { + super.initTextures(); + bag = new PlaneRenderer(this, 56, 19).at(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z); + apron = new PlaneRenderer(this, 56, 16).at(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z); + trinket = new PlaneRenderer(this, 0, 3).at(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z); + } + + @Override + protected void initPositions(float yOffset, float stretch) { + super.initPositions(yOffset, stretch); + + bag.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + bag.setTextureOffset(56, 29); + bag.addWestPlane(-7, -5, -4, 6, 8, stretch); + bag.addWestPlane(-4, -5, -4, 6, 8, stretch); + bag.addWestPlane( 4, -5, -4, 6, 8, stretch); + bag.addWestPlane( 7, -5, -4, 6, 8, stretch); + + PlaneRenderer rotatedPieces = new PlaneRenderer(this, 56, 16); + rotatedPieces.rotateAngleY = 4.712389F; + bag.addChild(rotatedPieces); + + rotatedPieces.addTopPlane(2, -5, -2, 8, 3, stretch); + rotatedPieces.addTopPlane(2, -5, -13, 8, 3, stretch); + rotatedPieces.setTextureOffset(56, 22); + rotatedPieces.addBottomPlane(2, 1, -2, 8, 3, stretch); + + bag.setTextureOffset(56, 22); + bag.addBottomPlane(2, 1, -13, 8, 3, stretch); + bag.setTextureOffset(56, 25); + bag.addBackPlane(-7, -5, -4, 3, 6, stretch); + bag.addBackPlane( 4, -5, -4, 3, 6, stretch); + bag.setTextureOffset(59, 25); + bag.addBackPlane(-7, -5, 4, 3, 6, stretch); + bag.addBackPlane( 5, -5, 4, 3, 6, stretch); + bag.setTextureOffset(56, 31); + bag.addTopPlane(-4, -4.5F, -1, 8, 1, stretch); + bag.addTopPlane(-4, -4.5F, 0, 8, 1, stretch); + + apron.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z).addBackPlane(-4, -4, -9, 8, 10, stretch); + trinket.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z).addBackPlane(-2, -4, -9, 4, 5, stretch); + } +} diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java new file mode 100644 index 00000000..5656b0d7 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -0,0 +1,51 @@ +package com.minelittlepony.model.ponies; + +import com.minelittlepony.model.ModelMobPony; +import com.minelittlepony.model.armour.ModelZombiePonyArmor; +import com.minelittlepony.model.armour.PonyArmor; + +import net.minecraft.util.math.MathHelper; + +public class ModelZombiePony extends ModelMobPony { + + public ModelZombiePony() { + super(); + } + + @Override + public PonyArmor createArmour() { + return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor()); + } + + private boolean isRight(float move) { + return MathHelper.sin(move / 20f) < 0; + } + + @Override + protected void rotateRightArm(float var8, float var9, float move, float tick) { + if (rightArmPose != ArmPose.EMPTY) return; + + if (isRight(move)) { + rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + } else { + rotateArmHolding(bipedLeftArm, -1, var8, var9, tick); + } + } + + @Override + protected void rotateLeftArm(float var8, float var9, float move, float tick) { + + } + + @Override + protected void fixSpecialRotationPoints(float move) { + if (rightArmPose != ArmPose.EMPTY) return; + + if (isRight(move)) { + shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + } else { + shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + } + + } +} diff --git a/src/main/java/com/minelittlepony/model/pony/package-info.java b/src/main/java/com/minelittlepony/model/ponies/package-info.java similarity index 79% rename from src/main/java/com/minelittlepony/model/pony/package-info.java rename to src/main/java/com/minelittlepony/model/ponies/package-info.java index 5ea323a5..576187ce 100644 --- a/src/main/java/com/minelittlepony/model/pony/package-info.java +++ b/src/main/java/com/minelittlepony/model/ponies/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.model.pony; +package com.minelittlepony.model.ponies; import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java deleted file mode 100644 index 660124d2..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.minelittlepony.model.pony; - -import com.minelittlepony.renderer.plane.PlaneRenderer; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.util.math.MathHelper; -import static com.minelittlepony.model.PonyModelConstants.*; - -public class ModelVillagerPony extends ModelPlayerPony { - - public PlaneRenderer[] VillagerBagPiece; - public PlaneRenderer VillagerApron; - public PlaneRenderer VillagerTrinket; - - public ModelVillagerPony() { - super(false); - } - - @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); - - float bodySwingRotation = 0.0F; - if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; - } - for (PlaneRenderer aVillagerBagPiece : this.VillagerBagPiece) { - aVillagerBagPiece.rotateAngleY = bodySwingRotation * 0.2F; - } - - this.VillagerBagPiece[4].rotateAngleY += 4.712389F; - this.VillagerBagPiece[5].rotateAngleY += 4.712389F; - this.VillagerBagPiece[6].rotateAngleY += 4.712389F; - this.VillagerBagPiece[7].rotateAngleY += 4.712389F; - this.VillagerApron.rotateAngleY = bodySwingRotation * 0.2F; - this.VillagerTrinket.rotateAngleY = bodySwingRotation * 0.2F; - } - - @Override - protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - super.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - - if (entityIn instanceof EntityVillager) { - this.bipedBody.postRender(this.scale); - int profession = ((EntityVillager) entityIn).getProfession(); - if (profession < 2) { - for (PlaneRenderer aVillagerBagPiece : this.VillagerBagPiece) { - aVillagerBagPiece.render(this.scale); - } - } else if (profession == 2) { - this.VillagerTrinket.render(this.scale); - } else if (profession > 2) { - this.VillagerApron.render(this.scale); - } - } - } - - @Override - protected void initTextures() { - super.initTextures(); - this.VillagerBagPiece = new PlaneRenderer[14]; - this.VillagerBagPiece[0] = new PlaneRenderer(this, 56, 19); - this.VillagerBagPiece[1] = new PlaneRenderer(this, 56, 19); - this.VillagerBagPiece[2] = new PlaneRenderer(this, 56, 19); - this.VillagerBagPiece[3] = new PlaneRenderer(this, 56, 19); - this.VillagerBagPiece[4] = new PlaneRenderer(this, 56, 16); - this.VillagerBagPiece[5] = new PlaneRenderer(this, 56, 16); - this.VillagerBagPiece[6] = new PlaneRenderer(this, 56, 22); - this.VillagerBagPiece[7] = new PlaneRenderer(this, 56, 22); - this.VillagerBagPiece[8] = new PlaneRenderer(this, 56, 25); - this.VillagerBagPiece[9] = new PlaneRenderer(this, 56, 25); - this.VillagerBagPiece[10] = new PlaneRenderer(this, 59, 25); - this.VillagerBagPiece[11] = new PlaneRenderer(this, 59, 25); - this.VillagerBagPiece[12] = new PlaneRenderer(this, 56, 31); - this.VillagerBagPiece[13] = new PlaneRenderer(this, 56, 31); - this.VillagerApron = new PlaneRenderer(this, 56, 16); - this.VillagerTrinket = new PlaneRenderer(this, 0, 3); - } - - @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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, stretch); - this.VillagerTrinket.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/HumanArmors.java b/src/main/java/com/minelittlepony/model/pony/armor/HumanArmors.java deleted file mode 100644 index 07b9c6ff..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/HumanArmors.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import com.minelittlepony.model.AbstractArmor; -import com.minelittlepony.model.pony.ModelHumanPlayer; - -public class HumanArmors extends AbstractArmor { - - public HumanArmors() { - this.modelArmorChestplate = new ModelHumanPlayer(false); - this.modelArmor = new ModelHumanPlayer(false); - } - -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java deleted file mode 100644 index 46a4e29d..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; - -import static com.minelittlepony.model.PonyModelConstants.*; - -public class ModelSkeletonPonyArmor extends ModelPonyArmor { - - @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float rightArmRotateAngleX; - float leftArmRotateAngleX; - float rightLegRotateAngleX; - float leftLegRotateAngleX; - float var8; - float var9; - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { - if (this.rainboom) { - rightArmRotateAngleX = ROTATE_270; - leftArmRotateAngleX = ROTATE_270; - rightLegRotateAngleX = ROTATE_90; - leftLegRotateAngleX = ROTATE_90; - } else { - rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); - leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); - } - - this.bipedRightArm.rotateAngleY = 0.2F; - this.steveRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.bipedRightLeg.rotateAngleY = -0.2F; - this.bipedLeftLeg.rotateAngleY = 0.2F; - } else { - var8 = (float) Math.pow(swing, 16.0D); - var9 = 3.1415927F * var8 * 0.5F; - float laQuad = 3.1415927F * var8; - float rlQuad = 3.1415927F * var8 * 0.2F; - float llQuad = 3.1415927F * var8 * -0.4F; - rightArmRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + var9) * 0.6F * swing; - leftArmRotateAngleX = MathHelper.cos(move * 0.6662F + laQuad) * 0.6F * swing; - rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.6F * swing; - leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.6F * swing; - this.bipedRightArm.rotateAngleY = 0.0F; - this.steveRightArm.rotateAngleY = 0.0F; - this.unicornArmRight.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - } - - this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; - this.steveRightArm.rotateAngleX = rightArmRotateAngleX; - this.unicornArmRight.rotateAngleX = 0.0F; - this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; - this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; - this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.steveRightArm.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.rightArmPose != ArmPose.EMPTY) { - var8 = MathHelper.sin(this.swingProgress * 3.1415927F); - var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); - if (!this.metadata.hasMagic()) { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F; - this.bipedRightArm.rotateAngleX = -1.5707964F; - this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } else { - this.unicornArmRight.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleY = 0.1F - var8 * 0.6F; - this.unicornArmRight.rotateAngleX = -1.5707964F; - this.unicornArmRight.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.unicornArmRight.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.unicornArmRight.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } - } - - this.syncLegs(); - } - - @Override - protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { - this.bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); - } - - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java deleted file mode 100644 index 1657be66..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; -import static com.minelittlepony.model.PonyModelConstants.*; - -public class ModelZombiePonyArmor extends ModelPonyArmor { - - @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float rightArmRotateAngleX; - float leftArmRotateAngleX; - float rightLegRotateAngleX; - float leftLegRotateAngleX; - float var8; - float var9; - if (this.isFlying && this.metadata.getRace().hasWings() || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { - if (this.rainboom) { - rightArmRotateAngleX = ROTATE_270; - leftArmRotateAngleX = ROTATE_270; - rightLegRotateAngleX = ROTATE_90; - leftLegRotateAngleX = ROTATE_90; - } else { - rightArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - leftArmRotateAngleX = MathHelper.sin(0.0F - swing * 0.5F); - rightLegRotateAngleX = MathHelper.sin(swing * 0.5F); - leftLegRotateAngleX = MathHelper.sin(swing * 0.5F); - } - - this.bipedRightArm.rotateAngleY = 0.2F; - this.steveRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.bipedRightLeg.rotateAngleY = -0.2F; - this.bipedLeftLeg.rotateAngleY = 0.2F; - } else { - var8 = (float) Math.pow(swing, 16.0D); - var9 = 3.1415927F * var8 * 0.5F; - float laQuad = 3.1415927F * var8; - float rlQuad = 3.1415927F * var8 * 0.2F; - 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; - rightLegRotateAngleX = MathHelper.cos(move * 0.6662F + rlQuad) * 0.45F * swing; - leftLegRotateAngleX = MathHelper.cos(move * 0.6662F + 3.1415927F + llQuad) * 0.45F * swing; - this.bipedRightArm.rotateAngleY = 0.0F; - this.steveRightArm.rotateAngleY = 0.0F; - this.unicornArmRight.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - } - - this.bipedRightArm.rotateAngleX = rightArmRotateAngleX; - this.steveRightArm.rotateAngleX = rightArmRotateAngleX; - this.unicornArmRight.rotateAngleX = 0.0F; - this.bipedLeftArm.rotateAngleX = leftArmRotateAngleX; - this.bipedRightLeg.rotateAngleX = rightLegRotateAngleX; - this.bipedLeftLeg.rotateAngleX = leftLegRotateAngleX; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.steveRightArm.rotateAngleZ = 0.0F; - this.unicornArmRight.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.rightArmPose == ArmPose.EMPTY) { - var8 = MathHelper.sin(this.swingProgress * 3.1415927F); - var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); - if (MathHelper.sin(move / 20.0F) < 0.0F) { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = 0.1F - var8 * 0.6F; - this.bipedRightArm.rotateAngleX = -1.5707964F; - this.bipedRightArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } else { - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleY = -(0.1F - var8 * 0.6F); - this.bipedLeftArm.rotateAngleX = -1.5707964F; - this.bipedLeftArm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; - this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; - } - } - - this.syncLegs(); - } - - @Override - protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose == ArmPose.EMPTY) { - if (MathHelper.sin(move / 20.0F) < 0.0F) { - shiftRotationPoint(this.bipedRightArm, 0.5F, 1.5F, 3.0F); - } else { - shiftRotationPoint(this.bipedLeftArm, -0.5F, 1.5F, 3.0F); - } - } - - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/PonyArmors.java b/src/main/java/com/minelittlepony/model/pony/armor/PonyArmors.java deleted file mode 100644 index 48a5ba7e..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/PonyArmors.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import com.minelittlepony.model.AbstractArmor; - -public class PonyArmors extends AbstractArmor { - - public PonyArmors() { - this.modelArmorChestplate = new ModelPonyArmor(); - this.modelArmor = new ModelPonyArmor(); - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/SkeletonPonyArmors.java b/src/main/java/com/minelittlepony/model/pony/armor/SkeletonPonyArmors.java deleted file mode 100644 index 82b16793..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/SkeletonPonyArmors.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import com.minelittlepony.model.AbstractArmor; - -public class SkeletonPonyArmors extends AbstractArmor { - - public SkeletonPonyArmors() { - this.modelArmorChestplate = new ModelSkeletonPonyArmor(); - this.modelArmor = new ModelSkeletonPonyArmor(); - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/ZombiePonyArmors.java b/src/main/java/com/minelittlepony/model/pony/armor/ZombiePonyArmors.java deleted file mode 100644 index 2257aa4c..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/ZombiePonyArmors.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import com.minelittlepony.model.AbstractArmor; - -public class ZombiePonyArmors extends AbstractArmor { - - public ZombiePonyArmors() { - this.modelArmorChestplate = new ModelZombiePonyArmor(); - this.modelArmor = new ModelZombiePonyArmor(); - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/package-info.java b/src/main/java/com/minelittlepony/model/pony/armor/package-info.java deleted file mode 100644 index 63f362af..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package com.minelittlepony.model.pony.armor; - -import mcp.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index 1dde419c..364112a9 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -3,7 +3,7 @@ package com.minelittlepony.pony.data; import com.google.common.base.MoreObjects; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IDownloadImageData; -import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.ModelWrapper; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.ThreadDownloadImageETag; import net.minecraft.client.Minecraft; @@ -103,7 +103,7 @@ public class Pony { return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater() || player.isElytraFlying()); } - public PlayerModel getModel(boolean ignorePony) { + public ModelWrapper getModel(boolean ignorePony) { return getRace(ignorePony).getModel().getModel(smallArms); } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java index d47897c0..f7588831 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -1,6 +1,6 @@ package com.minelittlepony.pony.data; -import com.minelittlepony.model.PlayerModels; +import com.minelittlepony.model.player.PlayerModels; public enum PonyRace implements ITriggerPixelMapped { diff --git a/src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java similarity index 82% rename from src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java rename to src/main/java/com/minelittlepony/render/BasePonyRenderer.java index 0df82fb9..787d51ff 100644 --- a/src/main/java/com/minelittlepony/renderer/BasePonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java @@ -1,4 +1,4 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -28,7 +28,19 @@ public class BasePonyRenderer> extends ModelRender super.setTextureOffset(x, y); return (T) this; } + + public T at(float x, float y, float z) { + offsetX = x; + offsetY = y; + offsetZ = z; + return (T) this; + } + public T around(float x, float y, float z) { + setRotationPoint(x, y, z); + return (T) this; + } + @Override public T addBox(String partName, float offX, float offY, float offZ, int width, int height, int depth) { partName = boxName + "." + partName; diff --git a/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java similarity index 80% rename from src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java rename to src/main/java/com/minelittlepony/render/HornGlowRenderer.java index cd6cec19..33dd2626 100644 --- a/src/main/java/com/minelittlepony/renderer/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java @@ -1,8 +1,9 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render; import static net.minecraft.client.renderer.GlStateManager.color; -import com.minelittlepony.model.ModelHornGlow; +import com.minelittlepony.model.components.HornGlow; + import net.minecraft.client.model.ModelBase; public class HornGlowRenderer extends BasePonyRenderer { @@ -33,7 +34,7 @@ public class HornGlowRenderer extends BasePonyRenderer { @Override public void addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { - this.cubeList.add(new ModelHornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, a)); + this.cubeList.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, a)); } @Override diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java similarity index 82% rename from src/main/java/com/minelittlepony/renderer/RenderPonyMob.java rename to src/main/java/com/minelittlepony/render/RenderPonyMob.java index fbbabead..0292546c 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -1,12 +1,12 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render; import com.minelittlepony.MineLittlePony; 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.LayerPonyCustomHead; -import com.minelittlepony.renderer.layer.LayerPonyElytra; +import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerPonyArmor; +import com.minelittlepony.render.layer.LayerPonyCustomHead; +import com.minelittlepony.render.layer.LayerPonyElytra; import com.voxelmodpack.hdskins.HDSkinManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; @@ -18,9 +18,9 @@ import javax.annotation.OverridingMethodsMustInvokeSuper; public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { - protected PlayerModel playerModel; + protected ModelWrapper playerModel; - public RenderPonyMob(RenderManager renderManager, PlayerModel playerModel) { + public RenderPonyMob(RenderManager renderManager, ModelWrapper playerModel) { super(renderManager, playerModel.getModel(), 0.5F); this.playerModel = playerModel; @@ -66,7 +66,7 @@ public abstract class RenderPonyMob extends RenderLiving } @Override - public PlayerModel getPlayerModel() { + public ModelWrapper getPlayerModel() { return playerModel; } diff --git a/src/main/java/com/minelittlepony/renderer/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java similarity index 94% rename from src/main/java/com/minelittlepony/renderer/layer/AbstractPonyLayer.java rename to src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 733a4bba..43d3b875 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -1,6 +1,7 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; + +import com.minelittlepony.model.ponies.ModelHumanPlayer; -import com.minelittlepony.model.pony.ModelHumanPlayer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerRenderer; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java similarity index 97% rename from src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java rename to src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index 83a72b8b..87ce609f 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -1,8 +1,9 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; import com.minelittlepony.ForgeProxy; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.pony.ModelPlayerPony; +import com.minelittlepony.model.ponies.ModelPlayerPony; + import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java similarity index 98% rename from src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java rename to src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index f2fcb1ce..9d13d904 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -1,10 +1,10 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; 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.ModelPlayerPony; +import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.pony.data.IPonyData; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerOverlayBase.java b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java similarity index 96% rename from src/main/java/com/minelittlepony/renderer/layer/LayerOverlayBase.java rename to src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java index ec9422d6..456b65df 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerOverlayBase.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java @@ -1,4 +1,4 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java similarity index 98% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index f057dc88..1e85bfba 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -1,11 +1,12 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; import com.google.common.collect.Maps; import com.minelittlepony.ForgeProxy; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.pony.armor.ModelPonyArmor; +import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.model.armour.ModelPonyArmor; + import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -32,7 +33,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { private static final Map HUMAN_ARMORS = Maps.newHashMap(); private static final Map PONY_ARMORS = Maps.newHashMap(); - private PlayerModel pony; + private ModelWrapper pony; public LayerPonyArmor(RenderLivingBase renderer) { super(renderer, new LayerBipedArmor(renderer)); diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java similarity index 95% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index 0ea172a6..a8cd1b05 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -1,8 +1,9 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.ModelWrapper; + import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderPlayer; @@ -24,7 +25,7 @@ public class LayerPonyCape extends AbstractPonyLayer { @Override public void doPonyRender(@Nonnull AbstractClientPlayer clientPlayer, float p2, float p3, float ticks, float p5, float p6, float p7, float scale) { - PlayerModel model = ((IRenderPony) getRenderer()).getPlayerModel(); + ModelWrapper model = ((IRenderPony) getRenderer()).getPlayerModel(); if (clientPlayer.hasPlayerInfo() && !clientPlayer.isInvisible() && clientPlayer.isWearing(EnumPlayerModelParts.CAPE) && clientPlayer.getLocationCape() != null && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java similarity index 95% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 0d1e011c..82b78e7d 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -1,10 +1,10 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.pony.ModelPlayerPony; +import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.model.ponies.ModelPlayerPony; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; @@ -97,7 +97,7 @@ public class LayerPonyCustomHead implements LayerRenderer { } - private PlayerModel getModel() { + private ModelWrapper getModel() { return ((IRenderPony) renderer).getPlayerModel(); } diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java similarity index 94% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index bb68ff74..3b85d7d5 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -1,9 +1,10 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.ModelPonyElytra; +import com.minelittlepony.model.components.PonyElytra; + import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLivingBase; @@ -21,7 +22,7 @@ import javax.annotation.Nonnull; public class LayerPonyElytra extends AbstractPonyLayer { private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); - private ModelPonyElytra modelElytra = new ModelPonyElytra(); + private PonyElytra modelElytra = new PonyElytra(); public LayerPonyElytra(RenderLivingBase rp) { super(rp, new LayerElytra(rp)); diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java similarity index 92% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java index afc39a40..88839f52 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java @@ -1,6 +1,7 @@ -package com.minelittlepony.renderer.layer; +package com.minelittlepony.render.layer; + +import com.minelittlepony.model.ponies.ModelSkeletonPony; -import com.minelittlepony.model.pony.ModelSkeletonPony; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.entity.monster.EntityStray; diff --git a/src/main/java/com/minelittlepony/renderer/package-info.java b/src/main/java/com/minelittlepony/render/layer/package-info.java similarity index 79% rename from src/main/java/com/minelittlepony/renderer/package-info.java rename to src/main/java/com/minelittlepony/render/layer/package-info.java index f99a8bdb..d6daad76 100644 --- a/src/main/java/com/minelittlepony/renderer/package-info.java +++ b/src/main/java/com/minelittlepony/render/layer/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.renderer; +package com.minelittlepony.render.layer; import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/gui/package-info.java b/src/main/java/com/minelittlepony/render/package-info.java similarity index 82% rename from src/main/java/com/minelittlepony/gui/package-info.java rename to src/main/java/com/minelittlepony/render/package-info.java index 4f7db50d..4e9d38ab 100644 --- a/src/main/java/com/minelittlepony/gui/package-info.java +++ b/src/main/java/com/minelittlepony/render/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.gui; +package com.minelittlepony.render; import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/renderer/plane/Face.java b/src/main/java/com/minelittlepony/render/plane/Face.java similarity index 57% rename from src/main/java/com/minelittlepony/renderer/plane/Face.java rename to src/main/java/com/minelittlepony/render/plane/Face.java index 98eb9b25..86149e82 100644 --- a/src/main/java/com/minelittlepony/renderer/plane/Face.java +++ b/src/main/java/com/minelittlepony/render/plane/Face.java @@ -1,4 +1,4 @@ -package com.minelittlepony.renderer.plane; +package com.minelittlepony.render.plane; enum Face { WEST, EAST, diff --git a/src/main/java/com/minelittlepony/renderer/plane/ModelPlane.java b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java similarity index 98% rename from src/main/java/com/minelittlepony/renderer/plane/ModelPlane.java rename to src/main/java/com/minelittlepony/render/plane/ModelPlane.java index 7592da53..33695541 100644 --- a/src/main/java/com/minelittlepony/renderer/plane/ModelPlane.java +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -1,4 +1,4 @@ -package com.minelittlepony.renderer.plane; +package com.minelittlepony.render.plane; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.PositionTextureVertex; diff --git a/src/main/java/com/minelittlepony/renderer/plane/PlaneRenderer.java b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java similarity index 94% rename from src/main/java/com/minelittlepony/renderer/plane/PlaneRenderer.java rename to src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java index 03f9eff9..cb5e54f9 100644 --- a/src/main/java/com/minelittlepony/renderer/plane/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java @@ -1,6 +1,6 @@ -package com.minelittlepony.renderer.plane; +package com.minelittlepony.render.plane; -import com.minelittlepony.renderer.BasePonyRenderer; +import com.minelittlepony.render.BasePonyRenderer; import net.minecraft.client.model.ModelBase; diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java similarity index 87% rename from src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java rename to src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index 925f929d..1048c957 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -1,18 +1,18 @@ -package com.minelittlepony.renderer.player; +package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.model.pony.ModelPlayerPony; +import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.pony.data.Pony; -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 com.minelittlepony.render.layer.LayerEntityOnPonyShoulder; +import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerPonyArmor; +import com.minelittlepony.render.layer.LayerPonyCape; +import com.minelittlepony.render.layer.LayerPonyCustomHead; +import com.minelittlepony.render.layer.LayerPonyElytra; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; @@ -25,13 +25,13 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony protected final boolean smallArms; - private PlayerModel playerModel; + private ModelWrapper playerModel; protected AbstractPonyModel ponyModel; private Pony pony; - public RenderPonyBase(RenderManager manager, boolean useSmallArms, String id, PlayerModel model) { + public RenderPonyBase(RenderManager manager, boolean useSmallArms, String id, ModelWrapper model) { super(manager, useSmallArms); smallArms = useSmallArms; @@ -126,11 +126,11 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony } @Override - public PlayerModel getPlayerModel() { + public ModelWrapper getPlayerModel() { return playerModel; } - protected void setPlayerModel(PlayerModel model) { + protected void setPlayerModel(ModelWrapper model) { playerModel = model; mainModel = ponyModel = playerModel.getModel(); } diff --git a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java similarity index 93% rename from src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java rename to src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 422f4f2f..ea72c1fc 100644 --- a/src/main/java/com/minelittlepony/renderer/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -1,15 +1,15 @@ -package com.minelittlepony.renderer.player; +package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IPonyAnimationHolder; -import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.ModelWrapper; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { - public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, PlayerModel model) { + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, ModelWrapper model) { super(renderManager, useSmallArms, id, model); } diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java similarity index 89% rename from src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java index 917461ee..71d47177 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java @@ -1,8 +1,10 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import com.minelittlepony.model.ponies.ModelIllagerPony; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerHeldPonyItem; + import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java similarity index 93% rename from src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java index 0029c415..8c45e138 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java @@ -1,8 +1,10 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import com.minelittlepony.model.ponies.ModelIllagerPony; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerHeldPonyItem; + import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyPigman.java similarity index 87% rename from src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyPigman.java index 6d9a45b0..ad972667 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyPigman.java @@ -1,6 +1,8 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; + import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java similarity index 94% rename from src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java index cca3441f..e83ecb53 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java @@ -1,7 +1,9 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; -import com.minelittlepony.renderer.layer.LayerPonyStrayOverlay; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerPonyStrayOverlay; + import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVex.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java similarity index 91% rename from src/main/java/com/minelittlepony/renderer/RenderPonyVex.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java index a3126bb3..0c95da70 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVex.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java @@ -1,6 +1,7 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; + +import com.minelittlepony.model.ponies.ModelBreezie; -import com.minelittlepony.model.pony.ModelBreezie; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.client.renderer.entity.RenderManager; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java similarity index 93% rename from src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java index 03554aae..52ed43c6 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java @@ -1,6 +1,8 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; + import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.passive.EntityVillager; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java similarity index 89% rename from src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java index 232c2991..814c0981 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java @@ -1,8 +1,10 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.renderer.layer.LayerHeldPonyItem; +import com.minelittlepony.model.ponies.ModelIllagerPony; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerHeldPonyItem; + import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java similarity index 95% rename from src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java index 87936155..3e7c144a 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java @@ -1,6 +1,7 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java similarity index 94% rename from src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java index f2abb3b5..e506a132 100644 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java @@ -1,6 +1,8 @@ -package com.minelittlepony.renderer; +package com.minelittlepony.render.ponies; import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; + import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/minelittlepony/render/ponies/package-info.java b/src/main/java/com/minelittlepony/render/ponies/package-info.java new file mode 100644 index 00000000..f9848ab7 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author Chris Albers + * + */ +package com.minelittlepony.render.ponies; \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/renderer/layer/package-info.java b/src/main/java/com/minelittlepony/renderer/layer/package-info.java deleted file mode 100644 index ff86e160..00000000 --- a/src/main/java/com/minelittlepony/renderer/layer/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package com.minelittlepony.renderer.layer; - -import mcp.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; From 9391c1d8c07924878e7f062cfb8b41c116edcc1f Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 21:29:49 +0200 Subject: [PATCH 15/96] Code stylee, documentation, fixed leg alignment --- .../java/com/minelittlepony/ForgeProxy.java | 30 ++- .../minelittlepony/LiteModMineLittlePony.java | 3 - .../com/minelittlepony/MineLittlePony.java | 185 ++++-------------- .../java/com/minelittlepony/PonyConfig.java | 15 ++ .../java/com/minelittlepony/PonyManager.java | 53 ++++- .../com/minelittlepony/PonyRenderManager.java | 142 ++++++++++++++ .../com/minelittlepony/PonySettingPanel.java | 5 +- .../ducks/IDownloadImageData.java | 3 + .../com/minelittlepony/ducks/IPlayerInfo.java | 9 + .../ducks/IPonyAnimationHolder.java | 7 + .../com/minelittlepony/ducks/IRenderItem.java | 3 + .../minelittlepony/ducks/IRenderManager.java | 5 + .../com/minelittlepony/ducks/IRenderPony.java | 6 + .../hdskins/gui/EntityPonyModel.java | 3 + .../hdskins/gui/GuiSkinsMineLP.java | 3 + .../hdskins/gui/RenderPonyModel.java | 3 + .../model/AbstractPonyModel.java | 68 +++++-- .../minelittlepony/model/ModelMobPony.java | 37 ++-- .../minelittlepony/model/ModelWrapper.java | 26 ++- .../model/armour/ModelPonyArmor.java | 10 +- .../model/armour/ModelSkeletonPonyArmor.java | 17 +- .../model/armour/ModelZombiePonyArmor.java | 8 +- .../model/ponies/ModelPlayerPony.java | 184 +++++++++-------- .../model/ponies/ModelSkeletonPony.java | 1 - .../model/ponies/ModelZombiePony.java | 8 +- .../minelittlepony/pony/data/IPonyData.java | 20 +- .../pony/data/ITriggerPixelMapped.java | 17 +- .../minelittlepony/pony/data/PonyData.java | 8 + .../minelittlepony/pony/data/PonyRace.java | 19 ++ .../pony/data/TriggerPixels.java | 14 ++ .../render/layer/LayerPonyStrayOverlay.java | 2 +- 31 files changed, 620 insertions(+), 294 deletions(-) create mode 100644 src/main/java/com/minelittlepony/PonyRenderManager.java diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java index a192c7b3..7c888acc 100644 --- a/src/main/java/com/minelittlepony/ForgeProxy.java +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -15,16 +15,40 @@ import javax.annotation.Nullable; import java.util.Optional; import java.util.function.Function; +/** + * Proxy class for accessing forge fields and methods. + */ public class ForgeProxy { - + + /** + * True if forge is present. + */ private static boolean forgeLoaded = ModUtilities.fmlIsPresent(); - public static String getArmorTexture(Entity entity, ItemStack armor, String def, EntityEquipmentSlot slot, @Nullable String type) { + /** + * Gets the mod armour texture for associated item and slot. + * + * @param entity The entity to get armour for. + * @param item The armour item + * @param def Default return value if no mods present + * @param slot The slot this armour piece is place in. + * @param type unknown + * @return + */ + public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) { if (forgeLoaded) - return ForgeHooksClient.getArmorTexture(entity, armor, def, slot, type); + return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type); return def; } + /** + * Gets the mod armour texture for associated item and slot. + * + * @param entity The entity to get armour for. + * @param item The armour item + * @param slot The slot this armour piece is place in. + * @param def Default return value if no mods present + */ public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) { if (forgeLoaded) return ForgeHooksClient.getArmorModel(entity, item, slot, def); diff --git a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java index bf40a70b..0a19818e 100644 --- a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java +++ b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java @@ -28,8 +28,6 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener { @Override public void init(File configPath) { this.mlp = new MineLittlePony(); - this.mlp.init(); - } @Override @@ -41,5 +39,4 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener { public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { this.mlp.onTick(minecraft, inGame); } - } diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index 3f82fe79..965d9139 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -1,93 +1,69 @@ package com.minelittlepony; -import com.google.common.collect.Maps; import com.minelittlepony.hdskins.gui.GuiSkinsMineLP; -import com.minelittlepony.model.PMAPI; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyDataSerialzier; -import com.minelittlepony.render.player.RenderPonyPlayer; -import com.minelittlepony.render.ponies.RenderPonyEvoker; -import com.minelittlepony.render.ponies.RenderPonyIllusionIllager; -import com.minelittlepony.render.ponies.RenderPonyPigman; -import com.minelittlepony.render.ponies.RenderPonySkeleton; -import com.minelittlepony.render.ponies.RenderPonyVex; -import com.minelittlepony.render.ponies.RenderPonyVillager; -import com.minelittlepony.render.ponies.RenderPonyVindicator; -import com.minelittlepony.render.ponies.RenderPonyZombie; -import com.minelittlepony.render.ponies.RenderPonyZombieVillager; import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.util.ModUtilities; import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.gui.GuiSkins; import com.voxelmodpack.hdskins.skins.SkinServer; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.data.MetadataSerializer; import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.Entity; -import net.minecraft.entity.monster.EntityEvoker; -import net.minecraft.entity.monster.EntityGiantZombie; -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; -import net.minecraft.entity.monster.EntityVex; -import net.minecraft.entity.monster.EntityVindicator; -import net.minecraft.entity.monster.EntityWitherSkeleton; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.monster.EntityZombieVillager; -import net.minecraft.entity.passive.EntityVillager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.input.Keyboard; -import java.util.Map; - +/** + * Static MineLittlePony singleton class. Everything's controlled from up here. + */ public class MineLittlePony { public static final Logger logger = LogManager.getLogger("MineLittlePony"); - public static final String MOD_NAME = "Mine Little Pony"; - public static final String MOD_VERSION = "@VERSION@"; + public static final String + MOD_NAME = "Mine Little Pony", + MOD_VERSION = "@VERSION@"; + + private static final String + SKIN_SERVER_URL = "minelpskins.voxelmodpack.com", + GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; - @SuppressWarnings("unused") - private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; - @SuppressWarnings("unused") - private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); private static MineLittlePony instance; - private PonyConfig config; - private PonyManager ponyManager; + private final PonyConfig config; + private final PonyManager ponyManager; - private Map, Render> renderMap = Maps.newHashMap(); + private final PonyRenderManager renderManager; MineLittlePony() { instance = this; - } - void init() { LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI); - this.config = new PonyConfig(); - this.ponyManager = new PonyManager(config); - + config = new PonyConfig(); + ponyManager = new PonyManager(config); + renderManager = new PonyRenderManager(); + LiteLoader.getInstance().registerExposable(config, null); IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); - irrm.registerReloadListener(this.ponyManager); + irrm.registerReloadListener(ponyManager); MetadataSerializer ms = Minecraft.getMinecraft().getResourcePackRepository().rprMetadataSerializer; ms.registerMetadataSectionType(new PonyDataSerialzier(), IPonyData.class); // This also makes it the default gateway server. - SkinServer.defaultServers.add("legacy:http://minelpskins.voxelmodpack.com;http://minelpskinmanager.voxelmodpack.com"); + SkinServer.defaultServers.add("legacy:" + SKIN_SERVER_URL + ";" + GATEWAY_URL); } + /** + * Called when the game is ready. + */ void postInit(Minecraft minecraft) { HDSkinManager manager = HDSkinManager.INSTANCE; @@ -97,104 +73,13 @@ public class MineLittlePony { // logger.info("Set MineLP skin server URL."); RenderManager rm = minecraft.getRenderManager(); - this.saveCurrentRenderers(rm); - //ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); - - this.initialisePlayerRenderers(rm); - this.initializeMobRenderers(rm); - - } - - private void saveCurrentRenderers(RenderManager rm) { - // villagers - saveRenderer(rm, EntityVillager.class); - saveRenderer(rm, EntityZombieVillager.class); - // zombies - saveRenderer(rm, EntityZombie.class); - saveRenderer(rm, EntityGiantZombie.class); - saveRenderer(rm, EntityHusk.class); - // pig zombie - saveRenderer(rm, EntityPigZombie.class); - // skeletons - saveRenderer(rm, EntitySkeleton.class); - saveRenderer(rm, EntityStray.class); - saveRenderer(rm, EntityWitherSkeleton.class); - // illagers - 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") - private Render getRenderer(Class cl) { - Render render = (Render) this.renderMap.get(cl); - if (render == null) throw new MissingRendererException(cl); - return render; - } - - public void initialisePlayerRenderers(RenderManager rm) { - new RenderPonyPlayer(rm, false, "pony", PMAPI.pony); - new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall); - } - - public void initializeMobRenderers(RenderManager rm) { - if (this.config.villagers) { - ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); - ModUtilities.addRenderer(EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); - logger.info("Villagers are now ponies."); - } else { - ModUtilities.addRenderer(EntityVillager.class, getRenderer(EntityVillager.class)); - ModUtilities.addRenderer(EntityZombieVillager.class, getRenderer(EntityZombieVillager.class)); - } - - if (this.config.zombies) { - ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie<>(rm)); - ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm)); - ModUtilities.addRenderer(EntityGiantZombie.class, new RenderPonyZombie.Giant(rm)); - logger.info("Zombies are now ponies."); - } else { - ModUtilities.addRenderer(EntityZombie.class, getRenderer(EntityZombie.class)); - ModUtilities.addRenderer(EntityHusk.class, getRenderer(EntityHusk.class)); - ModUtilities.addRenderer(EntityGiantZombie.class, getRenderer(EntityGiantZombie.class)); - } - - if (this.config.pigzombies) { - ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyPigman(rm)); - logger.info("Zombie pigmen are now ponies."); - } else { - ModUtilities.addRenderer(EntityPigZombie.class, getRenderer(EntityPigZombie.class)); - } - - if (this.config.skeletons) { - ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton<>(rm)); - ModUtilities.addRenderer(EntityStray.class, new RenderPonySkeleton.Stray(rm)); - ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); - logger.info("Skeletons are now ponies."); - } else { - ModUtilities.addRenderer(EntitySkeleton.class, getRenderer(EntitySkeleton.class)); - ModUtilities.addRenderer(EntityStray.class, getRenderer(EntityStray.class)); - ModUtilities.addRenderer(EntityWitherSkeleton.class, getRenderer(EntityWitherSkeleton.class)); - } - - if (this.config.illagers) { - ModUtilities.addRenderer(EntityVex.class, new RenderPonyVex(rm)); - ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm)); - ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm)); - 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)); - } + renderManager.initialisePlayerRenderers(rm); + renderManager.initializeMobRenderers(rm, config); } + /** + * Called on every update tick + */ void onTick(Minecraft minecraft, boolean inGame) { if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) { @@ -210,14 +95,30 @@ public class MineLittlePony { } + /** + * Gets the global MineLP instance. + */ public static MineLittlePony getInstance() { return instance; } + /** + * Gets the static pony manager instance. + */ public PonyManager getManager() { return ponyManager; } + + /** + * Gets the static pony render manager responsible for all entity renderers. + */ + public PonyRenderManager getRenderManager() { + return renderManager; + } + /** + * Gets the global MineLP client configuration. + */ public static PonyConfig getConfig() { return getInstance().config; } diff --git a/src/main/java/com/minelittlepony/PonyConfig.java b/src/main/java/com/minelittlepony/PonyConfig.java index ac76072a..9557ea61 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -6,6 +6,10 @@ import com.mumfrey.liteloader.modconfig.ConfigStrategy; import com.mumfrey.liteloader.modconfig.Exposable; import com.mumfrey.liteloader.modconfig.ExposableOptions; +/** + * Storage contained for MineLP client settings. + * + */ @ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned) public class PonyConfig implements Exposable { @@ -20,15 +24,26 @@ public class PonyConfig implements Exposable { @Expose public boolean skeletons = true; @Expose public boolean illagers = true; + /** + * Gets the current PonyLevel. That is the level of ponies you would like to see. + * @param ignorePony true to ignore whatever value the setting has. + */ public PonyLevel getPonyLevel(boolean ignorePony) { return ignorePony ? PonyLevel.BOTH : getPonyLevel(); } + /** + * Actually gets the pony level value. No option to ignore reality here. + */ public PonyLevel getPonyLevel() { if (ponylevel == null) ponylevel = PonyLevel.PONIES; return ponylevel; } + /** + * Sets the pony level. Want MOAR PONEHS? Well here you go. + * @param ponylevel + */ public void setPonyLevel(PonyLevel ponylevel) { this.ponylevel = ponylevel; } diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index bfddf206..3a32070e 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -24,15 +24,22 @@ import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; +/** + * The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin. + * + */ public class PonyManager implements IResourceManagerReloadListener { - public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"); - 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"); + public static final ResourceLocation + STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"), + ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"), + BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json"); private static final Gson GSON = new Gson(); + /** + * All currently loaded background ponies. + */ private List backgroundPonyList = Lists.newArrayList(); private PonyConfig config; @@ -46,16 +53,27 @@ public class PonyManager implements IResourceManagerReloadListener { initmodels(); } - public void initmodels() { + private void initmodels() { MineLittlePony.logger.info("Initializing models..."); PMAPI.init(); MineLittlePony.logger.info("Done initializing models."); } - public Pony getPony(ResourceLocation skinResourceLocation, boolean slim) { - return poniesCache.computeIfAbsent(skinResourceLocation, res -> new Pony(res, slim)); + /** + * Gets or creates a pony for the given skin resource and vanilla model type. + * + * @param resource A texture resource + */ + public Pony getPony(ResourceLocation resource, boolean slim) { + return poniesCache.computeIfAbsent(resource, res -> new Pony(res, slim)); } + /** + * Gets or creates a pony for the given player. + * Delegates to the background-ponies registry if no pony skins were available and client settings allows it. + * + * @param player the player + */ public Pony getPony(AbstractClientPlayer player) { Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms()); @@ -66,6 +84,16 @@ public class PonyManager implements IResourceManagerReloadListener { return pony; } + /** + * Gets or creates a pony for the given skin resource and entity id. + * + * Whether is has slim arms is determined by the id. + * + * Delegates to the background-ponies registry if no pony skins were available and client settings allows it. + * + * @param resource A texture resource + * @param uuid id of a player or entity + */ public Pony getPony(ResourceLocation resource, UUID uuid) { Pony pony = getPony(resource, isSlimSkin(uuid)); @@ -76,6 +104,11 @@ public class PonyManager implements IResourceManagerReloadListener { return pony; } + /** + * Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings. + * + * @param uuid id of a player or entity + */ public Pony getDefaultPony(UUID uuid) { if (config.getPonyLevel() != PonyLevel.PONIES) { return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid)); @@ -93,6 +126,9 @@ public class PonyManager implements IResourceManagerReloadListener { return getPony(backgroundPonyList.get(bgi), false); } + /** + * De-registers a pony from the cache. + */ public Pony removePony(ResourceLocation location) { return poniesCache.remove(location); } @@ -124,6 +160,9 @@ public class PonyManager implements IResourceManagerReloadListener { return isSlimSkin(uuid) ? ALEX : STEVE; } + /** + * Returns true if the given uuid is of a player would would use the ALEX skin type. + */ public static boolean isSlimSkin(UUID uuid) { return (uuid.hashCode() & 1) == 1; } diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java new file mode 100644 index 00000000..bb14bbbe --- /dev/null +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -0,0 +1,142 @@ +package com.minelittlepony; + +import java.util.Map; + +import com.google.common.collect.Maps; +import com.minelittlepony.hdskins.gui.EntityPonyModel; +import com.minelittlepony.hdskins.gui.RenderPonyModel; +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.player.RenderPonyPlayer; +import com.minelittlepony.render.ponies.RenderPonyEvoker; +import com.minelittlepony.render.ponies.RenderPonyIllusionIllager; +import com.minelittlepony.render.ponies.RenderPonyPigman; +import com.minelittlepony.render.ponies.RenderPonySkeleton; +import com.minelittlepony.render.ponies.RenderPonyVex; +import com.minelittlepony.render.ponies.RenderPonyVillager; +import com.minelittlepony.render.ponies.RenderPonyVindicator; +import com.minelittlepony.render.ponies.RenderPonyZombie; +import com.minelittlepony.render.ponies.RenderPonyZombieVillager; +import com.mumfrey.liteloader.util.ModUtilities; + +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityEvoker; +import net.minecraft.entity.monster.EntityGiantZombie; +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; +import net.minecraft.entity.monster.EntityVex; +import net.minecraft.entity.monster.EntityVindicator; +import net.minecraft.entity.monster.EntityWitherSkeleton; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.monster.EntityZombieVillager; +import net.minecraft.entity.passive.EntityVillager; + +/** + * Render manager responsible for replacing and restoring entity renderers when the client settings change. + * Old values of persisted internally. + */ +public class PonyRenderManager { + + private final Map, Render> renderMap = Maps.newHashMap(); + + public PonyRenderManager() { + + } + + /** + * Registers all new player skin types. (currently only pony and slimpony). + */ + public void initialisePlayerRenderers(RenderManager rm) { + // Preview on the select skin gui + ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); + + new RenderPonyPlayer(rm, false, "pony", PMAPI.pony); + new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall); + //TODO: Add skin types for each species? May require model break up. + } + + /** + * Registers all entity model replacements. (except for players). + */ + public void initializeMobRenderers(RenderManager rm, PonyConfig config) { + + if (config.villagers) { + pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm)); + pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); + MineLittlePony.logger.info("Villagers are now ponies."); + } else { + restoreRenderer(EntityVillager.class); + restoreRenderer(EntityZombieVillager.class); + } + + if (config.zombies) { + pushNewRenderer(rm, EntityZombie.class, new RenderPonyZombie<>(rm)); + pushNewRenderer(rm, EntityHusk.class, new RenderPonyZombie.Husk(rm)); + pushNewRenderer(rm, EntityGiantZombie.class, new RenderPonyZombie.Giant(rm)); + MineLittlePony.logger.info("Zombies are now ponies."); + } else { + restoreRenderer(EntityZombie.class); + restoreRenderer(EntityHusk.class); + restoreRenderer(EntityGiantZombie.class); + } + + if (config.pigzombies) { + pushNewRenderer(rm, EntityPigZombie.class, new RenderPonyPigman(rm)); + MineLittlePony.logger.info("Zombie pigmen are now ponies."); + } else { + restoreRenderer(EntityPigZombie.class); + } + + if (config.skeletons) { + pushNewRenderer(rm, EntitySkeleton.class, new RenderPonySkeleton<>(rm)); + pushNewRenderer(rm, EntityStray.class, new RenderPonySkeleton.Stray(rm)); + pushNewRenderer(rm, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); + MineLittlePony.logger.info("Skeletons are now ponies."); + } else { + restoreRenderer(EntitySkeleton.class); + restoreRenderer(EntityStray.class); + restoreRenderer(EntityWitherSkeleton.class); + } + + if (config.illagers) { + pushNewRenderer(rm, EntityVex.class, new RenderPonyVex(rm)); + pushNewRenderer(rm, EntityEvoker.class, new RenderPonyEvoker(rm)); + pushNewRenderer(rm, EntityVindicator.class, new RenderPonyVindicator(rm)); + pushNewRenderer(rm, EntityIllusionIllager.class, new RenderPonyIllusionIllager(rm)); + MineLittlePony.logger.info("Illagers are now ponies."); + } else { + restoreRenderer(EntityVex.class); + restoreRenderer(EntityEvoker.class); + restoreRenderer(EntityVindicator.class); + restoreRenderer(EntityIllusionIllager.class); + } + } + + /** + * Pushes a new renderer replacement storing the original internally. This change can be undone with {@link #restoreRenderer(Class)} + * @param manager The render manager + * @param type The type to replace + * @param renderer The replacement value + * @param The entity type + */ + public void pushNewRenderer(RenderManager manager, Class type, Render renderer) { + if (!renderMap.containsKey(type)) { + renderMap.put(type, manager.getEntityClassRenderObject(type)); + } + ModUtilities.addRenderer(type, renderer); + } + + /** + * Restores a renderer to its previous value. + */ + @SuppressWarnings("unchecked") + public void restoreRenderer(Class type) { + if (renderMap.containsKey(type)) { + ModUtilities.addRenderer(type, (Render)renderMap.get(type)); + } + } +} diff --git a/src/main/java/com/minelittlepony/PonySettingPanel.java b/src/main/java/com/minelittlepony/PonySettingPanel.java index e045b1a5..935f429e 100644 --- a/src/main/java/com/minelittlepony/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/PonySettingPanel.java @@ -9,6 +9,9 @@ import net.minecraft.client.resources.I18n; import java.io.IOException; +/** + * In-Game options menu. + */ public class PonySettingPanel extends GuiScreen { private static final String _PREFIX = "minelp.options."; @@ -175,6 +178,6 @@ public class PonySettingPanel extends GuiScreen { @Override public void onGuiClosed() { LiteLoader.getInstance().writeConfig(config); - MineLittlePony.getInstance().initializeMobRenderers(mc.getRenderManager()); + MineLittlePony.getInstance().getRenderManager().initializeMobRenderers(mc.getRenderManager(), config); } } diff --git a/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java b/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java index 313fa923..15a0b914 100644 --- a/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java +++ b/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java @@ -3,5 +3,8 @@ package com.minelittlepony.ducks; import java.awt.image.BufferedImage; public interface IDownloadImageData { + /** + * Gets the downloaded image data as a buffered image. + */ BufferedImage getBufferedImage(); } diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index f2d62f55..ef74e6ea 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -6,10 +6,19 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; public interface IPlayerInfo { + /** + * Gets the pony associated with this player. + */ Pony getPony(); + /** + * Returns true if the vanilla skin (the one returned by NetworkPlayerInfo.getSkinLocation) uses the ALEX model type. + */ boolean usesSlimArms(); + /** + * Gets the player info for the given player. + */ public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) { return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID()); } diff --git a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java index 4c9f7520..2351fca3 100644 --- a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java +++ b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java @@ -1,5 +1,12 @@ package com.minelittlepony.ducks; +/** + * Holding class for entities that support special pony animations used for the renderers. + */ public interface IPonyAnimationHolder { + + /** + * Updates and gets the amount this entity is strafing to each side. + */ float getStrafeAmount(float ticks); } diff --git a/src/main/java/com/minelittlepony/ducks/IRenderItem.java b/src/main/java/com/minelittlepony/ducks/IRenderItem.java index 4d1a0eec..ebd69469 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderItem.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderItem.java @@ -2,5 +2,8 @@ package com.minelittlepony.ducks; public interface IRenderItem { + /** + * Sets whether items should be rendered with transparency support. + */ void useTransparency(boolean use); } diff --git a/src/main/java/com/minelittlepony/ducks/IRenderManager.java b/src/main/java/com/minelittlepony/ducks/IRenderManager.java index f401e645..d48b127a 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderManager.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderManager.java @@ -3,5 +3,10 @@ package com.minelittlepony.ducks; import net.minecraft.client.renderer.entity.RenderPlayer; public interface IRenderManager { + /** + * Registers a new player model to the underlying skinMap object. + * @param key The key to identify it by. + * @param render The renderer to add. + */ void addPlayerSkin(String key, RenderPlayer render); } diff --git a/src/main/java/com/minelittlepony/ducks/IRenderPony.java b/src/main/java/com/minelittlepony/ducks/IRenderPony.java index 17ba01bf..8af9d081 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderPony.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderPony.java @@ -2,7 +2,13 @@ package com.minelittlepony.ducks; import com.minelittlepony.model.ModelWrapper; +/** + * I Render Pony now, oky? + */ public interface IRenderPony { + /** + * Gets the wrapped pony model for this renderer. + */ ModelWrapper getPlayerModel(); } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java index d16fc047..1c93e6f8 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java @@ -3,6 +3,9 @@ package com.minelittlepony.hdskins.gui; import com.mojang.authlib.GameProfile; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; +/** + * Dummy model used for the skin uploading screen. + */ public class EntityPonyModel extends EntityPlayerModel { public EntityPonyModel(GameProfile profile) { diff --git a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java index ad052db1..b45afce7 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -8,6 +8,9 @@ import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.GuiSkins; import net.minecraft.util.ResourceLocation; +/** + * Skin uploading GUI. Usually displayed over the main menu. + */ public class GuiSkinsMineLP extends GuiSkins { private PonyManager ponyManager; diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index a8b6387e..696c7726 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -18,6 +18,9 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +/** + * Renderer used for the dummy pony model when selecting a skin. + */ public class RenderPonyModel extends RenderPlayerModel { public RenderPonyModel(RenderManager renderer) { diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 63d8c2ac..1126bbed 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -29,27 +29,40 @@ public abstract class AbstractPonyModel extends ModelPlayer { public IPonyData metadata = new PonyData(); public float motionPitch; + @Deprecated // TODO: Why so many arms? - public ModelRenderer steveLeftArm, steveRightArm, - steveLeftArmwear, steveRightArmwear; + public ModelRenderer steveLeftArm; + public ModelRenderer steveRightArm; public AbstractPonyModel(boolean arms) { super(0, arms); this.steveLeftArm = this.bipedLeftArm; this.steveRightArm = this.bipedRightArm; - this.steveLeftArmwear = this.bipedLeftArmwear; - this.steveRightArmwear = this.bipedLeftArmwear; } + /** + * Sets up this model's initial values, like a constructor... + * @param yOffset YPosition for this model. Always 0. + * @param stretch Scaling factor for this model. Ranges above or below 0 (no change). + */ public void init(float yOffset, float stretch) { - this.initTextures(); + initTextures(); this.initPositions(yOffset, stretch); } + /** + * Returns a new pony armour to go with this model. Called on startup by a model wrapper. + */ public abstract PonyArmor createArmour(); + /** + * Loads texture values. + */ protected abstract void initTextures(); + /** + * Loads texture positions and boxes. Pretty much just finishes the job of initTextures. + */ protected abstract void initPositions(float yOffset, float stretch); @Override @@ -58,17 +71,19 @@ public abstract class AbstractPonyModel extends ModelPlayer { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); return; } - this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F; + + this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2 * limbSwingAmount * 0.5F; this.steveRightArm.rotateAngleY = 0; this.steveRightArm.rotateAngleZ = 0; - this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F; + + this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2 * limbSwingAmount * 0.5F; this.steveLeftArm.rotateAngleY = 0; this.steveLeftArm.rotateAngleZ = 0; - - copyModelAngles(steveRightArm, steveRightArmwear); - copyModelAngles(steveLeftArm, steveLeftArmwear); } + /** + * Returns true if the default minecraft handling should be used. + */ protected boolean doCancelRender() { return false; } @@ -79,15 +94,31 @@ public abstract class AbstractPonyModel extends ModelPlayer { aRenderer.rotationPointZ += shiftZ; } - protected static void rotateArmHolding(ModelRenderer arm, float direction, float var8, float var9, float tick) { + /** + * Rotates the provided arm to the correct orientation for holding an item. + * + * @param arm The arm to rotate + * @param direction Direction multiplier. 1 for right, -1 for left. + * @param swingProgress How far we are through the current swing + * @param tick Render partial ticks + */ + protected static void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { + float swing = MathHelper.sin(swingProgress * (float)Math.PI); + float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); + arm.rotateAngleZ = 0.0F; - arm.rotateAngleY = direction * (0.1F - var8 * 0.6F); + arm.rotateAngleY = direction * (0.1F - swing * 0.6F); arm.rotateAngleX = -1.5707964F; - arm.rotateAngleX -= var8 * 1.2F - var9 * 0.4F; + arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; } + /** + * Applies a transform particular to a certain body part. + * + * FIXME: Too long! Is there a better way to do this? + */ public void transform(BodyPart part) { if (this.isRiding) { translate(0.0F, -0.6F, -0.2F); @@ -221,15 +252,18 @@ public abstract class AbstractPonyModel extends ModelPlayer { } } + /** + * Copies this model's attributes from some other. + */ @Override public void setModelAttributes(ModelBase model) { super.setModelAttributes(model); if (model instanceof AbstractPonyModel) { AbstractPonyModel pony = (AbstractPonyModel) model; - this.isFlying = pony.isFlying; - this.isSleeping = pony.isSleeping; - this.metadata = pony.metadata; - this.motionPitch = pony.motionPitch; + isFlying = pony.isFlying; + isSleeping = pony.isSleeping; + metadata = pony.metadata; + motionPitch = pony.motionPitch; } } diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index 3652cb6d..5007762c 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -3,8 +3,11 @@ package com.minelittlepony.model; import com.minelittlepony.model.ponies.ModelPlayerPony; import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; +/** + * Common class for all humanoid (ponioid?) non-player enemies. + * + */ public class ModelMobPony extends ModelPlayerPony { public ModelMobPony() { @@ -15,32 +18,42 @@ public class ModelMobPony extends ModelPlayerPony { protected void rotateLegs(float move, float swing, float tick, Entity entity) { super.rotateLegs(move, swing, tick, entity); - float var8 = MathHelper.sin(swingProgress * (float)Math.PI); - float var9 = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); - - rotateRightArm(var8, var9, move, tick); - rotateLeftArm(var8, var9, move, tick); + rotateRightArm(move, tick); + rotateLeftArm(move, tick); } - protected void rotateRightArm(float var8, float var9, float move, float tick) { + /** + * Called to update the left arm's final rotation. + * Subclasses may replace it with their own implementations. + * + * @param move Limb swing amount. + * @param tick Render partial ticks. + */ + protected void rotateRightArm(float move, float tick) { if (this.rightArmPose == ArmPose.EMPTY) return; if (!metadata.hasMagic()) { - rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmRight, 1, var8, var9, tick); + rotateArmHolding(unicornArmRight, 1, swingProgress, tick); } } - protected void rotateLeftArm(float var8, float var9, float move, float tick) { + /** + * Same as rotateRightArm but for the left arm (duh). + * + * @param move Limb swing amount. + * @param tick Render partial ticks. + */ + protected void rotateLeftArm(float move, float tick) { if (leftArmPose == ArmPose.EMPTY) return; if (!metadata.hasMagic()) { - rotateArmHolding(bipedLeftArm, 1, var8, var9, tick); + rotateArmHolding(bipedLeftArm, 1, swingProgress, tick); } else { unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmLeft, 1, var8, var9, tick); + rotateArmHolding(unicornArmLeft, 1, swingProgress, tick); } } } diff --git a/src/main/java/com/minelittlepony/model/ModelWrapper.java b/src/main/java/com/minelittlepony/model/ModelWrapper.java index a56d83e8..ede02d2f 100644 --- a/src/main/java/com/minelittlepony/model/ModelWrapper.java +++ b/src/main/java/com/minelittlepony/model/ModelWrapper.java @@ -3,11 +3,17 @@ package com.minelittlepony.model; import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.pony.data.IPonyData; +/** + * Container class for the various models and their associated piece of armour. + */ public class ModelWrapper { private final AbstractPonyModel model; private final PonyArmor armor; + /** + * Created a new model wrapper to contain the given pony. + */ public ModelWrapper(AbstractPonyModel model) { this.model = model; this.armor = model.createArmour(); @@ -18,17 +24,27 @@ public class ModelWrapper { return model; } - public void init() { - model.init(0, 0); - armor.init(); - } - + /** + * Returns the contained armour model. + * @return + */ public PonyArmor getArmor() { return armor; } + /** + * Updates metadata values on this wrapper's armour and model. + */ public void apply(IPonyData meta) { model.metadata = meta; armor.apply(meta); } + + /** + * Called at startup to configure a model's needed components. + */ + public void init() { + model.init(0, 0); + armor.init(); + } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index 86118dd8..0d051057 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -125,14 +125,20 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void initLegTextures() { this.bipedRightArm = new ModelRenderer(this, 0, 16); + this.steveRightArm = new ModelRenderer(this, 0, 16); + this.bipedLeftArm = new ModelRenderer(this, 0, 16); this.bipedLeftArm.mirror = true; - this.bipedRightLeg = new ModelRenderer(this, 0, 16); + this.bipedLeftLeg = new ModelRenderer(this, 0, 16); this.bipedLeftLeg.mirror = true; - this.steveRightArm = new ModelRenderer(this, 0, 16); + + this.bipedRightLeg = new ModelRenderer(this, 0, 16); + + this.unicornArmRight = new ModelRenderer(this, 0, 16); this.unicornArmLeft = new ModelRenderer(this, 0, 16); + this.extLegs[0] = new ModelRenderer(this, 48, 8); this.extLegs[1] = new ModelRenderer(this, 48, 8); this.extLegs[1].mirror = true; diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java index ba0584be..5375ca2f 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -1,15 +1,26 @@ package com.minelittlepony.model.armour; +/** + * Armour for skeleton ponies. + * + */ public class ModelSkeletonPonyArmor extends ModelPonyArmor { + /** + * The code here is copied from ModelMobPony, all with but one line of difference. + */ @Override - protected void rotateRightArm(float var8, float var9, float move, float tick) { + protected void rotateRightArm(float move, float tick) { if (this.rightArmPose == ArmPose.EMPTY) return; if (!this.metadata.hasMagic()) { - rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { - rotateArmHolding(unicornArmRight, 1, var8, var9, tick); + // With everything that's happening in ModelPonyArmor, + // it's hard to tell if this is need or not. + // Testing will probably reveal all. + //unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmRight, 1, swingProgress, tick); } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index b058dde2..65caef48 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -9,18 +9,18 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { } @Override - protected void rotateRightArm(float var8, float var9, float move, float tick) { + protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; if (isRight(move)) { - rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { - rotateArmHolding(bipedLeftArm, -1, var8, var9, tick); + rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); } } @Override - protected void rotateLeftArm(float var8, float var9, float move, float tick) { + protected void rotateLeftArm(float move, float tick) { } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 4f14ef1c..e3a64742 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -222,31 +222,33 @@ public class ModelPlayerPony extends AbstractPonyModel { leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; - this.steveRightArm.rotateAngleY = 0; - this.unicornArmRight.rotateAngleY = 0; - this.unicornArmLeft.rotateAngleY = 0; - - this.bipedRightArm.rotateAngleY = 0; + this.steveRightArm.rotateAngleY = this.bipedRightArm.rotateAngleY = 0; + this.bipedLeftArm.rotateAngleY = 0; this.bipedRightLeg.rotateAngleY = 0; this.bipedLeftLeg.rotateAngleY = 0; + + this.unicornArmRight.rotateAngleY = 0; + this.unicornArmLeft.rotateAngleY = 0; } - this.bipedRightArm.rotateAngleX = rightArm; - this.steveRightArm.rotateAngleX = rightArm; + + + + + this.steveLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX = leftArm; + this.steveRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX = rightArm; + + this.bipedLeftArm.rotateAngleZ = 0; + this.steveRightArm.rotateAngleZ = this.bipedRightArm.rotateAngleZ = 0; + + this.bipedLeftLeg.rotateAngleX = leftLeg; + this.bipedRightLeg.rotateAngleX = rightLeg; + this.unicornArmRight.rotateAngleX = 0; this.unicornArmLeft.rotateAngleX = 0; - - this.bipedLeftArm.rotateAngleX = leftArm; - this.bipedRightLeg.rotateAngleX = rightLeg; - this.bipedLeftLeg.rotateAngleX = leftLeg; - - this.bipedRightArm.rotateAngleZ = 0; - - this.steveRightArm.rotateAngleZ = 0; this.unicornArmRight.rotateAngleZ = 0; this.unicornArmLeft.rotateAngleZ = 0; - this.bipedLeftArm.rotateAngleZ = 0; } private float getLegOutset() { @@ -256,30 +258,34 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void adjustLegs() { - float sinBodyRotateAngleYFactor = MathHelper.sin(this.bipedBody.rotateAngleY) * 5; - float cosBodyRotateAngleYFactor = MathHelper.cos(this.bipedBody.rotateAngleY) * 5; - - - float legOutset = getLegOutset(); + float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; + float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; + float spread = rainboom ? 2 : 1; - this.bipedRightArm.rotationPointZ = spread + sinBodyRotateAngleYFactor; - this.steveRightArm.rotationPointZ = spread + sinBodyRotateAngleYFactor; - this.bipedLeftArm.rotationPointZ = spread - sinBodyRotateAngleYFactor; - this.steveRightArm.rotationPointX = -cosBodyRotateAngleYFactor; + steveRightArm.rotationPointZ = bipedRightArm.rotationPointZ = spread + sin; - float rpxl = legOutset - cosBodyRotateAngleYFactor - 1; - float rpxr = cosBodyRotateAngleYFactor + 2 - legOutset; - - bipedRightArm.rotationPointX = bipedRightLeg.rotationPointX = rpxl; - bipedLeftArm.rotationPointX = bipedLeftLeg.rotationPointX = rpxr; + bipedLeftArm.rotationPointZ = spread - sin; + steveRightArm.rotationPointZ = -cos; + + float legOutset = getLegOutset(); + float rpxl = cos + 1 - legOutset; + float rpxr = legOutset - cos - 1; + + bipedRightArm.rotationPointX = rpxr; + bipedRightLeg.rotationPointX = rpxr; + bipedLeftArm.rotationPointX = rpxl; + bipedLeftLeg.rotationPointX = rpxl; + + // Push the front legs back apart if we're a thin pony + if (smallArms) { + bipedLeftArm.rotationPointX--; + bipedLeftArm.rotationPointX += 2; + } bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; - //noinspection SuspiciousNameCombination - this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; - bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; } @@ -298,17 +304,16 @@ public class ModelPlayerPony extends AbstractPonyModel { this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); } - - @SuppressWarnings("incomplete-switch") - private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean bothHoovesAreOccupied, float swing) { + + private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { switch (pose) { case ITEM: float swag = 1; - if (!isFlying && bothHoovesAreOccupied) { + if (!isFlying && both) { swag = (float) (1 - Math.pow(swing, 2)); } - float rotationMultiplier = 0.5f + (1 - swag)/2; - arm.rotateAngleX = this.bipedLeftArm.rotateAngleX * rotationMultiplier - ((float) Math.PI / 10) * swag; + float mult = 0.5f + (1 - swag)/2; + arm.rotateAngleX = this.bipedLeftArm.rotateAngleX * mult - ((float) Math.PI / 10) * swag; case EMPTY: arm.rotateAngleY = 0; break; @@ -316,6 +321,7 @@ public class ModelPlayerPony extends AbstractPonyModel { arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; arm.rotateAngleY = (float) (Math.PI / 6); break; + default: } } @@ -348,38 +354,38 @@ public class ModelPlayerPony extends AbstractPonyModel { } private void swingArm(ModelRenderer arm, float f22, float f33, float f28) { - arm.rotateAngleX = (float) (this.unicornArmRight.rotateAngleX - (f22 * 1.2D + f33)); + arm.rotateAngleX = (float) (arm.rotateAngleX - (f22 * 1.2D + f33)); arm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; arm.rotateAngleZ = f28 * -0.4F; } protected void swingArms(float tick) { - float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; + float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(tick * 0.067F) * 0.05F; if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) { if (this.metadata.hasMagic()) { - this.unicornArmRight.rotateAngleZ += cosTickFactor; - this.unicornArmRight.rotateAngleX += sinTickFactor; + this.unicornArmRight.rotateAngleZ += cos; + this.unicornArmRight.rotateAngleX += sin; } else { - this.bipedRightArm.rotateAngleZ += cosTickFactor; - this.bipedRightArm.rotateAngleX += sinTickFactor; - - this.steveRightArm.rotateAngleZ += cosTickFactor; - this.steveRightArm.rotateAngleX += sinTickFactor; + this.bipedRightArm.rotateAngleZ += cos; + this.steveRightArm.rotateAngleZ += cos; + + this.bipedRightArm.rotateAngleX += sin; + this.steveRightArm.rotateAngleX += sin; } } if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) { if (this.metadata.hasMagic()) { - this.unicornArmLeft.rotateAngleZ += cosTickFactor; - this.unicornArmLeft.rotateAngleX += sinTickFactor; + this.unicornArmLeft.rotateAngleZ += cos; + this.unicornArmLeft.rotateAngleX += sin; } else { - this.bipedLeftArm.rotateAngleZ += cosTickFactor; - this.bipedLeftArm.rotateAngleX += sinTickFactor; - - this.steveLeftArm.rotateAngleZ += cosTickFactor; - this.steveLeftArm.rotateAngleX += sinTickFactor; + this.bipedLeftArm.rotateAngleZ += cos; + this.steveLeftArm.rotateAngleZ += cos; + + this.bipedLeftArm.rotateAngleX += sin; + this.steveLeftArm.rotateAngleX += sin; } } } @@ -412,10 +418,9 @@ public class ModelPlayerPony extends AbstractPonyModel { this.unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; this.bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; - this.bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; + + this.bipedLeftLeg.rotationPointY = this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; } protected void ponySleep() { @@ -675,50 +680,55 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void initLegPositions(float yOffset, float stretch) { - int armWidth = this.smallArms ? 3 : 4; - float armY = this.smallArms ? 8.5f : 8f; - float armX = this.smallArms ? -2f : -3f; + int armWidth = smallArms ? 3 : 4; + float rarmY = smallArms ? 8.5f : 8; + float rarmX = smallArms ? 2 : 3; - this.bipedRightArm.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch); - this.bipedLeftArm .addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, armWidth, 12, 4, stretch); + float armX = THIRDP_ARM_CENTRE_X - 2; + float armY = THIRDP_ARM_CENTRE_Y - 6; + float armZ = THIRDP_ARM_CENTRE_Z - 2; - this.bipedRightArm.setRotationPoint(armX, yOffset + armY, 0.0F); - this.bipedLeftArm .setRotationPoint(3.0F, yOffset + armY, 0.0F); + this.bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch); + this.bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch); - this.bipedRightLeg.addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); - 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); + this.bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch); + this.bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch); - this.bipedRightLeg.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); + this.bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); + this.bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); + + this.bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); + this.bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); - 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.unicornArmLeft .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); - this.unicornArmLeft .setRotationPoint(-5.0F, 2.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, armWidth, 12, 4, stretch + 0.25f); - this.bipedRightArmwear.setRotationPoint(-3.0F, yOffset + armY, 0.0F); + if (bipedLeftArmwear != null) { + this.bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f); + this.bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); } - if (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 .setRotationPoint(3.0F, yOffset + armY, 0.0F); + if (bipedRightArmwear != null) { + this.bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f); + this.bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); + } + + if (this.bipedLeftLegwear != null) { + this.bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); + this.bipedRightLegwear.setRotationPoint(3, yOffset, 0); } 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.setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); + this.bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); + this.bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } - 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.unicornArmLeft .addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); + this.unicornArmRight.addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); + + this.unicornArmLeft .setRotationPoint(5, yOffset + 2, 0); + this.unicornArmRight.setRotationPoint(-5, yOffset + 2, 0); } @Override public void renderCape(float scale) { this.bipedCape.render(scale); } - } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index a8fea8cc..c13f23f4 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -54,7 +54,6 @@ public class ModelSkeletonPony extends ModelMobPony { if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } - } @Override diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 5656b0d7..9785eb4c 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -22,18 +22,18 @@ public class ModelZombiePony extends ModelMobPony { } @Override - protected void rotateRightArm(float var8, float var9, float move, float tick) { + protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; if (isRight(move)) { - rotateArmHolding(bipedRightArm, 1, var8, var9, tick); + rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { - rotateArmHolding(bipedLeftArm, -1, var8, var9, tick); + rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); } } @Override - protected void rotateLeftArm(float var8, float var9, float move, float tick) { + protected void rotateLeftArm(float move, float tick) { } diff --git a/src/main/java/com/minelittlepony/pony/data/IPonyData.java b/src/main/java/com/minelittlepony/pony/data/IPonyData.java index f1f23d67..74756255 100644 --- a/src/main/java/com/minelittlepony/pony/data/IPonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/IPonyData.java @@ -3,18 +3,36 @@ package com.minelittlepony.pony.data; import net.minecraft.client.resources.data.IMetadataSection; /** - * Dummy interface so gson won't go crazy + * Metadata for a pony. */ public interface IPonyData extends IMetadataSection { + /** + * Gets this pony's race. + */ PonyRace getRace(); + /** + * Gets the length of the pony's tail. + */ TailLengths getTail(); + /** + * Get the pony's gender (usually female). + */ PonyGender getGender(); + /** + * Gets the current pony size. + */ PonySize getSize(); + /** + * Gets the magical glow colour for magic-casting races. Returns 0 otherwise. + */ int getGlowColor(); + /** + * Returns true if and only if this metadata represents a pony that can cast magic. + */ boolean hasMagic(); } diff --git a/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java index 9ba53aa0..2e2e5925 100644 --- a/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java +++ b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java @@ -1,9 +1,24 @@ package com.minelittlepony.pony.data; +/** + * Interface for enums that can be parsed from an image trigger pixel value. + * @author Chris Albers + * + * @param + */ public interface ITriggerPixelMapped & ITriggerPixelMapped> { - + /** + * Gets the pixel colour matching this enum value. + */ int getTriggerPixel(); + /** + * Gets the enum value corresponding to the given enum type and pixel value. + * If none are found, the first parameter is returned as the default. + * + * @param type Return type and default value. + * @param pixelValue The pixel colour to search for. + */ @SuppressWarnings("unchecked") public static & ITriggerPixelMapped> T getByTriggerPixel(T type, int pixelValue) { for (T i : (T[])type.getClass().getEnumConstants()) { diff --git a/src/main/java/com/minelittlepony/pony/data/PonyData.java b/src/main/java/com/minelittlepony/pony/data/PonyData.java index aa5e0ea0..7d6cf50b 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyData.java @@ -6,6 +6,11 @@ import com.minelittlepony.MineLittlePony; import java.awt.image.BufferedImage; import javax.annotation.concurrent.Immutable; + +/** + * Implementation for IPonyData. + * + */ @Immutable public class PonyData implements IPonyData { private final PonyRace race; @@ -71,6 +76,9 @@ public class PonyData implements IPonyData { .toString(); } + /** + * Parses an image buffer into a new IPonyData representing the values stored in it's individual trigger pixels. + */ static IPonyData parse(BufferedImage image) { return new PonyData(image); } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java index f7588831..de350c26 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -29,22 +29,41 @@ public enum PonyRace implements ITriggerPixelMapped { this.model = model; } + /** + * Returns true if this pony has a horn (and by extension can cast magic). + * @return + */ public boolean hasHorn() { return horn; } + /** + * Returns true if this pony has wings. If it has wings, it can fly, of course. + */ public boolean hasWings() { return wings; } + /** + * Returns true if this is a human. + */ public boolean isHuman() { return this == HUMAN; } + /** + * Gets the model type associated with this species. + */ public PlayerModels getModel() { return model; } + /** + * Gets the actual race determined by the given pony level. + * PonyLevel.HUMANS would force all races to be humans. + * PonyLevel.BOTH is no change. + * PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't. + */ public PonyRace getEffectiveRace(PonyLevel level) { if (level == PonyLevel.HUMANS) return HUMAN; return this; diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java index e1c42fca..57e79cb7 100644 --- a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -2,6 +2,10 @@ package com.minelittlepony.pony.data; import java.awt.image.BufferedImage; +/** + * Individual trigger pixels for a pony skin. + * + */ public enum TriggerPixels { RACE(PonyRace.HUMAN, 0, 0), TAIL(TailLengths.FULL, 1, 0), @@ -19,10 +23,20 @@ public enum TriggerPixels { this.y = y; } + /** + * Reads tis trigger pixel's value and returns the raw colour value. + * @param image Image to read + * @param mask Colour mask (0xffffff for rgb, -1 for rgba) + */ public int readColor(BufferedImage image, int mask) { return image.getRGB(x, y) & mask; } + /** + * Reads this trigger pixel's value and parses it to an Enum instance. + * + * @param image Image to read + */ @SuppressWarnings("unchecked") public & ITriggerPixelMapped> T readValue(BufferedImage image) { return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff)); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java index 88839f52..5c6df3b0 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java @@ -16,7 +16,7 @@ public class LayerPonyStrayOverlay extends LayerOverlayBase { public LayerPonyStrayOverlay(RenderLivingBase render) { super(render); this.overlayModel = new ModelSkeletonPony(); - this.overlayModel.init(0F, 0.25F); + this.overlayModel.init(0, 0.25F); } @Override From 5964cf1bc4df0b7628cb53a5fe98672618f1a70e Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 21:38:11 +0200 Subject: [PATCH 16/96] What time is it? Amputation time! --- .../model/AbstractPonyModel.java | 15 ----------- .../model/armour/ModelPonyArmor.java | 1 - .../model/ponies/ModelPlayerPony.java | 25 ++++++------------- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 1126bbed..3cc7ec98 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -29,15 +29,8 @@ public abstract class AbstractPonyModel extends ModelPlayer { public IPonyData metadata = new PonyData(); public float motionPitch; - @Deprecated - // TODO: Why so many arms? - public ModelRenderer steveLeftArm; - public ModelRenderer steveRightArm; - public AbstractPonyModel(boolean arms) { super(0, arms); - this.steveLeftArm = this.bipedLeftArm; - this.steveRightArm = this.bipedRightArm; } /** @@ -71,14 +64,6 @@ public abstract class AbstractPonyModel extends ModelPlayer { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); return; } - - this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2 * limbSwingAmount * 0.5F; - this.steveRightArm.rotateAngleY = 0; - this.steveRightArm.rotateAngleZ = 0; - - this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2 * limbSwingAmount * 0.5F; - this.steveLeftArm.rotateAngleY = 0; - this.steveLeftArm.rotateAngleZ = 0; } /** diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index 0d051057..a85587a2 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -125,7 +125,6 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void initLegTextures() { this.bipedRightArm = new ModelRenderer(this, 0, 16); - this.steveRightArm = new ModelRenderer(this, 0, 16); this.bipedLeftArm = new ModelRenderer(this, 0, 16); this.bipedLeftArm.mirror = true; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index e3a64742..6ec1c354 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -204,7 +204,7 @@ public class ModelPlayerPony extends AbstractPonyModel { rightLeg = leftLeg = MathHelper.sin(swing / 2); } - steveRightArm.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F; + bipedRightArm.rotateAngleY = 0.2F; bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; this.bipedLeftLeg.rotateAngleY = 0.2F; @@ -222,7 +222,7 @@ public class ModelPlayerPony extends AbstractPonyModel { leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; - this.steveRightArm.rotateAngleY = this.bipedRightArm.rotateAngleY = 0; + this.bipedRightArm.rotateAngleY = 0; this.bipedLeftArm.rotateAngleY = 0; this.bipedRightLeg.rotateAngleY = 0; @@ -236,11 +236,11 @@ public class ModelPlayerPony extends AbstractPonyModel { - this.steveLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX = leftArm; - this.steveRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX = rightArm; + this.bipedLeftArm.rotateAngleX = leftArm; + this.bipedRightArm.rotateAngleX = rightArm; this.bipedLeftArm.rotateAngleZ = 0; - this.steveRightArm.rotateAngleZ = this.bipedRightArm.rotateAngleZ = 0; + this.bipedRightArm.rotateAngleZ = 0; this.bipedLeftLeg.rotateAngleX = leftLeg; this.bipedRightLeg.rotateAngleX = rightLeg; @@ -263,10 +263,9 @@ public class ModelPlayerPony extends AbstractPonyModel { float spread = rainboom ? 2 : 1; - steveRightArm.rotationPointZ = bipedRightArm.rotationPointZ = spread + sin; + bipedRightArm.rotationPointZ = spread + sin; bipedLeftArm.rotationPointZ = spread - sin; - steveRightArm.rotationPointZ = -cos; float legOutset = getLegOutset(); float rpxl = cos + 1 - legOutset; @@ -347,8 +346,7 @@ public class ModelPlayerPony extends AbstractPonyModel { if (this.metadata.hasMagic() && mainPose != ArmPose.EMPTY) { swingArm(mainRight ? this.unicornArmRight : this.unicornArmLeft, f22, f33, f28); } else { - swingArm(this.getArmForSide(mainSide), f22, f33, f28); - swingArm(mainRight ? this.steveRightArm : this.steveLeftArm, f22, f33, f28); + swingArm(getArmForSide(mainSide), f22, f33, f28); } } } @@ -370,10 +368,7 @@ public class ModelPlayerPony extends AbstractPonyModel { this.unicornArmRight.rotateAngleX += sin; } else { this.bipedRightArm.rotateAngleZ += cos; - this.steveRightArm.rotateAngleZ += cos; - this.bipedRightArm.rotateAngleX += sin; - this.steveRightArm.rotateAngleX += sin; } } if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) { @@ -382,10 +377,7 @@ public class ModelPlayerPony extends AbstractPonyModel { this.unicornArmLeft.rotateAngleX += sin; } else { this.bipedLeftArm.rotateAngleZ += cos; - this.steveLeftArm.rotateAngleZ += cos; - this.bipedLeftArm.rotateAngleX += sin; - this.steveLeftArm.rotateAngleX += sin; } } } @@ -412,8 +404,6 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void sneakLegs() { - this.steveRightArm.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; this.unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; @@ -619,7 +609,6 @@ public class ModelPlayerPony extends AbstractPonyModel { this.unicornArmRight = new ModelRenderer(this, 40, 32).setTextureSize(64, 64); this.unicornArmLeft = new ModelRenderer(this, 40, 32).setTextureSize(64, 64); - this.boxList.remove(this.steveRightArm); this.boxList.remove(this.unicornArmRight); } From 0c6e2a74ffcffa3e9c8ecb5a36e9d46b651b846f Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Apr 2018 22:01:31 +0200 Subject: [PATCH 17/96] Infinite loops are bad, mmmkay? --- .../minelittlepony/model/AbstractPonyModel.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 3cc7ec98..bd38469a 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -252,15 +252,21 @@ public abstract class AbstractPonyModel extends ModelPlayer { } } - // TODO: This has potential to create an infinite loop. @Override public ModelRenderer getRandomModelBox(Random rand) { - // empty lists cause problems + // grab one at random, but cycle through the list until you find one that's filled. + // Return if you find one, or if you get back to where you started in which case there isn't any. + int index = rand.nextInt(boxList.size()); + int i = index; + ModelRenderer mr; do { - // try until it's not - mr = super.getRandomModelBox(rand); - } while (mr.cubeList.isEmpty()); + mr = boxList.get(index); + if (!mr.cubeList.isEmpty()) return mr; + + i = (i + 1) % boxList.size(); + } while (i != index); + return mr; } } From 3dbedc3a5b5b3c1eadbe1176c664943920dc34be Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 15:54:27 +0200 Subject: [PATCH 18/96] This is why you test things, folks --- .../java/com/minelittlepony/mixin/MixinEntityLivingBase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java index bd8a9a29..2ca11143 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java +++ b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java @@ -33,6 +33,7 @@ public abstract class MixinEntityLivingBase extends Entity implements IPonyAnima } else { strafeRollAmount *= 0.8; } - return (float)Math.toDegrees(strafeRollAmount * ticks); + + return (float)Math.toDegrees(strafeRollAmount); } } From d6c5e2bd0b0bbe227c0b24a53a25639c54c21b8f Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 15:56:36 +0200 Subject: [PATCH 19/96] Reimplement Daring Doo (STEVE) / Night Guard (ALEX) --- .../java/com/minelittlepony/PonyManager.java | 33 ++++++++++++------- .../com/minelittlepony/ducks/IPlayerInfo.java | 12 +++---- .../mixin/MixinNetworkPlayerInfo.java | 12 +------ 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 3a32070e..f8ffef56 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -9,7 +9,9 @@ import com.minelittlepony.model.PMAPI; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.pony.data.PonyLevel; +import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; @@ -75,13 +77,16 @@ public class PonyManager implements IResourceManagerReloadListener { * @param player the player */ public Pony getPony(AbstractClientPlayer player) { - Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms()); - - if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { - return getBackgroundPony(player.getUniqueID()); - } - - return pony; + return getPony(IPlayerInfo.getPlayerInfo(player).unwrap()); + } + + public Pony getPony(NetworkPlayerInfo playerInfo) { + ResourceLocation skin = playerInfo.getLocationSkin(); + UUID uuid = playerInfo.getGameProfile().getId(); + + if (skin == null) return getDefaultPony(uuid); + + return getPony(skin, uuid); } /** @@ -118,13 +123,19 @@ public class PonyManager implements IResourceManagerReloadListener { } private Pony getBackgroundPony(UUID uuid) { - if (getNumberOfPonies() == 0) return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); + if (getNumberOfPonies() == 0 || isUser(uuid)) { + return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); + } - int bgi = uuid.hashCode() % this.getNumberOfPonies(); - while (bgi < 0) bgi += this.getNumberOfPonies(); + int bgi = uuid.hashCode() % getNumberOfPonies(); + while (bgi < 0) bgi += getNumberOfPonies(); return getPony(backgroundPonyList.get(bgi), false); } + + private boolean isUser(UUID uuid) { + return Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.getUniqueID().equals(uuid); + } /** * De-registers a pony from the cache. @@ -164,7 +175,7 @@ public class PonyManager implements IResourceManagerReloadListener { * Returns true if the given uuid is of a player would would use the ALEX skin type. */ public static boolean isSlimSkin(UUID uuid) { - return (uuid.hashCode() & 1) == 1; + return false;//(uuid.hashCode() & 1) == 1; } private int getNumberOfPonies() { diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index ef74e6ea..a8474fd3 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -1,16 +1,10 @@ package com.minelittlepony.ducks; -import com.minelittlepony.pony.data.Pony; - import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.network.NetworkPlayerInfo; public interface IPlayerInfo { - /** - * Gets the pony associated with this player. - */ - Pony getPony(); - /** * Returns true if the vanilla skin (the one returned by NetworkPlayerInfo.getSkinLocation) uses the ALEX model type. */ @@ -22,4 +16,8 @@ public interface IPlayerInfo { public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) { return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID()); } + + default NetworkPlayerInfo unwrap() { + return (NetworkPlayerInfo)this; + } } diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java index 89356ba0..ab91b363 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyManager; import com.minelittlepony.ducks.IPlayerInfo; -import com.minelittlepony.pony.data.Pony; import com.mojang.authlib.GameProfile; import net.minecraft.client.network.NetworkPlayerInfo; @@ -29,16 +28,7 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true) private void getSkinType(CallbackInfoReturnable info) { - info.setReturnValue(getPony().getRace(false).getModel().getId(usesSlimArms())); - } - - @Override - public Pony getPony() { - ResourceLocation skin = getLocationSkin(); - if (skin == null) { - return MineLittlePony.getInstance().getManager().getDefaultPony(getGameProfile().getId()); - } - return MineLittlePony.getInstance().getManager().getPony(skin, getGameProfile().getId()); + info.setReturnValue(MineLittlePony.getInstance().getManager().getPony(unwrap()).getRace(false).getModel().getId(usesSlimArms())); } @Override From 75cb0eb6fc930114bb01a9cd7e9cfc7b201def85 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 15:57:37 +0200 Subject: [PATCH 20/96] Rewrite the plane renderer/horn glow renderer to be more sensible --- .../render/BasePonyRenderer.java | 109 +++++++++++++++++- .../minelittlepony/render/PonyRenderer.java | 20 ++++ .../com/minelittlepony/render/plane/Face.java | 4 +- .../render/plane/ModelPlane.java | 75 ++++-------- .../render/plane/PlaneRenderer.java | 51 +++++--- 5 files changed, 186 insertions(+), 73 deletions(-) create mode 100644 src/main/java/com/minelittlepony/render/PonyRenderer.java diff --git a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java index 787d51ff..05305dbe 100644 --- a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java @@ -1,16 +1,19 @@ package com.minelittlepony.render; import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.TextureOffset; @SuppressWarnings("unchecked") -public class BasePonyRenderer> extends ModelRenderer { +public abstract class BasePonyRenderer> extends ModelRenderer { protected final ModelBase baseModel; protected int textureOffsetX, textureOffsetY; + protected float modelOffsetX, modelOffsetY, modelOffsetZ; + public BasePonyRenderer(ModelBase model) { super(model); baseModel = model; @@ -20,6 +23,11 @@ public class BasePonyRenderer> extends ModelRender super(model, x, y); baseModel = model; } + + /** + * Called to create a new instance of this renderer (used for child renderers) + */ + protected abstract T copySelf(); @Override public T setTextureOffset(int x, int y) { @@ -29,23 +37,87 @@ public class BasePonyRenderer> extends ModelRender return (T) this; } - public T at(float x, float y, float z) { - offsetX = x; - offsetY = y; - offsetZ = z; + /** + * Flips the mirror flag. All faces are mirrored until this is called again. + */ + public T mirror() { + return mirror(!mirror); + } + + public T mirror(boolean m) { + mirror = m; return (T) this; } + + /** + * Sets the texture offset + */ + public T tex(int x, int y) { + return setTextureOffset(x, y); + } + + public T size(int x, int y) { + return (T) setTextureSize(x, y); + } + + /** + * Positions this model in space. + */ + public T at(float x, float y, float z) { + return (T)at(this, x, y, z); + } + + /** + * Sets an offset to be used on all shapes and children created through this renderer. + */ + public T offset(float x, float y, float z) { + modelOffsetX = x; + modelOffsetY = y; + modelOffsetZ = z; + return (T) this; + } + + public static T at(T renderer, float x, float y, float z) { + renderer.offsetX = x / 16; + renderer.offsetY = y / 16; + renderer.offsetZ = z / 16; + return renderer; + } + + public void rotateTo(ModelRenderer other) { + rotateAngleX = other.rotateAngleX; + rotateAngleY = other.rotateAngleY; + rotateAngleZ = other.rotateAngleZ; + } + + public T rotateAt(ModelRenderer other) { + return at(other.rotationPointX, other.rotationPointY, other.rotationPointZ); + } + /** + * Sets the rotation point. + */ public T around(float x, float y, float z) { setRotationPoint(x, y, z); return (T) this; } + /** + * Gets or creates a new child model based on its unique index. + * New children will be of the same type and inherit the same textures and offsets of the original. + */ + public T child(int index) { + if (childModels == null || index >= childModels.size()) { + addChild(copySelf().offset(modelOffsetX, modelOffsetY, modelOffsetZ)); + } + return (T)childModels.get(index); + } + @Override public T addBox(String partName, float offX, float offY, float offZ, int width, int height, int depth) { partName = boxName + "." + partName; - TextureOffset tex = this.baseModel.getTextureOffset(partName); + TextureOffset tex = baseModel.getTextureOffset(partName); setTextureOffset(tex.textureOffsetX, tex.textureOffsetY).addBox(offX, offY, offZ, width, height, depth); cubeList.get(cubeList.size() - 1).setBoxName(partName); @@ -58,4 +130,29 @@ public class BasePonyRenderer> extends ModelRender addBox(offX, offY, offZ, width, height, depth, 0); return (T) this; } + + public T addBox(float offX, float offY, float offZ, int width, int height, int depth, boolean mirrored) { + addBox(offX, offY, offZ, width, height, depth, 0, mirrored); + return (T)this; + } + + public void addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { + addBox(offX, offY, offZ, width, height, depth, scaleFactor, mirror); + } + + /** + * Creates a textured box. + */ + public T box(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { + return addBox(offX, offY, offZ, width, height, depth, scaleFactor, mirror); + } + + private T addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { + createBox(modelOffsetX + offX, modelOffsetY + offY, modelOffsetZ + offZ, width, height, depth, scaleFactor, mirrored); + return (T)this; + } + + protected void createBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { + cubeList.add(new ModelBox(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, mirrored)); + } } diff --git a/src/main/java/com/minelittlepony/render/PonyRenderer.java b/src/main/java/com/minelittlepony/render/PonyRenderer.java new file mode 100644 index 00000000..102dc0ff --- /dev/null +++ b/src/main/java/com/minelittlepony/render/PonyRenderer.java @@ -0,0 +1,20 @@ +package com.minelittlepony.render; + +import net.minecraft.client.model.ModelBase; + +public class PonyRenderer extends BasePonyRenderer { + + public PonyRenderer(ModelBase model) { + super(model); + } + + public PonyRenderer(ModelBase model, int x, int y) { + super(model, x, y); + } + + @Override + protected PonyRenderer copySelf() { + return new PonyRenderer(baseModel, textureOffsetX, textureOffsetY); + } + +} diff --git a/src/main/java/com/minelittlepony/render/plane/Face.java b/src/main/java/com/minelittlepony/render/plane/Face.java index 86149e82..1c466452 100644 --- a/src/main/java/com/minelittlepony/render/plane/Face.java +++ b/src/main/java/com/minelittlepony/render/plane/Face.java @@ -1,7 +1,7 @@ package com.minelittlepony.render.plane; enum Face { - WEST, EAST, + NORTH, SOUTH, UP, DOWN, - NORTH, SOUTH + EAST, WEST; } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java index 33695541..bd575aa1 100644 --- a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -16,17 +16,14 @@ public class ModelPlane extends ModelBox { public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, float x, float y, float z, int w, int h, int d, float scale, Face face) { super(renderer, textureX, textureY, x, y, z, w, h, d, scale, false); - float x2 = x + w; - float y2 = y + h; - float z2 = z + d; + float x2 = x + w + scale; + float y2 = y + h + scale; + float z2 = z + d + scale; x -= scale; y -= scale; z -= scale; - x2 += scale; - y2 += scale; - z2 += scale; - + if (renderer.mirror) { float v = x2; x2 = x; @@ -47,56 +44,32 @@ public class ModelPlane extends ModelBox { } // w:west e:east d:down u:up s:south n:north - PositionTextureVertex wds = new PositionTextureVertex(x, y, z, 0.0F, 0.0F); - PositionTextureVertex eds = new PositionTextureVertex(x2, y, z, 0.0F, 8.0F); - PositionTextureVertex eus = new PositionTextureVertex(x2, y2, z, 8.0F, 8.0F); - PositionTextureVertex wus = new PositionTextureVertex(x, y2, z, 8.0F, 0.0F); - PositionTextureVertex wdn = new PositionTextureVertex(x, y, z2, 0.0F, 0.0F); - PositionTextureVertex edn = new PositionTextureVertex(x2, y, z2, 0.0F, 8.0F); - PositionTextureVertex eun = new PositionTextureVertex(x2, y2, z2, 8.0F, 8.0F); - PositionTextureVertex wun = new PositionTextureVertex(x, y2, z2, 8.0F, 0.0F); + PositionTextureVertex wds = new PositionTextureVertex(x , y , z , 0, 0); + PositionTextureVertex eds = new PositionTextureVertex(x2, y , z , 0, 8); + PositionTextureVertex eus = new PositionTextureVertex(x2, y2, z , 8, 8); + PositionTextureVertex wus = new PositionTextureVertex(x , y2, z , 8, 0); + PositionTextureVertex wdn = new PositionTextureVertex(x , y , z2, 0, 0); + PositionTextureVertex edn = new PositionTextureVertex(x2, y , z2, 0, 8); + PositionTextureVertex eun = new PositionTextureVertex(x2, y2, z2, 8, 8); + PositionTextureVertex wun = new PositionTextureVertex(x , y2, z2, 8, 0); - if (face == Face.EAST) { - quad = new TexturedQuad( - new PositionTextureVertex[]{edn, eds, eus, eun}, - textureX, textureY, - textureX + d, textureY + h, - renderer.textureWidth, renderer.textureHeight); + if (face == Face.EAST) { // North/Front (was East) + quad = new TexturedQuad(new PositionTextureVertex[]{edn, eds, eus, eun}, textureX, textureY, textureX + d, textureY + h, renderer.textureWidth, renderer.textureHeight); } - if (face == Face.WEST) { - quad = new TexturedQuad( - new PositionTextureVertex[]{wds, wdn, wun, wus}, - textureX, textureY, - textureX + d, textureY + h, - renderer.textureWidth, renderer.textureHeight); + if (face == Face.WEST) { // South/Back (was West) + quad = new TexturedQuad(new PositionTextureVertex[]{wds, wdn, wun, wus}, textureX, textureY, textureX + d, textureY + h, renderer.textureWidth, renderer.textureHeight); } - if (face == Face.UP) { - quad = new TexturedQuad( - new PositionTextureVertex[]{edn, wdn, wds, eds}, - textureX, textureY, - textureX + w, textureY + d, - renderer.textureWidth, renderer.textureHeight); + if (face == Face.UP) { // Up + quad = new TexturedQuad(new PositionTextureVertex[]{edn, wdn, wds, eds}, textureX, textureY, textureX + w, textureY + d, renderer.textureWidth, renderer.textureHeight); } - if (face == Face.DOWN) { - quad = new TexturedQuad( - new PositionTextureVertex[]{eus, wus, wun, eun}, - textureX, textureY, - textureX + w, textureY + d, - renderer.textureWidth, renderer.textureHeight); + if (face == Face.DOWN) { // Down + quad = new TexturedQuad(new PositionTextureVertex[]{eus, wus, wun, eun}, textureX, textureY, textureX + w, textureY + d, renderer.textureWidth, renderer.textureHeight); } - if (face == Face.SOUTH) { - quad = new TexturedQuad( - new PositionTextureVertex[]{eds, wds, wus, eus}, - textureX, textureY, - textureX + w, textureY + h, - renderer.textureWidth, renderer.textureHeight); + if (face == Face.SOUTH) { // East/Left (was South) + quad = new TexturedQuad(new PositionTextureVertex[]{eds, wds, wus, eus}, textureX, textureY, textureX + w, textureY + h, renderer.textureWidth, renderer.textureHeight); } - if (face == Face.NORTH) { - quad = new TexturedQuad( - new PositionTextureVertex[]{wdn, edn, eun, wun}, - textureX, textureY, - textureX + w, textureY + h, - renderer.textureWidth, renderer.textureHeight); + if (face == Face.NORTH) { // West/Right (was North) + quad = new TexturedQuad(new PositionTextureVertex[]{wdn, edn, eun, wun}, textureX, textureY, textureX + w, textureY + h, renderer.textureWidth, renderer.textureHeight); } if (renderer.mirror || renderer.mirrory || renderer.mirrorz) { diff --git a/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java index cb5e54f9..c5560169 100644 --- a/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java @@ -16,31 +16,54 @@ public class PlaneRenderer extends BasePonyRenderer { super(model, x, y); } - private void addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) { - this.cubeList.add(new ModelPlane(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scale, face)); + /** + * Flips the Z bit. Any calls to add a plane will be mirrored until this is called again. + */ + public PlaneRenderer flipZ() { + mirrorz = !mirrorz; + return this; } - 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); + + /** + * Flips the Y bit. Any calls to add a plane will be mirrored until this is called again. + */ + public PlaneRenderer flipY() { + mirrory = !mirrory; + return this; } - 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); + @Override + protected PlaneRenderer copySelf() { + return new PlaneRenderer(baseModel, textureOffsetX, textureOffsetY); } - 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); + private PlaneRenderer addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) { + cubeList.add(new ModelPlane(this, textureOffsetX, textureOffsetY, modelOffsetX + offX, modelOffsetY + offY, modelOffsetZ + offZ, width, height, depth, scale, face)); + return this; } - 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 PlaneRenderer addTopPlane(float offX, float offY, float offZ, int width, int depth, float scale) { + return addPlane(offX, offY, offZ, width, 0, depth, scale, Face.UP); } - 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 PlaneRenderer addBottomPlane(float offX, float offY, float offZ, int width, int depth, float scale) { + return addPlane(offX, offY, offZ, width, 0, depth, scale, Face.DOWN); } - 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); + public PlaneRenderer addWestPlane(float offX, float offY, float offZ, int height, int depth, float scale) { + return addPlane(offX, offY, offZ, 0, height, depth, scale, Face.WEST); + } + + public PlaneRenderer addEastPlane(float offX, float offY, float offZ, int height, int depth, float scale) { + return addPlane(offX, offY, offZ, 0, height, depth, scale, Face.EAST); + } + + public PlaneRenderer addFrontPlane(float offX, float offY, float offZ, int width, int height, float scale) { + return addPlane(offX, offY, offZ, width, height, 0, scale, Face.NORTH); + } + + public PlaneRenderer addBackPlane(float offX, float offY, float offZ, int width, int height, float scale) { + return addPlane(offX, offY, offZ, width, height, 0, scale, Face.SOUTH); } } From 280013c8a40ea43437d6132e782ab95af5d7d64a Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 16:01:31 +0200 Subject: [PATCH 21/96] Rewrite model code (part 1) --- .../model/AbstractPonyModel.java | 282 ++++---- .../minelittlepony/model/ModelMobPony.java | 8 +- .../model/PonyModelConstants.java | 12 +- .../model/armour/ModelPonyArmor.java | 209 +++--- .../model/armour/ModelSkeletonPonyArmor.java | 25 +- .../model/armour/ModelZombiePonyArmor.java | 18 +- .../model/components/HornGlow.java | 93 ++- .../model/ponies/ModelPlayerPony.java | 635 ++++++++---------- .../model/ponies/ModelSkeletonPony.java | 24 +- .../model/ponies/ModelVillagerPony.java | 61 +- .../model/ponies/ModelZombiePony.java | 8 +- .../render/HornGlowRenderer.java | 9 +- .../render/layer/LayerPonyArmor.java | 27 +- 13 files changed, 660 insertions(+), 751 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index bd38469a..cea8e448 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,7 +1,6 @@ package com.minelittlepony.model; import com.minelittlepony.model.armour.PonyArmor; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyData; import com.minelittlepony.pony.data.PonySize; @@ -10,6 +9,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.MathHelper; import java.util.Random; @@ -17,18 +17,33 @@ import java.util.Random; import static net.minecraft.client.renderer.GlStateManager.*; /** - * TODO move this into constructor and make separate classes for the races. + * TODO: move this into constructor and make separate classes for the races. */ public abstract class AbstractPonyModel extends ModelPlayer { + /** + * The model's current scale. + */ protected float scale = 0.0625F; public boolean isFlying; public boolean isSleeping; + /** + * Associcated pony data. + */ public IPonyData metadata = new PonyData(); + + /** + * Vertical pitch whilst flying. + */ public float motionPitch; - + + /** + * Flag indicating that this model is performing a rainboom (flight). + */ + public boolean rainboom; + public AbstractPonyModel(boolean arms) { super(0, arms); } @@ -40,7 +55,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { */ public void init(float yOffset, float stretch) { initTextures(); - this.initPositions(yOffset, stretch); + initPositions(yOffset, stretch); } /** @@ -62,7 +77,6 @@ public abstract class AbstractPonyModel extends ModelPlayer { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { if (doCancelRender()) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); - return; } } @@ -72,11 +86,36 @@ public abstract class AbstractPonyModel extends ModelPlayer { protected boolean doCancelRender() { return false; } + + /** + * Returns true if this model is on the ground and crouching. + */ + public boolean isCrouching() { + return isSneak && !isFlying; + } - public static void shiftRotationPoint(ModelRenderer aRenderer, float shiftX, float shiftY, float shiftZ) { - aRenderer.rotationPointX += shiftX; - aRenderer.rotationPointY += shiftY; - aRenderer.rotationPointZ += shiftZ; + /** + * Returns true if the given entity can and is flying, or has an elytra. + */ + public boolean isFlying(Entity entity) { + return (isFlying && metadata.getRace().hasWings()) || + (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()); + } + + /** + * Returns true if the current model is a child or a child-like foal. + */ + public boolean isChild() { + return metadata.getSize() == PonySize.FOAL || isChild; + } + + /** + * Adjusts the rotation center of the given renderer by the given amounts in each direction. + */ + public static void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) { + renderer.rotationPointX += x; + renderer.rotationPointY += y; + renderer.rotationPointZ += z; } /** @@ -105,135 +144,111 @@ public abstract class AbstractPonyModel extends ModelPlayer { * FIXME: Too long! Is there a better way to do this? */ public void transform(BodyPart part) { - if (this.isRiding) { - translate(0.0F, -0.6F, -0.2F); + if (isRiding) translate(0, -0.6F, -0.2F); + + if (isSleeping) { + rotate(90, 0, 1, 0); + rotate(270, 0, 0, 1); + rotate(90, 0, 1, 0); + rotate(180, 0, 0, 1); + rotate(180, 0, 1, 0); } - if (this.isSleeping) { - rotate(90.0F, 0.0F, 1.0F, 0.0F); - rotate(270.0F, 0.0F, 0.0F, 1.0F); - rotate(90.0F, 0.0F, 1.0F, 0.0F); - rotate(180.0F, 0.0F, 0.0F, 1.0F); - rotate(180.0F, 0.0F, 1.0F, 0.0F); - } - - if (this.metadata.getSize() == PonySize.FOAL || isChild) { - if (this.isSneak && !this.isFlying) { - translate(0.0F, -0.12F, 0.0F); - } - - if (this.isSleeping) { - translate(0.0F, -1.2F, 0.25F); - } - if (this.isRiding) { - translate(0, -.1, 0); - } - switch (part) { - case NECK: - case HEAD: - translate(0.0F, 0.76F, 0.0F); - scale(0.9F, 0.9F, 0.9F); - if (part == BodyPart.HEAD) - break; - if (this.isSneak && !this.isFlying) { - translate(0.0F, -0.01F, 0.15F); - } - break; - case BODY: - case TAIL: - translate(0.0F, 0.76F, -0.04F); - scale(0.6F, 0.6F, 0.6F); - break; - case LEGS: - translate(0.0F, 0.89F, 0.0F); - scale(0.6F, 0.41F, 0.6F); - if (this.isSneak && !this.isFlying) { - translate(0.0F, 0.12F, 0.0F); - } - - if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) { - translate(0.0F, -0.08F, 0.0F); - } - - break; - } - - } else if (this.metadata.getSize() == PonySize.LARGE) { - if (this.isSleeping) { - translate(0.0F, -0.7F, 0.2F); - } - - switch (part) { - case HEAD: - - translate(0.0F, -0.17F, -0.04F); - if (this.isSleeping) { - translate(0.0F, 0.0F, -0.1F); - } - - if (this.isSneak && !this.isFlying) { - translate(0.0F, 0.15F, 0.0F); - } - - break; - case NECK: - translate(0.0F, -0.15F, -0.07F); - if (this.isSneak && !this.isFlying) { - translate(0.0F, 0.0F, -0.05F); - } - - break; - case BODY: - translate(0.0F, -0.2F, -0.04F); - scale(1.15F, 1.2F, 1.2F); - break; - case TAIL: - translate(0.0F, -0.2F, 0.08F); - break; - case LEGS: - translate(0.0F, -0.14F, 0.0F); - scale(1.15F, 1.12F, 1.15F); - break; - } - } else if (this.metadata.getSize() == PonySize.TALL) { - if (this.isSleeping) { - translate(0.0F, -0.65F, 0.25F); - } - - switch (part) { - case HEAD: - translate(0.0F, -0.15F, 0.01F); - if (this.isSneak && !this.isFlying) { - translate(0.0F, 0.05F, 0.0F); - } - break; - case NECK: - translate(0.0F, -0.19F, -0.01F); - scale(1.0F, 1.1F, 1.0F); - if (this.isSneak && !this.isFlying) { - translate(0.0F, -0.06F, -0.04F); - } - break; - case BODY: - case TAIL: - translate(0.0F, -0.1F, 0.0F); - scale(1.0F, 1.0F, 1.0F); - break; - case LEGS: - translate(0.0F, -0.25F, 0.03F); - scale(1.0F, 1.18F, 1.0F); - if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) { - translate(0.0F, 0.05F, 0.0F); - } - break; - } + if (isChild()) { + transformFoal(part); + } else if (metadata.getSize() == PonySize.LARGE) { + transformLarge(part); + } else if (metadata.getSize() == PonySize.TALL) { + transformTall(part); } else { - if (this.isSleeping) { - translate(0.0F, -0.75F, 0.25F); - } + if (isSleeping) translate(0, -0.75F, 0.25F); } if (part == BodyPart.HEAD) { - rotate(motionPitch, 1F, 0F, 0F); + rotate(motionPitch, 1, 0, 0); + } + } + + private void transformTall(BodyPart part) { + if (isSleeping) translate(0, -0.65F, 0.25F); + + switch (part) { + case HEAD: + translate(0, -0.15F, 0.01F); + if (isCrouching()) translate(0, 0.05F, 0); + break; + case NECK: + translate(0, -0.19F, -0.01F); + scale(1, 1.1F, 1); + if (isCrouching()) translate(0, -0.06F, -0.04F); + break; + case BODY: + case TAIL: + translate(0, -0.1F, 0); + scale(1, 1, 1); + break; + case LEGS: + translate(0, -0.25F, 0.03F); + scale(1, 1.18F, 1); + if (rainboom) translate(0, 0.05F, 0); + break; + } + } + + private void transformLarge(BodyPart part) { + if (this.isSleeping) translate(0, -0.7F, 0.2F); + + switch (part) { + case HEAD: + translate(0, -0.17F, -0.04F); + if (isSleeping) translate(0, 0, -0.1F); + if (isCrouching()) translate(0, 0.15F, 0); + + break; + case NECK: + translate(0, -0.15F, -0.07F); + if (isCrouching()) translate(0, 0, -0.05F); + + break; + case BODY: + translate(0, -0.2F, -0.04F); + scale(1.15F, 1.2F, 1.2F); + break; + case TAIL: + translate(0, -0.2F, 0.08F); + break; + case LEGS: + translate(0, -0.14F, 0); + scale(1.15F, 1.12F, 1.15F); + break; + } + } + + private void transformFoal(BodyPart part) { + if (isCrouching()) translate(0, -0.12F, 0.0F); + if (isSleeping) translate(0, -1.2F, 0.25F); + if (isRiding) translate(0, -.1, 0); + + switch (part) { + case NECK: + case HEAD: + translate(0, 0.76F, 0); + scale(0.9F, 0.9F, 0.9F); + if (part == BodyPart.HEAD) + break; + if (isCrouching()) translate(0, -0.01F, 0.15F); + break; + case BODY: + case TAIL: + translate(0, 0.76F, -0.04F); + scale(0.6F, 0.6F, 0.6F); + break; + case LEGS: + translate(0, 0.89F, 0); + scale(0.6F, 0.41F, 0.6F); + if (isCrouching()) translate(0, 0.12F, 0); + if (rainboom) translate(0, -0.08F, 0); + + break; } } @@ -249,6 +264,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { isSleeping = pony.isSleeping; metadata = pony.metadata; motionPitch = pony.motionPitch; + rainboom = pony.rainboom; } } diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index 5007762c..69173516 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -33,10 +33,10 @@ public class ModelMobPony extends ModelPlayerPony { if (this.rightArmPose == ArmPose.EMPTY) return; if (!metadata.hasMagic()) { - rotateArmHolding(bipedRightArm, 1, swingProgress, tick); + rotateArmHolding(bipedRightArm, -1, swingProgress, tick); } else { unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmRight, 1, swingProgress, tick); + rotateArmHolding(unicornArmRight, -1, swingProgress, tick); } } @@ -50,10 +50,10 @@ public class ModelMobPony extends ModelPlayerPony { if (leftArmPose == ArmPose.EMPTY) return; if (!metadata.hasMagic()) { - rotateArmHolding(bipedLeftArm, 1, swingProgress, tick); + rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); } else { unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmLeft, 1, swingProgress, tick); + rotateArmHolding(unicornArmLeft, -1, swingProgress, tick); } } } diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 1244d225..79aaab00 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -3,9 +3,15 @@ package com.minelittlepony.model; public final class PonyModelConstants { public static final float - BODY_CENTRE_X = 0.0F, - BODY_CENTRE_Y = 8.0F, - BODY_CENTRE_Z = 6.0F, + PI = (float)Math.PI, + + BODY_CENTRE_X = 0, + BODY_CENTRE_Y = 8, + BODY_CENTRE_Z = 6, + + NECK_CENTRE_X = BODY_CENTRE_X - 2, + NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8f, + NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8f, BODY_ROTATE_ANGLE_X_NOTSNEAK = 0.0F, BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index a85587a2..fc924b1e 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -6,12 +6,12 @@ import net.minecraft.entity.Entity; import static com.minelittlepony.model.PonyModelConstants.*; import com.minelittlepony.model.ModelMobPony; +import com.minelittlepony.render.PonyRenderer; public class ModelPonyArmor extends ModelMobPony { - public ModelRenderer Bodypiece, extBody; - public ModelRenderer[] extHead, extLegs; - + public PonyRenderer Bodypiece, extBody, extLegLeft, extLegRight, extHead; + public ModelPonyArmor() { super(); this.textureHeight = 32; @@ -19,56 +19,47 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { - this.bipedBody.rotateAngleY = bodySwing * 0.2F; + bipedBody.rotateAngleY = bodySwing * 0.2F; } @Override protected void adjustBodyRiding() { - this.adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); + adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); } @Override protected void setHead(float posX, float posY, float posZ) { - this.bipedHead.setRotationPoint(posX, posY, posZ); - this.bipedHeadwear.setRotationPoint(posX, posY, posZ); - this.extHead[0].setRotationPoint(posX, posY, posZ); - this.extHead[1].setRotationPoint(posX, posY, posZ); + super.setHead(posX, posY, posZ); + extHead.setRotationPoint(posX, posY, posZ); } @Override - protected void rotateHead(float horz, float vert) { - super.rotateHead(horz, vert); - - float headRotateAngleX = this.bipedHead.rotateAngleX; - float headRotateAngleY = this.bipedHead.rotateAngleY; - - this.extHead[0].rotateAngleY = headRotateAngleY; - this.extHead[0].rotateAngleX = headRotateAngleX; - this.extHead[1].rotateAngleY = headRotateAngleY; - this.extHead[1].rotateAngleX = headRotateAngleX; + protected void updateHeadRotation(float x, float y) { + super.updateHeadRotation(x, y); + extHead.rotateAngleX = x; + extHead.rotateAngleX = x; } @Override protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { - this.bipedBody.rotateAngleX = rotateAngleX; - this.bipedBody.rotationPointY = rotationPointY; - this.bipedBody.rotationPointZ = rotationPointZ; + bipedBody.rotateAngleX = rotateAngleX; + bipedBody.rotationPointY = rotationPointY; + bipedBody.rotationPointZ = rotationPointZ; - this.Bodypiece.rotateAngleX = rotateAngleX; - this.Bodypiece.rotationPointY = rotationPointY; - this.Bodypiece.rotationPointZ = rotationPointZ; + Bodypiece.rotateAngleX = rotateAngleX; + Bodypiece.rotationPointY = rotationPointY; + Bodypiece.rotationPointZ = rotationPointZ; - this.extBody.rotateAngleX = rotateAngleX; - this.extBody.rotationPointY = rotationPointY; - this.extBody.rotationPointZ = rotationPointZ; + extBody.rotateAngleX = rotateAngleX; + extBody.rotationPointY = rotationPointY; + extBody.rotationPointZ = rotationPointZ; } @Override protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - this.bipedHead.render(this.scale); - this.extHead[0].render(this.scale); - this.extHead[1].render(this.scale); - this.bipedHeadwear.render(this.scale); + bipedHead.render(this.scale); + extHead.render(this.scale); + bipedHeadwear.render(this.scale); } @Override @@ -77,165 +68,139 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - this.bipedBody.render(this.scale); - this.Bodypiece.render(this.scale); - this.extBody.render(this.scale); + bipedBody.render(this.scale); + Bodypiece.render(this.scale); + extBody.render(this.scale); } @Override protected void renderLegs() { if (!isSneak) { boolean isLegs = this.extBody.showModel; - this.extBody.showModel = true; - this.extBody.postRender(this.scale); - this.extBody.showModel = isLegs; + extBody.showModel = true; + extBody.postRender(scale); + extBody.showModel = isLegs; } - this.bipedLeftArm.render(this.scale); - this.bipedRightArm.render(this.scale); - this.bipedLeftLeg.render(this.scale); - this.bipedRightLeg.render(this.scale); - this.extLegs[0].render(this.scale); - this.extLegs[1].render(this.scale); + bipedLeftArm.render(scale); + bipedRightArm.render(scale); + bipedLeftLeg.render(scale); + bipedRightLeg.render(scale); + extLegRight.render(scale); + extLegLeft.render(scale); } @Override protected void initTextures() { - this.extHead = new ModelRenderer[2]; - this.extLegs = new ModelRenderer[2]; - this.initHeadTextures(); - this.initBodyTextures(); - this.initLegTextures(); + initHeadTextures(); + initBodyTextures(); + initLegTextures(); } @Override protected void initHeadTextures() { - this.bipedHead = new ModelRenderer(this, 0, 0); - this.bipedHeadwear = new ModelRenderer(this, 32, 0); - this.extHead[0] = new ModelRenderer(this, 0, 0); - this.extHead[1] = new ModelRenderer(this, 0, 4); + bipedHead = new ModelRenderer(this, 0, 0); + bipedHeadwear = new ModelRenderer(this, 32, 0); + extHead = new PonyRenderer(this, 0, 0); } @Override protected void initBodyTextures() { - this.bipedBody = new ModelRenderer(this, 16, 16); - this.Bodypiece = new ModelRenderer(this, 0, 0); - this.extBody = new ModelRenderer(this, 16, 8); + bipedBody = new PonyRenderer(this, 16, 16); + Bodypiece = new PonyRenderer(this, 0, 0); + extBody = new PonyRenderer(this, 16, 8); } @Override protected void initLegTextures() { - this.bipedRightArm = new ModelRenderer(this, 0, 16); + bipedRightArm = new PonyRenderer(this, 0, 16); + bipedRightLeg = new ModelRenderer(this, 0, 16); - this.bipedLeftArm = new ModelRenderer(this, 0, 16); - this.bipedLeftArm.mirror = true; - - this.bipedLeftLeg = new ModelRenderer(this, 0, 16); - this.bipedLeftLeg.mirror = true; - - this.bipedRightLeg = new ModelRenderer(this, 0, 16); - - - this.unicornArmRight = new ModelRenderer(this, 0, 16); - this.unicornArmLeft = new ModelRenderer(this, 0, 16); - - this.extLegs[0] = new ModelRenderer(this, 48, 8); - this.extLegs[1] = new ModelRenderer(this, 48, 8); - this.extLegs[1].mirror = true; + bipedLeftArm = new PonyRenderer(this, 0, 16).mirror(); + bipedLeftLeg = new PonyRenderer(this, 0, 16).mirror(); + + unicornArmRight = new PonyRenderer(this, 0, 16); + unicornArmLeft = new PonyRenderer(this, 0, 16); + + extLegLeft = new PonyRenderer(this, 48, 8); + extLegRight = new PonyRenderer(this, 48, 8); } @Override - protected void initPositions(float yOffset, float stretch) { - this.initHeadPositions(yOffset, stretch); - this.initBodyPositions(yOffset, stretch); - this.initLegPositions(yOffset, stretch); + protected void initTailPositions(float yOffset, float stretch) { + } @Override protected void initHeadPositions(float yOffset, float stretch) { - this.bipedHead .addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch * 1.1F); - this.bipedHeadwear .addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch * 1.1F + 0.5F); + bipedHead .addBox(HEAD_CENTRE_X - 4, HEAD_CENTRE_Y - 4, HEAD_CENTRE_Z - 4, 8, 8, 8, stretch * 1.1F); + bipedHeadwear.addBox(HEAD_CENTRE_X - 4, HEAD_CENTRE_Y - 4, HEAD_CENTRE_Z - 4, 8, 8, 8, stretch * 1.1F + 0.5F); - this.extHead[0].addBox(-4.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch * 0.5F); - this.extHead[1].addBox(2.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch * 0.5F); + extHead.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .box(-4, -6, 1, 2, 2, 2, stretch * 0.5F) + .tex(0, 4).box( 2, -6, 1, 2, 2, 2, stretch * 0.5F); - this.bipedHead .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.bipedHeadwear .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.extHead[0] .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.extHead[1] .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + bipedHead .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); } @Override protected void initBodyPositions(float yOffset, float stretch) { - this.bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch); - this.Bodypiece.addBox(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch); - this.extBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 16, stretch); - - this.bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.Bodypiece.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.extBody .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch); + + Bodypiece.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .box(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch); + extBody.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .box(-4.0F, 4.0F, -2.0F, 8, 8, 16, stretch); } @Override protected void initLegPositions(float yOffset, float stretch) { super.initLegPositions(yOffset, stretch); - this.extLegs[0].addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); - this.extLegs[1].addBox(-2.0F + THIRDP_ARM_CENTRE_X, -6.0F + THIRDP_ARM_CENTRE_Y, -2.0F + THIRDP_ARM_CENTRE_Z, 4, 12, 4, stretch); - - this.extLegs[0].setRotationPoint(-3.0F, 0.0F + yOffset, 0.0F); - this.extLegs[1].setRotationPoint(3.0F, 0.0F + yOffset, 0.0F); + extLegLeft.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) + .around(-3, yOffset, 0) + .box(-2, -6, -2, 4, 12, 4, stretch); + extLegRight.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) + .around(3, yOffset, 0) + .mirror().box(-2, -6, -2, 4, 12, 4, stretch); } protected void syncLegs() { - this.extLegs[0].rotateAngleX = this.bipedRightLeg.rotateAngleX; - this.extLegs[0].rotateAngleY = this.bipedRightLeg.rotateAngleY; - this.extLegs[0].rotateAngleZ = this.bipedRightLeg.rotateAngleZ; - - this.extLegs[0].rotationPointX = this.bipedRightLeg.rotationPointX; - this.extLegs[0].rotationPointY = this.bipedRightLeg.rotationPointY; - this.extLegs[0].rotationPointZ = this.bipedRightLeg.rotationPointZ; - - this.extLegs[1].rotateAngleX = this.bipedLeftLeg.rotateAngleX; - this.extLegs[1].rotateAngleY = this.bipedLeftLeg.rotateAngleY; - this.extLegs[1].rotateAngleZ = this.bipedLeftLeg.rotateAngleZ; - - this.extLegs[1].rotationPointX = this.bipedLeftLeg.rotationPointX; - this.extLegs[1].rotationPointY = this.bipedLeftLeg.rotationPointY; - this.extLegs[1].rotationPointZ = this.bipedLeftLeg.rotationPointZ; + extLegRight.rotateAt(bipedRightLeg).rotateTo(bipedRightLeg); + extLegLeft.rotateAt(bipedLeftLeg).rotateTo(bipedLeftLeg); } @Override protected void rotateLegs(float move, float swing, float tick, Entity entity) { super.rotateLegs(move, swing, tick, entity); - this.syncLegs(); + syncLegs(); } @Override protected void adjustLegs() { super.adjustLegs(); - this.syncLegs(); + syncLegs(); } @Override protected void sneakLegs() { super.sneakLegs(); - this.syncLegs(); + syncLegs(); } @Override protected void ponySleep() { super.ponySleep(); - this.syncLegs(); + syncLegs(); } public void setVisible(boolean invisible) { super.setVisible(invisible); - this.Bodypiece.showModel = invisible; + Bodypiece.showModel = invisible; extBody.showModel = invisible; - for (ModelRenderer m : extHead) { - m.showModel = invisible; - } - for (ModelRenderer m : extLegs) { - m.showModel = invisible; - } + extHead.showModel = invisible; + extLegLeft.showModel = invisible; + extLegRight.showModel = invisible; } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java index 5375ca2f..5f1b4ffb 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -1,34 +1,23 @@ package com.minelittlepony.model.armour; +import net.minecraft.entity.Entity; + /** * Armour for skeleton ponies. * */ public class ModelSkeletonPonyArmor extends ModelPonyArmor { - /** - * The code here is copied from ModelMobPony, all with but one line of difference. - */ @Override - protected void rotateRightArm(float move, float tick) { - if (this.rightArmPose == ArmPose.EMPTY) return; - - if (!this.metadata.hasMagic()) { - rotateArmHolding(bipedRightArm, 1, swingProgress, tick); - } else { - // With everything that's happening in ModelPonyArmor, - // it's hard to tell if this is need or not. - // Testing will probably reveal all. - //unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmRight, 1, swingProgress, tick); - } + protected void rotateLegs(float move, float swing, float tick, Entity entity) { + super.rotateLegs(move, swing, tick, entity); + aimBow(leftArmPose, rightArmPose, tick); } @Override protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { - this.bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); + if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { + bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); } - } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index 65caef48..ecd6d452 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -1,5 +1,6 @@ package com.minelittlepony.model.armour; +import net.minecraft.client.model.ModelRenderer; import net.minecraft.util.math.MathHelper; public class ModelZombiePonyArmor extends ModelPonyArmor { @@ -8,10 +9,11 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { return MathHelper.sin(move / 20f) < 0; } + // Copied from ModelZombiePony @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; - + if (isRight(move)) { rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { @@ -21,16 +23,16 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { @Override protected void rotateLeftArm(float move, float tick) { - + // Zombies are unidexterous. } @Override protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { - shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); - } else { - shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); - } + if (rightArmPose != ArmPose.EMPTY) return; + boolean right = isRight(move); + float xchange = right ? 0.5f : -0.5f; + ModelRenderer arm = right ? bipedRightArm : bipedLeftArm; + + shiftRotationPoint(arm, xchange, 1.5f, 3); } } diff --git a/src/main/java/com/minelittlepony/model/components/HornGlow.java b/src/main/java/com/minelittlepony/model/components/HornGlow.java index 287b61cf..91d028f4 100644 --- a/src/main/java/com/minelittlepony/model/components/HornGlow.java +++ b/src/main/java/com/minelittlepony/model/components/HornGlow.java @@ -17,75 +17,62 @@ public class HornGlow extends ModelBox { private TexturedQuad[] quadList; - public HornGlow(HornGlowRenderer parent, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10, float alpha) { - super(parent, par2, par3, par4, par5, par6, par7, par8, par9, par10); + public HornGlow(HornGlowRenderer parent, int texU, int texV, float x, float y, float z, int w, int h, int d, float scale, float alpha) { + super(parent, texU, texV, x, y, z, w, h, d, scale); + this.parent = parent; this.alpha = alpha; this.quadList = new TexturedQuad[6]; - float var11 = par4 + par7; - float var12 = par5 + par8; - float var13 = par6 + par9; - float halfpar4 = par4 + par7 * 0.05F; - float halfpar6 = par6 + par9 * 0.05F; - float halfvar11 = par4 + par7 * 0.95F; - float halfvar13 = par6 + par9 * 0.95F; - par4 -= par10; - par5 -= par10; - par6 -= par10; - var11 += par10; - var12 += par10; - var13 += par10; + + float x2 = x + w + scale; + float y2 = y + h + scale; + float z2 = z + d + scale; + + x -= scale; + y -= scale; + z -= scale; + if (parent.mirror) { - float var26 = var11; - var11 = par4; - par4 = var26; + float f3 = x2; + x2 = x; + x = f3; } - PositionTextureVertex var32 = new PositionTextureVertex(halfpar4, par5, halfpar6, 0.0F, 0.0F); - PositionTextureVertex var15 = new PositionTextureVertex(halfvar11, par5, halfpar6, 0.0F, 8.0F); - PositionTextureVertex var16 = new PositionTextureVertex(var11, var12, par6, 8.0F, 8.0F); - PositionTextureVertex var17 = new PositionTextureVertex(par4, var12, par6, 8.0F, 0.0F); - PositionTextureVertex var18 = new PositionTextureVertex(halfpar4, par5, halfvar13, 0.0F, 0.0F); - PositionTextureVertex var19 = new PositionTextureVertex(halfvar11, par5, halfvar13, 0.0F, 8.0F); - PositionTextureVertex var20 = new PositionTextureVertex(var11, var12, var13, 8.0F, 8.0F); - PositionTextureVertex var21 = new PositionTextureVertex(par4, var12, var13, 8.0F, 0.0F); + float halfpar4 = x + w * 0.05F; + float halfpar6 = z + d * 0.05F; + float halfvar11 = x + w * 0.95F; + float halfvar13 = z + d * 0.95F; + + PositionTextureVertex p7 = new PositionTextureVertex(halfpar4, y, halfpar6, 0, 0); + PositionTextureVertex p0 = new PositionTextureVertex(halfvar11, y, halfpar6, 0, 8); + PositionTextureVertex p1 = new PositionTextureVertex(x2, y2, z, 8, 8); + PositionTextureVertex p2 = new PositionTextureVertex(x, y2, z, 8, 0); + PositionTextureVertex p3 = new PositionTextureVertex(halfpar4, y, halfvar13, 0, 0); + PositionTextureVertex p4 = new PositionTextureVertex(halfvar11, y, halfvar13, 0, 8); + PositionTextureVertex p5 = new PositionTextureVertex(x2, y2, z2, 8, 8); + PositionTextureVertex p6 = new PositionTextureVertex(x, y2, z2, 8, 0); - this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{var19, var15, var16, var20}, - par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, - parent.textureWidth, parent.textureHeight); - this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{var32, var18, var21, var17}, par2, - par3 + par9, par2 + par9, par3 + par9 + par8, parent.textureWidth, - parent.textureHeight); - this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{var19, var18, var32, var15}, par2 + par9, - par3, par2 + par9 + par7, par3 + par9, parent.textureWidth, parent.textureHeight); - this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{var16, var17, var21, var20}, - par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, parent.textureWidth, - parent.textureHeight); - this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{var15, var32, var17, var16}, par2 + par9, - par3 + par9, par2 + par9 + par7, par3 + par9 + par8, parent.textureWidth, - parent.textureHeight); - this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{var18, var19, var20, var21}, - par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, - parent.textureWidth, parent.textureHeight); + this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{p4, p0, p1, p5}, texU + d + w, texV + d, texU + d + w + d, texV + d + h, parent.textureWidth, parent.textureHeight); + this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{p7, p3, p6, p2}, texU, texV + d, texU + d, texV + d + h, parent.textureWidth, parent.textureHeight); + this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{p4, p3, p7, p0}, texU + d, texV, texU + d + w, texV + d, parent.textureWidth, parent.textureHeight); + this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{p1, p2, p6, p5}, texU + d + w, texV + d, texU + d + w + w, texV, parent.textureWidth, parent.textureHeight); + this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{p0, p7, p2, p1}, texU + d, texV + d, texU + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); + this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{p3, p4, p5, p6}, texU + d + w + d, texV + d, texU + d + w + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); + if (parent.mirror) { - TexturedQuad[] var22 = this.quadList; - - for (TexturedQuad var25 : var22) { - var25.flipFace(); + for (TexturedQuad i : quadList) { + i.flipFace(); } } - } @Override - public void render(@Nonnull BufferBuilder buffer, float par2) { + public void render(@Nonnull BufferBuilder buffer, float scale) { parent.applyTint(alpha); - TexturedQuad[] var3 = this.quadList; - for (TexturedQuad var6 : var3) { - var6.draw(buffer, par2); + for (TexturedQuad i : quadList) { + i.draw(buffer, scale); } - } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 6ec1c354..3eda4fc2 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -8,12 +8,12 @@ import com.minelittlepony.model.components.PegasusWings; import com.minelittlepony.model.components.PonySnout; import com.minelittlepony.model.components.PonyTail; import com.minelittlepony.model.components.UnicornHorn; +import com.minelittlepony.render.PonyRenderer; import com.minelittlepony.render.plane.PlaneRenderer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; @@ -24,16 +24,15 @@ import static com.minelittlepony.model.PonyModelConstants.*; public class ModelPlayerPony extends AbstractPonyModel { private final boolean smallArms; - public boolean rainboom; - + public ModelRenderer bipedCape; - public PlaneRenderer[] Bodypiece; - public PlaneRenderer BodypieceNeck; + public PlaneRenderer upperTorso; + public PlaneRenderer neck; - public ModelRenderer unicornArmRight, unicornArmLeft; + public PonyRenderer unicornArmRight, unicornArmLeft; - public PonyTail Tail; + public PonyTail tail; public PonySnout snout; public UnicornHorn horn; public PegasusWings wings; @@ -70,73 +69,63 @@ public class ModelPlayerPony extends AbstractPonyModel { rotateLook(limbSwing, limbSwingAmount, bodySwingRotation, ageInTicks); - this.setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn); - this.holdItem(limbSwingAmount); - this.swingItem(entityIn, this.swingProgress); - if (this.isSneak && !this.isFlying && !this.rainboom) { - this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); - this.sneakLegs(); - this.setHead(0.0F, 6.0F, -2.0F); - } else if (this.isRiding) { + setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn); + holdItem(limbSwingAmount); + swingItem(entityIn, swingProgress); + + if (isCrouching() && !rainboom) { + adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); + sneakLegs(); + setHead(0, 6, -2); + } else if (isRiding) { this.adjustBodyRiding(); - this.bipedLeftLeg.rotationPointZ = 15; - this.bipedLeftLeg.rotationPointY = 10; - this.bipedLeftLeg.rotateAngleX = (float) (Math.PI * -0.25); - this.bipedLeftLeg.rotateAngleY = (float) (Math.PI * -0.2); + bipedLeftLeg.rotationPointZ = 15; + bipedLeftLeg.rotationPointY = 10; + bipedLeftLeg.rotateAngleX = -PI / 4; + bipedLeftLeg.rotateAngleY = -PI / 5; - this.bipedRightLeg.rotationPointZ = 15; - this.bipedRightLeg.rotationPointY = 10; - this.bipedRightLeg.rotateAngleX = (float) (Math.PI * -0.25); - this.bipedRightLeg.rotateAngleY = (float) (Math.PI * 0.2); + bipedRightLeg.rotationPointZ = 15; + bipedRightLeg.rotationPointY = 10; + bipedRightLeg.rotateAngleX = -PI / 4; + bipedRightLeg.rotateAngleY = PI / 5; - this.bipedLeftArm.rotateAngleZ = (float) (Math.PI * -0.06); - this.bipedRightArm.rotateAngleZ = (float) (Math.PI * 0.06); + bipedLeftArm.rotateAngleZ = -PI * 0.06f; + bipedRightArm.rotateAngleZ = PI * 0.06f; } else { + adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - this.adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - - this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - this.swingArms(ageInTicks); - this.setHead(0.0F, 0.0F, 0.0F); + bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; + bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; + swingArms(ageInTicks); + setHead(0, 0, 0); } - if (this.isSleeping) { - this.ponySleep(); - } + if (isSleeping) ponySleep(); - this.aimBow(leftArmPose, rightArmPose, ageInTicks); - - this.fixSpecialRotations(); - this.fixSpecialRotationPoints(limbSwing); + aimBow(leftArmPose, rightArmPose, ageInTicks); + fixSpecialRotationPoints(limbSwing); animateWears(); - this.bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; + bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; - this.snout.setGender(this.metadata.getGender()); - this.wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + snout.setGender(metadata.getGender()); + wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); } protected void adjustBodyRiding() { - this.adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); - this.adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - this.setHead(0.0F, 0.0F, 0.0F); + adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); + adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); + setHead(0, 0, 0); } protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { - this.Tail.setRotationAndAngles(rainboom, limbSwing, limbSwingAmount, bodySwing, ticks); + tail.setRotationAndAngles(rainboom, limbSwing, limbSwingAmount, bodySwing, ticks); + bodySwing /= 5; - for (PlaneRenderer i : this.Bodypiece) { - i.rotateAngleY = bodySwing * 0.2F; - } - - this.bipedBody.rotateAngleY = bodySwing * 0.2F; - this.BodypieceNeck.rotateAngleY = bodySwing * 0.2F; - this.bipedHead.offsetY = 0f; - this.bipedHead.offsetZ = 0f; - this.bipedHeadwear.offsetY = 0f; - this.bipedHeadwear.offsetZ = 0f; + upperTorso.rotateAngleY = bodySwing; + bipedBody.rotateAngleY = bodySwing; + neck.rotateAngleY = bodySwing; } private void animateWears() { @@ -147,56 +136,57 @@ public class ModelPlayerPony extends AbstractPonyModel { copyModelAngles(bipedBody, bipedBodyWear); } + /** + * Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast. + */ protected void checkRainboom(Entity entity, float swing) { - boolean flying = this.metadata.getRace().hasWings() && this.isFlying - || entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying(); - - this.rainboom = flying && swing >= 0.9999F; + rainboom = isFlying(entity) && swing >= 0.9999F; } + /** + * Sets the head rotation angle. + */ protected void setHead(float posX, float posY, float posZ) { - this.bipedHead.setRotationPoint(posX, posY, posZ); - this.bipedHeadwear.setRotationPoint(posX, posY, posZ); + bipedHead.setRotationPoint(posX, posY, posZ); + bipedHeadwear.setRotationPoint(posX, posY, posZ); } - protected void rotateHead(float horz, float vert) { - float headRotateAngleY; - float headRotateAngleX; - if (this.isSleeping) { - headRotateAngleY = 1.4F; - headRotateAngleX = 0.1F; - } else { - headRotateAngleY = horz / 57.29578F; - headRotateAngleX = vert / 57.29578F; - } - - final float max = (float) (0.5f - Math.toRadians(this.motionPitch)); - final float min = (float) (-1.25f - Math.toRadians(this.motionPitch)); - headRotateAngleX = Math.min(headRotateAngleX, max); - headRotateAngleX = Math.max(headRotateAngleX, min); - this.bipedHead.rotateAngleY = headRotateAngleY; - this.bipedHead.rotateAngleX = headRotateAngleX; - this.bipedHeadwear.rotateAngleY = headRotateAngleY; - this.bipedHeadwear.rotateAngleX = headRotateAngleX; + /** + * Rotates the head within reason. X is clamped to around motionPitch. + * Both arguments are also ignored when sleeping. + */ + private void rotateHead(float horz, float vert) { + float headRotateAngleY = isSleeping ? 1.4f : horz / 57.29578F; + float headRotateAngleX = isSleeping ? 0.1f : vert / 57.29578F; + + headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); + headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch))); + + updateHeadRotation(headRotateAngleX, headRotateAngleY); + } + + /** + * Called to update the head rotation. + * + * @param x New rotation X + * @param y New rotation Y + */ + protected void updateHeadRotation(float x, float y) { + bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y; + bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; } protected void setLegs(float move, float swing, float tick, Entity entity) { - this.rotateLegs(move, swing, tick, entity); - this.adjustLegs(); + rotateLegs(move, swing, tick, entity); + adjustLegs(); } - public boolean isFlying(Entity entity) { - return (isFlying && metadata.getRace().hasWings()) || - (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()); - } - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float leftArm, rightArm, - leftLeg, rightLeg; + float leftArm, rightArm, leftLeg, rightLeg; if (isFlying(entity)) { - if (this.rainboom) { + if (rainboom) { rightArm = leftArm = ROTATE_270; rightLeg = leftLeg = ROTATE_90; } else { @@ -207,10 +197,9 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightArm.rotateAngleY = 0.2F; bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; - this.bipedLeftLeg.rotateAngleY = 0.2F; + bipedLeftLeg.rotateAngleY = 0.2F; } else { - float PI = (float)Math.PI; float pi = PI * (float) Math.pow(swing, 16); float mve = move * 0.6662F; // magic number ahoy @@ -221,34 +210,31 @@ public class ModelPlayerPony extends AbstractPonyModel { leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; - - this.bipedRightArm.rotateAngleY = 0; - - this.bipedLeftArm.rotateAngleY = 0; - this.bipedRightLeg.rotateAngleY = 0; - this.bipedLeftLeg.rotateAngleY = 0; - this.unicornArmRight.rotateAngleY = 0; - this.unicornArmLeft.rotateAngleY = 0; + bipedLeftArm.rotateAngleY = 0; + bipedRightArm.rotateAngleY = 0; + + bipedLeftLeg.rotateAngleY = 0; + bipedRightLeg.rotateAngleY = 0; + + unicornArmRight.rotateAngleY = 0; + unicornArmLeft.rotateAngleY = 0; } - - - - - this.bipedLeftArm.rotateAngleX = leftArm; - this.bipedRightArm.rotateAngleX = rightArm; - - this.bipedLeftArm.rotateAngleZ = 0; - this.bipedRightArm.rotateAngleZ = 0; - - this.bipedLeftLeg.rotateAngleX = leftLeg; - this.bipedRightLeg.rotateAngleX = rightLeg; - - this.unicornArmRight.rotateAngleX = 0; - this.unicornArmLeft.rotateAngleX = 0; - this.unicornArmRight.rotateAngleZ = 0; - this.unicornArmLeft.rotateAngleZ = 0; + bipedLeftArm.rotateAngleX = leftArm; + bipedRightArm.rotateAngleX = rightArm; + + bipedLeftLeg.rotateAngleX = leftLeg; + bipedRightLeg.rotateAngleX = rightLeg; + + bipedLeftArm.rotateAngleZ = 0; + bipedRightArm.rotateAngleZ = 0; + + unicornArmLeft.rotateAngleZ = 0; + unicornArmRight.rotateAngleZ = 0; + + unicornArmLeft.rotateAngleX = 0; + unicornArmRight.rotateAngleX = 0; } private float getLegOutset() { @@ -292,16 +278,17 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void holdItem(float swing) { - if (!this.rainboom && !this.metadata.hasMagic()) { - boolean bothHoovesAreOccupied = this.leftArmPose == ArmPose.ITEM && this.rightArmPose == ArmPose.ITEM; - alignArmForAction(bipedLeftArm, leftArmPose, bothHoovesAreOccupied, swing); - alignArmForAction(bipedRightArm, rightArmPose, bothHoovesAreOccupied, swing); - } else if (this.metadata.hasMagic()) { - if (this.leftArmPose == ArmPose.BLOCK) blockArm(unicornArmLeft); - if (this.rightArmPose == ArmPose.BLOCK) blockArm(unicornArmRight); + boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; + + if (!rainboom && !metadata.hasMagic()) { + alignArmForAction(bipedLeftArm, leftArmPose, both, swing); + alignArmForAction(bipedRightArm, rightArmPose, both, swing); + } else if (metadata.hasMagic()) { + alignArmForAction(unicornArmLeft, leftArmPose, both, swing); + alignArmForAction(unicornArmRight, rightArmPose, both, swing); } - this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); + horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); } private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { @@ -309,42 +296,42 @@ public class ModelPlayerPony extends AbstractPonyModel { case ITEM: float swag = 1; if (!isFlying && both) { - swag = (float) (1 - Math.pow(swing, 2)); + swag -= (float)Math.pow(swing, 2); } - float mult = 0.5f + (1 - swag)/2; - arm.rotateAngleX = this.bipedLeftArm.rotateAngleX * mult - ((float) Math.PI / 10) * swag; + float mult = 1 - swag/2f; + arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag; case EMPTY: arm.rotateAngleY = 0; break; case BLOCK: - arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; - arm.rotateAngleY = (float) (Math.PI / 6); + blockArm(arm); break; default: } } private void blockArm(ModelRenderer arm) { - arm.rotateAngleX = arm.rotateAngleX * 0.5F - 0.9424779F; - arm.rotateAngleY = (float) (Math.PI / 6); + arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; + arm.rotateAngleY = PI / 6; } protected void swingItem(Entity entity, float swingProgress) { if (swingProgress > -9990.0F && !this.isSleeping) { - float f16 = 1.0F - swingProgress; - f16 *= f16 * f16; - f16 = 1.0F - f16; - float f22 = MathHelper.sin(f16 * 3.1415927F); - float f28 = MathHelper.sin(swingProgress * 3.1415927F); - float f33 = f28 * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; - EnumHandSide mainSide = this.getMainHand(entity); - boolean mainRight = mainSide == EnumHandSide.RIGHT; - ArmPose mainPose = mainRight ? this.rightArmPose : this.leftArmPose; + ArmPose mainPose = mainRight ? rightArmPose : leftArmPose; - if (this.metadata.hasMagic() && mainPose != ArmPose.EMPTY) { - swingArm(mainRight ? this.unicornArmRight : this.unicornArmLeft, f22, f33, f28); + if (mainPose == ArmPose.EMPTY) return; + + float f16 = 1 - swingProgress; + f16 *= f16 * f16; + f16 = 1 - f16; + float f22 = MathHelper.sin(f16 * PI); + float f28 = MathHelper.sin(swingProgress * PI); + float f33 = f28 * (0.7F - bipedHead.rotateAngleX) * 0.75F; + + if (metadata.hasMagic()) { + swingArm(mainRight ? unicornArmRight : unicornArmLeft, f22, f33, f28); } else { swingArm(getArmForSide(mainSide), f22, f33, f28); } @@ -388,54 +375,44 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { - this.bipedBody.rotateAngleX = rotateAngleX; - this.bipedBody.rotationPointY = rotationPointY; - this.bipedBody.rotationPointZ = rotationPointZ; + bipedBody.rotateAngleX = rotateAngleX; + bipedBody.rotationPointY = rotationPointY; + bipedBody.rotationPointZ = rotationPointZ; - for (PlaneRenderer i : Bodypiece) { - i.rotateAngleX = rotateAngleX; - i.rotationPointY = rotationPointY; - i.rotationPointZ = rotationPointZ; - } + upperTorso.rotateAngleX = rotateAngleX; + upperTorso.rotationPointY = rotationPointY; + upperTorso.rotationPointZ = rotationPointZ; } protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { - BodypieceNeck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); + neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); } + /** + * Aligns legs to a sneaky position. + */ protected void sneakLegs() { - this.unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - this.bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - - this.bipedLeftLeg.rotationPointY = this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; + bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; + bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; + + bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; } protected void ponySleep() { - this.bipedRightArm.rotateAngleX = ROTATE_270; - this.bipedLeftArm.rotateAngleX = ROTATE_270; - this.bipedRightLeg.rotateAngleX = ROTATE_90; - this.bipedLeftLeg.rotateAngleX = ROTATE_90; + bipedRightArm.rotateAngleX = ROTATE_270; + bipedLeftArm.rotateAngleX = ROTATE_270; + bipedRightLeg.rotateAngleX = ROTATE_90; + bipedLeftLeg.rotateAngleX = ROTATE_90; - float headPosX, headPosY, headPosZ; + setHead(1, 2, isSneak ? -1 : 1); - if (this.isSneak) { - headPosY = 2; - headPosZ = -1; - headPosX = 1; - } else { - headPosY = 2; - headPosZ = 1; - headPosX = 1; - } - - this.setHead(headPosX, headPosY, headPosZ); - shiftRotationPoint(this.bipedRightArm, 0.0F, 2.0F, 6.0F); - shiftRotationPoint(this.bipedLeftArm, 0.0F, 2.0F, 6.0F); - shiftRotationPoint(this.bipedRightLeg, 0.0F, 2.0F, -8.0F); - shiftRotationPoint(this.bipedLeftLeg, 0.0F, 2.0F, -8.0F); + shiftRotationPoint(bipedRightArm, 0, 2, 6); + shiftRotationPoint(bipedLeftArm, 0, 2, 6); + shiftRotationPoint(bipedRightLeg, 0, 2, -8); + shiftRotationPoint(bipedLeftLeg, 0, 2, -8); } protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { @@ -452,20 +429,12 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) { - arm.rotateAngleZ = 0.0F; - arm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; - arm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; + arm.rotateAngleZ = 0; + arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; + arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - if (shift) shiftRotationPoint(arm, 0.0F, 0.0F, 1.0F); - } - - protected void fixSpecialRotations() { - this.Bodypiece[9].rotateAngleX += 0.5F; - this.Bodypiece[10].rotateAngleX += 0.5F; - this.Bodypiece[11].rotateAngleX += 0.5F; - this.Bodypiece[12].rotateAngleX += 0.5F; - this.Bodypiece[13].rotateAngleX += 0.5F; + if (shift) shiftRotationPoint(arm, 0, 0, 1); } protected void fixSpecialRotationPoints(float move) { @@ -473,199 +442,177 @@ public class ModelPlayerPony extends AbstractPonyModel { @Override public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - + pushMatrix(); - this.transform(BodyPart.HEAD); - this.renderHead(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + transform(BodyPart.HEAD); + renderHead(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); popMatrix(); pushMatrix(); - this.transform(BodyPart.NECK); - this.renderNeck(); + transform(BodyPart.NECK); + renderNeck(); popMatrix(); pushMatrix(); - this.transform(BodyPart.BODY); - this.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - this.Tail.render(this.metadata.getTail(), this.scale); + transform(BodyPart.BODY); + renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + tail.render(metadata.getTail(), scale); popMatrix(); pushMatrix(); - this.transform(BodyPart.LEGS); - this.renderLegs(); + transform(BodyPart.LEGS); + renderLegs(); popMatrix(); } 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); - this.horn.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - + bipedHead.render(scale); + bipedHeadwear.render(scale); + bipedHead.postRender(scale); + horn.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); } protected void renderNeck() { GlStateManager.scale(0.9, 0.9, 0.9); - this.BodypieceNeck.render(this.scale); + neck.render(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); + bipedBody.render(scale); + if (textureHeight == 64) { + bipedBodyWear.render(scale); } - for (PlaneRenderer aBodypiece : this.Bodypiece) { - aBodypiece.render(this.scale); - } - this.bipedBody.postRender(scale); - this.wings.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, this.scale); + upperTorso.render(scale); + bipedBody.postRender(scale); + wings.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); } protected void renderLegs() { - if (!this.isSneak) { - this.bipedBody.postRender(this.scale); - } + if (!isSneak) bipedBody.postRender(scale); - this.bipedLeftArm.render(this.scale); - this.bipedRightArm.render(this.scale); - this.bipedLeftLeg.render(this.scale); - this.bipedRightLeg.render(this.scale); + bipedLeftArm.render(scale); + bipedRightArm.render(scale); + bipedLeftLeg.render(scale); + bipedRightLeg.render(scale); - if (this.textureHeight == 64) { - this.bipedLeftArmwear.render(this.scale); - this.bipedRightArmwear.render(this.scale); - this.bipedLeftLegwear.render(this.scale); - this.bipedRightLegwear.render(this.scale); + if (textureHeight == 64) { + bipedLeftArmwear.render(scale); + bipedRightArmwear.render(scale); + bipedLeftLegwear.render(scale); + bipedRightLegwear.render(scale); } } @Override protected void initTextures() { - this.boxList.clear(); - this.Bodypiece = new PlaneRenderer[14]; - this.initHeadTextures(); - this.initBodyTextures(); - this.initLegTextures(); - this.Tail = new PonyTail(this); + boxList.clear(); + initHeadTextures(); + initBodyTextures(); + initLegTextures(); + tail = new PonyTail(this); } protected void initHeadTextures() { - this.bipedCape = new ModelRenderer(this, 0, 0).setTextureSize(64, 32); - this.bipedHead = new ModelRenderer(this, 0, 0); - this.bipedHeadwear = new ModelRenderer(this, 32, 0); + bipedCape = new PonyRenderer(this, 0, 0).size(64, 32); + bipedHead = new PonyRenderer(this, 0, 0); + bipedHeadwear = new PonyRenderer(this, 32, 0); } protected void initBodyTextures() { - this.bipedBody = new ModelRenderer(this, 16, 16); + bipedBody = new ModelRenderer(this, 16, 16); - if (this.textureHeight == 64) { - this.bipedBodyWear = new ModelRenderer(this, 16, 32); + if (textureHeight == 64) { + bipedBodyWear = new ModelRenderer(this, 16, 32); } - this.Bodypiece[0] = new PlaneRenderer(this, 24, 0); - this.Bodypiece[0].mirrorz = true; - - this.Bodypiece[1] = new PlaneRenderer(this, 24, 0); - - this.Bodypiece[2] = new PlaneRenderer(this, 32, 20); - this.Bodypiece[2].mirrorz = true; - - this.Bodypiece[3] = new PlaneRenderer(this, 56, 0); - - this.Bodypiece[4] = new PlaneRenderer(this, 4, 0); - this.Bodypiece[4].mirrorz = true; - - this.Bodypiece[5] = new PlaneRenderer(this, 4, 0); - - this.Bodypiece[6] = new PlaneRenderer(this, 36, 16); - this.Bodypiece[7] = new PlaneRenderer(this, 36, 16); - this.Bodypiece[8] = new PlaneRenderer(this, 36, 16); - - this.Bodypiece[11] = new PlaneRenderer(this, 32, 0); - this.Bodypiece[11].mirror = true; - - this.Bodypiece[9] = new PlaneRenderer(this, 32, 0); - this.Bodypiece[10] = new PlaneRenderer(this, 32, 0); - this.Bodypiece[12] = new PlaneRenderer(this, 32, 0); - this.Bodypiece[13] = new PlaneRenderer(this, 32, 0); - - this.BodypieceNeck = new PlaneRenderer(this, 0, 16); - + upperTorso = new PlaneRenderer(this, 24, 0); + neck = new PlaneRenderer(this, 0, 16); } protected void initLegTextures() { - this.bipedRightArm = new ModelRenderer(this, 40, 16); - this.bipedRightLeg = new ModelRenderer(this, 0, 16); + bipedRightArm = new ModelRenderer(this, 40, 16); + bipedRightLeg = new ModelRenderer(this, 0, 16); - this.bipedLeftArm = new ModelRenderer(this, 32, 48); - this.bipedLeftLeg = new ModelRenderer(this, 16, 48); + bipedLeftArm = new ModelRenderer(this, 32, 48); + bipedLeftLeg = new ModelRenderer(this, 16, 48); - this.bipedRightArmwear = new ModelRenderer(this, 40, 32); - this.bipedRightLegwear = new ModelRenderer(this, 0, 32); + bipedRightArmwear = new ModelRenderer(this, 40, 32); + bipedRightLegwear = new ModelRenderer(this, 0, 32); - this.bipedLeftArmwear = new ModelRenderer(this, 48, 48); - this.bipedLeftLegwear = new ModelRenderer(this, 0, 48); + bipedLeftArmwear = new ModelRenderer(this, 48, 48); + bipedLeftLegwear = new ModelRenderer(this, 0, 48); - this.unicornArmRight = new ModelRenderer(this, 40, 32).setTextureSize(64, 64); - this.unicornArmLeft = new ModelRenderer(this, 40, 32).setTextureSize(64, 64); + unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); + unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); - this.boxList.remove(this.unicornArmRight); + boxList.remove(unicornArmRight); } @Override protected void initPositions(float yOffset, float stretch) { - this.initHeadPositions(yOffset, stretch); - this.initBodyPositions(yOffset, stretch); - this.initLegPositions(yOffset, stretch); - this.Tail.init(yOffset, stretch); + initHeadPositions(yOffset, stretch); + initBodyPositions(yOffset, stretch); + initLegPositions(yOffset, stretch); + initTailPositions(yOffset, stretch); + } + + protected void initTailPositions(float yOffset, float stretch) { + tail.init(yOffset, stretch); } protected void initHeadPositions(float yOffset, float stretch) { - this.bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); - this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -4 + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch); - this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2); - // set ears - this.bipedHead.setTextureOffset(12, 16); - this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch); - this.bipedHead.mirror = true; - this.bipedHead.addBox(2.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch); - - this.bipedHeadwear.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch + 0.5F); - this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2); + bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); + + ((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .box(-4, -4, -4, 8, 8, 8, stretch) + .tex(12, 16) + .box(-4, -6, 1, 2, 2, 2, stretch) + .mirror() + .box(2, -6, 1, 2, 2, 2, stretch); + + ((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .box(-4, -4, -4, 8, 8, 8, stretch + 0.5F); } + /** + * Creates the main torso and neck. + */ protected void initBodyPositions(float yOffset, float stretch) { - this.bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch); - this.bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - 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, 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[2].addTopPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, -4.0F + BODY_CENTRE_Z, 8, 12, 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[4].addWestPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 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[6].addBackPlane(-4.0F + BODY_CENTRE_X, -4.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 8, 4, 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[8].addBottomPlane(-4.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, 4.0F + BODY_CENTRE_Z, 8, 4, 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[10].addBottomPlane(-1.0F + BODY_CENTRE_X, 4.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 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[12].addEastPlane(1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 2.0F + BODY_CENTRE_Z, 2, 6, stretch); - this.Bodypiece[13].addBackPlane(-1.0F + BODY_CENTRE_X, 2.0F + BODY_CENTRE_Y, 8.0F + BODY_CENTRE_Z, 2, 2, stretch); + bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch); + bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - for (int i = 0; i < this.Bodypiece.length; i++) { - this.Bodypiece[i].setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - } - - this.BodypieceNeck.addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); - this.BodypieceNeck.addBackPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -4.8F + BODY_CENTRE_Z, 4, 4, stretch); - this.BodypieceNeck.addEastPlane(2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); - this.BodypieceNeck.addWestPlane(-2.0F + BODY_CENTRE_X, -6.8F + BODY_CENTRE_Y, -8.8F + BODY_CENTRE_Z, 4, 4, stretch); + bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); + bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.BodypieceNeck.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - this.BodypieceNeck.rotateAngleX = NECK_ROT_X; + upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch) + .tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch) + .tex(4, 0) .addEastPlane( 4, -4, 4, 8, 4, stretch) + .tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch) + .addBackPlane(-4, 0, 8, 8, 4, stretch) + .addBottomPlane(-4, 4, 4, 8, 4, stretch) + .flipZ().tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch) + .tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch) + .tex(4, 0) .addWestPlane(-4, -4, 4, 8, 4, stretch) + // Tail stub + .child(0) + .tex(32, 0).addTopPlane(-1, 2, 2, 2, 6, stretch) + .addBottomPlane(-1, 4, 2, 2, 6, stretch) + .addEastPlane( 1, 2, 2, 2, 6, stretch) + .addBackPlane(-1, 2, 8, 2, 2, stretch) + .flipZ().addWestPlane(-1, 2, 2, 2, 6, stretch) + .rotateAngleX = 0.5F; + + neck.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .addFrontPlane(0, 0, 0, 4, 4, stretch) + .addBackPlane(0, 0, 4, 4, 4, stretch) + .addEastPlane(4, 0, 0, 4, 4, stretch) + .addWestPlane(0, 0, 0, 4, 4, stretch) + .rotateAngleX = NECK_ROT_X; } protected void initLegPositions(float yOffset, float stretch) { @@ -677,47 +624,47 @@ public class ModelPlayerPony extends AbstractPonyModel { float armY = THIRDP_ARM_CENTRE_Y - 6; float armZ = THIRDP_ARM_CENTRE_Z - 2; - this.bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch); - this.bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch); + bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch); + bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch); - this.bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch); - this.bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch); + bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch); + bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch); - this.bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); - this.bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); + bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); + bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); - this.bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); - this.bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); + bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); + bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); if (bipedLeftArmwear != null) { - this.bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f); - this.bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); + bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f); + bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); } if (bipedRightArmwear != null) { - this.bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f); - this.bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); + bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f); + bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); } - if (this.bipedLeftLegwear != null) { - this.bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); - this.bipedRightLegwear.setRotationPoint(3, yOffset, 0); + if (bipedLeftLegwear != null) { + bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); + bipedRightLegwear.setRotationPoint(3, yOffset, 0); } if (bipedRightLegwear != null) { - this.bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); - this.bipedRightLegwear.setRotationPoint(-3, yOffset, 0); + bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); + bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } - this.unicornArmLeft .addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); - this.unicornArmRight.addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); + unicornArmLeft .addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); + unicornArmRight.addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); - this.unicornArmLeft .setRotationPoint(5, yOffset + 2, 0); - this.unicornArmRight.setRotationPoint(-5, yOffset + 2, 0); + unicornArmLeft .setRotationPoint(5, yOffset + 2, 0); + unicornArmRight.setRotationPoint(-5, yOffset + 2, 0); } @Override public void renderCape(float scale) { - this.bipedCape.render(scale); + bipedCape.render(scale); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index c13f23f4..c7e69e19 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -59,27 +59,27 @@ public class ModelSkeletonPony extends ModelMobPony { @Override protected void renderLegs() { pushMatrix(); - translate(0.05F, -0.21F, 0); - scale(0.5F, 1.15F, 0.5F); - this.bipedLeftArm.render(this.scale); + translate(0.05F, -0.21F, 0); + scale(0.5F, 1.15F, 0.5F); + bipedLeftArm.render(this.scale); popMatrix(); pushMatrix(); - translate(-0.05F, -0.21F, 0); - scale(0.5F, 1.2F, 0.5F); - this.bipedRightArm.render(this.scale); + translate(-0.05F, -0.21F, 0); + scale(0.5F, 1.2F, 0.5F); + bipedRightArm.render(this.scale); popMatrix(); pushMatrix(); - translate(0.05F, -0.21F, 0.35F); - scale(0.5F, 1.2F, 0.5F); - this.bipedLeftLeg.render(this.scale); + translate(0.05F, -0.21F, 0.35F); + scale(0.5F, 1.2F, 0.5F); + bipedLeftLeg.render(this.scale); popMatrix(); pushMatrix(); - translate(-0.05F, -0.21F, 0.35F); - scale(0.5F, 1.15F, 0.5F); - this.bipedRightLeg.render(this.scale); + translate(-0.05F, -0.21F, 0.35F); + scale(0.5F, 1.15F, 0.5F); + bipedRightLeg.render(this.scale); popMatrix(); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 5000142c..8d21c1b9 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -33,7 +33,7 @@ public class ModelVillagerPony extends ModelPlayerPony { super.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); if (entityIn instanceof EntityVillager) { - this.bipedBody.postRender(this.scale); + bipedBody.postRender(this.scale); int profession = ((EntityVillager) entityIn).getProfession(); if (profession < 2) { bag.render(scale); @@ -43,49 +43,44 @@ public class ModelVillagerPony extends ModelPlayerPony { apron.render(scale); } } + } @Override protected void initTextures() { super.initTextures(); - bag = new PlaneRenderer(this, 56, 19).at(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z); - apron = new PlaneRenderer(this, 56, 16).at(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z); - trinket = new PlaneRenderer(this, 0, 3).at(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z); + bag = new PlaneRenderer(this, 56, 19); + apron = new PlaneRenderer(this, 56, 16); + trinket = new PlaneRenderer(this, 0, 3); } @Override protected void initPositions(float yOffset, float stretch) { super.initPositions(yOffset, stretch); - bag.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - bag.setTextureOffset(56, 29); - bag.addWestPlane(-7, -5, -4, 6, 8, stretch); - bag.addWestPlane(-4, -5, -4, 6, 8, stretch); - bag.addWestPlane( 4, -5, -4, 6, 8, stretch); - bag.addWestPlane( 7, -5, -4, 6, 8, stretch); + bag.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(56, 25).addBackPlane(-7, -5, -4, 3, 6, stretch) //right bag front + .addBackPlane( 4, -5, -4, 3, 6, stretch) //left bag front + .tex(59, 25).addBackPlane(-7, -5, 4, 3, 6, stretch) //right bag back + .addBackPlane( 5, -5, 4, 3, 6, stretch) //left bag back + .tex(56, 29).addWestPlane(-7, -5, -4, 6, 8, stretch) //right bag outside + .addWestPlane( 7, -5, -4, 6, 8, stretch) //left bag outside + .addWestPlane(-4, -5, -4, 6, 8, stretch) //right bag inside + .addWestPlane( 4, -5, -4, 6, 8, stretch) //left bag inside + .tex(56, 31).addTopPlane(-4, -4.5F, -1, 8, 1, stretch) //strap front + .addTopPlane(-4, -4.5F, 0, 8, 1, stretch) //strap back + .child(0).tex(56, 16).addTopPlane(2, -5, -2, 8, 3, stretch) //right bag top + .addTopPlane(2, -5, -13, 8, 3, stretch) //left bag top + .tex(56, 22).addBottomPlane(2, 1, -2, 8, 3, stretch) //right bag bottom + .addBottomPlane(2, 1, -13, 8, 3, stretch) //left bag bottom + .rotateAngleY = 4.712389F; - PlaneRenderer rotatedPieces = new PlaneRenderer(this, 56, 16); - rotatedPieces.rotateAngleY = 4.712389F; - bag.addChild(rotatedPieces); - - rotatedPieces.addTopPlane(2, -5, -2, 8, 3, stretch); - rotatedPieces.addTopPlane(2, -5, -13, 8, 3, stretch); - rotatedPieces.setTextureOffset(56, 22); - rotatedPieces.addBottomPlane(2, 1, -2, 8, 3, stretch); - - bag.setTextureOffset(56, 22); - bag.addBottomPlane(2, 1, -13, 8, 3, stretch); - bag.setTextureOffset(56, 25); - bag.addBackPlane(-7, -5, -4, 3, 6, stretch); - bag.addBackPlane( 4, -5, -4, 3, 6, stretch); - bag.setTextureOffset(59, 25); - bag.addBackPlane(-7, -5, 4, 3, 6, stretch); - bag.addBackPlane( 5, -5, 4, 3, 6, stretch); - bag.setTextureOffset(56, 31); - bag.addTopPlane(-4, -4.5F, -1, 8, 1, stretch); - bag.addTopPlane(-4, -4.5F, 0, 8, 1, stretch); - - apron.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z).addBackPlane(-4, -4, -9, 8, 10, stretch); - trinket.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z).addBackPlane(-2, -4, -9, 4, 5, stretch); + apron.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .addBackPlane(-4, -4, -9, 8, 10, stretch); + trinket.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .addBackPlane(-2, -4, -9, 4, 5, stretch); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 9785eb4c..1612f64d 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -24,23 +24,23 @@ public class ModelZombiePony extends ModelMobPony { @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; - + if (isRight(move)) { rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); } } - + @Override protected void rotateLeftArm(float move, float tick) { - + } @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; - + if (isRight(move)) { shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); } else { diff --git a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java index 33dd2626..87bf4857 100644 --- a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java @@ -33,8 +33,8 @@ public class HornGlowRenderer extends BasePonyRenderer { } @Override - public void addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { - this.cubeList.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, a)); + public void createBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { + cubeList.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, a)); } @Override @@ -42,4 +42,9 @@ public class HornGlowRenderer extends BasePonyRenderer { super.render(scale); color(1, 1, 1, 1); } + + @Override + protected HornGlowRenderer copySelf() { + return new HornGlowRenderer(baseModel, textureOffsetX, textureOffsetY); + } } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index 1e85bfba..22dbcba4 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -9,13 +9,13 @@ import com.minelittlepony.model.armour.ModelPonyArmor; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; -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.resources.ResourcePackRepository; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.inventory.EntityEquipmentSlot.Type; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemStack; @@ -42,11 +42,12 @@ public class LayerPonyArmor extends AbstractPonyLayer { @Override public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { pony = ((IRenderPony) getRenderer()).getPlayerModel(); - 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); - + + for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) { + if (i.getSlotType() == Type.ARMOR) { + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, i); + } + } } private void renderArmor(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { @@ -134,9 +135,8 @@ public class LayerPonyArmor extends AbstractPonyLayer { model.bipedLeftArm.showModel = true; model.bipedRightLeg.showModel = !isPony; model.bipedLeftLeg.showModel = !isPony; - for (ModelRenderer extLeg : model.extLegs) { - extLeg.showModel = isPony; - } + model.extLegLeft.showModel = isPony; + model.extLegRight.showModel = isPony; break; // legs case LEGS: @@ -147,9 +147,8 @@ public class LayerPonyArmor extends AbstractPonyLayer { model.bipedBody.showModel = !isPony; model.Bodypiece.showModel = !isPony; model.extBody.showModel = isPony; - for (ModelRenderer extLeg : model.extLegs) { - extLeg.showModel = isPony; - } + model.extLegLeft.showModel = isPony; + model.extLegRight.showModel = isPony; break; // chest case CHEST: @@ -160,9 +159,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { // head case HEAD: model.bipedHead.showModel = true; - for (ModelRenderer head : model.extHead) { - head.showModel = isPony; - } + model.extHead.showModel = isPony; } } From 618a9b78bbe5670699c407906dbc361ee1455627 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 17:20:02 +0200 Subject: [PATCH 22/96] Rewrite wings - fix walking/interacting wing animation --- .../model/PonyModelConstants.java | 60 ++++----- .../model/components/ModelWing.java | 121 +++++++----------- .../model/components/PegasusWings.java | 59 ++++++--- 3 files changed, 116 insertions(+), 124 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 79aaab00..944949e3 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -13,59 +13,59 @@ public final class PonyModelConstants { NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8f, NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8f, - BODY_ROTATE_ANGLE_X_NOTSNEAK = 0.0F, + BODY_ROTATE_ANGLE_X_NOTSNEAK = 0, BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, BODY_ROTATE_ANGLE_X_RIDING = (float) (Math.PI * 3.8), - BODY_RP_Y_NOTSNEAK = 0.0F, - BODY_RP_Y_SNEAK = 7.0F, + BODY_RP_Y_NOTSNEAK = 0, + BODY_RP_Y_SNEAK = 7, BODY_RP_Y_RIDING = 1, - BODY_RP_Z_NOTSNEAK = 0.0F, - BODY_RP_Z_SNEAK = -4.0F, - BODY_RP_Z_RIDING = 4F, + BODY_RP_Z_NOTSNEAK = 0, + BODY_RP_Z_SNEAK = -4, + BODY_RP_Z_RIDING = 4, EXT_WING_ROTATE_ANGLE_X = 2.5F, - FIRSTP_ARM_CENTRE_X = -1.0F, - FIRSTP_ARM_CENTRE_Y = 4.0F, - FIRSTP_ARM_CENTRE_Z = 0.0F, + FIRSTP_ARM_CENTRE_X = -1, + FIRSTP_ARM_CENTRE_Y = 4, + FIRSTP_ARM_CENTRE_Z = 0, - FRONT_LEG_RP_Y_NOTSNEAK = 8.0F, - FRONT_LEG_RP_Y_SNEAK = 8.0F, + FRONT_LEG_RP_Y_NOTSNEAK = 8, + FRONT_LEG_RP_Y_SNEAK = 8, - HEAD_CENTRE_X = 0.0F, - HEAD_CENTRE_Y = -1.0F, - HEAD_CENTRE_Z = -2.0F, + HEAD_CENTRE_X = 0, + HEAD_CENTRE_Y = -1, + HEAD_CENTRE_Z = -2, - HEAD_RP_X = 0.0F, - HEAD_RP_Y = 0.0F, - HEAD_RP_Z = 0.0F, + HEAD_RP_X = 0, + HEAD_RP_Y = 0, + HEAD_RP_Z = 0, LEFT_WING_EXT_RP_X = 4.5F, - LEFT_WING_EXT_RP_Y = 5.0F, - LEFT_WING_EXT_RP_Z = 6.0F, + LEFT_WING_EXT_RP_Y = 6, + LEFT_WING_EXT_RP_Z = 6, - LEFT_WING_ROTATE_ANGLE_Z_SNEAK = -6.0F, + LEFT_WING_ROTATE_ANGLE_Z_SNEAK = 4, ROTATE_270 = 4.712F, ROTATE_90 = 1.571F, SNEAK_LEG_X_ROTATION_ADJUSTMENT = 0.4F, - TAIL_RP_X = 0.0F, - TAIL_RP_Y = 0.0F, - TAIL_RP_Z = 0.0F, + TAIL_RP_X = 0, + TAIL_RP_Y = 0, + TAIL_RP_Z = 0, - TAIL_RP_Z_NOTSNEAK = 14.0F, - TAIL_RP_Z_SNEAK = 15.0F, + TAIL_RP_Z_NOTSNEAK = 14, + TAIL_RP_Z_SNEAK = 15, - THIRDP_ARM_CENTRE_X = 0.0F, - THIRDP_ARM_CENTRE_Y = 10.0F, - THIRDP_ARM_CENTRE_Z = 0.0F, + THIRDP_ARM_CENTRE_X = 0, + THIRDP_ARM_CENTRE_Y = 10, + THIRDP_ARM_CENTRE_Z = 0, - WING_FOLDED_RP_Y = 13.0F, - WING_FOLDED_RP_Z = -3.0F, + WING_FOLDED_RP_Y = 13, + WING_FOLDED_RP_Z = -3, NECK_ROT_X = 0.166F; } diff --git a/src/main/java/com/minelittlepony/model/components/ModelWing.java b/src/main/java/com/minelittlepony/model/components/ModelWing.java index c43d31f5..b09e3120 100644 --- a/src/main/java/com/minelittlepony/model/components/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/components/ModelWing.java @@ -1,95 +1,70 @@ package com.minelittlepony.model.components; -import net.minecraft.client.model.ModelRenderer; - import static com.minelittlepony.model.PonyModelConstants.*; import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.render.PonyRenderer; -// TODO: Combine each wing into one ModelRenderer with multiple boxes, not multiple ModelRenderers each with one box. public class ModelWing { - public ModelRenderer[] folded = new ModelRenderer[3], - extended = new ModelRenderer[6]; + public PonyRenderer extended; + public PonyRenderer folded; - public ModelWing(AbstractPonyModel pony, boolean mirror, float xOffset, float yOffset, float stretch, int texY) { - - // TODO: Don't add the model to the pony if you're just going to remove it again. - for (int i = 0; i < folded.length; i++) { - folded[i] = new ModelRenderer(pony, 56, texY); - pony.boxList.remove(folded[i]); - } - - for (int i = 0; i < extended.length; i++) { - extended[i] = new ModelRenderer(pony, 56, texY + 3); - pony.boxList.remove(extended[i]); - // this seems to hide the wings being a different size when folded - extended[i].mirror = mirror; - } - - init(xOffset, yOffset, stretch); - addFeathers(mirror ? -1 : 1, yOffset, stretch); + private boolean mirror; + + public ModelWing(AbstractPonyModel pony, boolean mirror, float x, float y, float scale, int texY) { + this.mirror = mirror; + + folded = new PonyRenderer(pony, 56, texY) + .around(HEAD_RP_X, WING_FOLDED_RP_Y, WING_FOLDED_RP_Z); + extended = new PonyRenderer(pony, 56, texY + 3) + .around(HEAD_RP_X, WING_FOLDED_RP_Y, WING_FOLDED_RP_Z).mirror(mirror); + + addCloseWing(x, y, scale); + addFeathers(mirror, y, scale); + } + + private void addCloseWing(float x, float y, float scale) { + folded.box(x, 5f, 2, 2, 6, 2, scale) + .box(x, 5f, 4, 2, 8, 2, scale) + .box(x, 5f, 6, 2, 6, 2, scale) + .rotateAngleX = ROTATE_90; } - private void addFeathers(float r, float y, float scale) { - addFeather(0, r, y, 6.0F, 0.0F, 8, scale + 0.1F); - addFeather(1, r, y, -1.2F, -0.2F, 8, scale + 0.2F); - addFeather(2, r, y, 1.8F, 1.3F, 8, scale - 0.1F); - addFeather(3, r, y, 5.0F, 2.0F, 8, scale); - addFeather(4, r, y, 0.0F, -0.2F, 6, scale + 0.3F); - addFeather(5, r, y, 0.0F, 0.2F, 3, scale + 0.19F); + private void addFeathers(boolean mirror, float y, float scale) { + float r = mirror ? -1 : 1; + extended.cubeList.clear(); + extended.around(r * LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + y, LEFT_WING_EXT_RP_Z); + addFeather(0, r, y, 6, 0, 8, scale + 0.1F); + addFeather(1, r, y, -1.2F, -0.2F, 8, scale + 0.2F) .rotateAngleX = -0.85F; + addFeather(2, r, y, 1.8F, 1.3F, 8, scale - 0.1F) .rotateAngleX = -0.75F; + addFeather(3, r, y, 5, 2, 8, scale) .rotateAngleX = -0.5F; + addFeather(4, r, y, 0, -0.2F, 6, scale + 0.3F); + addFeather(5, r, y, 0, 0.2F, 3, scale + 0.19F).rotateAngleX = -0.85F; } - private void addFeather(int i, float r, float Y, float y, float z, int h, float scale) { - extended[i].addBox(-0.5f, y, z, 1, h, 2, scale); - extended[i].setRotationPoint(r * LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + Y, LEFT_WING_EXT_RP_Z); + private PonyRenderer addFeather(int i, float r, float Y, float y, float z, int h, float scale) { + return extended.child(i).around(0, 0, 0).box(-0.5f, y, z, 1, h, 2, scale); } - private void init(float x, float y, float scale) { - initFeather(folded[0], y, x, 2F, 6, scale); - initFeather(folded[1], y, x, 4F, 8, scale); - initFeather(folded[2], y, x, 6F, 6, scale); + public void rotateWalking(float swing) { + folded.rotateAngleY = swing * 0.2F; } - private void initFeather(ModelRenderer wing, float y, float x, float z, int h, float scale) { - wing.addBox(x, 5f, z, 2, h, 2, scale); - wing.setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + y, WING_FOLDED_RP_Z); - wing.rotateAngleX = ROTATE_90; - } - - public void updateModelRotation(float swing) { - for (ModelRenderer feather : folded) { - feather.rotateAngleY = swing * 0.2F; + + public void render(boolean extend, float scale) { + extended.rotationPointX = (mirror ? -1 : 1) * LEFT_WING_EXT_RP_X; + extended.rotationPointY = LEFT_WING_EXT_RP_Y; + + extended.rotateAngleY = 3; + if (extend) { + extended.render(scale); + } else { + folded.render(scale); } } - public void rotate(float angle) { - for (ModelRenderer feather : folded) { - feather.rotateAngleX = angle; - } - // Special - extended[1].rotateAngleX -= 0.85F; - extended[2].rotateAngleX -= 0.75F; - extended[3].rotateAngleX -= 0.5F; - extended[5].rotateAngleX -= 0.85F; + public void rotateFlying(float angle) { + extended.rotateAngleZ = angle; } - public void render(boolean standing, float scale) { - for (ModelRenderer feather : (standing ? folded : extended)) { - feather.render(scale); - } - } - - public void rotateSneaked(float rotZ) { - for (ModelRenderer feather : extended) { - feather.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - feather.rotateAngleZ = rotZ; - } - } - - public void rotateUnsneaked(float angle) { - for (ModelRenderer aLeftWingExt : extended) { - aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aLeftWingExt.rotateAngleZ = -angle; - } - } } diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index 655ed09c..7d889d17 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -23,35 +23,52 @@ public class PegasusWings extends ModelBase { @Override public void setRotationAngles(float limbSwing, float limbSwingAmount, float ticks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - - float bodySwingRotation = 0.0F; - if (pony.swingProgress > -9990.0F && !pony.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F; - } + if (!isVisible()) return; - leftWing.updateModelRotation(bodySwingRotation); - rightWing.updateModelRotation(bodySwingRotation); + float swing = 0; - if (pony.isSneak && !pony.isFlying) { - leftWing.rotateSneaked(LEFT_WING_ROTATE_ANGLE_Z_SNEAK); - rightWing.rotateSneaked(-LEFT_WING_ROTATE_ANGLE_Z_SNEAK); - } else if (pony.isFlying) { - float WingRotateAngleZ = (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; + if (pony.swingProgress > 0) { + swing = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * PI * 2); + } else { + float pi = PI * (float) Math.pow(limbSwingAmount, 16); - leftWing.rotateUnsneaked(WingRotateAngleZ); - rightWing.rotateUnsneaked(-WingRotateAngleZ); + float mve = limbSwing * 0.6662F; // magic number ahoy + float srt = limbSwingAmount / 4; + + swing = MathHelper.cos(mve + pi) * srt; } - leftWing.rotate(ROTATE_90); - rightWing.rotate(ROTATE_90); + leftWing.rotateWalking(swing); + rightWing.rotateWalking(-swing); + + if (isExtended()) { + float flapAngle = getWingRotationFactor(ticks); + leftWing.rotateFlying(flapAngle); + rightWing.rotateFlying(-flapAngle); + } + + } + + public float getWingRotationFactor(float ticks) { + if (pony.isFlying) { + return (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; + } + return LEFT_WING_ROTATE_ANGLE_Z_SNEAK; + } + + public boolean isVisible() { + return pony.metadata.getRace().hasWings(); + } + + public boolean isExtended() { + return pony.isFlying || pony.isSneak; } @Override public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - if (pony.metadata.getRace().hasWings()) { - boolean standing = !pony.isFlying && !pony.isSneak; - leftWing.render(standing, scale); - rightWing.render(standing, scale); - } + if (!isVisible()) return; + boolean standing = isExtended(); + leftWing.render(standing, scale); + rightWing.render(standing, scale); } } From 2ef344d9d3e49a2f5a1b56c0b4254fe6178b8222 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 17:20:22 +0200 Subject: [PATCH 23/96] Debug --- src/main/java/com/minelittlepony/PonyManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index f8ffef56..c2bf323e 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -175,7 +175,7 @@ public class PonyManager implements IResourceManagerReloadListener { * Returns true if the given uuid is of a player would would use the ALEX skin type. */ public static boolean isSlimSkin(UUID uuid) { - return false;//(uuid.hashCode() & 1) == 1; + return (uuid.hashCode() & 1) == 1; } private int getNumberOfPonies() { From af3dff6c87bdf30f9e72f11dbd12175646d126ca Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 17:20:40 +0200 Subject: [PATCH 24/96] Fix errors when rendering armour --- .../minelittlepony/model/ponies/ModelPlayerPony.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 3eda4fc2..bce9ffde 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -107,10 +107,12 @@ public class ModelPlayerPony extends AbstractPonyModel { animateWears(); - bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; - - snout.setGender(metadata.getGender()); - wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + if (bipedCape != null) { + bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; + + snout.setGender(metadata.getGender()); + wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + } } protected void adjustBodyRiding() { @@ -456,7 +458,6 @@ public class ModelPlayerPony extends AbstractPonyModel { pushMatrix(); transform(BodyPart.BODY); renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - tail.render(metadata.getTail(), scale); popMatrix(); pushMatrix(); @@ -485,6 +486,7 @@ public class ModelPlayerPony extends AbstractPonyModel { upperTorso.render(scale); bipedBody.postRender(scale); wings.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + tail.render(metadata.getTail(), scale); } protected void renderLegs() { From d233399b68439bc4a2b4dcec413d46a4b8cfc1c7 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 17:21:38 +0200 Subject: [PATCH 25/96] Fixed skeleton legs not swinging --- .../model/ponies/ModelSkeletonPony.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index c7e69e19..e237685f 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -7,6 +7,7 @@ import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; import com.minelittlepony.model.armour.PonyArmor; import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; @@ -55,31 +56,41 @@ public class ModelSkeletonPony extends ModelMobPony { bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } } + + // TODO: HACK It would be better to just change the size of the legs. + private void renderScaledArm(ModelRenderer arm, float x, float y, float z) { + scale(x, y, z); + x /= 1.5f; + z /= 1.5f; + arm.rotateAngleX /= x; + arm.rotateAngleY /= y; + arm.rotateAngleZ /= z; + arm.render(scale); + arm.rotateAngleX *= x; + arm.rotateAngleY *= y; + arm.rotateAngleZ *= z; + } @Override protected void renderLegs() { pushMatrix(); translate(0.05F, -0.21F, 0); - scale(0.5F, 1.15F, 0.5F); - bipedLeftArm.render(this.scale); + renderScaledArm(bipedLeftArm, 0.5F, 1.15F, 0.5F); popMatrix(); pushMatrix(); translate(-0.05F, -0.21F, 0); - scale(0.5F, 1.2F, 0.5F); - bipedRightArm.render(this.scale); + renderScaledArm(bipedRightArm, 0.5F, 1.2F, 0.5F); popMatrix(); pushMatrix(); translate(0.05F, -0.21F, 0.35F); - scale(0.5F, 1.2F, 0.5F); - bipedLeftLeg.render(this.scale); + renderScaledArm(bipedLeftLeg, 0.5F, 1.2F, 0.5F); popMatrix(); pushMatrix(); translate(-0.05F, -0.21F, 0.35F); - scale(0.5F, 1.15F, 0.5F); - bipedRightLeg.render(this.scale); + renderScaledArm(bipedRightLeg, 0.5F, 1.15F, 0.5F); popMatrix(); } } From f01bdd973bce0e87dc77e7f175c565a8a66829e1 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 17:22:09 +0200 Subject: [PATCH 26/96] Added some more swing to tails --- src/main/java/com/minelittlepony/model/components/PonyTail.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 36c321a0..8bcc1c94 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -62,6 +62,7 @@ public class PonyTail extends PlaneRenderer { public void swingX(float tick) { float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; rotateAngleX += sinTickFactor; + rotateAngleY += sinTickFactor; } public void rotateSneak() { From ca2e5ddf46f38a190c6f81c6bc5e71e3069a2e9e Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 18:20:22 +0200 Subject: [PATCH 27/96] Fixed some armour issues --- .../com/minelittlepony/model/armour/ModelPonyArmor.java | 7 ++++--- .../java/com/minelittlepony/render/BasePonyRenderer.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index fc924b1e..32e56476 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -37,7 +37,7 @@ public class ModelPonyArmor extends ModelMobPony { protected void updateHeadRotation(float x, float y) { super.updateHeadRotation(x, y); extHead.rotateAngleX = x; - extHead.rotateAngleX = x; + extHead.rotateAngleY = y; } @Override @@ -158,11 +158,12 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void initLegPositions(float yOffset, float stretch) { super.initLegPositions(yOffset, stretch); + extLegLeft.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) - .around(-3, yOffset, 0) + .around(3, yOffset, 0) .box(-2, -6, -2, 4, 12, 4, stretch); extLegRight.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) - .around(3, yOffset, 0) + .around(-3, yOffset, 0) .mirror().box(-2, -6, -2, 4, 12, 4, stretch); } diff --git a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java index 05305dbe..0db25e85 100644 --- a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java @@ -91,7 +91,7 @@ public abstract class BasePonyRenderer> extends Mo } public T rotateAt(ModelRenderer other) { - return at(other.rotationPointX, other.rotationPointY, other.rotationPointZ); + return around(other.rotationPointX, other.rotationPointY, other.rotationPointZ); } /** From 16eed1e5686538bdb43ba038e3cd44a3ae98066d Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 22:30:17 +0200 Subject: [PATCH 28/96] More codestyle --- .../render/layer/AbstractPonyLayer.java | 3 +-- .../render/layer/LayerEntityOnPonyShoulder.java | 9 +++------ .../render/layer/LayerHeldPonyItem.java | 13 +++++++------ .../minelittlepony/render/layer/LayerPonyArmor.java | 6 +++--- .../java/com/minelittlepony/render/plane/Face.java | 4 ++-- .../render/player/RenderPonyBase.java | 2 -- .../render/ponies/RenderPonyIllusionIllager.java | 12 ++++++------ 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 43d3b875..bea43202 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -17,8 +17,7 @@ public abstract class AbstractPonyLayer implements L this.layer = humanLayer; } - public final void doRenderLayer(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, - float netHeadYaw, float headPitch, float scale) { + public final void doRenderLayer(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { ModelBase model = renderer.getMainModel(); if (model instanceof ModelHumanPlayer) { // render the human layer diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index 87ce609f..31dc7c08 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -30,11 +30,10 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { this.rm = rm; } - public void doPonyRender(EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, - float ageInTicks, float netHeadYaw, float headPitch, float scale) { + 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); + GlStateManager.color(1, 1, 1, 1); NBTTagCompound leftTag = player.getLeftShoulderEntity(); @@ -71,9 +70,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { model.transform(BodyPart.BODY); // render on the haunches - float f = .25F; - float f1 = left ? 0.25F : -0.25F; - GlStateManager.translate(f1, f, 0.35F); + GlStateManager.translate(left ? 0.25F : -0.25F, 0.25F, 0.35F); GlStateManager.scale(1, -1, -1); GlStateManager.rotate(5 * (left ? -1 : 1), 0, 0, 1); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index 9d13d904..ff975fc6 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -33,12 +33,13 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { } @Override - 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) { + 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(); + ItemStack left = mainRight ? itemOff : itemMain; ItemStack right = mainRight ? itemMain : itemOff; @@ -70,14 +71,14 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { GlStateManager.translate(0.0F, 0.2F, 0.0F); } - GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(-90.0F, 1, 0, 0); + GlStateManager.rotate(180.0F, 0, 1, 0); boolean isUnicorn = isUnicorn(this.getRenderer().getMainModel()); boolean isLeft = hand == EnumHandSide.LEFT; if (isUnicorn) { - GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -.5); + GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -0.5F); } else { - GlStateManager.translate(0.0425F, 0.125F, -1.00F); + GlStateManager.translate(0.0425F, 0.125F, -1); } Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index 22dbcba4..a3670daf 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -163,9 +163,9 @@ public class LayerPonyArmor extends AbstractPonyLayer { } } - private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_, float p_177183_4_, float p_177183_5_, + private void renderEnchantment(EntityLivingBase entity, ModelBase model, 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_; + float f7 = entity.ticksExisted + p_177183_5_; this.getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); GlStateManager.depthFunc(514); @@ -185,7 +185,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, f7 * (0.001F + i * 0.003F) * 20.0F, 0.0F); GlStateManager.matrixMode(5888); - modelbaseIn.render(entitylivingbaseIn, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, p_177183_9_); + model.render(entity, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, p_177183_9_); } GlStateManager.matrixMode(5890); diff --git a/src/main/java/com/minelittlepony/render/plane/Face.java b/src/main/java/com/minelittlepony/render/plane/Face.java index 1c466452..199e9c0e 100644 --- a/src/main/java/com/minelittlepony/render/plane/Face.java +++ b/src/main/java/com/minelittlepony/render/plane/Face.java @@ -2,6 +2,6 @@ package com.minelittlepony.render.plane; enum Face { NORTH, SOUTH, - UP, DOWN, - EAST, WEST; + UP, DOWN, + EAST, WEST; } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index 1048c957..9188ccb9 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -73,8 +73,6 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony super.doRender(player, x, y, z, entityYaw, partialTicks); } - - // TODO: Why are there two sets of arms? @Override public void renderRightArm(AbstractClientPlayer player) { updateModel(player); diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java index 8c45e138..0c9dff2d 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java @@ -54,14 +54,14 @@ public class RenderPonyIllusionIllager extends RenderPonyMob Date: Thu, 26 Apr 2018 22:31:26 +0200 Subject: [PATCH 29/96] Apparantly google hates concise readable code. So there, can't complain about static members if they're not static. :P I may just revert this later... --- src/main/java/com/minelittlepony/model/AbstractPonyModel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index cea8e448..4697dd4f 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -112,7 +112,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { /** * Adjusts the rotation center of the given renderer by the given amounts in each direction. */ - public static void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) { + public void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) { renderer.rotationPointX += x; renderer.rotationPointY += y; renderer.rotationPointZ += z; @@ -126,7 +126,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { * @param swingProgress How far we are through the current swing * @param tick Render partial ticks */ - protected static void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { + protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { float swing = MathHelper.sin(swingProgress * (float)Math.PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); From 785784b694c74839d69a87b489f2883deaf04a6c Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 23:46:32 +0200 Subject: [PATCH 30/96] Move HornGlow to the correct package --- .../components => render}/HornGlow.java | 28 +++++++++---------- .../render/HornGlowRenderer.java | 21 +++++++------- 2 files changed, 24 insertions(+), 25 deletions(-) rename src/main/java/com/minelittlepony/{model/components => render}/HornGlow.java (93%) diff --git a/src/main/java/com/minelittlepony/model/components/HornGlow.java b/src/main/java/com/minelittlepony/render/HornGlow.java similarity index 93% rename from src/main/java/com/minelittlepony/model/components/HornGlow.java rename to src/main/java/com/minelittlepony/render/HornGlow.java index 91d028f4..8957540b 100644 --- a/src/main/java/com/minelittlepony/model/components/HornGlow.java +++ b/src/main/java/com/minelittlepony/render/HornGlow.java @@ -1,4 +1,4 @@ -package com.minelittlepony.model.components; +package com.minelittlepony.render; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.PositionTextureVertex; @@ -7,43 +7,41 @@ import net.minecraft.client.renderer.BufferBuilder; import javax.annotation.Nonnull; -import com.minelittlepony.render.HornGlowRenderer; - public class HornGlow extends ModelBox { private final float alpha; - + private final HornGlowRenderer parent; - + private TexturedQuad[] quadList; public HornGlow(HornGlowRenderer parent, int texU, int texV, float x, float y, float z, int w, int h, int d, float scale, float alpha) { super(parent, texU, texV, x, y, z, w, h, d, scale); - + this.parent = parent; this.alpha = alpha; - + this.quadList = new TexturedQuad[6]; - + float x2 = x + w + scale; float y2 = y + h + scale; float z2 = z + d + scale; - + x -= scale; y -= scale; z -= scale; - + if (parent.mirror) { - float f3 = x2; + float tmp = x2; x2 = x; - x = f3; + x = tmp; } float halfpar4 = x + w * 0.05F; float halfpar6 = z + d * 0.05F; float halfvar11 = x + w * 0.95F; float halfvar13 = z + d * 0.95F; - + PositionTextureVertex p7 = new PositionTextureVertex(halfpar4, y, halfpar6, 0, 0); PositionTextureVertex p0 = new PositionTextureVertex(halfvar11, y, halfpar6, 0, 8); PositionTextureVertex p1 = new PositionTextureVertex(x2, y2, z, 8, 8); @@ -59,7 +57,7 @@ public class HornGlow extends ModelBox { this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{p1, p2, p6, p5}, texU + d + w, texV + d, texU + d + w + w, texV, parent.textureWidth, parent.textureHeight); this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{p0, p7, p2, p1}, texU + d, texV + d, texU + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{p3, p4, p5, p6}, texU + d + w + d, texV + d, texU + d + w + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); - + if (parent.mirror) { for (TexturedQuad i : quadList) { i.flipFace(); @@ -70,7 +68,7 @@ public class HornGlow extends ModelBox { @Override public void render(@Nonnull BufferBuilder buffer, float scale) { parent.applyTint(alpha); - + for (TexturedQuad i : quadList) { i.draw(buffer, scale); } diff --git a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java index 87bf4857..dcc3b0f3 100644 --- a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java @@ -2,39 +2,40 @@ package com.minelittlepony.render; import static net.minecraft.client.renderer.GlStateManager.color; -import com.minelittlepony.model.components.HornGlow; - import net.minecraft.client.model.ModelBase; public class HornGlowRenderer extends BasePonyRenderer { - float r, g, b, a = 1; + float red; + float green; + float blue; + float alpha = 1; public HornGlowRenderer(ModelBase model, int x, int y) { super(model, x, y); } - public HornGlowRenderer setAlpha(float a) { - this.a = a; + public HornGlowRenderer setAlpha(float alpha) { + this.alpha = alpha; return this; } public HornGlowRenderer setTint(int tint) { - r = (tint >> 16 & 255) / 255.0F; - g = (tint >> 8 & 255) / 255.0F; - b = (tint & 255) / 255.0F; + red = (tint >> 16 & 255) / 255.0F; + green = (tint >> 8 & 255) / 255.0F; + blue = (tint & 255) / 255.0F; return this; } public void applyTint(float alpha) { - color(r, g, b, alpha); + color(red, green, blue, alpha); } @Override public void createBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { - cubeList.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, a)); + cubeList.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, alpha)); } @Override From 2ad7119723e38abbee23776366de54420dc91447 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 23:53:03 +0200 Subject: [PATCH 31/96] Yet more codestyle! --- .../java/com/minelittlepony/PonyManager.java | 7 ++-- .../hdskins/gui/RenderPonyModel.java | 4 +-- .../model/AbstractPonyModel.java | 23 +++++++------ .../model/PonyModelConstants.java | 10 ++++-- .../model/components/PegasusWings.java | 7 ++-- .../model/components/UnicornHorn.java | 26 +++++++-------- .../model/ponies/ModelVillagerPony.java | 2 +- .../model/ponies/ModelZombiePony.java | 2 +- .../minelittlepony/pony/data/PonyGender.java | 2 +- .../minelittlepony/pony/data/PonyLevel.java | 1 - .../minelittlepony/pony/data/PonyRace.java | 3 +- .../minelittlepony/pony/data/PonySize.java | 3 +- .../pony/data/TriggerPixels.java | 3 +- .../render/BasePonyRenderer.java | 7 ++-- .../minelittlepony/render/RenderPonyMob.java | 3 +- .../render/layer/LayerPonyCape.java | 33 ++++++++++--------- 16 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index c2bf323e..0b8b7121 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -32,10 +32,9 @@ import java.util.stream.Collectors; */ public class PonyManager implements IResourceManagerReloadListener { - public static final ResourceLocation - STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"), - ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"), - BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json"); + public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"); + public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"); + public static final ResourceLocation BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json"); private static final Gson GSON = new Gson(); diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 696c7726..ca8a91a2 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -56,12 +56,12 @@ public class RenderPonyModel extends RenderPlayerModel { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.color(1, 1, 1, 1); bindTexture(entity.getElytraTexture()); GlStateManager.pushMatrix(); - GlStateManager.translate(0.0F, 0.25F, 0.125F); + GlStateManager.translate(0, 0.25F, 0.125F); ((AbstractPonyModel) mainModel).transform(BodyPart.BODY); modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 4697dd4f..12115e0a 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -130,7 +130,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { float swing = MathHelper.sin(swingProgress * (float)Math.PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); - arm.rotateAngleZ = 0.0F; + arm.rotateAngleZ = 0; arm.rotateAngleY = direction * (0.1F - swing * 0.6F); arm.rotateAngleX = -1.5707964F; arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; @@ -224,9 +224,9 @@ public abstract class AbstractPonyModel extends ModelPlayer { } private void transformFoal(BodyPart part) { - if (isCrouching()) translate(0, -0.12F, 0.0F); + if (isCrouching()) translate(0, -0.12F, 0); if (isSleeping) translate(0, -1.2F, 0.25F); - if (isRiding) translate(0, -.1, 0); + if (isRiding) translate(0, -0.1F, 0); switch (part) { case NECK: @@ -247,7 +247,6 @@ public abstract class AbstractPonyModel extends ModelPlayer { scale(0.6F, 0.41F, 0.6F); if (isCrouching()) translate(0, 0.12F, 0); if (rainboom) translate(0, -0.08F, 0); - break; } } @@ -272,17 +271,17 @@ public abstract class AbstractPonyModel extends ModelPlayer { public ModelRenderer getRandomModelBox(Random rand) { // grab one at random, but cycle through the list until you find one that's filled. // Return if you find one, or if you get back to where you started in which case there isn't any. - int index = rand.nextInt(boxList.size()); - int i = index; + int randomI = rand.nextInt(boxList.size()); + int index = randomI; - ModelRenderer mr; + ModelRenderer result; do { - mr = boxList.get(index); - if (!mr.cubeList.isEmpty()) return mr; + result = boxList.get(randomI); + if (!result.cubeList.isEmpty()) return result; - i = (i + 1) % boxList.size(); - } while (i != index); + index = (index + 1) % boxList.size(); + } while (index != randomI); - return mr; + return result; } } diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 944949e3..42686b39 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -10,12 +10,12 @@ public final class PonyModelConstants { BODY_CENTRE_Z = 6, NECK_CENTRE_X = BODY_CENTRE_X - 2, - NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8f, - NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8f, + NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8F, + NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8F, BODY_ROTATE_ANGLE_X_NOTSNEAK = 0, BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, - BODY_ROTATE_ANGLE_X_RIDING = (float) (Math.PI * 3.8), + BODY_ROTATE_ANGLE_X_RIDING = PI * 3.8F, BODY_RP_Y_NOTSNEAK = 0, BODY_RP_Y_SNEAK = 7, @@ -42,6 +42,10 @@ public final class PonyModelConstants { HEAD_RP_Y = 0, HEAD_RP_Z = 0, + HORN_X = HEAD_CENTRE_X - 0.5F, + HORN_Y = HEAD_CENTRE_Y - 10, + HORN_Z = HEAD_CENTRE_Z - 1.5F, + LEFT_WING_EXT_RP_X = 4.5F, LEFT_WING_EXT_RP_Y = 6, LEFT_WING_EXT_RP_Z = 6, diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index 7d889d17..6ee7884d 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -12,7 +12,8 @@ public class PegasusWings extends ModelBase { private final AbstractPonyModel pony; - public final ModelWing leftWing, rightWing; + public final ModelWing leftWing; + public final ModelWing rightWing; public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) { this.pony = pony; @@ -32,7 +33,7 @@ public class PegasusWings extends ModelBase { } else { float pi = PI * (float) Math.pow(limbSwingAmount, 16); - float mve = limbSwing * 0.6662F; // magic number ahoy + float mve = limbSwing * 0.6662f; // magic number ahoy float srt = limbSwingAmount / 4; swing = MathHelper.cos(mve + pi) * srt; @@ -51,7 +52,7 @@ public class PegasusWings extends ModelBase { public float getWingRotationFactor(float ticks) { if (pony.isFlying) { - return (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; + return (MathHelper.sin(ticks * 0.536f) * 1) + ROTATE_270 + 0.4f; } return LEFT_WING_ROTATE_ANGLE_Z_SNEAK; } diff --git a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java index 0cf53555..9de799bf 100644 --- a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -2,9 +2,9 @@ package com.minelittlepony.model.components; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.render.HornGlowRenderer; +import com.minelittlepony.render.PonyRenderer; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import static org.lwjgl.opengl.GL11.*; @@ -12,15 +12,10 @@ import static net.minecraft.client.renderer.GlStateManager.*; import static com.minelittlepony.model.PonyModelConstants.*; public class UnicornHorn extends ModelBase { - static final float - hornX = HEAD_CENTRE_X - 0.5F, - hornY = HEAD_CENTRE_Y - 10, - hornZ = HEAD_CENTRE_Z - 1.5F; protected final AbstractPonyModel pony; - private ModelRenderer horn; - + private PonyRenderer horn; private HornGlowRenderer glow; private boolean usingMagic; @@ -28,22 +23,25 @@ public class UnicornHorn extends ModelBase { public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) { this.pony = pony; - horn = new ModelRenderer(pony, 0, 3); + horn = new PonyRenderer(pony, 0, 3); glow = new HornGlowRenderer(pony, 0, 3); - horn.addBox(hornX, hornY, hornZ, 1, 4, 1, stretch); - horn.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - horn.rotateAngleX = 0.5F; + horn.offset(HORN_X, HORN_Y, HORN_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .box(0, 0, 0, 1, 4, 1, stretch) + .rotateAngleX = 0.5F; - glow.setAlpha(0.4f).addBox(hornX, hornY, hornZ, 1, 4, 1, stretch + 0.5F); - glow.setAlpha(0.2f).addBox(hornX, hornY, hornZ, 1, 3, 1, stretch + 0.8F); + glow.offset(HORN_X, HORN_Y, HORN_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .setAlpha(0.4f).box(0, 0, 0, 1, 4, 1, stretch + 0.5F) + .setAlpha(0.2f).box(0, 0, 0, 1, 3, 1, stretch + 0.8F); } @Override public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (!pony.metadata.getRace().hasHorn()) return; - this.horn.render(scale); + horn.render(scale); if (usingMagic && pony.metadata.hasMagic()) { renderMagic(pony.metadata.getGlowColor(), scale); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 8d21c1b9..a6cbcfc3 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -21,7 +21,7 @@ public class ModelVillagerPony extends ModelPlayerPony { float swing = 0; if (swingProgress > -9990.0F && !metadata.hasMagic()) { - swing = MathHelper.sin(MathHelper.sqrt(swingProgress) * (float)Math.PI * 2) * 0.04f; + swing = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F; } bag.rotateAngleY = swing; apron.rotateAngleY = swing; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 1612f64d..ff7c7d25 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -18,7 +18,7 @@ public class ModelZombiePony extends ModelMobPony { } private boolean isRight(float move) { - return MathHelper.sin(move / 20f) < 0; + return MathHelper.sin(move / 20) < 0; } @Override diff --git a/src/main/java/com/minelittlepony/pony/data/PonyGender.java b/src/main/java/com/minelittlepony/pony/data/PonyGender.java index f1634136..0a056b05 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyGender.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyGender.java @@ -4,7 +4,7 @@ public enum PonyGender implements ITriggerPixelMapped { MARE(0), STALLION(0xffffff); - int triggerValue; + private int triggerValue; PonyGender(int pixel) { triggerValue = pixel; diff --git a/src/main/java/com/minelittlepony/pony/data/PonyLevel.java b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java index 573f9c74..9297fc15 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyLevel.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java @@ -1,7 +1,6 @@ package com.minelittlepony.pony.data; public enum PonyLevel { - PONIES, HUMANS, BOTH diff --git a/src/main/java/com/minelittlepony/pony/data/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java index de350c26..c795cfcd 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -15,7 +15,8 @@ public enum PonyRace implements ITriggerPixelMapped { GRIFFIN(0xae9145, PlayerModels.PONY, true, false), HIPPOGRIFF(0xd6ddac, PlayerModels.PONY, true, false); - private boolean wings, horn; + private boolean wings; + private boolean horn; private int triggerPixel; diff --git a/src/main/java/com/minelittlepony/pony/data/PonySize.java b/src/main/java/com/minelittlepony/pony/data/PonySize.java index 8f4d07d6..a4f6bd52 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonySize.java +++ b/src/main/java/com/minelittlepony/pony/data/PonySize.java @@ -8,7 +8,8 @@ public enum PonySize implements ITriggerPixelMapped { private int triggerValue; - private float shadowSize, scale; + private float shadowSize; + private float scale; PonySize(int pixel, float shadowSz, float scaleF) { triggerValue = pixel; diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java index 57e79cb7..d1706bb6 100644 --- a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -13,7 +13,8 @@ public enum TriggerPixels { SIZE(PonySize.NORMAL, 3, 0), GLOW(null, 0, 1); - private int x, y; + private int x; + private int y; ITriggerPixelMapped def; diff --git a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java index 0db25e85..5ee0a305 100644 --- a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/BasePonyRenderer.java @@ -10,9 +10,12 @@ public abstract class BasePonyRenderer> extends Mo protected final ModelBase baseModel; - protected int textureOffsetX, textureOffsetY; + protected int textureOffsetX; + protected int textureOffsetY; - protected float modelOffsetX, modelOffsetY, modelOffsetZ; + protected float modelOffsetX; + protected float modelOffsetY; + protected float modelOffsetZ; public BasePonyRenderer(ModelBase model) { super(model); diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 0292546c..3d73191e 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -37,8 +37,7 @@ public abstract class RenderPonyMob extends RenderLiving } @Override - public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, - float partialTicks) { + public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float partialTicks) { double yOrigin = yPosition; if (entity.isSneaking()) { yOrigin -= 0.125D; diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index a8cd1b05..10864b36 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -16,6 +16,7 @@ import net.minecraft.util.math.MathHelper; import javax.annotation.Nonnull; import static net.minecraft.client.renderer.GlStateManager.*; +import static com.minelittlepony.model.PonyModelConstants.PI; public class LayerPonyCape extends AbstractPonyLayer { @@ -31,38 +32,38 @@ public class LayerPonyCape extends AbstractPonyLayer { && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { pushMatrix(); model.getModel().transform(BodyPart.BODY); - translate(0.0F, 0.24F, 0.0F); + translate(0, 0.24F, 0); model.getModel().bipedBody.postRender(scale); double d = clientPlayer.prevChasingPosX + (clientPlayer.chasingPosX - clientPlayer.prevChasingPosX) * scale - (clientPlayer.prevPosX + (clientPlayer.posX - clientPlayer.prevPosX) * scale); double d1 = clientPlayer.prevChasingPosY + (clientPlayer.chasingPosY - clientPlayer.prevChasingPosY) * scale - (clientPlayer.prevPosY + (clientPlayer.posY - clientPlayer.prevPosY) * scale); double d2 = clientPlayer.prevChasingPosZ + (clientPlayer.chasingPosZ - clientPlayer.prevChasingPosZ) * scale - (clientPlayer.prevPosZ + (clientPlayer.posZ - clientPlayer.prevPosZ) * scale); float f10 = clientPlayer.prevRenderYawOffset + (clientPlayer.renderYawOffset - clientPlayer.prevRenderYawOffset) * scale; - double d3 = MathHelper.sin(f10 * 3.1415927F / 180.0F); - double d4 = (-MathHelper.cos(f10 * 3.1415927F / 180.0F)); - float f12 = (float) d1 * 10.0F; + double d3 = MathHelper.sin(f10 * PI / 180); + double d4 = (-MathHelper.cos(f10 * PI / 180)); + float f12 = (float) d1 * 10; if (f12 < -6.0F) { f12 = -6.0F; } - if (f12 > 32.0F) { - f12 = 32.0F; + if (f12 > 32) { + f12 = 32; } - float f13 = (float) (d * d3 + d2 * d4) * 100.0F; - float f14 = (float) (d * d4 - d2 * d3) * 100.0F; - if (f13 < 0.0F) { - f13 = 0.0F; + float f13 = (float) (d * d3 + d2 * d4) * 100; + float f14 = (float) (d * d4 - d2 * d3) * 100; + if (f13 < 0) { + f13 = 0; } float f15 = clientPlayer.prevCameraYaw + (clientPlayer.cameraYaw - clientPlayer.prevCameraYaw) * scale; - f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified + (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6.0F) * 32.0F * f15; + f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified + (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6) * 32 * f15; - rotate(2.0F + f13 / 12.0F + f12, 1.0F, 0.0F, 0.0F); - rotate(f14 / 2.0F, 0.0F, 0.0F, 1.0F); - 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); + rotate(2 + f13 / 12 + f12, 1, 0, 0); + rotate(f14 / 2, 0, 0, 1); + rotate(-f14 / 2, 0, 1, 0); + rotate(180, 0, 0, 1); + rotate(90, 1, 0, 0); this.getRenderer().bindTexture(clientPlayer.getLocationCape()); model.getModel().renderCape(0.0625F); popMatrix(); From 7a66dfda4208762e48c5abe7896c0459b1f880c7 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 23:53:22 +0200 Subject: [PATCH 32/96] Tidy up ponytails --- .../model/components/PonyTail.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 8bcc1c94..7368fa64 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -35,13 +35,13 @@ public class PonyTail extends PlaneRenderer { } else if (theModel.isRiding) { rotationPointZ = 13; rotationPointY = 3; - rotateAngleX = (float) (Math.PI * 0.2); + rotateAngleX = PI / 5; } else { setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); if (rainboom) { - rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(limbSwing); + rotateAngleX = ROTATE_90 + MathHelper.sin(limbSwing) / 10; } else { - rotateAngleX = 0.5F * limbSwingAmount; + rotateAngleX = limbSwingAmount / 2; } if (!rainboom) { @@ -50,17 +50,17 @@ public class PonyTail extends PlaneRenderer { } if (rainboom) { - rotationPointY += 6.0F; + rotationPointY += 6; rotationPointZ++; } } public void swingZ(boolean rainboom, float move, float swing) { - rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2F * swing; + rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; } public void swingX(float tick) { - float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; + float sinTickFactor = MathHelper.sin(tick * 0.067f) * 0.05f; rotateAngleX += sinTickFactor; rotateAngleY += sinTickFactor; } @@ -94,16 +94,18 @@ public class PonyTail extends PlaneRenderer { int texX = (index % 2) * 4; if (index == 0) { - setTextureOffset(32, 0).addTopPlane(-2, 0, 2, 4, 4, stretch); + tex(32, 0).addTopPlane(-2, 0, 2, 4, 4, stretch); } - setTextureOffset(36, texX).addEastPlane(2, 0, 2, 4, 4, stretch); - addWestPlane(-2, 0, 2, 4, 4, stretch); - setTextureOffset(32, texX).addBackPlane(-2, 0, 2, 4, 4, stretch); - addFrontPlane(-2, 0, 6, 4, 4, stretch); - setTextureOffset(32, 0).addBottomPlane(-2, 4, 2, 4, 4, stretch); - - setRotationPoint(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); + around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); + tex(36, texX) + .addEastPlane(2, 0, 2, 4, 4, stretch) + .addWestPlane(-2, 0, 2, 4, 4, stretch); + tex(32, texX) + .addBackPlane(-2, 0, 2, 4, 4, stretch) + .addFrontPlane(-2, 0, 6, 4, 4, stretch); + tex(32, 0) + .addBottomPlane(-2, 4, 2, 4, 4, stretch); } } } From c6e81529f3064a6fb1c6464ec4565653d9199976 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 23:53:49 +0200 Subject: [PATCH 33/96] More formatting --- .../model/components/PonyElytra.java | 38 +++++----- .../model/ponies/ModelIllagerPony.java | 4 +- .../model/ponies/ModelPlayerPony.java | 72 +++++++++---------- .../render/layer/LayerPonyCustomHead.java | 17 ++--- .../render/layer/LayerPonyElytra.java | 4 +- 5 files changed, 68 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/components/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java index 5cf19541..16160059 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -1,53 +1,53 @@ package com.minelittlepony.model.components; import com.minelittlepony.model.PonyModelConstants; +import com.minelittlepony.render.PonyRenderer; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.Vec3d; public class PonyElytra extends ModelBase { - private ModelRenderer rightWing; - private ModelRenderer leftWing = new ModelRenderer(this, 22, 0); + private PonyRenderer rightWing = new PonyRenderer(this, 22, 0); + private PonyRenderer leftWing = new PonyRenderer(this, 22, 0); public PonyElytra() { - this.leftWing.addBox(-10.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F); - this.rightWing = new ModelRenderer(this, 22, 0); - this.rightWing.mirror = true; - this.rightWing.addBox(0.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F); + this.leftWing .box(-10, 0, 0, 10, 20, 2, 1); + this.rightWing.mirror().box( 0, 0, 0, 10, 20, 2, 1); } @Override - public void render(Entity entityIn, float p_78088_2_, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { GlStateManager.disableRescaleNormal(); GlStateManager.disableCull(); - this.leftWing.render(scale); - this.rightWing.render(scale); + leftWing.render(scale); + rightWing.render(scale); } @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); + final float PI = (float) Math.PI; float rotateX = PI / 2F; - float rotateZ = PI / 12; - float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK; float rotateY = PI / 8F; - + float rotateZ = PI / 12; + + float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK; + if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).isElytraFlying()) { - float f4 = 1.0F; + float f4 = 1; - if (entityIn.motionY < 0.0D) { + if (entityIn.motionY < 0) { Vec3d vec3d = (new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ)).normalize(); - f4 = 1.0F - (float) Math.pow(-vec3d.y, 1.5D); + f4 = 1 - (float) Math.pow(-vec3d.y, 1.5); } - rotateX = f4 * PI * (2 / 3F) + (1.0F - f4) * rotateX; - rotateY = f4 * ((float) Math.PI / 2F) + (1.0F - f4) * rotateY; + rotateX = f4 * PI * (2 / 3F) + (1 - f4) * rotateX; + rotateY = f4 * ((float) Math.PI / 2F) + (1 - f4) * rotateY; } else if (entityIn.isSneaking()) { rotateX = ((float) Math.PI * 1.175F); rotateY = PI / 2; @@ -55,7 +55,7 @@ public class PonyElytra extends ModelBase { rotateZ = PI / 4F; } - this.leftWing.rotationPointX = 5.0F; + this.leftWing.rotationPointX = 5; this.leftWing.rotationPointY = rpY; if (entityIn instanceof AbstractClientPlayer) { diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index d30b697d..e4b85ffb 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -51,13 +51,13 @@ public class ModelIllagerPony extends ModelPlayerPony { // 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.rotateAngleZ = MathHelper.cos(ageInTicks * 0.6662F) / 4; 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.rotateAngleZ = -MathHelper.cos(ageInTicks * 0.6662F) / 4; this.bipedLeftArm.rotateAngleY = -1.1F; } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index bce9ffde..47e72e82 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -62,9 +62,9 @@ public class ModelPlayerPony extends AbstractPonyModel { this.checkRainboom(entityIn, limbSwingAmount); this.rotateHead(netHeadYaw, headPitch); - float bodySwingRotation = 0.0F; - if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; + float bodySwingRotation = 0; + if (swingProgress > -9990.0F && !metadata.hasMagic()) { + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; } rotateLook(limbSwing, limbSwingAmount, bodySwingRotation, ageInTicks); @@ -184,7 +184,10 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float leftArm, rightArm, leftLeg, rightLeg; + float leftArm; + float rightArm; + float leftLeg; + float rightLeg; if (isFlying(entity)) { @@ -196,11 +199,8 @@ public class ModelPlayerPony extends AbstractPonyModel { rightLeg = leftLeg = MathHelper.sin(swing / 2); } - bipedRightArm.rotateAngleY = 0.2F; + bipedLeftLeg.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F; bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; - - bipedLeftLeg.rotateAngleY = 0.2F; - } else { float pi = PI * (float) Math.pow(swing, 16); @@ -325,55 +325,55 @@ public class ModelPlayerPony extends AbstractPonyModel { if (mainPose == ArmPose.EMPTY) return; - float f16 = 1 - swingProgress; - f16 *= f16 * f16; - f16 = 1 - f16; - float f22 = MathHelper.sin(f16 * PI); - float f28 = MathHelper.sin(swingProgress * PI); - float f33 = f28 * (0.7F - bipedHead.rotateAngleX) * 0.75F; - if (metadata.hasMagic()) { - swingArm(mainRight ? unicornArmRight : unicornArmLeft, f22, f33, f28); + swingArm(mainRight ? unicornArmRight : unicornArmLeft); } else { - swingArm(getArmForSide(mainSide), f22, f33, f28); + swingArm(getArmForSide(mainSide)); } } } - private void swingArm(ModelRenderer arm, float f22, float f33, float f28) { - arm.rotateAngleX = (float) (arm.rotateAngleX - (f22 * 1.2D + f33)); - arm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; - arm.rotateAngleZ = f28 * -0.4F; + private void swingArm(ModelRenderer arm) { + float swing = 1 - (float)Math.pow(1 - swingProgress, 3); + + float deltaX = MathHelper.sin(swing * PI); + float deltaZ = MathHelper.sin(swingProgress * PI); + + float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F; + + arm.rotateAngleX -= deltaAim + deltaX * 1.2F; + arm.rotateAngleZ = deltaZ * -0.4F; + arm.rotateAngleY += bipedBody.rotateAngleY * 2; } protected void swingArms(float tick) { float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float sin = MathHelper.sin(tick * 0.067F) * 0.05F; - if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) { + if (rightArmPose != ArmPose.EMPTY && !isSleeping) { - if (this.metadata.hasMagic()) { - this.unicornArmRight.rotateAngleZ += cos; - this.unicornArmRight.rotateAngleX += sin; + if (metadata.hasMagic()) { + unicornArmRight.rotateAngleZ += cos; + unicornArmRight.rotateAngleX += sin; } else { - this.bipedRightArm.rotateAngleZ += cos; - this.bipedRightArm.rotateAngleX += sin; + bipedRightArm.rotateAngleZ += cos; + bipedRightArm.rotateAngleX += sin; } } - if (this.leftArmPose != ArmPose.EMPTY && !this.isSleeping) { - if (this.metadata.hasMagic()) { - this.unicornArmLeft.rotateAngleZ += cos; - this.unicornArmLeft.rotateAngleX += sin; + if (leftArmPose != ArmPose.EMPTY && !isSleeping) { + if (metadata.hasMagic()) { + unicornArmLeft.rotateAngleZ += cos; + unicornArmLeft.rotateAngleX += sin; } else { - this.bipedLeftArm.rotateAngleZ += cos; - this.bipedLeftArm.rotateAngleX += sin; + bipedLeftArm.rotateAngleZ += cos; + bipedLeftArm.rotateAngleX += sin; } } } protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { - this.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); - this.adjustNeck(rotateAngleX, rotationPointY, rotationPointZ); + adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); + adjustNeck(rotateAngleX, rotationPointY, rotationPointZ); } protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { @@ -420,7 +420,7 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { - if (this.metadata.hasMagic()) { + if (metadata.hasMagic()) { if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); } else { diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 82b78e7d..aa7e5c2e 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -48,9 +48,9 @@ public class LayerPonyCustomHead implements LayerRenderer { model.transform(BodyPart.HEAD); model.bipedHead.postRender(0.0625f); if (model instanceof ModelPlayerPony) { - translate(0, .2, 0); + translate(0, 0.2F, 0); } else { - translate(0, 0, .15); + translate(0, 0, 0.15F); } color(1, 1, 1, 1); if (item == Items.SKULL) { @@ -65,26 +65,27 @@ public class LayerPonyCustomHead implements LayerRenderer { private void renderBlock(EntityLivingBase entity, ItemStack itemstack) { rotate(180, 0, 1, 0); - scale(0.625, -0.625, -0.625); - translate(0, 0.4, -0.21); + scale(0.625, -0.625F, -0.625F); + translate(0, 0.4F, -0.21F); Minecraft.getMinecraft().getItemRenderer().renderItem(entity, itemstack, TransformType.HEAD); } private void renderSkull(ItemStack itemstack, boolean isVillager, float limbSwing) { - translate(0, 0, -.14); + translate(0, 0, -0.14F); float f = 1.1875f; scale(f, -f, -f); if (isVillager) { - translate(0, 0.0625, 0); + translate(0, 0.0625F, 0); } - translate(0, 0, -.05f); + translate(0, 0, -0.05F); GameProfile profile = null; if (itemstack.hasTagCompound()) { NBTTagCompound nbt = itemstack.getTagCompound(); assert nbt != null; + if (nbt.hasKey("SkullOwner", 10)) { profile = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("SkullOwner")); } else if (nbt.hasKey("SkullOwner", 8)) { @@ -93,7 +94,7 @@ public class LayerPonyCustomHead implements LayerRenderer { } } - TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.45F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), profile, -1, limbSwing); + TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index 3b85d7d5..e5a11eaf 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -36,7 +36,7 @@ public class LayerPonyElytra extends AbstractPonyLayer { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.color(1, 1, 1, 1); if (entity instanceof AbstractClientPlayer) { @@ -53,7 +53,7 @@ public class LayerPonyElytra extends AbstractPonyLayer { } GlStateManager.pushMatrix(); - GlStateManager.translate(0.0F, 0.25F, 0.125F); + GlStateManager.translate(0, 0.25F, 0.125F); model.transform(BodyPart.BODY); this.modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); this.modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); From 36ee3966d768f3fb36a11e0ad9b82fd1a8ddf434 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Apr 2018 23:55:09 +0200 Subject: [PATCH 34/96] Tidy up snuzzles --- .../model/components/PonySnout.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java index f3266838..f4f33ac8 100644 --- a/src/main/java/com/minelittlepony/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -9,34 +9,33 @@ import com.minelittlepony.model.AbstractPonyModel; public class PonySnout { - private PlaneRenderer mare, stallion; + private PlaneRenderer mare; + private PlaneRenderer stallion; public PonySnout(AbstractPonyModel pony, float yOffset, float stretch) { mare = new PlaneRenderer(pony); - mare.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - - mare.setTextureOffset(10, 14).addBackPlane(-2.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 2, stretch); - mare.setTextureOffset(11, 13).addBackPlane(-1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 2, 1, stretch); - mare.setTextureOffset(9, 14).addTopPlane(-2.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 1, 1, stretch); - mare.setTextureOffset(14, 14).addTopPlane(1.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 1, 1, stretch); - mare.setTextureOffset(11, 12).addTopPlane(-1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 2, 1, stretch); - mare.setTextureOffset(18, 7).addBottomPlane(-2.0F + HEAD_CENTRE_X, 4.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 1, stretch); - mare.setTextureOffset(9, 14).addWestPlane(-2.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 2, 1, stretch); - mare.setTextureOffset(14, 14).addEastPlane(2.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 2, 1, stretch); - mare.setTextureOffset(11, 12).addWestPlane(-1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 1, 1, stretch); - mare.setTextureOffset(12, 12).addEastPlane(1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 1, 1, stretch); - + mare.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(10, 14) .addBackPlane(-2, 2, -5, 4, 2, stretch) + .tex(11, 13) .addBackPlane(-1, 1, -5, 2, 1, stretch) + .tex(9, 14) .addTopPlane(-2, 2, -5, 1, 1, stretch) + .tex(14, 14) .addTopPlane( 1, 2, -5, 1, 1, stretch) + .tex(11, 12) .addTopPlane(-1, 1, -5, 2, 1, stretch) + .tex(18, 7).addBottomPlane(-2, 4, -5, 4, 1, stretch) + .tex(9, 14) .addWestPlane(-2, 2, -5, 2, 1, stretch) + .tex(14, 14) .addEastPlane( 2, 2, -5, 2, 1, stretch) + .tex(11, 12) .addWestPlane(-1, 1, -5, 1, 1, stretch) + .tex(12, 12) .addEastPlane( 1, 1, -5, 1, 1, stretch); pony.bipedHead.addChild(mare); stallion = new PlaneRenderer(pony); - stallion.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - - stallion.setTextureOffset(10, 13).addBackPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 3, stretch); - stallion.setTextureOffset(10, 13).addTopPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 1, stretch); - stallion.setTextureOffset(18, 7).addBottomPlane(-2.0F + HEAD_CENTRE_X, 4.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 1, stretch); - stallion.setTextureOffset(10, 13).addWestPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 3, 1, stretch); - stallion.setTextureOffset(13, 13).addEastPlane(2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 3, 1, stretch); - + stallion.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(10, 13) .addBackPlane(-2, 1, -5, 4, 3, stretch) + .tex(10, 13) .addTopPlane(-2, 1, -5, 4, 1, stretch) + .tex(18, 7).addBottomPlane(-2, 4, -5, 4, 1, stretch) + .tex(10, 13) .addWestPlane(-2, 1, -5, 3, 1, stretch) + .tex(13, 13) .addEastPlane( 2, 1, -5, 3, 1, stretch); pony.bipedHead.addChild(stallion); } From 17624c484a1c1b09388961be8211d8cb70640c95 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 09:46:44 +0200 Subject: [PATCH 35/96] Clean up elytra code --- .../model/components/PonyElytra.java | 81 ++++++++++--------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/components/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java index 16160059..18272972 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -1,6 +1,5 @@ package com.minelittlepony.model.components; -import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.render.PonyRenderer; import net.minecraft.client.entity.AbstractClientPlayer; @@ -10,6 +9,11 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.Vec3d; +import static com.minelittlepony.model.PonyModelConstants.*; + +/** + * Modified from ModelElytra. + */ public class PonyElytra extends ModelBase { private PonyRenderer rightWing = new PonyRenderer(this, 22, 0); private PonyRenderer leftWing = new PonyRenderer(this, 22, 0); @@ -28,55 +32,56 @@ public class PonyElytra extends ModelBase { } @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); + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entity) { + super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); - final float PI = (float) Math.PI; - float rotateX = PI / 2F; - float rotateY = PI / 8F; + float rotateX = PI / 2; + float rotateY = PI / 8; float rotateZ = PI / 12; - - float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK; - - if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).isElytraFlying()) { - float f4 = 1; - if (entityIn.motionY < 0) { - Vec3d vec3d = (new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ)).normalize(); - f4 = 1 - (float) Math.pow(-vec3d.y, 1.5); + float rpY = BODY_RP_Y_NOTSNEAK; + + if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { + float velY = 1; + + if (entity.motionY < 0) { + Vec3d motion = (new Vec3d(entity.motionX, entity.motionY, entity.motionZ)).normalize(); + velY = 1 - (float) Math.pow(-motion.y, 1.5); } - rotateX = f4 * PI * (2 / 3F) + (1 - f4) * rotateX; - rotateY = f4 * ((float) Math.PI / 2F) + (1 - f4) * rotateY; - } else if (entityIn.isSneaking()) { - rotateX = ((float) Math.PI * 1.175F); + rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX; + rotateY = velY * (PI / 2) + (1 - velY) * rotateY; + } else if (entity.isSneaking()) { + rotateX = PI * 1.175F; rotateY = PI / 2; - rpY = PonyModelConstants.BODY_RP_Y_SNEAK; - rotateZ = PI / 4F; + rotateZ = PI / 4; + rpY = BODY_RP_Y_SNEAK; } - this.leftWing.rotationPointX = 5; - this.leftWing.rotationPointY = rpY; + leftWing.rotationPointX = 5; + leftWing.rotationPointY = rpY; - if (entityIn instanceof AbstractClientPlayer) { - AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer) entityIn; - abstractclientplayer.rotateElytraX = (float) (abstractclientplayer.rotateElytraX + (rotateX - abstractclientplayer.rotateElytraX) * 0.1D); - abstractclientplayer.rotateElytraY = (float) (abstractclientplayer.rotateElytraY + (rotateY - abstractclientplayer.rotateElytraY) * 0.1D); - abstractclientplayer.rotateElytraZ = (float) (abstractclientplayer.rotateElytraZ + (rotateZ - abstractclientplayer.rotateElytraZ) * 0.1D); - this.leftWing.rotateAngleX = abstractclientplayer.rotateElytraX; - this.leftWing.rotateAngleY = abstractclientplayer.rotateElytraY; - this.leftWing.rotateAngleZ = abstractclientplayer.rotateElytraZ; + if (entity instanceof AbstractClientPlayer) { + AbstractClientPlayer player = (AbstractClientPlayer) entity; + + player.rotateElytraX += (rotateX - player.rotateElytraX) / 10; + player.rotateElytraY += (rotateY - player.rotateElytraY) / 10; + player.rotateElytraZ += (rotateZ - player.rotateElytraZ) / 10; + + leftWing.rotateAngleX = player.rotateElytraX; + leftWing.rotateAngleY = player.rotateElytraY; + leftWing.rotateAngleZ = player.rotateElytraZ; } else { - this.leftWing.rotateAngleX = rotateX; - this.leftWing.rotateAngleZ = rotateZ; - this.leftWing.rotateAngleY = rotateY; + leftWing.rotateAngleX = rotateX; + leftWing.rotateAngleZ = rotateZ; + leftWing.rotateAngleY = rotateY; } - this.rightWing.rotationPointX = -this.leftWing.rotationPointX; - this.rightWing.rotateAngleY = -this.leftWing.rotateAngleY; - this.rightWing.rotationPointY = this.leftWing.rotationPointY; - this.rightWing.rotateAngleX = this.leftWing.rotateAngleX; - this.rightWing.rotateAngleZ = -this.leftWing.rotateAngleZ; + rightWing.rotationPointX = -leftWing.rotationPointX; + rightWing.rotationPointY = leftWing.rotationPointY; + rightWing.rotateAngleX = leftWing.rotateAngleX; + rightWing.rotateAngleY = -leftWing.rotateAngleY; + rightWing.rotateAngleZ = -leftWing.rotateAngleZ; } } From 7d8e971f038c32a25f8a642933d781758d2313d3 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 09:47:23 +0200 Subject: [PATCH 36/96] Rename BasePonyRenderer -> AbstractPonyRenderer --- .../{BasePonyRenderer.java => AbstractPonyRenderer.java} | 6 +++--- .../java/com/minelittlepony/render/HornGlowRenderer.java | 2 +- src/main/java/com/minelittlepony/render/PonyRenderer.java | 2 +- .../java/com/minelittlepony/render/plane/PlaneRenderer.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/com/minelittlepony/render/{BasePonyRenderer.java => AbstractPonyRenderer.java} (95%) diff --git a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java similarity index 95% rename from src/main/java/com/minelittlepony/render/BasePonyRenderer.java rename to src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index 5ee0a305..43a2c9a2 100644 --- a/src/main/java/com/minelittlepony/render/BasePonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -6,7 +6,7 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.TextureOffset; @SuppressWarnings("unchecked") -public abstract class BasePonyRenderer> extends ModelRenderer { +public abstract class AbstractPonyRenderer> extends ModelRenderer { protected final ModelBase baseModel; @@ -17,12 +17,12 @@ public abstract class BasePonyRenderer> extends Mo protected float modelOffsetY; protected float modelOffsetZ; - public BasePonyRenderer(ModelBase model) { + public AbstractPonyRenderer(ModelBase model) { super(model); baseModel = model; } - public BasePonyRenderer(ModelBase model, int x, int y) { + public AbstractPonyRenderer(ModelBase model, int x, int y) { super(model, x, y); baseModel = model; } diff --git a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java index dcc3b0f3..e767cf10 100644 --- a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java @@ -4,7 +4,7 @@ import static net.minecraft.client.renderer.GlStateManager.color; import net.minecraft.client.model.ModelBase; -public class HornGlowRenderer extends BasePonyRenderer { +public class HornGlowRenderer extends AbstractPonyRenderer { float red; float green; diff --git a/src/main/java/com/minelittlepony/render/PonyRenderer.java b/src/main/java/com/minelittlepony/render/PonyRenderer.java index 102dc0ff..61f2d204 100644 --- a/src/main/java/com/minelittlepony/render/PonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/PonyRenderer.java @@ -2,7 +2,7 @@ package com.minelittlepony.render; import net.minecraft.client.model.ModelBase; -public class PonyRenderer extends BasePonyRenderer { +public class PonyRenderer extends AbstractPonyRenderer { public PonyRenderer(ModelBase model) { super(model); diff --git a/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java index c5560169..d1076f90 100644 --- a/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java +++ b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java @@ -1,10 +1,10 @@ package com.minelittlepony.render.plane; -import com.minelittlepony.render.BasePonyRenderer; +import com.minelittlepony.render.AbstractPonyRenderer; import net.minecraft.client.model.ModelBase; -public class PlaneRenderer extends BasePonyRenderer { +public class PlaneRenderer extends AbstractPonyRenderer { public boolean mirrory, mirrorz; From 7fbb56ad7934d5afef8b525244c7daec34a4a6b4 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 09:48:55 +0200 Subject: [PATCH 37/96] No changes, just whitespace --- .../model/AbstractPonyModel.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 12115e0a..8cb5b222 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -33,17 +33,17 @@ public abstract class AbstractPonyModel extends ModelPlayer { * Associcated pony data. */ public IPonyData metadata = new PonyData(); - + /** * Vertical pitch whilst flying. */ public float motionPitch; - + /** * Flag indicating that this model is performing a rainboom (flight). */ public boolean rainboom; - + public AbstractPonyModel(boolean arms) { super(0, arms); } @@ -57,12 +57,12 @@ public abstract class AbstractPonyModel extends ModelPlayer { initTextures(); initPositions(yOffset, stretch); } - + /** * Returns a new pony armour to go with this model. Called on startup by a model wrapper. */ public abstract PonyArmor createArmour(); - + /** * Loads texture values. */ @@ -86,7 +86,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { protected boolean doCancelRender() { return false; } - + /** * Returns true if this model is on the ground and crouching. */ @@ -101,7 +101,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { return (isFlying && metadata.getRace().hasWings()) || (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()); } - + /** * Returns true if the current model is a child or a child-like foal. */ @@ -117,7 +117,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { renderer.rotationPointY += y; renderer.rotationPointZ += z; } - + /** * Rotates the provided arm to the correct orientation for holding an item. * @@ -129,7 +129,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { float swing = MathHelper.sin(swingProgress * (float)Math.PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); - + arm.rotateAngleZ = 0; arm.rotateAngleY = direction * (0.1F - swing * 0.6F); arm.rotateAngleX = -1.5707964F; @@ -167,7 +167,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { rotate(motionPitch, 1, 0, 0); } } - + private void transformTall(BodyPart part) { if (isSleeping) translate(0, -0.65F, 0.25F); @@ -193,7 +193,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { break; } } - + private void transformLarge(BodyPart part) { if (this.isSleeping) translate(0, -0.7F, 0.2F); @@ -222,12 +222,12 @@ public abstract class AbstractPonyModel extends ModelPlayer { break; } } - + private void transformFoal(BodyPart part) { if (isCrouching()) translate(0, -0.12F, 0); if (isSleeping) translate(0, -1.2F, 0.25F); if (isRiding) translate(0, -0.1F, 0); - + switch (part) { case NECK: case HEAD: From 0e0ee17f46ec8230c8e88d53190b10294668d44f Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 13:49:33 +0200 Subject: [PATCH 38/96] Codestyle to remove all trailing whitespace, unneccessary this arguments, and standardise parameter names --- .../java/com/minelittlepony/ForgeProxy.java | 6 +- .../minelittlepony/LiteModMineLittlePony.java | 6 +- .../com/minelittlepony/MineLittlePony.java | 4 +- .../java/com/minelittlepony/PonyManager.java | 40 ++-- .../com/minelittlepony/PonyRenderManager.java | 14 +- .../com/minelittlepony/PonySettingPanel.java | 34 ++-- .../com/minelittlepony/ducks/IPlayerInfo.java | 2 +- .../ducks/IPonyAnimationHolder.java | 2 +- .../com/minelittlepony/ducks/IRenderPony.java | 5 + .../hdskins/gui/GuiSkinsMineLP.java | 8 +- .../mixin/MixinEntityLivingBase.java | 4 +- .../mixin/MixinRenderManager.java | 1 + .../mixin/MixinThreadDownloadImageData.java | 1 + .../model/AbstractPonyModel.java | 10 +- .../minelittlepony/model/ModelMobPony.java | 14 +- .../minelittlepony/model/ModelWrapper.java | 6 +- .../model/armour/ModelPonyArmor.java | 107 +++++----- .../model/armour/ModelSkeletonPonyArmor.java | 2 +- .../model/armour/ModelZombiePonyArmor.java | 8 +- .../model/armour/PonyArmor.java | 19 +- .../model/components/ModelWing.java | 16 +- .../model/components/PegasusWings.java | 46 ++--- .../model/components/PonyElytra.java | 10 +- .../model/components/PonyTail.java | 42 ++-- .../model/components/UnicornHorn.java | 10 +- .../model/player/PlayerModels.java | 2 +- .../model/ponies/ModelBreezie.java | 187 +++++++++--------- .../model/ponies/ModelHumanPlayer.java | 4 +- .../model/ponies/ModelIllagerPony.java | 56 +++--- .../model/ponies/ModelPlayerPony.java | 157 +++++++-------- .../model/ponies/ModelSkeletonPony.java | 15 +- .../model/ponies/ModelVillagerPony.java | 28 +-- .../model/ponies/ModelZombiePony.java | 6 +- .../pony/data/ITriggerPixelMapped.java | 4 +- .../com/minelittlepony/pony/data/Pony.java | 10 +- .../minelittlepony/pony/data/PonyData.java | 24 +-- .../minelittlepony/pony/data/PonyGender.java | 4 +- .../minelittlepony/pony/data/PonyRace.java | 4 +- .../minelittlepony/pony/data/PonySize.java | 2 +- .../minelittlepony/pony/data/TailLengths.java | 6 +- .../pony/data/TriggerPixels.java | 8 +- .../render/AbstractPonyRenderer.java | 32 +-- .../com/minelittlepony/render/HornGlow.java | 14 +- .../minelittlepony/render/PonyRenderer.java | 2 +- .../minelittlepony/render/RenderPonyMob.java | 46 ++--- .../render/layer/AbstractPonyLayer.java | 9 +- .../layer/LayerEntityOnPonyShoulder.java | 29 +-- .../render/layer/LayerHeldPonyItem.java | 36 ++-- .../render/layer/LayerOverlayBase.java | 17 +- .../render/layer/LayerPonyArmor.java | 102 +++++----- .../render/layer/LayerPonyCape.java | 57 +++--- .../render/layer/LayerPonyCustomHead.java | 14 +- .../render/layer/LayerPonyElytra.java | 18 +- .../render/layer/LayerPonyStrayOverlay.java | 10 +- .../render/plane/ModelPlane.java | 10 +- .../render/player/RenderPonyBase.java | 66 +++---- .../render/player/RenderPonyPlayer.java | 12 +- .../render/ponies/RenderPonyEvoker.java | 22 ++- .../ponies/RenderPonyIllusionIllager.java | 38 ++-- .../render/ponies/RenderPonyPigman.java | 4 +- .../render/ponies/RenderPonySkeleton.java | 12 +- .../render/ponies/RenderPonyVex.java | 6 +- .../render/ponies/RenderPonyVillager.java | 8 +- .../render/ponies/RenderPonyVindicator.java | 18 +- .../render/ponies/RenderPonyZombie.java | 32 +-- .../ponies/RenderPonyZombieVillager.java | 16 +- .../render/ponies/package-info.java | 8 - 67 files changed, 802 insertions(+), 770 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/render/ponies/package-info.java diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java index 7c888acc..f4f314ae 100644 --- a/src/main/java/com/minelittlepony/ForgeProxy.java +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -19,7 +19,7 @@ import java.util.function.Function; * Proxy class for accessing forge fields and methods. */ public class ForgeProxy { - + /** * True if forge is present. */ @@ -27,7 +27,7 @@ public class ForgeProxy { /** * Gets the mod armour texture for associated item and slot. - * + * * @param entity The entity to get armour for. * @param item The armour item * @param def Default return value if no mods present @@ -43,7 +43,7 @@ public class ForgeProxy { /** * Gets the mod armour texture for associated item and slot. - * + * * @param entity The entity to get armour for. * @param item The armour item * @param slot The slot this armour piece is place in. diff --git a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java index 0a19818e..2a9d5612 100644 --- a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java +++ b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java @@ -27,16 +27,16 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener { @Override public void init(File configPath) { - this.mlp = new MineLittlePony(); + mlp = new MineLittlePony(); } @Override public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { - this.mlp.postInit(minecraft); + mlp.postInit(minecraft); } @Override public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { - this.mlp.onTick(minecraft, inGame); + mlp.onTick(minecraft, inGame); } } diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index 965d9139..c566d09f 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -48,7 +48,7 @@ public class MineLittlePony { config = new PonyConfig(); ponyManager = new PonyManager(config); renderManager = new PonyRenderManager(); - + LiteLoader.getInstance().registerExposable(config, null); IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); @@ -108,7 +108,7 @@ public class MineLittlePony { public PonyManager getManager() { return ponyManager; } - + /** * Gets the static pony render manager responsible for all entity renderers. */ diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 0b8b7121..da2134de 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -62,7 +62,7 @@ public class PonyManager implements IResourceManagerReloadListener { /** * Gets or creates a pony for the given skin resource and vanilla model type. - * + * * @param resource A texture resource */ public Pony getPony(ResourceLocation resource, boolean slim) { @@ -72,45 +72,45 @@ public class PonyManager implements IResourceManagerReloadListener { /** * Gets or creates a pony for the given player. * Delegates to the background-ponies registry if no pony skins were available and client settings allows it. - * + * * @param player the player */ public Pony getPony(AbstractClientPlayer player) { return getPony(IPlayerInfo.getPlayerInfo(player).unwrap()); } - + public Pony getPony(NetworkPlayerInfo playerInfo) { ResourceLocation skin = playerInfo.getLocationSkin(); UUID uuid = playerInfo.getGameProfile().getId(); - + if (skin == null) return getDefaultPony(uuid); - + return getPony(skin, uuid); } - + /** * Gets or creates a pony for the given skin resource and entity id. - * + * * Whether is has slim arms is determined by the id. - * + * * Delegates to the background-ponies registry if no pony skins were available and client settings allows it. - * + * * @param resource A texture resource * @param uuid id of a player or entity */ public Pony getPony(ResourceLocation resource, UUID uuid) { Pony pony = getPony(resource, isSlimSkin(uuid)); - + if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { return getBackgroundPony(uuid); } - + return pony; } /** * Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings. - * + * * @param uuid id of a player or entity */ public Pony getDefaultPony(UUID uuid) { @@ -131,7 +131,7 @@ public class PonyManager implements IResourceManagerReloadListener { return getPony(backgroundPonyList.get(bgi), false); } - + private boolean isUser(UUID uuid) { return Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.getUniqueID().equals(uuid); } @@ -145,17 +145,17 @@ public class PonyManager implements IResourceManagerReloadListener { @Override public void onResourceManagerReload(IResourceManager resourceManager) { - this.poniesCache.clear(); - this.backgroudPoniesCache.clear(); - this.backgroundPonyList.clear(); + poniesCache.clear(); + backgroudPoniesCache.clear(); + backgroundPonyList.clear(); try { for (IResource res : resourceManager.getAllResources(BGPONIES_JSON)) { try (Reader reader = new InputStreamReader((res.getInputStream()))) { BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class); if (ponies.override) { - this.backgroundPonyList.clear(); + backgroundPonyList.clear(); } - this.backgroundPonyList.addAll(ponies.getPonies()); + backgroundPonyList.addAll(ponies.getPonies()); } catch (JsonParseException e) { MineLittlePony.logger.error("Invalid bgponies.json in " + res.getResourcePackName(), e); } @@ -169,7 +169,7 @@ public class PonyManager implements IResourceManagerReloadListener { private ResourceLocation getDefaultSkin(UUID uuid) { return isSlimSkin(uuid) ? ALEX : STEVE; } - + /** * Returns true if the given uuid is of a player would would use the ALEX skin type. */ @@ -196,7 +196,7 @@ public class PonyManager implements IResourceManagerReloadListener { } public List getPonies() { - return this.ponies.stream().map(this::apply).collect(Collectors.toList()); + return ponies.stream().map(this::apply).collect(Collectors.toList()); } } } diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index bb14bbbe..a408afaa 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -40,20 +40,20 @@ import net.minecraft.entity.passive.EntityVillager; * Old values of persisted internally. */ public class PonyRenderManager { - + private final Map, Render> renderMap = Maps.newHashMap(); - + public PonyRenderManager() { - + } - + /** * Registers all new player skin types. (currently only pony and slimpony). */ public void initialisePlayerRenderers(RenderManager rm) { // Preview on the select skin gui ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); - + new RenderPonyPlayer(rm, false, "pony", PMAPI.pony); new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall); //TODO: Add skin types for each species? May require model break up. @@ -63,7 +63,7 @@ public class PonyRenderManager { * Registers all entity model replacements. (except for players). */ public void initializeMobRenderers(RenderManager rm, PonyConfig config) { - + if (config.villagers) { pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm)); pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); @@ -129,7 +129,7 @@ public class PonyRenderManager { } ModUtilities.addRenderer(type, renderer); } - + /** * Restores a renderer to its previous value. */ diff --git a/src/main/java/com/minelittlepony/PonySettingPanel.java b/src/main/java/com/minelittlepony/PonySettingPanel.java index 935f429e..1e2095b1 100644 --- a/src/main/java/com/minelittlepony/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/PonySettingPanel.java @@ -65,22 +65,22 @@ public class PonySettingPanel extends GuiScreen { final int LEFT = width / 10 + 16; GuiCheckbox pony, human, both, hd, sizes, snuzzles, showscale, villager, zombie, pigmen, skeleton, illager; int row = 32; - this.buttonList.add(pony = ponies = new GuiCheckbox(PONY_ID, LEFT, row += 15, I18n.format(PONY))); - this.buttonList.add(human = humans = new GuiCheckbox(HUMAN_ID, LEFT, row += 15, I18n.format(HUMAN))); - this.buttonList.add(both = this.both = new GuiCheckbox(BOTH_ID, LEFT, row += 15, I18n.format(BOTH))); + buttonList.add(pony = ponies = new GuiCheckbox(PONY_ID, LEFT, row += 15, I18n.format(PONY))); + buttonList.add(human = humans = new GuiCheckbox(HUMAN_ID, LEFT, row += 15, I18n.format(HUMAN))); + buttonList.add(both = this.both = new GuiCheckbox(BOTH_ID, LEFT, row += 15, I18n.format(BOTH))); row += 15; - this.buttonList.add(hd = new GuiCheckbox(HD_ID, LEFT, row += 15, I18n.format(HD))); - this.buttonList.add(sizes = new GuiCheckbox(SIZES_ID, LEFT, row += 15, I18n.format(SIZES))); - this.buttonList.add(snuzzles = new GuiCheckbox(SNUZZLES_ID, LEFT, row += 15, I18n.format(SNUZZLES))); - this.buttonList.add(showscale = new GuiCheckbox(SHOW_SCALE_ID, LEFT, row += 15, I18n.format(SHOW_SCALE))); + buttonList.add(hd = new GuiCheckbox(HD_ID, LEFT, row += 15, I18n.format(HD))); + buttonList.add(sizes = new GuiCheckbox(SIZES_ID, LEFT, row += 15, I18n.format(SIZES))); + buttonList.add(snuzzles = new GuiCheckbox(SNUZZLES_ID, LEFT, row += 15, I18n.format(SNUZZLES))); + buttonList.add(showscale = new GuiCheckbox(SHOW_SCALE_ID, LEFT, row += 15, I18n.format(SHOW_SCALE))); final int RIGHT = width - width / 3; row = 32; - this.buttonList.add(villager = new GuiCheckbox(VILLAGERS_ID, RIGHT, row += 15, I18n.format(VILLAGERS))); - this.buttonList.add(zombie = new GuiCheckbox(ZOMBIES_ID, RIGHT, row += 15, I18n.format(ZOMBIES))); - this.buttonList.add(pigmen = new GuiCheckbox(ZOMBIE_PIGMEN_ID, RIGHT, row += 15, I18n.format(ZOMBIE_PIGMEN))); - this.buttonList.add(skeleton = new GuiCheckbox(SKELETONS_ID, RIGHT, row += 15, I18n.format(SKELETONS))); - this.buttonList.add(illager = new GuiCheckbox(ILLAGER_ID, RIGHT, row += 15, I18n.format(ILLAGERS))); + buttonList.add(villager = new GuiCheckbox(VILLAGERS_ID, RIGHT, row += 15, I18n.format(VILLAGERS))); + buttonList.add(zombie = new GuiCheckbox(ZOMBIES_ID, RIGHT, row += 15, I18n.format(ZOMBIES))); + buttonList.add(pigmen = new GuiCheckbox(ZOMBIE_PIGMEN_ID, RIGHT, row += 15, I18n.format(ZOMBIE_PIGMEN))); + buttonList.add(skeleton = new GuiCheckbox(SKELETONS_ID, RIGHT, row += 15, I18n.format(SKELETONS))); + buttonList.add(illager = new GuiCheckbox(ILLAGER_ID, RIGHT, row += 15, I18n.format(ILLAGERS))); switch (config.getPonyLevel()) { default: @@ -107,13 +107,13 @@ public class PonySettingPanel extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - this.drawDefaultBackground(); + drawDefaultBackground(); - this.drawCenteredString(mc.fontRenderer, I18n.format(TITLE), width / 2, 12, -1); + drawCenteredString(mc.fontRenderer, I18n.format(TITLE), width / 2, 12, -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); + drawString(mc.fontRenderer, I18n.format(MOB_TITLE), width - width / 3 - 16, 32, -1); + drawString(mc.fontRenderer, I18n.format(PONY_LEVEL), width / 10, 32, -1); + drawString(mc.fontRenderer, I18n.format(OPTIONS), width / 10, 94, -1); super.drawScreen(mouseX, mouseY, partialTicks); } diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index a8474fd3..6bb623f7 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -16,7 +16,7 @@ public interface IPlayerInfo { public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) { return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID()); } - + default NetworkPlayerInfo unwrap() { return (NetworkPlayerInfo)this; } diff --git a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java index 2351fca3..9d91c168 100644 --- a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java +++ b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java @@ -4,7 +4,7 @@ package com.minelittlepony.ducks; * Holding class for entities that support special pony animations used for the renderers. */ public interface IPonyAnimationHolder { - + /** * Updates and gets the amount this entity is strafing to each side. */ diff --git a/src/main/java/com/minelittlepony/ducks/IRenderPony.java b/src/main/java/com/minelittlepony/ducks/IRenderPony.java index 8af9d081..d630a50a 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderPony.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderPony.java @@ -11,4 +11,9 @@ public interface IRenderPony { * Gets the wrapped pony model for this renderer. */ ModelWrapper getPlayerModel(); + + /** + * Gets the current shadow size for rendering. + */ + float getShadowScale(); } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java index b45afce7..2bad9f35 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -16,7 +16,7 @@ public class GuiSkinsMineLP extends GuiSkins { private PonyManager ponyManager; public GuiSkinsMineLP(PonyManager manager) { - this.ponyManager = manager; + ponyManager = manager; } @Override @@ -28,7 +28,7 @@ public class GuiSkinsMineLP extends GuiSkins { protected void onSetLocalSkin(MinecraftProfileTexture.Type type) { MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); if (type == MinecraftProfileTexture.Type.SKIN) { - ponyManager.removePony(this.localPlayer.getSkinTexture()); + ponyManager.removePony(localPlayer.getSkinTexture()); } } @@ -43,8 +43,8 @@ public class GuiSkinsMineLP extends GuiSkins { @Override public void onGuiClosed() { super.onGuiClosed(); - ponyManager.removePony(this.localPlayer.getSkinTexture()); - ponyManager.removePony(this.remotePlayer.getSkinTexture()); + ponyManager.removePony(localPlayer.getSkinTexture()); + ponyManager.removePony(remotePlayer.getSkinTexture()); } } diff --git a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java index 2ca11143..f0646c58 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java +++ b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java @@ -25,7 +25,7 @@ public abstract class MixinEntityLivingBase extends Entity implements IPonyAnima @Override public float getStrafeAmount(float ticks) { - float strafing = this.moveStrafing; + float strafing = moveStrafing; if (strafing != 0) { if (Math.abs(strafeRollAmount) < Math.abs(strafing)) { strafeRollAmount += strafing/10; @@ -33,7 +33,7 @@ public abstract class MixinEntityLivingBase extends Entity implements IPonyAnima } else { strafeRollAmount *= 0.8; } - + return (float)Math.toDegrees(strafeRollAmount); } } diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java index 3ec1dbc3..8b732680 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java @@ -16,6 +16,7 @@ public abstract class MixinRenderManager implements IRenderManager { @Shadow @Final private Map skinMap; + @Override public void addPlayerSkin(String key, RenderPlayer render) { skinMap.put(key, render); } diff --git a/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java index 990bc1c3..835fb3f6 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java +++ b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java @@ -18,6 +18,7 @@ public abstract class MixinThreadDownloadImageData extends SimpleTexture impleme super(textureResourceLocation); } + @Override @Accessor("bufferedImage") public abstract BufferedImage getBufferedImage(); } diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 8cb5b222..2cbc1d19 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -74,9 +74,9 @@ public abstract class AbstractPonyModel extends ModelPlayer { protected abstract void initPositions(float yOffset, float stretch); @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { if (doCancelRender()) { - super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); } } @@ -120,7 +120,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { /** * Rotates the provided arm to the correct orientation for holding an item. - * + * * @param arm The arm to rotate * @param direction Direction multiplier. 1 for right, -1 for left. * @param swingProgress How far we are through the current swing @@ -140,7 +140,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { /** * Applies a transform particular to a certain body part. - * + * * FIXME: Too long! Is there a better way to do this? */ public void transform(BodyPart part) { @@ -195,7 +195,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { } private void transformLarge(BodyPart part) { - if (this.isSleeping) translate(0, -0.7F, 0.2F); + if (isSleeping) translate(0, -0.7F, 0.2F); switch (part) { case HEAD: diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index 69173516..fbddc04a 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -17,21 +17,21 @@ public class ModelMobPony extends ModelPlayerPony { @Override protected void rotateLegs(float move, float swing, float tick, Entity entity) { super.rotateLegs(move, swing, tick, entity); - + rotateRightArm(move, tick); rotateLeftArm(move, tick); } - + /** * Called to update the left arm's final rotation. * Subclasses may replace it with their own implementations. - * + * * @param move Limb swing amount. * @param tick Render partial ticks. */ protected void rotateRightArm(float move, float tick) { - if (this.rightArmPose == ArmPose.EMPTY) return; - + if (rightArmPose == ArmPose.EMPTY) return; + if (!metadata.hasMagic()) { rotateArmHolding(bipedRightArm, -1, swingProgress, tick); } else { @@ -39,10 +39,10 @@ public class ModelMobPony extends ModelPlayerPony { rotateArmHolding(unicornArmRight, -1, swingProgress, tick); } } - + /** * Same as rotateRightArm but for the left arm (duh). - * + * * @param move Limb swing amount. * @param tick Render partial ticks. */ diff --git a/src/main/java/com/minelittlepony/model/ModelWrapper.java b/src/main/java/com/minelittlepony/model/ModelWrapper.java index ede02d2f..854fe358 100644 --- a/src/main/java/com/minelittlepony/model/ModelWrapper.java +++ b/src/main/java/com/minelittlepony/model/ModelWrapper.java @@ -16,8 +16,8 @@ public class ModelWrapper { */ public ModelWrapper(AbstractPonyModel model) { this.model = model; - this.armor = model.createArmour(); - this.armor.apply(model.metadata); + armor = model.createArmour(); + armor.apply(model.metadata); } public AbstractPonyModel getModel() { @@ -39,7 +39,7 @@ public class ModelWrapper { model.metadata = meta; armor.apply(meta); } - + /** * Called at startup to configure a model's needed components. */ diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index 32e56476..ba5d30fb 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -10,18 +10,24 @@ import com.minelittlepony.render.PonyRenderer; public class ModelPonyArmor extends ModelMobPony { - public PonyRenderer Bodypiece, extBody, extLegLeft, extLegRight, extHead; - + public PonyRenderer flankGuard; + + public PonyRenderer saddle; + public PonyRenderer helmet; + + public PonyRenderer leftLegging; + public PonyRenderer rightLegging; + public ModelPonyArmor() { super(); - this.textureHeight = 32; + textureHeight = 32; } - + @Override protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { bipedBody.rotateAngleY = bodySwing * 0.2F; } - + @Override protected void adjustBodyRiding() { adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); @@ -30,14 +36,14 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void setHead(float posX, float posY, float posZ) { super.setHead(posX, posY, posZ); - extHead.setRotationPoint(posX, posY, posZ); + helmet.setRotationPoint(posX, posY, posZ); } @Override protected void updateHeadRotation(float x, float y) { super.updateHeadRotation(x, y); - extHead.rotateAngleX = x; - extHead.rotateAngleY = y; + helmet.rotateAngleX = x; + helmet.rotateAngleY = y; } @Override @@ -45,20 +51,20 @@ public class ModelPonyArmor extends ModelMobPony { bipedBody.rotateAngleX = rotateAngleX; bipedBody.rotationPointY = rotationPointY; bipedBody.rotationPointZ = rotationPointZ; - - Bodypiece.rotateAngleX = rotateAngleX; - Bodypiece.rotationPointY = rotationPointY; - Bodypiece.rotationPointZ = rotationPointZ; - - extBody.rotateAngleX = rotateAngleX; - extBody.rotationPointY = rotationPointY; - extBody.rotationPointZ = rotationPointZ; + + flankGuard.rotateAngleX = rotateAngleX; + flankGuard.rotationPointY = rotationPointY; + flankGuard.rotationPointZ = rotationPointZ; + + saddle.rotateAngleX = rotateAngleX; + saddle.rotationPointY = rotationPointY; + saddle.rotationPointZ = rotationPointZ; } @Override protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { bipedHead.render(this.scale); - extHead.render(this.scale); + helmet.render(this.scale); bipedHeadwear.render(this.scale); } @@ -69,24 +75,24 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { bipedBody.render(this.scale); - Bodypiece.render(this.scale); - extBody.render(this.scale); + flankGuard.render(this.scale); + saddle.render(this.scale); } @Override protected void renderLegs() { if (!isSneak) { - boolean isLegs = this.extBody.showModel; - extBody.showModel = true; - extBody.postRender(scale); - extBody.showModel = isLegs; + boolean isLegs = saddle.showModel; + saddle.showModel = true; + saddle.postRender(scale); + saddle.showModel = isLegs; } bipedLeftArm.render(scale); bipedRightArm.render(scale); bipedLeftLeg.render(scale); bipedRightLeg.render(scale); - extLegRight.render(scale); - extLegLeft.render(scale); + rightLegging.render(scale); + leftLegging.render(scale); } @Override @@ -100,46 +106,46 @@ public class ModelPonyArmor extends ModelMobPony { protected void initHeadTextures() { bipedHead = new ModelRenderer(this, 0, 0); bipedHeadwear = new ModelRenderer(this, 32, 0); - extHead = new PonyRenderer(this, 0, 0); + helmet = new PonyRenderer(this, 0, 0); } @Override protected void initBodyTextures() { bipedBody = new PonyRenderer(this, 16, 16); - Bodypiece = new PonyRenderer(this, 0, 0); - extBody = new PonyRenderer(this, 16, 8); + flankGuard = new PonyRenderer(this, 0, 0); + saddle = new PonyRenderer(this, 16, 8); } @Override protected void initLegTextures() { bipedRightArm = new PonyRenderer(this, 0, 16); bipedRightLeg = new ModelRenderer(this, 0, 16); - + bipedLeftArm = new PonyRenderer(this, 0, 16).mirror(); bipedLeftLeg = new PonyRenderer(this, 0, 16).mirror(); - + unicornArmRight = new PonyRenderer(this, 0, 16); unicornArmLeft = new PonyRenderer(this, 0, 16); - - extLegLeft = new PonyRenderer(this, 48, 8); - extLegRight = new PonyRenderer(this, 48, 8); + + leftLegging = new PonyRenderer(this, 48, 8); + rightLegging = new PonyRenderer(this, 48, 8); } @Override protected void initTailPositions(float yOffset, float stretch) { - + } @Override protected void initHeadPositions(float yOffset, float stretch) { bipedHead .addBox(HEAD_CENTRE_X - 4, HEAD_CENTRE_Y - 4, HEAD_CENTRE_Z - 4, 8, 8, 8, stretch * 1.1F); bipedHeadwear.addBox(HEAD_CENTRE_X - 4, HEAD_CENTRE_Y - 4, HEAD_CENTRE_Z - 4, 8, 8, 8, stretch * 1.1F + 0.5F); - - extHead.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + + helmet.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .box(-4, -6, 1, 2, 2, 2, stretch * 0.5F) .tex(0, 4).box( 2, -6, 1, 2, 2, 2, stretch * 0.5F); - + bipedHead .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); } @@ -148,28 +154,28 @@ public class ModelPonyArmor extends ModelMobPony { protected void initBodyPositions(float yOffset, float stretch) { bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch); - - Bodypiece.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + + flankGuard.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .box(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch); - extBody.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + saddle.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .box(-4.0F, 4.0F, -2.0F, 8, 8, 16, stretch); } @Override protected void initLegPositions(float yOffset, float stretch) { super.initLegPositions(yOffset, stretch); - - extLegLeft.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) + + leftLegging.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) .around(3, yOffset, 0) .box(-2, -6, -2, 4, 12, 4, stretch); - extLegRight.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) + rightLegging.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) .around(-3, yOffset, 0) .mirror().box(-2, -6, -2, 4, 12, 4, stretch); } protected void syncLegs() { - extLegRight.rotateAt(bipedRightLeg).rotateTo(bipedRightLeg); - extLegLeft.rotateAt(bipedLeftLeg).rotateTo(bipedLeftLeg); + rightLegging.rotateAt(bipedRightLeg).rotateTo(bipedRightLeg); + leftLegging.rotateAt(bipedLeftLeg).rotateTo(bipedLeftLeg); } @Override @@ -196,12 +202,13 @@ public class ModelPonyArmor extends ModelMobPony { syncLegs(); } + @Override public void setVisible(boolean invisible) { super.setVisible(invisible); - Bodypiece.showModel = invisible; - extBody.showModel = invisible; - extHead.showModel = invisible; - extLegLeft.showModel = invisible; - extLegRight.showModel = invisible; + flankGuard.showModel = invisible; + saddle.showModel = invisible; + helmet.showModel = invisible; + leftLegging.showModel = invisible; + rightLegging.showModel = invisible; } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java index 5f1b4ffb..86d32d22 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -17,7 +17,7 @@ public class ModelSkeletonPonyArmor extends ModelPonyArmor { @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { - bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4.0F); + bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index ecd6d452..dab818d7 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -4,11 +4,11 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.util.math.MathHelper; public class ModelZombiePonyArmor extends ModelPonyArmor { - + private boolean isRight(float move) { return MathHelper.sin(move / 20f) < 0; } - + // Copied from ModelZombiePony @Override protected void rotateRightArm(float move, float tick) { @@ -20,7 +20,7 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); } } - + @Override protected void rotateLeftArm(float move, float tick) { // Zombies are unidexterous. @@ -32,7 +32,7 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { boolean right = isRight(move); float xchange = right ? 0.5f : -0.5f; ModelRenderer arm = right ? bipedRightArm : bipedLeftArm; - + shiftRotationPoint(arm, xchange, 1.5f, 3); } } diff --git a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java index d5094257..eccb0ee7 100644 --- a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java @@ -5,20 +5,21 @@ import com.minelittlepony.pony.data.IPonyData; public class PonyArmor { - public final AbstractPonyModel modelArmorChestplate, modelArmor; - + public final AbstractPonyModel chestplate; + public final AbstractPonyModel armour; + public PonyArmor(AbstractPonyModel chest, AbstractPonyModel body) { - this.modelArmorChestplate = chest; - this.modelArmor = body; + chestplate = chest; + armour = body; } - + public void apply(IPonyData meta) { - modelArmorChestplate.metadata = meta; - modelArmor.metadata = meta; + chestplate.metadata = meta; + armour.metadata = meta; } public void init() { - modelArmorChestplate.init(0, 1); - modelArmor.init(0, 0.5f); + chestplate.init(0, 1); + armour.init(0, 0.5f); } } diff --git a/src/main/java/com/minelittlepony/model/components/ModelWing.java b/src/main/java/com/minelittlepony/model/components/ModelWing.java index b09e3120..3f602d73 100644 --- a/src/main/java/com/minelittlepony/model/components/ModelWing.java +++ b/src/main/java/com/minelittlepony/model/components/ModelWing.java @@ -10,20 +10,20 @@ public class ModelWing { public PonyRenderer folded; private boolean mirror; - + public ModelWing(AbstractPonyModel pony, boolean mirror, float x, float y, float scale, int texY) { this.mirror = mirror; - + folded = new PonyRenderer(pony, 56, texY) .around(HEAD_RP_X, WING_FOLDED_RP_Y, WING_FOLDED_RP_Z); extended = new PonyRenderer(pony, 56, texY + 3) .around(HEAD_RP_X, WING_FOLDED_RP_Y, WING_FOLDED_RP_Z).mirror(mirror); - - addCloseWing(x, y, scale); + + addClosedWing(x, y, scale); addFeathers(mirror, y, scale); } - - private void addCloseWing(float x, float y, float scale) { + + private void addClosedWing(float x, float y, float scale) { folded.box(x, 5f, 2, 2, 6, 2, scale) .box(x, 5f, 4, 2, 8, 2, scale) .box(x, 5f, 6, 2, 6, 2, scale) @@ -50,11 +50,11 @@ public class ModelWing { folded.rotateAngleY = swing * 0.2F; } - + public void render(boolean extend, float scale) { extended.rotationPointX = (mirror ? -1 : 1) * LEFT_WING_EXT_RP_X; extended.rotationPointY = LEFT_WING_EXT_RP_Y; - + extended.rotateAngleY = 3; if (extend) { extended.render(scale); diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index 6ee7884d..7f2ea4bf 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -15,58 +15,58 @@ public class PegasusWings extends ModelBase { public final ModelWing leftWing; public final ModelWing rightWing; - public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) { - this.pony = pony; - + public PegasusWings(AbstractPonyModel model, float yOffset, float stretch) { + pony = model; + leftWing = new ModelWing(pony, false, 4f, yOffset, stretch, 32); rightWing = new ModelWing(pony, true, -6f, yOffset, stretch, 16); } @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ticks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { if (!isVisible()) return; - - float swing = 0; - + + float flap = 0; + if (pony.swingProgress > 0) { - swing = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * PI * 2); + flap = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * PI * 2); } else { - float pi = PI * (float) Math.pow(limbSwingAmount, 16); - - float mve = limbSwing * 0.6662f; // magic number ahoy - float srt = limbSwingAmount / 4; - - swing = MathHelper.cos(mve + pi) * srt; + float pi = PI * (float) Math.pow(swing, 16); + + float mve = move * 0.6662f; // magic number ahoy + float srt = swing / 4; + + flap = MathHelper.cos(mve + pi) * srt; } - - leftWing.rotateWalking(swing); - rightWing.rotateWalking(-swing); - + + leftWing.rotateWalking(flap); + rightWing.rotateWalking(-flap); + if (isExtended()) { float flapAngle = getWingRotationFactor(ticks); leftWing.rotateFlying(flapAngle); rightWing.rotateFlying(-flapAngle); } - + } - + public float getWingRotationFactor(float ticks) { if (pony.isFlying) { return (MathHelper.sin(ticks * 0.536f) * 1) + ROTATE_270 + 0.4f; } return LEFT_WING_ROTATE_ANGLE_Z_SNEAK; } - + public boolean isVisible() { return pony.metadata.getRace().hasWings(); } - + public boolean isExtended() { return pony.isFlying || pony.isSneak; } @Override - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { if (!isVisible()) return; boolean standing = isExtended(); leftWing.render(standing, scale); diff --git a/src/main/java/com/minelittlepony/model/components/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java index 18272972..8aef37f2 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -19,12 +19,12 @@ public class PonyElytra extends ModelBase { private PonyRenderer leftWing = new PonyRenderer(this, 22, 0); public PonyElytra() { - this.leftWing .box(-10, 0, 0, 10, 20, 2, 1); - this.rightWing.mirror().box( 0, 0, 0, 10, 20, 2, 1); + leftWing .box(-10, 0, 0, 10, 20, 2, 1); + rightWing.mirror().box( 0, 0, 0, 10, 20, 2, 1); } @Override - public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { GlStateManager.disableRescaleNormal(); GlStateManager.disableCull(); leftWing.render(scale); @@ -32,8 +32,8 @@ public class PonyElytra extends ModelBase { } @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entity) { - super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity); + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); float rotateX = PI / 2; float rotateY = PI / 8; diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 7368fa64..e9f92540 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -10,26 +10,26 @@ import com.minelittlepony.pony.data.TailLengths; import com.minelittlepony.render.plane.PlaneRenderer; public class PonyTail extends PlaneRenderer { - + private final TailSegment[] segments = new TailSegment[4]; - + private final AbstractPonyModel theModel; - + public PonyTail(AbstractPonyModel model) { super(model); theModel = model; } - + public void init(float yOffset, float stretch) { for (int i = 0; i < segments.length; i++) { addChild(segments[i] = new TailSegment(theModel, i, yOffset, stretch)); } } - - public void setRotationAndAngles(boolean rainboom, float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { - swingZ(rainboom, limbSwing, limbSwingAmount); + + public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) { + rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; rotateAngleY = bodySwing; - + if (theModel.isSneak && !theModel.isFlying && !rainboom) { rotateSneak(); } else if (theModel.isRiding) { @@ -39,9 +39,9 @@ public class PonyTail extends PlaneRenderer { } else { setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); if (rainboom) { - rotateAngleX = ROTATE_90 + MathHelper.sin(limbSwing) / 10; + rotateAngleX = ROTATE_90 + MathHelper.sin(move) / 10; } else { - rotateAngleX = limbSwingAmount / 2; + rotateAngleX = swing / 2; } if (!rainboom) { @@ -55,16 +55,12 @@ public class PonyTail extends PlaneRenderer { } } - public void swingZ(boolean rainboom, float move, float swing) { - rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; - } - public void swingX(float tick) { float sinTickFactor = MathHelper.sin(tick * 0.067f) * 0.05f; rotateAngleX += sinTickFactor; rotateAngleY += sinTickFactor; } - + public void rotateSneak() { setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK); rotateAngleX = -BODY_ROTATE_ANGLE_X_SNEAK + 0.1F; @@ -79,24 +75,24 @@ public class PonyTail extends PlaneRenderer { super.render(scale); } - + private class TailSegment extends PlaneRenderer { - + public TailSegment(ModelBase model, int index, float yOffset, float stretch) { super(model); - - this.offsetY = ((float)index)/4 + 0.063f; - + + offsetY = ((float)index)/4 + 0.063f; + init(index, yOffset, stretch); } - + public void init(int index, float yOffset, float stretch) { int texX = (index % 2) * 4; - + if (index == 0) { tex(32, 0).addTopPlane(-2, 0, 2, 4, 4, stretch); } - + around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); tex(36, texX) .addEastPlane(2, 0, 2, 4, 4, stretch) diff --git a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java index 9de799bf..c8d8d147 100644 --- a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -25,7 +25,7 @@ public class UnicornHorn extends ModelBase { horn = new PonyRenderer(pony, 0, 3); glow = new HornGlowRenderer(pony, 0, 3); - + horn.offset(HORN_X, HORN_Y, HORN_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .box(0, 0, 0, 1, 4, 1, stretch) @@ -38,16 +38,16 @@ public class UnicornHorn extends ModelBase { } @Override - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { if (!pony.metadata.getRace().hasHorn()) return; - + horn.render(scale); - + if (usingMagic && pony.metadata.hasMagic()) { renderMagic(pony.metadata.getGlowColor(), scale); } } - + private void renderMagic(int tint, float scale) { glPushAttrib(24577); disableTexture2D(); diff --git a/src/main/java/com/minelittlepony/model/player/PlayerModels.java b/src/main/java/com/minelittlepony/model/player/PlayerModels.java index c325e482..18a2d666 100644 --- a/src/main/java/com/minelittlepony/model/player/PlayerModels.java +++ b/src/main/java/com/minelittlepony/model/player/PlayerModels.java @@ -20,7 +20,7 @@ public enum PlayerModels { } public ModelWrapper getModel(boolean slim) { - return slim ? this.slim.resolve() : this.normal.resolve(); + return slim ? this.slim.resolve() : normal.resolve(); } public String getId(boolean useSlimArms) { diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java index 805efc24..f6b00af4 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java @@ -11,6 +11,7 @@ public class ModelBreezie extends ModelBiped { ModelRenderer neck; ModelRenderer tail; ModelRenderer tailStub; + ModelRenderer leftWing; ModelRenderer rightWing; @@ -18,7 +19,7 @@ public class ModelBreezie extends ModelBiped { textureWidth = 64; textureHeight = 64; - this.bipedHeadwear.showModel = false; + bipedHeadwear.showModel = false; bipedHead = new ModelRenderer(this, 0, 0); bipedHead.setRotationPoint(0, 0, -4); @@ -30,58 +31,58 @@ public class ModelBreezie extends ModelBiped { ModelRenderer antenna = new ModelRenderer(this); antenna.setTextureOffset(28, 2).addBox(1F, -11F, -2F, 1, 6, 1); antenna.setTextureOffset(24, 2).addBox(-2F, -11F, -2F, 1, 6, 1); - setRotation(antenna, -0.2617994F, 0F, 0F); + setRotation(antenna, -0.2617994F, 0, 0); - this.bipedHead.addChild(antenna); + bipedHead.addChild(antenna); bipedBody = new ModelRenderer(this, 2, 12); - bipedBody.addBox(0F, 0F, 0F, 6, 7, 14).setRotationPoint(-3F, 1F, -3F); - setRotation(bipedBody, -0.5235988F, 0F, 0F); + bipedBody.addBox(0, 0, 0, 6, 7, 14).setRotationPoint(-3, 1, -3); + setRotation(bipedBody, -0.5235988F, 0, 0); bipedRightArm = new ModelRenderer(this, 36, 12); - bipedRightArm.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(-3F, 8F, -5F); + bipedRightArm.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(-3, 8, -5); bipedLeftArm = new ModelRenderer(this, 28, 12); - bipedLeftArm.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(1F, 8F, -5F); + bipedLeftArm.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(1, 8, -5); bipedLeftLeg = new ModelRenderer(this, 8, 12); - bipedLeftLeg.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(1F, 12F, 3F); + bipedLeftLeg.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(1, 12, 3); bipedRightLeg = new ModelRenderer(this, 0, 12); - bipedRightLeg.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(-3F, 12F, 3F); + bipedRightLeg.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(-3, 12, 3); neck = new ModelRenderer(this, 40, 0); - neck.addBox(0F, 0F, 0F, 2, 5, 2).setRotationPoint(-1F, -2F, -4F); - setRotation(neck, 0.0872665F, 0F, 0F); + neck.addBox(0, 0, 0, 2, 5, 2).setRotationPoint(-1, -2, -4); + setRotation(neck, 0.0872665F, 0, 0); tailStub = new ModelRenderer(this, 40, 7); - tailStub.addBox(0F, 0F, 0F, 1, 1, 3).setRotationPoint(-0.5F, 8F, 8F); + tailStub.addBox(0, 0, 0, 1, 1, 3).setRotationPoint(-0.5F, 8, 8); tail = new ModelRenderer(this, 32, 0); - tail.addBox(0F, 0F, 1F, 2, 9, 2).setRotationPoint(-1F, 7F, 10F); + tail.addBox(0, 0, 1, 2, 9, 2).setRotationPoint(-1, 7, 10); leftWing = new ModelRenderer(this, 0, 40); - leftWing.addBox(0F, -12F, 0F, 24, 24, 0); - leftWing.setRotationPoint(2F, 3F, 1F); + leftWing.addBox(0, -12, 0, 24, 24, 0); + leftWing.setRotationPoint(2, 3, 1); leftWing.setTextureSize(64, 32); - setRotation(leftWing, 0F, -0.6981317F, 0F); + setRotation(leftWing, 0, -0.6981317F, 0); rightWing = new ModelRenderer(this, 0, 40); - rightWing.addBox(-24F, -12F, 0F, 24, 24, 0, true); - rightWing.setRotationPoint(-2F, 3F, 1F); + rightWing.addBox(-24, -12, 0, 24, 24, 0, true); + rightWing.setRotationPoint(-2, 3, 1); rightWing.setTextureSize(64, 32); - setRotation(rightWing, 0F, 0.6981317F, 0F); + setRotation(rightWing, 0, 0.6981317F, 0); } @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - neck.render(f5); - tailStub.render(f5); - tail.render(f5); - leftWing.render(f5); - rightWing.render(f5); + public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.render(entity, move, swing, age, headYaw, headPitch, scale); + neck.render(scale); + tailStub.render(scale); + tail.render(scale); + leftWing.render(scale); + rightWing.render(scale); } private void setRotation(ModelRenderer model, float x, float y, float z) { @@ -92,106 +93,106 @@ public class ModelBreezie extends ModelBiped { @SuppressWarnings("incomplete-switch") @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - this.bipedHead.rotateAngleY = netHeadYaw * 0.017453292F; - this.bipedHead.rotateAngleX = headPitch * 0.017453292F; + bipedHead.rotateAngleY = headYaw * 0.017453292F; + bipedHead.rotateAngleX = headPitch * 0.017453292F; - this.bipedRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F; - this.bipedLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount; - this.bipedLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 1.4F * limbSwingAmount; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - this.bipedRightLeg.rotateAngleZ = 0.0F; - this.bipedLeftLeg.rotateAngleZ = 0.0F; + bipedRightArm.rotateAngleX = MathHelper.cos(move * 0.6662F + (float) Math.PI) * 2.0F * swing * 0.5F; + bipedLeftArm.rotateAngleX = MathHelper.cos(move * 0.6662F) * 2.0F * swing * 0.5F; + bipedRightArm.rotateAngleZ = 0; + bipedLeftArm.rotateAngleZ = 0; + bipedRightLeg.rotateAngleX = MathHelper.cos(move * 0.6662F) * 1.4F * swing; + bipedLeftLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + (float) Math.PI) * 1.4F * swing; + bipedRightLeg.rotateAngleY = 0; + bipedLeftLeg.rotateAngleY = 0; + bipedRightLeg.rotateAngleZ = 0; + bipedLeftLeg.rotateAngleZ = 0; - if (this.isRiding) { - this.bipedRightArm.rotateAngleX += -((float) Math.PI / 5F); - this.bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F); - this.bipedRightLeg.rotateAngleX = -1.4137167F; - this.bipedRightLeg.rotateAngleY = ((float) Math.PI / 10F); - this.bipedRightLeg.rotateAngleZ = 0.07853982F; - this.bipedLeftLeg.rotateAngleX = -1.4137167F; - this.bipedLeftLeg.rotateAngleY = -((float) Math.PI / 10F); - this.bipedLeftLeg.rotateAngleZ = -0.07853982F; + if (isRiding) { + bipedRightArm.rotateAngleX += -((float) Math.PI / 5F); + bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F); + bipedRightLeg.rotateAngleX = -1.4137167F; + bipedRightLeg.rotateAngleY = ((float) Math.PI / 10F); + bipedRightLeg.rotateAngleZ = 0.07853982F; + bipedLeftLeg.rotateAngleX = -1.4137167F; + bipedLeftLeg.rotateAngleY = -((float) Math.PI / 10F); + bipedLeftLeg.rotateAngleZ = -0.07853982F; } - this.bipedRightArm.rotateAngleY = 0; - this.bipedRightArm.rotateAngleZ = 0F; + bipedRightArm.rotateAngleY = 0; + bipedRightArm.rotateAngleZ = 0F; - switch (this.leftArmPose) { + switch (leftArmPose) { case EMPTY: - this.bipedLeftArm.rotateAngleY = 0.0F; + bipedLeftArm.rotateAngleY = 0; break; case BLOCK: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedLeftArm.rotateAngleY = 0.5235988F; + bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; + bipedLeftArm.rotateAngleY = 0.5235988F; break; case ITEM: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - this.bipedLeftArm.rotateAngleY = 0.0F; + bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); + bipedLeftArm.rotateAngleY = 0; } - switch (this.rightArmPose) { + switch (rightArmPose) { case EMPTY: - this.bipedRightArm.rotateAngleY = 0.0F; + bipedRightArm.rotateAngleY = 0; break; case BLOCK: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedRightArm.rotateAngleY = -0.5235988F; + bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; + bipedRightArm.rotateAngleY = -0.5235988F; break; case ITEM: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - this.bipedRightArm.rotateAngleY = 0.0F; + bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); + bipedRightArm.rotateAngleY = 0; } - if (this.swingProgress > 0.0F) { - EnumHandSide enumhandside = this.getMainHand(entityIn); - ModelRenderer modelrenderer = this.getArmForSide(enumhandside); - float f1 = this.swingProgress; - this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float) Math.PI * 2F)) * 0.2F; + if (swingProgress > 0.0F) { + EnumHandSide enumhandside = getMainHand(entity); + ModelRenderer modelrenderer = getArmForSide(enumhandside); + float f1 = swingProgress; + bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float) Math.PI * 2F)) * 0.2F; if (enumhandside == EnumHandSide.LEFT) { - this.bipedBody.rotateAngleY *= -1.0F; + bipedBody.rotateAngleY *= -1.0F; } - this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; - this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; - this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; - this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; - this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; - this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; + bipedRightArm.rotationPointZ = MathHelper.sin(bipedBody.rotateAngleY) * 5; + bipedRightArm.rotationPointX = -MathHelper.cos(bipedBody.rotateAngleY) * 5; + bipedLeftArm.rotationPointZ = -MathHelper.sin(bipedBody.rotateAngleY) * 5; + bipedLeftArm.rotationPointX = MathHelper.cos(bipedBody.rotateAngleY) * 5; + bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; + bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; //noinspection SuspiciousNameCombination - this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; - f1 = 1.0F - this.swingProgress; + bipedLeftArm.rotateAngleX += bipedBody.rotateAngleY; + f1 = 1.0F - swingProgress; f1 = f1 * f1; f1 = f1 * f1; f1 = 1.0F - f1; float f2 = MathHelper.sin(f1 * (float) Math.PI); - float f3 = MathHelper.sin(this.swingProgress * (float) Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; + float f3 = MathHelper.sin(swingProgress * (float) Math.PI) * -(bipedHead.rotateAngleX - 0.7F) * 0.75F; modelrenderer.rotateAngleX = (float) (modelrenderer.rotateAngleX - (f2 * 1.2D + f3)); - modelrenderer.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; - modelrenderer.rotateAngleZ += MathHelper.sin(this.swingProgress * (float) Math.PI) * -0.4F; + modelrenderer.rotateAngleY += bipedBody.rotateAngleY * 2.0F; + modelrenderer.rotateAngleZ += MathHelper.sin(swingProgress * (float) Math.PI) * -0.4F; } - 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; + bipedRightArm.rotateAngleZ += MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; + bipedLeftArm.rotateAngleZ -= MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; + bipedRightArm.rotateAngleX += MathHelper.sin(age * 0.067F) * 0.05F; + bipedLeftArm.rotateAngleX -= MathHelper.sin(age * 0.067F) * 0.05F; - if (this.rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { - this.bipedRightArm.rotateAngleY = -0.1F + this.bipedHead.rotateAngleY; - this.bipedLeftArm.rotateAngleY = 0.1F + this.bipedHead.rotateAngleY + 0.4F; - this.bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX; - this.bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX; - } else if (this.leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { - this.bipedRightArm.rotateAngleY = -0.1F + this.bipedHead.rotateAngleY - 0.4F; - this.bipedLeftArm.rotateAngleY = 0.1F + this.bipedHead.rotateAngleY; - this.bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX; - this.bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + this.bipedHead.rotateAngleX; + if (rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { + bipedRightArm.rotateAngleY = -0.1F + bipedHead.rotateAngleY; + bipedLeftArm.rotateAngleY = 0.1F + bipedHead.rotateAngleY + 0.4F; + bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; + bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; + } else if (leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { + bipedRightArm.rotateAngleY = -0.1F + bipedHead.rotateAngleY - 0.4F; + bipedLeftArm.rotateAngleY = 0.1F + bipedHead.rotateAngleY; + bipedRightArm.rotateAngleX = -((float) Math.PI / 2) + bipedHead.rotateAngleX; + bipedLeftArm.rotateAngleX = -((float) Math.PI / 2) + bipedHead.rotateAngleX; } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java index c9d27a4d..1fb345bc 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java @@ -21,12 +21,12 @@ public class ModelHumanPlayer extends AbstractPonyModel { @Override protected void initTextures() { - + } @Override protected void initPositions(float yOffset, float stretch) { - + } @Override diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index e4b85ffb..b70608d3 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -13,64 +13,64 @@ public class ModelIllagerPony extends ModelPlayerPony { } @Override - public void setRotationAngles(float swing, float move, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(swing, move, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); - AbstractIllager illager = (AbstractIllager) entityIn; + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + AbstractIllager illager = (AbstractIllager) entity; AbstractIllager.IllagerArmPose pose = illager.getArmPose(); boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; 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; + float f = MathHelper.sin(swingProgress * (float) Math.PI); + float f1 = MathHelper.sin((1.0F - (1.0F - swingProgress) * (1.0F - swingProgress)) * (float) Math.PI); + bipedRightArm.rotateAngleZ = 0.0F; + bipedLeftArm.rotateAngleZ = 0.0F; + bipedRightArm.rotateAngleY = 0.15707964F; + bipedLeftArm.rotateAngleY = -0.15707964F; if (rightHanded) { - this.bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; - this.bipedRightArm.rotateAngleX += f * 2.2F - f1 * 0.4F; + bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(age * 0.09F) * 0.15F; + 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; + bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(age * 0.09F) * 0.15F; + bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F; } - 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; + bipedRightArm.rotateAngleZ += MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; + bipedLeftArm.rotateAngleZ -= MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; + bipedRightArm.rotateAngleX += MathHelper.sin(age * 0.067F) * 0.05F; + bipedLeftArm.rotateAngleX -= MathHelper.sin(age * 0.067F) * 0.05F; } else if (pose == AbstractIllager.IllagerArmPose.SPELLCASTING) { - if (this.metadata.hasMagic()) { - this.horn.setUsingMagic(true); + if (metadata.hasMagic()) { + 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) / 4; - this.bipedRightArm.rotateAngleY = 1.1F; + bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI); + bipedRightArm.rotateAngleZ = MathHelper.cos(age * 0.6662F) / 4; + 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) / 4; - this.bipedLeftArm.rotateAngleY = -1.1F; + bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI); + bipedLeftArm.rotateAngleZ = -MathHelper.cos(age * 0.6662F) / 4; + bipedLeftArm.rotateAngleY = -1.1F; } } else if (pose == AbstractIllager.IllagerArmPose.BOW_AND_ARROW) { if (rightHanded) { - aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, ageInTicks); + aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, age); } else { - aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, ageInTicks); + aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, age); } } } public ModelRenderer getArm(EnumHandSide side) { - return metadata.hasMagic() ? side == EnumHandSide.LEFT ? this.unicornArmLeft : this.unicornArmRight : this.getArmForSide(side); + return metadata.hasMagic() ? side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight : getArmForSide(side); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 47e72e82..806f5497 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -24,14 +24,15 @@ import static com.minelittlepony.model.PonyModelConstants.*; public class ModelPlayerPony extends AbstractPonyModel { private final boolean smallArms; - + public ModelRenderer bipedCape; - + public PlaneRenderer upperTorso; public PlaneRenderer neck; - - public PonyRenderer unicornArmRight, unicornArmLeft; - + + public PonyRenderer unicornArmRight; + public PonyRenderer unicornArmLeft; + public PonyTail tail; public PonySnout snout; public UnicornHorn horn; @@ -41,7 +42,7 @@ public class ModelPlayerPony extends AbstractPonyModel { super(smallArms); this.smallArms = smallArms; } - + @Override public PonyArmor createArmour() { return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); @@ -56,29 +57,29 @@ public class ModelPlayerPony extends AbstractPonyModel { } @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); + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - this.checkRainboom(entityIn, limbSwingAmount); - this.rotateHead(netHeadYaw, headPitch); + checkRainboom(entity, swing); + rotateHead(headYaw, headPitch); float bodySwingRotation = 0; if (swingProgress > -9990.0F && !metadata.hasMagic()) { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; } - rotateLook(limbSwing, limbSwingAmount, bodySwingRotation, ageInTicks); + rotateLook(move, swing, bodySwingRotation, age); - setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn); - holdItem(limbSwingAmount); - swingItem(entityIn, swingProgress); + setLegs(move, swing, age, entity); + holdItem(swing); + swingItem(entity, swingProgress); if (isCrouching() && !rainboom) { adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); sneakLegs(); setHead(0, 6, -2); } else if (isRiding) { - this.adjustBodyRiding(); + adjustBodyRiding(); bipedLeftLeg.rotationPointZ = 15; bipedLeftLeg.rotationPointY = 10; bipedLeftLeg.rotateAngleX = -PI / 4; @@ -96,35 +97,35 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - swingArms(ageInTicks); + swingArms(age); setHead(0, 0, 0); } - + if (isSleeping) ponySleep(); - aimBow(leftArmPose, rightArmPose, ageInTicks); - fixSpecialRotationPoints(limbSwing); + aimBow(leftArmPose, rightArmPose, age); + fixSpecialRotationPoints(move); animateWears(); if (bipedCape != null) { bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; - + snout.setGender(metadata.getGender()); - wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); } } - + protected void adjustBodyRiding() { adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); setHead(0, 0, 0); } - - protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { - tail.setRotationAndAngles(rainboom, limbSwing, limbSwingAmount, bodySwing, ticks); + + protected void rotateLook(float move, float swing, float bodySwing, float ticks) { + tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks); bodySwing /= 5; - + upperTorso.rotateAngleY = bodySwing; bipedBody.rotateAngleY = bodySwing; neck.rotateAngleY = bodySwing; @@ -160,16 +161,16 @@ public class ModelPlayerPony extends AbstractPonyModel { private void rotateHead(float horz, float vert) { float headRotateAngleY = isSleeping ? 1.4f : horz / 57.29578F; float headRotateAngleX = isSleeping ? 0.1f : vert / 57.29578F; - + headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch))); - + updateHeadRotation(headRotateAngleX, headRotateAngleY); } - + /** * Called to update the head rotation. - * + * * @param x New rotation X * @param y New rotation Y */ @@ -182,14 +183,14 @@ public class ModelPlayerPony extends AbstractPonyModel { rotateLegs(move, swing, tick, entity); adjustLegs(); } - + protected void rotateLegs(float move, float swing, float tick, Entity entity) { float leftArm; float rightArm; float leftLeg; float rightLeg; - - + + if (isFlying(entity)) { if (rainboom) { rightArm = leftArm = ROTATE_270; @@ -203,13 +204,13 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; } else { float pi = PI * (float) Math.pow(swing, 16); - + float mve = move * 0.6662F; // magic number ahoy float srt = swing / 4; - + leftArm = MathHelper.cos(mve + pi) * srt; rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; - + leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; @@ -238,7 +239,7 @@ public class ModelPlayerPony extends AbstractPonyModel { unicornArmLeft.rotateAngleX = 0; unicornArmRight.rotateAngleX = 0; } - + private float getLegOutset() { if (isSleeping) return 2.6f; if (isSneak && !isFlying) return smallArms ? 1 : 0; @@ -277,8 +278,8 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; } - - + + protected void holdItem(float swing) { boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; @@ -290,7 +291,7 @@ public class ModelPlayerPony extends AbstractPonyModel { alignArmForAction(unicornArmRight, rightArmPose, both, swing); } - horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); + horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY); } private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { @@ -311,20 +312,20 @@ public class ModelPlayerPony extends AbstractPonyModel { default: } } - + private void blockArm(ModelRenderer arm) { arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; arm.rotateAngleY = PI / 6; } protected void swingItem(Entity entity, float swingProgress) { - if (swingProgress > -9990.0F && !this.isSleeping) { - EnumHandSide mainSide = this.getMainHand(entity); + if (swingProgress > -9990.0F && !isSleeping) { + EnumHandSide mainSide = getMainHand(entity); boolean mainRight = mainSide == EnumHandSide.RIGHT; ArmPose mainPose = mainRight ? rightArmPose : leftArmPose; - + if (mainPose == ArmPose.EMPTY) return; - + if (metadata.hasMagic()) { swingArm(mainRight ? unicornArmRight : unicornArmLeft); } else { @@ -332,15 +333,15 @@ public class ModelPlayerPony extends AbstractPonyModel { } } } - + private void swingArm(ModelRenderer arm) { float swing = 1 - (float)Math.pow(1 - swingProgress, 3); - + float deltaX = MathHelper.sin(swing * PI); float deltaZ = MathHelper.sin(swingProgress * PI); - + float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F; - + arm.rotateAngleX -= deltaAim + deltaX * 1.2F; arm.rotateAngleZ = deltaZ * -0.4F; arm.rotateAngleY += bipedBody.rotateAngleY * 2; @@ -351,7 +352,7 @@ public class ModelPlayerPony extends AbstractPonyModel { float sin = MathHelper.sin(tick * 0.067F) * 0.05F; if (rightArmPose != ArmPose.EMPTY && !isSleeping) { - + if (metadata.hasMagic()) { unicornArmRight.rotateAngleZ += cos; unicornArmRight.rotateAngleX += sin; @@ -380,7 +381,7 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedBody.rotateAngleX = rotateAngleX; bipedBody.rotationPointY = rotationPointY; bipedBody.rotationPointZ = rotationPointZ; - + upperTorso.rotateAngleX = rotateAngleX; upperTorso.rotationPointY = rotationPointY; upperTorso.rotationPointZ = rotationPointZ; @@ -408,9 +409,9 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftArm.rotateAngleX = ROTATE_270; bipedRightLeg.rotateAngleX = ROTATE_90; bipedLeftLeg.rotateAngleX = ROTATE_90; - + setHead(1, 2, isSneak ? -1 : 1); - + shiftRotationPoint(bipedRightArm, 0, 2, 6); shiftRotationPoint(bipedLeftArm, 0, 2, 6); shiftRotationPoint(bipedRightLeg, 0, 2, -8); @@ -443,11 +444,11 @@ public class ModelPlayerPony extends AbstractPonyModel { } @Override - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - + public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { + pushMatrix(); transform(BodyPart.HEAD); - renderHead(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + renderHead(entityIn, move, swing, age, headYaw, headPitch, scale); popMatrix(); pushMatrix(); @@ -457,7 +458,7 @@ public class ModelPlayerPony extends AbstractPonyModel { pushMatrix(); transform(BodyPart.BODY); - renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + renderBody(entityIn, move, swing, age, headYaw, headPitch, scale); popMatrix(); pushMatrix(); @@ -466,11 +467,11 @@ public class ModelPlayerPony extends AbstractPonyModel { popMatrix(); } - protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { bipedHead.render(scale); bipedHeadwear.render(scale); bipedHead.postRender(scale); - horn.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + horn.render(entity, move, swing, age, headYaw, headPitch, scale); } protected void renderNeck() { @@ -478,14 +479,14 @@ public class ModelPlayerPony extends AbstractPonyModel { neck.render(scale); } - protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { bipedBody.render(scale); if (textureHeight == 64) { bipedBodyWear.render(scale); } upperTorso.render(scale); bipedBody.postRender(scale); - wings.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + wings.render(entity, move, swing, age, headYaw, headPitch, scale); tail.render(metadata.getTail(), scale); } @@ -496,7 +497,7 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightArm.render(scale); bipedLeftLeg.render(scale); bipedRightLeg.render(scale); - + if (textureHeight == 64) { bipedLeftArmwear.render(scale); bipedRightArmwear.render(scale); @@ -522,11 +523,11 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void initBodyTextures() { bipedBody = new ModelRenderer(this, 16, 16); - + if (textureHeight == 64) { bipedBodyWear = new ModelRenderer(this, 16, 32); } - + upperTorso = new PlaneRenderer(this, 24, 0); neck = new PlaneRenderer(this, 0, 16); } @@ -557,14 +558,14 @@ public class ModelPlayerPony extends AbstractPonyModel { initLegPositions(yOffset, stretch); initTailPositions(yOffset, stretch); } - + protected void initTailPositions(float yOffset, float stretch) { tail.init(yOffset, stretch); } protected void initHeadPositions(float yOffset, float stretch) { bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); - + ((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .box(-4, -4, -4, 8, 8, 8, stretch) @@ -572,7 +573,7 @@ public class ModelPlayerPony extends AbstractPonyModel { .box(-4, -6, 1, 2, 2, 2, stretch) .mirror() .box(2, -6, 1, 2, 2, 2, stretch); - + ((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .box(-4, -4, -4, 8, 8, 8, stretch + 0.5F); @@ -584,10 +585,10 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void initBodyPositions(float yOffset, float stretch) { bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch); bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - + bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - + upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch) @@ -607,7 +608,7 @@ public class ModelPlayerPony extends AbstractPonyModel { .addBackPlane(-1, 2, 8, 2, 2, stretch) .flipZ().addWestPlane(-1, 2, 2, 2, 6, stretch) .rotateAngleX = 0.5F; - + neck.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .addFrontPlane(0, 0, 0, 4, 4, stretch) @@ -621,20 +622,20 @@ public class ModelPlayerPony extends AbstractPonyModel { int armWidth = smallArms ? 3 : 4; float rarmY = smallArms ? 8.5f : 8; float rarmX = smallArms ? 2 : 3; - + float armX = THIRDP_ARM_CENTRE_X - 2; float armY = THIRDP_ARM_CENTRE_Y - 6; float armZ = THIRDP_ARM_CENTRE_Z - 2; - + bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch); bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch); - + bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch); bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch); - + bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); - + bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); @@ -642,17 +643,17 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f); bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); } - + if (bipedRightArmwear != null) { bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f); bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); } - + if (bipedLeftLegwear != null) { bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); bipedRightLegwear.setRotationPoint(3, yOffset, 0); } - + if (bipedRightLegwear != null) { bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); bipedRightLegwear.setRotationPoint(-3, yOffset, 0); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index e237685f..812ce4a2 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -21,12 +21,13 @@ public class ModelSkeletonPony extends ModelMobPony { public ModelSkeletonPony() { super(); } - + @Override public PonyArmor createArmour() { return new PonyArmor(new ModelSkeletonPonyArmor(), new ModelSkeletonPonyArmor()); } - + + @Override public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { rightArmPose = ModelBiped.ArmPose.EMPTY; leftArmPose = ModelBiped.ArmPose.EMPTY; @@ -45,18 +46,18 @@ public class ModelSkeletonPony extends ModelMobPony { } @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); - aimBow(leftArmPose, rightArmPose, tick); + protected void rotateLegs(float move, float swing, float ticks, Entity entity) { + super.rotateLegs(move, swing, ticks, entity); + aimBow(leftArmPose, rightArmPose, ticks); } - + @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } } - + // TODO: HACK It would be better to just change the size of the legs. private void renderScaledArm(ModelRenderer arm, float x, float y, float z) { scale(x, y, z); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index a6cbcfc3..237f5384 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -16,25 +16,25 @@ public class ModelVillagerPony extends ModelPlayerPony { } @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); + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - float swing = 0; + float angleY = 0; if (swingProgress > -9990.0F && !metadata.hasMagic()) { - swing = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F; + angleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F; } - bag.rotateAngleY = swing; - apron.rotateAngleY = swing; - trinket.rotateAngleY = swing; + bag.rotateAngleY = angleY; + apron.rotateAngleY = angleY; + trinket.rotateAngleY = angleY; } @Override - protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - super.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); - if (entityIn instanceof EntityVillager) { + if (entity instanceof EntityVillager) { bipedBody.postRender(this.scale); - int profession = ((EntityVillager) entityIn).getProfession(); + int profession = ((EntityVillager) entity).getProfession(); if (profession < 2) { bag.render(scale); } else if (profession == 2) { @@ -43,7 +43,7 @@ public class ModelVillagerPony extends ModelPlayerPony { apron.render(scale); } } - + } @Override @@ -57,7 +57,7 @@ public class ModelVillagerPony extends ModelPlayerPony { @Override protected void initPositions(float yOffset, float stretch) { super.initPositions(yOffset, stretch); - + bag.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .tex(56, 25).addBackPlane(-7, -5, -4, 3, 6, stretch) //right bag front @@ -75,7 +75,7 @@ public class ModelVillagerPony extends ModelPlayerPony { .tex(56, 22).addBottomPlane(2, 1, -2, 8, 3, stretch) //right bag bottom .addBottomPlane(2, 1, -13, 8, 3, stretch) //left bag bottom .rotateAngleY = 4.712389F; - + apron.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .addBackPlane(-4, -4, -9, 8, 10, stretch); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index ff7c7d25..8a92cf68 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -11,16 +11,16 @@ public class ModelZombiePony extends ModelMobPony { public ModelZombiePony() { super(); } - + @Override public PonyArmor createArmour() { return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor()); } - + private boolean isRight(float move) { return MathHelper.sin(move / 20) < 0; } - + @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; diff --git a/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java index 2e2e5925..3a967aa8 100644 --- a/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java +++ b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java @@ -11,11 +11,11 @@ public interface ITriggerPixelMapped & ITriggerPixelMapped> * Gets the pixel colour matching this enum value. */ int getTriggerPixel(); - + /** * Gets the enum value corresponding to the given enum type and pixel value. * If none are found, the first parameter is returned as the default. - * + * * @param type Return type and default value. * @param pixelValue The pixel colour to search for. */ diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index 364112a9..638995f3 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -34,16 +34,16 @@ public class Pony { private final boolean smallArms; public Pony(ResourceLocation resource, boolean slim) { - this.texture = resource; - this.metadata = this.checkSkin(this.texture); - this.smallArms = slim; + texture = resource; + metadata = checkSkin(texture); + smallArms = slim; } private IPonyData checkSkin(ResourceLocation textureResourceLocation) { IPonyData data = checkPonyMeta(textureResourceLocation); if (data != null) return data; - BufferedImage skinImage = this.getBufferedImage(textureResourceLocation); + BufferedImage skinImage = getBufferedImage(textureResourceLocation); return this.checkSkin(skinImage); } @@ -92,7 +92,7 @@ public class Pony { private IPonyData checkSkin(BufferedImage bufferedimage) { if (bufferedimage == null) return new PonyData(); - MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", this.ponyId, bufferedimage); + MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage); return PonyData.parse(bufferedimage); } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyData.java b/src/main/java/com/minelittlepony/pony/data/PonyData.java index 7d6cf50b..8d5f6152 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyData.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyData.java @@ -20,19 +20,19 @@ public class PonyData implements IPonyData { private final int glowColor; public PonyData() { - this.race = PonyRace.HUMAN; - this.tailSize = TailLengths.FULL; - this.gender = PonyGender.MARE; - this.size = PonySize.NORMAL; - this.glowColor = 0x4444aa; + race = PonyRace.HUMAN; + tailSize = TailLengths.FULL; + gender = PonyGender.MARE; + size = PonySize.NORMAL; + glowColor = 0x4444aa; } - + private PonyData(BufferedImage image) { - this.race = TriggerPixels.RACE.readValue(image); - this.tailSize = TriggerPixels.TAIL.readValue(image); - this.size = TriggerPixels.SIZE.readValue(image); - this.gender = TriggerPixels.GENDER.readValue(image); - this.glowColor = TriggerPixels.GLOW.readColor(image, -1); + race = TriggerPixels.RACE.readValue(image); + tailSize = TriggerPixels.TAIL.readValue(image); + size = TriggerPixels.SIZE.readValue(image); + gender = TriggerPixels.GENDER.readValue(image); + glowColor = TriggerPixels.GLOW.readColor(image, -1); } @Override @@ -62,7 +62,7 @@ public class PonyData implements IPonyData { @Override public boolean hasMagic() { - return this.race != null && this.race.hasHorn() && this.glowColor != 0; + return race != null && race.hasHorn() && glowColor != 0; } @Override diff --git a/src/main/java/com/minelittlepony/pony/data/PonyGender.java b/src/main/java/com/minelittlepony/pony/data/PonyGender.java index 0a056b05..4ef71a31 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyGender.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyGender.java @@ -3,9 +3,9 @@ package com.minelittlepony.pony.data; public enum PonyGender implements ITriggerPixelMapped { MARE(0), STALLION(0xffffff); - + private int triggerValue; - + PonyGender(int pixel) { triggerValue = pixel; } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java index c795cfcd..9f86dc20 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -19,12 +19,12 @@ public enum PonyRace implements ITriggerPixelMapped { private boolean horn; private int triggerPixel; - + private PlayerModels model; PonyRace(int triggerPixel, PlayerModels model, boolean wings, boolean horn) { this.triggerPixel = triggerPixel; - + this.wings = wings; this.horn = horn; this.model = model; diff --git a/src/main/java/com/minelittlepony/pony/data/PonySize.java b/src/main/java/com/minelittlepony/pony/data/PonySize.java index a4f6bd52..587d6709 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonySize.java +++ b/src/main/java/com/minelittlepony/pony/data/PonySize.java @@ -7,7 +7,7 @@ public enum PonySize implements ITriggerPixelMapped { TALL(0x534b76, 0.45f, 1f); private int triggerValue; - + private float shadowSize; private float scale; diff --git a/src/main/java/com/minelittlepony/pony/data/TailLengths.java b/src/main/java/com/minelittlepony/pony/data/TailLengths.java index 7007e390..4e71f467 100644 --- a/src/main/java/com/minelittlepony/pony/data/TailLengths.java +++ b/src/main/java/com/minelittlepony/pony/data/TailLengths.java @@ -7,13 +7,13 @@ public enum TailLengths implements ITriggerPixelMapped { HALF(0x534b76), THREE_QUARTERS(0x8a6b7f), FULL(0); - + private int triggerValue; - + TailLengths(int pixel) { triggerValue = pixel; } - + @Override public int getTriggerPixel() { return triggerValue; diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java index d1706bb6..6ab7ec34 100644 --- a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -15,15 +15,15 @@ public enum TriggerPixels { private int x; private int y; - + ITriggerPixelMapped def; - + TriggerPixels(ITriggerPixelMapped def, int x, int y) { this.def = def; this.x = x; this.y = y; } - + /** * Reads tis trigger pixel's value and returns the raw colour value. * @param image Image to read @@ -35,7 +35,7 @@ public enum TriggerPixels { /** * Reads this trigger pixel's value and parses it to an Enum instance. - * + * * @param image Image to read */ @SuppressWarnings("unchecked") diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index 43a2c9a2..90547617 100644 --- a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -16,7 +16,7 @@ public abstract class AbstractPonyRenderer> ex protected float modelOffsetX; protected float modelOffsetY; protected float modelOffsetZ; - + public AbstractPonyRenderer(ModelBase model) { super(model); baseModel = model; @@ -26,7 +26,7 @@ public abstract class AbstractPonyRenderer> ex super(model, x, y); baseModel = model; } - + /** * Called to create a new instance of this renderer (used for child renderers) */ @@ -39,37 +39,37 @@ public abstract class AbstractPonyRenderer> ex super.setTextureOffset(x, y); return (T) this; } - + /** * Flips the mirror flag. All faces are mirrored until this is called again. */ public T mirror() { return mirror(!mirror); } - + public T mirror(boolean m) { mirror = m; return (T) this; } - + /** * Sets the texture offset */ public T tex(int x, int y) { return setTextureOffset(x, y); } - + public T size(int x, int y) { return (T) setTextureSize(x, y); } - + /** * Positions this model in space. */ public T at(float x, float y, float z) { return (T)at(this, x, y, z); } - + /** * Sets an offset to be used on all shapes and children created through this renderer. */ @@ -79,20 +79,20 @@ public abstract class AbstractPonyRenderer> ex modelOffsetZ = z; return (T) this; } - + public static T at(T renderer, float x, float y, float z) { renderer.offsetX = x / 16; renderer.offsetY = y / 16; renderer.offsetZ = z / 16; return renderer; } - + public void rotateTo(ModelRenderer other) { rotateAngleX = other.rotateAngleX; rotateAngleY = other.rotateAngleY; rotateAngleZ = other.rotateAngleZ; } - + public T rotateAt(ModelRenderer other) { return around(other.rotationPointX, other.rotationPointY, other.rotationPointZ); } @@ -104,7 +104,7 @@ public abstract class AbstractPonyRenderer> ex setRotationPoint(x, y, z); return (T) this; } - + /** * Gets or creates a new child model based on its unique index. * New children will be of the same type and inherit the same textures and offsets of the original. @@ -134,27 +134,29 @@ public abstract class AbstractPonyRenderer> ex return (T) this; } + @Override public T addBox(float offX, float offY, float offZ, int width, int height, int depth, boolean mirrored) { addBox(offX, offY, offZ, width, height, depth, 0, mirrored); return (T)this; } + @Override public void addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { addBox(offX, offY, offZ, width, height, depth, scaleFactor, mirror); } - + /** * Creates a textured box. */ public T box(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor) { return addBox(offX, offY, offZ, width, height, depth, scaleFactor, mirror); } - + private T addBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { createBox(modelOffsetX + offX, modelOffsetY + offY, modelOffsetZ + offZ, width, height, depth, scaleFactor, mirrored); return (T)this; } - + protected void createBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { cubeList.add(new ModelBox(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, mirrored)); } diff --git a/src/main/java/com/minelittlepony/render/HornGlow.java b/src/main/java/com/minelittlepony/render/HornGlow.java index 8957540b..021dc45f 100644 --- a/src/main/java/com/minelittlepony/render/HornGlow.java +++ b/src/main/java/com/minelittlepony/render/HornGlow.java @@ -21,7 +21,7 @@ public class HornGlow extends ModelBox { this.parent = parent; this.alpha = alpha; - this.quadList = new TexturedQuad[6]; + quadList = new TexturedQuad[6]; float x2 = x + w + scale; float y2 = y + h + scale; @@ -51,12 +51,12 @@ public class HornGlow extends ModelBox { PositionTextureVertex p5 = new PositionTextureVertex(x2, y2, z2, 8, 8); PositionTextureVertex p6 = new PositionTextureVertex(x, y2, z2, 8, 0); - this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{p4, p0, p1, p5}, texU + d + w, texV + d, texU + d + w + d, texV + d + h, parent.textureWidth, parent.textureHeight); - this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{p7, p3, p6, p2}, texU, texV + d, texU + d, texV + d + h, parent.textureWidth, parent.textureHeight); - this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{p4, p3, p7, p0}, texU + d, texV, texU + d + w, texV + d, parent.textureWidth, parent.textureHeight); - this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{p1, p2, p6, p5}, texU + d + w, texV + d, texU + d + w + w, texV, parent.textureWidth, parent.textureHeight); - this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{p0, p7, p2, p1}, texU + d, texV + d, texU + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); - this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{p3, p4, p5, p6}, texU + d + w + d, texV + d, texU + d + w + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); + quadList[0] = new TexturedQuad(new PositionTextureVertex[]{p4, p0, p1, p5}, texU + d + w, texV + d, texU + d + w + d, texV + d + h, parent.textureWidth, parent.textureHeight); + quadList[1] = new TexturedQuad(new PositionTextureVertex[]{p7, p3, p6, p2}, texU, texV + d, texU + d, texV + d + h, parent.textureWidth, parent.textureHeight); + quadList[2] = new TexturedQuad(new PositionTextureVertex[]{p4, p3, p7, p0}, texU + d, texV, texU + d + w, texV + d, parent.textureWidth, parent.textureHeight); + quadList[3] = new TexturedQuad(new PositionTextureVertex[]{p1, p2, p6, p5}, texU + d + w, texV + d, texU + d + w + w, texV, parent.textureWidth, parent.textureHeight); + quadList[4] = new TexturedQuad(new PositionTextureVertex[]{p0, p7, p2, p1}, texU + d, texV + d, texU + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); + quadList[5] = new TexturedQuad(new PositionTextureVertex[]{p3, p4, p5, p6}, texU + d + w + d, texV + d, texU + d + w + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); if (parent.mirror) { for (TexturedQuad i : quadList) { diff --git a/src/main/java/com/minelittlepony/render/PonyRenderer.java b/src/main/java/com/minelittlepony/render/PonyRenderer.java index 61f2d204..ce483fab 100644 --- a/src/main/java/com/minelittlepony/render/PonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/PonyRenderer.java @@ -11,7 +11,7 @@ public class PonyRenderer extends AbstractPonyRenderer { public PonyRenderer(ModelBase model, int x, int y) { super(model, x, y); } - + @Override protected PonyRenderer copySelf() { return new PonyRenderer(baseModel, textureOffsetX, textureOffsetY); diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 3d73191e..721241b9 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -20,48 +20,50 @@ public abstract class RenderPonyMob extends RenderLiving protected ModelWrapper playerModel; - public RenderPonyMob(RenderManager renderManager, ModelWrapper playerModel) { - super(renderManager, playerModel.getModel(), 0.5F); - this.playerModel = playerModel; + public RenderPonyMob(RenderManager manager, ModelWrapper model) { + super(manager, model.getModel(), 0.5F); + playerModel = model; addLayers(); } protected void addLayers() { - - this.addLayer(new LayerPonyArmor(this)); - this.addLayer(new LayerHeldPonyItem(this)); - // this.addLayer(new LayerArrow(this)); - this.addLayer(new LayerPonyCustomHead(this)); - this.addLayer(new LayerPonyElytra(this)); + addLayer(new LayerPonyArmor(this)); + addLayer(new LayerHeldPonyItem(this)); + // addLayer(new LayerArrow(this)); + addLayer(new LayerPonyCustomHead(this)); + addLayer(new LayerPonyElytra(this)); } @Override - public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float partialTicks) { - double yOrigin = yPosition; + public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { if (entity.isSneaking()) { - yOrigin -= 0.125D; + yPosition -= 0.125D; } - super.doRender(entity, xPosition, yOrigin, zPosition, yaw, partialTicks); + super.doRender(entity, xPosition, yPosition, zPosition, yaw, ticks); } @Override @OverridingMethodsMustInvokeSuper - protected void preRenderCallback(T entity, float partialTickTime) { - this.playerModel.getModel().isSneak = false; - this.playerModel.getModel().isFlying = false; - this.playerModel.getModel().isSleeping = false; + protected void preRenderCallback(T entity, float ticks) { + playerModel.getModel().isSneak = false; + playerModel.getModel().isFlying = false; + playerModel.getModel().isSleeping = false; ResourceLocation loc = getEntityTexture(entity); - this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata()); + playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata()); + shadowSize = getShadowScale(); + } + + @Override + public float getShadowScale() { if (mainModel.isChild) { - this.shadowSize = 0.25F; + return 0.25F; } else if (MineLittlePony.getConfig().showscale) { - this.shadowSize = 0.4F; - } else { - this.shadowSize = 0.5F; + return 0.4F; } + return 0.5F; } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index bea43202..0e61e2b7 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -17,18 +17,19 @@ public abstract class AbstractPonyLayer implements L this.layer = humanLayer; } - public final void doRenderLayer(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + @Override + public final void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ModelBase model = renderer.getMainModel(); if (model instanceof ModelHumanPlayer) { // render the human layer - layer.doRenderLayer(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); + layer.doRenderLayer(entity, move, swing, ticks, age, headYaw, headPitch, scale); } else { // render the pony layer - doPonyRender(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); + doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); } } - protected abstract void doPonyRender(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale); + protected abstract void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale); protected RenderLivingBase getRenderer() { return renderer; diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index 31dc7c08..a4570bee 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -21,16 +21,18 @@ import javax.annotation.Nullable; public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { - private final RenderManager rm; + private final RenderManager renderManager; + private EntityLivingBase leftEntity; private EntityLivingBase rightEntity; - public LayerEntityOnPonyShoulder(RenderManager rm, RenderLivingBase renderer) { - super(renderer, getForgeLayer(rm)); - this.rm = rm; + public LayerEntityOnPonyShoulder(RenderManager manager, RenderLivingBase renderer) { + super(renderer, getForgeLayer(manager)); + renderManager = manager; } - public void doPonyRender(EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + @Override + public void doPonyRender(EntityPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { GlStateManager.enableRescaleNormal(); GlStateManager.color(1, 1, 1, 1); @@ -38,15 +40,15 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { NBTTagCompound leftTag = player.getLeftShoulderEntity(); if (!leftTag.hasNoTags()) { - this.leftEntity = this.renderShoulderEntity(player, this.leftEntity, leftTag, - limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale, true); + leftEntity = renderShoulderEntity(player, leftEntity, + leftTag, move, swing, ticks, age, headYaw, headPitch, scale, true); } NBTTagCompound rightTag = player.getRightShoulderEntity(); if (!rightTag.hasNoTags()) { - this.rightEntity = this.renderShoulderEntity(player, this.rightEntity, rightTag, - limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale, false); + rightEntity = renderShoulderEntity(player, rightEntity, + rightTag, move, swing, ticks, age, headYaw, headPitch, scale, false); } GlStateManager.disableRescaleNormal(); @@ -54,7 +56,8 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { @SuppressWarnings("unchecked") @Nullable - private EntityLivingBase renderShoulderEntity(EntityPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound tag, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, boolean left) { + private EntityLivingBase renderShoulderEntity(EntityPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound tag, + float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, boolean left) { if (entity == null || !entity.getUniqueID().equals(tag.getUniqueId("UUID"))) { entity = (EntityLivingBase) EntityList.createEntityFromNBT(tag, player.world); @@ -74,7 +77,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { GlStateManager.scale(1, -1, -1); GlStateManager.rotate(5 * (left ? -1 : 1), 0, 0, 1); - Render render = rm.getEntityRenderObject(entity); + Render render = renderManager.getEntityRenderObject(entity); if (render != null) { render.doRender(entity, 0, 0, 0, 0, 0); GlStateManager.popMatrix(); @@ -82,9 +85,9 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { return entity; } - private static LayerRenderer getForgeLayer(RenderManager rm) { + private static LayerRenderer getForgeLayer(RenderManager manager) { return ForgeProxy.createShoulderLayer() .orElse(LayerEntityOnShoulder::new) - .apply(rm); + .apply(manager); } } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index ff975fc6..c0ce7c86 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -13,7 +13,7 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderItem; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.entity.EntityLivingBase; @@ -33,13 +33,13 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { } @Override - 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) { + public void doPonyRender(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ModelBase model = getRenderer().getMainModel(); boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; - + ItemStack itemMain = entity.getHeldItemMainhand(); ItemStack itemOff = entity.getHeldItemOffhand(); - + ItemStack left = mainRight ? itemOff : itemMain; ItemStack right = mainRight ? itemMain : itemOff; @@ -55,36 +55,39 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { scale(.5, .5, .5); } - renderHeldItem(entity, right, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); - renderHeldItem(entity, left, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); + renderHeldItem(entity, right, TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); + renderHeldItem(entity, left, TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); popMatrix(); } } - private void renderHeldItem(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand) { + private void renderHeldItem(EntityLivingBase entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (!drop.isEmpty()) { GlStateManager.pushMatrix(); translateToHand(hand); if (entity.isSneaking()) { - GlStateManager.translate(0.0F, 0.2F, 0.0F); + GlStateManager.translate(0, 0.2F, 0); } - GlStateManager.rotate(-90.0F, 1, 0, 0); - GlStateManager.rotate(180.0F, 0, 1, 0); - boolean isUnicorn = isUnicorn(this.getRenderer().getMainModel()); + GlStateManager.rotate(-90, 1, 0, 0); + GlStateManager.rotate(180, 0, 1, 0); + + boolean isUnicorn = isUnicorn(getRenderer().getMainModel()); boolean isLeft = hand == EnumHandSide.LEFT; + if (isUnicorn) { GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -0.5F); } else { GlStateManager.translate(0.0425F, 0.125F, -1); } + Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); if (isUnicorn) { - IPonyData metadata = ((AbstractPonyModel) this.getRenderer().getMainModel()).metadata; - this.renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); + IPonyData metadata = ((AbstractPonyModel) getRenderer().getMainModel()).metadata; + renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); } GlStateManager.popMatrix(); } @@ -95,18 +98,17 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { } protected void translateToHand(EnumHandSide hand) { - AbstractPonyModel thePony = ((IRenderPony) this.getRenderer()).getPlayerModel().getModel(); + AbstractPonyModel thePony = ((IRenderPony) getRenderer()).getPlayerModel().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.getRenderer().getMainModel()).postRenderArm(0.0625F, hand); + ((ModelBiped) 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, TransformType transform, EnumHandSide hand, int glowColor) { // enchantments mess up the rendering ItemStack drop2 = drop.copy(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java index 456b65df..9b43fbcd 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java @@ -12,7 +12,7 @@ public abstract class LayerOverlayBase implements LayerR protected final RenderLivingBase renderer; public LayerOverlayBase(RenderLivingBase render) { - this.renderer = render; + renderer = render; } @Override @@ -20,12 +20,15 @@ public abstract class LayerOverlayBase implements LayerR return true; } - protected void renderOverlay(T skele, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - ModelBase overlayModel = this.getOverlayModel(); - overlayModel.setModelAttributes(this.renderer.getMainModel()); - overlayModel.setLivingAnimations(skele, limbSwing, limbSwingAmount, partialTicks); - renderer.bindTexture(this.getOverlayTexture()); - overlayModel.render(skele, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + protected void renderOverlay(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + ModelBase overlayModel = getOverlayModel(); + + overlayModel.setModelAttributes(renderer.getMainModel()); + overlayModel.setLivingAnimations(entity, move, swing, ticks); + + renderer.bindTexture(getOverlayTexture()); + + overlayModel.render(entity, move, swing, age, headYaw, headPitch, scale); } protected abstract ModelBase getOverlayModel(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index a3670daf..1379514c 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -23,6 +23,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; import javax.annotation.Nullable; + +import org.lwjgl.opengl.GL11; + import java.io.IOException; import java.util.Map; @@ -40,17 +43,17 @@ public class LayerPonyArmor extends AbstractPonyLayer { } @Override - public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void doPonyRender(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { pony = ((IRenderPony) getRenderer()).getPlayerModel(); - + for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) { if (i.getSlotType() == Type.ARMOR) { - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, i); + renderArmor(entity, move, swing, ticks, age, headYaw, headPitch, scale, i); } } } - 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 move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { @@ -59,33 +62,33 @@ public class LayerPonyArmor extends AbstractPonyLayer { AbstractPonyModel modelbase; if (armorSlot == EntityEquipmentSlot.LEGS) { - modelbase = pony.getArmor().modelArmor; + modelbase = pony.getArmor().armour; } else { - modelbase = pony.getArmor().modelArmorChestplate; + modelbase = pony.getArmor().chestplate; } modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); - modelbase.setModelAttributes(this.pony.getModel()); - modelbase.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity); + modelbase.setModelAttributes(pony.getModel()); + modelbase.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); Tuple armors = getArmorTexture(entity, itemstack, armorSlot, null); prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond()); - this.getRenderer().bindTexture(armors.getFirst()); + getRenderer().bindTexture(armors.getFirst()); if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { 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); + modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); - this.getRenderer().bindTexture(armors.getFirst()); + getRenderer().bindTexture(armors.getFirst()); } GlStateManager.color(1, 1, 1, 1); - modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); if (itemstack.isItemEnchanted()) { - this.renderEnchantment(entity, modelbase, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + renderEnchantment(entity, modelbase, move, swing, ticks, age, headYaw, headPitch, scale); } } } @@ -135,8 +138,8 @@ public class LayerPonyArmor extends AbstractPonyLayer { model.bipedLeftArm.showModel = true; model.bipedRightLeg.showModel = !isPony; model.bipedLeftLeg.showModel = !isPony; - model.extLegLeft.showModel = isPony; - model.extLegRight.showModel = isPony; + model.leftLegging.showModel = isPony; + model.rightLegging.showModel = isPony; break; // legs case LEGS: @@ -145,55 +148,63 @@ public class LayerPonyArmor extends AbstractPonyLayer { model.bipedRightArm.showModel = true; model.bipedLeftArm.showModel = true; model.bipedBody.showModel = !isPony; - model.Bodypiece.showModel = !isPony; - model.extBody.showModel = isPony; - model.extLegLeft.showModel = isPony; - model.extLegRight.showModel = isPony; + model.flankGuard.showModel = !isPony; + model.saddle.showModel = isPony; + model.leftLegging.showModel = isPony; + model.rightLegging.showModel = isPony; break; // chest case CHEST: - model.extBody.showModel = isPony; + model.saddle.showModel = isPony; model.bipedBody.showModel = !isPony; - model.Bodypiece.showModel = !isPony; + model.flankGuard.showModel = !isPony; break; // head case HEAD: model.bipedHead.showModel = true; - model.extHead.showModel = isPony; + model.helmet.showModel = isPony; } } - private void renderEnchantment(EntityLivingBase entity, ModelBase model, 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 = entity.ticksExisted + p_177183_5_; - this.getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); - GlStateManager.enableBlend(); - GlStateManager.depthFunc(514); - GlStateManager.depthMask(false); - float f8 = 0.5F; - GlStateManager.color(f8, f8, f8, 1.0F); + private void renderEnchantment(EntityLivingBase entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - for (int i = 0; i < 2; ++i) { + getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); + + GlStateManager.enableBlend(); + GlStateManager.depthFunc(GL11.GL_EQUAL); + GlStateManager.depthMask(false); + + float brightness = 0.5F; + GlStateManager.color(brightness, brightness, brightness, 1); + + float baseYOffset = entity.ticksExisted + ticks; + float glintBrightness = 0.76F; + float scaleFactor = 0.33333334F; + + for (int i = 0; i < 2; i++) { GlStateManager.disableLighting(); - GlStateManager.blendFunc(768, 1); - float f9 = 0.76F; - GlStateManager.color(0.5F * f9, 0.25F * f9, 0.8F * f9, 1.0F); + GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + + GlStateManager.color(glintBrightness / 2, glintBrightness / 4, 0.8F * glintBrightness, 1); + GlStateManager.matrixMode(5890); GlStateManager.loadIdentity(); - float f10 = 0.33333334F; - GlStateManager.scale(f10, f10, f10); - GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F); - GlStateManager.translate(0.0F, f7 * (0.001F + i * 0.003F) * 20.0F, 0.0F); - GlStateManager.matrixMode(5888); - model.render(entity, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, p_177183_9_); + + + GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor); + GlStateManager.rotate(30 - i * 60, 0, 0, 1); + GlStateManager.translate(0, baseYOffset * (0.02F + i * 0.06F), 0); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + + model.render(entity, move, swing, age, headYaw, headPitch, scale); } - GlStateManager.matrixMode(5890); + GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); - GlStateManager.matrixMode(5888); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.enableLighting(); GlStateManager.depthMask(true); - GlStateManager.depthFunc(515); + GlStateManager.depthFunc(GL11.GL_LEQUAL); GlStateManager.disableBlend(); } @@ -207,8 +218,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { String domain = human.getResourceDomain(); String path = human.getResourcePath(); if (domain.equals("minecraft")) { - // it's a vanilla armor. I provide these. - domain = "minelittlepony"; + domain = "minelittlepony"; // it's a vanilla armor. I provide these. } path = path.replace(".png", "_pony.png"); pony = new ResourceLocation(domain, path); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index 10864b36..02573010 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -25,46 +25,47 @@ public class LayerPonyCape extends AbstractPonyLayer { } @Override - public void doPonyRender(@Nonnull AbstractClientPlayer clientPlayer, float p2, float p3, float ticks, float p5, float p6, float p7, float scale) { + public void doPonyRender(@Nonnull AbstractClientPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ModelWrapper model = ((IRenderPony) getRenderer()).getPlayerModel(); - if (clientPlayer.hasPlayerInfo() && !clientPlayer.isInvisible() - && clientPlayer.isWearing(EnumPlayerModelParts.CAPE) && clientPlayer.getLocationCape() != null - && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { + + if (player.hasPlayerInfo() && !player.isInvisible() + && player.isWearing(EnumPlayerModelParts.CAPE) && player.getLocationCape() != null + && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { + pushMatrix(); model.getModel().transform(BodyPart.BODY); translate(0, 0.24F, 0); model.getModel().bipedBody.postRender(scale); - double d = clientPlayer.prevChasingPosX + (clientPlayer.chasingPosX - clientPlayer.prevChasingPosX) * scale - (clientPlayer.prevPosX + (clientPlayer.posX - clientPlayer.prevPosX) * scale); - double d1 = clientPlayer.prevChasingPosY + (clientPlayer.chasingPosY - clientPlayer.prevChasingPosY) * scale - (clientPlayer.prevPosY + (clientPlayer.posY - clientPlayer.prevPosY) * scale); - double d2 = clientPlayer.prevChasingPosZ + (clientPlayer.chasingPosZ - clientPlayer.prevChasingPosZ) * scale - (clientPlayer.prevPosZ + (clientPlayer.posZ - clientPlayer.prevPosZ) * scale); - float f10 = clientPlayer.prevRenderYawOffset + (clientPlayer.renderYawOffset - clientPlayer.prevRenderYawOffset) * scale; - double d3 = MathHelper.sin(f10 * PI / 180); - double d4 = (-MathHelper.cos(f10 * PI / 180)); - float f12 = (float) d1 * 10; - if (f12 < -6.0F) { - f12 = -6.0F; - } + double capeX = player.prevChasingPosX + (player.chasingPosX - player.prevChasingPosX) * scale - (player.prevPosX + (player.posX - player.prevPosX) * scale); + double capeY = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * scale - (player.prevPosY + (player.posY - player.prevPosY) * scale); + double capeZ = player.prevChasingPosZ + (player.chasingPosZ - player.prevChasingPosZ) * scale - (player.prevPosZ + (player.posZ - player.prevPosZ) * scale); - if (f12 > 32) { - f12 = 32; - } + float motionYaw = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * scale; - float f13 = (float) (d * d3 + d2 * d4) * 100; - float f14 = (float) (d * d4 - d2 * d3) * 100; - if (f13 < 0) { - f13 = 0; - } + double sin = MathHelper.sin(motionYaw * PI / 180); + double cos = (-MathHelper.cos(motionYaw * PI / 180)); - float f15 = clientPlayer.prevCameraYaw + (clientPlayer.cameraYaw - clientPlayer.prevCameraYaw) * scale; - f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified + (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6) * 32 * f15; + float capeMotionY = (float) capeY * 10; - rotate(2 + f13 / 12 + f12, 1, 0, 0); - rotate(f14 / 2, 0, 0, 1); - rotate(-f14 / 2, 0, 1, 0); + if (capeMotionY < -6) capeMotionY = -6; + if (capeMotionY > 32) capeMotionY = 32; + + float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100; + + float diagMotion = (float) (capeX * cos - capeZ * sin) * 100; + + if (capeMotionX < 0) capeMotionX = 0; + + float camera = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * scale; + capeMotionY += MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * scale) * 6) * 32 * camera; + + rotate(2 + capeMotionX / 12 + capeMotionY, 1, 0, 0); + rotate( diagMotion / 2, 0, 0, 1); + rotate(-diagMotion / 2, 0, 1, 0); rotate(180, 0, 0, 1); rotate(90, 1, 0, 0); - this.getRenderer().bindTexture(clientPlayer.getLocationCape()); + getRenderer().bindTexture(player.getLocationCape()); model.getModel().renderCape(0.0625F); popMatrix(); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index aa7e5c2e..31c4fb08 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -31,33 +31,37 @@ public class LayerPonyCustomHead implements LayerRenderer { private RenderLivingBase renderer; public LayerPonyCustomHead(RenderLivingBase renderPony) { - this.renderer = renderPony; + renderer = renderPony; } @Override - public void doRenderLayer(EntityLivingBase entity, float limbSwing, float p_177141_3_, - float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { + public void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (!itemstack.isEmpty()) { AbstractPonyModel model = getModel().getModel(); Item item = itemstack.getItem(); pushMatrix(); - boolean isVillager = entity instanceof EntityVillager || entity instanceof EntityZombieVillager; model.transform(BodyPart.HEAD); model.bipedHead.postRender(0.0625f); + if (model instanceof ModelPlayerPony) { translate(0, 0.2F, 0); } else { translate(0, 0, 0.15F); } + color(1, 1, 1, 1); + if (item == Items.SKULL) { - renderSkull(itemstack, isVillager, limbSwing); + boolean isVillager = entity instanceof EntityVillager || entity instanceof EntityZombieVillager; + + renderSkull(itemstack, isVillager, move); } else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) { renderBlock(entity, itemstack); } + popMatrix(); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index e5a11eaf..0f79de37 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -29,9 +29,9 @@ public class LayerPonyElytra extends AbstractPonyLayer { } @Override - public void doPonyRender(@Nonnull EntityLivingBase entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { + public void doPonyRender(@Nonnull EntityLivingBase entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) { - AbstractPonyModel model = ((IRenderPony) this.getRenderer()).getPlayerModel().getModel(); + AbstractPonyModel model = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); @@ -42,24 +42,24 @@ public class LayerPonyElytra extends AbstractPonyLayer { AbstractClientPlayer player = (AbstractClientPlayer) entity; if (player.isPlayerInfoSet() && player.getLocationElytra() != null) { - this.getRenderer().bindTexture(player.getLocationElytra()); + getRenderer().bindTexture(player.getLocationElytra()); } else if (player.hasPlayerInfo() && player.getLocationCape() != null && player.isWearing(EnumPlayerModelParts.CAPE)) { - this.getRenderer().bindTexture(player.getLocationCape()); + getRenderer().bindTexture(player.getLocationCape()); } else { - this.getRenderer().bindTexture(TEXTURE_ELYTRA); + getRenderer().bindTexture(TEXTURE_ELYTRA); } } else { - this.getRenderer().bindTexture(TEXTURE_ELYTRA); + getRenderer().bindTexture(TEXTURE_ELYTRA); } GlStateManager.pushMatrix(); GlStateManager.translate(0, 0.25F, 0.125F); model.transform(BodyPart.BODY); - this.modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); - this.modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); + modelElytra.setRotationAngles(move, swing, age, yaw, head, scale, entity); + modelElytra.render(entity, move, swing, age, yaw, head, scale); if (itemstack.isItemEnchanted()) { - LayerArmorBase.renderEnchantedGlint(this.getRenderer(), entity, this.modelElytra, swing, swingAmount, ticks, age, yaw, head, scale); + LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, modelElytra, move, swing, ticks, age, yaw, head, scale); } GlStateManager.popMatrix(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java index 5c6df3b0..cc809013 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java @@ -15,18 +15,18 @@ public class LayerPonyStrayOverlay extends LayerOverlayBase { public LayerPonyStrayOverlay(RenderLivingBase render) { super(render); - this.overlayModel = new ModelSkeletonPony(); - this.overlayModel.init(0, 0.25F); + overlayModel = new ModelSkeletonPony(); + overlayModel.init(0, 0.25F); } @Override - public void doRenderLayer(EntityStray skele, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - this.renderOverlay(skele, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + public void doRenderLayer(EntityStray entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + renderOverlay(entity, move, swing, ticks, age, headYaw, headPitch, scale); } @Override protected ModelBase getOverlayModel() { - return this.overlayModel; + return overlayModel; } @Override diff --git a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java index bd575aa1..d4beb59b 100644 --- a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -10,20 +10,20 @@ import javax.annotation.Nonnull; public class ModelPlane extends ModelBox { private TexturedQuad quad; - + public boolean hidden = false; - + public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, float x, float y, float z, int w, int h, int d, float scale, Face face) { super(renderer, textureX, textureY, x, y, z, w, h, d, scale, false); float x2 = x + w + scale; float y2 = y + h + scale; float z2 = z + d + scale; - + x -= scale; y -= scale; z -= scale; - + if (renderer.mirror) { float v = x2; x2 = x; @@ -79,6 +79,6 @@ public class ModelPlane extends ModelBox { @Override public void render(@Nonnull BufferBuilder renderer, float scale) { - if (!hidden) this.quad.draw(renderer, scale); + if (!hidden) quad.draw(renderer, scale); } } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index 9188ccb9..7cee9264 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -22,27 +22,27 @@ import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.util.ResourceLocation; public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony { - + protected final boolean smallArms; - + private ModelWrapper playerModel; - + protected AbstractPonyModel ponyModel; - + private Pony pony; - + public RenderPonyBase(RenderManager manager, boolean useSmallArms, String id, ModelWrapper model) { super(manager, useSmallArms); smallArms = useSmallArms; - + setPlayerModel(model); - + layerRenderers.clear(); addExtraLayers(); - + ((IRenderManager)manager).addPlayerSkin(id, this); } - + protected void addExtraLayers() { addLayer(new LayerPonyArmor(this)); addLayer(new LayerHeldPonyItem(this)); @@ -52,7 +52,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony addLayer(new LayerPonyElytra(this)); addLayer(new LayerEntityOnPonyShoulder(renderManager, this)); } - + @Override protected void renderLivingAt(AbstractClientPlayer player, double x, double y, double z) { float s = getScaleFactor(); @@ -61,18 +61,18 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony } @Override - public void doRender(AbstractClientPlayer player, double x, double y, double z, float entityYaw, float partialTicks) { + public void doRender(AbstractClientPlayer player, double x, double y, double z, float entityYaw, float ticks) { updateModel(player); ponyModel.isSneak = player.isSneaking(); ponyModel.isSleeping = player.isPlayerSleeping(); ponyModel.isFlying = pony.isPegasusFlying(player); - - shadowSize = getPonyShadowScale(); - - super.doRender(player, x, y, z, entityYaw, partialTicks); + + shadowSize = getShadowScale(); + + super.doRender(player, x, y, z, entityYaw, ticks); } - + @Override public void renderRightArm(AbstractClientPlayer player) { updateModel(player); @@ -88,41 +88,41 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony updateModel(player); bindEntityTexture(player); GlStateManager.pushMatrix(); - GlStateManager.translate(0.06, -0.37, -0); + GlStateManager.translate(0.06, -0.37, 0); super.renderLeftArm(player); GlStateManager.popMatrix(); } - + @Override protected void applyRotations(AbstractClientPlayer player, float yaw, float pitch, float ticks) { super.applyRotations(player, yaw, pitch, ticks); - + double motionX = player.posX - player.prevPosX; double motionY = player.onGround ? 0 : player.posY - player.prevPosY; double motionZ = player.posZ - player.prevPosZ; - + if (player.isElytraFlying()) { transformElytraFlight(player, motionX, motionY, motionZ, ticks); - return; } - + if (player.isEntityAlive() && player.isPlayerSleeping()) return; - + if (((ModelPlayerPony) ponyModel).rainboom) { transformPegasusFlight(player, motionX, motionY, motionZ, yaw, pitch, ticks); return; } - + // require arms to be stretched out (sorry mud ponies, no flight skills for you) ponyModel.motionPitch = 0; } - - public ResourceLocation getEntityTexture(AbstractClientPlayer entity) { - updateModel(entity); + + @Override + public ResourceLocation getEntityTexture(AbstractClientPlayer player) { + updateModel(player); return pony.getTexture(); } - + @Override public ModelWrapper getPlayerModel() { return playerModel; @@ -132,21 +132,19 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony playerModel = model; mainModel = ponyModel = playerModel.getModel(); } - + protected void updateModel(AbstractClientPlayer player) { pony = MineLittlePony.getInstance().getManager().getPony(player); playerModel.apply(pony.getMetadata()); } - + public Pony getPony() { return pony; } - - protected abstract float getPonyShadowScale(); - + protected abstract float getScaleFactor(); protected abstract void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks); - + protected abstract void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks); } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index ea72c1fc..2754bd57 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -12,13 +12,13 @@ public class RenderPonyPlayer extends RenderPonyBase { public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, ModelWrapper model) { super(renderManager, useSmallArms, id, model); } - + @Override - protected float getPonyShadowScale() { + public float getShadowScale() { if (!MineLittlePony.getConfig().showscale) return .5f; return getPony().getMetadata().getSize().getShadowSize(); } - + @Override protected float getScaleFactor() { return getPony().getMetadata().getSize().getScaleFactor(); @@ -34,7 +34,7 @@ public class RenderPonyPlayer extends RenderPonyBase { protected void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks) { double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); double angle = Math.atan2(motionY, dist); - + if (!player.capabilities.isFlying) { if (angle > 0) { angle = 0; @@ -45,9 +45,9 @@ public class RenderPonyPlayer extends RenderPonyBase { if (angle > Math.PI / 3) angle = Math.PI / 3; if (angle < -Math.PI / 3) angle = -Math.PI / 3; - + ponyModel.motionPitch = (float) Math.toDegrees(angle); - + GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java index 71d47177..3ef0643a 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java @@ -17,21 +17,23 @@ 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, PMAPI.illager); + public RenderPonyEvoker(RenderManager manager) { + super(manager, 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 (((EntitySpellcasterIllager) entitylivingbaseIn).isSpellcasting()) { - super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + addLayer(new LayerHeldPonyItem(this) { + @Override + public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float age, float headYaw, float headPitch, float scale) { + if (((EntitySpellcasterIllager) entity).isSpellcasting()) { + super.doPonyRender(entity, limbSwing, limbSwingAmount, ticks, age, headYaw, headPitch, scale); } } - protected void translateToHand(EnumHandSide p_191361_1_) { - ((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(p_191361_1_).postRender(0.0625F); + @Override + protected void translateToHand(EnumHandSide hand) { + ((ModelIllagerPony) getRenderer().getMainModel()).getArm(hand).postRender(0.0625F); } }); } @@ -42,8 +44,8 @@ public class RenderPonyEvoker extends RenderPonyMob { } @Override - protected void preRenderCallback(EntityEvoker entitylivingbaseIn, float partialTickTime) { - super.preRenderCallback(entitylivingbaseIn, partialTickTime); + protected void preRenderCallback(EntityEvoker entity, float ticks) { + super.preRenderCallback(entity, ticks); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java index 0c9dff2d..ba223c60 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java @@ -19,24 +19,23 @@ public class RenderPonyIllusionIllager extends RenderPonyMob { private static final ResourceLocation PIGMAN = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pigman_pony.png"); - public RenderPonyPigman(RenderManager renderManager) { - super(renderManager, PMAPI.pony); + public RenderPonyPigman(RenderManager manager) { + super(manager, PMAPI.pony); } @Override diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java index e83ecb53..a871e03c 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java @@ -25,11 +25,11 @@ public class RenderPonySkeleton extends Rende @Override protected void addLayers() { super.addLayers(); - this.addLayer(new LayerBipedArmor(this) { + addLayer(new LayerBipedArmor(this) { @Override protected void initArmor() { - this.modelLeggings = getPlayerModel().getArmor().modelArmor; - this.modelArmor = getPlayerModel().getArmor().modelArmorChestplate; + modelLeggings = getPlayerModel().getArmor().armour; + modelArmor = getPlayerModel().getArmor().chestplate; } }); } @@ -43,7 +43,7 @@ public class RenderPonySkeleton extends Rende public Stray(RenderManager rm) { super(rm); - this.addLayer(new LayerPonyStrayOverlay(this)); + addLayer(new LayerPonyStrayOverlay(this)); } @Override @@ -64,8 +64,8 @@ public class RenderPonySkeleton extends Rende } @Override - protected void preRenderCallback(EntityWitherSkeleton skeleton, float partialTicks) { - super.preRenderCallback(skeleton, partialTicks); + protected void preRenderCallback(EntityWitherSkeleton skeleton, float ticks) { + super.preRenderCallback(skeleton, ticks); GlStateManager.scale(1.2F, 1.2F, 1.2F); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java index 0c95da70..7341de76 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java @@ -16,12 +16,12 @@ public class RenderPonyVex extends RenderBiped { private static final ResourceLocation VEX = new ResourceLocation("minelittlepony", "textures/entity/illager/vex_pony.png"); private static final ResourceLocation VEX_CHARGING = new ResourceLocation("minelittlepony", "textures/entity/illager/vex_charging_pony.png"); - public RenderPonyVex(RenderManager renderManagerIn) { - super(renderManagerIn, new ModelBreezie(), 0.3F); + public RenderPonyVex(RenderManager manager) { + super(manager, new ModelBreezie(), 0.3F); } @Override - protected void preRenderCallback(EntityVex entitylivingbaseIn, float partialTickTime) { + protected void preRenderCallback(EntityVex entity, float ticks) { GlStateManager.scale(0.4F, 0.4F, 0.4F); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java index 52ed43c6..85b781f4 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java @@ -19,13 +19,13 @@ public class RenderPonyVillager extends RenderPonyMob { new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png") }; - public RenderPonyVillager(RenderManager rm) { - super(rm, PMAPI.villager); + public RenderPonyVillager(RenderManager manager) { + super(manager, PMAPI.villager); } @Override - protected void preRenderCallback(EntityVillager villager, float partialTicks) { - super.preRenderCallback(villager, partialTicks); + protected void preRenderCallback(EntityVillager villager, float ticks) { + super.preRenderCallback(villager, ticks); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java index 814c0981..6d2b2bc7 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java @@ -16,8 +16,8 @@ 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, PMAPI.illager); + public RenderPonyVindicator(RenderManager manager) { + super(manager, PMAPI.illager); } @@ -25,17 +25,15 @@ public class RenderPonyVindicator extends RenderPonyMob { protected void addLayers() { this.addLayer(new LayerHeldPonyItem(this) { @Override - public void doPonyRender(EntityLivingBase vindicator, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, - float netHeadYaw, float headPitch, float scale) { - - if (((EntityVindicator) vindicator).isAggressive()) { - super.doPonyRender(vindicator, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + public void doPonyRender(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + if (((EntityVindicator) entity).isAggressive()) { + super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); } } @Override protected void translateToHand(EnumHandSide side) { - ((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(side).postRender(0.0625F); + ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); } }); } @@ -46,8 +44,8 @@ public class RenderPonyVindicator extends RenderPonyMob { } @Override - protected void preRenderCallback(EntityVindicator entitylivingbaseIn, float partialTickTime) { - super.preRenderCallback(entitylivingbaseIn, partialTickTime); + protected void preRenderCallback(EntityVindicator entity, float ticks) { + super.preRenderCallback(entity, ticks); GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java index 3e7c144a..9645c06d 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java @@ -15,48 +15,48 @@ public class RenderPonyZombie extends RenderPonyMob private static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png"); private static final ResourceLocation HUSK = new ResourceLocation("minelittlepony", "textures/entity/zombie/husk_pony.png"); - public RenderPonyZombie(RenderManager rendermanager) { - super(rendermanager, PMAPI.zombie); + public RenderPonyZombie(RenderManager manager) { + super(manager, PMAPI.zombie); } @Override - protected ResourceLocation getTexture(Zombie zombie) { + protected ResourceLocation getTexture(Zombie entity) { return ZOMBIE; } public static class Husk extends RenderPonyZombie { - public Husk(RenderManager rendermanager) { - super(rendermanager); + public Husk(RenderManager manager) { + super(manager); } @Override - protected void preRenderCallback(EntityHusk entitylivingbaseIn, float partialTickTime) { + protected void preRenderCallback(EntityHusk entity, float ticks) { GlStateManager.scale(1.0625F, 1.0625F, 1.0625F); - super.preRenderCallback(entitylivingbaseIn, partialTickTime); + super.preRenderCallback(entity, ticks); } @Override - protected ResourceLocation getTexture(EntityHusk zombie) { + protected ResourceLocation getTexture(EntityHusk entity) { return HUSK; } } - + public static class Giant extends RenderPonyMob { - public Giant(RenderManager renderManager) { - super(renderManager, PMAPI.zombie); + public Giant(RenderManager manager) { + super(manager, PMAPI.zombie); } - + @Override - protected void preRenderCallback(EntityGiantZombie entitylivingbaseIn, float partialTickTime) { + protected void preRenderCallback(EntityGiantZombie entity, float ticks) { GlStateManager.scale(3, 3, 3); - super.preRenderCallback(entitylivingbaseIn, partialTickTime); + super.preRenderCallback(entity, ticks); } - + @Override - protected ResourceLocation getTexture(EntityGiantZombie zombie) { + protected ResourceLocation getTexture(EntityGiantZombie entity) { return ZOMBIE; } } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java index e506a132..41aee572 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java @@ -18,21 +18,21 @@ public class RenderPonyZombieVillager extends RenderPonyMob Date: Fri, 27 Apr 2018 17:50:13 +0200 Subject: [PATCH 39/96] Use generics --- .../hdskins/gui/RenderPonyModel.java | 10 +++------- .../minelittlepony/render/RenderPonyMob.java | 8 ++++---- .../render/layer/AbstractPonyLayer.java | 17 +++++++++-------- .../render/layer/LayerEntityOnPonyShoulder.java | 6 +++--- .../render/layer/LayerHeldPonyItem.java | 10 +++++----- .../render/layer/LayerPonyArmor.java | 12 ++++++------ .../render/layer/LayerPonyCape.java | 2 +- .../render/layer/LayerPonyCustomHead.java | 10 +++++----- .../render/layer/LayerPonyElytra.java | 6 +++--- .../render/player/RenderPonyBase.java | 8 ++++---- .../render/ponies/RenderPonyEvoker.java | 10 ++++------ .../ponies/RenderPonyIllusionIllager.java | 9 ++++----- .../render/ponies/RenderPonyVindicator.java | 7 +++---- 13 files changed, 54 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index ca8a91a2..721b0dee 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -44,15 +44,11 @@ public class RenderPonyModel extends RenderPlayerModel { @Override protected LayerRenderer getElytraLayer() { - final LayerRenderer elytra = super.getElytraLayer(); - final PonyElytra modelElytra = new PonyElytra(); - return new AbstractPonyLayer(this, elytra) { + return new AbstractPonyLayer(this, super.getElytraLayer()) { + final PonyElytra modelElytra = new PonyElytra(); @Override - public void doPonyRender(EntityLivingBase entityBase, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { - - EntityPonyModel entity = (EntityPonyModel) entityBase; - + public void doPonyRender(EntityPonyModel entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 721241b9..41762b0e 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -28,11 +28,11 @@ public abstract class RenderPonyMob extends RenderLiving } protected void addLayers() { - addLayer(new LayerPonyArmor(this)); - addLayer(new LayerHeldPonyItem(this)); + addLayer(new LayerPonyArmor<>(this)); + addLayer(new LayerHeldPonyItem<>(this)); // addLayer(new LayerArrow(this)); - addLayer(new LayerPonyCustomHead(this)); - addLayer(new LayerPonyElytra(this)); + addLayer(new LayerPonyCustomHead<>(this)); + addLayer(new LayerPonyElytra<>(this)); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 0e61e2b7..a13a80bc 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -7,31 +7,32 @@ import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; -public abstract class AbstractPonyLayer implements LayerRenderer { +public abstract class AbstractPonyLayer implements LayerRenderer { - private final RenderLivingBase renderer; - private LayerRenderer layer; + private final RenderLivingBase renderer; + private LayerRenderer layer; - public AbstractPonyLayer(RenderLivingBase renderer, LayerRenderer humanLayer) { + public AbstractPonyLayer(RenderLivingBase renderer, LayerRenderer humanLayer) { this.renderer = renderer; this.layer = humanLayer; } + @SuppressWarnings("unchecked") @Override - public final void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ModelBase model = renderer.getMainModel(); if (model instanceof ModelHumanPlayer) { // render the human layer - layer.doRenderLayer(entity, move, swing, ticks, age, headYaw, headPitch, scale); + layer.doRenderLayer((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); } else { // render the pony layer - doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); + doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); } } protected abstract void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale); - protected RenderLivingBase getRenderer() { + protected RenderLivingBase getRenderer() { return renderer; } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index a4570bee..27535f4b 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -19,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import javax.annotation.Nullable; -public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { +public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { private final RenderManager renderManager; @@ -32,7 +32,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { } @Override - public void doPonyRender(EntityPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(AbstractClientPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { GlStateManager.enableRescaleNormal(); GlStateManager.color(1, 1, 1, 1); @@ -56,7 +56,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { @SuppressWarnings("unchecked") @Nullable - private EntityLivingBase renderShoulderEntity(EntityPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound tag, + private EntityLivingBase renderShoulderEntity(AbstractClientPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound tag, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, boolean left) { if (entity == null || !entity.getUniqueID().equals(tag.getUniqueId("UUID"))) { diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index c0ce7c86..1af8aec1 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -26,14 +26,14 @@ import javax.annotation.Nullable; import static net.minecraft.client.renderer.GlStateManager.*; -public class LayerHeldPonyItem extends AbstractPonyLayer { +public class LayerHeldPonyItem extends AbstractPonyLayer { - public LayerHeldPonyItem(RenderLivingBase livingPony) { + public LayerHeldPonyItem(RenderLivingBase livingPony) { super(livingPony, new LayerHeldItem(livingPony)); } @Override - public void doPonyRender(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ModelBase model = getRenderer().getMainModel(); boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; @@ -62,7 +62,7 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { } } - private void renderHeldItem(EntityLivingBase entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + private void renderHeldItem(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (!drop.isEmpty()) { GlStateManager.pushMatrix(); translateToHand(hand); @@ -108,7 +108,7 @@ public class LayerHeldPonyItem extends AbstractPonyLayer { } } - public void renderItemGlow(EntityLivingBase entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) { + public void renderItemGlow(T entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) { // enchantments mess up the rendering ItemStack drop2 = drop.copy(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index 1379514c..b8007727 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -29,7 +29,7 @@ import org.lwjgl.opengl.GL11; import java.io.IOException; import java.util.Map; -public class LayerPonyArmor extends AbstractPonyLayer { +public class LayerPonyArmor extends AbstractPonyLayer { private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png"); @@ -38,12 +38,12 @@ public class LayerPonyArmor extends AbstractPonyLayer { private ModelWrapper pony; - public LayerPonyArmor(RenderLivingBase renderer) { + public LayerPonyArmor(RenderLivingBase renderer) { super(renderer, new LayerBipedArmor(renderer)); } @Override - public void doPonyRender(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { pony = ((IRenderPony) getRenderer()).getPlayerModel(); for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) { @@ -53,7 +53,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { } } - private void renderArmor(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { + private void renderArmor(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { @@ -93,7 +93,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { } } - private Tuple getArmorTexture(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, @Nullable String type) { + private Tuple getArmorTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, @Nullable String type) { ItemArmor item = (ItemArmor) itemstack.getItem(); String texture = item.getArmorMaterial().getName(); String domain = "minecraft"; @@ -166,7 +166,7 @@ public class LayerPonyArmor extends AbstractPonyLayer { } } - private void renderEnchantment(EntityLivingBase entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + private void renderEnchantment(T entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index 02573010..d7f21109 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -20,7 +20,7 @@ import static com.minelittlepony.model.PonyModelConstants.PI; public class LayerPonyCape extends AbstractPonyLayer { - public LayerPonyCape(RenderLivingBase entity) { + public LayerPonyCape(RenderLivingBase entity) { super(entity, new LayerCape((RenderPlayer) entity)); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 31c4fb08..5a8cd881 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -26,16 +26,16 @@ import net.minecraft.util.EnumFacing; import static net.minecraft.client.renderer.GlStateManager.*; -public class LayerPonyCustomHead implements LayerRenderer { +public class LayerPonyCustomHead implements LayerRenderer { - private RenderLivingBase renderer; + private RenderLivingBase renderer; - public LayerPonyCustomHead(RenderLivingBase renderPony) { + public LayerPonyCustomHead(RenderLivingBase renderPony) { renderer = renderPony; } @Override - public void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (!itemstack.isEmpty()) { AbstractPonyModel model = getModel().getModel(); @@ -67,7 +67,7 @@ public class LayerPonyCustomHead implements LayerRenderer { } - private void renderBlock(EntityLivingBase entity, ItemStack itemstack) { + private void renderBlock(T entity, ItemStack itemstack) { rotate(180, 0, 1, 0); scale(0.625, -0.625F, -0.625F); translate(0, 0.4F, -0.21F); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index 0f79de37..7fdefb4d 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -19,17 +19,17 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -public class LayerPonyElytra extends AbstractPonyLayer { +public class LayerPonyElytra extends AbstractPonyLayer { private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); private PonyElytra modelElytra = new PonyElytra(); - public LayerPonyElytra(RenderLivingBase rp) { + public LayerPonyElytra(RenderLivingBase rp) { super(rp, new LayerElytra(rp)); } @Override - public void doPonyRender(@Nonnull EntityLivingBase entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) { + public void doPonyRender(@Nonnull T entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) { AbstractPonyModel model = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index 7cee9264..c5e64560 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -44,12 +44,12 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony } protected void addExtraLayers() { - addLayer(new LayerPonyArmor(this)); - addLayer(new LayerHeldPonyItem(this)); + addLayer(new LayerPonyArmor<>(this)); + addLayer(new LayerHeldPonyItem<>(this)); addLayer(new LayerArrow(this)); addLayer(new LayerPonyCape(this)); - addLayer(new LayerPonyCustomHead(this)); - addLayer(new LayerPonyElytra(this)); + addLayer(new LayerPonyCustomHead<>(this)); + addLayer(new LayerPonyElytra<>(this)); addLayer(new LayerEntityOnPonyShoulder(renderManager, this)); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java index 3ef0643a..961f3ead 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java @@ -7,9 +7,7 @@ import com.minelittlepony.render.layer.LayerHeldPonyItem; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; -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; @@ -23,11 +21,11 @@ public class RenderPonyEvoker extends RenderPonyMob { @Override protected void addLayers() { - addLayer(new LayerHeldPonyItem(this) { + addLayer(new LayerHeldPonyItem(this) { @Override - public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float age, float headYaw, float headPitch, float scale) { - if (((EntitySpellcasterIllager) entity).isSpellcasting()) { - super.doPonyRender(entity, limbSwing, limbSwingAmount, ticks, age, headYaw, headPitch, scale); + public void doPonyRender(EntityEvoker entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + if (entity.isSpellcasting()) { + super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); } } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java index ba223c60..d9076f7d 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java @@ -7,7 +7,6 @@ import com.minelittlepony.render.layer.LayerHeldPonyItem; import net.minecraft.client.renderer.GlStateManager; 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; @@ -25,11 +24,11 @@ public class RenderPonyIllusionIllager extends RenderPonyMob(this) { @Override - public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float age, float headYaw, float headPitch, float scale) { - if (((EntityIllusionIllager) entity).isSpellcasting() || ((EntityIllusionIllager) entity).isAggressive()) { - super.doPonyRender(entity, limbSwing, limbSwingAmount, ticks, age, headYaw, headPitch, scale); + public void doPonyRender(EntityIllusionIllager entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + if (entity.isSpellcasting() || entity.isAggressive()) { + super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); } } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java index 6d2b2bc7..b5fe5bc8 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java @@ -7,7 +7,6 @@ import com.minelittlepony.render.layer.LayerHeldPonyItem; import net.minecraft.client.renderer.GlStateManager; 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; @@ -23,10 +22,10 @@ public class RenderPonyVindicator extends RenderPonyMob { @Override protected void addLayers() { - this.addLayer(new LayerHeldPonyItem(this) { + this.addLayer(new LayerHeldPonyItem(this) { @Override - public void doPonyRender(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - if (((EntityVindicator) entity).isAggressive()) { + public void doPonyRender(EntityVindicator entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + if (entity.isAggressive()) { super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); } } From b00b2745e1883df93e18457a46cc20e92c5547fb Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 17:55:30 +0200 Subject: [PATCH 40/96] Rename 'translateToHand' to better reflect what it does --- .../render/layer/LayerHeldPonyItem.java | 11 +++++++---- .../render/ponies/RenderPonyEvoker.java | 4 ++-- .../render/ponies/RenderPonyIllusionIllager.java | 4 ++-- .../render/ponies/RenderPonyVindicator.java | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index 1af8aec1..a6488281 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -65,7 +65,7 @@ public class LayerHeldPonyItem extends AbstractPonyL private void renderHeldItem(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (!drop.isEmpty()) { GlStateManager.pushMatrix(); - translateToHand(hand); + postRenderArm(hand); if (entity.isSneaking()) { GlStateManager.translate(0, 0.2F, 0); @@ -97,14 +97,17 @@ public class LayerHeldPonyItem extends AbstractPonyL return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); } - protected void translateToHand(EnumHandSide hand) { + /** + * Renders the main arm + */ + protected void postRenderArm(EnumHandSide side) { AbstractPonyModel thePony = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); if (thePony.metadata.hasMagic()) { ModelPlayerPony playerModel = (ModelPlayerPony) thePony; - ModelRenderer unicornarm = hand == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; + ModelRenderer unicornarm = side == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; unicornarm.postRender(0.0625F); } else { - ((ModelBiped) getRenderer().getMainModel()).postRenderArm(0.0625F, hand); + ((ModelBiped) getRenderer().getMainModel()).postRenderArm(0.0625F, side); } } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java index 961f3ead..b27a14bd 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java @@ -30,8 +30,8 @@ public class RenderPonyEvoker extends RenderPonyMob { } @Override - protected void translateToHand(EnumHandSide hand) { - ((ModelIllagerPony) getRenderer().getMainModel()).getArm(hand).postRender(0.0625F); + protected void postRenderArm(EnumHandSide side) { + ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); } }); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java index d9076f7d..c8c27f77 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java @@ -33,8 +33,8 @@ public class RenderPonyIllusionIllager extends RenderPonyMob { } @Override - protected void translateToHand(EnumHandSide side) { + protected void postRenderArm(EnumHandSide side) { ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); } }); From 235494cd6cfaa644ccfbf513aab2d31629e042a6 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 19:06:22 +0200 Subject: [PATCH 41/96] Split the held item renderer up into a magical and non-magical variant since they not neccessarily neet to be together --- .../minelittlepony/render/RenderPonyMob.java | 4 +- .../render/layer/LayerHeldPonyItem.java | 89 ++------------ .../layer/LayerHeldPonyItemMagical.java | 111 ++++++++++++++++++ 3 files changed, 124 insertions(+), 80 deletions(-) create mode 100644 src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 41762b0e..33870add 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -3,7 +3,7 @@ package com.minelittlepony.render; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.ModelWrapper; -import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.render.layer.LayerPonyArmor; import com.minelittlepony.render.layer.LayerPonyCustomHead; import com.minelittlepony.render.layer.LayerPonyElytra; @@ -29,7 +29,7 @@ public abstract class RenderPonyMob extends RenderLiving protected void addLayers() { addLayer(new LayerPonyArmor<>(this)); - addLayer(new LayerHeldPonyItem<>(this)); + addLayer(new LayerHeldPonyItemMagical<>(this)); // addLayer(new LayerArrow(this)); addLayer(new LayerPonyCustomHead<>(this)); addLayer(new LayerPonyElytra<>(this)); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index a6488281..a1ebb217 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -1,29 +1,17 @@ package com.minelittlepony.render.layer; -import com.minelittlepony.ducks.IRenderItem; -import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.ponies.ModelPlayerPony; -import com.minelittlepony.pony.data.IPonyData; - import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; 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 extends AbstractPonyLayer { @@ -65,7 +53,7 @@ public class LayerHeldPonyItem extends AbstractPonyL private void renderHeldItem(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (!drop.isEmpty()) { GlStateManager.pushMatrix(); - postRenderArm(hand); + renderArm(hand); if (entity.isSneaking()) { GlStateManager.translate(0, 0.2F, 0); @@ -74,81 +62,26 @@ public class LayerHeldPonyItem extends AbstractPonyL GlStateManager.rotate(-90, 1, 0, 0); GlStateManager.rotate(180, 0, 1, 0); - boolean isUnicorn = isUnicorn(getRenderer().getMainModel()); - boolean isLeft = hand == EnumHandSide.LEFT; + preItemRender(entity, drop, transform, hand); + Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, hand == EnumHandSide.LEFT); + postItemRender(entity, drop, transform, hand); - if (isUnicorn) { - GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -0.5F); - } else { - GlStateManager.translate(0.0425F, 0.125F, -1); - } - - Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); - - if (isUnicorn) { - IPonyData metadata = ((AbstractPonyModel) getRenderer().getMainModel()).metadata; - renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); - } GlStateManager.popMatrix(); } } - private static boolean isUnicorn(ModelBase model) { - return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); + protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + GlStateManager.translate(0.0425F, 0.125F, -1); + } + + protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { } /** * Renders the main arm */ - protected void postRenderArm(EnumHandSide side) { - AbstractPonyModel thePony = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); - if (thePony.metadata.hasMagic()) { - ModelPlayerPony playerModel = (ModelPlayerPony) thePony; - ModelRenderer unicornarm = side == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; - unicornarm.postRender(0.0625F); - } else { - ((ModelBiped) getRenderer().getMainModel()).postRenderArm(0.0625F, side); - } - } - - public void renderItemGlow(T entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) { - - // enchantments mess up the rendering - ItemStack drop2 = drop.copy(); - 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; - float alpha = 0.2F; - - pushMatrix(); - disableLighting(); - - GL14.glBlendColor(red, green, blue, alpha); - - RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - ((IRenderItem) renderItem).useTransparency(true); - - scale(1.1, 1.1, 1.1); - - translate(0, .01, .01); - renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); - translate(.01, -.01, -.02); - renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); - - ((IRenderItem) renderItem).useTransparency(false); - enableLighting(); - popMatrix(); - - // I hate rendering - } - - private void removeEnch(@Nullable NBTTagCompound tag) { - if (tag != null) { - tag.removeTag("ench"); - } + protected void renderArm(EnumHandSide side) { + ((ModelBiped) getRenderer().getMainModel()).postRenderArm(0.0625F, side); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java new file mode 100644 index 00000000..94be2ca8 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -0,0 +1,111 @@ +package com.minelittlepony.render.layer; + +import static net.minecraft.client.renderer.GlStateManager.disableLighting; +import static net.minecraft.client.renderer.GlStateManager.enableLighting; +import static net.minecraft.client.renderer.GlStateManager.popMatrix; +import static net.minecraft.client.renderer.GlStateManager.pushMatrix; +import static net.minecraft.client.renderer.GlStateManager.scale; +import static net.minecraft.client.renderer.GlStateManager.translate; + +import javax.annotation.Nullable; + +import org.lwjgl.opengl.GL14; + +import com.minelittlepony.ducks.IRenderItem; +import com.minelittlepony.ducks.IRenderPony; +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.ponies.ModelPlayerPony; +import com.minelittlepony.pony.data.IPonyData; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumHandSide; + +public class LayerHeldPonyItemMagical extends LayerHeldPonyItem { + + public LayerHeldPonyItemMagical(RenderLivingBase livingPony) { + super(livingPony); + } + + private boolean isUnicorn() { + ModelBase model = getRenderer().getMainModel(); + return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); + } + + protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + if (isUnicorn()) { + GlStateManager.translate(hand == EnumHandSide.LEFT ? -0.6F : 0.1F, 1, -0.5F); + } else { + super.preItemRender(entity, drop, transform, hand); + } + } + + protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + if (isUnicorn()) { + IPonyData metadata = ((AbstractPonyModel) getRenderer().getMainModel()).metadata; + renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); + } + } + + /** + * Renders the main arm + */ + protected void renderArm(EnumHandSide side) { + AbstractPonyModel thePony = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); + if (thePony.metadata.hasMagic()) { + ModelPlayerPony playerModel = (ModelPlayerPony) thePony; + ModelRenderer unicornarm = side == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; + unicornarm.postRender(0.0625F); + } else { + super.renderArm(side); + } + } + + public void renderItemGlow(T entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) { + + // enchantments mess up the rendering + ItemStack drop2 = drop.copy(); + 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; + float alpha = 0.2F; + + pushMatrix(); + disableLighting(); + + GL14.glBlendColor(red, green, blue, alpha); + + RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); + ((IRenderItem) renderItem).useTransparency(true); + + scale(1.1, 1.1, 1.1); + + translate(0, .01, .01); + renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); + translate(.01, -.01, -.02); + renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); + + ((IRenderItem) renderItem).useTransparency(false); + enableLighting(); + popMatrix(); + + // I hate rendering + } + + private void removeEnch(@Nullable NBTTagCompound tag) { + if (tag != null) { + tag.removeTag("ench"); + } + } +} From e14b601b9fd3ac759504666c7d354475c36e377e Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 19:08:23 +0200 Subject: [PATCH 42/96] Merge RenderPonyEvoker + RenderPonyIllusionIllager + RenderPonyVindicator = RenderPonyIllager --- .../com/minelittlepony/PonyRenderManager.java | 10 +- .../render/layer/LayerHeldItemIllager.java | 31 ++++++ .../render/ponies/RenderPonyEvoker.java | 50 ---------- .../render/ponies/RenderPonyIllager.java | 96 +++++++++++++++++++ .../ponies/RenderPonyIllusionIllager.java | 75 --------------- .../render/ponies/RenderPonyVindicator.java | 51 ---------- 6 files changed, 131 insertions(+), 182 deletions(-) create mode 100644 src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java delete mode 100644 src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java create mode 100644 src/main/java/com/minelittlepony/render/ponies/RenderPonyIllager.java delete mode 100644 src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java delete mode 100644 src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index a408afaa..178237cb 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -7,13 +7,11 @@ import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.RenderPonyModel; import com.minelittlepony.model.PMAPI; import com.minelittlepony.render.player.RenderPonyPlayer; -import com.minelittlepony.render.ponies.RenderPonyEvoker; -import com.minelittlepony.render.ponies.RenderPonyIllusionIllager; +import com.minelittlepony.render.ponies.RenderPonyIllager; import com.minelittlepony.render.ponies.RenderPonyPigman; import com.minelittlepony.render.ponies.RenderPonySkeleton; import com.minelittlepony.render.ponies.RenderPonyVex; import com.minelittlepony.render.ponies.RenderPonyVillager; -import com.minelittlepony.render.ponies.RenderPonyVindicator; import com.minelittlepony.render.ponies.RenderPonyZombie; import com.minelittlepony.render.ponies.RenderPonyZombieVillager; import com.mumfrey.liteloader.util.ModUtilities; @@ -104,9 +102,9 @@ public class PonyRenderManager { if (config.illagers) { pushNewRenderer(rm, EntityVex.class, new RenderPonyVex(rm)); - pushNewRenderer(rm, EntityEvoker.class, new RenderPonyEvoker(rm)); - pushNewRenderer(rm, EntityVindicator.class, new RenderPonyVindicator(rm)); - pushNewRenderer(rm, EntityIllusionIllager.class, new RenderPonyIllusionIllager(rm)); + pushNewRenderer(rm, EntityEvoker.class, new RenderPonyIllager.Evoker(rm)); + pushNewRenderer(rm, EntityVindicator.class, new RenderPonyIllager.Vindicator(rm)); + pushNewRenderer(rm, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(rm)); MineLittlePony.logger.info("Illagers are now ponies."); } else { restoreRenderer(EntityVex.class); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java new file mode 100644 index 00000000..e389b90e --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java @@ -0,0 +1,31 @@ +package com.minelittlepony.render.layer; + +import com.minelittlepony.model.ponies.ModelIllagerPony; + +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.entity.monster.AbstractIllager; +import net.minecraft.entity.monster.AbstractIllager.IllagerArmPose; +import net.minecraft.util.EnumHandSide; + +public class LayerHeldItemIllager extends LayerHeldPonyItem { + + public LayerHeldItemIllager(RenderLivingBase livingPony) { + super(livingPony); + } + + @Override + public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + if (shouldRender(entity)) { + super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); + } + } + + @Override + protected void renderArm(EnumHandSide side) { + ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); + } + + public boolean shouldRender(T entity) { + return entity.getArmPose() != IllagerArmPose.CROSSED; + } +} diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java deleted file mode 100644 index b27a14bd..00000000 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyEvoker.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.minelittlepony.render.ponies; - -import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.ponies.ModelIllagerPony; -import com.minelittlepony.render.RenderPonyMob; -import com.minelittlepony.render.layer.LayerHeldPonyItem; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityEvoker; -import net.minecraft.util.EnumHandSide; -import net.minecraft.util.ResourceLocation; - -public class RenderPonyEvoker extends RenderPonyMob { - - private static final ResourceLocation EVOKER = new ResourceLocation("minelittlepony", "textures/entity/illager/evoker_pony.png"); - - public RenderPonyEvoker(RenderManager manager) { - super(manager, PMAPI.illager); - } - - @Override - protected void addLayers() { - addLayer(new LayerHeldPonyItem(this) { - @Override - public void doPonyRender(EntityEvoker entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - if (entity.isSpellcasting()) { - super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); - } - } - - @Override - protected void postRenderArm(EnumHandSide side) { - ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); - } - }); - } - - @Override - protected ResourceLocation getTexture(EntityEvoker entity) { - return EVOKER; - } - - @Override - protected void preRenderCallback(EntityEvoker entity, float ticks) { - super.preRenderCallback(entity, ticks); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - } - -} diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllager.java new file mode 100644 index 00000000..5175fefd --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllager.java @@ -0,0 +1,96 @@ +package com.minelittlepony.render.ponies; + +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerHeldItemIllager; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.monster.AbstractIllager; +import net.minecraft.entity.monster.EntityEvoker; +import net.minecraft.entity.monster.EntityIllusionIllager; +import net.minecraft.entity.monster.EntityVindicator; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; + +public abstract class RenderPonyIllager extends RenderPonyMob { + + public static final ResourceLocation ILLUSIONIST = new ResourceLocation("minelittlepony", "textures/entity/illager/illusionist_pony.png"); + public static final ResourceLocation EVOKER = new ResourceLocation("minelittlepony", "textures/entity/illager/evoker_pony.png"); + public static final ResourceLocation VINDICATOR = new ResourceLocation("minelittlepony", "textures/entity/illager/vindicator_pony.png"); + + public RenderPonyIllager(RenderManager manager) { + super(manager, PMAPI.illager); + } + + @Override + protected void addLayers() { + addLayer(new LayerHeldItemIllager<>(this)); + } + + @Override + protected void preRenderCallback(T entity, float ticks) { + super.preRenderCallback(entity, ticks); + GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); + } + + public static class Vindicator extends RenderPonyIllager { + + public Vindicator(RenderManager manager) { + super(manager); + + } + + @Override + protected ResourceLocation getTexture(EntityVindicator entity) { + return VINDICATOR; + } + } + + public static class Evoker extends RenderPonyIllager { + + public Evoker(RenderManager manager) { + super(manager); + } + + @Override + protected ResourceLocation getTexture(EntityEvoker entity) { + return EVOKER; + } + } + + public static class Illusionist extends RenderPonyIllager { + + public Illusionist(RenderManager manager) { + super(manager); + } + + @Override + protected ResourceLocation getTexture(EntityIllusionIllager entity) { + return ILLUSIONIST; + } + + @Override + public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float ticks) { + if (entity.isInvisible()) { + Vec3d[] clones = entity.getRenderLocations(ticks); + float rotation = handleRotationFloat(entity, ticks); + + for (int i = 0; i < clones.length; ++i) { + super.doRender(entity, + x + clones[i].x + MathHelper.cos(i + rotation * 0.5F) * 0.025D, + y + clones[i].y + MathHelper.cos(i + rotation * 0.75F) * 0.0125D, + z + clones[i].z + MathHelper.cos(i + rotation * 0.7F) * 0.025D, + yaw, ticks); + } + } else { + super.doRender(entity, x, y, z, yaw, ticks); + } + } + + @Override + protected boolean isVisible(EntityIllusionIllager entity) { + return true; + } + } +} diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java deleted file mode 100644 index c8c27f77..00000000 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyIllusionIllager.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.minelittlepony.render.ponies; - -import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.ponies.ModelIllagerPony; -import com.minelittlepony.render.RenderPonyMob; -import com.minelittlepony.render.layer.LayerHeldPonyItem; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -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 manager) { - super(manager, PMAPI.illager); - } - - @Override - protected void addLayers() { - addLayer(new LayerHeldPonyItem(this) { - @Override - public void doPonyRender(EntityIllusionIllager entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - if (entity.isSpellcasting() || entity.isAggressive()) { - super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); - } - } - - @Override - protected void postRenderArm(EnumHandSide side) { - ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); - } - }); - } - - @Override - protected ResourceLocation getTexture(EntityIllusionIllager entity) { - return TEXTURE; - } - - @Override - protected void preRenderCallback(EntityIllusionIllager entity, float ticks) { - super.preRenderCallback(entity, ticks); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - } - - @Override - public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float ticks) { - if (entity.isInvisible()) { - Vec3d[] vects = entity.getRenderLocations(ticks); - float f = handleRotationFloat(entity, ticks); - - for (int i = 0; i < vects.length; ++i) { - super.doRender(entity, - x + vects[i].x + MathHelper.cos(i + f * 0.5F) * 0.025D, - y + vects[i].y + MathHelper.cos(i + f * 0.75F) * 0.0125D, - z + vects[i].z + MathHelper.cos(i + f * 0.7F) * 0.025D, - yaw, ticks); - } - } else { - super.doRender(entity, x, y, z, yaw, ticks); - } - } - - @Override - protected boolean isVisible(EntityIllusionIllager entity) { - return true; - } -} diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java deleted file mode 100644 index 125f8add..00000000 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVindicator.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.minelittlepony.render.ponies; - -import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.ponies.ModelIllagerPony; -import com.minelittlepony.render.RenderPonyMob; -import com.minelittlepony.render.layer.LayerHeldPonyItem; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityVindicator; -import net.minecraft.util.EnumHandSide; -import net.minecraft.util.ResourceLocation; - -public class RenderPonyVindicator extends RenderPonyMob { - - private static final ResourceLocation VINDICATOR = new ResourceLocation("minelittlepony", "textures/entity/illager/vindicator_pony.png"); - - public RenderPonyVindicator(RenderManager manager) { - super(manager, PMAPI.illager); - - } - - @Override - protected void addLayers() { - this.addLayer(new LayerHeldPonyItem(this) { - @Override - public void doPonyRender(EntityVindicator entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - if (entity.isAggressive()) { - super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); - } - } - - @Override - protected void postRenderArm(EnumHandSide side) { - ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); - } - }); - } - - @Override - protected ResourceLocation getTexture(EntityVindicator entity) { - return VINDICATOR; - } - - @Override - protected void preRenderCallback(EntityVindicator entity, float ticks) { - super.preRenderCallback(entity, ticks); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - } - -} From 8118cff5b6b2ffb4b6c83f5a6b14ea44f027a60f Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 19:10:22 +0200 Subject: [PATCH 43/96] Now that I know where this delegates, let's be consistent. --- .../com/minelittlepony/render/ponies/RenderPonyZombie.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java index 9645c06d..333a6ead 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java @@ -32,8 +32,8 @@ public class RenderPonyZombie extends RenderPonyMob @Override protected void preRenderCallback(EntityHusk entity, float ticks) { - GlStateManager.scale(1.0625F, 1.0625F, 1.0625F); super.preRenderCallback(entity, ticks); + GlStateManager.scale(1.0625F, 1.0625F, 1.0625F); } @Override @@ -51,8 +51,8 @@ public class RenderPonyZombie extends RenderPonyMob @Override protected void preRenderCallback(EntityGiantZombie entity, float ticks) { - GlStateManager.scale(3, 3, 3); super.preRenderCallback(entity, ticks); + GlStateManager.scale(3, 3, 3); } @Override From b410b988a293cbdf130ce0c1207c00f2da6fdab5 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 19:12:45 +0200 Subject: [PATCH 44/96] Try not to break horribly when encountering an unexpected profession (can't assume new ones won't be added later on / by mods). --- .../com/minelittlepony/render/ponies/RenderPonyVillager.java | 2 +- .../minelittlepony/render/ponies/RenderPonyZombieVillager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java index 85b781f4..cdd6b242 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java @@ -31,6 +31,6 @@ public class RenderPonyVillager extends RenderPonyMob { @Override protected ResourceLocation getTexture(EntityVillager entity) { - return PROFESSIONS[entity.getProfession()]; + return PROFESSIONS[entity.getProfession() % PROFESSIONS.length]; } } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java index 41aee572..bfa4273c 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java @@ -24,7 +24,7 @@ public class RenderPonyZombieVillager extends RenderPonyMob Date: Fri, 27 Apr 2018 20:37:54 +0200 Subject: [PATCH 45/96] Some more tidying up --- .../model/AbstractPonyModel.java | 5 +++ .../model/ponies/ModelIllagerPony.java | 2 +- .../model/ponies/ModelPlayerPony.java | 24 ++++++----- .../render/layer/AbstractPonyLayer.java | 15 +++++++ .../layer/LayerEntityOnPonyShoulder.java | 10 ++--- .../render/layer/LayerHeldItemIllager.java | 2 +- .../render/layer/LayerHeldPonyItem.java | 4 +- .../layer/LayerHeldPonyItemMagical.java | 37 ++++++---------- .../render/layer/LayerPonyElytra.java | 43 +++++++++++-------- 9 files changed, 79 insertions(+), 63 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 2cbc1d19..fddb2c83 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -10,6 +10,7 @@ import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; import java.util.Random; @@ -80,6 +81,10 @@ public abstract class AbstractPonyModel extends ModelPlayer { } } + public ArmPose getArmPoseForSide(EnumHandSide side) { + return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; + } + /** * Returns true if the default minecraft handling should be used. */ diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index b70608d3..9d1a5fa9 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -71,6 +71,6 @@ public class ModelIllagerPony extends ModelPlayerPony { } public ModelRenderer getArm(EnumHandSide side) { - return metadata.hasMagic() ? side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight : getArmForSide(side); + return metadata.hasMagic() ? getUnicornArmForSide(side) : getArmForSide(side); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 806f5497..435a5cc8 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -321,13 +321,11 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void swingItem(Entity entity, float swingProgress) { if (swingProgress > -9990.0F && !isSleeping) { EnumHandSide mainSide = getMainHand(entity); - boolean mainRight = mainSide == EnumHandSide.RIGHT; - ArmPose mainPose = mainRight ? rightArmPose : leftArmPose; - if (mainPose == ArmPose.EMPTY) return; + if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; if (metadata.hasMagic()) { - swingArm(mainRight ? unicornArmRight : unicornArmLeft); + swingArm(getUnicornArmForSide(mainSide)); } else { swingArm(getArmForSide(mainSide)); } @@ -348,10 +346,12 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void swingArms(float tick) { + if (isSleeping) return; + float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float sin = MathHelper.sin(tick * 0.067F) * 0.05F; - if (rightArmPose != ArmPose.EMPTY && !isSleeping) { + if (rightArmPose != ArmPose.EMPTY) { if (metadata.hasMagic()) { unicornArmRight.rotateAngleZ += cos; @@ -361,7 +361,8 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightArm.rotateAngleX += sin; } } - if (leftArmPose != ArmPose.EMPTY && !isSleeping) { + + if (leftArmPose != ArmPose.EMPTY) { if (metadata.hasMagic()) { unicornArmLeft.rotateAngleZ += cos; unicornArmLeft.rotateAngleX += sin; @@ -391,6 +392,10 @@ public class ModelPlayerPony extends AbstractPonyModel { neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); } + public PonyRenderer getUnicornArmForSide(EnumHandSide side) { + return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; + } + /** * Aligns legs to a sneaky position. */ @@ -659,11 +664,8 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } - unicornArmLeft .addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); - unicornArmRight.addBox(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f); - - unicornArmLeft .setRotationPoint(5, yOffset + 2, 0); - unicornArmRight.setRotationPoint(-5, yOffset + 2, 0); + unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0); + unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index a13a80bc..43621a1c 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -1,5 +1,7 @@ package com.minelittlepony.render.layer; +import com.minelittlepony.ducks.IRenderPony; +import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.ponies.ModelHumanPlayer; import net.minecraft.client.model.ModelBase; @@ -36,6 +38,19 @@ public abstract class AbstractPonyLayer implements L return renderer; } + public AbstractPonyModel getPlayerModel() { + return ((IRenderPony) getRenderer()).getPlayerModel().getModel(); + } + + public AbstractPonyModel getPonyModel() { + return getMainModel(); + } + + @SuppressWarnings("unchecked") + public M getMainModel() { + return (M)getRenderer().getMainModel(); + } + @Override public boolean shouldCombineTextures() { return false; diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index 27535f4b..c603cf83 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -2,7 +2,6 @@ package com.minelittlepony.render.layer; import com.minelittlepony.ForgeProxy; import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.ponies.ModelPlayerPony; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; @@ -54,7 +53,6 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer render = renderManager.getEntityRenderObject(entity); if (render != null) { render.doRender(entity, 0, 0, 0, 0, 0); - GlStateManager.popMatrix(); } + + GlStateManager.popMatrix(); return entity; } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java index e389b90e..deb5a933 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java @@ -22,7 +22,7 @@ public class LayerHeldItemIllager extends LayerHeldPo @Override protected void renderArm(EnumHandSide side) { - ((ModelIllagerPony) getRenderer().getMainModel()).getArm(side).postRender(0.0625F); + ((ModelIllagerPony)getPonyModel()).getArm(side).postRender(0.0625F); } public boolean shouldRender(T entity) { diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index a1ebb217..428b5fed 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -22,7 +22,7 @@ public class LayerHeldPonyItem extends AbstractPonyL @Override public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - ModelBase model = getRenderer().getMainModel(); + boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; ItemStack itemMain = entity.getHeldItemMainhand(); @@ -32,6 +32,8 @@ public class LayerHeldPonyItem extends AbstractPonyL ItemStack right = mainRight ? itemMain : itemOff; if (!left.isEmpty() || !right.isEmpty()) { + ModelBase model = getRenderer().getMainModel(); + pushMatrix(); if (model instanceof AbstractPonyModel) { ((AbstractPonyModel) model).transform(BodyPart.LEGS); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index 94be2ca8..1c039ff2 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -7,26 +7,19 @@ import static net.minecraft.client.renderer.GlStateManager.pushMatrix; import static net.minecraft.client.renderer.GlStateManager.scale; import static net.minecraft.client.renderer.GlStateManager.translate; -import javax.annotation.Nullable; - import org.lwjgl.opengl.GL14; import com.minelittlepony.ducks.IRenderItem; -import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.ponies.ModelPlayerPony; -import com.minelittlepony.pony.data.IPonyData; - import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHandSide; public class LayerHeldPonyItemMagical extends LayerHeldPonyItem { @@ -36,7 +29,7 @@ public class LayerHeldPonyItemMagical extends LayerH } private boolean isUnicorn() { - ModelBase model = getRenderer().getMainModel(); + ModelBase model = getMainModel(); return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); } @@ -50,8 +43,7 @@ public class LayerHeldPonyItemMagical extends LayerH protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (isUnicorn()) { - IPonyData metadata = ((AbstractPonyModel) getRenderer().getMainModel()).metadata; - renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); + renderItemGlow(entity, drop, transform, hand, getPonyModel().metadata.getGlowColor()); } } @@ -59,11 +51,8 @@ public class LayerHeldPonyItemMagical extends LayerH * Renders the main arm */ protected void renderArm(EnumHandSide side) { - AbstractPonyModel thePony = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); - if (thePony.metadata.hasMagic()) { - ModelPlayerPony playerModel = (ModelPlayerPony) thePony; - ModelRenderer unicornarm = side == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; - unicornarm.postRender(0.0625F); + if (isUnicorn()) { + this.getMainModel().getUnicornArmForSide(side).postRender(0.0625F); } else { super.renderArm(side); } @@ -72,10 +61,8 @@ public class LayerHeldPonyItemMagical extends LayerH public void renderItemGlow(T entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) { // enchantments mess up the rendering - ItemStack drop2 = drop.copy(); - if (drop2.hasEffect()) { - removeEnch(drop2.getTagCompound()); - } + drop = stackWithoutEnchantment(drop); + float red = (glowColor >> 16 & 255) / 255.0F; float green = (glowColor >> 8 & 255) / 255.0F; float blue = (glowColor & 255) / 255.0F; @@ -91,9 +78,9 @@ public class LayerHeldPonyItemMagical extends LayerH scale(1.1, 1.1, 1.1); - translate(0, .01, .01); + translate(0, 0.01F, 0.01F); renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); - translate(.01, -.01, -.02); + translate(0.01F, -0.01F, -0.02F); renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); ((IRenderItem) renderItem).useTransparency(false); @@ -103,9 +90,11 @@ public class LayerHeldPonyItemMagical extends LayerH // I hate rendering } - private void removeEnch(@Nullable NBTTagCompound tag) { - if (tag != null) { - tag.removeTag("ench"); + private ItemStack stackWithoutEnchantment(ItemStack original) { + ItemStack copy = original.copy(); + if (copy.isItemEnchanted()) { + copy.getTagCompound().removeTag("ench"); } + return copy; } } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index 7fdefb4d..a26f3dc3 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -1,7 +1,5 @@ package com.minelittlepony.render.layer; -import com.minelittlepony.ducks.IRenderPony; -import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.components.PonyElytra; @@ -30,31 +28,16 @@ public class LayerPonyElytra extends AbstractPonyLay @Override public void doPonyRender(@Nonnull T entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) { - - AbstractPonyModel model = ((IRenderPony) getRenderer()).getPlayerModel().getModel(); - ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { GlStateManager.color(1, 1, 1, 1); - if (entity instanceof AbstractClientPlayer) { - - AbstractClientPlayer player = (AbstractClientPlayer) entity; - if (player.isPlayerInfoSet() && player.getLocationElytra() != null) { - getRenderer().bindTexture(player.getLocationElytra()); - } else if (player.hasPlayerInfo() && player.getLocationCape() != null && player.isWearing(EnumPlayerModelParts.CAPE)) { - getRenderer().bindTexture(player.getLocationCape()); - } else { - getRenderer().bindTexture(TEXTURE_ELYTRA); - } - } else { - getRenderer().bindTexture(TEXTURE_ELYTRA); - } + getRenderer().bindTexture(getElytraTexture(entity)); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0.25F, 0.125F); - model.transform(BodyPart.BODY); + getPlayerModel().transform(BodyPart.BODY); modelElytra.setRotationAngles(move, swing, age, yaw, head, scale, entity); modelElytra.render(entity, move, swing, age, yaw, head, scale); @@ -66,6 +49,28 @@ public class LayerPonyElytra extends AbstractPonyLay } } + protected ResourceLocation getElytraTexture(T entity) { + if (entity instanceof AbstractClientPlayer) { + AbstractClientPlayer player = (AbstractClientPlayer) entity; + + ResourceLocation result; + + if (player.isPlayerInfoSet()) { + result = player.getLocationElytra(); + + if (result != null) return result; + } + + if (player.hasPlayerInfo() && player.isWearing(EnumPlayerModelParts.CAPE)) { + result = player.getLocationCape(); + + if (result != null) return result; + } + } + + return TEXTURE_ELYTRA; + } + @Override public boolean shouldCombineTextures() { return false; From 2e090498db27cb7f222eb096b2cf15ee156117e9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 21:48:55 +0200 Subject: [PATCH 46/96] Rewrite breezies (and ensure it has a head) --- .../model/ponies/ModelBreezie.java | 254 ++++++++---------- .../render/AbstractPonyRenderer.java | 24 +- 2 files changed, 137 insertions(+), 141 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java index f6b00af4..af2b50ff 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java @@ -6,72 +6,62 @@ import net.minecraft.entity.Entity; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; +import static com.minelittlepony.model.PonyModelConstants.PI; + +import com.minelittlepony.render.PonyRenderer; + public class ModelBreezie extends ModelBiped { - ModelRenderer neck; - ModelRenderer tail; - ModelRenderer tailStub; + PonyRenderer neck; + PonyRenderer tail; + PonyRenderer tailStub; - ModelRenderer leftWing; - ModelRenderer rightWing; + PonyRenderer leftWing; + PonyRenderer rightWing; public ModelBreezie() { textureWidth = 64; textureHeight = 64; bipedHeadwear.showModel = false; + bipedHead = new PonyRenderer(this) + .child(new PonyRenderer(this) + .addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4) + .tex(28, 0).addBox( 2, -7, 1, 1, 1, 1) + .tex(24, 0).addBox(-3, -7, 1, 1, 1, 1) + .tex(24, 9).addBox(-1, -2, -4, 2, 2, 1)) + .child(new PonyRenderer(this) + .tex(28, 2).addBox( 1, -11, -2, 1, 6, 1) + .tex(24, 2).addBox(-2, -11, -2, 1, 6, 1) + .rotate(-0.2617994F, 0, 0)); - bipedHead = new ModelRenderer(this, 0, 0); - bipedHead.setRotationPoint(0, 0, -4); - bipedHead.addBox(-3, -6, -3F, 6, 6, 6); - bipedHead.setTextureOffset(28, 0).addBox(2F, -7F, 1F, 1, 1, 1); - bipedHead.setTextureOffset(24, 0).addBox(-3F, -7F, 1F, 1, 1, 1); - bipedHead.setTextureOffset(24, 9).addBox(-1F, -2F, -4F, 2, 2, 1); + bipedBody = new PonyRenderer(this, 2, 12) + .addBox(0, 0, 0, 6, 7, 14).rotate(-0.5235988F, 0, 0).around(-3, 1, -3); - ModelRenderer antenna = new ModelRenderer(this); - antenna.setTextureOffset(28, 2).addBox(1F, -11F, -2F, 1, 6, 1); - antenna.setTextureOffset(24, 2).addBox(-2F, -11F, -2F, 1, 6, 1); - setRotation(antenna, -0.2617994F, 0, 0); + bipedLeftArm = new PonyRenderer(this, 28, 12).addBox(0, 0, 0, 2, 12, 2).around( 1, 8, -5); + bipedRightArm = new PonyRenderer(this, 36, 12).addBox(0, 0, 0, 2, 12, 2).around(-3, 8, -5); + bipedLeftLeg = new PonyRenderer(this, 8, 12) .addBox(0, 0, 0, 2, 12, 2).around( 1, 12, 3); + bipedRightLeg = new PonyRenderer(this, 0, 12) .addBox(0, 0, 0, 2, 12, 2).around(-3, 12, 3); - bipedHead.addChild(antenna); + neck = new PonyRenderer(this, 40, 0) + .addBox(0, 0, 0, 2, 5, 2) + .rotate(0.0872665F, 0, 0).around(-1, -2, -4); - bipedBody = new ModelRenderer(this, 2, 12); - bipedBody.addBox(0, 0, 0, 6, 7, 14).setRotationPoint(-3, 1, -3); - setRotation(bipedBody, -0.5235988F, 0, 0); + tailStub = new PonyRenderer(this, 40, 7) + .addBox(0, 0, 0, 1, 1, 3).around(-0.5F, 8, 8); - bipedRightArm = new ModelRenderer(this, 36, 12); - bipedRightArm.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(-3, 8, -5); + tail = new PonyRenderer(this, 32, 0) + .addBox(0, 0, 1, 2, 9, 2).around(-1, 7, 10); - bipedLeftArm = new ModelRenderer(this, 28, 12); - bipedLeftArm.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(1, 8, -5); - - bipedLeftLeg = new ModelRenderer(this, 8, 12); - bipedLeftLeg.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(1, 12, 3); - - bipedRightLeg = new ModelRenderer(this, 0, 12); - bipedRightLeg.addBox(0, 0, 0, 2, 12, 2).setRotationPoint(-3, 12, 3); - - neck = new ModelRenderer(this, 40, 0); - neck.addBox(0, 0, 0, 2, 5, 2).setRotationPoint(-1, -2, -4); - setRotation(neck, 0.0872665F, 0, 0); - - tailStub = new ModelRenderer(this, 40, 7); - tailStub.addBox(0, 0, 0, 1, 1, 3).setRotationPoint(-0.5F, 8, 8); - - tail = new ModelRenderer(this, 32, 0); - tail.addBox(0, 0, 1, 2, 9, 2).setRotationPoint(-1, 7, 10); - - leftWing = new ModelRenderer(this, 0, 40); - leftWing.addBox(0, -12, 0, 24, 24, 0); - leftWing.setRotationPoint(2, 3, 1); + leftWing = new PonyRenderer(this, 0, 40) + .addBox(0, -12, 0, 24, 24, 0) + .rotate(0, -0.6981317F, 0).around(2, 3, 1); leftWing.setTextureSize(64, 32); - setRotation(leftWing, 0, -0.6981317F, 0); - rightWing = new ModelRenderer(this, 0, 40); - rightWing.addBox(-24, -12, 0, 24, 24, 0, true); - rightWing.setRotationPoint(-2, 3, 1); + rightWing = new PonyRenderer(this, 0, 40) + .addBox(-24, -12, 0, 24, 24, 0, true) + .rotate(0, 0.6981317F, 0).around(-2, 3, 1); rightWing.setTextureSize(64, 32); - setRotation(rightWing, 0, 0.6981317F, 0); } @@ -85,12 +75,6 @@ public class ModelBreezie extends ModelBiped { rightWing.render(scale); } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - @SuppressWarnings("incomplete-switch") @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { @@ -98,103 +82,99 @@ public class ModelBreezie extends ModelBiped { bipedHead.rotateAngleY = headYaw * 0.017453292F; bipedHead.rotateAngleX = headPitch * 0.017453292F; - bipedRightArm.rotateAngleX = MathHelper.cos(move * 0.6662F + (float) Math.PI) * 2.0F * swing * 0.5F; - bipedLeftArm.rotateAngleX = MathHelper.cos(move * 0.6662F) * 2.0F * swing * 0.5F; - bipedRightArm.rotateAngleZ = 0; + bipedLeftArm.rotateAngleX = MathHelper.cos(move * 0.6662F) * swing; bipedLeftArm.rotateAngleZ = 0; - bipedRightLeg.rotateAngleX = MathHelper.cos(move * 0.6662F) * 1.4F * swing; - bipedLeftLeg.rotateAngleX = MathHelper.cos(move * 0.6662F + (float) Math.PI) * 1.4F * swing; - bipedRightLeg.rotateAngleY = 0; - bipedLeftLeg.rotateAngleY = 0; - bipedRightLeg.rotateAngleZ = 0; - bipedLeftLeg.rotateAngleZ = 0; + + ((PonyRenderer)bipedRightArm).rotate(swing * MathHelper.cos(move * 0.6662F + PI), 0, 0); + ((PonyRenderer)bipedLeftLeg) .rotate(swing * MathHelper.cos(move * 0.6662F + PI) * 1.4F, 0, 0); + ((PonyRenderer)bipedRightLeg).rotate(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0); if (isRiding) { - bipedRightArm.rotateAngleX += -((float) Math.PI / 5F); - bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F); - bipedRightLeg.rotateAngleX = -1.4137167F; - bipedRightLeg.rotateAngleY = ((float) Math.PI / 10F); - bipedRightLeg.rotateAngleZ = 0.07853982F; - bipedLeftLeg.rotateAngleX = -1.4137167F; - bipedLeftLeg.rotateAngleY = -((float) Math.PI / 10F); - bipedLeftLeg.rotateAngleZ = -0.07853982F; + bipedLeftArm.rotateAngleX += -PI / 5; + bipedRightArm.rotateAngleX += -PI / 5; + + rotateLegRiding(((PonyRenderer)bipedLeftLeg), -1); + rotateLegRiding(((PonyRenderer)bipedRightLeg), 1); } - bipedRightArm.rotateAngleY = 0; - bipedRightArm.rotateAngleZ = 0F; + rotateArm(bipedLeftArm, leftArmPose, 1); + rotateArm(bipedRightArm, rightArmPose, 1); - switch (leftArmPose) { - case EMPTY: - bipedLeftArm.rotateAngleY = 0; - break; - case BLOCK: - bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; - bipedLeftArm.rotateAngleY = 0.5235988F; - break; - case ITEM: - bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - bipedLeftArm.rotateAngleY = 0; + if (swingProgress > 0) { + swingArms(getMainHand(entity)); } - switch (rightArmPose) { - case EMPTY: - bipedRightArm.rotateAngleY = 0; - break; - case BLOCK: - bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; - bipedRightArm.rotateAngleY = -0.5235988F; - break; - case ITEM: - bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - bipedRightArm.rotateAngleY = 0; - } + float rotX = MathHelper.sin(age * 0.067F) * 0.05F; + float rotZ = MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; - if (swingProgress > 0.0F) { - EnumHandSide enumhandside = getMainHand(entity); - ModelRenderer modelrenderer = getArmForSide(enumhandside); - float f1 = swingProgress; - bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float) Math.PI * 2F)) * 0.2F; + bipedLeftArm.rotateAngleX -= rotX; + bipedLeftArm.rotateAngleZ -= rotZ; - if (enumhandside == EnumHandSide.LEFT) { - bipedBody.rotateAngleY *= -1.0F; - } - - bipedRightArm.rotationPointZ = MathHelper.sin(bipedBody.rotateAngleY) * 5; - bipedRightArm.rotationPointX = -MathHelper.cos(bipedBody.rotateAngleY) * 5; - bipedLeftArm.rotationPointZ = -MathHelper.sin(bipedBody.rotateAngleY) * 5; - bipedLeftArm.rotationPointX = MathHelper.cos(bipedBody.rotateAngleY) * 5; - bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; - bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; - //noinspection SuspiciousNameCombination - bipedLeftArm.rotateAngleX += bipedBody.rotateAngleY; - f1 = 1.0F - swingProgress; - f1 = f1 * f1; - f1 = f1 * f1; - f1 = 1.0F - f1; - float f2 = MathHelper.sin(f1 * (float) Math.PI); - float f3 = MathHelper.sin(swingProgress * (float) Math.PI) * -(bipedHead.rotateAngleX - 0.7F) * 0.75F; - modelrenderer.rotateAngleX = (float) (modelrenderer.rotateAngleX - (f2 * 1.2D + f3)); - modelrenderer.rotateAngleY += bipedBody.rotateAngleY * 2.0F; - modelrenderer.rotateAngleZ += MathHelper.sin(swingProgress * (float) Math.PI) * -0.4F; - } - - bipedRightArm.rotateAngleZ += MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; - bipedLeftArm.rotateAngleZ -= MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; - bipedRightArm.rotateAngleX += MathHelper.sin(age * 0.067F) * 0.05F; - bipedLeftArm.rotateAngleX -= MathHelper.sin(age * 0.067F) * 0.05F; + bipedRightArm.rotateAngleX += rotX; + bipedRightArm.rotateAngleZ += rotZ; if (rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { - bipedRightArm.rotateAngleY = -0.1F + bipedHead.rotateAngleY; - bipedLeftArm.rotateAngleY = 0.1F + bipedHead.rotateAngleY + 0.4F; - bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; - bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; + raiseArm(bipedRightArm, bipedLeftArm, -1); } else if (leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { - bipedRightArm.rotateAngleY = -0.1F + bipedHead.rotateAngleY - 0.4F; - bipedLeftArm.rotateAngleY = 0.1F + bipedHead.rotateAngleY; - bipedRightArm.rotateAngleX = -((float) Math.PI / 2) + bipedHead.rotateAngleX; - bipedLeftArm.rotateAngleX = -((float) Math.PI / 2) + bipedHead.rotateAngleX; + raiseArm(bipedLeftArm, bipedRightArm, 1); } - } + protected void rotateLegRiding(PonyRenderer leg, float factor) { + leg.rotate(-1.4137167F, factor * PI / 10, factor * 0.07853982F); + } + + protected void swingArms(EnumHandSide mainHand) { + bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) / 5; + + if (mainHand == EnumHandSide.LEFT) { + bipedBody.rotateAngleY *= -1; + } + + float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; + float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; + + bipedLeftArm.rotateAngleX += bipedBody.rotateAngleY; + bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; + bipedLeftArm.rotationPointX = cos; + bipedLeftArm.rotationPointZ = -sin; + + bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; + bipedRightArm.rotationPointX = -cos; + bipedRightArm.rotationPointZ = sin; + + float swingAmount = 1 - (float)Math.pow(1 - swingProgress, 4); + + float swingFactorX = MathHelper.sin(swingAmount * PI); + float swingX = MathHelper.sin(swingProgress * PI) * (0.7F - bipedHead.rotateAngleX) * 0.75F; + + ModelRenderer mainArm = getArmForSide(mainHand); + mainArm.rotateAngleX -= swingFactorX * 1.2F + swingX; + mainArm.rotateAngleY += bipedBody.rotateAngleY * 2; + mainArm.rotateAngleZ -= MathHelper.sin(swingProgress * PI) * 0.4F; + } + + protected void rotateArm(ModelRenderer arm, ArmPose pose, float factor) { + switch (pose) { + case EMPTY: + arm.rotateAngleY = 0; + break; + case ITEM: + arm.rotateAngleX = arm.rotateAngleX / 2 - (PI / 10); + arm.rotateAngleY = 0; + case BLOCK: + arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; + arm.rotateAngleY = factor * 0.5235988F; + break; + default: + } + } + + protected void raiseArm(ModelRenderer up, ModelRenderer down, float factor) { + up.rotateAngleY = bipedHead.rotateAngleY + (factor / 10); + up.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); + + down.rotateAngleY = bipedHead.rotateAngleY - (factor / 2); + down.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); + } } diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index 90547617..ea9796cf 100644 --- a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -80,6 +80,16 @@ public abstract class AbstractPonyRenderer> ex return (T) this; } + /** + * Sets this renderer's rotation angles. + */ + public T rotate(float x, float y, float z) { + rotateAngleX = x; + rotateAngleY = y; + rotateAngleZ = z; + return (T) this; + } + public static T at(T renderer, float x, float y, float z) { renderer.offsetX = x / 16; renderer.offsetY = y / 16; @@ -88,9 +98,7 @@ public abstract class AbstractPonyRenderer> ex } public void rotateTo(ModelRenderer other) { - rotateAngleX = other.rotateAngleX; - rotateAngleY = other.rotateAngleY; - rotateAngleZ = other.rotateAngleZ; + rotate(other.rotateAngleX, other.rotateAngleY, other.rotateAngleZ); } public T rotateAt(ModelRenderer other) { @@ -111,11 +119,19 @@ public abstract class AbstractPonyRenderer> ex */ public T child(int index) { if (childModels == null || index >= childModels.size()) { - addChild(copySelf().offset(modelOffsetX, modelOffsetY, modelOffsetZ)); + child(copySelf().offset(modelOffsetX, modelOffsetY, modelOffsetZ)); } return (T)childModels.get(index); } + /** + * Adds a new child renderer and returns itself for chaining. + */ + public T child(K child) { + addChild(child); + return (T)this; + } + @Override public T addBox(String partName, float offX, float offY, float offZ, int width, int height, int depth) { partName = boxName + "." + partName; From 3a4e1fc32a7e922f0129ba896b7bf3e71a6218e9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 21:49:27 +0200 Subject: [PATCH 47/96] Fix mirroring issues on villager's saddlebags, add depth to the bag's strap --- .../model/ponies/ModelVillagerPony.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 237f5384..0353c930 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -43,7 +43,6 @@ public class ModelVillagerPony extends ModelPlayerPony { apron.render(scale); } } - } @Override @@ -60,20 +59,22 @@ public class ModelVillagerPony extends ModelPlayerPony { bag.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) - .tex(56, 25).addBackPlane(-7, -5, -4, 3, 6, stretch) //right bag front - .addBackPlane( 4, -5, -4, 3, 6, stretch) //left bag front - .tex(59, 25).addBackPlane(-7, -5, 4, 3, 6, stretch) //right bag back - .addBackPlane( 5, -5, 4, 3, 6, stretch) //left bag back - .tex(56, 29).addWestPlane(-7, -5, -4, 6, 8, stretch) //right bag outside - .addWestPlane( 7, -5, -4, 6, 8, stretch) //left bag outside - .addWestPlane(-4, -5, -4, 6, 8, stretch) //right bag inside - .addWestPlane( 4, -5, -4, 6, 8, stretch) //left bag inside - .tex(56, 31).addTopPlane(-4, -4.5F, -1, 8, 1, stretch) //strap front - .addTopPlane(-4, -4.5F, 0, 8, 1, stretch) //strap back - .child(0).tex(56, 16).addTopPlane(2, -5, -2, 8, 3, stretch) //right bag top - .addTopPlane(2, -5, -13, 8, 3, stretch) //left bag top - .tex(56, 22).addBottomPlane(2, 1, -2, 8, 3, stretch) //right bag bottom - .addBottomPlane(2, 1, -13, 8, 3, stretch) //left bag bottom + .tex(56, 25).addBackPlane(-7, -5, -4, 3, 6, stretch) //right bag front + .addBackPlane( 4, -5, -4, 3, 6, stretch) //left bag front + .tex(59, 25).addBackPlane(-7, -5, 4, 3, 6, stretch) //right bag back + .addBackPlane( 4, -5, 4, 3, 6, stretch) //left bag back + .tex(56, 29).addWestPlane(-7, -5, -4, 6, 8, stretch) //right bag outside + .addWestPlane( 7, -5, -4, 6, 8, stretch) //left bag outside + .addWestPlane(-4.01f, -5, -4, 6, 8, stretch) //right bag inside + .addWestPlane( 4.01f, -5, -4, 6, 8, stretch) //left bag inside + .tex(56, 31) .addTopPlane(-4, -4.5F, -1, 8, 1, stretch) //strap front + .addTopPlane(-4, -4.5F, 0, 8, 1, stretch) //strap back + .addBackPlane(-4, -4.5F, 0, 8, 1, stretch) + .addFrontPlane(-4, -4.5F, 0, 8, 1, stretch) + .child(0).tex(56, 16).flipZ().addTopPlane(2, -5, -13, 8, 3, stretch) //left bag top + .flipZ().addTopPlane(2, -5, -2, 8, 3, stretch) //right bag top + .tex(56, 22).flipZ().addBottomPlane(2, 1, -13, 8, 3, stretch) //left bag bottom + .flipZ().addBottomPlane(2, 1, -2, 8, 3, stretch) //right bag bottom .rotateAngleY = 4.712389F; apron.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) From 52ed49defd187089b59fa716dbef9029d912518e Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 23:22:37 +0200 Subject: [PATCH 48/96] Mobs now flap their wings when falling/flying --- .../com/minelittlepony/model/components/PegasusWings.java | 2 +- .../java/com/minelittlepony/model/components/PonyTail.java | 2 +- src/main/java/com/minelittlepony/render/RenderPonyMob.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index 7f2ea4bf..e492137e 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -62,7 +62,7 @@ public class PegasusWings extends ModelBase { } public boolean isExtended() { - return pony.isFlying || pony.isSneak; + return pony.isFlying || pony.isCrouching(); } @Override diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index e9f92540..7ecf0383 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -30,7 +30,7 @@ public class PonyTail extends PlaneRenderer { rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; rotateAngleY = bodySwing; - if (theModel.isSneak && !theModel.isFlying && !rainboom) { + if (theModel.isCrouching() && !rainboom) { rotateSneak(); } else if (theModel.isRiding) { rotationPointZ = 13; diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 33870add..5dd8c40d 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -46,8 +46,8 @@ public abstract class RenderPonyMob extends RenderLiving @Override @OverridingMethodsMustInvokeSuper protected void preRenderCallback(T entity, float ticks) { - playerModel.getModel().isSneak = false; - playerModel.getModel().isFlying = false; + playerModel.getModel().isSneak = entity.isSneaking(); + playerModel.getModel().isFlying = !entity.onGround; playerModel.getModel().isSleeping = false; ResourceLocation loc = getEntityTexture(entity); From 2dfe6471652c82bb16374722725af8e738a4e2b5 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Apr 2018 23:23:47 +0200 Subject: [PATCH 49/96] All four legs are now thin, update the ALEX skin to have thin legs --- .../model/ponies/ModelPlayerPony.java | 51 ++++++++++-------- .../textures/entity/alex_pony.png | Bin 823 -> 1286 bytes 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java index 435a5cc8..2f8a398f 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java @@ -242,7 +242,7 @@ public class ModelPlayerPony extends AbstractPonyModel { private float getLegOutset() { if (isSleeping) return 2.6f; - if (isSneak && !isFlying) return smallArms ? 1 : 0; + if (isCrouching()) return smallArms ? 1 : 0; return 4; } @@ -267,8 +267,8 @@ public class ModelPlayerPony extends AbstractPonyModel { // Push the front legs back apart if we're a thin pony if (smallArms) { - bipedLeftArm.rotationPointX--; - bipedLeftArm.rotationPointX += 2; + bipedLeftArm.rotationPointX++; + bipedLeftLeg.rotationPointX++; } bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; @@ -538,20 +538,20 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void initLegTextures() { - bipedRightArm = new ModelRenderer(this, 40, 16); - bipedRightLeg = new ModelRenderer(this, 0, 16); - bipedLeftArm = new ModelRenderer(this, 32, 48); - bipedLeftLeg = new ModelRenderer(this, 16, 48); - - bipedRightArmwear = new ModelRenderer(this, 40, 32); - bipedRightLegwear = new ModelRenderer(this, 0, 32); + bipedRightArm = new ModelRenderer(this, 40, 16); bipedLeftArmwear = new ModelRenderer(this, 48, 48); - bipedLeftLegwear = new ModelRenderer(this, 0, 48); + bipedRightArmwear = new ModelRenderer(this, 40, 32); + + bipedLeftLeg = new ModelRenderer(this, 16, 48); + bipedRightLeg = new ModelRenderer(this, 0, 16); + + bipedLeftLegwear = new ModelRenderer(this, 0, 48); + bipedRightLegwear = new ModelRenderer(this, 0, 32); - unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); + unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); boxList.remove(unicornArmRight); } @@ -623,8 +623,17 @@ public class ModelPlayerPony extends AbstractPonyModel { .rotateAngleX = NECK_ROT_X; } + protected int getArmWidth() { + return smallArms ? 3 : 4; + } + + protected int getArmDepth() { + return 4; + } + protected void initLegPositions(float yOffset, float stretch) { - int armWidth = smallArms ? 3 : 4; + int armWidth = getArmWidth(); + int armDepth = getArmDepth(); float rarmY = smallArms ? 8.5f : 8; float rarmX = smallArms ? 2 : 3; @@ -632,11 +641,11 @@ public class ModelPlayerPony extends AbstractPonyModel { float armY = THIRDP_ARM_CENTRE_Y - 6; float armZ = THIRDP_ARM_CENTRE_Z - 2; - bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch); - bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch); + bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch); - bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch); + bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + bipedRightLeg.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); @@ -645,22 +654,22 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); if (bipedLeftArmwear != null) { - bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f); + bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); } if (bipedRightArmwear != null) { - bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f); + bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); } if (bipedLeftLegwear != null) { - bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); + bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); bipedRightLegwear.setRotationPoint(3, yOffset, 0); } if (bipedRightLegwear != null) { - bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f); + bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } diff --git a/src/main/resources/assets/minelittlepony/textures/entity/alex_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/alex_pony.png index 9dece2ec9a42f20f69170fc04ae553b5812e9d90..ec8c870bfca26cd18f01fc1f35bd269a9f646292 100644 GIT binary patch delta 1267 zcmV%-7I&&_2Wk}}qZm0>f?6^Kl2V1z z!GyGF1*RBkL^`AdO48zVl0C@Il6Y{M+K|ObJ(yP1ByBJqJXEF`GIU6VEn6ZOR9YG8 zV0CG;<#n*{>E7w|{@puSh5Lb!-rc*q@85m*-F+wRw|jpWxqt7!!t%;Z4FJx3n>VHg zl1Pta&=*PI-P907@czXMn0QtM09*^-ZK^-gJ%{c33jjbY+|^Wn<@1~7@A1jc001+& zJ7!tw@q%VI{?+U)!>&H`{EY>Z`F5cD$lK=c+4^NyZ3g2}S7m;nzjJC*I`c&Hewe4h zvk)gdc=U_C0DovRxjlVdld1K+-8J9L%YshNk*nET#;+0vA&i^CsJD;74=%jrYymW; z29kjjFcEze{uH-9Kss;+iJ8V|hJnnv1YSLRNtjvs8vu_v)VH5#eUXG=R}a8o`)c(} z%5*0JhA4fu7C>)Sit8H&s?Y6AS?iOPrtadYz8+o&#&xnLwn~<=9|v|UL2|g20jJGM$;{q zF}DXG|4RXon4VZbHW$Ts?>xqP=aJ1t(SH|7Sl%I^4@_Cu)pg7iV2{%1xcrk(|2gmr z4gavXwA^F~d%J6voI$&oZ)pK`J2W@uPd;O#X>OU5ww;*wOP{R(X!A^^hRrxT$iaA^ zlO%h)YZm6|I$89EXzj5<%4%U#y5pJ}NTR1_uBp7IXU>wNkVT))N-&igHe>FcT7L

2!6?qbHwAu^{;-26S&j$Fd<)!r|p=LSVjkz|}gwN(I}4(S3A&ELzu zpCIf5*c&5mZjc?kL&o;ip3wgD!)*I%3Mc_60Vn||0Vn}mNV<4sYCz(002ovPDHLkV1hP`a;E?Q delta 801 zcmV++1K#|G3bzK3BYy(^Nklr9Zgy|~T)JOJ zzx$Va@A~eqZGHLLUwpsrZ{K^|KiJ;y-@N}+Bsv$JlXU!T_kV^iude&Uv!8?LvlRIN z;di{OGtBa@JOA-ZvI@~e?kOiv*U^W5G;TC-WvOoqudmkVR5O_@hq>asogYX@Y7ncEm z0F?rO(B@=$&VOT2D{BH^mEys)mO74D3IL=u#Iq31G4;4SSF{NkgM^W+@>&2WAeqWM zNb7ht0Hjwt_lF?KH~=y_R+<6wPHMrytah)Riwgio*RmWuc)JzM06JE?3B&+chAgO> z0bEa?zaCVx4~X5doWQ55%L!il+^Q2y%?7Q5)Xqg^Tz`|E0xdFtJ9+Ew&OhY>kabhl zSpkRAGBm9OZFwBjQ-Fl-psXMBugX9O7tm6&6#%Qvrux?mK_RO8rB}9n$Oo_*#J!9jgH#_O}>7Xi{=|wmVX25)%p@T0DTzf(ixw zkhKE<2ogZ316>;c2vBPV@-fO`@a1wTI`&^>fE<@=ixn~x|g4i3Bb+G&CSit&CSit z&CSit&8^g|ouk(E7YQKem6y``4#1nhifzi?Vd>r@|E&XX01m(bH~ Date: Sat, 28 Apr 2018 12:28:45 +0200 Subject: [PATCH 50/96] Killjoy reminded me you can use interfaces for this --- .../minelittlepony/ducks/IDownloadImageData.java | 10 ---------- .../mixin/MixinThreadDownloadImageData.java | 14 ++------------ .../java/com/minelittlepony/pony/data/Pony.java | 6 +++--- 3 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/ducks/IDownloadImageData.java diff --git a/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java b/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java deleted file mode 100644 index 15a0b914..00000000 --- a/src/main/java/com/minelittlepony/ducks/IDownloadImageData.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.minelittlepony.ducks; - -import java.awt.image.BufferedImage; - -public interface IDownloadImageData { - /** - * Gets the downloaded image data as a buffered image. - */ - BufferedImage getBufferedImage(); -} diff --git a/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java index 835fb3f6..6c4f0a60 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java +++ b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java @@ -5,20 +5,10 @@ import java.awt.image.BufferedImage; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import com.minelittlepony.ducks.IDownloadImageData; - import net.minecraft.client.renderer.ThreadDownloadImageData; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.util.ResourceLocation; @Mixin(ThreadDownloadImageData.class) -public abstract class MixinThreadDownloadImageData extends SimpleTexture implements IDownloadImageData { - - private MixinThreadDownloadImageData(ResourceLocation textureResourceLocation) { - super(textureResourceLocation); - } - - @Override +public interface MixinThreadDownloadImageData { @Accessor("bufferedImage") - public abstract BufferedImage getBufferedImage(); + BufferedImage getBufferedImage(); } diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index 638995f3..a7317438 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -2,7 +2,7 @@ package com.minelittlepony.pony.data; import com.google.common.base.MoreObjects; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.ducks.IDownloadImageData; +import com.minelittlepony.mixin.MixinThreadDownloadImageData; import com.minelittlepony.model.ModelWrapper; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.ThreadDownloadImageETag; @@ -78,8 +78,8 @@ public class Pony { try { ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(resource); - if (e2 instanceof IDownloadImageData) { - return ((IDownloadImageData) e2).getBufferedImage(); + if (e2 instanceof MixinThreadDownloadImageData) { + return ((MixinThreadDownloadImageData) e2).getBufferedImage(); } else if (e2 instanceof ThreadDownloadImageETag) { return ((ThreadDownloadImageETag) e2).getBufferedImage(); } else if (e2 instanceof DynamicTextureImage) { From 9dd0c0dfb8533abbff6df6de3041df7ace0e99bf Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 12:29:26 +0200 Subject: [PATCH 51/96] Copy the texture width/height with children --- .../com/minelittlepony/render/AbstractPonyRenderer.java | 9 ++++++--- .../java/com/minelittlepony/render/PonyRenderer.java | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index ea9796cf..b13caa00 100644 --- a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -22,8 +22,8 @@ public abstract class AbstractPonyRenderer> ex baseModel = model; } - public AbstractPonyRenderer(ModelBase model, int x, int y) { - super(model, x, y); + public AbstractPonyRenderer(ModelBase model, int texX, int texY) { + super(model, texX, texY); baseModel = model; } @@ -119,7 +119,10 @@ public abstract class AbstractPonyRenderer> ex */ public T child(int index) { if (childModels == null || index >= childModels.size()) { - child(copySelf().offset(modelOffsetX, modelOffsetY, modelOffsetZ)); + T copy = copySelf(); + child(copy.offset(modelOffsetX, modelOffsetY, modelOffsetZ)); + copy.textureHeight = textureHeight; + copy.textureWidth = textureWidth; } return (T)childModels.get(index); } diff --git a/src/main/java/com/minelittlepony/render/PonyRenderer.java b/src/main/java/com/minelittlepony/render/PonyRenderer.java index ce483fab..c2031230 100644 --- a/src/main/java/com/minelittlepony/render/PonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/PonyRenderer.java @@ -8,8 +8,8 @@ public class PonyRenderer extends AbstractPonyRenderer { super(model); } - public PonyRenderer(ModelBase model, int x, int y) { - super(model, x, y); + public PonyRenderer(ModelBase model, int texX, int texY) { + super(model, texX, texY); } @Override From 25a42908e98f416eb531a9943b2831d4b0855588 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 12:35:22 +0200 Subject: [PATCH 52/96] Apparantly this is correct? --- src/main/java/com/minelittlepony/pony/data/Pony.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index a7317438..b3ec6798 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -121,6 +121,9 @@ public class Pony { @Override public String toString() { - return MoreObjects.toStringHelper(this).add("texture", texture).add("metadata", metadata).toString(); + return MoreObjects.toStringHelper(this) + .add("texture", texture) + .add("metadata", metadata) + .toString(); } } From e5a453abd0591e54cef1d954933ff092402d8660 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 12:44:10 +0200 Subject: [PATCH 53/96] Reformatting missed some tabs --- .../java/com/minelittlepony/MissingRendererException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/MissingRendererException.java b/src/main/java/com/minelittlepony/MissingRendererException.java index c2fdba27..4ae09414 100644 --- a/src/main/java/com/minelittlepony/MissingRendererException.java +++ b/src/main/java/com/minelittlepony/MissingRendererException.java @@ -1,9 +1,9 @@ package com.minelittlepony; public class MissingRendererException extends RuntimeException { - private static final long serialVersionUID = -6059469512902628663L; + private static final long serialVersionUID = -6059469512902628663L; - public MissingRendererException(Class cl) { + public MissingRendererException(Class cl) { super("Could not find a renderer for " + cl.getName() + ". This is a bug."); } } From 6335e206d9c89afb4356107d114994070d882487 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 12:48:51 +0200 Subject: [PATCH 54/96] Sneaky buggers --- .../com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java | 2 +- .../java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java index eb3d1362..9bbb49b6 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java @@ -20,7 +20,7 @@ public class TexturesPayloadBuilder { private static Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); - private long timestamp; + private long timestamp; private UUID profileId; private String profileName; private boolean isPublic; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java index c23d50ce..9a3643b6 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java @@ -15,7 +15,7 @@ import javax.annotation.Nullable; public class ValhallaSkinServer implements SkinServer { @SuppressWarnings("unused") - private final String baseURL; + private final String baseURL; public ValhallaSkinServer(String baseURL) { this.baseURL = baseURL; From 12ec6c1302fd1a2a27e4e942be125ce86686deae Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 16:39:32 +0200 Subject: [PATCH 55/96] Break ModelPlayerPony into each different race --- .../java/com/minelittlepony/ForgeProxy.java | 13 -- .../com/minelittlepony/PonyRenderManager.java | 13 +- .../hdskins/gui/RenderPonyModel.java | 6 +- .../model/AbstractPonyModel.java | 21 +-- .../minelittlepony/model/ModelMobPony.java | 18 +- .../java/com/minelittlepony/model/PMAPI.java | 30 +-- .../model/armour/ModelPonyArmor.java | 10 +- .../model/armour/ModelSkeletonPonyArmor.java | 6 +- .../model/armour/ModelZombiePonyArmor.java | 18 +- .../model/armour/PonyArmor.java | 18 +- .../model/capabilities/IModelPegasus.java | 5 + .../model/capabilities/IModelUnicorn.java | 11 ++ .../model/player/ModelAlicorn.java | 152 +++++++++++++++ .../ModelEarthPony.java} | 177 ++++++------------ .../model/player/ModelPegasus.java | 63 +++++++ .../model/player/PlayerModels.java | 13 +- .../model/ponies/ModelHumanPlayer.java | 36 ---- .../model/ponies/ModelIllagerPony.java | 6 +- .../model/ponies/ModelSkeletonPony.java | 5 +- .../model/ponies/ModelVillagerPony.java | 3 +- .../model/ponies/ModelZombiePony.java | 13 +- .../minelittlepony/pony/data/PonyRace.java | 18 +- .../render/layer/AbstractPonyLayer.java | 15 +- .../layer/LayerEntityOnPonyShoulder.java | 12 +- .../render/layer/LayerHeldPonyItem.java | 3 +- .../layer/LayerHeldPonyItemMagical.java | 8 +- .../render/layer/LayerPonyArmor.java | 11 +- .../render/layer/LayerPonyCape.java | 4 +- .../render/layer/LayerPonyCustomHead.java | 3 +- .../render/layer/LayerPonyElytra.java | 3 +- .../render/player/RenderPonyBase.java | 7 +- .../render/player/RenderPonyPlayer.java | 2 + .../render/ponies/RenderPonySkeleton.java | 2 +- 33 files changed, 411 insertions(+), 314 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java create mode 100644 src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java create mode 100644 src/main/java/com/minelittlepony/model/player/ModelAlicorn.java rename src/main/java/com/minelittlepony/model/{ponies/ModelPlayerPony.java => player/ModelEarthPony.java} (78%) create mode 100644 src/main/java/com/minelittlepony/model/player/ModelPegasus.java delete mode 100644 src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java index f4f314ae..90ad340c 100644 --- a/src/main/java/com/minelittlepony/ForgeProxy.java +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -2,18 +2,13 @@ package com.minelittlepony; import com.mumfrey.liteloader.util.ModUtilities; import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraftforge.client.ForgeHooksClient; import javax.annotation.Nullable; -import java.util.Optional; -import java.util.function.Function; /** * Proxy class for accessing forge fields and methods. @@ -54,12 +49,4 @@ public class ForgeProxy { return ForgeHooksClient.getArmorModel(entity, item, slot, def); return def; } - - public static Optional>> createShoulderLayer() { - if (forgeLoaded) { - // TODO - } - return Optional.empty(); - } - } diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 178237cb..24950148 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -5,7 +5,7 @@ import java.util.Map; import com.google.common.collect.Maps; import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.RenderPonyModel; -import com.minelittlepony.model.PMAPI; +import com.minelittlepony.model.player.PlayerModels; import com.minelittlepony.render.player.RenderPonyPlayer; import com.minelittlepony.render.ponies.RenderPonyIllager; import com.minelittlepony.render.ponies.RenderPonyPigman; @@ -52,9 +52,14 @@ public class PonyRenderManager { // Preview on the select skin gui ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); - new RenderPonyPlayer(rm, false, "pony", PMAPI.pony); - new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall); - //TODO: Add skin types for each species? May require model break up. + registerPlayerSkin(rm, PlayerModels.EARTH); + registerPlayerSkin(rm, PlayerModels.PEGASUS); + registerPlayerSkin(rm, PlayerModels.ALICORN); + } + + protected void registerPlayerSkin(RenderManager rm, PlayerModels playerModel) { + new RenderPonyPlayer(rm, false, playerModel.getId(false), playerModel.getModel(false)); + new RenderPonyPlayer(rm, true, playerModel.getId(true), playerModel.getModel(true)); } /** diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 721b0dee..936611aa 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -36,6 +36,10 @@ public class RenderPonyModel extends RenderPlayerModel { Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId()); + if (thePony.getRace(false).isHuman()) { + return super.getEntityModel(playermodel); + } + ModelWrapper pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); @@ -44,7 +48,7 @@ public class RenderPonyModel extends RenderPlayerModel { @Override protected LayerRenderer getElytraLayer() { - return new AbstractPonyLayer(this, super.getElytraLayer()) { + return new AbstractPonyLayer(this) { final PonyElytra modelElytra = new PonyElytra(); @Override diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index fddb2c83..c9cea49a 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -74,24 +74,10 @@ public abstract class AbstractPonyModel extends ModelPlayer { */ protected abstract void initPositions(float yOffset, float stretch); - @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - if (doCancelRender()) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - } - } - public ArmPose getArmPoseForSide(EnumHandSide side) { return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; } - /** - * Returns true if the default minecraft handling should be used. - */ - protected boolean doCancelRender() { - return false; - } - /** * Returns true if this model is on the ground and crouching. */ @@ -99,6 +85,13 @@ public abstract class AbstractPonyModel extends ModelPlayer { return isSneak && !isFlying; } + /** + * Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast. + */ + protected void checkRainboom(Entity entity, float swing) { + rainboom = isFlying(entity) && swing >= 0.9999F; + } + /** * Returns true if the given entity can and is flying, or has an elytra. */ diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index fbddc04a..dc807eef 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -1,27 +1,33 @@ package com.minelittlepony.model; -import com.minelittlepony.model.ponies.ModelPlayerPony; +import com.minelittlepony.model.player.ModelAlicorn; -import net.minecraft.entity.Entity; +import net.minecraft.util.math.MathHelper; /** * Common class for all humanoid (ponioid?) non-player enemies. * */ -public class ModelMobPony extends ModelPlayerPony { +public class ModelMobPony extends ModelAlicorn { public ModelMobPony() { super(false); } @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); - + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); rotateRightArm(move, tick); rotateLeftArm(move, tick); } + /** + * Returns true if the angle is to the right? + */ + public boolean islookAngleRight(float move) { + return MathHelper.sin(move / 20f) < 0; + } + /** * Called to update the left arm's final rotation. * Subclasses may replace it with their own implementations. diff --git a/src/main/java/com/minelittlepony/model/PMAPI.java b/src/main/java/com/minelittlepony/model/PMAPI.java index 1523da86..1a2b9c74 100644 --- a/src/main/java/com/minelittlepony/model/PMAPI.java +++ b/src/main/java/com/minelittlepony/model/PMAPI.java @@ -1,10 +1,12 @@ package com.minelittlepony.model; -import com.minelittlepony.model.ponies.ModelHumanPlayer; +import com.minelittlepony.model.player.ModelAlicorn; +import com.minelittlepony.model.player.ModelEarthPony; +import com.minelittlepony.model.player.ModelPegasus; import com.minelittlepony.model.ponies.ModelIllagerPony; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.model.ponies.ModelSkeletonPony; import com.minelittlepony.model.ponies.ModelVillagerPony; +import com.minelittlepony.model.ponies.ModelWitchPony; import com.minelittlepony.model.ponies.ModelZombiePony; import java.lang.reflect.Field; @@ -15,17 +17,23 @@ import java.lang.reflect.Field; */ public final class PMAPI { - public static final ModelWrapper - pony = new ModelWrapper(new ModelPlayerPony(false)), - ponySmall = new ModelWrapper(new ModelPlayerPony(true)), + public static final ModelWrapper pony = new ModelWrapper(new ModelAlicorn(false)); + public static final ModelWrapper ponySmall = new ModelWrapper(new ModelAlicorn(true)); - human = new ModelWrapper(new ModelHumanPlayer(false)), - humanSmall = new ModelWrapper(new ModelHumanPlayer(true)), + public static final ModelWrapper earthpony = new ModelWrapper(new ModelEarthPony(false)); + public static final ModelWrapper earthponySmall = new ModelWrapper(new ModelEarthPony(true)); - zombie = new ModelWrapper(new ModelZombiePony()), - skeleton = new ModelWrapper(new ModelSkeletonPony()), - villager = new ModelWrapper(new ModelVillagerPony()), - illager = new ModelWrapper(new ModelIllagerPony()); + public static final ModelWrapper pegasus = new ModelWrapper(new ModelPegasus(false)); + public static final ModelWrapper pegasusSmall = new ModelWrapper(new ModelPegasus(true)); + + public static final ModelWrapper alicorn = new ModelWrapper(new ModelAlicorn(false)); + public static final ModelWrapper alicornSmall = new ModelWrapper(new ModelAlicorn(true)); + + public static final ModelWrapper zombie = new ModelWrapper(new ModelZombiePony()); + public static final ModelWrapper skeleton = new ModelWrapper(new ModelSkeletonPony()); + public static final ModelWrapper villager = new ModelWrapper(new ModelVillagerPony()); + public static final ModelWrapper illager = new ModelWrapper(new ModelIllagerPony()); + public static final ModelWrapper witch = new ModelWrapper(new ModelWitchPony()); public static void init() { for (Field field : PMAPI.class.getFields()) { diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index ba5d30fb..2802fc9d 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -179,14 +179,8 @@ public class ModelPonyArmor extends ModelMobPony { } @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); - syncLegs(); - } - - @Override - protected void adjustLegs() { - super.adjustLegs(); + protected void setLegs(float move, float swing, float tick, Entity entity) { + super.setLegs(move, swing, tick, entity); syncLegs(); } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java index 86d32d22..08e3b167 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -1,7 +1,5 @@ package com.minelittlepony.model.armour; -import net.minecraft.entity.Entity; - /** * Armour for skeleton ponies. * @@ -9,9 +7,9 @@ import net.minecraft.entity.Entity; public class ModelSkeletonPonyArmor extends ModelPonyArmor { @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); + protected void adjustLegs(float move, float swing, float tick) { aimBow(leftArmPose, rightArmPose, tick); + super.adjustLegs(move, swing, tick); } @Override diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index dab818d7..3fac3c32 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -1,20 +1,13 @@ package com.minelittlepony.model.armour; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.util.math.MathHelper; - public class ModelZombiePonyArmor extends ModelPonyArmor { - private boolean isRight(float move) { - return MathHelper.sin(move / 20f) < 0; - } - // Copied from ModelZombiePony @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { + if (islookAngleRight(move)) { rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); @@ -29,10 +22,11 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; - boolean right = isRight(move); - float xchange = right ? 0.5f : -0.5f; - ModelRenderer arm = right ? bipedRightArm : bipedLeftArm; - shiftRotationPoint(arm, xchange, 1.5f, 3); + if (islookAngleRight(move)) { + shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + } else { + shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + } } } diff --git a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java index eccb0ee7..f3f0d9ae 100644 --- a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java @@ -3,23 +3,33 @@ package com.minelittlepony.model.armour; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.pony.data.IPonyData; +import net.minecraft.inventory.EntityEquipmentSlot; + public class PonyArmor { public final AbstractPonyModel chestplate; - public final AbstractPonyModel armour; + public final AbstractPonyModel leggings; public PonyArmor(AbstractPonyModel chest, AbstractPonyModel body) { chestplate = chest; - armour = body; + leggings = body; } public void apply(IPonyData meta) { chestplate.metadata = meta; - armour.metadata = meta; + leggings.metadata = meta; } public void init() { chestplate.init(0, 1); - armour.init(0, 0.5f); + leggings.init(0, 0.5f); + } + + public AbstractPonyModel getArmorForSlot(EntityEquipmentSlot slot) { + if (slot == EntityEquipmentSlot.LEGS) { + return leggings; + } + + return chestplate; } } diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java new file mode 100644 index 00000000..b84ec9e7 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java @@ -0,0 +1,5 @@ +package com.minelittlepony.model.capabilities; + +public interface IModelPegasus { + +} diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java new file mode 100644 index 00000000..a1f16559 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java @@ -0,0 +1,11 @@ +package com.minelittlepony.model.capabilities; + +import com.minelittlepony.render.PonyRenderer; + +import net.minecraft.util.EnumHandSide; + +public interface IModelUnicorn { + PonyRenderer getUnicornArmForSide(EnumHandSide side); + + boolean isCasting(); +} diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java new file mode 100644 index 00000000..3a66c916 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -0,0 +1,152 @@ +package com.minelittlepony.model.player; + +import com.minelittlepony.model.components.UnicornHorn; +import com.minelittlepony.render.PonyRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.math.MathHelper; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.capabilities.IModelUnicorn; + +/** + * Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff. + */ +public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { + + public PonyRenderer unicornArmRight; + public PonyRenderer unicornArmLeft; + + public UnicornHorn horn; + + public ModelAlicorn(boolean smallArms) { + super(smallArms); + } + + @Override + public void init(float yOffset, float stretch) { + super.init(yOffset, stretch); + horn = new UnicornHorn(this, yOffset, stretch); + } + + @Override + protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { + super.rotateLegsOnGround(move, swing, tick, entity); + + unicornArmRight.rotateAngleY = 0; + unicornArmLeft.rotateAngleY = 0; + } + + @Override + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); + + unicornArmLeft.rotateAngleZ = 0; + unicornArmRight.rotateAngleZ = 0; + + unicornArmLeft.rotateAngleX = 0; + unicornArmRight.rotateAngleX = 0; + } + + @Override + protected void holdItem(float swing) { + if (metadata.hasMagic()) { + boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; + + alignArmForAction(unicornArmLeft, leftArmPose, both, swing); + alignArmForAction(unicornArmRight, rightArmPose, both, swing); + } else { + super.holdItem(swing); + } + + horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY); + } + + @Override + protected void swingItem(Entity entity, float swingProgress) { + if (metadata.hasMagic()) { + if (swingProgress > -9990.0F && !isSleeping) { + EnumHandSide mainSide = getMainHand(entity); + + if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; + swingArm(getUnicornArmForSide(mainSide)); + } + } else { + super.swingItem(entity, swingProgress); + } + } + + @Override + protected void swingArms(float tick) { + if (isSleeping) return; + + if (!metadata.hasMagic()) { + super.swingArms(tick); + } else { + float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(tick * 0.067F) * 0.05F; + + if (rightArmPose != ArmPose.EMPTY) { + unicornArmRight.rotateAngleZ += cos; + unicornArmRight.rotateAngleX += sin; + } + + if (leftArmPose != ArmPose.EMPTY) { + unicornArmLeft.rotateAngleZ += cos; + unicornArmLeft.rotateAngleX += sin; + } + } + } + + @Override + public PonyRenderer getUnicornArmForSide(EnumHandSide side) { + return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; + } + + @Override + public boolean isCasting() { + return metadata.hasMagic(); + } + + @Override + protected void sneakLegs() { + super.sneakLegs(); + unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; + } + + @Override + protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { + if (!metadata.hasMagic()) { + super.aimBow(leftArm, rightArm, tick); + } else if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); + } + } + + @Override + protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.renderHead(entity, move, swing, age, headYaw, headPitch, scale); + horn.render(entity, move, swing, age, headYaw, headPitch, scale); + } + + @Override + protected void initLegTextures() { + super.initLegTextures(); + unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); + unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); + boxList.remove(unicornArmRight); + } + + @Override + protected void initLegPositions(float yOffset, float stretch) { + super.initLegPositions(yOffset, stretch); + float armY = THIRDP_ARM_CENTRE_Y - 6; + float armZ = THIRDP_ARM_CENTRE_Z - 2; + + unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0); + unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0); + } +} diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java similarity index 78% rename from src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java rename to src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 2f8a398f..f2b9ec65 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -1,13 +1,11 @@ -package com.minelittlepony.model.ponies; +package com.minelittlepony.model.player; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.armour.ModelPonyArmor; import com.minelittlepony.model.armour.PonyArmor; -import com.minelittlepony.model.components.PegasusWings; import com.minelittlepony.model.components.PonySnout; import com.minelittlepony.model.components.PonyTail; -import com.minelittlepony.model.components.UnicornHorn; import com.minelittlepony.render.PonyRenderer; import com.minelittlepony.render.plane.PlaneRenderer; @@ -21,7 +19,7 @@ import static net.minecraft.client.renderer.GlStateManager.popMatrix; import static net.minecraft.client.renderer.GlStateManager.pushMatrix; import static com.minelittlepony.model.PonyModelConstants.*; -public class ModelPlayerPony extends AbstractPonyModel { +public class ModelEarthPony extends AbstractPonyModel { private final boolean smallArms; @@ -30,15 +28,10 @@ public class ModelPlayerPony extends AbstractPonyModel { public PlaneRenderer upperTorso; public PlaneRenderer neck; - public PonyRenderer unicornArmRight; - public PonyRenderer unicornArmLeft; - public PonyTail tail; public PonySnout snout; - public UnicornHorn horn; - public PegasusWings wings; - public ModelPlayerPony(boolean smallArms) { + public ModelEarthPony(boolean smallArms) { super(smallArms); this.smallArms = smallArms; } @@ -52,15 +45,12 @@ public class ModelPlayerPony extends AbstractPonyModel { public void init(float yOffset, float stretch) { super.init(yOffset, stretch); snout = new PonySnout(this, yOffset, stretch); - horn = new UnicornHorn(this, yOffset, stretch); - wings = new PegasusWings(this, yOffset, stretch); } @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - checkRainboom(entity, swing); rotateHead(headYaw, headPitch); float bodySwingRotation = 0; @@ -74,7 +64,7 @@ public class ModelPlayerPony extends AbstractPonyModel { holdItem(swing); swingItem(entity, swingProgress); - if (isCrouching() && !rainboom) { + if (isCrouching()) { adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); sneakLegs(); setHead(0, 6, -2); @@ -112,7 +102,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; snout.setGender(metadata.getGender()); - wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); } } @@ -139,13 +128,6 @@ public class ModelPlayerPony extends AbstractPonyModel { copyModelAngles(bipedBody, bipedBodyWear); } - /** - * Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast. - */ - protected void checkRainboom(Entity entity, float swing) { - rainboom = isFlying(entity) && swing >= 0.9999F; - } - /** * Sets the head rotation angle. */ @@ -180,49 +162,46 @@ public class ModelPlayerPony extends AbstractPonyModel { } protected void setLegs(float move, float swing, float tick, Entity entity) { - rotateLegs(move, swing, tick, entity); - adjustLegs(); + if (isFlying(entity)) { + rotateLegsInFlight(move, swing, tick, entity); + } else { + rotateLegsOnGround(move, swing, tick, entity); + } + + bipedLeftArm.rotateAngleZ = 0; + bipedRightArm.rotateAngleZ = 0; + + adjustLegs(move, swing, tick); } - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - float leftArm; - float rightArm; - float leftLeg; - float rightLeg; + protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + float armX = MathHelper.sin(-swing / 2); + float legX = MathHelper.sin(swing / 2); + bipedLeftArm.rotateAngleX = armX; + bipedRightArm.rotateAngleX = armX; - if (isFlying(entity)) { - if (rainboom) { - rightArm = leftArm = ROTATE_270; - rightLeg = leftLeg = ROTATE_90; - } else { - rightArm = leftArm = MathHelper.sin(-swing / 2); - rightLeg = leftLeg = MathHelper.sin(swing / 2); - } + bipedLeftLeg.rotateAngleX = legX; + bipedRightLeg.rotateAngleX = legX; - bipedLeftLeg.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F; - bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F; - } else { - float pi = PI * (float) Math.pow(swing, 16); + bipedLeftArm.rotateAngleY = -0.2F; + bipedLeftLeg.rotateAngleY = 0.2F; - float mve = move * 0.6662F; // magic number ahoy - float srt = swing / 4; + bipedRightArm.rotateAngleY = 0.2F; + bipedRightLeg.rotateAngleY = -0.2F; + } - leftArm = MathHelper.cos(mve + pi) * srt; - rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; + protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { + float pi = PI * (float) Math.pow(swing, 16); - leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; - rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; + float mve = move * 0.6662F; // magic number ahoy + float srt = swing / 4; - bipedLeftArm.rotateAngleY = 0; - bipedRightArm.rotateAngleY = 0; + float leftArm = MathHelper.cos(mve + pi) * srt; + float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; - bipedLeftLeg.rotateAngleY = 0; - bipedRightLeg.rotateAngleY = 0; - - unicornArmRight.rotateAngleY = 0; - unicornArmLeft.rotateAngleY = 0; - } + float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; + float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; bipedLeftArm.rotateAngleX = leftArm; bipedRightArm.rotateAngleX = rightArm; @@ -230,14 +209,11 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftLeg.rotateAngleX = leftLeg; bipedRightLeg.rotateAngleX = rightLeg; - bipedLeftArm.rotateAngleZ = 0; - bipedRightArm.rotateAngleZ = 0; + bipedLeftArm.rotateAngleY = 0; + bipedRightArm.rotateAngleY = 0; - unicornArmLeft.rotateAngleZ = 0; - unicornArmRight.rotateAngleZ = 0; - - unicornArmLeft.rotateAngleX = 0; - unicornArmRight.rotateAngleX = 0; + bipedLeftLeg.rotateAngleY = 0; + bipedRightLeg.rotateAngleY = 0; } private float getLegOutset() { @@ -246,11 +222,15 @@ public class ModelPlayerPony extends AbstractPonyModel { return 4; } - protected void adjustLegs() { + protected float getLegSpread() { + return rainboom ? 2 : 1; + } + + protected void adjustLegs(float move, float swing, float tick) { float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; - float spread = rainboom ? 2 : 1; + float spread = getLegSpread(); bipedRightArm.rotationPointZ = spread + sin; @@ -278,23 +258,14 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; } - - protected void holdItem(float swing) { boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; - if (!rainboom && !metadata.hasMagic()) { - alignArmForAction(bipedLeftArm, leftArmPose, both, swing); - alignArmForAction(bipedRightArm, rightArmPose, both, swing); - } else if (metadata.hasMagic()) { - alignArmForAction(unicornArmLeft, leftArmPose, both, swing); - alignArmForAction(unicornArmRight, rightArmPose, both, swing); - } - - horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY); + alignArmForAction(bipedLeftArm, leftArmPose, both, swing); + alignArmForAction(bipedRightArm, rightArmPose, both, swing); } - private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { + protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { switch (pose) { case ITEM: float swag = 1; @@ -324,15 +295,11 @@ public class ModelPlayerPony extends AbstractPonyModel { if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; - if (metadata.hasMagic()) { - swingArm(getUnicornArmForSide(mainSide)); - } else { - swingArm(getArmForSide(mainSide)); - } + swingArm(getArmForSide(mainSide)); } } - private void swingArm(ModelRenderer arm) { + protected void swingArm(ModelRenderer arm) { float swing = 1 - (float)Math.pow(1 - swingProgress, 3); float deltaX = MathHelper.sin(swing * PI); @@ -352,24 +319,13 @@ public class ModelPlayerPony extends AbstractPonyModel { float sin = MathHelper.sin(tick * 0.067F) * 0.05F; if (rightArmPose != ArmPose.EMPTY) { - - if (metadata.hasMagic()) { - unicornArmRight.rotateAngleZ += cos; - unicornArmRight.rotateAngleX += sin; - } else { - bipedRightArm.rotateAngleZ += cos; - bipedRightArm.rotateAngleX += sin; - } + bipedRightArm.rotateAngleZ += cos; + bipedRightArm.rotateAngleX += sin; } if (leftArmPose != ArmPose.EMPTY) { - if (metadata.hasMagic()) { - unicornArmLeft.rotateAngleZ += cos; - unicornArmLeft.rotateAngleX += sin; - } else { - bipedLeftArm.rotateAngleZ += cos; - bipedLeftArm.rotateAngleX += sin; - } + bipedLeftArm.rotateAngleZ += cos; + bipedLeftArm.rotateAngleX += sin; } } @@ -392,17 +348,10 @@ public class ModelPlayerPony extends AbstractPonyModel { neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); } - public PonyRenderer getUnicornArmForSide(EnumHandSide side) { - return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; - } - /** * Aligns legs to a sneaky position. */ protected void sneakLegs() { - unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT; - bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; @@ -425,14 +374,8 @@ public class ModelPlayerPony extends AbstractPonyModel { protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { - - if (metadata.hasMagic()) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); - } else { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); - } + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); } } @@ -476,7 +419,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedHead.render(scale); bipedHeadwear.render(scale); bipedHead.postRender(scale); - horn.render(entity, move, swing, age, headYaw, headPitch, scale); } protected void renderNeck() { @@ -491,7 +433,6 @@ public class ModelPlayerPony extends AbstractPonyModel { } upperTorso.render(scale); bipedBody.postRender(scale); - wings.render(entity, move, swing, age, headYaw, headPitch, scale); tail.render(metadata.getTail(), scale); } @@ -549,11 +490,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedLeftLegwear = new ModelRenderer(this, 0, 48); bipedRightLegwear = new ModelRenderer(this, 0, 32); - - unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); - unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); - - boxList.remove(unicornArmRight); } @Override @@ -672,9 +608,6 @@ public class ModelPlayerPony extends AbstractPonyModel { bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } - - unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0); - unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0); } @Override diff --git a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java new file mode 100644 index 00000000..f4f4cb73 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java @@ -0,0 +1,63 @@ +package com.minelittlepony.model.player; + +import com.minelittlepony.model.components.PegasusWings; +import net.minecraft.entity.Entity; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.capabilities.IModelPegasus; + +public class ModelPegasus extends ModelEarthPony implements IModelPegasus { + public PegasusWings wings; + + public ModelPegasus(boolean smallArms) { + super(smallArms); + } + + @Override + public void init(float yOffset, float stretch) { + super.init(yOffset, stretch); + wings = new PegasusWings(this, yOffset, stretch); + } + + @Override + public boolean isCrouching() { + return super.isCrouching() && !rainboom; + } + + @Override + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + checkRainboom(entity, swing); + + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + + if (bipedCape != null) { + wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + } + } + + @Override + protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + if (rainboom) { + bipedLeftArm.rotateAngleX = ROTATE_270; + bipedRightArm.rotateAngleX = ROTATE_270; + + bipedLeftLeg.rotateAngleX = ROTATE_90; + bipedRightLeg.rotateAngleX = ROTATE_90; + + bipedLeftArm.rotateAngleY = -0.2F; + bipedLeftLeg.rotateAngleY = 0.2F; + + bipedRightArm.rotateAngleY = 0.2F; + bipedRightLeg.rotateAngleY = -0.2F; + } else { + super.rotateLegsInFlight(move, swing, tick, entity); + } + } + + @Override + protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); + wings.render(entity, move, swing, age, headYaw, headPitch, scale); + } +} diff --git a/src/main/java/com/minelittlepony/model/player/PlayerModels.java b/src/main/java/com/minelittlepony/model/player/PlayerModels.java index 18a2d666..af91e7f7 100644 --- a/src/main/java/com/minelittlepony/model/player/PlayerModels.java +++ b/src/main/java/com/minelittlepony/model/player/PlayerModels.java @@ -4,8 +4,13 @@ import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.ModelWrapper; public enum PlayerModels { - HUMAN("default", "slim", () -> PMAPI.human, () -> PMAPI.humanSmall), - PONY("pony", "slimpony", () -> PMAPI.pony, () -> PMAPI.ponySmall); + /** + * @deprecated Will be removed in a later revision + */ + @Deprecated HUMAN("default", "slim", () -> PMAPI.pony, () -> PMAPI.ponySmall), + EARTH("earthpony", "slimearthpony", () -> PMAPI.earthpony, () -> PMAPI.earthponySmall), + PEGASUS("pegasus", "slimpegasus", () -> PMAPI.pegasus, () -> PMAPI.pegasusSmall), + ALICORN("alicorn", "slimalicorn", () -> PMAPI.alicorn, () -> PMAPI.alicornSmall); private final ModelResolver normal, slim; @@ -20,11 +25,11 @@ public enum PlayerModels { } public ModelWrapper getModel(boolean slim) { - return slim ? this.slim.resolve() : normal.resolve(); + return slim ? this.slim.resolve() : normal.resolve(); } public String getId(boolean useSlimArms) { - return useSlimArms ? slimKey : normalKey; + return useSlimArms ? slimKey : normalKey; } /** diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java deleted file mode 100644 index 1fb345bc..00000000 --- a/src/main/java/com/minelittlepony/model/ponies/ModelHumanPlayer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.minelittlepony.model.ponies; - -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.armour.PonyArmor; - -public class ModelHumanPlayer extends AbstractPonyModel { - - public ModelHumanPlayer(boolean smallArms) { - super(smallArms); - } - - @Override - protected boolean doCancelRender() { - return true; - } - - @Override - public void transform(BodyPart part) { - } - - @Override - protected void initTextures() { - - } - - @Override - protected void initPositions(float yOffset, float stretch) { - - } - - @Override - public PonyArmor createArmour() { - return new PonyArmor(new ModelHumanPlayer(false), new ModelHumanPlayer(false)); - } -} diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index 9d1a5fa9..ea355585 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -1,12 +1,14 @@ package com.minelittlepony.model.ponies; +import com.minelittlepony.model.player.ModelAlicorn; + 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 class ModelIllagerPony extends ModelPlayerPony { +public class ModelIllagerPony extends ModelAlicorn { public ModelIllagerPony() { super(false); @@ -14,8 +16,8 @@ public class ModelIllagerPony extends ModelPlayerPony { @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + AbstractIllager illager = (AbstractIllager) entity; AbstractIllager.IllagerArmPose pose = illager.getArmPose(); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index 812ce4a2..eecef93d 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -8,7 +8,6 @@ import com.minelittlepony.model.armour.PonyArmor; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.init.Items; @@ -46,8 +45,8 @@ public class ModelSkeletonPony extends ModelMobPony { } @Override - protected void rotateLegs(float move, float swing, float ticks, Entity entity) { - super.rotateLegs(move, swing, ticks, entity); + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); aimBow(leftArmPose, rightArmPose, ticks); } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 0353c930..119a1313 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -5,9 +5,10 @@ import net.minecraft.entity.passive.EntityVillager; import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; +import com.minelittlepony.model.player.ModelAlicorn; import com.minelittlepony.render.plane.PlaneRenderer; -public class ModelVillagerPony extends ModelPlayerPony { +public class ModelVillagerPony extends ModelAlicorn { public PlaneRenderer bag, apron, trinket; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 8a92cf68..b3f7bb69 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -4,8 +4,6 @@ import com.minelittlepony.model.ModelMobPony; import com.minelittlepony.model.armour.ModelZombiePonyArmor; import com.minelittlepony.model.armour.PonyArmor; -import net.minecraft.util.math.MathHelper; - public class ModelZombiePony extends ModelMobPony { public ModelZombiePony() { @@ -17,15 +15,11 @@ public class ModelZombiePony extends ModelMobPony { return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor()); } - private boolean isRight(float move) { - return MathHelper.sin(move / 20) < 0; - } - @Override protected void rotateRightArm(float move, float tick) { if (rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { + if (islookAngleRight(move)) { rotateArmHolding(bipedRightArm, 1, swingProgress, tick); } else { rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); @@ -34,18 +28,17 @@ public class ModelZombiePony extends ModelMobPony { @Override protected void rotateLeftArm(float move, float tick) { - + // zombies are unidexterous. } @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; - if (isRight(move)) { + if (islookAngleRight(move)) { shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); } else { shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); } - } } diff --git a/src/main/java/com/minelittlepony/pony/data/PonyRace.java b/src/main/java/com/minelittlepony/pony/data/PonyRace.java index 9f86dc20..508f8707 100644 --- a/src/main/java/com/minelittlepony/pony/data/PonyRace.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -5,15 +5,15 @@ import com.minelittlepony.model.player.PlayerModels; public enum PonyRace implements ITriggerPixelMapped { HUMAN(0, PlayerModels.HUMAN, false, false), - EARTH(0xf9b131, PlayerModels.PONY,false, false), - PEGASUS(0x88caf0, PlayerModels.PONY, true, false), - UNICORN(0xd19fe4, PlayerModels.PONY, false, true), - ALICORN(0xfef9fc, PlayerModels.PONY, true, true), - CHANGELING(0x282b29, PlayerModels.PONY, true, true), - ZEBRA(0xd0cccf, PlayerModels.PONY, false, false), - REFORMED_CHANGELING(0xcaed5a, PlayerModels.PONY, true, true), - GRIFFIN(0xae9145, PlayerModels.PONY, true, false), - HIPPOGRIFF(0xd6ddac, PlayerModels.PONY, true, false); + EARTH(0xf9b131, PlayerModels.EARTH,false, false), + PEGASUS(0x88caf0, PlayerModels.PEGASUS, true, false), + UNICORN(0xd19fe4, PlayerModels.ALICORN, false, true), + ALICORN(0xfef9fc, PlayerModels.ALICORN, true, true), + CHANGELING(0x282b29, PlayerModels.ALICORN, true, true), + ZEBRA(0xd0cccf, PlayerModels.EARTH, false, false), + REFORMED_CHANGELING(0xcaed5a, PlayerModels.ALICORN, true, true), + GRIFFIN(0xae9145, PlayerModels.PEGASUS, true, false), + HIPPOGRIFF(0xd6ddac, PlayerModels.PEGASUS, true, false); private boolean wings; private boolean horn; diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 43621a1c..96ad02f2 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -2,7 +2,6 @@ package com.minelittlepony.render.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.ponies.ModelHumanPlayer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; @@ -12,24 +11,16 @@ import net.minecraft.entity.EntityLivingBase; public abstract class AbstractPonyLayer implements LayerRenderer { private final RenderLivingBase renderer; - private LayerRenderer layer; - public AbstractPonyLayer(RenderLivingBase renderer, LayerRenderer humanLayer) { + public AbstractPonyLayer(RenderLivingBase renderer) { this.renderer = renderer; - this.layer = humanLayer; } @SuppressWarnings("unchecked") @Override public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - ModelBase model = renderer.getMainModel(); - if (model instanceof ModelHumanPlayer) { - // render the human layer - layer.doRenderLayer((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); - } else { - // render the pony layer - doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); - } + // render the pony layer + doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); } protected abstract void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index c603cf83..817d350c 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -1,6 +1,5 @@ package com.minelittlepony.render.layer; -import com.minelittlepony.ForgeProxy; import com.minelittlepony.model.BodyPart; import net.minecraft.client.entity.AbstractClientPlayer; @@ -8,12 +7,9 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerEntityOnShoulder; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import javax.annotation.Nullable; @@ -26,7 +22,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer renderer) { - super(renderer, getForgeLayer(manager)); + super(renderer); renderManager = manager; } @@ -82,10 +78,4 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer getForgeLayer(RenderManager manager) { - return ForgeProxy.createShoulderLayer() - .orElse(LayerEntityOnShoulder::new) - .apply(manager); - } } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index 428b5fed..a0fc022b 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -8,7 +8,6 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumHandSide; @@ -17,7 +16,7 @@ import static net.minecraft.client.renderer.GlStateManager.*; public class LayerHeldPonyItem extends AbstractPonyLayer { public LayerHeldPonyItem(RenderLivingBase livingPony) { - super(livingPony, new LayerHeldItem(livingPony)); + super(livingPony); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index 1c039ff2..83491c81 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -10,8 +10,8 @@ import static net.minecraft.client.renderer.GlStateManager.translate; import org.lwjgl.opengl.GL14; import com.minelittlepony.ducks.IRenderItem; -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.ponies.ModelPlayerPony; +import com.minelittlepony.model.capabilities.IModelUnicorn; + import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; @@ -30,7 +30,7 @@ public class LayerHeldPonyItemMagical extends LayerH private boolean isUnicorn() { ModelBase model = getMainModel(); - return model instanceof AbstractPonyModel && ((AbstractPonyModel) model).metadata.hasMagic(); + return model instanceof IModelUnicorn && ((IModelUnicorn) model).isCasting(); } protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { @@ -52,7 +52,7 @@ public class LayerHeldPonyItemMagical extends LayerH */ protected void renderArm(EnumHandSide side) { if (isUnicorn()) { - this.getMainModel().getUnicornArmForSide(side).postRender(0.0625F); + ((IModelUnicorn)getMainModel()).getUnicornArmForSide(side).postRender(0.0625F); } else { super.renderArm(side); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index b8007727..af314204 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; 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.resources.ResourcePackRepository; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.EntityEquipmentSlot; @@ -39,7 +38,7 @@ public class LayerPonyArmor extends AbstractPonyLaye private ModelWrapper pony; public LayerPonyArmor(RenderLivingBase renderer) { - super(renderer, new LayerBipedArmor(renderer)); + super(renderer); } @Override @@ -60,12 +59,7 @@ public class LayerPonyArmor extends AbstractPonyLaye ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); - AbstractPonyModel modelbase; - if (armorSlot == EntityEquipmentSlot.LEGS) { - modelbase = pony.getArmor().armour; - } else { - modelbase = pony.getArmor().chestplate; - } + AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot); modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); modelbase.setModelAttributes(pony.getModel()); modelbase.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); @@ -167,7 +161,6 @@ public class LayerPonyArmor extends AbstractPonyLaye } private void renderEnchantment(T entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index d7f21109..162e26f8 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -6,8 +6,6 @@ import com.minelittlepony.model.ModelWrapper; 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.entity.player.EnumPlayerModelParts; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; @@ -21,7 +19,7 @@ import static com.minelittlepony.model.PonyModelConstants.PI; public class LayerPonyCape extends AbstractPonyLayer { public LayerPonyCape(RenderLivingBase entity) { - super(entity, new LayerCape((RenderPlayer) entity)); + super(entity); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 5a8cd881..6d54c9d6 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -4,7 +4,6 @@ import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.ModelWrapper; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; @@ -46,7 +45,7 @@ public class LayerPonyCustomHead implements LayerRen model.transform(BodyPart.HEAD); model.bipedHead.postRender(0.0625f); - if (model instanceof ModelPlayerPony) { + if (model instanceof AbstractPonyModel) { translate(0, 0.2F, 0); } else { translate(0, 0, 0.15F); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index a26f3dc3..be51dd6e 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -7,7 +7,6 @@ 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.entity.EntityLivingBase; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Items; @@ -23,7 +22,7 @@ public class LayerPonyElytra extends AbstractPonyLay private PonyElytra modelElytra = new PonyElytra(); public LayerPonyElytra(RenderLivingBase rp) { - super(rp, new LayerElytra(rp)); + super(rp); } @Override diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index c5e64560..82fa660b 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -5,10 +5,9 @@ import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.ModelWrapper; -import com.minelittlepony.model.ponies.ModelPlayerPony; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.render.layer.LayerEntityOnPonyShoulder; -import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.render.layer.LayerPonyArmor; import com.minelittlepony.render.layer.LayerPonyCape; import com.minelittlepony.render.layer.LayerPonyCustomHead; @@ -45,7 +44,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony protected void addExtraLayers() { addLayer(new LayerPonyArmor<>(this)); - addLayer(new LayerHeldPonyItem<>(this)); + addLayer(new LayerHeldPonyItemMagical<>(this)); addLayer(new LayerArrow(this)); addLayer(new LayerPonyCape(this)); addLayer(new LayerPonyCustomHead<>(this)); @@ -108,7 +107,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony if (player.isEntityAlive() && player.isPlayerSleeping()) return; - if (((ModelPlayerPony) ponyModel).rainboom) { + if (ponyModel.rainboom) { transformPegasusFlight(player, motionX, motionY, motionZ, yaw, pitch, ticks); return; } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 2754bd57..de9e52f8 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -51,4 +51,6 @@ public class RenderPonyPlayer extends RenderPonyBase { GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); } + + //TODO: transformSwimming() } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java index a871e03c..41ef294f 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java @@ -28,7 +28,7 @@ public class RenderPonySkeleton extends Rende addLayer(new LayerBipedArmor(this) { @Override protected void initArmor() { - modelLeggings = getPlayerModel().getArmor().armour; + modelLeggings = getPlayerModel().getArmor().leggings; modelArmor = getPlayerModel().getArmor().chestplate; } }); From 7ff68e0e4fc7781e42c91674c0e3fce84e303c95 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 18:13:35 +0200 Subject: [PATCH 56/96] Snippity snippity. That should fix horn glows --- .../model/AbstractPonyModel.java | 25 ++++++----- .../minelittlepony/model/ModelMobPony.java | 12 +++--- .../model/armour/ModelPonyArmor.java | 33 +++++--------- .../model/armour/ModelSkeletonPonyArmor.java | 8 +--- .../model/capabilities/IModel.java | 28 ++++++++++++ .../model/capabilities/IModelPegasus.java | 10 ++++- .../model/capabilities/IModelUnicorn.java | 11 ++++- .../model/components/PegasusWings.java | 43 +++++++------------ .../model/components/UnicornHorn.java | 26 ++--------- .../model/player/ModelAlicorn.java | 33 ++++++++------ .../model/player/ModelEarthPony.java | 12 +++--- .../model/player/ModelPegasus.java | 17 +++++++- .../model/ponies/ModelIllagerPony.java | 14 +++--- .../model/ponies/ModelSkeletonPony.java | 21 +++------ .../model/ponies/ModelVillagerPony.java | 2 +- .../model/ponies/ModelZombiePony.java | 4 -- .../layer/LayerHeldPonyItemMagical.java | 2 +- 17 files changed, 153 insertions(+), 148 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/capabilities/IModel.java diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index c9cea49a..da19d70b 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,6 +1,7 @@ package com.minelittlepony.model; import com.minelittlepony.model.armour.PonyArmor; +import com.minelittlepony.model.capabilities.IModel; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyData; import com.minelittlepony.pony.data.PonySize; @@ -20,7 +21,7 @@ import static net.minecraft.client.renderer.GlStateManager.*; /** * TODO: move this into constructor and make separate classes for the races. */ -public abstract class AbstractPonyModel extends ModelPlayer { +public abstract class AbstractPonyModel extends ModelPlayer implements IModel { /** * The model's current scale. @@ -78,9 +79,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; } - /** - * Returns true if this model is on the ground and crouching. - */ + @Override public boolean isCrouching() { return isSneak && !isFlying; } @@ -92,21 +91,27 @@ public abstract class AbstractPonyModel extends ModelPlayer { rainboom = isFlying(entity) && swing >= 0.9999F; } - /** - * Returns true if the given entity can and is flying, or has an elytra. - */ + @Override public boolean isFlying(Entity entity) { return (isFlying && metadata.getRace().hasWings()) || (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()); } - /** - * Returns true if the current model is a child or a child-like foal. - */ + @Override + public boolean isFlying() { + return isFlying; + } + + @Override public boolean isChild() { return metadata.getSize() == PonySize.FOAL || isChild; } + @Override + public float getSwingAmount() { + return swingProgress; + } + /** * Adjusts the rotation center of the given renderer by the given amounts in each direction. */ diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index dc807eef..8798bfc5 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -38,11 +38,11 @@ public class ModelMobPony extends ModelAlicorn { protected void rotateRightArm(float move, float tick) { if (rightArmPose == ArmPose.EMPTY) return; - if (!metadata.hasMagic()) { - rotateArmHolding(bipedRightArm, -1, swingProgress, tick); - } else { + if (canCast()) { unicornArmRight.setRotationPoint(-7, 12, -2); rotateArmHolding(unicornArmRight, -1, swingProgress, tick); + } else { + rotateArmHolding(bipedRightArm, -1, swingProgress, tick); } } @@ -55,11 +55,11 @@ public class ModelMobPony extends ModelAlicorn { protected void rotateLeftArm(float move, float tick) { if (leftArmPose == ArmPose.EMPTY) return; - if (!metadata.hasMagic()) { - rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); - } else { + if (!canCast()) { unicornArmRight.setRotationPoint(-7, 12, -2); rotateArmHolding(unicornArmLeft, -1, swingProgress, tick); + } else { + rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); } } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index 2802fc9d..fe44b19f 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -1,6 +1,5 @@ package com.minelittlepony.model.armour; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import static com.minelittlepony.model.PonyModelConstants.*; @@ -23,9 +22,15 @@ public class ModelPonyArmor extends ModelMobPony { textureHeight = 32; } + @Override + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + syncLegs(); + } + @Override protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { - bipedBody.rotateAngleY = bodySwing * 0.2F; + bipedBody.rotateAngleY = bodySwing / 5; } @Override @@ -104,8 +109,8 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void initHeadTextures() { - bipedHead = new ModelRenderer(this, 0, 0); - bipedHeadwear = new ModelRenderer(this, 32, 0); + bipedHead = new PonyRenderer(this, 0, 0); + bipedHeadwear = new PonyRenderer(this, 32, 0); helmet = new PonyRenderer(this, 0, 0); } @@ -119,7 +124,7 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void initLegTextures() { bipedRightArm = new PonyRenderer(this, 0, 16); - bipedRightLeg = new ModelRenderer(this, 0, 16); + bipedRightLeg = new PonyRenderer(this, 0, 16); bipedLeftArm = new PonyRenderer(this, 0, 16).mirror(); bipedLeftLeg = new PonyRenderer(this, 0, 16).mirror(); @@ -178,24 +183,6 @@ public class ModelPonyArmor extends ModelMobPony { leftLegging.rotateAt(bipedLeftLeg).rotateTo(bipedLeftLeg); } - @Override - protected void setLegs(float move, float swing, float tick, Entity entity) { - super.setLegs(move, swing, tick, entity); - syncLegs(); - } - - @Override - protected void sneakLegs() { - super.sneakLegs(); - syncLegs(); - } - - @Override - protected void ponySleep() { - super.ponySleep(); - syncLegs(); - } - @Override public void setVisible(boolean invisible) { super.setVisible(invisible); diff --git a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java index 08e3b167..a2229dff 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -6,15 +6,9 @@ package com.minelittlepony.model.armour; */ public class ModelSkeletonPonyArmor extends ModelPonyArmor { - @Override - protected void adjustLegs(float move, float swing, float tick) { - aimBow(leftArmPose, rightArmPose, tick); - super.adjustLegs(move, swing, tick); - } - @Override protected void fixSpecialRotationPoints(float move) { - if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { + if (rightArmPose != ArmPose.EMPTY && !canCast()) { bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } } diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModel.java b/src/main/java/com/minelittlepony/model/capabilities/IModel.java new file mode 100644 index 00000000..f1bfe006 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModel.java @@ -0,0 +1,28 @@ +package com.minelittlepony.model.capabilities; + +import net.minecraft.entity.Entity; + +public interface IModel { + + /** + * Returns true if this model is on the ground and crouching. + */ + boolean isCrouching(); + + /** + * Returns true if the given entity can and is flying, or has an elytra. + */ + boolean isFlying(Entity entity); + + /** + * Returns true if the model is flying. + */ + boolean isFlying(); + + /** + * Returns true if the current model is a child or a child-like foal. + */ + boolean isChild(); + + float getSwingAmount(); +} diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java index b84ec9e7..c2edccdb 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java @@ -1,5 +1,13 @@ package com.minelittlepony.model.capabilities; -public interface IModelPegasus { +public interface IModelPegasus extends IModel { + /** + * Returns true if the wings are spread. + */ + boolean wingsAreOpen(); + /** + * Returns true if this model is being applied to a race that has wings. + */ + boolean canFly(); } diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java index a1f16559..234003b9 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java @@ -4,8 +4,17 @@ import com.minelittlepony.render.PonyRenderer; import net.minecraft.util.EnumHandSide; -public interface IModelUnicorn { +public interface IModelUnicorn extends IModel { PonyRenderer getUnicornArmForSide(EnumHandSide side); + /** + * Returns true if this model is being applied to a race that can use magic. + */ + boolean canCast(); + + /** + * Returns true if this model is currently using magic (horn is lit). + * @return + */ boolean isCasting(); } diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java index e492137e..9846c2bd 100644 --- a/src/main/java/com/minelittlepony/model/components/PegasusWings.java +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -1,35 +1,32 @@ package com.minelittlepony.model.components; -import net.minecraft.client.model.ModelBase; -import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.capabilities.IModelPegasus; -public class PegasusWings extends ModelBase { +public class PegasusWings { - private final AbstractPonyModel pony; + private final IModelPegasus pegasus; public final ModelWing leftWing; public final ModelWing rightWing; - public PegasusWings(AbstractPonyModel model, float yOffset, float stretch) { - pony = model; + public PegasusWings(T model, float yOffset, float stretch) { + pegasus = model; - leftWing = new ModelWing(pony, false, 4f, yOffset, stretch, 32); - rightWing = new ModelWing(pony, true, -6f, yOffset, stretch, 16); + leftWing = new ModelWing(model, false, 4f, yOffset, stretch, 32); + rightWing = new ModelWing(model, true, -6f, yOffset, stretch, 16); } - @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - if (!isVisible()) return; - + public void setRotationAngles(float move, float swing, float ticks) { float flap = 0; + float progress = pegasus.getSwingAmount(); - if (pony.swingProgress > 0) { - flap = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * PI * 2); + if (progress > 0) { + flap = MathHelper.sin(MathHelper.sqrt(progress) * PI * 2); } else { float pi = PI * (float) Math.pow(swing, 16); @@ -42,7 +39,7 @@ public class PegasusWings extends ModelBase { leftWing.rotateWalking(flap); rightWing.rotateWalking(-flap); - if (isExtended()) { + if (pegasus.wingsAreOpen()) { float flapAngle = getWingRotationFactor(ticks); leftWing.rotateFlying(flapAngle); rightWing.rotateFlying(-flapAngle); @@ -51,24 +48,14 @@ public class PegasusWings extends ModelBase { } public float getWingRotationFactor(float ticks) { - if (pony.isFlying) { + if (pegasus.isFlying()) { return (MathHelper.sin(ticks * 0.536f) * 1) + ROTATE_270 + 0.4f; } return LEFT_WING_ROTATE_ANGLE_Z_SNEAK; } - public boolean isVisible() { - return pony.metadata.getRace().hasWings(); - } - - public boolean isExtended() { - return pony.isFlying || pony.isCrouching(); - } - - @Override - public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - if (!isVisible()) return; - boolean standing = isExtended(); + public void render(float scale) { + boolean standing = pegasus.wingsAreOpen(); leftWing.render(standing, scale); rightWing.render(standing, scale); } diff --git a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java index c8d8d147..9306c1dc 100644 --- a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -4,25 +4,16 @@ import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.render.HornGlowRenderer; import com.minelittlepony.render.PonyRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.entity.Entity; - import static org.lwjgl.opengl.GL11.*; import static net.minecraft.client.renderer.GlStateManager.*; import static com.minelittlepony.model.PonyModelConstants.*; -public class UnicornHorn extends ModelBase { - - protected final AbstractPonyModel pony; +public class UnicornHorn { private PonyRenderer horn; private HornGlowRenderer glow; - private boolean usingMagic; - public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) { - this.pony = pony; - horn = new PonyRenderer(pony, 0, 3); glow = new HornGlowRenderer(pony, 0, 3); @@ -37,18 +28,11 @@ public class UnicornHorn extends ModelBase { .setAlpha(0.2f).box(0, 0, 0, 1, 3, 1, stretch + 0.8F); } - @Override - public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { - if (!pony.metadata.getRace().hasHorn()) return; - + public void render(float scale) { horn.render(scale); - - if (usingMagic && pony.metadata.hasMagic()) { - renderMagic(pony.metadata.getGlowColor(), scale); - } } - private void renderMagic(int tint, float scale) { + public void renderMagic(int tint, float scale) { glPushAttrib(24577); disableTexture2D(); disableLighting(); @@ -63,8 +47,4 @@ public class UnicornHorn extends ModelBase { disableBlend(); popAttrib(); } - - public void setUsingMagic(boolean usingMagic) { - this.usingMagic = usingMagic; - } } diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java index 3a66c916..f6fbceb4 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -51,7 +51,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { @Override protected void holdItem(float swing) { - if (metadata.hasMagic()) { + if (canCast()) { boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; alignArmForAction(unicornArmLeft, leftArmPose, both, swing); @@ -59,13 +59,11 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { } else { super.holdItem(swing); } - - horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY); } @Override protected void swingItem(Entity entity, float swingProgress) { - if (metadata.hasMagic()) { + if (canCast()) { if (swingProgress > -9990.0F && !isSleeping) { EnumHandSide mainSide = getMainHand(entity); @@ -81,9 +79,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { protected void swingArms(float tick) { if (isSleeping) return; - if (!metadata.hasMagic()) { - super.swingArms(tick); - } else { + if (canCast()) { float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float sin = MathHelper.sin(tick * 0.067F) * 0.05F; @@ -96,6 +92,8 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { unicornArmLeft.rotateAngleZ += cos; unicornArmLeft.rotateAngleX += sin; } + } else { + super.swingArms(tick); } } @@ -105,10 +103,15 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { } @Override - public boolean isCasting() { + public boolean canCast() { return metadata.hasMagic(); } + @Override + public boolean isCasting() { + return rightArmPose != ArmPose.EMPTY || leftArmPose != ArmPose.EMPTY; + } + @Override protected void sneakLegs() { super.sneakLegs(); @@ -118,18 +121,24 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { @Override protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { - if (!metadata.hasMagic()) { - super.aimBow(leftArm, rightArm, tick); - } else if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { + if (canCast()) { if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); + } else { + super.aimBow(leftArm, rightArm, tick); } } @Override protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { super.renderHead(entity, move, swing, age, headYaw, headPitch, scale); - horn.render(entity, move, swing, age, headYaw, headPitch, scale); + + if (canCast()) { + horn.render(scale); + if (isCasting()) { + horn.renderMagic(metadata.getGlowColor(), scale); + } + } } @Override diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index f2b9ec65..dbf83658 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -272,7 +272,7 @@ public class ModelEarthPony extends AbstractPonyModel { if (!isFlying && both) { swag -= (float)Math.pow(swing, 2); } - float mult = 1 - swag/2f; + float mult = 1 - swag/2; arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag; case EMPTY: arm.rotateAngleY = 0; @@ -373,10 +373,8 @@ public class ModelEarthPony extends AbstractPonyModel { } protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { - if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); - } + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); } protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) { @@ -458,6 +456,10 @@ public class ModelEarthPony extends AbstractPonyModel { initHeadTextures(); initBodyTextures(); initLegTextures(); + initTailTextures(); + } + + protected void initTailTextures() { tail = new PonyTail(this); } diff --git a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java index f4f4cb73..7ad1d836 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java +++ b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java @@ -8,6 +8,7 @@ import static com.minelittlepony.model.PonyModelConstants.*; import com.minelittlepony.model.capabilities.IModelPegasus; public class ModelPegasus extends ModelEarthPony implements IModelPegasus { + public PegasusWings wings; public ModelPegasus(boolean smallArms) { @@ -32,7 +33,7 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); if (bipedCape != null) { - wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + wings.setRotationAngles(move, swing, age); } } @@ -58,6 +59,18 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus { @Override protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); - wings.render(entity, move, swing, age, headYaw, headPitch, scale); + if (canFly()) { + wings.render(scale); + } + } + + @Override + public boolean wingsAreOpen() { + return isFlying || isCrouching(); + } + + @Override + public boolean canFly() { + return metadata.getRace().hasWings(); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index ea355585..2307d034 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -5,6 +5,7 @@ import com.minelittlepony.model.player.ModelAlicorn; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.AbstractIllager; +import net.minecraft.entity.monster.AbstractIllager.IllagerArmPose; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; @@ -19,11 +20,11 @@ public class ModelIllagerPony extends ModelAlicorn { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); AbstractIllager illager = (AbstractIllager) entity; - AbstractIllager.IllagerArmPose pose = illager.getArmPose(); + IllagerArmPose pose = illager.getArmPose(); boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; - if (pose == AbstractIllager.IllagerArmPose.ATTACKING) { + if (pose == IllagerArmPose.ATTACKING) { // vindicator attacking float f = MathHelper.sin(swingProgress * (float) Math.PI); float f1 = MathHelper.sin((1.0F - (1.0F - swingProgress) * (1.0F - swingProgress)) * (float) Math.PI); @@ -44,10 +45,7 @@ public class ModelIllagerPony extends ModelAlicorn { bipedLeftArm.rotateAngleZ -= MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; bipedRightArm.rotateAngleX += MathHelper.sin(age * 0.067F) * 0.05F; bipedLeftArm.rotateAngleX -= MathHelper.sin(age * 0.067F) * 0.05F; - } else if (pose == AbstractIllager.IllagerArmPose.SPELLCASTING) { - if (metadata.hasMagic()) { - horn.setUsingMagic(true); - } + } else if (pose == IllagerArmPose.SPELLCASTING) { // waving arms! if (rightHanded) { // this.bipedRightArm.rotationPointZ = 0.0F; @@ -63,7 +61,7 @@ public class ModelIllagerPony extends ModelAlicorn { bipedLeftArm.rotateAngleY = -1.1F; } - } else if (pose == AbstractIllager.IllagerArmPose.BOW_AND_ARROW) { + } else if (pose == IllagerArmPose.BOW_AND_ARROW) { if (rightHanded) { aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, age); } else { @@ -73,6 +71,6 @@ public class ModelIllagerPony extends ModelAlicorn { } public ModelRenderer getArm(EnumHandSide side) { - return metadata.hasMagic() ? getUnicornArmForSide(side) : getArmForSide(side); + return canCast() ? getUnicornArmForSide(side) : getArmForSide(side); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index eecef93d..e74010a8 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -6,7 +6,6 @@ import com.minelittlepony.model.ModelMobPony; import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; import com.minelittlepony.model.armour.PonyArmor; -import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; @@ -17,10 +16,6 @@ import net.minecraft.util.EnumHandSide; public class ModelSkeletonPony extends ModelMobPony { - public ModelSkeletonPony() { - super(); - } - @Override public PonyArmor createArmour() { return new PonyArmor(new ModelSkeletonPonyArmor(), new ModelSkeletonPonyArmor()); @@ -28,31 +23,25 @@ public class ModelSkeletonPony extends ModelMobPony { @Override public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { - rightArmPose = ModelBiped.ArmPose.EMPTY; - leftArmPose = ModelBiped.ArmPose.EMPTY; + rightArmPose = ArmPose.EMPTY; + leftArmPose = ArmPose.EMPTY; ItemStack itemstack = entity.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() == Items.BOW && ((AbstractSkeleton)entity).isSwingingArms()) { if (entity.getPrimaryHand() == EnumHandSide.RIGHT) { - rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW; + rightArmPose = ArmPose.BOW_AND_ARROW; } else { - leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW; + leftArmPose = ArmPose.BOW_AND_ARROW; } } super.setLivingAnimations(entity, move, swing, ticks); } - @Override - protected void adjustLegs(float move, float swing, float ticks) { - super.adjustLegs(move, swing, ticks); - aimBow(leftArmPose, rightArmPose, ticks); - } - @Override protected void fixSpecialRotationPoints(float move) { - if (rightArmPose != ArmPose.EMPTY && !metadata.hasMagic()) { + if (rightArmPose != ArmPose.EMPTY && !canCast()) { bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 119a1313..d213c682 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -21,7 +21,7 @@ public class ModelVillagerPony extends ModelAlicorn { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); float angleY = 0; - if (swingProgress > -9990.0F && !metadata.hasMagic()) { + if (swingProgress > -9990.0F && !canCast()) { angleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F; } bag.rotateAngleY = angleY; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index b3f7bb69..e71c2bfe 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -6,10 +6,6 @@ import com.minelittlepony.model.armour.PonyArmor; public class ModelZombiePony extends ModelMobPony { - public ModelZombiePony() { - super(); - } - @Override public PonyArmor createArmour() { return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor()); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index 83491c81..e4f1b1da 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -30,7 +30,7 @@ public class LayerHeldPonyItemMagical extends LayerH private boolean isUnicorn() { ModelBase model = getMainModel(); - return model instanceof IModelUnicorn && ((IModelUnicorn) model).isCasting(); + return model instanceof IModelUnicorn && ((IModelUnicorn) model).canCast(); } protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { From 45ad30503c782b198cc85f23d5b143b6b2f6cb38 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 18:20:56 +0200 Subject: [PATCH 57/96] Okay, things are clear now. CRYSTAL CLEAR --- .../com/minelittlepony/model/ponies/ModelSkeletonPony.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index e74010a8..3238755d 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -7,6 +7,7 @@ import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; import com.minelittlepony.model.armour.PonyArmor; import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.init.Items; @@ -21,6 +22,11 @@ public class ModelSkeletonPony extends ModelMobPony { return new PonyArmor(new ModelSkeletonPonyArmor(), new ModelSkeletonPonyArmor()); } + @Override + public boolean isCasting() { + return true; + } + @Override public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { rightArmPose = ArmPose.EMPTY; From de88e95ffe73ff24ad9f7bdee78a215d8eb0bebc Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 20:39:06 +0200 Subject: [PATCH 58/96] Unused import --- .../java/com/minelittlepony/model/components/UnicornHorn.java | 1 + .../java/com/minelittlepony/model/ponies/ModelSkeletonPony.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java index 9306c1dc..4211beb7 100644 --- a/src/main/java/com/minelittlepony/model/components/UnicornHorn.java +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -40,6 +40,7 @@ public class UnicornHorn { blendFunc(GL_SRC_ALPHA, GL_ONE); horn.postRender(scale); + glow.setTint(tint).render(scale); enableTexture2D(); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index 3238755d..db2ed133 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -7,7 +7,6 @@ import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; import com.minelittlepony.model.armour.PonyArmor; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.init.Items; From 7237480d04b9ed161966174bd355b292ae79ae52 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 21:23:08 +0200 Subject: [PATCH 59/96] When you're sick and tired of staring at this unreadable code --- .../model/armour/ModelPonyArmor.java | 6 +- .../model/components/PonyElytra.java | 2 +- .../model/player/ModelEarthPony.java | 2 +- .../render/AbstractPonyRenderer.java | 2 +- .../render/plane/ModelPlane.java | 80 +++++++++---------- .../minelittlepony/util/coordinates/Box.java | 36 +++++++++ .../minelittlepony/util/coordinates/Quad.java | 10 +++ .../util/coordinates/Vertex.java | 27 +++++++ 8 files changed, 118 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/minelittlepony/util/coordinates/Box.java create mode 100644 src/main/java/com/minelittlepony/util/coordinates/Quad.java create mode 100644 src/main/java/com/minelittlepony/util/coordinates/Vertex.java diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index fe44b19f..fadc3f49 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -126,8 +126,8 @@ public class ModelPonyArmor extends ModelMobPony { bipedRightArm = new PonyRenderer(this, 0, 16); bipedRightLeg = new PonyRenderer(this, 0, 16); - bipedLeftArm = new PonyRenderer(this, 0, 16).mirror(); - bipedLeftLeg = new PonyRenderer(this, 0, 16).mirror(); + bipedLeftArm = new PonyRenderer(this, 0, 16).flipX(); + bipedLeftLeg = new PonyRenderer(this, 0, 16).flipX(); unicornArmRight = new PonyRenderer(this, 0, 16); unicornArmLeft = new PonyRenderer(this, 0, 16); @@ -175,7 +175,7 @@ public class ModelPonyArmor extends ModelMobPony { .box(-2, -6, -2, 4, 12, 4, stretch); rightLegging.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) .around(-3, yOffset, 0) - .mirror().box(-2, -6, -2, 4, 12, 4, stretch); + .flipX().box(-2, -6, -2, 4, 12, 4, stretch); } protected void syncLegs() { diff --git a/src/main/java/com/minelittlepony/model/components/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java index 8aef37f2..1f669a85 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -20,7 +20,7 @@ public class PonyElytra extends ModelBase { public PonyElytra() { leftWing .box(-10, 0, 0, 10, 20, 2, 1); - rightWing.mirror().box( 0, 0, 0, 10, 20, 2, 1); + rightWing.flipX().box( 0, 0, 0, 10, 20, 2, 1); } @Override diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index dbf83658..69e2eaef 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -514,7 +514,7 @@ public class ModelEarthPony extends AbstractPonyModel { .box(-4, -4, -4, 8, 8, 8, stretch) .tex(12, 16) .box(-4, -6, 1, 2, 2, 2, stretch) - .mirror() + .flipX() .box(2, -6, 1, 2, 2, 2, stretch); ((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index b13caa00..77e9d76b 100644 --- a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -43,7 +43,7 @@ public abstract class AbstractPonyRenderer> ex /** * Flips the mirror flag. All faces are mirrored until this is called again. */ - public T mirror() { + public T flipX() { return mirror(!mirror); } diff --git a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java index d4beb59b..a1cedd46 100644 --- a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -1,75 +1,73 @@ package com.minelittlepony.render.plane; -import net.minecraft.client.model.ModelBox; -import net.minecraft.client.model.PositionTextureVertex; -import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.BufferBuilder; import javax.annotation.Nonnull; -public class ModelPlane extends ModelBox { +import com.minelittlepony.util.coordinates.*; - private TexturedQuad quad; +public class ModelPlane extends Box { + + private Quad quad; public boolean hidden = false; - public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, float x, float y, float z, int w, int h, int d, float scale, Face face) { - super(renderer, textureX, textureY, x, y, z, w, h, d, scale, false); + public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, float xMin, float yMin, float zMin, int w, int h, int d, float scale, Face face) { + super(renderer, textureX, textureY, xMin, yMin, zMin, w, h, d, scale, false); - float x2 = x + w + scale; - float y2 = y + h + scale; - float z2 = z + d + scale; + float xMax = xMin + w + scale; + float yMax = yMin + h + scale; + float zMax = zMin + d + scale; - x -= scale; - y -= scale; - z -= scale; + xMin -= scale; + yMin -= scale; + zMin -= scale; if (renderer.mirror) { - float v = x2; - x2 = x; - x = v; + float v = xMax; + xMax = xMin; + xMin = v; } if (renderer.mirrory) { - float v = y2; - y2 = y; - y = v; + float v = yMax; + yMax = yMin; + yMin = v; } if (renderer.mirrorz) { - float v = z2; - z2 = z; - z = v; - + float v = zMax; + zMax = zMin; + zMin = v; } // w:west e:east d:down u:up s:south n:north - PositionTextureVertex wds = new PositionTextureVertex(x , y , z , 0, 0); - PositionTextureVertex eds = new PositionTextureVertex(x2, y , z , 0, 8); - PositionTextureVertex eus = new PositionTextureVertex(x2, y2, z , 8, 8); - PositionTextureVertex wus = new PositionTextureVertex(x , y2, z , 8, 0); - PositionTextureVertex wdn = new PositionTextureVertex(x , y , z2, 0, 0); - PositionTextureVertex edn = new PositionTextureVertex(x2, y , z2, 0, 8); - PositionTextureVertex eun = new PositionTextureVertex(x2, y2, z2, 8, 8); - PositionTextureVertex wun = new PositionTextureVertex(x , y2, z2, 8, 0); + Vertex wds = vert(xMin , yMin , zMin , 0, 0); + Vertex eds = vert(xMax, yMin , zMin , 0, 8); + Vertex eus = vert(xMax, yMax, zMin , 8, 8); + Vertex wus = vert(xMin , yMax, zMin , 8, 0); + Vertex wdn = vert(xMin , yMin , zMax, 0, 0); + Vertex edn = vert(xMax, yMin , zMax, 0, 8); + Vertex eun = vert(xMax, yMax, zMax, 8, 8); + Vertex wun = vert(xMin , yMax, zMax, 8, 0); - if (face == Face.EAST) { // North/Front (was East) - quad = new TexturedQuad(new PositionTextureVertex[]{edn, eds, eus, eun}, textureX, textureY, textureX + d, textureY + h, renderer.textureWidth, renderer.textureHeight); + if (face == Face.EAST) { + quad = quad(textureX, d, textureY, h, edn, eds, eus, eun); } - if (face == Face.WEST) { // South/Back (was West) - quad = new TexturedQuad(new PositionTextureVertex[]{wds, wdn, wun, wus}, textureX, textureY, textureX + d, textureY + h, renderer.textureWidth, renderer.textureHeight); + if (face == Face.WEST) { + quad = quad(textureX, d, textureY, h, wds, wdn, wun, wus); } - if (face == Face.UP) { // Up - quad = new TexturedQuad(new PositionTextureVertex[]{edn, wdn, wds, eds}, textureX, textureY, textureX + w, textureY + d, renderer.textureWidth, renderer.textureHeight); + if (face == Face.UP) { + quad = quad(textureX, w, textureY, h, edn, wdn, wds, eds); } - if (face == Face.DOWN) { // Down - quad = new TexturedQuad(new PositionTextureVertex[]{eus, wus, wun, eun}, textureX, textureY, textureX + w, textureY + d, renderer.textureWidth, renderer.textureHeight); + if (face == Face.DOWN) { + quad = quad(textureX, w, textureY, d, eus, wus, wun, eun); } if (face == Face.SOUTH) { // East/Left (was South) - quad = new TexturedQuad(new PositionTextureVertex[]{eds, wds, wus, eus}, textureX, textureY, textureX + w, textureY + h, renderer.textureWidth, renderer.textureHeight); + quad = quad(textureX, w, textureY, h, eds, wds, wus, eus); } if (face == Face.NORTH) { // West/Right (was North) - quad = new TexturedQuad(new PositionTextureVertex[]{wdn, edn, eun, wun}, textureX, textureY, textureX + w, textureY + h, renderer.textureWidth, renderer.textureHeight); + quad = quad(textureX, w, textureY, h, wdn, edn, eun, wun); } if (renderer.mirror || renderer.mirrory || renderer.mirrorz) { diff --git a/src/main/java/com/minelittlepony/util/coordinates/Box.java b/src/main/java/com/minelittlepony/util/coordinates/Box.java new file mode 100644 index 00000000..c735c0bd --- /dev/null +++ b/src/main/java/com/minelittlepony/util/coordinates/Box.java @@ -0,0 +1,36 @@ +package com.minelittlepony.util.coordinates; + +import net.minecraft.client.model.ModelBox; +import net.minecraft.client.model.ModelRenderer; + +public abstract class Box extends ModelBox { + + protected final T parent; + + public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta) { + super(renderer, texU, texV, x, y, z, dx, dy, dz, delta); + parent = renderer; + } + + public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta, boolean mirror) { + super(renderer, texU, texV, x, y, z, dx, dy, dz, delta, mirror); + parent = renderer; + } + + /** + * Creates a new vertex mapping the given (x, y, z) coordinates to a texture offset. + */ + protected Vertex vert(float x, float y, float z, int texX, int texY) { + return new Vertex(x, y, z, texX, texY); + } + + /** + * Creates a new quad with the given spacial vertices. + */ + protected Quad quad(int startX, int width, int startY, int height, Vertex ...verts) { + return new Quad(verts, + startX, startY, + startX + width, startY + height, + parent.textureWidth, parent.textureHeight); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/util/coordinates/Quad.java b/src/main/java/com/minelittlepony/util/coordinates/Quad.java new file mode 100644 index 00000000..ea43f510 --- /dev/null +++ b/src/main/java/com/minelittlepony/util/coordinates/Quad.java @@ -0,0 +1,10 @@ +package com.minelittlepony.util.coordinates; + +import net.minecraft.client.model.TexturedQuad; + +public class Quad extends TexturedQuad { + + public Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) { + super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/util/coordinates/Vertex.java b/src/main/java/com/minelittlepony/util/coordinates/Vertex.java new file mode 100644 index 00000000..5ea593ea --- /dev/null +++ b/src/main/java/com/minelittlepony/util/coordinates/Vertex.java @@ -0,0 +1,27 @@ +package com.minelittlepony.util.coordinates; + +import net.minecraft.client.model.PositionTextureVertex; + +public class Vertex extends PositionTextureVertex { + + public Vertex(float x, float y, float z, int texX, int texY) { + super(x, y, z, texX, texY); + } + + public Vertex(Vertex old, float texX, float texY) { + super(old, texX, texY); + } + + public Vertex setTexturePosition(float texX, float texY) { + texturePositionX = texX; + texturePositionY = texY; + return this; + } + + /** + * Creates a new vertex mapping the given (x, y, z) coordinates to a texture offset. + */ + public static Vertex vert(float x, float y, float z, int texX, int texY) { + return new Vertex(x, y, z, texX, texY); + } +} From 9f705df9c5524afb34fc34f6ccb9840c5df499a8 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 21:23:26 +0200 Subject: [PATCH 60/96] Fixed horn glow rendering looking derped --- .../com/minelittlepony/render/HornGlow.java | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/HornGlow.java b/src/main/java/com/minelittlepony/render/HornGlow.java index 021dc45f..e5f2d558 100644 --- a/src/main/java/com/minelittlepony/render/HornGlow.java +++ b/src/main/java/com/minelittlepony/render/HornGlow.java @@ -1,75 +1,75 @@ package com.minelittlepony.render; -import net.minecraft.client.model.ModelBox; -import net.minecraft.client.model.PositionTextureVertex; -import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.BufferBuilder; -import javax.annotation.Nonnull; +import com.minelittlepony.util.coordinates.*; -public class HornGlow extends ModelBox { +/** + * Like a normal box, but with the top narrowed a bit. + */ +public class HornGlow extends Box { private final float alpha; - private final HornGlowRenderer parent; + private Quad[] quadList; - private TexturedQuad[] quadList; + public HornGlow(HornGlowRenderer renderer, int texX, int texY, float xMin, float yMin, float zMin, int w, int h, int d, float scale, float alpha) { + super(renderer, texX, texY, xMin, yMin, zMin, w, h, d, scale); - public HornGlow(HornGlowRenderer parent, int texU, int texV, float x, float y, float z, int w, int h, int d, float scale, float alpha) { - super(parent, texU, texV, x, y, z, w, h, d, scale); - - this.parent = parent; this.alpha = alpha; - quadList = new TexturedQuad[6]; + float xMax = xMin + w + scale; + float yMax = yMin + h + scale; + float zMax = zMin + d + scale; - float x2 = x + w + scale; - float y2 = y + h + scale; - float z2 = z + d + scale; + xMin -= scale; + yMin -= scale; + zMin -= scale; - x -= scale; - y -= scale; - z -= scale; - - if (parent.mirror) { - float tmp = x2; - x2 = x; - x = tmp; + if (renderer.mirror) { + float v = xMax; + xMax = xMin; + xMin = v; } - float halfpar4 = x + w * 0.05F; - float halfpar6 = z + d * 0.05F; - float halfvar11 = x + w * 0.95F; - float halfvar13 = z + d * 0.95F; + float tipInset = 0.4f; - PositionTextureVertex p7 = new PositionTextureVertex(halfpar4, y, halfpar6, 0, 0); - PositionTextureVertex p0 = new PositionTextureVertex(halfvar11, y, halfpar6, 0, 8); - PositionTextureVertex p1 = new PositionTextureVertex(x2, y2, z, 8, 8); - PositionTextureVertex p2 = new PositionTextureVertex(x, y2, z, 8, 0); - PositionTextureVertex p3 = new PositionTextureVertex(halfpar4, y, halfvar13, 0, 0); - PositionTextureVertex p4 = new PositionTextureVertex(halfvar11, y, halfvar13, 0, 8); - PositionTextureVertex p5 = new PositionTextureVertex(x2, y2, z2, 8, 8); - PositionTextureVertex p6 = new PositionTextureVertex(x, y2, z2, 8, 0); + float tipXmin = xMin + w * tipInset; + float tipZmin = zMin + d * tipInset; + float tipXMax = xMax - w * tipInset; + float tipZMax = zMax - d * tipInset; - quadList[0] = new TexturedQuad(new PositionTextureVertex[]{p4, p0, p1, p5}, texU + d + w, texV + d, texU + d + w + d, texV + d + h, parent.textureWidth, parent.textureHeight); - quadList[1] = new TexturedQuad(new PositionTextureVertex[]{p7, p3, p6, p2}, texU, texV + d, texU + d, texV + d + h, parent.textureWidth, parent.textureHeight); - quadList[2] = new TexturedQuad(new PositionTextureVertex[]{p4, p3, p7, p0}, texU + d, texV, texU + d + w, texV + d, parent.textureWidth, parent.textureHeight); - quadList[3] = new TexturedQuad(new PositionTextureVertex[]{p1, p2, p6, p5}, texU + d + w, texV + d, texU + d + w + w, texV, parent.textureWidth, parent.textureHeight); - quadList[4] = new TexturedQuad(new PositionTextureVertex[]{p0, p7, p2, p1}, texU + d, texV + d, texU + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); - quadList[5] = new TexturedQuad(new PositionTextureVertex[]{p3, p4, p5, p6}, texU + d + w + d, texV + d, texU + d + w + d + w, texV + d + h, parent.textureWidth, parent.textureHeight); + // w:west e:east d:down u:up s:south n:north + Vertex wds = vert(tipXmin, yMin, tipZmin, 0, 0); + Vertex eds = vert(tipXMax, yMin, tipZmin, 0, 8); + Vertex eus = vert(xMax, yMax, zMin, 8, 8); + Vertex wus = vert(xMin, yMax, zMin, 8, 0); + Vertex wdn = vert(tipXmin, yMin, tipZMax, 0, 0); + Vertex edn = vert(tipXMax, yMin, tipZMax, 0, 8); + Vertex eun = vert(xMax, yMax, zMax, 8, 8); + Vertex wun = vert(xMin, yMax, zMax, 8, 0); - if (parent.mirror) { - for (TexturedQuad i : quadList) { + quadList = new Quad[] { + quad(texX + d + w, d, texY + d, h, edn, eds, eus, eun), + quad(texX, d, texY + d, h, wds, wdn, wun, wus), + quad(texX + d, w, texY, d, edn, wdn, wds, eds), + quad(texX + d + w, w, texY + d, -d, eus, wus, wun, eun), + quad(texX + d, w, texY + d, h, eds, wds, wus, eus), + quad(texX + d + w + d, w, texY + d, h, wdn, edn, eun, wun) + }; + + if (renderer.mirror) { + for (Quad i : quadList) { i.flipFace(); } } } @Override - public void render(@Nonnull BufferBuilder buffer, float scale) { + public void render(BufferBuilder buffer, float scale) { parent.applyTint(alpha); - for (TexturedQuad i : quadList) { + for (Quad i : quadList) { i.draw(buffer, scale); } } From 3f32e2b19a18be86586fd320fe25a4c53c83ba30 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 22:59:19 +0200 Subject: [PATCH 61/96] Zombie villagers will render with saddlebags and all the other stuff normal villagers do --- .../model/ponies/ModelVillagerPony.java | 15 +++++++++++++-- .../zombie_villager/zombie_farmer_pony.png | Bin 6395 -> 6541 bytes 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index d213c682..46a5f2e0 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -1,6 +1,7 @@ package com.minelittlepony.model.ponies; import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; @@ -33,9 +34,9 @@ public class ModelVillagerPony extends ModelAlicorn { protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); - if (entity instanceof EntityVillager) { + int profession = getProfession(entity); + if (profession > -1) { bipedBody.postRender(this.scale); - int profession = ((EntityVillager) entity).getProfession(); if (profession < 2) { bag.render(scale); } else if (profession == 2) { @@ -46,6 +47,16 @@ public class ModelVillagerPony extends ModelAlicorn { } } + protected int getProfession(Entity entity) { + if (entity instanceof EntityVillager) { + return ((EntityVillager) entity).getProfession(); + } + if (entity instanceof EntityZombieVillager) { + return ((EntityZombieVillager) entity).getProfession(); + } + return -1; + } + @Override protected void initTextures() { super.initTextures(); diff --git a/src/main/resources/assets/minelittlepony/textures/entity/zombie_villager/zombie_farmer_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/zombie_villager/zombie_farmer_pony.png index 5bddac77b70e9f9ce0e590fa63fc39d9d1623d93..4bffbf0051c03faea854471af5e829dd63b63bc8 100644 GIT binary patch delta 6530 zcmV-|8GYvaF^w~jED4Vb{9y$E017&hVH|¬Af0RM!@V&%Jkgq0KN9DMRnQ4IsTY zsnSGYm>FOw0}eAZu_2-Y5k*7<6+wa`28@Oxu_B6vfMCHMkRYJMU=&eNc{8$Bbmir} zmzUokXMJm*z4tw5?|s&~0Fb=>xx92(3V<}8fFI)JN{@_+repg74DbL0%m84rGBbYy zLOsKPNIo8J^h}Wx_#y~^H+RG<05^@igXnbd|4Eva!54_q1c}&!&B6{c}T{8k*B#$jdxfFgg1?E(%fNyMfiCh@~U+(f(-030dtD~|t)1)Lm# z_)>1^8M%CJVv>Na%hIEp+1fJb-kj`IjzC}(#AKx~`E0sddRhjPmkYq+oj*%PTwA)R z$kt}I*49Sm#%5m?>c4LOO^JKENUwrF_Y9)-eX;$OUwS1Bq z_rKUQ4+0=5>RbE3SNEZb=OsxX$gndp$k0Z0NWPyi}G1Ly)HU=D16J#Ypdz!wC9 zFc1Y+0TxICX@C#1K|a_Bia-h20d|9GPzxGB6KDY^KnFMtE`ZD6I=FuUZi5G41dM~{ zUdP6d+Yd3o?MrAqM0Kc|iV92owdyL5UC#5<>aVCa44|hpM4Es0sQW zIt5*Tu0n&*J!lk~f_{hI!w5`*sjxDv4V%CW*ah~3!{C*0BD@;TgA3v9a1~q+AA{TB z3-ERLHar49hi4Ih5D|YGqJ|hD48#oyM52)dgpaI4ijhjB9%(_kkY3~_GJ;Ga?@$;N z1w}_0q3luKsO2aYYBg#dsuWd?I)Z9P^`LH|Mo}}UPiQh)32lJ3L;Ij3(TV76bP>7| z-H2{OUqatTkE7pUFc=y}2V;Zr#zbL~F>5fTnEjYm%z4ZpW(_yPPlex4vr&>=Vw!U)NPjf5&f3*i#sA>kE~NK_}<5`&3c;s#LehVB(qYnh(mm2EGMTJRb|y!Y1?27ICh|q{WAa-GiiEL*j|5v{y+n;f zyTp*h3rW1BmZXd1D#<*_O39Ow1CrBHcqwfuHz}snI;k3|Q&PiHv(gl4GwDF-H0e_5 zqtaKUCuOiQ+Ad zZ)z7C=rQzC^!DrB(1-P{ z^po^!^al)J18W1W!G425L$sl-Ayeeqo|%5^b{6 zq}Sw=sg-G}X@ltlGZ`~qvjVd&v)|42%~|F(=C>@!7M>RCEjle;S{hh#EDu=TwW3%B zSZ#l?>bCl5ZDY;1Zn2)S(X@%P*=IA%pfZ9OrHm`KXj@m?^|q&N-`QE)3G7bT{bp}u zpJIR1esZbKQqIzbrDG224ortShY?4*W1Qnb#}OwrC#F-q(-UV6XSQ>r^Ms3@OR~!` zmlv+4u6)-v*Eu&kx3zBP-4S;$_hR>c4;g=tWs!lhetO?&#v%Tv3tdMj8#lg%$=1wD|1#}U8T4xb=8?z z$yjFW$vAXeMBLH156nPjJ##kRCw^c249ktRhxMH8%&uThaU3}1oQVX7gz|*RM2Ey( ziBm~VNtH>{TsLkt_hqtoa&7WlN??D=;gp5ch}70JTv}Y(DV_{3h1Zj=lAe=3m|>7n zlrgf}ZuRcfGkiaOVpAd!m-U>o12RyiugstTkN;gZbfb7ZtdS@v2E|RPsQxwYbB;7l_eiaS*6#$ zG5eTu9enWavU5N9)I?I-1m1*_?_rJ$vD~agVqoG+9++s?NEPvZu?9}QpZSV zROjF+-&5UP_FZj18vl6swA$&KGqPvO&JxZRo?SSXcW(B4#`)~-lqcg5k#>8o~EPhDeN>$q-xy}i$>uk9zRpW6DZ``ZU>20Cxp z-sl=!I(T--Y3RaD_nUv0Z~5H1etX&N!8^J{_+2=_${t z8_!le8-Jehe15v28mBN3k!>=u0ch3gRK7Nz- zW`3^tt-{+Q?-=iT-$%Tkn9u%z{ZRE$?_<{|zfTVr(iRr}1p}D#{3Ul5bpQYWAY({U zO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF*m;eA5aGbhPJOBU=(n&-?RCwC$U3+X4 z#~J_4+}@hlCN_T<8)Ken!5GJcKpLDB7e!S>MNw515frQlnwm6eD+Q^FB80*bE|Qa0 ztyD*99#x_wv^o%dC>5fq2q`qeCD5iRio?T@*g40>7%&Du@8OyLakt0rJ@#IEd%NfP zq?7h`XCF7;@B4j^*_$E0zpmr}h}`i$1;Dml_&L-vw$OjcQNZ%aRmrex5r+e0^}V-u zFa~z&6Wwzzz4{u-=AMtZwr8au`h4Gioyy}vNLIq7C@>LX`Ddoj*Q^TKp>wYfUbp^3 zM(djp5T|5q06g*M<&Znx2LMFVztxmxc@VHTY+PDmZ2+X&u)2?FK4vSeVrGT)K@bQ4 zOxri4qTGMd0FY9#eE-LN`0TDCjUuZ182W2y${;$Kd5N%He zfnX4r@PP*>(+C1MFgya3-Kl;!5N{v2KVV$|B(wbf`)W`T-bUE^Q&GNJVMc)wYoLE>08k3DXdZZHm%Uv;?}5YUuc48T zReX5G%!(Lg8wE4~;6+71)hv*PI?&~HAk&lh^uZgz^}*Ko`wV41hooythA=Ny^LY7XuirpnOE}dhrK4`SEREEjhrQ5=e0g za7R&y?n_JJTkf1HV0bi^?iCrh2F#lSI2^aFt!z5j;0=4m07kHY8Tow1?uM~Yq&_+h ze)Sr-w-@ZQPOyKU0YBRb^j!faeA>?Y+Wdcng&rQ91cq*EcTOuR90pL7Xoi2!Z*hl( zvVfbzz?WZvloo?j&H`r503->RT?u@3IX(z(4uhzJKMPg`(~3&eEHHBXGs`MJ<5(b- ztYBmetji1b@uy&&T_Ac^JvOclA0$U%#Q;X;_PNdqa={F^J_wd51^{AQhOO%W(JX(k zaN}CT@^-VpV0Hk?1J)mBlQJ3apZn+r+qv?r%Ej~MfXuJS9uQJ2;V%BkQ@Z^h{k}kK zdmR#|6tr=rmbgxRq8YEC`RY`=h*8Q9Rf8Nrk!;?x)7av6bk;&4Byk7IPPOvK06Ym` zCPKpo5`e`3eiwDxB!CwHlmTc2phfDZx406=PHgOB@wYu8hz{j362#Unff;o=tzCd;oYEz_0V+#`tK|5cZ5RV`G5t#{`}flv1pH@_Uhe zn|8NE+7Uv)7z3p=!W2d`fN^P@<|U4Yv%K6h03HW0VlDu*#VAZG0x6pw9{|~OAY&}$ zc06oZMgu^pF&H)!JnjR4;qbTL184zImBkg`25>Kczng}D=FqbI0Pqm$y8Nr## zWnf)B!1zS+xgP%fP$5-~;;Yd7L+gvQeaY6u`kczW{Am3OJqmS%4A#Q&Il> zC5teB$)dP`Fbf1J38f%kUj$lv7l^j_laL9>>{$Ttn|$aqqe6etgb%Fa0x&X~8UtiI z)T=07+0F+5GC&N-jB=3cgW$JDfbj|NNd`g*xLgEMJS~($m6j;~`#WH(U_b%E%o(7S zGlA0L_yEY31=Pyd+h+;6JP>-nPsIkPoE3WO2hjV^z)k=k*)JmGn)eu{{9q94?g2k{ zQK`-MrNY1feh7cy7lrWqvlAy{rA!Sqq_cn z{R)y*{}_@5B%*g)_VP4(71&} zybx00^771Oxpx72;w$du=~#WC&q-vq@}C|&mtO$r#Rh+tO%2l!tNuae{1J+ExPbGZ zs9VQ`3&@p3&w-!-A}9Y&PDA;6-wkJgsUGd?O<0jiMK#<0>+DZI6X@(W2mr}wyys$f zOq)WWemyXxWBJMY;?l)-p2{Ga8U%Ign8xa(T|j5QZ~>+<5dqiHgo zd*`|yZ*`C*OZ_qifEC<8GNqa|{Y$psvI>aaJHvlTQWucVk*#dz5Xwa-8#&#*-tS81 zKJnVtR>x2O679Ei5I7ZluT`Ff7Fu9s_n1Auw-@XPxW3(JENY>7NdbvVM0pb0xSj^ ztAl?|?V{9`z*M%A0zg>Y)L}&NLP&vtAd!V98z&F|C;&<44WJ$0x&3eA&VEq}p7N5> zELS|u`Tcgi9-2wz#izE!9NW5eD*#~MzI`cQw@H>0H6$neep5Se+qP{Poj3QJp{W8} zpL{g00I-z{P$@nUaCws~=LHCM6;l8Z&+>nBpnT;R4+Fu{An5(qd!dayGXS-N)i=p9 z-`mij*?+?CkNGIl99p)OhtCyeZf5{A2ZLx12C=831A7}9h@$*>65dZdl7t16M$Q#t zV*q3-E%o(iY;6@9wtEn$C~@h*gV@v2!Bfawc$?dep@Rp7b_)Rjr*`cM(R&)c{M3K0 zT{t1jXbPVz#KJCMbaWJ#E?tTQd>^b@#b2S6zd|YhVAU#3z8?+*69#rovdqIie+BLgA*P}ns&nPH*DFGOiRIvyz|aGA`MJo!Kq#Vk@bIC7KGL( zim-sn_ea+d8~`Tv`+UAaPkT)T03jr;PcnJ;-FIX1cg63A{d!+ZeZ5oh@yh;a->*J* zZ$kq-k~G=a+KQtqSJF1O+u@NU8Nh^4yTuq_!)?l&{Qdv{ zhewh|+5-X34O+5J!~o_!V>y7U@fsX^?njaM6hHt#P!$J^dl?%F?;BOe5<)Bpfan;Y zv9%R#Za2J)ecssGI;d`=Z0{^yjKFD5Xi3>i{b!r90?STOK&x7 z`icwSoFktfwW!DQ<4Avbobi31moZ#^X`hnwD{(+@OHok_xZ48(u4EBHtmy)jz>Rn$ zi6iXCfzWWUG8Uk0Hv+47xLlux(>s3j;6Ylxc{2y_pvUF6%)Wo_&8CL??b9>ZwLu;89uID6&+EPsVu<5sZ(mygAkS=ZpmN_b6jrPR3IG@k0y`;xN&&zu o1?Yi506>TUfDi!yAr_MV11J5^{U8k8Ybq(KEoLKs3sKw?0p zK^lhm=6>$)dfxZ?zCYI4*FJm2Z|&bYYwwe6YOG5}!b}1H0GYm?mN{;O|06^Y-1C!) z>j-YZ_f$7h2Y{B02&`ESZqDhhXKn-l&nN&O4JTJPqZl;+hs-G^a}u(Mgx@+ zLI8l|wzsCHsi~Jg%sUC|5?20I0?#~g zv8x}L49{`WcFkvU5df1*%d~J+;8AI76>{sD4!|c&d91WrC}}O533-SFBpJ0WMf`PU zQX7%orw0evRiyvUo6`>LcF(vS1CU)So|gwP0A&r+?8hk;Z%{oqgKYzF5W5Rp5HPgT z>2z)mC!!o0`I=D5^#souAG9B4(~TD}g_edJ6W$=IY&Rle*7E_XqBpmhM5q{&6nG7? z#M;JF@|p8QJQ#UBdIi*}Mv`y4J||PbinLbd|9GX;mNa;~_Kn34w_UowZH8RB14&Iu zq|zP5B2-J%EjlR@FNHDkm|075X)r*m@5>NilguqgC7H}Yy~d6C1uW|kJ3n5q7FoVe zI*|87-(Y+tkcOH7#+EDgb9$~&{dDbqbpSrzCxB15V90aIangLMpqmw--@CMx!pu!- zYq!a~YkMmrBQ16H+Vm#q(EskjymlDVS%)WO!%gZ=)8!;H;4+&0@XcYWXd?-HOceO? z6YDmm0Klv2{Mo+uby659i6`T!cc!;IwzA5l%KIcm&2U6v@L7r3gX!r2jO)PJ4C%WlpOJiMms*aCT+xk@?8jrjCpGY9 zPyWjDLp6psu4w=E7_UJ581;cP!|A{{br}exhbNRpIIPCD4rsbSkZ{oee7}B{vp7mh zVkMt7E!gS0pZZ z)~FVTcJzW4CPqD5{6J(F`>L55NxujB@&$G13xf>oQgN znw8d>(vrS|ykox?`&x%hC#WpUOy11B&URW?hN&TGMt8of2Tiq(52Np-bd2%ScwZ@A z;a|y*Zjxk#l2xX+d<=EtmekLGmrp&aV#xBF)q_$xqu`TU%YjWKl5K`#WPqeOVOD6{ zY}_Mzkh*$Urd(on%}zD3Ahrsrzle)XA7g#5K) z6keZN7M~Z*HW61m&qqED-tw0L&-dZ`*?K&$sTz`Fw8S3YYRL{w3oTI4i7?3K+Ia4u zH^IZ@O}Ih1!MY)~!CPQB!+j^a@(bPp`4j1LymPAabbRfPdLIp9MO)M>bSgC6^e`Pf zPUaSq`cK~7Z@izdMm)5YEo~kuC@RPxSTh~=iuqNJ`7QInNm_3U@8}K74eE_slh#$W z_nW2cr2M3O3-Ai!q!{jh79`Rx!DzUe$yqSt3~4N(_lh>PjVkCZ`YOpyJs&){pEr~^ zh2w5mYN>>injya#GXSZybT74xuYYZF9Tn!exVzBH}o?% zoZlobB*!FoiFZlx#uQXtR!dozRo(2oQt@%reA9fs8d*{&-l}%yMO$%OUT|Y@>Is;wH6w0}xdc*T-^u8h=-0Zd@{=X3xirD4!YO?* zDAH!h98uqA5{(8PxjgEZ_L5+fGi%366S4=Nu@nO_u+LPLqzV>o+ z&32pgda`8sd3s)E>FxYch_teFu5J1c(ZJS@u5-wt*dfEnQQqU+9p_+FtlNrb%eM*? zCa(G=?^5fxCv$f{3C+Boc^I$$0AJ!RV_w6=%-9SI(!{p!UCUdlS=RUGUuV#AKTeW% zrl0KmD*lx|g4&th&JR8gt~`NZZLr{zO7hp_hR-0+P#K#Uz9>GFKEGovPi>{~c!^Q* z`Pk0bp_rW5mcv*FcO!eFb|ctN%CFq-n_uR_w*{I7`vp&B5v7^1;zOz8(I;24g=&Ek<=+u_MtAAM7VKC@y<0L$In)G`S7U zzB?zM1ZOkfzJ8XssgtR*1g`?$ncn^u<)5s{ENr=A`A2lA#8C5k^Y7;KfbaXQ`x8W~ zNkLTKx#_q&o;#Y&)-~7F)OEb{6Fx;2C$%MsrLj9z_Xvf5d-;u|-ogrz@jT7-b8(V3 zDiOt=965gEDJSs<(~Wt!>R~H}>_K|^>IUBqFLXx*!zcf+{VR5!bYW!@65KX z^vLOo`~x+ndZ|u)%ZYKzK2zOxZG~KKgl*0_pRmZ5RvS!Cyh~MA+%tUaeq;FVdml3& zTc7X)%R{+e=?#H))_v@D9PfKQ<1P|o$!J)V<=7XsW?yt~)JEi7wq9BneUcAh5TNrF zVO+wrR9Bl;WH~Feehc>bDK{;*+ZMC)d%nIcTEvaPQB+Q_Q6S3sqfp01`iA_=rHDDI zKKHWeR@ja4sPW?1iX(X!d7ggWuiW&#llh-!#^T~a(eL;@#$Tp9pbH8o4o?Wz6^<0{ zdM)!h*s7<=7}@K%>M&(hZ`0Ki9K{j7gpNX8H3Z!a8VuSa51?3hby~OQg??D4kaRo$ z>At?Zjr-F3H2o<}>40rLS*`hIbx8R}4QCn0N+`kChmx$_J{fT!xw$j$e^dG58%rPRJdOIzrF0 zvDKuJ#*v=l^NuP(gTIG|>eK2=zKb*k9oZkfzq$X{0t^48h6<|Ra+F8!HC|!uwPTjo*U!z z9wgB(uiu??j2&`B1zt8p%ee((2yO;zmkgYS`;?9z{-`hQfOqINSvZT2GW0x;4m=ZG zeYDiIACg0AyVtTOthyexe!YJ9_e1Tp3F4XnoPT)PIj}y3yKoW*=-CDW04e1^0&2L` z6NG!o1k<*GS@?UvLR_Cb00LaS{a|8#4`7@!ViIDK5)C9I{Qy8tsIR4N8S1oCGM~w+ zOZVBcr#I;f9|@;0iP8g4QS}#Ex&1M4O6%k`5ET;vr5RBQEj52I>z_?zAQ!_OE@L;M zF(U^=s17HW={0_Q=pVYQEN-qC4T<+F#d9h}(zSh!jhl^)i$5B&qc#gSEowW*PalPh zZzGjE_7CHv-K4@VzOoIh{Vwt^T^-3>P@Eq|E?hU@4OWKmlk%Z zBQa;b7wD@uFQ0J~HXuu2R~wP1qctIHF%{=FSBpQMg0r}4P`j}$Y5(~Qj&(f&l zdrKuFKrhKpzudni{?!U`N4aP*8jr*#&d_q?@T0Us?*GLn(5W+UJ-b=`Zm1ka#h2UY zGd*zd_YzJocem0Rh`v(!_T8vsPcTgB`d4w zvx5bt-fSdmMx$UFp!$$nfh?vaV0yf^=f?n}2r* zhXBul5$;V>C2kb~8kAyjLz~ow+jQlz6LHuU8JVa`+DC4jUs&{1Y_yK;gYSQ}8CP*k z{U2jO|G|1VT@{37^#j(U-m|p0p;w0@-p;gh6sxlSN|`j`)K~QLzjT$YGqWMd&{ng2 zonxu$Gw3pf&m@zOKIJvU{SFkil&~hV;VaAXufTVV|MCy7@Y%+f{Gi)tQ^G<~ZIor{ z^*7STPCa&oP_dH$S*jd&N^_Z^&eE?;RQSIw9>HrWF7}fpY2z3H2UG*jL<#`Mpsm(#^~`y z4G#a*T~RbTl7xo~Kb%1n9;bpVB}Fbf;6jV`1CIuH2jXq`tdhPHv7K^Yh%rA0xG>`b zpRYHjmJ)qzk^6WlkMJEq#;l0cjcAGjLl5lfUWgvzy`1r0o=VEr-6`c>GDm1?_{gd8 z-wbLIC5(QoyUis_z2pir2Ct>`Ss!2UrfYkti}v@jP>z#0k*?ru;eL0XwaLlsxFR}h z{Ji!^>`8}0$t?m$!?IM@74g72jN@G|SJ5S|T?zM(k{W-WJlMojH0B_5y18EHJh`>K z2ti{~LG3N;)RlvOt`82L(8;C|qeE#r8R@T`a5;(LC9@3My4~WC6$oHiSBOORo*`8T zPrYjvm*#;!X$YkT=I9`rv&ZHIaAT?fP8JoeUy6HQ==G56Wu)5FpzL&uB@X6K^594wBt7a0ecW)YSMm z2$?hWI})7bsUGh^)m$~p&0%=#?xa&FlOOKRH*O>DKF6ML6~3%QH^zBWLm`dvxW0jo zC*wbx1L&_uICPxeWI2{k?WL*IaGuQ%izDib;CgPrfUNV?HmiV#S1hzYVcCCIWi#48 zqpZWUtXv&6NpdqWOffc|JU$KWKaz#hMH{%|d%Sdv(8T)%uvrWH z;)Maze-^xO0My*X<3WtqYunr2A=&{;!0$e$GJfxC6-2lJuQN?$xWHgEZE_A+Ab<#V zCt%54;k3AmTMg{Xf0olyNc=H03yxU>Qs!eG`2%9H*nz!sX^~CDi+-cam@~)(*0qts z>PzF16ntSmvN+<{lZI@#lK5O>*b4M*#4W+Zh#FiL3EdNhc=1(5Irp8K2{;HrIgqTcYfr>RgIQv~5nVKP|QA7+YDV#lmsI3-eVMs{G5Nma_AId786db1*AKk_TO!fA4Id!gaq4{|pG>2;;7rSHH?scOD=V~3H$)99 zBS^*>-zcgVF&3+0s(=C4J0uiW%NQ%9SVqho`LEl2dt6ejwE; z*P7v2|CI;lAq8Z|$X$yb1ky5EVn4TT_<=NVw$vQb{PEN0GGBl&Rrf8=Rb*L^)vGQM5h|3Z2Ginz9jXSFGjmJ|c4_wk*P;`PDT%rvLqK{F5P^RMose$9oq3BGN zV`0cFUR51}PA1n4P9+GL{q0KvhItD-r#PPqm|n|N>nQI?%G{fi^#MLpBwuUJFjnyi zcp59pzWAam1okRt`QnE!`Vcxl4D|95tR(&>v0I>TEmTXLBX}XrU&4HM?bG)v$_2Co z)lqsJ;U6fPatkvqE~<}A)opo&b_)jm8r82&q(0x56~vd9$s43qAHq+^kai>7``SD+ zi*)vJ}pL10n{`b_%2i0a4gP98%{TjR4I+TP>X>Jk#QS zNor>(+W3E*S~mg_`V_M80qa0l2cft5j%v39CtsCosYLATuYAh!Y3i9dwpF?wqMHap z5IpK4Nje*_r@e`q6Pqu-oEzH$Q_DjBn@aHBqOxrT!rYHLw|9G91w|Raw#YA8oOyBQ zbuj}EMPJ+D1zaorze&Ag@oRT|vX18Z-Zb!#I?}y6O!<9c0Tv|`mAO{kD-Ak5?(XF@ zbN??OBa#p4gJ!3@=~$KHKD8_Gy}k(`%#ZHVRjOBn$+zgD_hC-X|2u*7)PN}?`Ho&X zGp6Oco6*gi{%JH~ee8K1-)6~mo><)A`5(6&58_VB;ewnA76#Y7#h%7-%&a|-X?D{y z-S_$*{av0Th5W9#i#wtAU!Ts?ms8-%)pV>lZ4pPCO&NqrRqblT8%xY)L9EEog#FeF zp7sQbP>tbt(+lY^{0l}Z3`cJEPS9YrV>keOX zo1`5Q*3o1+ppWnQ@A%b676{C>E%8XxPi*9z7*&^mhyI@xmA%?WJB)480TTRQ0G>i= z(5Jiroh5QhgeuE2VzXp`I(=lm$7I-HXqCQ9=W0&U*K^s$7ztvePc|w`2Le?8-cwRt z*x_AJ?w#AqQi9P5V8A$qw;*%*w@$9?3i&y1@W(N6x2eETkX@4m1?wm=uA_SOd{n{( zd>?UbVcJbwc1&{E|Dl)`oJPtzsxR5!{{K$iGL`Lc=q+EVTwJ44i@^=Tv&SM4QPAPY ztMdAlP-9#?b4DOtx?B7i2(9o5i|bQr6+Rav5^bQw>n3L`9${dt*7r2g{@E=GvVQ!}|VZ=ZlKva{bx)08~U)(OqHH2^^8#@8c@=Vxxo<95rAa{vuFJDwBc zcc2krWPaaV*8S^@u(vfM-StQTH5ax9A^)vK8n5>Npju*Hmah#SBfg(33;3skxY68P zb5P0@Is_AjWLX-{CJy0z%b8S8)*KvKOVf}%>j^BjHmCjcM-58@@$;g@L v2H^cm3l4UjM4=np6<3Ao|6y#%_aJ&YEaeniAcTkeZv^zUjkOvzTw?zZ&!OCu From 7fbc14ca0113222fc7574219cc8a132593c08452 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Apr 2018 23:00:01 +0200 Subject: [PATCH 62/96] Added a model for witches (current texture is a placeholder until we can get Zebras) --- .../com/minelittlepony/PonyRenderManager.java | 4 + .../model/ponies/ModelWitchPony.java | 72 ++++++++++++++++++ .../minelittlepony/render/RenderPonyMob.java | 7 +- .../layer/LayerHeldPonyItemMagical.java | 2 +- .../render/ponies/RenderPonyWitch.java | 49 ++++++++++++ .../textures/entity/witch_pony.png | Bin 0 -> 620 bytes 6 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java create mode 100644 src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 24950148..0f58ce31 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -12,6 +12,7 @@ import com.minelittlepony.render.ponies.RenderPonyPigman; import com.minelittlepony.render.ponies.RenderPonySkeleton; import com.minelittlepony.render.ponies.RenderPonyVex; import com.minelittlepony.render.ponies.RenderPonyVillager; +import com.minelittlepony.render.ponies.RenderPonyWitch; import com.minelittlepony.render.ponies.RenderPonyZombie; import com.minelittlepony.render.ponies.RenderPonyZombieVillager; import com.mumfrey.liteloader.util.ModUtilities; @@ -28,6 +29,7 @@ import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityStray; import net.minecraft.entity.monster.EntityVex; import net.minecraft.entity.monster.EntityVindicator; +import net.minecraft.entity.monster.EntityWitch; import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.monster.EntityZombieVillager; @@ -69,10 +71,12 @@ public class PonyRenderManager { if (config.villagers) { pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm)); + pushNewRenderer(rm, EntityWitch.class, new RenderPonyWitch(rm)); pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); MineLittlePony.logger.info("Villagers are now ponies."); } else { restoreRenderer(EntityVillager.class); + restoreRenderer(EntityWitch.class); restoreRenderer(EntityZombieVillager.class); } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java new file mode 100644 index 00000000..6eb206ac --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java @@ -0,0 +1,72 @@ +package com.minelittlepony.model.ponies; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.util.ResourceLocation; + +import static com.minelittlepony.model.PonyModelConstants.HEAD_RP_X; +import static com.minelittlepony.model.PonyModelConstants.HEAD_RP_Y; +import static com.minelittlepony.model.PonyModelConstants.HEAD_RP_Z; + +import com.minelittlepony.render.PonyRenderer; + +public class ModelWitchPony extends ModelVillagerPony { + + private static final ResourceLocation WITCH_TEXTURES = new ResourceLocation("textures/entity/witch.png"); + + private PonyRenderer witchHat; + + public ModelWitchPony() { + super(); + } + + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + rightArmPose = ArmPose.EMPTY; + leftArmPose = ((EntityWitch) entity).getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; + + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + if (leftArmPose != ArmPose.EMPTY) { + if (!canCast()) { + bipedRightArm.rotateAngleX = -2 * (float)Math.PI/3; + bipedRightArm.offsetZ = 0.1f; + } + unicornArmRight.offsetZ = -0.1f; + } + } + + @Override + public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { + super.render(entityIn, move, swing, age, headYaw, headPitch, scale); + + copyModelAngles(bipedHead, witchHat); + + TextureManager tex = Minecraft.getMinecraft().getRenderManager().renderEngine; + tex.bindTexture(WITCH_TEXTURES); + witchHat.render(scale * 1.3f); + } + + @Override + protected void initTextures() { + super.initTextures(); + witchHat = new PonyRenderer(this).size(64, 128); + } + + @Override + protected void initPositions(float yOffset, float stretch) { + super.initPositions(yOffset, stretch); + witchHat.offset(-5, -6, -7) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .tex(0, 64).box(0, 0, 0, 10, 2, 10, stretch) + .child(0).offset(-5, -5, -7).around(1.75F, -4, 2) + .tex(0, 76).box(0, 0, 0, 7, 4, 7, stretch) + .rotate(-0.05235988F, 0, 0.02617994F) + .child(0).offset(-5, -4, -7).around(1.75F, -4, 2) + .tex(0, 87).box(0, 0, 0, 4, 4, 4, stretch) + .rotate(-0.10471976F, 0, 0.05235988F) + .child(0).offset(-5, -2, -7).around(1.75F, -2, 2) + .tex(0, 95).box(0, 0, 0, 1, 2, 1, stretch) + .rotate(-0.20943952F, 0, 0.10471976F); + } +} diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 5dd8c40d..eb1326b6 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -3,6 +3,7 @@ package com.minelittlepony.render; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.render.layer.LayerHeldPonyItem; import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.render.layer.LayerPonyArmor; import com.minelittlepony.render.layer.LayerPonyCustomHead; @@ -29,10 +30,14 @@ public abstract class RenderPonyMob extends RenderLiving protected void addLayers() { addLayer(new LayerPonyArmor<>(this)); - addLayer(new LayerHeldPonyItemMagical<>(this)); // addLayer(new LayerArrow(this)); addLayer(new LayerPonyCustomHead<>(this)); addLayer(new LayerPonyElytra<>(this)); + addLayer(createItemHoldingLayer()); + } + + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical<>(this); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index e4f1b1da..3e371e39 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -28,7 +28,7 @@ public class LayerHeldPonyItemMagical extends LayerH super(livingPony); } - private boolean isUnicorn() { + protected boolean isUnicorn() { ModelBase model = getMainModel(); return model instanceof IModelUnicorn && ((IModelUnicorn) model).canCast(); } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java new file mode 100644 index 00000000..cdfd4e3c --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyWitch.java @@ -0,0 +1,49 @@ +package com.minelittlepony.render.ponies; + +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.render.RenderPonyMob; +import com.minelittlepony.render.layer.LayerHeldPonyItem; +import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; + +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.ResourceLocation; + +public class RenderPonyWitch extends RenderPonyMob { + + private static final ResourceLocation WITCH_TEXTURES = new ResourceLocation("minelittlepony", "textures/entity/witch_pony.png"); + + public RenderPonyWitch(RenderManager manager) { + super(manager, PMAPI.witch); + } + + @Override + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical(this) { + @Override + protected void preItemRender(EntityWitch entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + if (isUnicorn()) { + GlStateManager.translate(-0.1F, 0.7F, 0); + GlStateManager.rotate(110, 1, 0, 0); + } else { + GlStateManager.translate(-0.2F, -0.3F, -0.7F); + } + } + }; + } + + @Override + protected void preRenderCallback(EntityWitch entity, float ticks) { + super.preRenderCallback(entity, ticks); + GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); + } + + @Override + protected ResourceLocation getTexture(EntityWitch entity) { + return WITCH_TEXTURES; + } +} diff --git a/src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png new file mode 100644 index 0000000000000000000000000000000000000000..215d140060ac2ce9cb9b3e7d26a09349a8699960 GIT binary patch literal 620 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU^4b}aSW-r^>&t_-w^`=*J4pV z2WQ{IvO5@gg;*c4e3_E5R5$z)lZeTch3=0yJT|-yQdT_dB6adi-{Xq6H~c=iOIa4a z+4}rupY6=tduH;_-o3guVb8odvoCjlop;ZE-;B5YFQ=^6yn3o_)!*6MisFPd_kElF z_WQ4R<&yVJ6K?$wVA%9Gg<*+6!`aWv%f*%$%)7O3yM>@4C(KrbL59pFyfN`nX)>TiFLq6H+;!n3%CO{8f7L zIxx-QEQ8xkwqgm*>l^k?Hd(5A-6LCnlP811Pwi_fx0aWA8C5eJzs_HM?31l6H>(1F z&{gIgHC5&37^=*w8P;f)ai5(&Lxkb2l}N)EWwou`N9Ku|sISUmNYUw^Wm8`~^X~O^ zm+#zOwZ2~G$&-mi_K}wL0t|0?;)EOQG7V0p0|UI8TOs zHuGNT#j-HOeU1V}2^efhVTf^D78Td2e|+QL&rA!9OT+~PHRX+C&ler+czZu<>#Ls9 zrM)~}S@)m){#107m+$R-@dH6A=Q*Qh>4-I4mt||1+5NrxfKZyl{YaRZAUffi`a!$t z5)47zf4rV>$1PhIA7jGo^zX5Bv^+x=i@|GE0b%owUh4p4O%0FK_b>cdeSQCV{ Date: Sun, 29 Apr 2018 11:56:26 +0200 Subject: [PATCH 63/96] Move some things for consistency --- .../model/AbstractPonyModel.java | 11 +-------- .../model/armour/ModelZombiePonyArmor.java | 6 +++-- .../model/capabilities/IModel.java | 22 +++++++++++++++++ .../model/capabilities/IModelUnicorn.java | 5 ++++ .../model/components/PonySnout.java | 11 +++++---- .../model/player/ModelAlicorn.java | 12 ++++++---- .../model/player/ModelEarthPony.java | 22 ++++++++--------- .../model/ponies/ModelZombiePony.java | 5 ++-- .../render/AbstractPonyRenderer.java | 9 +++++++ .../render/HornGlowRenderer.java | 12 ++++------ .../render/layer/AbstractPonyLayer.java | 6 +++-- .../layer/LayerHeldPonyItemMagical.java | 24 +++++++------------ .../render/layer/LayerPonyArmor.java | 7 ++---- .../render/plane/ModelPlane.java | 4 ++-- .../util/coordinates/Color.java | 21 ++++++++++++++++ 15 files changed, 110 insertions(+), 67 deletions(-) create mode 100644 src/main/java/com/minelittlepony/util/coordinates/Color.java diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index da19d70b..c1b65f88 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -60,11 +60,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { initPositions(yOffset, stretch); } - /** - * Returns a new pony armour to go with this model. Called on startup by a model wrapper. - */ - public abstract PonyArmor createArmour(); - /** * Loads texture values. */ @@ -141,11 +136,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; } - /** - * Applies a transform particular to a certain body part. - * - * FIXME: Too long! Is there a better way to do this? - */ + @Override public void transform(BodyPart part) { if (isRiding) translate(0, -0.6F, -0.2F); diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index 3fac3c32..d2d0d5d2 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -1,5 +1,7 @@ package com.minelittlepony.model.armour; +import com.minelittlepony.render.AbstractPonyRenderer; + public class ModelZombiePonyArmor extends ModelPonyArmor { // Copied from ModelZombiePony @@ -24,9 +26,9 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { - shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); } else { - shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); } } } diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModel.java b/src/main/java/com/minelittlepony/model/capabilities/IModel.java index f1bfe006..99003a50 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModel.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModel.java @@ -1,9 +1,31 @@ package com.minelittlepony.model.capabilities; +import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.armour.PonyArmor; + import net.minecraft.entity.Entity; public interface IModel { + + /** + * Sets up this model's initial values, like a constructor... + * @param yOffset YPosition for this model. Always 0. + * @param stretch Scaling factor for this model. Ranges above or below 0 (no change). + */ + void init(float yOffset, float stretch); + + /** + * Applies a transform particular to a certain body part. + */ + void transform(BodyPart part); + + + /** + * Returns a new pony armour to go with this model. Called on startup by a model wrapper. + */ + PonyArmor createArmour(); + /** * Returns true if this model is on the ground and crouching. */ diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java index 234003b9..9381169e 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java @@ -17,4 +17,9 @@ public interface IModelUnicorn extends IModel { * @return */ boolean isCasting(); + + /** + * Gets the preferred magic color for this mode. + */ + int getMagicColor(); } diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java index f4f33ac8..6d467296 100644 --- a/src/main/java/com/minelittlepony/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -12,8 +12,13 @@ public class PonySnout { private PlaneRenderer mare; private PlaneRenderer stallion; - public PonySnout(AbstractPonyModel pony, float yOffset, float stretch) { + public PonySnout(AbstractPonyModel pony) { mare = new PlaneRenderer(pony); + stallion = new PlaneRenderer(pony); + pony.bipedHead.addChild(stallion); + } + + public void init(float yOffset, float stretch) { mare.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .tex(10, 14) .addBackPlane(-2, 2, -5, 4, 2, stretch) @@ -26,9 +31,6 @@ public class PonySnout { .tex(14, 14) .addEastPlane( 2, 2, -5, 2, 1, stretch) .tex(11, 12) .addWestPlane(-1, 1, -5, 1, 1, stretch) .tex(12, 12) .addEastPlane( 1, 1, -5, 1, 1, stretch); - pony.bipedHead.addChild(mare); - - stallion = new PlaneRenderer(pony); stallion.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .tex(10, 13) .addBackPlane(-2, 1, -5, 4, 3, stretch) @@ -36,7 +38,6 @@ public class PonySnout { .tex(18, 7).addBottomPlane(-2, 4, -5, 4, 1, stretch) .tex(10, 13) .addWestPlane(-2, 1, -5, 3, 1, stretch) .tex(13, 13) .addEastPlane( 2, 1, -5, 3, 1, stretch); - pony.bipedHead.addChild(stallion); } public void setGender(PonyGender gender) { diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java index f6fbceb4..47bf83f8 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -112,6 +112,11 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { return rightArmPose != ArmPose.EMPTY || leftArmPose != ArmPose.EMPTY; } + @Override + public int getMagicColor() { + return metadata.getGlowColor(); + } + @Override protected void sneakLegs() { super.sneakLegs(); @@ -136,7 +141,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { if (canCast()) { horn.render(scale); if (isCasting()) { - horn.renderMagic(metadata.getGlowColor(), scale); + horn.renderMagic(getMagicColor(), scale); } } } @@ -146,7 +151,6 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { super.initLegTextures(); unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64); unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64); - boxList.remove(unicornArmRight); } @Override @@ -155,7 +159,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { float armY = THIRDP_ARM_CENTRE_Y - 6; float armZ = THIRDP_ARM_CENTRE_Z - 2; - unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0); - unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0); + unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25F).around(5, yOffset + 2, 0); + unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25F).around(-5, yOffset + 2, 0); } } diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 69e2eaef..693a10a7 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -6,6 +6,7 @@ import com.minelittlepony.model.armour.ModelPonyArmor; import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.model.components.PonySnout; import com.minelittlepony.model.components.PonyTail; +import com.minelittlepony.render.AbstractPonyRenderer; import com.minelittlepony.render.PonyRenderer; import com.minelittlepony.render.plane.PlaneRenderer; @@ -23,7 +24,7 @@ public class ModelEarthPony extends AbstractPonyModel { private final boolean smallArms; - public ModelRenderer bipedCape; + public PonyRenderer bipedCape; public PlaneRenderer upperTorso; public PlaneRenderer neck; @@ -41,12 +42,6 @@ public class ModelEarthPony extends AbstractPonyModel { return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); } - @Override - public void init(float yOffset, float stretch) { - super.init(yOffset, stretch); - snout = new PonySnout(this, yOffset, stretch); - } - @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); @@ -366,10 +361,10 @@ public class ModelEarthPony extends AbstractPonyModel { setHead(1, 2, isSneak ? -1 : 1); - shiftRotationPoint(bipedRightArm, 0, 2, 6); - shiftRotationPoint(bipedLeftArm, 0, 2, 6); - shiftRotationPoint(bipedRightLeg, 0, 2, -8); - shiftRotationPoint(bipedLeftLeg, 0, 2, -8); + AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6); + AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6); + AbstractPonyRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8); + AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); } protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { @@ -383,7 +378,7 @@ public class ModelEarthPony extends AbstractPonyModel { arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - if (shift) shiftRotationPoint(arm, 0, 0, 1); + if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1); } protected void fixSpecialRotationPoints(float move) { @@ -467,6 +462,7 @@ public class ModelEarthPony extends AbstractPonyModel { bipedCape = new PonyRenderer(this, 0, 0).size(64, 32); bipedHead = new PonyRenderer(this, 0, 0); bipedHeadwear = new PonyRenderer(this, 32, 0); + snout = new PonySnout(this); } protected void initBodyTextures() { @@ -507,6 +503,8 @@ public class ModelEarthPony extends AbstractPonyModel { } protected void initHeadPositions(float yOffset, float stretch) { + snout.init(yOffset, stretch); + bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); ((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index e71c2bfe..94e80d1e 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -3,6 +3,7 @@ package com.minelittlepony.model.ponies; import com.minelittlepony.model.ModelMobPony; import com.minelittlepony.model.armour.ModelZombiePonyArmor; import com.minelittlepony.model.armour.PonyArmor; +import com.minelittlepony.render.AbstractPonyRenderer; public class ModelZombiePony extends ModelMobPony { @@ -32,9 +33,9 @@ public class ModelZombiePony extends ModelMobPony { if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { - shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); } else { - shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); } } } diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index 77e9d76b..88a0a715 100644 --- a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -80,6 +80,15 @@ public abstract class AbstractPonyRenderer> ex return (T) this; } + /** + * Adjusts the rotation center of the given renderer by the given amounts in each direction. + */ + public static void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) { + renderer.rotationPointX += x; + renderer.rotationPointY += y; + renderer.rotationPointZ += z; + } + /** * Sets this renderer's rotation angles. */ diff --git a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java index e767cf10..d7a03c04 100644 --- a/src/main/java/com/minelittlepony/render/HornGlowRenderer.java +++ b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java @@ -2,13 +2,13 @@ package com.minelittlepony.render; import static net.minecraft.client.renderer.GlStateManager.color; +import com.minelittlepony.util.coordinates.Color; + import net.minecraft.client.model.ModelBase; public class HornGlowRenderer extends AbstractPonyRenderer { - float red; - float green; - float blue; + int tint; float alpha = 1; public HornGlowRenderer(ModelBase model, int x, int y) { @@ -22,15 +22,13 @@ public class HornGlowRenderer extends AbstractPonyRenderer { } public HornGlowRenderer setTint(int tint) { - red = (tint >> 16 & 255) / 255.0F; - green = (tint >> 8 & 255) / 255.0F; - blue = (tint & 255) / 255.0F; + this.tint = tint; return this; } public void applyTint(float alpha) { - color(red, green, blue, alpha); + Color.glColor(tint, alpha); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 96ad02f2..4e394568 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -2,6 +2,7 @@ package com.minelittlepony.render.layer; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.capabilities.IModel; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLivingBase; @@ -33,8 +34,9 @@ public abstract class AbstractPonyLayer implements L return ((IRenderPony) getRenderer()).getPlayerModel().getModel(); } - public AbstractPonyModel getPonyModel() { - return getMainModel(); + @SuppressWarnings("unchecked") + public M getPonyModel() { + return (M)getMainModel(); } @SuppressWarnings("unchecked") diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index 3e371e39..c4f66f87 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -7,13 +7,11 @@ import static net.minecraft.client.renderer.GlStateManager.pushMatrix; import static net.minecraft.client.renderer.GlStateManager.scale; import static net.minecraft.client.renderer.GlStateManager.translate; -import org.lwjgl.opengl.GL14; - import com.minelittlepony.ducks.IRenderItem; import com.minelittlepony.model.capabilities.IModelUnicorn; +import com.minelittlepony.util.coordinates.Color; import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; @@ -29,10 +27,10 @@ public class LayerHeldPonyItemMagical extends LayerH } protected boolean isUnicorn() { - ModelBase model = getMainModel(); - return model instanceof IModelUnicorn && ((IModelUnicorn) model).canCast(); + return getMainModel() instanceof IModelUnicorn && this.getPonyModel().canCast(); } + @Override protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (isUnicorn()) { GlStateManager.translate(hand == EnumHandSide.LEFT ? -0.6F : 0.1F, 1, -0.5F); @@ -41,18 +39,17 @@ public class LayerHeldPonyItemMagical extends LayerH } } + @Override protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { if (isUnicorn()) { - renderItemGlow(entity, drop, transform, hand, getPonyModel().metadata.getGlowColor()); + renderItemGlow(entity, drop, transform, hand, this.getPonyModel().getMagicColor()); } } - /** - * Renders the main arm - */ + @Override protected void renderArm(EnumHandSide side) { if (isUnicorn()) { - ((IModelUnicorn)getMainModel()).getUnicornArmForSide(side).postRender(0.0625F); + this.getPonyModel().getUnicornArmForSide(side).postRender(0.0625F); } else { super.renderArm(side); } @@ -63,15 +60,10 @@ public class LayerHeldPonyItemMagical extends LayerH // enchantments mess up the rendering drop = stackWithoutEnchantment(drop); - float red = (glowColor >> 16 & 255) / 255.0F; - float green = (glowColor >> 8 & 255) / 255.0F; - float blue = (glowColor & 255) / 255.0F; - float alpha = 0.2F; - pushMatrix(); disableLighting(); - GL14.glBlendColor(red, green, blue, alpha); + Color.glColor(glowColor, 0.2F); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); ((IRenderItem) renderItem).useTransparency(true); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index af314204..dc4c52e7 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -6,6 +6,7 @@ import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.ModelWrapper; import com.minelittlepony.model.armour.ModelPonyArmor; +import com.minelittlepony.util.coordinates.Color; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; @@ -69,11 +70,7 @@ public class LayerPonyArmor extends AbstractPonyLaye getRenderer().bindTexture(armors.getFirst()); if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { - 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); + Color.glColor(itemarmor.getColor(itemstack), 1); modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); getRenderer().bindTexture(armors.getFirst()); diff --git a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java index a1cedd46..0d713740 100644 --- a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -63,10 +63,10 @@ public class ModelPlane extends Box { if (face == Face.DOWN) { quad = quad(textureX, w, textureY, d, eus, wus, wun, eun); } - if (face == Face.SOUTH) { // East/Left (was South) + if (face == Face.SOUTH) { quad = quad(textureX, w, textureY, h, eds, wds, wus, eus); } - if (face == Face.NORTH) { // West/Right (was North) + if (face == Face.NORTH) { quad = quad(textureX, w, textureY, h, wdn, edn, eun, wun); } diff --git a/src/main/java/com/minelittlepony/util/coordinates/Color.java b/src/main/java/com/minelittlepony/util/coordinates/Color.java new file mode 100644 index 00000000..915b910b --- /dev/null +++ b/src/main/java/com/minelittlepony/util/coordinates/Color.java @@ -0,0 +1,21 @@ +package com.minelittlepony.util.coordinates; + +import net.minecraft.client.renderer.GlStateManager; + +public interface Color { + public static float r(int color) { + return (color >> 16 & 255) / 255F; + } + + public static float g(int color) { + return (color >> 8 & 255) / 255F; + } + + public static float b(int color) { + return (color & 255) / 255F; + } + + public static void glColor(int color, float alpha) { + GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha); + } +} From 44ab17361317b1601be09583afc1f5b71ce33c98 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 11:57:59 +0200 Subject: [PATCH 64/96] No longer used --- .../java/com/minelittlepony/model/AbstractPonyModel.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index c1b65f88..205b6850 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -107,15 +107,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { return swingProgress; } - /** - * Adjusts the rotation center of the given renderer by the given amounts in each direction. - */ - public void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) { - renderer.rotationPointX += x; - renderer.rotationPointY += y; - renderer.rotationPointZ += z; - } - /** * Rotates the provided arm to the correct orientation for holding an item. * From dfb338e39dfc221eacbc02dcf884cc53a7f5f43d Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 14:20:13 +0200 Subject: [PATCH 65/96] Fixed snouts --- .../java/com/minelittlepony/model/components/PonySnout.java | 6 ++++-- .../java/com/minelittlepony/pony/data/TriggerPixels.java | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java index 6d467296..05c12fd9 100644 --- a/src/main/java/com/minelittlepony/model/components/PonySnout.java +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -15,7 +15,9 @@ public class PonySnout { public PonySnout(AbstractPonyModel pony) { mare = new PlaneRenderer(pony); stallion = new PlaneRenderer(pony); + pony.bipedHead.addChild(stallion); + pony.bipedHead.addChild(mare); } public void init(float yOffset, float stretch) { @@ -41,7 +43,7 @@ public class PonySnout { } public void setGender(PonyGender gender) { - mare.isHidden = gender != PonyGender.MARE; - stallion.isHidden = gender != PonyGender.STALLION; + mare.isHidden = gender == PonyGender.STALLION; + stallion.isHidden = !mare.isHidden; } } diff --git a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java index 6ab7ec34..15d403bf 100644 --- a/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -6,6 +6,7 @@ import java.awt.image.BufferedImage; * Individual trigger pixels for a pony skin. * */ +@SuppressWarnings("unchecked") public enum TriggerPixels { RACE(PonyRace.HUMAN, 0, 0), TAIL(TailLengths.FULL, 1, 0), @@ -25,7 +26,8 @@ public enum TriggerPixels { } /** - * Reads tis trigger pixel's value and returns the raw colour value. + * Reads this trigger pixel's value and returns the raw colour. + * * @param image Image to read * @param mask Colour mask (0xffffff for rgb, -1 for rgba) */ @@ -38,7 +40,6 @@ public enum TriggerPixels { * * @param image Image to read */ - @SuppressWarnings("unchecked") public & ITriggerPixelMapped> T readValue(BufferedImage image) { return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff)); } From 07f1dfb60bf83908ee05af142435da12cc5a6c26 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 14:20:30 +0200 Subject: [PATCH 66/96] Fixed smith pony displaying the wrong snout --- .../textures/entity/villager/smith_pony.png | Bin 4536 -> 4520 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/minelittlepony/textures/entity/villager/smith_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/villager/smith_pony.png index 49b580250e6425f20e470612f7dd14213c0d66a9..11edcae909d1f20e05329146095a80298f483741 100644 GIT binary patch delta 4473 zcmV-<5r*!#Bd8;gBoPE>K}|sb0I`n?{9y$E017&hIvamTiJg{rR8-d%htIutdZEoQ z6e&aRy$v9}H>uJ@VVD_UC<6{NG_fI~0ue<-1QkJoA_k0xBC#Thg@9ne9*`iQ#9$Or zQF$}6R&?d%y_c8YA7_1QpS|}zXYYO1x&V;8{kgn!SPFnNo`4_XT^B0GzjoyKE}SbXLTb{bpEJtE$k zCFF=0@fUGX7MGJP;#(rtOckbaMf_GAo5o>g0)T%aiR}UoD@nwrA|~;}Lfk~W6aXA4 z@hgu1iUph;f%sBx=^43vZeo&vuFKM+o7vhj=-!;{RE|Jk6vSkuF!^k{TY6dsla~v? z;+;QBMqFFEsL0l4w$|20=Ei1U73#lk{!NK{yGXBsKlcox^?kAZm0x;20E}5tZFYRI z#qWOwpkp%t^7p^kG!FtGDe7DMz*qO7iRUFrAjq&YG0D!(Hs*3z#^Qqhq5tXdH}uu_ zjK%5xC=cD8lfV?F3h3gxvC>o1g?xHu29w318~u5R|8d}7pTjVOlfdC~c%q1K(Ufs{ ziK2G%*jxcOok!>L{!(Kmm5 zI1s5m_f-n#TRsj}B0%?E`vOzxB2#P=n*a3EfYETOrKoe*ICqM@{4K9Go;5vV} z0d9i_U<8bV=U@iB0rL<9VIeX^ffOKBNDDH6%pnHk2zfyMPzV$S#X*S>4-!K8&?cw^ zDu=3}I;aWy9y$eGfUZJ=&^>4rnu30Z-opq?f~l}FtPPvM4A=$sgTvsJa3Z`K&Vvi# z?Qj)b4O~2}Gii1cZ;QLyD0~q#kKOx{zMv zCNhFdBkxcc6a_^`8KLY^-l*j$7HTzW9jX*njXHvANA;j?qDE0Os847zS_y4{wnO`% zBhiWIY;+O265WVyLtjGQMvtT4U@#aOMh9bq@y0}9k}+#ArI`JgR?K9j^O?D{Qg|tCDK{ym)H7&wDr6*;uGTJg8GHjVbnL{!cWyUB7MT6o-VNo_w8Yq94DC1NNRfpN`iSTS4ifZ`>^=_S-9_DfhxikF;N za$gBn(pL&mTBCGGsZW1tR#`>aOF2V%ukuCZX%(7^vr4i`h00l#DOHN9qbgUmLiL>L zGrBC@g`P^UqW92e)Rfe`)r4wwYW-^S>N@Jn)eF>H)gNgPG#DBQ8WkGd8Z(-zngN>m zn$4Q`weVUDtt72ITD@9x+B(`1+FP_cv?q1sb$oR4beeS@>XLtTope|0*6ZHV!{{;e zQuOxg-Oz{it@M-hYxD;UU;}FduEBnTK|{2mts&2_-f-B6WaMI$Wz=jmYD_csH!d*l zFn(d8X%cO+)1=qrlc|+ys%eAi12Y*jU$X+UF0n%DhURoMh zax4#6-nF7w1z3M=vFf(^Xl-N7w{EeXveC4Ov)N}e%%C!Y7^RFWwrE>d+x51mZQt2h z+X?JW*!^a2WS?Sx)P8cQ&Qi|OhNWW;>JChYI)@QQx?`N`84^=_}cic_3iN^`Gxvb`#tg3_via}1;7Em0lNYoF4J1Z zTh0(}B^1wIPW30fWWV=yK-D7Ys0X^2@!en@X9B{VklXy}_T*RZm%2g`Mr3zv6? zONPgUH-&%CMYuc#Ks{QOuo{IxBNl zUR|ZQDs|PFSjkvs?8!KETtwW_xDU)gW<7H@-Y0%v{0z&DwTJbb?aZ!VPjMVL<(!EG zhlKKk$wY_5U5QgkPDzzX(_A-hHTPw*cXDm=TuOgn%HfoS)QHs9G+bI-+9{q4FNN2W zu9BXUKA2&UQIs*V+HUpk)iZoQeq$z-xiYg;Ko$K=^$B%_n}wrUj#)KXZ?nU*Pv%JH z@N)Wc^>er7PULy!eY*y=hP9?UUoC%Q{^(klwRP*Db@A)E*K4dVTtB|SYr~O^gpDa1 ze=2`4EhsN|y(wZ-SD|v@hQhJUUYnbXB#QV&!&~gP)NVy>YIh_3ETV2tjiAU!0h1dxU-n=E9e!)6|Z;4 z?!H=SSy{V>ut&IOq{_dlbFb#!9eY1iCslvnu5qnt-KVr~+rGK|?EOOroDa0rD%Y0O zzCXx4c(=~0uDxEnzVZ;}P}ZTR4dD&F-!i^!YE*12Y5aJYcX;GT$dR5Vo2I6tN=M6@ z;bvj;)UlXjH@fP?@5`Tzg`fam}Kbua(`>RI+y?e7jT@qQ9J+u2JJ~i zK~#9!?VV3-6lEC3pKrSqvMGOPNu!}{3XKp5LM0X{9uSpH2ngjM93&nD4qi-+S2QIy z#)BLTB@sy!;{^_QVJ$SoMKmM=#u9ARfRGfL-BxM=wRMaAv!4e#%g*ln+3n2i%+5T& zWYgVm-r3px-e=zT{oc;*il4to$fh^ygb)H!O60O*{lfe~AJJTM6aas4YoH%X8X7a> zw+8w%_qE2e$ISLI+TPx^OIUgRR{axtX6*_9&~!fWKOwnlRB#&Hqhs4iSC1bq#3*+8 zzUFvqOEo=ck@l`#-WEXY@_oFuZ;xv1YH#n%wjPS0%n282s5qVYQ~(;)q&Riyp0AxB z8lSTD`Ia;^sw#b7M1X(RmTJT<_xQ60n4D$=Fjz;*9qSjW9R0+K1pt8IYybG-&8I^l z3ZNL{8#faGfXA@FA1NSA0fgWC{1-!m5B9Cf++Vh|-d_=5UPVcd=fxT!obBMCMF3J{ z3h-M5AVmt`voCM^qxvVa6966WKUfAc0ua55JsYFz0IaaL=_7w>^t@)rZLT?r@7{Su zHTL4ir!{T0>=*&coC9yJ#rf17Lq}_kolo7tfo*GN9|0z(fGdeg3=a=u`?|-A-hW~e z`2DYH+`W4j8&`NwhZnD0C@3=M?K3oz$lQPa*$s}rUPS~iMV{0ZLAD)|7E-|3t0`<= z6G6+837j4Y;oE;-C-L&ra|+)7?{VPbwSQ4r`Dnj0J)_v#Jl`|U?;h;byijIKZJX|; zQ-$oasHWcD7n=l7r*^O+0+qAta`vlxI6f-@Y+e&Vyzf7ZkB?*fy2lY)+J>)>cK`t5 z@i-3c->JD@Y-t*}qiYRSB1o!jZL7ZG@p!>@$`!~$1n+v( zsq{pPgtRSkWSpDjVAYtGUDlZ8KESzUf8zVz6rxR$%$VHW4&3b2wNo6gWfuelgsrJa z%ei`XxqSs&8bKR}e?Z6X_Pk}{oUpkaaTm)eK&gND&+UC7b8EfXndf{xJFl>)rrvOg zXBS&)+obJFK?~Rt0koEVzYU~Rk5@KCbeD%g$L{uW$pxV0{FMz6(=p+EN|pj|EQ*yl%SIcB&XG zcFlipw4W;i$Sw4=xH0%Z^@hwo&wlFCy`t=$QN=VuX#i3J(-No31nNi@VQu4J5L(fngw>yoKX&4*;S=nAZL_VH>IxwYk0+%p zt4o7RJ%72_^8Em-n^tR%_x1L{Zs#v=Tx@DnZXzhv{FQYID8%^yu)J}xX_O!~M*ugt z-hVsK@gyJuxZZy|FV`0uAxIgffMT7?G~nZ9pw`*1RR6hYfs`l(l%juH^)qhHpXEM4 zsZ)Sn1SrOilyM3m0Te)Xe%CATc=iV*0vtSiBu@m2^A8?ALXY~j1^|Fq*O|;%>$a_# zvs?%vbGIpxgDy4?ub#dEkjonvOXY8@>rCcxu1)r~TpQlBZ=R0;xw$>N*^^xt1_4Yab$rq<7 z_xWQ4U|}QvB35Loc?^f+3)6={pjM2!3Te3eSD|qzpTC=Ko30! zmFgEc-9EmR`DYElB9Kr3gaRNG010XzpxoENrK+~QdVDMM@A~xsJJv6hW|M2Q4!7z! zv*&jD_)hl;m;wj|Kqvr00T2p+PymDiAQS+h00;#@C;$q8Q$PU_3V=`mKBXco4Ifhg zK4*GL7(S)|NT4xs{rdrej@$Fk2*4CTC;&nMkbo9}EXLf&&H4Wy!HJa1O#NfX9ECg=&G)6WaQ%IoKQ}x;p1$Z!c$8cP9Y+CQ+scGt*TT zCH(9@OfMSwPS4APnS#><7Kda?ocfq9!DLIHcJp z@wOfXk_o5=yn*EbRV@e-mBwcZvPpnlkD~()7>NKo{ufIl0Es$E4}<`lcU;Vn>_otM z$thX`xF~>OVtHvvf?u@!qFTm927 zONL6({o3mVAUl!yV%ohkzkb@X{(hM^7}^ISYfWV5+zt*n!s0;jV^sit`-BV;gvHQT zkP2i-55mVATO=;`sj{EpZHZqb*PPw@x88s~XKCGUl5lN|kO?cLYUy*lugGTdQ$DPH^Z3)T54#|U@3jzg`b zAQR4*@yQ#Fj8}V-x!f_Zw>LX(44*%opA$YIR-Tgv6_1o5fr%mo_Z*22_4w&6eVXU- z0PNOzwfqpEAV#``{T}c=-&Q%(&b|SV&N^?O0B~P}SJbQ?W7 z93&;8EaAdDqm1#F#OMQ~)!Sux8DrEX`D+u1bSgia4KogF4SSmKtO^%qO2M!2Bz>QJ z=vGB8_fD8os4HRtwa~V3Yk_@%Yu5&fa!`Hp`N(u$z@+<;?&U@LMX5zHr!+}5^G_Kj zGX*(j4ASw|u+kiiNx5-U!6m6@8FGDLEIN9*r5}?=uDGze;9bjCe7-TvBwxFeI%qN6 zv#Pz4x#2~S2SBhWxi+LV-{a{-!!;P%lwupu8{IaO0jtn%4pq`-4s!% zP!LswDDW~<`5a<(7DHy$rr&0${@FOY@&T?M%Sq*U8SN*`oE!|rdXp_Bn&MM@%v?oXJeeO^$3*@Kng~ZM>ZQq=~$(|>rUn}8c z>sFMKnqpZDFE%dLUT=^o+ssGhHE7mZorKb=b?Wll@@pgF`$xa)@v4PTO2RW1M7kP#7D-*#iwVm zX0VlEVo;lRGfzQZLBF%Fx9?-$Xu5Q!lEj$ga^`a8SmxXpJ8M5{VN3z$tCLREf_0wN z7N*`a!dlKM*V5ej9$KpuReEEzuCy+nA;0!c(w*Y0QAAtC4(2c% z*dF1)iulq|*0z<@kQDqa`1P3*IZf0AZ83*6N66D^ZzlP>^0OKJ@3&NfJN8pn#SoSQ z^aJC!aF|OyH``rNrkNw!2v$Vx)3CkhxEQ^cJ))_~qM7X2nXZNfU7v#|_kITqAD}YP znXQ`zQ{`JSTdrGC(;s@JKHSW*y7hFhtxNrv@#2sQ)rVwpx4DuKLv_PYM9ngfn4?&t zMd?_@mt5Z>y!|$-@}aW#2b?laQFc~x*6Km8Z1b0{FFl5BURe(!=G0&CoIgAdI3EJ} z$Quv@aZIRMs14D{Q9uw^(;F4}DW}7#iA}Xv*|loSYVj{iUoN(ka=CPEB$RUDm(%(a z`(0@xj6zmM2g&W1?Bm)(sQDwJA}k_R-aL-ByfP$_D(yQot^RaQ{(pOz>~9e2H}a-xD|GM?^@bElhoQS+#IDqJ9InpoGp z$No9}t@{!AEQO+s!tyDq`q6i8zx$&`FId3x>c;LR-y3hB{;eFX2yU?Y?c{^_93NO}%^A{%6>(l7ZWXfl;WIX5ekW`XykO+I5nD7Kv#AT3# zL98K`oS*lUI7L(uIy~dPh+Ru2|L%rPC?T~Hfns2JD`wULV}j&W2qz2YroNbNxs>88 zp}x&tboW$(?ECEx=bMbJjKAMvawGLDL^v#$8cH6?RVhC4pMv6;NrfWsl9ecajl~Fh z{4^}yv`8%rY2XVma0|WP(*3ff2I96(We#182wtBa+q`FJDP}cSWB)f2#jea86I;eK z#hS|eVq9R_Z;?I9tGg+E`dxKlaeM8<0q0@o)umaHEF0RCqSU2ST2GpZ$!eOpyVaWq zhniDjseJ-dbzvCw+D}c2U+bOnzxVeksF-~=+c*1bCbKm>Q)54NnVDPU2zWGjbkU%vkM@pB%$V zW+w5YLhIVJo!1))sBK>n8W|e%*YC0OJdZW}7gq6N?$fDMc%P-95AKu9K@TN0Jb`1FulYsNfLM z<7vC8kC?z^$NsrTbY9!v=zV?~~7 z-%~f?%fD4xZ&?3eUv*P$LVYIcr-}_>dVG8O#iM55?7g9BZ9G{-*Z?8%Af8U0G(J7P zCz2*|J?plzoZP&M_u1-czWTt!0lq9&!bd_+87qre$kEUBvHqd7p`6s+)TAblpxm>y z=Jm_vQ`lDQwZ`v$w|bTI!U>2gxiISFyv z-l^j)k*SM+lhYAyVgNwEjf+1t41nYF3tR=@nK%Gzb^yqy0l@0@_Cbdh0Ax5F4K*{r z$qkf&JChSz=Q;Wwbb_h+^U$D7gcb!!4r3e>U351eNw_yXEh8NfxmX@nD1(t5r$!t3 zHkvnfhlsqsg5}CQ_Z3EnBPHgMDjeG9DO7`;{MHe&u^!rAg+`Unq)#0GJ%3A6x2=dq z2Y)zM9N1It?blU#k;rJ^^+RXSuJdmM5hSm6NdWvBRaHrml3K!g(d;j06~A7Nzr6YB zOGATO>cho7n*+mz^co@6Ry~c9E6KNMwuUMk>^+bwQc8E1B+bHj6z5;56}_Zz+noW)luq=L1p-ebI@;)&YAGP-xDsXK z!pM8bK97yIvnPA@i*|C+cebU-HGYaJb*!!nP)kUQl96ZPYxj#$R?+2!b zo>fndANO)x9minyDa7SSZFS5Y{QTIa#+2^w6D}n+Z@)0dZOzn;e{BtvulHMgS=g0b zGcX7j#Gf7`WN#Dvofztw0!>Uwj-SJA;1EQ)bA`VFwTK?y;{e{5UN2DXJ%$4k4d-*X z<_@>>k5#)vA&3C2${PPh#QQm=@xp+d-jqq1KD~?~a-nNhw^g)mVBdL4RL z9C-WwTOd;&!!?1wj_vHM44%Qkg+1EFIu!u;{*W>1aNBG~tg@PBc!$=^+&rhQj{Snt zFcge*mx=Scq_`cV#J|q9jn2gwP`~~h%c55KEQPyvl5%xRf2p(F{E*#pv%ZbyvBBGM7NT}8yt(Obd{FPn4(kIMw|&n(dnRE7kZa?; zNi^kxSlrI-`JJN;4(APCod7>^!qjgf0Pyi+kX=7tjo zD*OAC=D|%xSkbaSqOLKT< zdau|;Z2Q*pU(We?s0}~qI&n_5Drx3IIg6gMigG(W9v9pnx|Q)6Ww-R({EytVr#rl% z2||RYfe*Trti7K1dpD+_EG*4T%j??FaUwMyt%teUr0y}`QBUI>nPlvk5W7Q0Pg{kf zZ(!{PkWQT!qsJMkLuR-}vpW%#+QC@}5%u|mD znVhqhs0w^N!PjD@YPiq5{p(p-PF4=UHbER^)`4>N2?{sG``%j2uH)fjt9!V}tk~ z-CTktT3r7IoLoI$iW@l!Ca^)${`G)ynA=E{FS^D-xH=f*H_dtO*ZFIyeDibs6Ivd> zy?=VLMgZ0>as{?cU8{#XrM)U{fF<<5j=?QYK*$5~)Z)p*wTn{I`WW$sWs?z`LD{VQ zbP?{=?9?hwVTRuh`v3jC1NnCmNZ!R33 Date: Sun, 29 Apr 2018 14:22:26 +0200 Subject: [PATCH 67/96] Refactoring for refactoring's sake. I wasn't happy with how things were split up --- .../model/AbstractPonyModel.java | 586 +++++++++++++++++- .../minelittlepony/model/ModelMobPony.java | 54 +- .../model/armour/ModelPonyArmor.java | 5 + .../model/armour/ModelZombiePonyArmor.java | 9 +- .../model/components/PonyTail.java | 51 +- .../model/player/ModelEarthPony.java | 574 +---------------- .../model/ponies/ModelZombiePony.java | 8 +- 7 files changed, 644 insertions(+), 643 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 205b6850..37a75d72 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,14 +1,21 @@ package com.minelittlepony.model; +import com.minelittlepony.model.armour.ModelPonyArmor; import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.model.capabilities.IModel; +import com.minelittlepony.model.components.PonySnout; +import com.minelittlepony.model.components.PonyTail; import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.PonyData; import com.minelittlepony.pony.data.PonySize; +import com.minelittlepony.render.AbstractPonyRenderer; +import com.minelittlepony.render.PonyRenderer; +import com.minelittlepony.render.plane.PlaneRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumHandSide; @@ -17,9 +24,10 @@ import net.minecraft.util.math.MathHelper; import java.util.Random; import static net.minecraft.client.renderer.GlStateManager.*; +import static com.minelittlepony.model.PonyModelConstants.*; /** - * TODO: move this into constructor and make separate classes for the races. + * Foundation class for all types of ponies. */ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { @@ -46,10 +54,341 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { */ public boolean rainboom; + public PlaneRenderer upperTorso; + public PlaneRenderer neck; + + public PonyTail tail; + public PonySnout snout; + public AbstractPonyModel(boolean arms) { super(0, arms); } + @Override + public PonyArmor createArmour() { + return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); + } + + @Override + public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + + float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; + float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F; + + headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); + headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch))); + + updateHeadRotation(headRotateAngleX, headRotateAngleY); + + float bodySwingRotation = 0; + if (swingProgress > -9990.0F && !metadata.hasMagic()) { + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; + } + + rotateLook(move, swing, bodySwingRotation, age); + + setLegs(move, swing, age, entity); + holdItem(swing); + swingItem(entity, swingProgress); + + if (isCrouching()) { + adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); + sneakLegs(); + setHead(0, 6, -2); + } else if (isRiding) { + adjustBodyRiding(); + bipedLeftLeg.rotationPointZ = 15; + bipedLeftLeg.rotationPointY = 10; + bipedLeftLeg.rotateAngleX = -PI / 4; + bipedLeftLeg.rotateAngleY = -PI / 5; + + bipedRightLeg.rotationPointZ = 15; + bipedRightLeg.rotationPointY = 10; + bipedRightLeg.rotateAngleX = -PI / 4; + bipedRightLeg.rotateAngleY = PI / 5; + + bipedLeftArm.rotateAngleZ = -PI * 0.06f; + bipedRightArm.rotateAngleZ = PI * 0.06f; + } else { + adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); + + bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; + bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; + swingArms(age); + setHead(0, 0, 0); + } + + if (isSleeping) ponySleep(); + + aimBow(leftArmPose, rightArmPose, age); + fixSpecialRotationPoints(move); + + animateWears(); + + snout.setGender(metadata.getGender()); + } + + protected void adjustBodyRiding() { + adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); + adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); + setHead(0, 0, 0); + } + + protected void rotateLook(float move, float swing, float bodySwing, float ticks) { + tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks); + bodySwing /= 5; + + upperTorso.rotateAngleY = bodySwing; + bipedBody.rotateAngleY = bodySwing; + neck.rotateAngleY = bodySwing; + } + + private void animateWears() { + copyModelAngles(bipedLeftArm, bipedLeftArmwear); + copyModelAngles(bipedRightArm, bipedRightArmwear); + copyModelAngles(bipedLeftLeg, bipedLeftLegwear); + copyModelAngles(bipedRightLeg, bipedRightLegwear); + copyModelAngles(bipedBody, bipedBodyWear); + } + + /** + * Sets the head rotation angle. + */ + protected void setHead(float posX, float posY, float posZ) { + bipedHead.setRotationPoint(posX, posY, posZ); + bipedHeadwear.setRotationPoint(posX, posY, posZ); + } + + /** + * Called to update the head rotation. + * + * @param x New rotation X + * @param y New rotation Y + */ + protected void updateHeadRotation(float x, float y) { + bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y; + bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; + } + + protected void setLegs(float move, float swing, float tick, Entity entity) { + if (isFlying(entity)) { + rotateLegsInFlight(move, swing, tick, entity); + } else { + rotateLegsOnGround(move, swing, tick, entity); + } + + bipedLeftArm.rotateAngleZ = 0; + bipedRightArm.rotateAngleZ = 0; + + adjustLegs(move, swing, tick); + } + + protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + float armX = MathHelper.sin(-swing / 2); + float legX = MathHelper.sin(swing / 2); + + bipedLeftArm.rotateAngleX = armX; + bipedRightArm.rotateAngleX = armX; + + bipedLeftLeg.rotateAngleX = legX; + bipedRightLeg.rotateAngleX = legX; + + bipedLeftArm.rotateAngleY = -0.2F; + bipedLeftLeg.rotateAngleY = 0.2F; + + bipedRightArm.rotateAngleY = 0.2F; + bipedRightLeg.rotateAngleY = -0.2F; + } + + protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { + float pi = PI * (float) Math.pow(swing, 16); + + float mve = move * 0.6662F; // magic number ahoy + float srt = swing / 4; + + float leftArm = MathHelper.cos(mve + pi) * srt; + float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; + + float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; + float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; + + bipedLeftArm.rotateAngleX = leftArm; + bipedRightArm.rotateAngleX = rightArm; + + bipedLeftLeg.rotateAngleX = leftLeg; + bipedRightLeg.rotateAngleX = rightLeg; + + bipedLeftArm.rotateAngleY = 0; + bipedRightArm.rotateAngleY = 0; + + bipedLeftLeg.rotateAngleY = 0; + bipedRightLeg.rotateAngleY = 0; + } + + protected float getLegOutset() { + if (isSleeping) return 2.6f; + if (isCrouching()) return 0; + return 4; + } + + protected float getLegSpread() { + return rainboom ? 2 : 1; + } + + protected void adjustLegs(float move, float swing, float tick) { + float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; + float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; + + float spread = getLegSpread(); + + bipedRightArm.rotationPointZ = spread + sin; + + bipedLeftArm.rotationPointZ = spread - sin; + + float legOutset = getLegOutset(); + float rpxl = cos + 1 - legOutset; + float rpxr = legOutset - cos - 1; + + bipedRightArm.rotationPointX = rpxr; + bipedRightLeg.rotationPointX = rpxr; + bipedLeftArm.rotationPointX = rpxl; + bipedLeftLeg.rotationPointX = rpxl; + + bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; + bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; + + bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; + bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; + } + + protected void holdItem(float swing) { + boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; + + alignArmForAction(bipedLeftArm, leftArmPose, both, swing); + alignArmForAction(bipedRightArm, rightArmPose, both, swing); + } + + protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { + switch (pose) { + case ITEM: + float swag = 1; + if (!isFlying && both) { + swag -= (float)Math.pow(swing, 2); + } + float mult = 1 - swag/2; + arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag; + case EMPTY: + arm.rotateAngleY = 0; + break; + case BLOCK: + arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; + arm.rotateAngleY = PI / 6; + break; + default: + } + } + + protected void swingItem(Entity entity, float swingProgress) { + if (swingProgress > -9990.0F && !isSleeping) { + EnumHandSide mainSide = getMainHand(entity); + + if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; + + swingArm(getArmForSide(mainSide)); + } + } + + protected void swingArm(ModelRenderer arm) { + float swing = 1 - (float)Math.pow(1 - swingProgress, 3); + + float deltaX = MathHelper.sin(swing * PI); + float deltaZ = MathHelper.sin(swingProgress * PI); + + float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F; + + arm.rotateAngleX -= deltaAim + deltaX * 1.2F; + arm.rotateAngleY += bipedBody.rotateAngleY * 2; + arm.rotateAngleZ = -deltaZ * 0.4F; + } + + protected void swingArms(float tick) { + if (isSleeping) return; + + float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(tick * 0.067F) * 0.05F; + + if (rightArmPose != ArmPose.EMPTY) { + bipedRightArm.rotateAngleZ += cos; + bipedRightArm.rotateAngleX += sin; + } + + if (leftArmPose != ArmPose.EMPTY) { + bipedLeftArm.rotateAngleZ += cos; + bipedLeftArm.rotateAngleX += sin; + } + } + + protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { + adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); + adjustNeck(rotateAngleX, rotationPointY, rotationPointZ); + } + + protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { + bipedBody.rotateAngleX = rotateAngleX; + bipedBody.rotationPointY = rotationPointY; + bipedBody.rotationPointZ = rotationPointZ; + + upperTorso.rotateAngleX = rotateAngleX; + upperTorso.rotationPointY = rotationPointY; + upperTorso.rotationPointZ = rotationPointZ; + } + + protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { + neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); + } + + /** + * Aligns legs to a sneaky position. + */ + protected void sneakLegs() { + bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; + bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; + + bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; + } + + protected void ponySleep() { + bipedRightArm.rotateAngleX = ROTATE_270; + bipedLeftArm.rotateAngleX = ROTATE_270; + bipedRightLeg.rotateAngleX = ROTATE_90; + bipedLeftLeg.rotateAngleX = ROTATE_90; + + setHead(1, 2, isSneak ? -1 : 1); + + AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6); + AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6); + AbstractPonyRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8); + AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); + } + + protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); + } + + protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) { + arm.rotateAngleZ = 0; + arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; + arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; + arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; + if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1); + } + + protected void fixSpecialRotationPoints(float move) { + } + /** * Sets up this model's initial values, like a constructor... * @param yOffset YPosition for this model. Always 0. @@ -63,12 +402,176 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { /** * Loads texture values. */ - protected abstract void initTextures(); + protected void initTextures() { + boxList.clear(); + initHeadTextures(); + initBodyTextures(); + initLegTextures(); + initTailTextures(); + } /** * Loads texture positions and boxes. Pretty much just finishes the job of initTextures. */ - protected abstract void initPositions(float yOffset, float stretch); + protected void initPositions(float yOffset, float stretch) { + initHeadPositions(yOffset, stretch); + initBodyPositions(yOffset, stretch); + initLegPositions(yOffset, stretch); + initTailPositions(yOffset, stretch); + } + + protected void initTailTextures() { + tail = new PonyTail(this); + } + + protected void initHeadTextures() { + bipedHead = new PonyRenderer(this, 0, 0); + bipedHeadwear = new PonyRenderer(this, 32, 0); + snout = new PonySnout(this); + } + + protected void initBodyTextures() { + bipedBody = new ModelRenderer(this, 16, 16); + + if (textureHeight == 64) { + bipedBodyWear = new ModelRenderer(this, 16, 32); + } + + upperTorso = new PlaneRenderer(this, 24, 0); + neck = new PlaneRenderer(this, 0, 16); + } + + protected void initLegTextures() { + bipedLeftArm = new ModelRenderer(this, 32, 48); + bipedRightArm = new ModelRenderer(this, 40, 16); + + bipedLeftArmwear = new ModelRenderer(this, 48, 48); + bipedRightArmwear = new ModelRenderer(this, 40, 32); + + bipedLeftLeg = new ModelRenderer(this, 16, 48); + bipedRightLeg = new ModelRenderer(this, 0, 16); + + bipedLeftLegwear = new ModelRenderer(this, 0, 48); + bipedRightLegwear = new ModelRenderer(this, 0, 32); + } + + protected void initTailPositions(float yOffset, float stretch) { + tail.init(yOffset, stretch); + } + + protected void initHeadPositions(float yOffset, float stretch) { + snout.init(yOffset, stretch); + ((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .box(-4, -4, -4, 8, 8, 8, stretch) + .tex(12, 16) + .box(-4, -6, 1, 2, 2, 2, stretch) + .flipX() + .box(2, -6, 1, 2, 2, 2, stretch); + + ((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .box(-4, -4, -4, 8, 8, 8, stretch + 0.5F); + } + + /** + * Creates the main torso and neck. + */ + protected void initBodyPositions(float yOffset, float stretch) { + bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch); + bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + + bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); + bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + + upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch) + .tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch) + .tex(4, 0) .addEastPlane( 4, -4, 4, 8, 4, stretch) + .tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch) + .addBackPlane(-4, 0, 8, 8, 4, stretch) + .addBottomPlane(-4, 4, 4, 8, 4, stretch) + .flipZ().tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch) + .tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch) + .tex(4, 0) .addWestPlane(-4, -4, 4, 8, 4, stretch) + // Tail stub + .child(0) + .tex(32, 0).addTopPlane(-1, 2, 2, 2, 6, stretch) + .addBottomPlane(-1, 4, 2, 2, 6, stretch) + .addEastPlane( 1, 2, 2, 2, 6, stretch) + .addBackPlane(-1, 2, 8, 2, 2, stretch) + .flipZ().addWestPlane(-1, 2, 2, 2, 6, stretch) + .rotateAngleX = 0.5F; + + neck.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z) + .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .addFrontPlane(0, 0, 0, 4, 4, stretch) + .addBackPlane(0, 0, 4, 4, 4, stretch) + .addEastPlane(4, 0, 0, 4, 4, stretch) + .addWestPlane(0, 0, 0, 4, 4, stretch) + .rotateAngleX = NECK_ROT_X; + } + + protected int getArmWidth() { + return 4; + } + + protected int getArmDepth() { + return 4; + } + + protected float getLegRotationX() { + return 3; + } + + protected float getArmRotationY() { + return 8; + } + + protected void initLegPositions(float yOffset, float stretch) { + int armWidth = getArmWidth(); + int armDepth = getArmDepth(); + + float rarmX = getLegRotationX(); + float rarmY = getArmRotationY(); + + float armX = THIRDP_ARM_CENTRE_X - 2; + float armY = THIRDP_ARM_CENTRE_Y - 6; + float armZ = THIRDP_ARM_CENTRE_Z - 2; + + bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + + bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + bipedRightLeg.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + + bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); + bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); + + bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); + bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); + + if (bipedLeftArmwear != null) { + bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); + } + + if (bipedRightArmwear != null) { + bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); + } + + if (bipedLeftLegwear != null) { + bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedRightLegwear.setRotationPoint(3, yOffset, 0); + } + + if (bipedRightLegwear != null) { + bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedRightLegwear.setRotationPoint(-3, yOffset, 0); + } + } public ArmPose getArmPoseForSide(EnumHandSide side) { return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; @@ -116,15 +619,80 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { * @param tick Render partial ticks */ protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { - float swing = MathHelper.sin(swingProgress * (float)Math.PI); - float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); + float swing = MathHelper.sin(swingProgress * PI); + float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI); + + float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(tick * 0.067F) / 10; - arm.rotateAngleZ = 0; - arm.rotateAngleY = direction * (0.1F - swing * 0.6F); arm.rotateAngleX = -1.5707964F; arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; - arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F; + arm.rotateAngleX += sin; + + arm.rotateAngleY = direction * (0.1F - swing * 0.6F); + arm.rotateAngleZ = cos; + + } + + @Override + public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { + + pushMatrix(); + transform(BodyPart.HEAD); + renderHead(entityIn, move, swing, age, headYaw, headPitch, scale); + popMatrix(); + + pushMatrix(); + transform(BodyPart.NECK); + renderNeck(); + popMatrix(); + + pushMatrix(); + transform(BodyPart.BODY); + renderBody(entityIn, move, swing, age, headYaw, headPitch, scale); + popMatrix(); + + pushMatrix(); + transform(BodyPart.LEGS); + renderLegs(); + popMatrix(); + } + + protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + bipedHead.render(scale); + bipedHeadwear.render(scale); + bipedHead.postRender(scale); + } + + protected void renderNeck() { + GlStateManager.scale(0.9, 0.9, 0.9); + neck.render(scale); + } + + protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + bipedBody.render(scale); + if (textureHeight == 64) { + bipedBodyWear.render(scale); + } + upperTorso.render(scale); + bipedBody.postRender(scale); + tail.render(scale); + } + + protected void renderLegs() { + if (!isSneak) bipedBody.postRender(scale); + + bipedLeftArm.render(scale); + bipedRightArm.render(scale); + bipedLeftLeg.render(scale); + bipedRightLeg.render(scale); + + if (textureHeight == 64) { + bipedLeftArmwear.render(scale); + bipedRightArmwear.render(scale); + bipedLeftLegwear.render(scale); + bipedRightLegwear.render(scale); + } } @Override diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index 8798bfc5..b57fd7f7 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -14,13 +14,6 @@ public class ModelMobPony extends ModelAlicorn { super(false); } - @Override - protected void adjustLegs(float move, float swing, float tick) { - super.adjustLegs(move, swing, tick); - rotateRightArm(move, tick); - rotateLeftArm(move, tick); - } - /** * Returns true if the angle is to the right? */ @@ -28,38 +21,25 @@ public class ModelMobPony extends ModelAlicorn { return MathHelper.sin(move / 20f) < 0; } - /** - * Called to update the left arm's final rotation. - * Subclasses may replace it with their own implementations. - * - * @param move Limb swing amount. - * @param tick Render partial ticks. - */ - protected void rotateRightArm(float move, float tick) { - if (rightArmPose == ArmPose.EMPTY) return; - - if (canCast()) { - unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmRight, -1, swingProgress, tick); - } else { - rotateArmHolding(bipedRightArm, -1, swingProgress, tick); + @Override + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); + if (rightArmPose != ArmPose.EMPTY) { + if (canCast()) { + unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmRight, -1, swingProgress, tick); + } else { + rotateArmHolding(bipedRightArm, -1, swingProgress, tick); + } } - } - /** - * Same as rotateRightArm but for the left arm (duh). - * - * @param move Limb swing amount. - * @param tick Render partial ticks. - */ - protected void rotateLeftArm(float move, float tick) { - if (leftArmPose == ArmPose.EMPTY) return; - - if (!canCast()) { - unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmLeft, -1, swingProgress, tick); - } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); + if (leftArmPose != ArmPose.EMPTY) { + if (!canCast()) { + unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmLeft, -1, swingProgress, tick); + } else { + rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); + } } } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index fadc3f49..7804a868 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -77,6 +77,11 @@ public class ModelPonyArmor extends ModelMobPony { protected void renderNeck() { } + @Override + protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { + + } + @Override protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { bipedBody.render(this.scale); diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index d2d0d5d2..efdaa1eb 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -3,10 +3,10 @@ package com.minelittlepony.model.armour; import com.minelittlepony.render.AbstractPonyRenderer; public class ModelZombiePonyArmor extends ModelPonyArmor { - // Copied from ModelZombiePony @Override - protected void rotateRightArm(float move, float tick) { + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { @@ -16,11 +16,6 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { } } - @Override - protected void rotateLeftArm(float move, float tick) { - // Zombies are unidexterous. - } - @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 7ecf0383..8468058c 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -6,23 +6,24 @@ import net.minecraft.util.math.MathHelper; import static com.minelittlepony.model.PonyModelConstants.*; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.pony.data.TailLengths; import com.minelittlepony.render.plane.PlaneRenderer; public class PonyTail extends PlaneRenderer { - private final TailSegment[] segments = new TailSegment[4]; + private static final int SEGMENTS = 4; private final AbstractPonyModel theModel; + private int tailStop = 0; + public PonyTail(AbstractPonyModel model) { super(model); theModel = model; } public void init(float yOffset, float stretch) { - for (int i = 0; i < segments.length; i++) { - addChild(segments[i] = new TailSegment(theModel, i, yOffset, stretch)); + for (int i = 0; i < SEGMENTS; i++) { + addChild(new TailSegment(theModel, i, yOffset, stretch)); } } @@ -53,6 +54,8 @@ public class PonyTail extends PlaneRenderer { rotationPointY += 6; rotationPointZ++; } + + tailStop = theModel.metadata.getTail().ordinal(); } public void swingX(float tick) { @@ -66,42 +69,40 @@ public class PonyTail extends PlaneRenderer { rotateAngleX = -BODY_ROTATE_ANGLE_X_SNEAK + 0.1F; } - public void render(TailLengths tail, float scale) { - int tailStop = tail.ordinal(); - - for (int i = 0; i < segments.length; i++) { - segments[i].isHidden = i >= tailStop; - } - - super.render(scale); - } - private class TailSegment extends PlaneRenderer { + private final int index; + public TailSegment(ModelBase model, int index, float yOffset, float stretch) { super(model); + this.index = index; offsetY = ((float)index)/4 + 0.063f; - init(index, yOffset, stretch); + init(yOffset, stretch); } - public void init(int index, float yOffset, float stretch) { + public void init(float yOffset, float stretch) { int texX = (index % 2) * 4; + around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); + if (index == 0) { tex(32, 0).addTopPlane(-2, 0, 2, 4, 4, stretch); } - around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); - tex(36, texX) - .addEastPlane(2, 0, 2, 4, 4, stretch) - .addWestPlane(-2, 0, 2, 4, 4, stretch); - tex(32, texX) - .addBackPlane(-2, 0, 2, 4, 4, stretch) - .addFrontPlane(-2, 0, 6, 4, 4, stretch); - tex(32, 0) - .addBottomPlane(-2, 4, 2, 4, 4, stretch); + tex(36, texX).addEastPlane( 2, 0, 2, 4, 4, stretch) + .addWestPlane(-2, 0, 2, 4, 4, stretch); + tex(32, texX).addBackPlane(-2, 0, 2, 4, 4, stretch) + .addFrontPlane(-2, 0, 6, 4, 4, stretch); + tex(32, 0).addBottomPlane(-2, 4, 2, 4, 4, stretch); + } + + @Override + public void render(float scale) { + if (index < tailStop) { + super.render(scale); + } } } } diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 693a10a7..92804b3b 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -1,24 +1,9 @@ package com.minelittlepony.model.player; import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.armour.ModelPonyArmor; -import com.minelittlepony.model.armour.PonyArmor; -import com.minelittlepony.model.components.PonySnout; -import com.minelittlepony.model.components.PonyTail; -import com.minelittlepony.render.AbstractPonyRenderer; import com.minelittlepony.render.PonyRenderer; -import com.minelittlepony.render.plane.PlaneRenderer; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; -import net.minecraft.util.EnumHandSide; -import net.minecraft.util.math.MathHelper; - -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static com.minelittlepony.model.PonyModelConstants.*; public class ModelEarthPony extends AbstractPonyModel { @@ -26,587 +11,58 @@ public class ModelEarthPony extends AbstractPonyModel { public PonyRenderer bipedCape; - public PlaneRenderer upperTorso; - public PlaneRenderer neck; - - public PonyTail tail; - public PonySnout snout; - public ModelEarthPony(boolean smallArms) { super(smallArms); this.smallArms = smallArms; } - @Override - public PonyArmor createArmour() { - return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); - } - @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - rotateHead(headYaw, headPitch); - - float bodySwingRotation = 0; - if (swingProgress > -9990.0F && !metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; - } - - rotateLook(move, swing, bodySwingRotation, age); - - setLegs(move, swing, age, entity); - holdItem(swing); - swingItem(entity, swingProgress); - - if (isCrouching()) { - adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); - sneakLegs(); - setHead(0, 6, -2); - } else if (isRiding) { - adjustBodyRiding(); - bipedLeftLeg.rotationPointZ = 15; - bipedLeftLeg.rotationPointY = 10; - bipedLeftLeg.rotateAngleX = -PI / 4; - bipedLeftLeg.rotateAngleY = -PI / 5; - - bipedRightLeg.rotationPointZ = 15; - bipedRightLeg.rotationPointY = 10; - bipedRightLeg.rotateAngleX = -PI / 4; - bipedRightLeg.rotateAngleY = PI / 5; - - bipedLeftArm.rotateAngleZ = -PI * 0.06f; - bipedRightArm.rotateAngleZ = PI * 0.06f; - } else { - adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - - bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - swingArms(age); - setHead(0, 0, 0); - } - - if (isSleeping) ponySleep(); - - aimBow(leftArmPose, rightArmPose, age); - fixSpecialRotationPoints(move); - - animateWears(); - - if (bipedCape != null) { - bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; - - snout.setGender(metadata.getGender()); - } + bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; } - protected void adjustBodyRiding() { - adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); - adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - setHead(0, 0, 0); + protected float getLegOutset() { + if (isCrouching() && smallArms) return 1; + return super.getLegOutset(); } - protected void rotateLook(float move, float swing, float bodySwing, float ticks) { - tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks); - bodySwing /= 5; - - upperTorso.rotateAngleY = bodySwing; - bipedBody.rotateAngleY = bodySwing; - neck.rotateAngleY = bodySwing; + protected int getArmWidth() { + return smallArms ? 3 : super.getArmWidth(); } - private void animateWears() { - copyModelAngles(bipedLeftArm, bipedLeftArmwear); - copyModelAngles(bipedRightArm, bipedRightArmwear); - copyModelAngles(bipedLeftLeg, bipedLeftLegwear); - copyModelAngles(bipedRightLeg, bipedRightLegwear); - copyModelAngles(bipedBody, bipedBodyWear); + protected float getLegRotationX() { + return smallArms ? 2 : super.getLegRotationX(); } - /** - * Sets the head rotation angle. - */ - protected void setHead(float posX, float posY, float posZ) { - bipedHead.setRotationPoint(posX, posY, posZ); - bipedHeadwear.setRotationPoint(posX, posY, posZ); - } - - /** - * Rotates the head within reason. X is clamped to around motionPitch. - * Both arguments are also ignored when sleeping. - */ - private void rotateHead(float horz, float vert) { - float headRotateAngleY = isSleeping ? 1.4f : horz / 57.29578F; - float headRotateAngleX = isSleeping ? 0.1f : vert / 57.29578F; - - headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); - headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch))); - - updateHeadRotation(headRotateAngleX, headRotateAngleY); - } - - /** - * Called to update the head rotation. - * - * @param x New rotation X - * @param y New rotation Y - */ - protected void updateHeadRotation(float x, float y) { - bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y; - bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; - } - - protected void setLegs(float move, float swing, float tick, Entity entity) { - if (isFlying(entity)) { - rotateLegsInFlight(move, swing, tick, entity); - } else { - rotateLegsOnGround(move, swing, tick, entity); - } - - bipedLeftArm.rotateAngleZ = 0; - bipedRightArm.rotateAngleZ = 0; - - adjustLegs(move, swing, tick); - } - - protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { - float armX = MathHelper.sin(-swing / 2); - float legX = MathHelper.sin(swing / 2); - - bipedLeftArm.rotateAngleX = armX; - bipedRightArm.rotateAngleX = armX; - - bipedLeftLeg.rotateAngleX = legX; - bipedRightLeg.rotateAngleX = legX; - - bipedLeftArm.rotateAngleY = -0.2F; - bipedLeftLeg.rotateAngleY = 0.2F; - - bipedRightArm.rotateAngleY = 0.2F; - bipedRightLeg.rotateAngleY = -0.2F; - } - - protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { - float pi = PI * (float) Math.pow(swing, 16); - - float mve = move * 0.6662F; // magic number ahoy - float srt = swing / 4; - - float leftArm = MathHelper.cos(mve + pi) * srt; - float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; - - float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; - float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; - - bipedLeftArm.rotateAngleX = leftArm; - bipedRightArm.rotateAngleX = rightArm; - - bipedLeftLeg.rotateAngleX = leftLeg; - bipedRightLeg.rotateAngleX = rightLeg; - - bipedLeftArm.rotateAngleY = 0; - bipedRightArm.rotateAngleY = 0; - - bipedLeftLeg.rotateAngleY = 0; - bipedRightLeg.rotateAngleY = 0; - } - - private float getLegOutset() { - if (isSleeping) return 2.6f; - if (isCrouching()) return smallArms ? 1 : 0; - return 4; - } - - protected float getLegSpread() { - return rainboom ? 2 : 1; + protected float getArmRotationY() { + return smallArms ? 8.5f : super.getArmRotationY(); } protected void adjustLegs(float move, float swing, float tick) { - float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; - float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; - - float spread = getLegSpread(); - - bipedRightArm.rotationPointZ = spread + sin; - - bipedLeftArm.rotationPointZ = spread - sin; - - float legOutset = getLegOutset(); - float rpxl = cos + 1 - legOutset; - float rpxr = legOutset - cos - 1; - - bipedRightArm.rotationPointX = rpxr; - bipedRightLeg.rotationPointX = rpxr; - bipedLeftArm.rotationPointX = rpxl; - bipedLeftLeg.rotationPointX = rpxl; - + super.adjustLegs(move, swing, tick); // Push the front legs back apart if we're a thin pony if (smallArms) { bipedLeftArm.rotationPointX++; bipedLeftLeg.rotationPointX++; } - - bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; - bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; - - bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; - bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; - } - - protected void holdItem(float swing) { - boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; - - alignArmForAction(bipedLeftArm, leftArmPose, both, swing); - alignArmForAction(bipedRightArm, rightArmPose, both, swing); - } - - protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { - switch (pose) { - case ITEM: - float swag = 1; - if (!isFlying && both) { - swag -= (float)Math.pow(swing, 2); - } - float mult = 1 - swag/2; - arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag; - case EMPTY: - arm.rotateAngleY = 0; - break; - case BLOCK: - blockArm(arm); - break; - default: - } - } - - private void blockArm(ModelRenderer arm) { - arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; - arm.rotateAngleY = PI / 6; - } - - protected void swingItem(Entity entity, float swingProgress) { - if (swingProgress > -9990.0F && !isSleeping) { - EnumHandSide mainSide = getMainHand(entity); - - if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; - - swingArm(getArmForSide(mainSide)); - } - } - - protected void swingArm(ModelRenderer arm) { - float swing = 1 - (float)Math.pow(1 - swingProgress, 3); - - float deltaX = MathHelper.sin(swing * PI); - float deltaZ = MathHelper.sin(swingProgress * PI); - - float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F; - - arm.rotateAngleX -= deltaAim + deltaX * 1.2F; - arm.rotateAngleZ = deltaZ * -0.4F; - arm.rotateAngleY += bipedBody.rotateAngleY * 2; - } - - protected void swingArms(float tick) { - if (isSleeping) return; - - float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sin = MathHelper.sin(tick * 0.067F) * 0.05F; - - if (rightArmPose != ArmPose.EMPTY) { - bipedRightArm.rotateAngleZ += cos; - bipedRightArm.rotateAngleX += sin; - } - - if (leftArmPose != ArmPose.EMPTY) { - bipedLeftArm.rotateAngleZ += cos; - bipedLeftArm.rotateAngleX += sin; - } - } - - protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { - adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); - adjustNeck(rotateAngleX, rotationPointY, rotationPointZ); - } - - protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { - bipedBody.rotateAngleX = rotateAngleX; - bipedBody.rotationPointY = rotationPointY; - bipedBody.rotationPointZ = rotationPointZ; - - upperTorso.rotateAngleX = rotateAngleX; - upperTorso.rotationPointY = rotationPointY; - upperTorso.rotationPointZ = rotationPointZ; - } - - protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { - neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ); - } - - /** - * Aligns legs to a sneaky position. - */ - protected void sneakLegs() { - bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT; - - bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; - } - - protected void ponySleep() { - bipedRightArm.rotateAngleX = ROTATE_270; - bipedLeftArm.rotateAngleX = ROTATE_270; - bipedRightLeg.rotateAngleX = ROTATE_90; - bipedLeftLeg.rotateAngleX = ROTATE_90; - - setHead(1, 2, isSneak ? -1 : 1); - - AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6); - AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6); - AbstractPonyRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8); - AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); - } - - protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); - } - - protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) { - arm.rotateAngleZ = 0; - arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; - arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; - arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1); - } - - protected void fixSpecialRotationPoints(float move) { - } - - @Override - public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { - - pushMatrix(); - transform(BodyPart.HEAD); - renderHead(entityIn, move, swing, age, headYaw, headPitch, scale); - popMatrix(); - - pushMatrix(); - transform(BodyPart.NECK); - renderNeck(); - popMatrix(); - - pushMatrix(); - transform(BodyPart.BODY); - renderBody(entityIn, move, swing, age, headYaw, headPitch, scale); - popMatrix(); - - pushMatrix(); - transform(BodyPart.LEGS); - renderLegs(); - popMatrix(); - } - - protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - bipedHead.render(scale); - bipedHeadwear.render(scale); - bipedHead.postRender(scale); - } - - protected void renderNeck() { - GlStateManager.scale(0.9, 0.9, 0.9); - neck.render(scale); - } - - protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - bipedBody.render(scale); - if (textureHeight == 64) { - bipedBodyWear.render(scale); - } - upperTorso.render(scale); - bipedBody.postRender(scale); - tail.render(metadata.getTail(), scale); - } - - protected void renderLegs() { - if (!isSneak) bipedBody.postRender(scale); - - bipedLeftArm.render(scale); - bipedRightArm.render(scale); - bipedLeftLeg.render(scale); - bipedRightLeg.render(scale); - - if (textureHeight == 64) { - bipedLeftArmwear.render(scale); - bipedRightArmwear.render(scale); - bipedLeftLegwear.render(scale); - bipedRightLegwear.render(scale); - } - } - - @Override - protected void initTextures() { - boxList.clear(); - initHeadTextures(); - initBodyTextures(); - initLegTextures(); - initTailTextures(); - } - - protected void initTailTextures() { - tail = new PonyTail(this); } protected void initHeadTextures() { + super.initHeadTextures(); bipedCape = new PonyRenderer(this, 0, 0).size(64, 32); - bipedHead = new PonyRenderer(this, 0, 0); - bipedHeadwear = new PonyRenderer(this, 32, 0); - snout = new PonySnout(this); - } - - protected void initBodyTextures() { - bipedBody = new ModelRenderer(this, 16, 16); - - if (textureHeight == 64) { - bipedBodyWear = new ModelRenderer(this, 16, 32); - } - - upperTorso = new PlaneRenderer(this, 24, 0); - neck = new PlaneRenderer(this, 0, 16); - } - - protected void initLegTextures() { - bipedLeftArm = new ModelRenderer(this, 32, 48); - bipedRightArm = new ModelRenderer(this, 40, 16); - - bipedLeftArmwear = new ModelRenderer(this, 48, 48); - bipedRightArmwear = new ModelRenderer(this, 40, 32); - - bipedLeftLeg = new ModelRenderer(this, 16, 48); - bipedRightLeg = new ModelRenderer(this, 0, 16); - - bipedLeftLegwear = new ModelRenderer(this, 0, 48); - bipedRightLegwear = new ModelRenderer(this, 0, 32); - } - - @Override - protected void initPositions(float yOffset, float stretch) { - initHeadPositions(yOffset, stretch); - initBodyPositions(yOffset, stretch); - initLegPositions(yOffset, stretch); - initTailPositions(yOffset, stretch); - } - - protected void initTailPositions(float yOffset, float stretch) { - tail.init(yOffset, stretch); } protected void initHeadPositions(float yOffset, float stretch) { - snout.init(yOffset, stretch); - + super.initHeadPositions(yOffset, stretch); bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); - - ((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) - .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) - .box(-4, -4, -4, 8, 8, 8, stretch) - .tex(12, 16) - .box(-4, -6, 1, 2, 2, 2, stretch) - .flipX() - .box(2, -6, 1, 2, 2, 2, stretch); - - ((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) - .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) - .box(-4, -4, -4, 8, 8, 8, stretch + 0.5F); - } - - /** - * Creates the main torso and neck. - */ - protected void initBodyPositions(float yOffset, float stretch) { - bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch); - bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - - bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); - bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - - upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) - .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) - .tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch) - .tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch) - .tex(4, 0) .addEastPlane( 4, -4, 4, 8, 4, stretch) - .tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch) - .addBackPlane(-4, 0, 8, 8, 4, stretch) - .addBottomPlane(-4, 4, 4, 8, 4, stretch) - .flipZ().tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch) - .tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch) - .tex(4, 0) .addWestPlane(-4, -4, 4, 8, 4, stretch) - // Tail stub - .child(0) - .tex(32, 0).addTopPlane(-1, 2, 2, 2, 6, stretch) - .addBottomPlane(-1, 4, 2, 2, 6, stretch) - .addEastPlane( 1, 2, 2, 2, 6, stretch) - .addBackPlane(-1, 2, 8, 2, 2, stretch) - .flipZ().addWestPlane(-1, 2, 2, 2, 6, stretch) - .rotateAngleX = 0.5F; - - neck.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z) - .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) - .addFrontPlane(0, 0, 0, 4, 4, stretch) - .addBackPlane(0, 0, 4, 4, 4, stretch) - .addEastPlane(4, 0, 0, 4, 4, stretch) - .addWestPlane(0, 0, 0, 4, 4, stretch) - .rotateAngleX = NECK_ROT_X; - } - - protected int getArmWidth() { - return smallArms ? 3 : 4; - } - - protected int getArmDepth() { - return 4; } protected void initLegPositions(float yOffset, float stretch) { - int armWidth = getArmWidth(); - int armDepth = getArmDepth(); - float rarmY = smallArms ? 8.5f : 8; - float rarmX = smallArms ? 2 : 3; + super.initLegPositions(yOffset, stretch); + if (smallArms) { - float armX = THIRDP_ARM_CENTRE_X - 2; - float armY = THIRDP_ARM_CENTRE_Y - 6; - float armZ = THIRDP_ARM_CENTRE_Z - 2; - - bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - - bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - bipedRightLeg.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - - bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); - bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); - - bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); - bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); - - if (bipedLeftArmwear != null) { - bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); - } - - if (bipedRightArmwear != null) { - bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); - } - - if (bipedLeftLegwear != null) { - bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedRightLegwear.setRotationPoint(3, yOffset, 0); - } - - if (bipedRightLegwear != null) { - bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedRightLegwear.setRotationPoint(-3, yOffset, 0); } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 94e80d1e..7cf862be 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -13,7 +13,8 @@ public class ModelZombiePony extends ModelMobPony { } @Override - protected void rotateRightArm(float move, float tick) { + protected void adjustLegs(float move, float swing, float tick) { + super.adjustLegs(move, swing, tick); if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { @@ -23,11 +24,6 @@ public class ModelZombiePony extends ModelMobPony { } } - @Override - protected void rotateLeftArm(float move, float tick) { - // zombies are unidexterous. - } - @Override protected void fixSpecialRotationPoints(float move) { if (rightArmPose != ArmPose.EMPTY) return; From 7060359f580984e651d55ac80c9a5b77f9b9ff01 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 16:41:40 +0200 Subject: [PATCH 68/96] Shhh you saw nothing (items glow again) --- .../render/layer/LayerHeldPonyItemMagical.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java index c4f66f87..8a83e6d6 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -7,6 +7,8 @@ import static net.minecraft.client.renderer.GlStateManager.pushMatrix; import static net.minecraft.client.renderer.GlStateManager.scale; import static net.minecraft.client.renderer.GlStateManager.translate; +import org.lwjgl.opengl.GL14; + import com.minelittlepony.ducks.IRenderItem; import com.minelittlepony.model.capabilities.IModelUnicorn; import com.minelittlepony.util.coordinates.Color; @@ -63,7 +65,7 @@ public class LayerHeldPonyItemMagical extends LayerH pushMatrix(); disableLighting(); - Color.glColor(glowColor, 0.2F); + GL14.glBlendColor(Color.r(glowColor), Color.g(glowColor), Color.b(glowColor), 0.2F); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); ((IRenderItem) renderItem).useTransparency(true); @@ -83,10 +85,10 @@ public class LayerHeldPonyItemMagical extends LayerH } private ItemStack stackWithoutEnchantment(ItemStack original) { - ItemStack copy = original.copy(); - if (copy.isItemEnchanted()) { - copy.getTagCompound().removeTag("ench"); + if (original.isItemEnchanted()) { + original = original.copy(); + original.getTagCompound().removeTag("ench"); } - return copy; + return original; } } From 7d4c7ede88f1d03eda3db4797ac02fe1bfdca49e Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 18:00:26 +0200 Subject: [PATCH 69/96] Fixed various leg alignment issues (may break resourcepacks) May Break Resourcepacks: To fix, just rescale skeleton legs to 2x2 pixels width keeping the original positions. --- .../model/AbstractPonyModel.java | 38 +++++++-------- .../model/armour/ModelPonyArmor.java | 18 ++++--- .../model/player/ModelEarthPony.java | 20 ++------ .../model/ponies/ModelSkeletonPony.java | 44 ++++-------------- .../entity/skeleton/skeleton_pony.png | Bin 952 -> 1656 bytes .../entity/skeleton/skeleton_wither_pony.png | Bin 993 -> 1689 bytes .../textures/entity/skeleton/stray_pony.png | Bin 1727 -> 1753 bytes 7 files changed, 44 insertions(+), 76 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 37a75d72..b56de29a 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -126,7 +126,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { animateWears(); - snout.setGender(metadata.getGender()); + if (snout != null) { + snout.setGender(metadata.getGender()); + } } protected void adjustBodyRiding() { @@ -243,17 +245,15 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { float spread = getLegSpread(); bipedRightArm.rotationPointZ = spread + sin; - bipedLeftArm.rotationPointZ = spread - sin; - float legOutset = getLegOutset(); - float rpxl = cos + 1 - legOutset; - float rpxr = legOutset - cos - 1; + float legRPX = cos - getLegOutset(); - bipedRightArm.rotationPointX = rpxr; - bipedRightLeg.rotationPointX = rpxr; - bipedLeftArm.rotationPointX = rpxl; - bipedLeftLeg.rotationPointX = rpxl; + bipedRightArm.rotationPointX = -legRPX; + bipedRightLeg.rotationPointX = -legRPX; + + bipedLeftArm.rotationPointX = legRPX; + bipedLeftLeg.rotationPointX = legRPX; bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; @@ -536,15 +536,15 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { float rarmX = getLegRotationX(); float rarmY = getArmRotationY(); - float armX = THIRDP_ARM_CENTRE_X - 2; + float armX = THIRDP_ARM_CENTRE_X; float armY = THIRDP_ARM_CENTRE_Y - 6; - float armZ = THIRDP_ARM_CENTRE_Z - 2; + float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth; bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + bipedRightArm.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch); bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); - bipedRightLeg.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch); + bipedRightLeg.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch); bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); @@ -554,22 +554,22 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { if (bipedLeftArmwear != null) { bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0); + bipedLeftArmwear.setRotationPoint(rarmX, yOffset + rarmY, 0); } if (bipedRightArmwear != null) { - bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0); + bipedRightArmwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedRightArmwear.setRotationPoint(-rarmX, yOffset + rarmY, 0); } if (bipedLeftLegwear != null) { bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedRightLegwear.setRotationPoint(3, yOffset, 0); + bipedRightLegwear.setRotationPoint(rarmX, yOffset, 0); } if (bipedRightLegwear != null) { - bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); - bipedRightLegwear.setRotationPoint(-3, yOffset, 0); + bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0); } } diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index 7804a868..00f7e753 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -175,12 +175,18 @@ public class ModelPonyArmor extends ModelMobPony { protected void initLegPositions(float yOffset, float stretch) { super.initLegPositions(yOffset, stretch); - leftLegging.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) - .around(3, yOffset, 0) - .box(-2, -6, -2, 4, 12, 4, stretch); - rightLegging.offset(THIRDP_ARM_CENTRE_X, THIRDP_ARM_CENTRE_Y, THIRDP_ARM_CENTRE_Z) - .around(-3, yOffset, 0) - .flipX().box(-2, -6, -2, 4, 12, 4, stretch); + float rarmX = getLegRotationX(); + + float armX = THIRDP_ARM_CENTRE_X; + float armY = THIRDP_ARM_CENTRE_Y; + float armZ = THIRDP_ARM_CENTRE_Z; + + leftLegging.offset(armX + 2, armY, armZ) + .around(rarmX, yOffset, 0) + .box(-2, -6, -2, 4, 12, 4, stretch); + rightLegging.offset(armX - 2, armY, armZ) + .around(-rarmX, yOffset, 0) + .flipX().box(-2, -6, -2, 4, 12, 4, stretch); } protected void syncLegs() { diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 92804b3b..f66d83c9 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -20,7 +20,9 @@ public class ModelEarthPony extends AbstractPonyModel { public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); - bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; + if (bipedCape != null) { + bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; + } } protected float getLegOutset() { @@ -40,15 +42,6 @@ public class ModelEarthPony extends AbstractPonyModel { return smallArms ? 8.5f : super.getArmRotationY(); } - protected void adjustLegs(float move, float swing, float tick) { - super.adjustLegs(move, swing, tick); - // Push the front legs back apart if we're a thin pony - if (smallArms) { - bipedLeftArm.rotationPointX++; - bipedLeftLeg.rotationPointX++; - } - } - protected void initHeadTextures() { super.initHeadTextures(); bipedCape = new PonyRenderer(this, 0, 0).size(64, 32); @@ -59,13 +52,6 @@ public class ModelEarthPony extends AbstractPonyModel { bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); } - protected void initLegPositions(float yOffset, float stretch) { - super.initLegPositions(yOffset, stretch); - if (smallArms) { - - } - } - @Override public void renderCape(float scale) { bipedCape.render(scale); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index db2ed133..586ccfa6 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -1,12 +1,9 @@ package com.minelittlepony.model.ponies; -import static net.minecraft.client.renderer.GlStateManager.*; - import com.minelittlepony.model.ModelMobPony; import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; import com.minelittlepony.model.armour.PonyArmor; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.init.Items; @@ -51,40 +48,19 @@ public class ModelSkeletonPony extends ModelMobPony { } } - // TODO: HACK It would be better to just change the size of the legs. - private void renderScaledArm(ModelRenderer arm, float x, float y, float z) { - scale(x, y, z); - x /= 1.5f; - z /= 1.5f; - arm.rotateAngleX /= x; - arm.rotateAngleY /= y; - arm.rotateAngleZ /= z; - arm.render(scale); - arm.rotateAngleX *= x; - arm.rotateAngleY *= y; - arm.rotateAngleZ *= z; + protected int getArmWidth() { + return 2; } - @Override - protected void renderLegs() { - pushMatrix(); - translate(0.05F, -0.21F, 0); - renderScaledArm(bipedLeftArm, 0.5F, 1.15F, 0.5F); - popMatrix(); + protected int getArmDepth() { + return 2; + } - pushMatrix(); - translate(-0.05F, -0.21F, 0); - renderScaledArm(bipedRightArm, 0.5F, 1.2F, 0.5F); - popMatrix(); + protected float getLegRotationX() { + return 3; + } - pushMatrix(); - translate(0.05F, -0.21F, 0.35F); - renderScaledArm(bipedLeftLeg, 0.5F, 1.2F, 0.5F); - popMatrix(); - - pushMatrix(); - translate(-0.05F, -0.21F, 0.35F); - renderScaledArm(bipedRightLeg, 0.5F, 1.15F, 0.5F); - popMatrix(); + protected float getArmRotationY() { + return 8; } } diff --git a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_pony.png index 843cb75883f14d3d6bf0c43c7b84af433fe90884..c9ea7d7bcb535ed8acea29a584b2e2c6bfd339e2 100644 GIT binary patch delta 1640 zcmV-u2ABD`2lxz-BYy@zNkl;yImUY3)1!beVRmnaBz_Nj4Y_^ytup6d3kw>lamt~WWLpEVRLgcmANRiS}g#8 zEX$GCnLy*(JW&;ZB?&8vvamXgfzfEhuZ8jE&6@>bynOj`Xgnz)YEWQek<8TIaT}P|c;wHgx@7_JAsv7&SC=Dob^#P#L>-DJTc@RYr zpFVw}K{M!dIzo_1S(f3t?vg1m1cemtj{_S&uKg_SwfskVwbL1Qgfi>H`LY0h-MwL{Y?eJb&gFf~)MhE*gynY}>|YG{S5) z!|mI*k!JH@+mDMHuIoZkl*l%B0We19^EtQCaOe?55u?%Qf1+yjmsTe!T(Ssbnr391 zHw5Mc=kqydwqCCcsz#dx{zfVnx?_`eQqj}B;ox09G91u|Jhchf_A$t zWZg&PE`NYtuSb~%0Dz`xAcR1cWo&J2!M1IF^VZfDZr!>C-}mw3#}7=WQ#6}R*tX4S zE-o&(0GQ)stIX^==;4bNLM0fsL{WtA`|y1qmStf$90CANPfxMCyNjKj9o)Qm6WiO{ zI6XZ@v)ROOID}DpXa4=Xsb;r#x)35UD5%bY16tg$sarY38Xt z&x4{U&@>ITS`7g30(8=B1~Ow)uYim26Uuq=zy zvay0rFlrz1{Q2|3onQq3+U>R=NfHKw0W?iRyWJM{_VxtZws}leRh8TD{rmS}+cqkd z3T)fP-rk0mIp7R+-ENW-gFujtdKPjPm3hKCOy z;_KJ1c=YHI9z1v;;1369;PdCtG#Jj}gtNcDzw-HC*Y%}C%~iwRy5<+@1OZ?;9Kv;7 z9u02XxN#+kG6vaEnmNI&iH&v5Z%F{bj12So0O0#R{S`9_V>X+iTCMW-s>o}83x7^9 zk25*j60*#F>tA3l7bj^iwtOV;@v92_JI zpxf=zq|=ybnrSM=84I5q7<1ijmxizX3bM?v)9EDpfV7OvDo0Y&G@1WtL#x$V*bl^MK-T%CMuDV^On+SZD-Mj=;7Kybd{WpnO*1mvyw3SW3Lq&XllFk{ zfhLLZ@bTJloCP0ne0)q5MOo5-Ec06_3a}$=RO>iS;xFi_4Z{$a1{j9HnJ^4PV9Xna zA;fuamWd8y9rKIT07X&Yc^)K5ifmbeW7Q3iVHm>E(Gl%-yOi}E9UW1|e19+sginw4 zdL5D^E!8O2F~3*=u+&#v8%%IS;o{TBG1qk$k}7ev#C2zc5?3&71+pTz50GVfK@0Zx_k~`s zhdk$3#Wg}OHCLiUi4rABlz%8uqC|-jB}$Yikr&qXg2Tzl31zA8pGl3#u@4UqbD_T~ z)|L^nEDMAXRIAl1)$g;?7bbwHFFt-IGbsQNLWDf&v!b$&l}~E(rZ3zFu!?S64L|J} zo12@N=+o-|xog0mt_5omK-RB5iu`IMvlC4F+GEvK%t~LF0Fr9=>|w>|Jn0KJfu!2~ z@1QSS1K6wfaW(w3?|!nRMmzEBNFtInp`aGI0L+Xv)c9kwiss;Vkv)voI- m03oB66#9Nb;cti(jeh}Q8f(sE`2!aoBA-HklS`b{h zk+<^$-hbqA3g>d}+*H%1Y3n7!9nwkDI&(5JnI^aR`{$o4gx2e|Tdh_<`ew74L(6M$ z5kMTPY~THgi`3-GzwZhy77Mr8Y@8au-|tIS075|EvuN>NAAbM@*Vh(Z6Oji1yr%Im zpbCKLbn29S091JZf%UbW7`E451IK;h+EzBntrht3sex4*&q$?be~)?RHMXK(DRwJ^-phfQI{Gy7weF9*^De zcq|P92s$h34S$f~CAfyiSO7v+fvTLt+~R9H@c;mT+4mX5d_WH%htANuOx}AA&?E?E zE&w28tO)cFx-?e_j=?hu6ul|7j_AaA1ptP@5VY_Nv}DNF>(yN@mr|zp=ralcIJS;R zPBetG4+V8)!2Qu^%$n%JdMV?2xMp-(R&DxwI(>9&!v&{0FI#tfH8*gPft(|ts@5E1-2$2 z5SV%NF$5U<3>%EqXZbF>)Y&?s7!pBw)&yGIpdYgj*S_6uB>tNJPvp?b&u08KvVN?7o&7+nnm#!Id?DggvwB@a zSW~cV3xKxtOa24)!)CAmy!#w|#~RzOV%^^Jjq}w8vHArApoy!Ftc)d)tj787g>tNZ z!2oD=R!8QiEBe&9SJ(Q16zTy@^$Xs%R%7bO7JmS1tWQ<|LOr3We#t#RKXPd7Dp=$m+K zZMUgIx2R&D&j55yZ5*v7J^D&bZJpycm3s#u=2W>2c`yLPp5r%_vj^lP*fTXfw{J`C z9e}3i_HD_7DSczl@tewn0iZAL9e~*5>l}|i{{D0T{sXW?$?faliC_Q#002ovPDHLk FV1g{>z%u{< diff --git a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_wither_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_wither_pony.png index 88f51bfab3c24362e15b475131ef301152fba2be..46efb341ac1401934d71fc74e843fc1bb8740fa9 100644 GIT binary patch delta 1674 zcmV;526g%22bm3!BYy^9Nklc}UD8;hqhaS|!+#aG8mNFl^HNslI7kh4|geg5!i~njnNY6gxjVLoSy?a%IKQHWrIr=^;#x z5aN10m(Tki7m2t4I4nFG4gmn)?(9GmMG649Tn+%xZnvSRs_Tt(U8ntiAM1qR#57@= z=9NdzG)>>*LVrB~05X{jWv+U7cqlXs193&cgKT!{?%iGw!-;X$QmLs?cszXg5ChA? zy2nW0wb2IvajRIQvMgg@Styswls)|2+qbAys{)(%0KnQYm*%}eQB{YLcyxO`PX!u= z;d@-T0S1-@07$3P)06qlO~(jydp)?d<1w%-3@i(>EPuORV=m1T;Oup;<3bIPPNyMB z658!Hj*gB10OP^nl7epSX4#s3W;@9|#jW#8C&6~ReTmh7fAz|tDC;=i&d;s=!k$~_ zP1E!|E*b&=6bc1u+xE1xgb)lzBS&OV6a^$$&)9v-|s^dMF@fbF&4vU zIK*f)f~u;JWf>noenhEMLL!lXZQB?O2H4x%!+%btg5y>TmSsVbBuKIh`{Dwl(Fmd_ zB9Ta7d~q?28Z3_(SQduEA=XkU-|2BH9>6-kmP&zAip1*bSIdYZ;(~xb-n>C3lbLpS zl@Ppt{Ti7}2DNGxzwYjWQi}d?h+e0IPPdD0r-RX8fPTLZYZ5kDh*VS+imD==PG5^h z7Jp^{0I+QvrxQ0nZndDQDhMG^C&p;CS}2uD`1jK%06?i!!rtB<0N|+EM5oh%X_`|{ z;Ng}>c!koXOaTD+;ptNv69g!$t5{oKha^cz$}()*Ml2SCQLp3OpMT<;$B(g+O5yKX z4drqf=}ZP=+lC;DI6pl_EFQ2_ckUNy@TJx3{-1t?*A*Lb0xvqT0oeE2|9sBAiZ4c0e*`SuTK#8&W9bXMJ|>EUDqkg&fJb(9>BtyqN` zjs51^?NlmsBcFFH#)9-4Se6h_Q-Aa~04stLLg04vG61XZnWjlS&N~XL{CT$$oEIKs zv+&c85aMfqAX1#$1Gs`G?e==S!KQ{_zrC&{S5_R!5Mz3tFvIHid4E4R3d~cH@hXn8 z&T-+&(-5;^^GmaN>6~rbzWRCTajh`Olhswpi*-a+6vv{*tK)9fURhBbd4IvrFJ90i z!?@%De)@$inuzlXvKk=Y@z4AF0vlz%6SZnpV21Hq{{Hj+{nQJttB2PoFbaev!G>W_ zMO81cIZuLabDJ%Y`24`FU66jENziTU>MDs49|h(uYHSsY4p}z$`DqcPUswag=Pf<6 zxfiCQ!}0-kj|bT-OQ$irjDHT&8k%UOTu!&wo%o5%|hoSou4X2i#YLHh|yXU9Li6Vdd`x z3Hn_RdX0^}W;d^VSP~4)0YSU7L8EvTj=0kXxN45SEcx3ofDpz*Za_YY0%7nU{k4+n UIl&Pl00000NkvXXt^-0~f|+qCn*aa+ delta 972 zcmV;-12g=Y4dDlnBYy*^NklEQQZR*A|+H3$TC6@pjAmw;0DObehfLum^HVR|xeQAJ}(*VfCr2*ivID;}z zf-s~~skn!6R)5F(mjJNgQceTlvkN3SAk!qc2yrORhHEeT0x<7><~e{fKN|*P+wC^J zYc{7`tJR#xA;;MtV^EM~Fh>FfSqXwnpxiIyfuN`apjxd`yW6FY*Vi;0k7+m>QSbQJ zF)xLS%S+ckzq)cVkR3#0oueaq-|0*N;B8db5pp}t9De|K5{mBa?KuxZG4!#{(Z_w% zON~Z@I+1bkG_Em*Fog_c*;tMO^f^j&9f4Nw7MVr>jBiE?B9sp!&w{%rC-mX;)EWBE zQ_kSQ#l_6nw`j-sdUxjvr?c~OI_UN2Z3GYlIj@e$4FHna^YHXwFrb%e`6U9jx3?X0 z1b`vK>wljkL9%ZhktxAz-Dv&xheP@ld2{mcKtGg@6+V= zmd29_eU4gqA9C%3gQ@qEiY-}l0vCCWzVC9L1)})|48tnWLd}iRAxE{Xn)RHzl}YB-zVgIMIIdF{Q&*P%f6iG zx_;dNgzA_21JZh_SvvrWUPl+Pd?}ju=BMw)$?-|lI`#7gKqKkf*9V?*T%R+>$uCNp zq563PpbtKL`}(*`pZ?6dr;DLDr9<^wc}@BDH2{m|Y5*2RK&XDHM}V*4Ny|m*B2S_= z7JmVuNk*eB*S}7B`kYZ48&@plJ_*L1-s&V6x3<|^zBwTEBp9*_gdEBHMnGx+q@HA! z06{Cgiaty07x(dU8D1veYfJIGH=%MASKlBXwq_&QJZbClvEAFcO+^zXd u_bmb}30e{~04xdS0f4O7lAr+)Mt=be`66Sj7*)Uk0000qOY$vVbnuRuK-MQNd4UUY7+axB9 zQ!7oN9;$YnTEt<~+HRfJjdl`3Rht{F&{RN^=z)R|(hd^`gtSc)oVL@n1M4Alq4|&h z#Ln9xJmVyGTM@K!M;Rm6m%a@xjRtys>H*ONU z@Po-DdZJNJ;hZp-OacG|UU0lm73wwy3HJ8~51KR_75KW?0E??@WZ~*6v74NxYslvF)+&@0#S%c4Bn&2#mP=5)bL0r3 zLe%wPP8QI~)dzsk;_4cy7!^d=Fn+v!o7ml8esYqr3n}md6jf_-1q!>88n3&7&hIwv ziv=8(Wf*1^TBXwD22=n=)c^nqxzBa7om>utG=~LBtAA>$W8kC;avKAU0qN~+3=Z@o z91i1o?v>fuS6NXtB;-Eii$!FzIT)saWFi4CpKtVix2&P48lnR4I0mkOWPd*ZfDi(K z=NwZ{gbgE;&AlQDv#+%}ttSJw!&008KX#h~dLc#el0 z7m+O#Uj?kVh-4yxiecjKr%!9CYM>w4LeZiry?9|MpcXheYn7>A+ar9Zl@PM~dV~$b zteP;)DssgF(wPhZ;NIpYj=lFTjt&h$5=A8BK7ZWX+{EBOKhl{Da>W7+vkJ3nBEp87 z;)s18anKMdD+&ajgB%yZb39Z{2O$J~VjPkv;@;*a?rhw`{NfLI_WU{i+1kQa-_GOC z#w}c5zYa+h(I>`12!X2UmgNXMSGU@`*++B&Y%NObP&NH!{;wd)^N9DvAolbC0L~1L zV1I7L^@FY}S$1lJBhQWb;{F{D;2pdMcw--D4f<;T` zvIjw@eZ*(O!yONTApn@37-s~ILwb7~y??P7rYFXk^CKfnp;UsRX^8SXdZJNeay1`5 zIy8iAp$LXyP$-pfeq@B1o)~9(V=<(+w;^zxB|J^53AxWor|C@QKnQPHfET{Fa)o?y z>J%P6eu9(7-p9|69^s=CC-A}X;|$(#SOQ$XdzaYLnVWK^&Yj)$`Cpc#rbEqM(|=yO z_;U<`0FcgPplBK*Yy@o8L^u@QlSZk4^e9b(px?qqyZCETfW0CkvX(wzR!#CcZqf+D zFu<~`HSQHb@mCiFgE*7ZEioPaAjp~lv$VcWdZJO36$LIMKEMqh8dM}OP@ z@9M?|DJx2yyZGhr;^=5=1tl-NV=6yLzX1u3q?z~e4%KqdgFDP9R`!hy8VEg1^DI9GYhn;$heii+(3nu z;-X~{cHvv4&8>9WvD(~D{u~w1sv_g{fX2c|E5YseD6KsPEL>eBQGsu=0DnLH?J5h< zBdpU{R+N^1_DH=vJHt>5Se~7+gjk-PVW{xSvonla^j0<1F|xOVKUWKg2?8{|0-lRF zjaMkmKUW24dc`VxIgR!L zhZBnBa#PB)ufEf7r?gosn1Adv&F_~#PX&0HiIrzg?dN zIt6aBqP1+DixBoUrc$1YW3X$V{C(%Pg+0AxQo@ZUK#1z^#GWMHgLk z(M12$*KOY+lgnqARTYp6;S1dr&wOUKu ztbz@P_LaV43UK=3`d_X57POFO!5J$$cc^hBe+=)L;? zfm^_vZUt>ofZwk^I{DRz?;z;)wa0E((Jy_+6ws=79~F4dRrE{WaTjRSyWbD`j#~iF z@vgmlo{Qjxss>7bAVY$nR}VjE`U4RJ-Ec^Xx4gfTFZiNAFlPa;)$J7hekj22`vo0+ gKVg54Tn8Bc14@|g0zw{OdH?_b07*qoM6N<$g7EoB82|tP delta 1712 zcmV;h22c6f4ZjVLBYyw}VoOIv0RI600RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_ z000McNliru;0Ff=2nNtl1_S^A224prK~#9!?ORQ36Gs&OHvZYQll6M3iH!(SZ)s1c zaHLe+Dp9GN5~%`lKuI|{RS&J2q)pYdC6y3DAvc0h65K>!JaB5Fg zRY49Wb>e?^$KLhy;LI}qSv$`9Cy4znlefFGp7-Yc&3hZ+r+fG42PaPo*v93R6>1m; zJ~?-;>RKw3fvP9~fK(;}0GN-*t!L~ox3olSukrIPudL8!^FKa&w&ia)!NBE<7wayT z3=>y=_>uC=kAK8s7z_kjGS>(ru^0eA5~YUsnLzEvZo>Qf{rhzi4oG6v?l15%Os}tQ;Km|=}ICdKY0I;xpjb6CAOnH?fMS@f&W9>pg(<}y5MZric zW|;)Tp#ujHkOHnoa-!5jAZ4vaNI)l-9ciHdiNlL&wPkWH)xz z2P8H&FcKYx$K%0f`i0u@yR7L15jBiVE{9|)4Z}1Li$u`M=4)-=E^25xK|m54j$Ic( zYEeM9-r5PWGek)lE>TD?lcRREW)fO5)H?0LtsvjsjkoK!G2Y(G6zyD zK@$DgOlP3!8YEG|P%sFyY$7OC9GmF#;lET0CBv+|SP(EhIUzXBBf2hth2?9MX#fBW z1%n_(0?{u*4arDlb1xiLNJcCYLCG-j_md};P=6I2Mk<@L=H#D0w**jeoPKMUnO*Z9 zzTZL^;BDRK^}sBfFw8R2xhxXNBmm&<+8U0$`34S;jzW=TMAR_uuB~AtI*ddziF7Ut z!z{xroA7x(b$*1;Bla2w3YrE<^g|8F5d9)_QUs+GVL1dvmT`A&4YyZsVt(N}JlovF zKY#1%`24GR++Mwj8!I=U$TGrm2$WLjq-bf5B>Jm%dnb8BKj5u+=^}Je+>ZYx1Vj;` z!64+pK>)z1v2n~ze})H-9s>Zr`Em}Y#>N2vuPF+0g#t*CKqCYNt#O>^^N41lwC6s6 zIYCMELnlRq4GaZ?n4X*v&X11^*?b-vAqa>f z1_J>k(-j*&JUWV0HU~ivkj>|DetcY*o}3VdfG@w(l)6KW)3E1seGQ#pC&3tGM``8+yIt6D6a{#&*sl??og4Tn50=fgUThc! zyk4(0b_$(ZUzHQ=23ShW#y#r;T7T8#T7l2&dHb)m_1b%k=AXN|x=IV0R%I?u*VoGQ zECDb^Y7Z=}XdW5v+@OSHi@CX_C0cuLr)YOQ?H;%+0kFKC9dma|1HgJB0aa1(@6&aQ zxlA@^`}gaIMyvx8pAR(CfZeXIRleb6l429ur5kC15|W{WWJ@D>=9`7h^?yX7?pmkU zS0{kl14+AdZDFJtn2*PWkG{P? z8T0(JwKczpx(^4VQP|ZDcYm|K9VbG3A)_5SS18nZT7LH%(T&1prC_pUyU^XPucZK3 zO^*~y+c~wbEt>Bk?j~(!no=pnS39nY*RNBj>uV{1+6UXEor16YYI?QJihdE@UZ1xY z&4*^-6F z%wFB@3DoxSTh$Pq&Tkh3uet_wyd;*+Wvh0KeH&ny<(|xUHK5l%z-j;9DV% Date: Sun, 29 Apr 2018 18:07:44 +0200 Subject: [PATCH 70/96] Fixed Vex overlays not being aligned to its body --- .../com/minelittlepony/render/layer/LayerOverlayBase.java | 4 +++- .../render/layer/LayerPonyStrayOverlay.java | 8 +------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java index 9b43fbcd..f887a8ca 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java @@ -20,11 +20,13 @@ public abstract class LayerOverlayBase implements LayerR return true; } - protected void renderOverlay(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + @Override + public void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { ModelBase overlayModel = getOverlayModel(); overlayModel.setModelAttributes(renderer.getMainModel()); overlayModel.setLivingAnimations(entity, move, swing, ticks); + overlayModel.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); renderer.bindTexture(getOverlayTexture()); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java index cc809013..b58d5213 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java @@ -11,19 +11,13 @@ public class LayerPonyStrayOverlay extends LayerOverlayBase { public static final ResourceLocation STRAY_SKELETON_OVERLAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony_overlay.png"); - private final ModelSkeletonPony overlayModel; + private final ModelSkeletonPony overlayModel = new ModelSkeletonPony(); public LayerPonyStrayOverlay(RenderLivingBase render) { super(render); - overlayModel = new ModelSkeletonPony(); overlayModel.init(0, 0.25F); } - @Override - public void doRenderLayer(EntityStray entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { - renderOverlay(entity, move, swing, ticks, age, headYaw, headPitch, scale); - } - @Override protected ModelBase getOverlayModel() { return overlayModel; From 871f12c3e2b2948650deb4c61074da479076e67f Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 20:18:57 +0200 Subject: [PATCH 71/96] Ponies no longer float above beds when they're sleeping --- .../model/AbstractPonyModel.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index b56de29a..32a3d4be 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -487,8 +487,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch) - .tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch) .tex(4, 0) .addEastPlane( 4, -4, 4, 8, 4, stretch) + .tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch) .tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch) .addBackPlane(-4, 0, 8, 8, 4, stretch) .addBottomPlane(-4, 4, 4, 8, 4, stretch) @@ -700,13 +700,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { if (isRiding) translate(0, -0.6F, -0.2F); if (isSleeping) { - rotate(90, 0, 1, 0); - rotate(270, 0, 0, 1); - rotate(90, 0, 1, 0); - rotate(180, 0, 0, 1); + rotate(90, 1, 0, 0); rotate(180, 0, 1, 0); } + if (part == BodyPart.HEAD) { + rotate(motionPitch, 1, 0, 0); + } + if (isChild()) { transformFoal(part); } else if (metadata.getSize() == PonySize.LARGE) { @@ -714,15 +715,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } else if (metadata.getSize() == PonySize.TALL) { transformTall(part); } else { - if (isSleeping) translate(0, -0.75F, 0.25F); - } - if (part == BodyPart.HEAD) { - rotate(motionPitch, 1, 0, 0); + if (isSleeping) translate(0, -0.61F, 0.25F); } + } private void transformTall(BodyPart part) { - if (isSleeping) translate(0, -0.65F, 0.25F); + if (isSleeping) translate(0, -0.5F, 0.25F); switch (part) { case HEAD: @@ -748,7 +747,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } private void transformLarge(BodyPart part) { - if (isSleeping) translate(0, -0.7F, 0.2F); + if (isSleeping) translate(0, -0.98F, 0.2F); switch (part) { case HEAD: @@ -778,7 +777,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { private void transformFoal(BodyPart part) { if (isCrouching()) translate(0, -0.12F, 0); - if (isSleeping) translate(0, -1.2F, 0.25F); + if (isSleeping) translate(0, -1.48F, 0.25F); if (isRiding) translate(0, -0.1F, 0); switch (part) { From 0f7605edc3ec78830e21e26681ac0abbf00353c5 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 20:19:30 +0200 Subject: [PATCH 72/96] Can't always rely on Minecraft.getConnection. Mojang pls --- src/main/java/com/minelittlepony/PonyManager.java | 8 ++++++-- src/main/java/com/minelittlepony/ducks/IPlayerInfo.java | 9 --------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index da2134de..ef26715f 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -4,7 +4,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.JsonParseException; -import com.minelittlepony.ducks.IPlayerInfo; import com.minelittlepony.model.PMAPI; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.pony.data.PonyLevel; @@ -76,7 +75,12 @@ public class PonyManager implements IResourceManagerReloadListener { * @param player the player */ public Pony getPony(AbstractClientPlayer player) { - return getPony(IPlayerInfo.getPlayerInfo(player).unwrap()); + ResourceLocation skin = player.getLocationSkin(); + UUID uuid = player.getGameProfile().getId(); + + if (skin == null) return getDefaultPony(uuid); + + return getPony(skin, uuid); } public Pony getPony(NetworkPlayerInfo playerInfo) { diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index 6bb623f7..503c5059 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -1,7 +1,5 @@ package com.minelittlepony.ducks; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.network.NetworkPlayerInfo; public interface IPlayerInfo { @@ -10,13 +8,6 @@ public interface IPlayerInfo { */ boolean usesSlimArms(); - /** - * Gets the player info for the given player. - */ - public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) { - return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID()); - } - default NetworkPlayerInfo unwrap() { return (NetworkPlayerInfo)this; } From 35e9ef750be9f74f3b5b2777cfd322e35b77d2b4 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 23:06:34 +0200 Subject: [PATCH 73/96] Fixed leg outset being encorrect for normal width legs --- .../java/com/minelittlepony/model/AbstractPonyModel.java | 6 +++--- .../com/minelittlepony/model/player/ModelEarthPony.java | 6 +++++- .../com/minelittlepony/model/ponies/ModelSkeletonPony.java | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 32a3d4be..dae74b50 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -229,9 +229,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } protected float getLegOutset() { - if (isSleeping) return 2.6f; - if (isCrouching()) return 0; - return 4; + if (isSleeping) return 3.6f; + if (isCrouching()) return 1; + return 5; } protected float getLegSpread() { diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index f66d83c9..51895e34 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -26,7 +26,11 @@ public class ModelEarthPony extends AbstractPonyModel { } protected float getLegOutset() { - if (isCrouching() && smallArms) return 1; + if (smallArms) { + if (isSleeping) return 2.6f; + if (isCrouching()) return 1; + return 4; + } return super.getLegOutset(); } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java index 586ccfa6..0e999a26 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -48,6 +48,12 @@ public class ModelSkeletonPony extends ModelMobPony { } } + protected float getLegOutset() { + if (isSleeping) return 2.6f; + if (isCrouching()) return 0; + return 4; + } + protected int getArmWidth() { return 2; } From b69c365a5d66c9bff1559d1002eec772b2573714 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 29 Apr 2018 23:34:05 +0200 Subject: [PATCH 74/96] Let's cut this down a bit --- .../minelittlepony/mixin/MixinRenderItem.java | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderItem.java b/src/main/java/com/minelittlepony/mixin/MixinRenderItem.java index dee104f5..b1989d98 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderItem.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderItem.java @@ -2,42 +2,32 @@ package com.minelittlepony.mixin; import com.minelittlepony.ducks.IRenderItem; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.GlStateManager.DestFactor; +import net.minecraft.client.renderer.GlStateManager.SourceFactor; import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.resources.IResourceManagerReloadListener; -import org.spongepowered.asm.mixin.Implements; -import org.spongepowered.asm.mixin.Interface; +import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = RenderItem.class) -@Implements( value = @Interface(iface = IRenderItem.class, prefix = "mlp$") ) +@Mixin(RenderItem.class) public abstract class MixinRenderItem implements IResourceManagerReloadListener, IRenderItem { - private static final String ItemStack = "Lnet/minecraft/item/ItemStack;"; - private static final String IBakedModel = "Lnet/minecraft/client/renderer/block/model/IBakedModel;"; - private static final String ItemCameraTransform$TransformType = "Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;"; - private static final String GlStateManager$SourceFactor = "Lnet/minecraft/client/renderer/GlStateManager$SourceFactor;"; - private static final String GlStateManager$DestFactor = "Lnet/minecraft/client/renderer/GlStateManager$DestFactor;"; - private boolean transparency; - public void mlp$useTransparency(boolean transparency) { + @Override + public void useTransparency(boolean transparency) { this.transparency = transparency; } - @Redirect(method = "renderItemModel(" + ItemStack + IBakedModel + ItemCameraTransform$TransformType + "Z)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/GlStateManager;tryBlendFuncSeparate(" - + GlStateManager$SourceFactor + GlStateManager$DestFactor - + GlStateManager$SourceFactor + GlStateManager$DestFactor + ")V")) - private void redirectBlendFunc(GlStateManager.SourceFactor srcFactor, GlStateManager.DestFactor dstFactor, - GlStateManager.SourceFactor srcFactorAlpha, GlStateManager.DestFactor dstFactorAlpha) { + @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD")) + private void onRenderItem(ItemStack stack, IBakedModel model, CallbackInfo info) { if (transparency) { - GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.CONSTANT_COLOR, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); - } else { - GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.tryBlendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO); } } } From e2c94901c4df4690b37b1f0e68046c0070f985d4 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 08:31:57 +0200 Subject: [PATCH 75/96] Tried dissassembling the staircase, but it broke half the model. Could probably get it to work, but it'd take more math. --- .../model/ponies/ModelWitchPony.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java index 6eb206ac..206fff7f 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java @@ -56,17 +56,16 @@ public class ModelWitchPony extends ModelVillagerPony { @Override protected void initPositions(float yOffset, float stretch) { super.initPositions(yOffset, stretch); - witchHat.offset(-5, -6, -7) - .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) - .tex(0, 64).box(0, 0, 0, 10, 2, 10, stretch) - .child(0).offset(-5, -5, -7).around(1.75F, -4, 2) - .tex(0, 76).box(0, 0, 0, 7, 4, 7, stretch) - .rotate(-0.05235988F, 0, 0.02617994F) - .child(0).offset(-5, -4, -7).around(1.75F, -4, 2) - .tex(0, 87).box(0, 0, 0, 4, 4, 4, stretch) - .rotate(-0.10471976F, 0, 0.05235988F) - .child(0).offset(-5, -2, -7).around(1.75F, -2, 2) - .tex(0, 95).box(0, 0, 0, 1, 2, 1, stretch) - .rotate(-0.20943952F, 0, 0.10471976F); + witchHat.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) + .tex(0, 64).box(-5, -6, -7, 10, 2, 10, stretch) + .child(0).around(1.75F, -4, 2) + .tex(0, 76).box(-5, -5, -7, 7, 4, 7, stretch) + .rotate(-0.05235988F, 0, 0.02617994F) + .child(0).around(1.75F, -4, 2) + .tex(0, 87).box(-5, -4, -7, 4, 4, 4, stretch) + .rotate(-0.10471976F, 0, 0.05235988F) + .child(0).around(1.75F, -2, 2) + .tex(0, 95).box(-5, -2, -7, 1, 2, 1, stretch) + .rotate(-0.20943952F, 0, 0.10471976F); } } From 4e4b83fb30535eb022739df543b0710b862f48b1 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 08:51:36 +0200 Subject: [PATCH 76/96] Moved IRenderManager.addPlayerSkin up one and put stuff with PlayerModels into one spot --- .../java/com/minelittlepony/PonyRenderManager.java | 6 +++--- .../minelittlepony/render/player/RenderPonyBase.java | 5 +---- .../minelittlepony/render/player/RenderPonyPlayer.java | 10 +++++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 0f58ce31..e2f28bc7 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -59,9 +59,9 @@ public class PonyRenderManager { registerPlayerSkin(rm, PlayerModels.ALICORN); } - protected void registerPlayerSkin(RenderManager rm, PlayerModels playerModel) { - new RenderPonyPlayer(rm, false, playerModel.getId(false), playerModel.getModel(false)); - new RenderPonyPlayer(rm, true, playerModel.getId(true), playerModel.getModel(true)); + protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { + new RenderPonyPlayer(manager, false, playerModel); + new RenderPonyPlayer(manager, true, playerModel); } /** diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index 82fa660b..510d2c41 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -1,7 +1,6 @@ package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.ducks.IRenderPony; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.ModelWrapper; @@ -30,7 +29,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony private Pony pony; - public RenderPonyBase(RenderManager manager, boolean useSmallArms, String id, ModelWrapper model) { + public RenderPonyBase(RenderManager manager, boolean useSmallArms, ModelWrapper model) { super(manager, useSmallArms); smallArms = useSmallArms; @@ -38,8 +37,6 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony layerRenderers.clear(); addExtraLayers(); - - ((IRenderManager)manager).addPlayerSkin(id, this); } protected void addExtraLayers() { diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index de9e52f8..b566658c 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -2,15 +2,19 @@ package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IPonyAnimationHolder; -import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.ducks.IRenderManager; +import com.minelittlepony.model.player.PlayerModels; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { - public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, ModelWrapper model) { - super(renderManager, useSmallArms, id, model); + + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) { + super(renderManager, useSmallArms, model.getModel(useSmallArms)); + + ((IRenderManager)renderManager).addPlayerSkin(model.getId(useSmallArms), this); } @Override From 3a8ac047b1406a0168cf4174c96a1e7a78fe2b5e Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 09:00:15 +0200 Subject: [PATCH 77/96] Moved it up one more. That looks better. --- src/main/java/com/minelittlepony/PonyRenderManager.java | 9 +++++++-- .../minelittlepony/render/player/RenderPonyPlayer.java | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index e2f28bc7..23fb8822 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -3,6 +3,7 @@ package com.minelittlepony; import java.util.Map; import com.google.common.collect.Maps; +import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.RenderPonyModel; import com.minelittlepony.model.player.PlayerModels; @@ -60,8 +61,12 @@ public class PonyRenderManager { } protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { - new RenderPonyPlayer(manager, false, playerModel); - new RenderPonyPlayer(manager, true, playerModel); + addPlayerSkin(manager, new RenderPonyPlayer(manager, false, playerModel)); + addPlayerSkin(manager, new RenderPonyPlayer(manager, true, playerModel)); + } + + public void addPlayerSkin(RenderManager manager, RenderPonyPlayer renderer) { + ((IRenderManager)manager).addPlayerSkin(renderer.skinId, renderer); } /** diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index b566658c..dfdb89a8 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -2,7 +2,6 @@ package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IPonyAnimationHolder; -import com.minelittlepony.ducks.IRenderManager; import com.minelittlepony.model.player.PlayerModels; import net.minecraft.client.entity.AbstractClientPlayer; @@ -11,10 +10,14 @@ import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { + /** + * The id used to find this renderer in the player skin map. + */ + public final String skinId; + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) { super(renderManager, useSmallArms, model.getModel(useSmallArms)); - - ((IRenderManager)renderManager).addPlayerSkin(model.getId(useSmallArms), this); + skinId = model.getId(useSmallArms); } @Override From 51e5c9ddc53075aeedfc3c637a6f22a2276fdd8f Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 10:31:14 +0200 Subject: [PATCH 78/96] Fixed unicorns not swinging their arms when their hands are empty --- .../java/com/minelittlepony/model/AbstractPonyModel.java | 2 -- .../java/com/minelittlepony/model/player/ModelAlicorn.java | 7 +++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index dae74b50..ce81c541 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -293,8 +293,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { if (swingProgress > -9990.0F && !isSleeping) { EnumHandSide mainSide = getMainHand(entity); - if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; - swingArm(getArmForSide(mainSide)); } } diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java index 47bf83f8..610e274c 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -63,11 +63,10 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { @Override protected void swingItem(Entity entity, float swingProgress) { - if (canCast()) { - if (swingProgress > -9990.0F && !isSleeping) { - EnumHandSide mainSide = getMainHand(entity); + EnumHandSide mainSide = getMainHand(entity); - if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return; + if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) { + if (swingProgress > -9990.0F && !isSleeping) { swingArm(getUnicornArmForSide(mainSide)); } } else { From ab8ab99bd5e2226ee22686568d1912969b82a6cb Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 11:48:35 +0200 Subject: [PATCH 79/96] Fixed rendering issues where the skin upload renders with the wrong model --- .../hdskins/gui/EntityPonyModel.java | 30 ++++++++++++++++++ .../hdskins/gui/RenderPonyModel.java | 30 +++++++++++++----- .../minelittlepony/textures/mob/noskin.png | Bin 0 -> 1944 bytes 3 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/minelittlepony/textures/mob/noskin.png diff --git a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java index 1c93e6f8..55754c12 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java @@ -1,14 +1,44 @@ package com.minelittlepony.hdskins.gui; +import java.io.File; + import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; + /** * Dummy model used for the skin uploading screen. */ public class EntityPonyModel extends EntityPlayerModel { + public static final ResourceLocation NO_SKIN_PONY = new ResourceLocation("minelittlepony", "textures/mob/noskin.png"); + public EntityPonyModel(GameProfile profile) { super(profile); } + + public void setLocalTexture(File skinTextureFile, Type type) { + super.setLocalTexture(skinTextureFile, type); + } + + public ResourceLocation getSkinTexture() { + ResourceLocation skin = super.getSkinTexture(); + if (skin == NO_SKIN) { + // We're a pony, might as well look like one. + return NO_SKIN_PONY; + } + + return skin; + } + + public void swingArm() { + super.swingArm(); + + // Fixes the preview model swinging the wrong arm. + // Who's maintaining HDSkins anyway? + this.swingingHand = EnumHand.MAIN_HAND; + } } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 936611aa..cf26ab0c 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -1,13 +1,15 @@ package com.minelittlepony.hdskins.gui; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; +import com.minelittlepony.PonyManager; import com.minelittlepony.model.ModelWrapper; import com.minelittlepony.model.components.PonyElytra; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.render.layer.AbstractPonyLayer; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelElytra; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; @@ -23,18 +25,24 @@ import net.minecraft.util.ResourceLocation; */ public class RenderPonyModel extends RenderPlayerModel { + boolean renderingAsHuman = false; + public RenderPonyModel(RenderManager renderer) { super(renderer); } @Override public ModelPlayer getEntityModel(EntityPonyModel playermodel) { + renderingAsHuman = true; + ResourceLocation loc = getEntityTexture(playermodel); if (loc == null) { return super.getEntityModel(playermodel); } - Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId()); + // TODO: We can't find out whether to use thin arms just by the texture. + // Maybe a trigger pixel for thin arms? #FutureThoughts + Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, PonyManager.isSlimSkin(playermodel.profile.getId())); if (thePony.getRace(false).isHuman()) { return super.getEntityModel(playermodel); @@ -43,13 +51,16 @@ public class RenderPonyModel extends RenderPlayerModel { ModelWrapper pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); + renderingAsHuman = false; + return pm.getModel(); } @Override protected LayerRenderer getElytraLayer() { return new AbstractPonyLayer(this) { - final PonyElytra modelElytra = new PonyElytra(); + final PonyElytra ponyElytra = new PonyElytra(); + final ModelElytra modelElytra = new ModelElytra(); @Override public void doPonyRender(EntityPonyModel entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { @@ -61,12 +72,15 @@ public class RenderPonyModel extends RenderPlayerModel { bindTexture(entity.getElytraTexture()); GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0.25F, 0.125F); - ((AbstractPonyModel) mainModel).transform(BodyPart.BODY); - modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); - modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); + ModelBase model = renderingAsHuman ? modelElytra : ponyElytra; + if (!renderingAsHuman) { + GlStateManager.translate(0, 0.25F, 0.125F); + } + + model.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); + model.render(entity, swing, swingAmount, age, yaw, head, scale); GlStateManager.popMatrix(); } diff --git a/src/main/resources/assets/minelittlepony/textures/mob/noskin.png b/src/main/resources/assets/minelittlepony/textures/mob/noskin.png new file mode 100644 index 0000000000000000000000000000000000000000..2234de1ea5444c384ac3e4f369a9d0165c831aa6 GIT binary patch literal 1944 zcmV;J2WR++P)T+4Fbtt-8iF9en>TM5_7UgK zofBE(YpU=7(CKvW?%lh{4ZiQAR4TzRjL3Dym~6LgTmH3eTlNWp0AUzLe&fVW;~RM% zQYw`I0G{VT*Y(6cuU@^1oS!;%N?MGjY4AKxwiOD6u__{K{6qzGI-SVu8-^h@sp~ol zg@U}67nWtoW6$$oS=LyUkT!mz0?OrbL|dvRIp>jw?F7|rNMO1@?o#`KoyOPl`Vr@R zK$BT$Hk*mWL*}TOCPb>H{lc^)|D5i22|&r)7oal=^AUP&-(d?U;J z(?~?u^@#tgZjxkzaWl;7zaK7;H9ni0n-dh%8Dn6K!LlrA@^q7~>*)9U;G9F#G#G{f zA%u(yx~{|XJP0A=vq*Vac|@bpU^qZTEI1} zds~`Tzu!j?1kiO|3YU~ekV(e#hyzuCVHonIHBFN<==;7Tjyremz%)%9IdTNQfByz! z42?zuj~+cjx7(FgA%uXYX$Zp*LI@de^W+f+1uX~yXqtvXp#WXirRkfd3DY!j>((s@ zA<$~I@bl+S)a!MGVTe|%g)3LC$bMuclqXQCNy?=>f;gj8Dvgy3QWZd^9|VD9%$1cD ztgf!YvMdyfMclr98(+SB0b>lujvd3>w{LO({(VeOPs6e-tgfzNWn~4NbNL)0L~0%} zj`*J!k^~uJ2*VJjY2w0#3#ip|W<0n;>L z+cuibCSJUFfquU)-9aV6q&y-B0@UmE10@1BKR+*mAb?>QIDPsw&YnFB&-38AF52xj zW@l%iX&M@hM&!n7wTf=Hi*~yW+qU624lK*UhYug{@#9C(Gs7^9$(7dcDp_B zv2_0YdDym%$B!Q$tOD-cyC>pFkBWy6A4bkUefq=z;O5Pn!uNfd3p{x6fC0eT+M4+F z>sR7n)6>&<{rYw03oS1%gE1y^30>DAgh0RFN1;$ay!6Mwm8gs})w`o1rt3u8+9>0^W(>lL)UdwDizGm&f>?99{_-@tt|k+ z=H})=G*J~sE=9s8MISY3i?<&=dNgwW~Cy72XTfbpnd}alzDMwZD2yLUPUrloXFJgkG;Vo+vOiH6?jK6_QfhBtghr z>0A{mz8t2KUEB)JoH-L&tUYn!M5NE>&z~cUIP>%KaSj;X0w}x?vN%E&Ccf;X3P$Ft z_MzjXnM_kkoJh;%a%2^IBo>eqW{4x=ZE*`w$*9-srTVF=h+?sbUauGN?_RG5+qTi^ zbP|{8k|Ij{dbL{3r-0oOV4QjLuy9hJyo)5Hh%~{-67mQ>GzaWPAv+0~ro5zQWLZMm z^;`;|cwMPfGCNYgv}zE&v`TixVo`>(v{{bFd6h(ymfzz^(f0QCfFd?GH&LxtQ(Yv{ z0@4Ij6PhGcDisJJP^nbVYPGPqxR^+)w79CiXr)rY!oq?i+-|ok`PC}Ap zWLe0*<^g$J#c>?DZb+7<_H`Twj^oI6hQ-Cj0kTzRH!T`WFu?>9OfbO&6HG9{1QSd! z!2}cJ!N@l!oIH6lQo_A{{d%PR?%lhYV_v;_RjBp<@87>is=v>kJsaseYlm${MqU5^ z;}j6DJgKuEZ~H41kfn@6$pOReFQ`_l5z~JE{(YoBmCHHj@O^(^X?xiE|4ta&jzv;J zl3%N}0N?iq%HLVl;y=O#hN&!((D5xYq@cf^1Jp`!-koI!?gFZh4@+$OUH>1O1*m%n z;`ro5hHVf-R>_?-9Yv6QJVRo&jZrf epN{vl_WvK61a9K(5$9z90000 Date: Mon, 30 Apr 2018 11:49:29 +0200 Subject: [PATCH 80/96] Rendering is super annoying, I agree >.> --- .../minelittlepony/model/AbstractPonyModel.java | 7 +++++-- .../minelittlepony/render/plane/ModelPlane.java | 16 ++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index ce81c541..a3b667f6 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -71,6 +71,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + this.boxList.clear(); + this.init(0, 0); + super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; @@ -490,8 +493,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { .tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch) .addBackPlane(-4, 0, 8, 8, 4, stretch) .addBottomPlane(-4, 4, 4, 8, 4, stretch) - .flipZ().tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch) - .tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch) + .flipZ().tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch) + .tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch) .tex(4, 0) .addWestPlane(-4, -4, 4, 8, 4, stretch) // Tail stub .child(0) diff --git a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java index 0d713740..ebf41c03 100644 --- a/src/main/java/com/minelittlepony/render/plane/ModelPlane.java +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -42,14 +42,14 @@ public class ModelPlane extends Box { } // w:west e:east d:down u:up s:south n:north - Vertex wds = vert(xMin , yMin , zMin , 0, 0); - Vertex eds = vert(xMax, yMin , zMin , 0, 8); - Vertex eus = vert(xMax, yMax, zMin , 8, 8); - Vertex wus = vert(xMin , yMax, zMin , 8, 0); - Vertex wdn = vert(xMin , yMin , zMax, 0, 0); - Vertex edn = vert(xMax, yMin , zMax, 0, 8); + Vertex wds = vert(xMin, yMin, zMin, 0, 0); + Vertex eds = vert(xMax, yMin, zMin, 0, 8); + Vertex eus = vert(xMax, yMax, zMin, 8, 8); + Vertex wus = vert(xMin, yMax, zMin, 8, 0); + Vertex wdn = vert(xMin, yMin, zMax, 0, 0); + Vertex edn = vert(xMax, yMin, zMax, 0, 8); Vertex eun = vert(xMax, yMax, zMax, 8, 8); - Vertex wun = vert(xMin , yMax, zMax, 8, 0); + Vertex wun = vert(xMin, yMax, zMax, 8, 0); if (face == Face.EAST) { quad = quad(textureX, d, textureY, h, edn, eds, eus, eun); @@ -58,7 +58,7 @@ public class ModelPlane extends Box { quad = quad(textureX, d, textureY, h, wds, wdn, wun, wus); } if (face == Face.UP) { - quad = quad(textureX, w, textureY, h, edn, wdn, wds, eds); + quad = quad(textureX, w, textureY, d, edn, wdn, wds, eds); } if (face == Face.DOWN) { quad = quad(textureX, w, textureY, d, eus, wus, wun, eun); From d23c3f23facba04a7a83197a1b9e0e877a39765d Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 11:50:03 +0200 Subject: [PATCH 81/96] This background pony didn't have a race bit properly set so it rendered as a human in the skin select screen --- .../textures/entity/pony/bpony_14.png | Bin 669 -> 976 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/minelittlepony/textures/entity/pony/bpony_14.png b/src/main/resources/assets/minelittlepony/textures/entity/pony/bpony_14.png index 60743c05678159a24d15f12ce1a11b06aa05e34d..6d1ee486d3890ce1819387acf2fc5b3abd09f92e 100644 GIT binary patch delta 955 zcmV;s14R6t1<(hOBYy*zNkldh+P4 zNIgU;7<#Qxf)&ZZmQW}NQbL8QpLIm(Kn2r+mr_V*X@v@voDAckPT1Y< zUv_qvO*0>q(AnL$`@Z?!oA+jye1G4d!%t!a|1rOFLZLxEyMKakB&r%~ogQL3n+7im zOY5e`f37|zJofecQ6iLD{HhulucYwl(TZwpI-5r8^w3r3mG@EF_8Xz?-ANV0x$-R5 z7S0~fD~wlC2wzKLZ9%Olt-^dE003lJrm`$k0La{5M5|drdO2wr0^vv$`Rt10o2HkO zXf-Q%`R;DVo_~?^v56dwP2|qWSZ~Y;$nmdZm7y<7_fXq!0dM z$=4)QSXwuoaVs@gtrAuWkg8i%^~lYn@0r-l!A2=VVt*4k>c(vAD!_^%H(*vr%*6+Y zGO@Aql=00Ho*4;t@`2$hV1~K)fTLq}W?j3IG)fu5Vm};-b{ub%GK3w|TP|6cI9VA& zX3N=Jd;pYE6!T>iUdx^FV!n)Gz6?sKEfTbal$rF695o|CNnE#(ED{K2HtP8C<{>Dh zSlImy0DqnTXEy4X-#KwTWUQpD3=KB(PUH^&A*-ThIC1?fSrD~-LP+PB9T=&AmndGF zu5@SQIB}Cq4$CXmp4(gi+NQ@03F*ej8;vyhqx4vhNGa{VAi%{^a z4$zzFk5h4?tgxP5{R;pXyfR1tfQ6LX`v%=UAAbXD^0qYv-pF3Xeh4t>2NgWe*LC5q zRSfGL*f{GPnasVKeY@B;DDBy}h@$IEc|Z5PYlM+gP<+sunq zpx;&j&-Vj@4zs-g5dwk$L4Y7Y5FiK;1c*xTLStmFVz?L3Zq|eXT<-?0-py&>-@AQ% zAaelk_XS>lpCFQ85L!~NulF2b~3wBYy&9NklJY^Vbi%cBtRx)lKP`CNhG2%w`N^%Q`zp$>pe4W>ZwH#N+Z*9gGsd!=-J9v`al zXx}?exuXE;fVymD`+NgF#|D7Cj|vT=01$$nrT_qHGddJP@)3~2v&XIiE@OQll8=Bc z0Qd~#tP)-TZGRZ)a-!6+ndY}?m1yD*nl2NK?)d=N8f}AM13_1eXaFu}1_pv0T|KG6 z<-B5{1b^-bpb$C-5Mr>d^gWCqO+Ztg z8^pE`#TMYLH-IrcUMc`n`?3KD4Q(wKT9T0Th}@w00000NkvXXu0mjfbJz}p From 6981cde884a5a3c58310cd70f7b1f945317817e2 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 12:53:08 +0200 Subject: [PATCH 82/96] Debug code pls --- src/main/java/com/minelittlepony/model/AbstractPonyModel.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index a3b667f6..0decb91d 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -71,9 +71,6 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { @Override public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - this.boxList.clear(); - this.init(0, 0); - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; From e4281116cd6d6af6a4f07a3669a3e1a62eb43169 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 17:12:08 +0200 Subject: [PATCH 83/96] Remove these todos because I think they've been done now --- src/main/java/com/minelittlepony/model/package-info.java | 2 -- src/main/java/com/minelittlepony/package-info.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/package-info.java b/src/main/java/com/minelittlepony/model/package-info.java index 40137727..6dc6a541 100644 --- a/src/main/java/com/minelittlepony/model/package-info.java +++ b/src/main/java/com/minelittlepony/model/package-info.java @@ -5,5 +5,3 @@ package com.minelittlepony.model; import mcp.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; - -// TODO: Class/Enum/Interface names are inconsistent. \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/package-info.java b/src/main/java/com/minelittlepony/package-info.java index 28e8a42d..a1d3fc42 100644 --- a/src/main/java/com/minelittlepony/package-info.java +++ b/src/main/java/com/minelittlepony/package-info.java @@ -5,5 +5,3 @@ package com.minelittlepony; import mcp.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; - -// TODO: Code style is inconsistent \ No newline at end of file From e0732a14d6d56d43f413443385f1c20f8595ee74 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 17:24:07 +0200 Subject: [PATCH 84/96] Arrows seem to work fine, so let's re-enable them --- src/main/java/com/minelittlepony/render/RenderPonyMob.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index eb1326b6..9223fac5 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -11,6 +11,7 @@ import com.minelittlepony.render.layer.LayerPonyElytra; import com.voxelmodpack.hdskins.HDSkinManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; @@ -30,7 +31,7 @@ public abstract class RenderPonyMob extends RenderLiving protected void addLayers() { addLayer(new LayerPonyArmor<>(this)); - // addLayer(new LayerArrow(this)); + addLayer(new LayerArrow(this)); addLayer(new LayerPonyCustomHead<>(this)); addLayer(new LayerPonyElytra<>(this)); addLayer(createItemHoldingLayer()); From 4513f1c443c946b583cd75129d1946d0092b2b3e Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 17:27:21 +0200 Subject: [PATCH 85/96] Fixed bows shooting off into space https://www.youtube.com/watch?v=7dwLCHNdqWw --- .../java/com/minelittlepony/model/AbstractPonyModel.java | 7 +++---- .../java/com/minelittlepony/model/player/ModelAlicorn.java | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 0decb91d..56479dd9 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -371,17 +371,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false); + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick); } - protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) { + protected void aimBowPony(ModelRenderer arm, float tick) { arm.rotateAngleZ = 0; arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1); } protected void fixSpecialRotationPoints(float move) { diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java index 610e274c..a39f49f9 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -126,8 +126,8 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { @Override protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { if (canCast()) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false); + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick); } else { super.aimBow(leftArm, rightArm, tick); } From df5d18d3506817d79ec2e68802a0e464cfcb7385 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 12:38:13 +0200 Subject: [PATCH 86/96] One last codestyle commit to clean stuff up I missed, correct and document some names, and add TODO items for everything that needs to be done. --- .../com/minelittlepony/MineLittlePony.java | 10 +- .../java/com/minelittlepony/PonyManager.java | 4 +- .../com/minelittlepony/PonyRenderManager.java | 44 ++-- .../com/minelittlepony/ducks/IPlayerInfo.java | 3 + .../hdskins/gui/EntityPonyModel.java | 2 +- .../hdskins/gui/GuiSkinsMineLP.java | 11 +- .../hdskins/gui/RenderPonyModel.java | 10 +- .../mixin/MixinNetworkPlayerInfo.java | 10 +- .../model/AbstractPonyModel.java | 216 +++++++++++++----- .../minelittlepony/model/ModelMobPony.java | 14 +- .../minelittlepony/model/ModelWrapper.java | 9 +- .../java/com/minelittlepony/model/PMAPI.java | 1 + .../model/armour/ModelPonyArmor.java | 11 +- .../model/armour/ModelZombiePonyArmor.java | 8 +- .../model/armour/PonyArmor.java | 3 +- .../model/armour/package-info.java | 7 + .../model/capabilities/IModel.java | 5 +- .../model/capabilities/IModelWrapper.java | 15 ++ .../model/capabilities/package-info.java | 7 + .../model/components/PonyElytra.java | 16 +- .../model/components/PonyTail.java | 9 +- .../model/components/package-info.java | 7 + .../model/player/ModelAlicorn.java | 36 +-- .../model/player/ModelEarthPony.java | 4 +- .../model/player/ModelPegasus.java | 14 +- .../model/player/package-info.java | 7 + .../model/ponies/ModelBreezie.java | 10 +- .../model/ponies/ModelIllagerPony.java | 24 +- .../model/ponies/ModelVillagerPony.java | 8 +- .../model/ponies/ModelWitchPony.java | 9 +- .../model/ponies/ModelZombiePony.java | 8 +- .../com/minelittlepony/pony/data/Pony.java | 26 +-- .../pony/data/package-info.java | 7 + .../render/AbstractPonyRenderer.java | 10 + .../render/layer/AbstractPonyLayer.java | 18 +- .../layer/LayerEntityOnPonyShoulder.java | 29 +-- .../render/layer/LayerHeldItemIllager.java | 4 +- .../render/layer/LayerHeldPonyItem.java | 2 +- .../render/layer/LayerOverlayBase.java | 8 +- .../render/layer/LayerPonyArmor.java | 20 +- .../render/layer/LayerPonyCape.java | 2 +- .../render/layer/LayerPonyCustomHead.java | 3 +- .../render/layer/LayerPonyElytra.java | 8 +- .../render/player/RenderPonyBase.java | 3 - .../render/player/RenderPonyPlayer.java | 2 +- .../render/ponies/RenderPonySkeleton.java | 4 +- .../render/ponies/RenderPonyZombie.java | 2 + .../util/coordinates/Vertex.java | 6 +- 48 files changed, 440 insertions(+), 256 deletions(-) create mode 100644 src/main/java/com/minelittlepony/model/armour/package-info.java create mode 100644 src/main/java/com/minelittlepony/model/capabilities/IModelWrapper.java create mode 100644 src/main/java/com/minelittlepony/model/capabilities/package-info.java create mode 100644 src/main/java/com/minelittlepony/model/components/package-info.java create mode 100644 src/main/java/com/minelittlepony/model/player/package-info.java create mode 100644 src/main/java/com/minelittlepony/pony/data/package-info.java diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index c566d09f..d5b56797 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -23,13 +23,11 @@ public class MineLittlePony { public static final Logger logger = LogManager.getLogger("MineLittlePony"); - public static final String - MOD_NAME = "Mine Little Pony", - MOD_VERSION = "@VERSION@"; + public static final String MOD_NAME = "Mine Little Pony"; + public static final String MOD_VERSION = "@VERSION@"; - private static final String - SKIN_SERVER_URL = "minelpskins.voxelmodpack.com", - GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; + private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; + private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index ef26715f..81dcab6e 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -143,8 +143,8 @@ public class PonyManager implements IResourceManagerReloadListener { /** * De-registers a pony from the cache. */ - public Pony removePony(ResourceLocation location) { - return poniesCache.remove(location); + public Pony removePony(ResourceLocation resource) { + return poniesCache.remove(resource); } @Override diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 23fb8822..95a7a0a0 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -44,20 +44,16 @@ public class PonyRenderManager { private final Map, Render> renderMap = Maps.newHashMap(); - public PonyRenderManager() { - - } - /** * Registers all new player skin types. (currently only pony and slimpony). */ - public void initialisePlayerRenderers(RenderManager rm) { + public void initialisePlayerRenderers(RenderManager manager) { // Preview on the select skin gui - ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); + ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(manager)); - registerPlayerSkin(rm, PlayerModels.EARTH); - registerPlayerSkin(rm, PlayerModels.PEGASUS); - registerPlayerSkin(rm, PlayerModels.ALICORN); + registerPlayerSkin(manager, PlayerModels.EARTH); + registerPlayerSkin(manager, PlayerModels.PEGASUS); + registerPlayerSkin(manager, PlayerModels.ALICORN); } protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { @@ -72,12 +68,12 @@ public class PonyRenderManager { /** * Registers all entity model replacements. (except for players). */ - public void initializeMobRenderers(RenderManager rm, PonyConfig config) { + public void initializeMobRenderers(RenderManager manager, PonyConfig config) { if (config.villagers) { - pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm)); - pushNewRenderer(rm, EntityWitch.class, new RenderPonyWitch(rm)); - pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); + pushNewRenderer(manager, EntityVillager.class, new RenderPonyVillager(manager)); + pushNewRenderer(manager, EntityWitch.class, new RenderPonyWitch(manager)); + pushNewRenderer(manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager)); MineLittlePony.logger.info("Villagers are now ponies."); } else { restoreRenderer(EntityVillager.class); @@ -86,9 +82,9 @@ public class PonyRenderManager { } if (config.zombies) { - pushNewRenderer(rm, EntityZombie.class, new RenderPonyZombie<>(rm)); - pushNewRenderer(rm, EntityHusk.class, new RenderPonyZombie.Husk(rm)); - pushNewRenderer(rm, EntityGiantZombie.class, new RenderPonyZombie.Giant(rm)); + pushNewRenderer(manager, EntityZombie.class, new RenderPonyZombie<>(manager)); + pushNewRenderer(manager, EntityHusk.class, new RenderPonyZombie.Husk(manager)); + pushNewRenderer(manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager)); MineLittlePony.logger.info("Zombies are now ponies."); } else { restoreRenderer(EntityZombie.class); @@ -97,16 +93,16 @@ public class PonyRenderManager { } if (config.pigzombies) { - pushNewRenderer(rm, EntityPigZombie.class, new RenderPonyPigman(rm)); + pushNewRenderer(manager, EntityPigZombie.class, new RenderPonyPigman(manager)); MineLittlePony.logger.info("Zombie pigmen are now ponies."); } else { restoreRenderer(EntityPigZombie.class); } if (config.skeletons) { - pushNewRenderer(rm, EntitySkeleton.class, new RenderPonySkeleton<>(rm)); - pushNewRenderer(rm, EntityStray.class, new RenderPonySkeleton.Stray(rm)); - pushNewRenderer(rm, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); + pushNewRenderer(manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager)); + pushNewRenderer(manager, EntityStray.class, new RenderPonySkeleton.Stray(manager)); + pushNewRenderer(manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager)); MineLittlePony.logger.info("Skeletons are now ponies."); } else { restoreRenderer(EntitySkeleton.class); @@ -115,10 +111,10 @@ public class PonyRenderManager { } if (config.illagers) { - pushNewRenderer(rm, EntityVex.class, new RenderPonyVex(rm)); - pushNewRenderer(rm, EntityEvoker.class, new RenderPonyIllager.Evoker(rm)); - pushNewRenderer(rm, EntityVindicator.class, new RenderPonyIllager.Vindicator(rm)); - pushNewRenderer(rm, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(rm)); + pushNewRenderer(manager, EntityVex.class, new RenderPonyVex(manager)); + pushNewRenderer(manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager)); + pushNewRenderer(manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager)); + pushNewRenderer(manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager)); MineLittlePony.logger.info("Illagers are now ponies."); } else { restoreRenderer(EntityVex.class); diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index 503c5059..bf7ef895 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -8,6 +8,9 @@ public interface IPlayerInfo { */ boolean usesSlimArms(); + /** + * Quick cast back to the original type. + */ default NetworkPlayerInfo unwrap() { return (NetworkPlayerInfo)this; } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java index 55754c12..7b35c4a4 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java @@ -39,6 +39,6 @@ public class EntityPonyModel extends EntityPlayerModel { // Fixes the preview model swinging the wrong arm. // Who's maintaining HDSkins anyway? - this.swingingHand = EnumHand.MAIN_HAND; + swingingHand = EnumHand.MAIN_HAND; } } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java index 2bad9f35..1a540e88 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -4,6 +4,7 @@ import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyManager; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.GuiSkins; import net.minecraft.util.ResourceLocation; @@ -25,18 +26,18 @@ public class GuiSkinsMineLP extends GuiSkins { } @Override - protected void onSetLocalSkin(MinecraftProfileTexture.Type type) { + protected void onSetLocalSkin(Type type) { MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); - if (type == MinecraftProfileTexture.Type.SKIN) { + if (type == Type.SKIN) { ponyManager.removePony(localPlayer.getSkinTexture()); } } @Override - protected void onSetRemoteSkin(MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { + protected void onSetRemoteSkin(Type type, ResourceLocation resource, MinecraftProfileTexture profileTexture) { MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); - if (type == MinecraftProfileTexture.Type.SKIN) { - ponyManager.removePony(location); + if (type == Type.SKIN) { + ponyManager.removePony(resource); } } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index cf26ab0c..38e8fed9 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -27,8 +27,8 @@ public class RenderPonyModel extends RenderPlayerModel { boolean renderingAsHuman = false; - public RenderPonyModel(RenderManager renderer) { - super(renderer); + public RenderPonyModel(RenderManager manager) { + super(manager); } @Override @@ -63,7 +63,7 @@ public class RenderPonyModel extends RenderPlayerModel { final ModelElytra modelElytra = new ModelElytra(); @Override - public void doPonyRender(EntityPonyModel entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { + public void doPonyRender(EntityPonyModel entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { @@ -79,8 +79,8 @@ public class RenderPonyModel extends RenderPlayerModel { GlStateManager.translate(0, 0.25F, 0.125F); } - model.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); - model.render(entity, swing, swingAmount, age, yaw, head, scale); + model.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + model.render(entity, move, swing, ticks, headYaw, headPitch, scale); GlStateManager.popMatrix(); } diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java index ab91b363..af1323ef 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -9,10 +9,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyManager; import com.minelittlepony.ducks.IPlayerInfo; -import com.mojang.authlib.GameProfile; import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.util.ResourceLocation; @Mixin(NetworkPlayerInfo.class) public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { @@ -20,12 +18,6 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { @Shadow private String skinType; - @Shadow - public abstract ResourceLocation getLocationSkin(); - - @Shadow - public abstract GameProfile getGameProfile(); - @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true) private void getSkinType(CallbackInfoReturnable info) { info.setReturnValue(MineLittlePony.getInstance().getManager().getPony(unwrap()).getRace(false).getModel().getId(usesSlimArms())); @@ -33,7 +25,7 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { @Override public boolean usesSlimArms() { - if (skinType == null) return PonyManager.isSlimSkin(getGameProfile().getId()); + if (skinType == null) return PonyManager.isSlimSkin(unwrap().getGameProfile().getId()); return "slim".equals(skinType); } } diff --git a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java index 56479dd9..c7b96fdd 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -69,9 +69,20 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); } + /** + * Sets the model's various rotation angles. + * + * @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount. + * @param swing Degree to which each 'limb' swings. + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + * @param headYaw Horizontal head motion in radians. + * @param headPitch Vertical head motion in radians. + * @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}. + * @param entity The entity we're being called for. + */ @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F; @@ -86,11 +97,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; } - rotateLook(move, swing, bodySwingRotation, age); + rotateLook(move, swing, bodySwingRotation, ticks); - setLegs(move, swing, age, entity); + setLegs(move, swing, ticks, entity); holdItem(swing); - swingItem(entity, swingProgress); + swingItem(entity); if (isCrouching()) { adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); @@ -115,13 +126,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - swingArms(age); + swingArms(ticks); setHead(0, 0, 0); } if (isSleeping) ponySleep(); - aimBow(leftArmPose, rightArmPose, age); + aimBow(leftArmPose, rightArmPose, ticks); fixSpecialRotationPoints(move); animateWears(); @@ -137,6 +148,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { setHead(0, 0, 0); } + /** + * Sets the model's various rotation angles. + * + * @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount. + * @param swing Degree to which each 'limb' swings. + * @param bodySwing Horizontal (Y) body rotation. + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + */ protected void rotateLook(float move, float swing, float bodySwing, float ticks) { tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks); bodySwing /= 5; @@ -155,7 +174,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } /** - * Sets the head rotation angle. + * Sets the head rotation point. */ protected void setHead(float posX, float posY, float posZ) { bipedHead.setRotationPoint(posX, posY, posZ); @@ -165,28 +184,46 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { /** * Called to update the head rotation. * - * @param x New rotation X - * @param y New rotation Y + * @param x New rotation X + * @param y New rotation Y */ protected void updateHeadRotation(float x, float y) { bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y; bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; } - protected void setLegs(float move, float swing, float tick, Entity entity) { + /** + * + * Used to set the legs rotation based on walking/crouching animations. + * + * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} + * + * TODO: This can be merged into adjustLegs + * + */ + protected void setLegs(float move, float swing, float ticks, Entity entity) { if (isFlying(entity)) { - rotateLegsInFlight(move, swing, tick, entity); + rotateLegsInFlight(move, swing, ticks, entity); } else { - rotateLegsOnGround(move, swing, tick, entity); + rotateLegsOnGround(move, swing, ticks, entity); } bipedLeftArm.rotateAngleZ = 0; bipedRightArm.rotateAngleZ = 0; - adjustLegs(move, swing, tick); + adjustLegs(move, swing, ticks); } - protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + /** + * Rotates legs in quopy fashion whilst flying. + * + * @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount. + * @param swing Degree to which each 'limb' swings. + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + * @param entity The entity we're being called for. + * + */ + protected void rotateLegsInFlight(float move, float swing, float ticks, Entity entity) { float armX = MathHelper.sin(-swing / 2); float legX = MathHelper.sin(swing / 2); @@ -203,23 +240,26 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { bipedRightLeg.rotateAngleY = -0.2F; } - protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { - float pi = PI * (float) Math.pow(swing, 16); + /** + * Rotates legs in quopy fashion for walking. + * + * @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount. + * @param swing Degree to which each 'limb' swings. + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + * @param entity The entity we're being called for. + * + */ + protected void rotateLegsOnGround(float move, float swing, float ticks, Entity entity) { + float angle = PI * (float) Math.pow(swing, 16); - float mve = move * 0.6662F; // magic number ahoy - float srt = swing / 4; + float baseRotation = move * 0.6662F; // magic number ahoy + float scale = swing / 4; - float leftArm = MathHelper.cos(mve + pi) * srt; - float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; + bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale; + bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale; - float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; - float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; - - bipedLeftArm.rotateAngleX = leftArm; - bipedRightArm.rotateAngleX = rightArm; - - bipedLeftLeg.rotateAngleX = leftLeg; - bipedRightLeg.rotateAngleX = rightLeg; + bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale; + bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale; bipedLeftArm.rotateAngleY = 0; bipedRightArm.rotateAngleY = 0; @@ -238,7 +278,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { return rainboom ? 2 : 1; } - protected void adjustLegs(float move, float swing, float tick) { + /** + * + * Used to set the legs rotation based on walking/crouching animations. + * + * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} + * + * TODO: This can be merged into setLegs + * + */ + protected void adjustLegs(float move, float swing, float ticks) { float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; @@ -262,6 +311,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; } + /** + * Adjusts legs as if holding an item. Delegates to the correct arm/leg/limb as neccessary. + * + * @param swing + */ protected void holdItem(float swing) { boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; @@ -269,6 +323,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { alignArmForAction(bipedRightArm, rightArmPose, both, swing); } + /** + * Aligns an arm for the appropriate arm pose + * + * @param arm The arm model to align + * @param pose The post to align to + * @param both True if we have something in both hands + * @param swing Degree to which each 'limb' swings. + */ protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { switch (pose) { case ITEM: @@ -289,7 +351,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } } - protected void swingItem(Entity entity, float swingProgress) { + /** + * Animates arm swinging. Delegates to the correct arm/leg/limb as neccessary. + * + * @param entity The entity we are being called for. + */ + protected void swingItem(Entity entity) { if (swingProgress > -9990.0F && !isSleeping) { EnumHandSide mainSide = getMainHand(entity); @@ -297,6 +364,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } } + /** + * Animates arm swinging. + * + * @param arm The arm to swing + */ protected void swingArm(ModelRenderer arm) { float swing = 1 - (float)Math.pow(1 - swingProgress, 3); @@ -310,11 +382,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { arm.rotateAngleZ = -deltaZ * 0.4F; } - protected void swingArms(float tick) { + /** + * Animates the walking animation. + * + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + */ + protected void swingArms(float ticks) { if (isSleeping) return; - float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sin = MathHelper.sin(tick * 0.067F) * 0.05F; + float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; if (rightArmPose != ArmPose.EMPTY) { bipedRightArm.rotateAngleZ += cos; @@ -370,28 +447,31 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); } - protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick); + protected void aimBow(ArmPose leftArm, ArmPose rightArm, float ticks) { + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, ticks); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, ticks); } - protected void aimBowPony(ModelRenderer arm, float tick) { + protected void aimBowPony(ModelRenderer arm, float ticks) { arm.rotateAngleZ = 0; arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; - arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - } - - protected void fixSpecialRotationPoints(float move) { + arm.rotateAngleZ += MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + arm.rotateAngleX += MathHelper.sin(ticks * 0.067F) * 0.05F; } /** - * Sets up this model's initial values, like a constructor... - * @param yOffset YPosition for this model. Always 0. - * @param stretch Scaling factor for this model. Ranges above or below 0 (no change). + * Called after postioning but before wears alignment to perform some last-minute adjustments. + * + * @param move Entity motion parameter. See {@link AbstractPonyModel.setRotationAngles}. + * + * TODO: Empty method */ + protected void fixSpecialRotationPoints(float move) { + } + public void init(float yOffset, float stretch) { + // TODO: Splitting things like this isn't strictly neccessary and just complicates things. initTextures(); initPositions(yOffset, stretch); } @@ -613,14 +693,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { * @param arm The arm to rotate * @param direction Direction multiplier. 1 for right, -1 for left. * @param swingProgress How far we are through the current swing - * @param tick Render partial ticks + * @param ticks Render partial ticks */ - protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { + protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float ticks) { float swing = MathHelper.sin(swingProgress * PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI); - float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sin = MathHelper.sin(tick * 0.067F) / 10; + float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(ticks * 0.067F) / 10; arm.rotateAngleX = -1.5707964F; arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; @@ -631,12 +711,23 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { } + /** + * Sets the model's various rotation angles. + * + * @param entity The entity we're being called for. + * @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount. + * @param swing Degree to which each 'limb' swings. + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + * @param headYaw Horizontal head motion in radians. + * @param headPitch Vertical head motion in radians. + * @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}. + */ @Override - public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { + public void render(Entity entityIn, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { pushMatrix(); transform(BodyPart.HEAD); - renderHead(entityIn, move, swing, age, headYaw, headPitch, scale); + renderHead(entityIn, move, swing, ticks, headYaw, headPitch, scale); popMatrix(); pushMatrix(); @@ -646,7 +737,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { pushMatrix(); transform(BodyPart.BODY); - renderBody(entityIn, move, swing, age, headYaw, headPitch, scale); + renderBody(entityIn, move, swing, ticks, headYaw, headPitch, scale); popMatrix(); pushMatrix(); @@ -655,7 +746,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { popMatrix(); } - protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + /** + * + * Called to render the head. + * + * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} + * + */ + protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { bipedHead.render(scale); bipedHeadwear.render(scale); bipedHead.postRender(scale); @@ -666,7 +764,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { neck.render(scale); } - protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + /** + * + * Called to render the head. + * + * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} + * + */ + protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { bipedBody.render(scale); if (textureHeight == 64) { bipedBodyWear.render(scale); @@ -705,6 +810,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel { rotate(motionPitch, 1, 0, 0); } + // TODO: Get these out of here if (isChild()) { transformFoal(part); } else if (metadata.getSize() == PonySize.LARGE) { diff --git a/src/main/java/com/minelittlepony/model/ModelMobPony.java b/src/main/java/com/minelittlepony/model/ModelMobPony.java index b57fd7f7..1edb4daa 100644 --- a/src/main/java/com/minelittlepony/model/ModelMobPony.java +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -18,27 +18,27 @@ public class ModelMobPony extends ModelAlicorn { * Returns true if the angle is to the right? */ public boolean islookAngleRight(float move) { - return MathHelper.sin(move / 20f) < 0; + return MathHelper.sin(move / 20) < 0; } @Override - protected void adjustLegs(float move, float swing, float tick) { - super.adjustLegs(move, swing, tick); + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); if (rightArmPose != ArmPose.EMPTY) { if (canCast()) { unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmRight, -1, swingProgress, tick); + rotateArmHolding(unicornArmRight, -1, swingProgress, ticks); } else { - rotateArmHolding(bipedRightArm, -1, swingProgress, tick); + rotateArmHolding(bipedRightArm, -1, swingProgress, ticks); } } if (leftArmPose != ArmPose.EMPTY) { if (!canCast()) { unicornArmRight.setRotationPoint(-7, 12, -2); - rotateArmHolding(unicornArmLeft, -1, swingProgress, tick); + rotateArmHolding(unicornArmLeft, -1, swingProgress, ticks); } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); + rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); } } } diff --git a/src/main/java/com/minelittlepony/model/ModelWrapper.java b/src/main/java/com/minelittlepony/model/ModelWrapper.java index 854fe358..eceaa90a 100644 --- a/src/main/java/com/minelittlepony/model/ModelWrapper.java +++ b/src/main/java/com/minelittlepony/model/ModelWrapper.java @@ -1,12 +1,13 @@ package com.minelittlepony.model; import com.minelittlepony.model.armour.PonyArmor; +import com.minelittlepony.model.capabilities.IModelWrapper; import com.minelittlepony.pony.data.IPonyData; /** * Container class for the various models and their associated piece of armour. */ -public class ModelWrapper { +public class ModelWrapper implements IModelWrapper { private final AbstractPonyModel model; private final PonyArmor armor; @@ -32,17 +33,11 @@ public class ModelWrapper { return armor; } - /** - * Updates metadata values on this wrapper's armour and model. - */ public void apply(IPonyData meta) { model.metadata = meta; armor.apply(meta); } - /** - * Called at startup to configure a model's needed components. - */ public void init() { model.init(0, 0); armor.init(); diff --git a/src/main/java/com/minelittlepony/model/PMAPI.java b/src/main/java/com/minelittlepony/model/PMAPI.java index 1a2b9c74..2d02aa5e 100644 --- a/src/main/java/com/minelittlepony/model/PMAPI.java +++ b/src/main/java/com/minelittlepony/model/PMAPI.java @@ -14,6 +14,7 @@ import java.lang.reflect.Field; /** * PMAPI - Pony Models API? * + * TODO: Remove this, move the models to where they're being used. */ public final class PMAPI { diff --git a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java index 00f7e753..59205969 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -23,13 +23,13 @@ public class ModelPonyArmor extends ModelMobPony { } @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); syncLegs(); } @Override - protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { + protected void rotateLook(float move, float swing, float bodySwing, float ticks) { bipedBody.rotateAngleY = bodySwing / 5; } @@ -67,7 +67,7 @@ public class ModelPonyArmor extends ModelMobPony { } @Override - protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { bipedHead.render(this.scale); helmet.render(this.scale); bipedHeadwear.render(this.scale); @@ -75,6 +75,7 @@ public class ModelPonyArmor extends ModelMobPony { @Override protected void renderNeck() { + // TODO: Disabling the neck like this forces more complexity lower down } @Override @@ -83,7 +84,7 @@ public class ModelPonyArmor extends ModelMobPony { } @Override - protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { bipedBody.render(this.scale); flankGuard.render(this.scale); saddle.render(this.scale); diff --git a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java index efdaa1eb..15a37cba 100644 --- a/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -5,14 +5,14 @@ import com.minelittlepony.render.AbstractPonyRenderer; public class ModelZombiePonyArmor extends ModelPonyArmor { // Copied from ModelZombiePony @Override - protected void adjustLegs(float move, float swing, float tick) { - super.adjustLegs(move, swing, tick); + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { - rotateArmHolding(bipedRightArm, 1, swingProgress, tick); + rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); + rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); } } diff --git a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java index f3f0d9ae..31aeeec6 100644 --- a/src/main/java/com/minelittlepony/model/armour/PonyArmor.java +++ b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java @@ -1,11 +1,12 @@ package com.minelittlepony.model.armour; import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.capabilities.IModelWrapper; import com.minelittlepony.pony.data.IPonyData; import net.minecraft.inventory.EntityEquipmentSlot; -public class PonyArmor { +public class PonyArmor implements IModelWrapper { public final AbstractPonyModel chestplate; public final AbstractPonyModel leggings; diff --git a/src/main/java/com/minelittlepony/model/armour/package-info.java b/src/main/java/com/minelittlepony/model/armour/package-info.java new file mode 100644 index 00000000..ce1fed56 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.model.armour; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModel.java b/src/main/java/com/minelittlepony/model/capabilities/IModel.java index 99003a50..acc4e84c 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/IModel.java +++ b/src/main/java/com/minelittlepony/model/capabilities/IModel.java @@ -7,11 +7,10 @@ import net.minecraft.entity.Entity; public interface IModel { - /** * Sets up this model's initial values, like a constructor... - * @param yOffset YPosition for this model. Always 0. - * @param stretch Scaling factor for this model. Ranges above or below 0 (no change). + * @param yOffset YPosition for this model. Always 0. + * @param stretch Scaling factor for this model. Ranges above or below 0 (no change). */ void init(float yOffset, float stretch); diff --git a/src/main/java/com/minelittlepony/model/capabilities/IModelWrapper.java b/src/main/java/com/minelittlepony/model/capabilities/IModelWrapper.java new file mode 100644 index 00000000..96212bc8 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelWrapper.java @@ -0,0 +1,15 @@ +package com.minelittlepony.model.capabilities; + +import com.minelittlepony.pony.data.IPonyData; + +public interface IModelWrapper { + /** + * Initialises this wrapper's contained models. + */ + void init(); + + /** + * Updates metadata values to this wrapper's contained models. + */ + void apply(IPonyData meta); +} diff --git a/src/main/java/com/minelittlepony/model/capabilities/package-info.java b/src/main/java/com/minelittlepony/model/capabilities/package-info.java new file mode 100644 index 00000000..85345172 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.model.capabilities; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/components/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java index 1f669a85..518fc2fe 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyElytra.java +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -23,17 +23,27 @@ public class PonyElytra extends ModelBase { rightWing.flipX().box( 0, 0, 0, 10, 20, 2, 1); } + /** + * Sets the model's various rotation angles. + * + * See {@link AbstractPonyModel.render} for an explanation of the various parameters. + */ @Override - public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { + public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { GlStateManager.disableRescaleNormal(); GlStateManager.disableCull(); leftWing.render(scale); rightWing.render(scale); } + /** + * Sets the model's various rotation angles. + * + * See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters. + */ @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); float rotateX = PI / 2; float rotateY = PI / 8; diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java index 8468058c..c806149c 100644 --- a/src/main/java/com/minelittlepony/model/components/PonyTail.java +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -27,6 +27,11 @@ public class PonyTail extends PlaneRenderer { } } + /** + * Sets the model's various rotation angles. + * + * See {@link AbstractPonyMode.setRotationAndAngle} for an explanation of the various parameters. + */ public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) { rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; rotateAngleY = bodySwing; @@ -58,8 +63,8 @@ public class PonyTail extends PlaneRenderer { tailStop = theModel.metadata.getTail().ordinal(); } - public void swingX(float tick) { - float sinTickFactor = MathHelper.sin(tick * 0.067f) * 0.05f; + public void swingX(float ticks) { + float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f; rotateAngleX += sinTickFactor; rotateAngleY += sinTickFactor; } diff --git a/src/main/java/com/minelittlepony/model/components/package-info.java b/src/main/java/com/minelittlepony/model/components/package-info.java new file mode 100644 index 00000000..34123d53 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.model.components; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java index a39f49f9..5350c5fb 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -6,10 +6,10 @@ import net.minecraft.entity.Entity; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.MathHelper; -import static com.minelittlepony.model.PonyModelConstants.*; - import com.minelittlepony.model.capabilities.IModelUnicorn; +import static com.minelittlepony.model.PonyModelConstants.*; + /** * Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff. */ @@ -31,16 +31,16 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { } @Override - protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { - super.rotateLegsOnGround(move, swing, tick, entity); + protected void rotateLegsOnGround(float move, float swing, float ticks, Entity entity) { + super.rotateLegsOnGround(move, swing, ticks, entity); unicornArmRight.rotateAngleY = 0; unicornArmLeft.rotateAngleY = 0; } @Override - protected void adjustLegs(float move, float swing, float tick) { - super.adjustLegs(move, swing, tick); + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); unicornArmLeft.rotateAngleZ = 0; unicornArmRight.rotateAngleZ = 0; @@ -62,7 +62,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { } @Override - protected void swingItem(Entity entity, float swingProgress) { + protected void swingItem(Entity entity) { EnumHandSide mainSide = getMainHand(entity); if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) { @@ -70,17 +70,17 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { swingArm(getUnicornArmForSide(mainSide)); } } else { - super.swingItem(entity, swingProgress); + super.swingItem(entity); } } @Override - protected void swingArms(float tick) { + protected void swingArms(float ticks) { if (isSleeping) return; if (canCast()) { - float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - float sin = MathHelper.sin(tick * 0.067F) * 0.05F; + float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; if (rightArmPose != ArmPose.EMPTY) { unicornArmRight.rotateAngleZ += cos; @@ -92,7 +92,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { unicornArmLeft.rotateAngleX += sin; } } else { - super.swingArms(tick); + super.swingArms(ticks); } } @@ -124,18 +124,18 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn { } @Override - protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { + protected void aimBow(ArmPose leftArm, ArmPose rightArm, float ticks) { if (canCast()) { - if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick); - if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick); + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, ticks); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, ticks); } else { - super.aimBow(leftArm, rightArm, tick); + super.aimBow(leftArm, rightArm, ticks); } } @Override - protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - super.renderHead(entity, move, swing, age, headYaw, headPitch, scale); + protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale); if (canCast()) { horn.render(scale); diff --git a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java index 51895e34..3e682e28 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -17,8 +17,8 @@ public class ModelEarthPony extends AbstractPonyModel { } @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); if (bipedCape != null) { bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; diff --git a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java index 7ad1d836..5fb90a65 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java +++ b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java @@ -27,18 +27,18 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus { } @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { checkRainboom(entity, swing); - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); if (bipedCape != null) { - wings.setRotationAngles(move, swing, age); + wings.setRotationAngles(move, swing, ticks); } } @Override - protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { + protected void rotateLegsInFlight(float move, float swing, float ticks, Entity entity) { if (rainboom) { bipedLeftArm.rotateAngleX = ROTATE_270; bipedRightArm.rotateAngleX = ROTATE_270; @@ -52,13 +52,13 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus { bipedRightArm.rotateAngleY = 0.2F; bipedRightLeg.rotateAngleY = -0.2F; } else { - super.rotateLegsInFlight(move, swing, tick, entity); + super.rotateLegsInFlight(move, swing, ticks, entity); } } @Override - protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); + protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); if (canFly()) { wings.render(scale); } diff --git a/src/main/java/com/minelittlepony/model/player/package-info.java b/src/main/java/com/minelittlepony/model/player/package-info.java new file mode 100644 index 00000000..fefa925a --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.model.player; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java index af2b50ff..79619eff 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java @@ -66,8 +66,8 @@ public class ModelBreezie extends ModelBiped { } @Override - public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - super.render(entity, move, swing, age, headYaw, headPitch, scale); + public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.render(entity, move, swing, ticks, headYaw, headPitch, scale); neck.render(scale); tailStub.render(scale); tail.render(scale); @@ -77,7 +77,7 @@ public class ModelBreezie extends ModelBiped { @SuppressWarnings("incomplete-switch") @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { bipedHead.rotateAngleY = headYaw * 0.017453292F; bipedHead.rotateAngleX = headPitch * 0.017453292F; @@ -104,8 +104,8 @@ public class ModelBreezie extends ModelBiped { swingArms(getMainHand(entity)); } - float rotX = MathHelper.sin(age * 0.067F) * 0.05F; - float rotZ = MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; + float rotX = MathHelper.sin(ticks * 0.067F) * 0.05F; + float rotZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; bipedLeftArm.rotateAngleX -= rotX; bipedLeftArm.rotateAngleZ -= rotZ; diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java index 2307d034..14127339 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -16,8 +16,8 @@ public class ModelIllagerPony extends ModelAlicorn { } @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); AbstractIllager illager = (AbstractIllager) entity; IllagerArmPose pose = illager.getArmPose(); @@ -34,38 +34,38 @@ public class ModelIllagerPony extends ModelAlicorn { bipedLeftArm.rotateAngleY = -0.15707964F; if (rightHanded) { - bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(age * 0.09F) * 0.15F; + bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F; bipedRightArm.rotateAngleX += f * 2.2F - f1 * 0.4F; } else { - bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(age * 0.09F) * 0.15F; + bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F; bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F; } - bipedRightArm.rotateAngleZ += MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; - bipedLeftArm.rotateAngleZ -= MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; - bipedRightArm.rotateAngleX += MathHelper.sin(age * 0.067F) * 0.05F; - bipedLeftArm.rotateAngleX -= MathHelper.sin(age * 0.067F) * 0.05F; + bipedRightArm.rotateAngleZ += MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + bipedLeftArm.rotateAngleZ -= MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + bipedRightArm.rotateAngleX += MathHelper.sin(ticks * 0.067F) * 0.05F; + bipedLeftArm.rotateAngleX -= MathHelper.sin(ticks * 0.067F) * 0.05F; } else if (pose == IllagerArmPose.SPELLCASTING) { // waving arms! if (rightHanded) { // this.bipedRightArm.rotationPointZ = 0.0F; // this.bipedRightArm.rotationPointX = -5.0F; bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI); - bipedRightArm.rotateAngleZ = MathHelper.cos(age * 0.6662F) / 4; + bipedRightArm.rotateAngleZ = MathHelper.cos(ticks * 0.6662F) / 4; bipedRightArm.rotateAngleY = 1.1F; } else { // this.bipedLeftArm.rotationPointZ = 0.0F; // this.bipedLeftArm.rotationPointX = 5.0F; bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI); - bipedLeftArm.rotateAngleZ = -MathHelper.cos(age * 0.6662F) / 4; + bipedLeftArm.rotateAngleZ = -MathHelper.cos(ticks * 0.6662F) / 4; bipedLeftArm.rotateAngleY = -1.1F; } } else if (pose == IllagerArmPose.BOW_AND_ARROW) { if (rightHanded) { - aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, age); + aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, ticks); } else { - aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, age); + aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, ticks); } } } diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java index 46a5f2e0..c3d303cd 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -18,8 +18,8 @@ public class ModelVillagerPony extends ModelAlicorn { } @Override - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); float angleY = 0; if (swingProgress > -9990.0F && !canCast()) { @@ -31,8 +31,8 @@ public class ModelVillagerPony extends ModelAlicorn { } @Override - protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { - super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); + protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); int profession = getProfession(entity); if (profession > -1) { diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java index 206fff7f..e8daea9c 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java @@ -22,11 +22,12 @@ public class ModelWitchPony extends ModelVillagerPony { super(); } - public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { + @Override + public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { rightArmPose = ArmPose.EMPTY; leftArmPose = ((EntityWitch) entity).getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; - super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); if (leftArmPose != ArmPose.EMPTY) { if (!canCast()) { bipedRightArm.rotateAngleX = -2 * (float)Math.PI/3; @@ -37,8 +38,8 @@ public class ModelWitchPony extends ModelVillagerPony { } @Override - public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { - super.render(entityIn, move, swing, age, headYaw, headPitch, scale); + public void render(Entity entityIn, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.render(entityIn, move, swing, ticks, headYaw, headPitch, scale); copyModelAngles(bipedHead, witchHat); diff --git a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java index 7cf862be..6faecbe5 100644 --- a/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -13,14 +13,14 @@ public class ModelZombiePony extends ModelMobPony { } @Override - protected void adjustLegs(float move, float swing, float tick) { - super.adjustLegs(move, swing, tick); + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { - rotateArmHolding(bipedRightArm, 1, swingProgress, tick); + rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); + rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); } } diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index b3ec6798..4c038064 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -39,18 +39,18 @@ public class Pony { smallArms = slim; } - private IPonyData checkSkin(ResourceLocation textureResourceLocation) { - IPonyData data = checkPonyMeta(textureResourceLocation); + private IPonyData checkSkin(ResourceLocation resource) { + IPonyData data = checkPonyMeta(resource); if (data != null) return data; - BufferedImage skinImage = getBufferedImage(textureResourceLocation); + BufferedImage skinImage = getBufferedImage(resource); return this.checkSkin(skinImage); } @Nullable - private IPonyData checkPonyMeta(ResourceLocation location) { + private IPonyData checkPonyMeta(ResourceLocation resource) { try { - IResource res = Minecraft.getMinecraft().getResourceManager().getResource(location); + IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); if (res.hasMetadata()) { PonyData data = res.getMetadata(PonyDataSerialzier.NAME); if (data != null) { @@ -60,7 +60,7 @@ public class Pony { } catch (FileNotFoundException e) { // Ignore uploaded texture } catch (IOException e) { - MineLittlePony.logger.warn("Unable to read {} metadata", location, e); + MineLittlePony.logger.warn("Unable to read {} metadata", resource, e); } return null; } @@ -76,14 +76,14 @@ public class Pony { } catch (IOException ignored) { } try { - ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(resource); + ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resource); - if (e2 instanceof MixinThreadDownloadImageData) { - return ((MixinThreadDownloadImageData) e2).getBufferedImage(); - } else if (e2 instanceof ThreadDownloadImageETag) { - return ((ThreadDownloadImageETag) e2).getBufferedImage(); - } else if (e2 instanceof DynamicTextureImage) { - return ((DynamicTextureImage) e2).getImage(); + if (texture instanceof MixinThreadDownloadImageData) { + return ((MixinThreadDownloadImageData) texture).getBufferedImage(); + } else if (texture instanceof ThreadDownloadImageETag) { + return ((ThreadDownloadImageETag) texture).getBufferedImage(); + } else if (texture instanceof DynamicTextureImage) { + return ((DynamicTextureImage) texture).getImage(); } } catch (Exception ignored) { } diff --git a/src/main/java/com/minelittlepony/pony/data/package-info.java b/src/main/java/com/minelittlepony/pony/data/package-info.java new file mode 100644 index 00000000..31822866 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.pony.data; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java index 88a0a715..6be6717a 100644 --- a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -99,6 +99,10 @@ public abstract class AbstractPonyRenderer> ex return (T) this; } + /** + * Positions a given model in space by setting its offset values divided + * by 16 to account for scaling applied inside the model. + */ public static T at(T renderer, float x, float y, float z) { renderer.offsetX = x / 16; renderer.offsetY = y / 16; @@ -106,10 +110,16 @@ public abstract class AbstractPonyRenderer> ex return renderer; } + /** + * Rotates this model to align itself with the angles of another. + */ public void rotateTo(ModelRenderer other) { rotate(other.rotateAngleX, other.rotateAngleY, other.rotateAngleZ); } + /** + * Shifts this model to align its center with the center of another. + */ public T rotateAt(ModelRenderer other) { return around(other.rotationPointX, other.rotationPointY, other.rotationPointZ); } diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java index 4e394568..b895aace 100644 --- a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -19,12 +19,24 @@ public abstract class AbstractPonyLayer implements L @SuppressWarnings("unchecked") @Override - public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { // render the pony layer - doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); + doPonyRender((T)entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale); } - protected abstract void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale); + /** + * Renders this layer. + * + * @param entity The entity we're being called for. + * @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount. + * @param swing Degree to which each 'limb' swings. + * @param partialTicks Render partial ticks + * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. + * @param headYaw Horizontal head motion in radians. + * @param headPitch Vertical head motion in radians. + * @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}. + */ + protected abstract void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale); protected RenderLivingBase getRenderer() { return renderer; diff --git a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java index 817d350c..6a93a2c9 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -14,6 +14,9 @@ import net.minecraft.nbt.NBTTagCompound; import javax.annotation.Nullable; +/** + * TODO: Looks like {@link LayerEntityOnShoulder} + */ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { private final RenderManager renderManager; @@ -27,7 +30,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer render = renderManager.getEntityRenderObject(entity); + + if (render == null) { + return entity; + } + GlStateManager.pushMatrix(); getPonyModel().transform(BodyPart.BODY); @@ -70,10 +76,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer render = renderManager.getEntityRenderObject(entity); - if (render != null) { - render.doRender(entity, 0, 0, 0, 0, 0); - } + render.doRender(entity, 0, 0, 0, 0, partialTicks); GlStateManager.popMatrix(); return entity; diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java index deb5a933..c301e574 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldItemIllager.java @@ -14,9 +14,9 @@ public class LayerHeldItemIllager extends LayerHeldPo } @Override - public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { if (shouldRender(entity)) { - super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); + super.doPonyRender(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale); } } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java index a0fc022b..4203dfae 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -20,7 +20,7 @@ public class LayerHeldPonyItem extends AbstractPonyL } @Override - public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; diff --git a/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java index f887a8ca..779f8f0d 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java @@ -21,16 +21,16 @@ public abstract class LayerOverlayBase implements LayerR } @Override - public void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doRenderLayer(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { ModelBase overlayModel = getOverlayModel(); overlayModel.setModelAttributes(renderer.getMainModel()); - overlayModel.setLivingAnimations(entity, move, swing, ticks); - overlayModel.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + overlayModel.setLivingAnimations(entity, move, swing, partialTicks); + overlayModel.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); renderer.bindTexture(getOverlayTexture()); - overlayModel.render(entity, move, swing, age, headYaw, headPitch, scale); + overlayModel.render(entity, move, swing, ticks, headYaw, headPitch, scale); } protected abstract ModelBase getOverlayModel(); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index dc4c52e7..8ae87f37 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -43,17 +43,17 @@ public class LayerPonyArmor extends AbstractPonyLaye } @Override - public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { pony = ((IRenderPony) getRenderer()).getPlayerModel(); for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) { if (i.getSlotType() == Type.ARMOR) { - renderArmor(entity, move, swing, ticks, age, headYaw, headPitch, scale, i); + renderArmor(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale, i); } } } - private void renderArmor(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { + private void renderArmor(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { @@ -63,7 +63,7 @@ public class LayerPonyArmor extends AbstractPonyLaye AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot); modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); modelbase.setModelAttributes(pony.getModel()); - modelbase.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); + modelbase.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); Tuple armors = getArmorTexture(entity, itemstack, armorSlot, null); prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond()); @@ -71,15 +71,15 @@ public class LayerPonyArmor extends AbstractPonyLaye getRenderer().bindTexture(armors.getFirst()); if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { Color.glColor(itemarmor.getColor(itemstack), 1); - modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); + modelbase.render(entity, move, swing, ticks, headYaw, headPitch, scale); armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); getRenderer().bindTexture(armors.getFirst()); } GlStateManager.color(1, 1, 1, 1); - modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); + modelbase.render(entity, move, swing, ticks, headYaw, headPitch, scale); if (itemstack.isItemEnchanted()) { - renderEnchantment(entity, modelbase, move, swing, ticks, age, headYaw, headPitch, scale); + renderEnchantment(entity, modelbase, move, swing, partialTicks, ticks, headYaw, headPitch, scale); } } } @@ -157,7 +157,7 @@ public class LayerPonyArmor extends AbstractPonyLaye } } - private void renderEnchantment(T entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + private void renderEnchantment(T entity, ModelBase model, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); @@ -167,7 +167,7 @@ public class LayerPonyArmor extends AbstractPonyLaye float brightness = 0.5F; GlStateManager.color(brightness, brightness, brightness, 1); - float baseYOffset = entity.ticksExisted + ticks; + float baseYOffset = entity.ticksExisted + partialTicks; float glintBrightness = 0.76F; float scaleFactor = 0.33333334F; @@ -186,7 +186,7 @@ public class LayerPonyArmor extends AbstractPonyLaye GlStateManager.translate(0, baseYOffset * (0.02F + i * 0.06F), 0); GlStateManager.matrixMode(GL11.GL_MODELVIEW); - model.render(entity, move, swing, age, headYaw, headPitch, scale); + model.render(entity, move, swing, ticks, headYaw, headPitch, scale); } GlStateManager.matrixMode(GL11.GL_TEXTURE); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java index 162e26f8..88161fc6 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -23,7 +23,7 @@ public class LayerPonyCape extends AbstractPonyLayer { } @Override - public void doPonyRender(@Nonnull AbstractClientPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doPonyRender(@Nonnull AbstractClientPlayer player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { ModelWrapper model = ((IRenderPony) getRenderer()).getPlayerModel(); if (player.hasPlayerInfo() && !player.isInvisible() diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 6d54c9d6..a0174ce7 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -34,7 +34,7 @@ public class LayerPonyCustomHead implements LayerRen } @Override - public void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { + public void doRenderLayer(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (!itemstack.isEmpty()) { AbstractPonyModel model = getModel().getModel(); @@ -97,6 +97,7 @@ public class LayerPonyCustomHead implements LayerRen } } + // TODO: PonySkullRenderer TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing); } diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java index be51dd6e..0c3c9ec8 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -26,7 +26,7 @@ public class LayerPonyElytra extends AbstractPonyLay } @Override - public void doPonyRender(@Nonnull T entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) { + public void doPonyRender(@Nonnull T entity, float move, float swing, float partialTicks, float ticks, float yaw, float head, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { @@ -37,11 +37,11 @@ public class LayerPonyElytra extends AbstractPonyLay GlStateManager.pushMatrix(); GlStateManager.translate(0, 0.25F, 0.125F); getPlayerModel().transform(BodyPart.BODY); - modelElytra.setRotationAngles(move, swing, age, yaw, head, scale, entity); - modelElytra.render(entity, move, swing, age, yaw, head, scale); + modelElytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity); + modelElytra.render(entity, move, swing, ticks, yaw, head, scale); if (itemstack.isItemEnchanted()) { - LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, modelElytra, move, swing, ticks, age, yaw, head, scale); + LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, modelElytra, move, swing, partialTicks, ticks, yaw, head, scale); } GlStateManager.popMatrix(); diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java index 510d2c41..8bd4c822 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -21,8 +21,6 @@ import net.minecraft.util.ResourceLocation; public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony { - protected final boolean smallArms; - private ModelWrapper playerModel; protected AbstractPonyModel ponyModel; @@ -31,7 +29,6 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony public RenderPonyBase(RenderManager manager, boolean useSmallArms, ModelWrapper model) { super(manager, useSmallArms); - smallArms = useSmallArms; setPlayerModel(model); diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index dfdb89a8..1ef664ac 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -59,5 +59,5 @@ public class RenderPonyPlayer extends RenderPonyBase { GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); } - //TODO: transformSwimming() + //TODO: MC1.13 transformSwimming() } diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java index 41ef294f..9e9e5968 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java @@ -18,8 +18,8 @@ public class RenderPonySkeleton extends Rende private static final ResourceLocation WITHER = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png"); private static final ResourceLocation STRAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony.png"); - public RenderPonySkeleton(RenderManager rm) { - super(rm, PMAPI.skeleton); + public RenderPonySkeleton(RenderManager manager) { + super(manager, PMAPI.skeleton); } @Override diff --git a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java index 333a6ead..b4338e19 100644 --- a/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java @@ -60,4 +60,6 @@ public class RenderPonyZombie extends RenderPonyMob return ZOMBIE; } } + + //TODO: MC1.13 EntityDrowned } diff --git a/src/main/java/com/minelittlepony/util/coordinates/Vertex.java b/src/main/java/com/minelittlepony/util/coordinates/Vertex.java index 5ea593ea..c2a30a44 100644 --- a/src/main/java/com/minelittlepony/util/coordinates/Vertex.java +++ b/src/main/java/com/minelittlepony/util/coordinates/Vertex.java @@ -12,10 +12,10 @@ public class Vertex extends PositionTextureVertex { super(old, texX, texY); } + // The MCP name is misleading. + // This is meant to return a COPY with the given texture position public Vertex setTexturePosition(float texX, float texY) { - texturePositionX = texX; - texturePositionY = texY; - return this; + return new Vertex(this, texX, texY); } /** From 1f68025252474e70cf94eeedf274ef605221bc26 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 12:40:18 +0200 Subject: [PATCH 87/96] Cleaned up MixinRenderManager and made KillJoy happy This will be the last commit on master until I can get this PR merged --- .../com/minelittlepony/PonyRenderManager.java | 14 ++++++++------ .../com/minelittlepony/ducks/IRenderManager.java | 12 ------------ .../minelittlepony/mixin/MixinRenderManager.java | 16 ++++------------ .../render/player/RenderPonyPlayer.java | 12 +++--------- 4 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/ducks/IRenderManager.java diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 95a7a0a0..809e305c 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -3,7 +3,7 @@ package com.minelittlepony; import java.util.Map; import com.google.common.collect.Maps; -import com.minelittlepony.ducks.IRenderManager; +import com.minelittlepony.mixin.MixinRenderManager; import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.RenderPonyModel; import com.minelittlepony.model.player.PlayerModels; @@ -56,13 +56,15 @@ public class PonyRenderManager { registerPlayerSkin(manager, PlayerModels.ALICORN); } - protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { - addPlayerSkin(manager, new RenderPonyPlayer(manager, false, playerModel)); - addPlayerSkin(manager, new RenderPonyPlayer(manager, true, playerModel)); + private void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { + addPlayerSkin(manager, false, playerModel); + addPlayerSkin(manager, true, playerModel); } - public void addPlayerSkin(RenderManager manager, RenderPonyPlayer renderer) { - ((IRenderManager)manager).addPlayerSkin(renderer.skinId, renderer); + private void addPlayerSkin(RenderManager manager, boolean slimArms, PlayerModels playerModel) { + RenderPonyPlayer renderer = new RenderPonyPlayer(manager, slimArms, playerModel.getModel(slimArms)); + + ((MixinRenderManager)manager).getSkinMap().put(playerModel.getId(slimArms), renderer); } /** diff --git a/src/main/java/com/minelittlepony/ducks/IRenderManager.java b/src/main/java/com/minelittlepony/ducks/IRenderManager.java deleted file mode 100644 index d48b127a..00000000 --- a/src/main/java/com/minelittlepony/ducks/IRenderManager.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.minelittlepony.ducks; - -import net.minecraft.client.renderer.entity.RenderPlayer; - -public interface IRenderManager { - /** - * Registers a new player model to the underlying skinMap object. - * @param key The key to identify it by. - * @param render The renderer to add. - */ - void addPlayerSkin(String key, RenderPlayer render); -} diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java index 8b732680..5f200841 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java @@ -2,22 +2,14 @@ package com.minelittlepony.mixin; import java.util.Map; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.minelittlepony.ducks.IRenderManager; +import org.spongepowered.asm.mixin.gen.Accessor; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; @Mixin(RenderManager.class) -public abstract class MixinRenderManager implements IRenderManager { - @Shadow @Final - private Map skinMap; - - @Override - public void addPlayerSkin(String key, RenderPlayer render) { - skinMap.put(key, render); - } +public interface MixinRenderManager { + @Accessor + Map getSkinMap(); } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 1ef664ac..793cd758 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -2,7 +2,7 @@ package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IPonyAnimationHolder; -import com.minelittlepony.model.player.PlayerModels; +import com.minelittlepony.model.ModelWrapper; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; @@ -10,14 +10,8 @@ import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { - /** - * The id used to find this renderer in the player skin map. - */ - public final String skinId; - - public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) { - super(renderManager, useSmallArms, model.getModel(useSmallArms)); - skinId = model.getId(useSmallArms); + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, ModelWrapper model) { + super(renderManager, useSmallArms, model); } @Override From 9f429415b5729ff5d3f03d2568c2c92836d01d1a Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 19:30:47 +0200 Subject: [PATCH 88/96] Eclipse pls, I told you to use spaces --- src/main/java/com/minelittlepony/MineLittlePony.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index d5b56797..ba43cf3f 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -26,7 +26,7 @@ public class MineLittlePony { public static final String MOD_NAME = "Mine Little Pony"; public static final String MOD_VERSION = "@VERSION@"; - private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; + private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); From 2325bf162d4a2570936e42c15864efab44441022 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 19:33:17 +0200 Subject: [PATCH 89/96] metadata.getRace().getEfectiveRace(MineLittlePony.getConfig().getEffectivePonyLevel(ignorePony)); --- src/main/java/com/minelittlepony/PonyConfig.java | 2 +- src/main/java/com/minelittlepony/pony/data/Pony.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyConfig.java b/src/main/java/com/minelittlepony/PonyConfig.java index 9557ea61..3d0ef93a 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -28,7 +28,7 @@ public class PonyConfig implements Exposable { * Gets the current PonyLevel. That is the level of ponies you would like to see. * @param ignorePony true to ignore whatever value the setting has. */ - public PonyLevel getPonyLevel(boolean ignorePony) { + public PonyLevel getEffectivePonyLevel(boolean ignorePony) { return ignorePony ? PonyLevel.BOTH : getPonyLevel(); } diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index 4c038064..270e3d1e 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -108,7 +108,7 @@ public class Pony { } public PonyRace getRace(boolean ignorePony) { - return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony)); + return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getEffectivePonyLevel(ignorePony)); } public ResourceLocation getTexture() { From 7e183e32475b6a60a7d7ccc97db1b754410daa5d Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 19:43:39 +0200 Subject: [PATCH 90/96] Bleh --- src/main/java/com/minelittlepony/PonyManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 81dcab6e..7e9a4254 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -44,9 +44,8 @@ public class PonyManager implements IResourceManagerReloadListener { private PonyConfig config; - private Map - poniesCache = Maps.newHashMap(), - backgroudPoniesCache = Maps.newHashMap(); + private Map poniesCache = Maps.newHashMap(); + private Map backgroudPoniesCache = Maps.newHashMap(); public PonyManager(PonyConfig config) { this.config = config; From a639afea59254fd468e9cf84b3fcdc8d3f0f04a9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 21:29:16 +0200 Subject: [PATCH 91/96] Moved render logic out of the entity mixin even though it's actually entity logic. --- .../ducks/IPonyAnimationHolder.java | 4 +++- .../mixin/MixinEntityLivingBase.java | 20 ++++++------------- .../render/player/RenderPonyPlayer.java | 16 ++++++++++++++- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java index 9d91c168..2fd0c4f5 100644 --- a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java +++ b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java @@ -8,5 +8,7 @@ public interface IPonyAnimationHolder { /** * Updates and gets the amount this entity is strafing to each side. */ - float getStrafeAmount(float ticks); + float getStrafeAmount(); + + void setStrafeAmount(float strafeAmount); } diff --git a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java index f0646c58..078e4f91 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java +++ b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java @@ -1,7 +1,6 @@ package com.minelittlepony.mixin; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import com.minelittlepony.ducks.IPonyAnimationHolder; @@ -11,9 +10,6 @@ import net.minecraft.world.World; @Mixin(EntityLivingBase.class) public abstract class MixinEntityLivingBase extends Entity implements IPonyAnimationHolder { - @Shadow - public float moveStrafing; - private MixinEntityLivingBase(World worldIn) { super(worldIn); } @@ -24,16 +20,12 @@ public abstract class MixinEntityLivingBase extends Entity implements IPonyAnima private float strafeRollAmount = 0; @Override - public float getStrafeAmount(float ticks) { - float strafing = moveStrafing; - if (strafing != 0) { - if (Math.abs(strafeRollAmount) < Math.abs(strafing)) { - strafeRollAmount += strafing/10; - } - } else { - strafeRollAmount *= 0.8; - } + public float getStrafeAmount() { + return strafeRollAmount; + } - return (float)Math.toDegrees(strafeRollAmount); + @Override + public void setStrafeAmount(float strafeAmount) { + strafeRollAmount = strafeAmount; } } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 793cd758..519d0cd7 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -50,7 +50,21 @@ public class RenderPonyPlayer extends RenderPonyBase { ponyModel.motionPitch = (float) Math.toDegrees(angle); GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); - GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); + + + float lastStrafe = ((IPonyAnimationHolder)player).getStrafeAmount(); + + float strafing = player.moveStrafing; + if (strafing != 0) { + if (Math.abs(lastStrafe) < Math.abs(strafing)) { + lastStrafe += strafing/10; + } + } else { + lastStrafe *= 0.8; + } + + ((IPonyAnimationHolder)player).setStrafeAmount(lastStrafe); + GlStateManager.rotate((float)Math.toDegrees(lastStrafe), 0, 0, 1); } //TODO: MC1.13 transformSwimming() From df36cf61fce52fb6945627372d9301ebe371ad7a Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 21:30:10 +0200 Subject: [PATCH 92/96] Fixed leg placement whilst flying (alicorns will still have held items lag behind them - I call it a feature) --- .../java/com/minelittlepony/model/player/ModelPegasus.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java index 5fb90a65..8fdadfb0 100644 --- a/src/main/java/com/minelittlepony/model/player/ModelPegasus.java +++ b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java @@ -56,6 +56,12 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus { } } + protected void holdItem(float swing) { + if (!rainboom) { + super.holdItem(swing); + } + } + @Override protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); From e8500ea31f6835d8004dbb2e9b678f5732d405f0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 2 May 2018 14:40:17 +0200 Subject: [PATCH 93/96] I really hate these stupid package-info files... --- .../java/com/minelittlepony/render/plane/package-info.java | 7 +++++++ .../com/minelittlepony/render/player/package-info.java | 7 +++++++ .../com/minelittlepony/render/ponies/package-info.java | 7 +++++++ .../com/minelittlepony/util/coordinates/package-info.java | 7 +++++++ .../java/com/minelittlepony/util/math/package-info.java | 7 +++++++ 5 files changed, 35 insertions(+) create mode 100644 src/main/java/com/minelittlepony/render/plane/package-info.java create mode 100644 src/main/java/com/minelittlepony/render/player/package-info.java create mode 100644 src/main/java/com/minelittlepony/render/ponies/package-info.java create mode 100644 src/main/java/com/minelittlepony/util/coordinates/package-info.java create mode 100644 src/main/java/com/minelittlepony/util/math/package-info.java diff --git a/src/main/java/com/minelittlepony/render/plane/package-info.java b/src/main/java/com/minelittlepony/render/plane/package-info.java new file mode 100644 index 00000000..07179e8a --- /dev/null +++ b/src/main/java/com/minelittlepony/render/plane/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.render.plane; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/render/player/package-info.java b/src/main/java/com/minelittlepony/render/player/package-info.java new file mode 100644 index 00000000..ee1504e8 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/player/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.render.player; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/render/ponies/package-info.java b/src/main/java/com/minelittlepony/render/ponies/package-info.java new file mode 100644 index 00000000..5ecb94c1 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.render.ponies; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/coordinates/package-info.java b/src/main/java/com/minelittlepony/util/coordinates/package-info.java new file mode 100644 index 00000000..0196ca93 --- /dev/null +++ b/src/main/java/com/minelittlepony/util/coordinates/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.util.coordinates; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/math/package-info.java b/src/main/java/com/minelittlepony/util/math/package-info.java new file mode 100644 index 00000000..5d02780c --- /dev/null +++ b/src/main/java/com/minelittlepony/util/math/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.util.math; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; From b5104d67fd27e5bd3ee0e1bb14f35f2f0fbaf94e Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 2 May 2018 14:41:43 +0200 Subject: [PATCH 94/96] Rewrite strafing to not use a mixin --- .../ducks/IPonyAnimationHolder.java | 14 --------- .../mixin/MixinEntityLivingBase.java | 31 ------------------- .../render/player/RenderPonyPlayer.java | 27 +++++++--------- .../minelittlepony/util/math/MathUtil.java | 10 ++++++ src/main/resources/minelp.mixin.json | 3 +- 5 files changed, 23 insertions(+), 62 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java delete mode 100644 src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java create mode 100644 src/main/java/com/minelittlepony/util/math/MathUtil.java diff --git a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java b/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java deleted file mode 100644 index 2fd0c4f5..00000000 --- a/src/main/java/com/minelittlepony/ducks/IPonyAnimationHolder.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.minelittlepony.ducks; - -/** - * Holding class for entities that support special pony animations used for the renderers. - */ -public interface IPonyAnimationHolder { - - /** - * Updates and gets the amount this entity is strafing to each side. - */ - float getStrafeAmount(); - - void setStrafeAmount(float strafeAmount); -} diff --git a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java b/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java deleted file mode 100644 index 078e4f91..00000000 --- a/src/main/java/com/minelittlepony/mixin/MixinEntityLivingBase.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.minelittlepony.mixin; - -import org.spongepowered.asm.mixin.Mixin; - -import com.minelittlepony.ducks.IPonyAnimationHolder; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.world.World; - -@Mixin(EntityLivingBase.class) -public abstract class MixinEntityLivingBase extends Entity implements IPonyAnimationHolder { - private MixinEntityLivingBase(World worldIn) { - super(worldIn); - } - - // No other place to save this stuff? :'c - // Add any animations you want - // This could also go into Pony, but I'm unsure if that's a good place for it (@Immutable). - private float strafeRollAmount = 0; - - @Override - public float getStrafeAmount() { - return strafeRollAmount; - } - - @Override - public void setStrafeAmount(float strafeAmount) { - strafeRollAmount = strafeAmount; - } -} diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 519d0cd7..5b0468c0 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -1,12 +1,13 @@ package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.ducks.IPonyAnimationHolder; import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.util.math.MathUtil; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.util.math.Vec3d; public class RenderPonyPlayer extends RenderPonyBase { @@ -28,7 +29,7 @@ public class RenderPonyPlayer extends RenderPonyBase { @Override protected void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks) { GlStateManager.rotate(90, 1, 0, 0); - GlStateManager.translate(0, -1, 0); + GlStateManager.translate(0, player.isSneaking() ? 0.2F : -1, 0); } @Override @@ -44,27 +45,23 @@ public class RenderPonyPlayer extends RenderPonyBase { } } - if (angle > Math.PI / 3) angle = Math.PI / 3; - if (angle < -Math.PI / 3) angle = -Math.PI / 3; + angle = MathUtil.clampLimit(angle, Math.PI / 3); ponyModel.motionPitch = (float) Math.toDegrees(angle); GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0); + // Strafe like an elytra + Vec3d lookDirection = player.getForward(); - float lastStrafe = ((IPonyAnimationHolder)player).getStrafeAmount(); + double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ); + double horLook = Math.sqrt(lookDirection.x * lookDirection.x + lookDirection.z * lookDirection.z); - float strafing = player.moveStrafing; - if (strafing != 0) { - if (Math.abs(lastStrafe) < Math.abs(strafing)) { - lastStrafe += strafing/10; - } - } else { - lastStrafe *= 0.8; + if (horMotion > 0 && horLook > 0) { + double magnitude = (motionX * lookDirection.x + motionZ * lookDirection.z) / horMotion * horLook; + double direction = motionX * lookDirection.z - motionZ * lookDirection.x; + GlStateManager.rotate((float)Math.toDegrees(Math.signum(direction) * Math.acos(magnitude)), 0, 0, 1); } - - ((IPonyAnimationHolder)player).setStrafeAmount(lastStrafe); - GlStateManager.rotate((float)Math.toDegrees(lastStrafe), 0, 0, 1); } //TODO: MC1.13 transformSwimming() diff --git a/src/main/java/com/minelittlepony/util/math/MathUtil.java b/src/main/java/com/minelittlepony/util/math/MathUtil.java new file mode 100644 index 00000000..5dab16ec --- /dev/null +++ b/src/main/java/com/minelittlepony/util/math/MathUtil.java @@ -0,0 +1,10 @@ +package com.minelittlepony.util.math; + +import net.minecraft.util.math.MathHelper; + +public class MathUtil { + + public static double clampLimit(double num, double limit) { + return MathHelper.clamp(num, -limit, limit); + } +} diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index 972824cf..03138d99 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -8,7 +8,6 @@ "MixinThreadDownloadImageData", "MixinNetworkPlayerInfo", "MixinRenderItem", - "MixinRenderManager", - "MixinEntityLivingBase" + "MixinRenderManager" ] } From 22fe5417602756e7520bb28460fb0ca8155239c1 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 3 May 2018 14:58:05 +0200 Subject: [PATCH 95/96] Seems I was looking at the completely wrong method. Again, either one line of braces. Anything else is bad for readability and I won't stand for it. --- src/main/java/com/minelittlepony/PonyConfig.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/PonyConfig.java b/src/main/java/com/minelittlepony/PonyConfig.java index 3d0ef93a..70a513e3 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -36,7 +36,9 @@ public class PonyConfig implements Exposable { * Actually gets the pony level value. No option to ignore reality here. */ public PonyLevel getPonyLevel() { - if (ponylevel == null) ponylevel = PonyLevel.PONIES; + if (ponylevel == null) { + ponylevel = PonyLevel.PONIES; + } return ponylevel; } From e812ca8de9c1244808bc54e2e17499e75ac01548 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 6 May 2018 13:34:11 +0200 Subject: [PATCH 96/96] Fix some errors in the ForgeProxy docs --- src/main/java/com/minelittlepony/ForgeProxy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java index 90ad340c..09d5b6a5 100644 --- a/src/main/java/com/minelittlepony/ForgeProxy.java +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -21,7 +21,7 @@ public class ForgeProxy { private static boolean forgeLoaded = ModUtilities.fmlIsPresent(); /** - * Gets the mod armour texture for associated item and slot. + * Gets the mod armour texture for an associated item and slot. * * @param entity The entity to get armour for. * @param item The armour item @@ -37,7 +37,7 @@ public class ForgeProxy { } /** - * Gets the mod armour texture for associated item and slot. + * Gets the mod armour model for an associated item and slot. * * @param entity The entity to get armour for. * @param item The armour item