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..9bbb49b6 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/TexturesPayloadBuilder.java @@ -15,6 +15,7 @@ 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(); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java index 50046925..9a3643b6 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java @@ -14,6 +14,7 @@ import javax.annotation.Nullable; public class ValhallaSkinServer implements SkinServer { + @SuppressWarnings("unused") private final String baseURL; public ValhallaSkinServer(String baseURL) { diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java index a192c7b3..09d5b6a5 100644 --- a/src/main/java/com/minelittlepony/ForgeProxy.java +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -2,40 +2,51 @@ 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. + */ 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 an 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 model for an 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); return def; } - - public static Optional>> createShoulderLayer() { - if (forgeLoaded) { - // TODO - } - return Optional.empty(); - } - } diff --git a/src/main/java/com/minelittlepony/IPonyData.java b/src/main/java/com/minelittlepony/IPonyData.java deleted file mode 100644 index 20b253ac..00000000 --- a/src/main/java/com/minelittlepony/IPonyData.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.minelittlepony; - -import net.minecraft.client.resources.data.IMetadataSection; - -/** - * Dummy interface so gson won't go crazy - */ -public interface IPonyData extends IMetadataSection { - -} diff --git a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java index bf40a70b..2a9d5612 100644 --- a/src/main/java/com/minelittlepony/LiteModMineLittlePony.java +++ b/src/main/java/com/minelittlepony/LiteModMineLittlePony.java @@ -27,19 +27,16 @@ public class LiteModMineLittlePony implements Tickable, InitCompleteListener { @Override public void init(File configPath) { - this.mlp = new MineLittlePony(); - this.mlp.init(); - + 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 e9b16174..ba43cf3f 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -1,90 +1,67 @@ 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.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.pony.data.IPonyData; +import com.minelittlepony.pony.data.PonyDataSerialzier; 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.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@"; 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"); 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; @@ -94,95 +71,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.initializeMobRenderers(rm); - - } - - private void saveCurrentRenderers(RenderManager rm) { - // villagers - saveRenderer(rm, EntityVillager.class); - saveRenderer(rm, EntityZombieVillager.class); - // zombies - saveRenderer(rm, EntityZombie.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 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)); - logger.info("Zombies are now ponies."); - } else { - ModUtilities.addRenderer(EntityZombie.class, getRenderer(EntityZombie.class)); - ModUtilities.addRenderer(EntityHusk.class, getRenderer(EntityHusk.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()) { @@ -198,14 +93,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 this.ponyManager; + 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/MissingRendererException.java b/src/main/java/com/minelittlepony/MissingRendererException.java index 34117e18..4ae09414 100644 --- a/src/main/java/com/minelittlepony/MissingRendererException.java +++ b/src/main/java/com/minelittlepony/MissingRendererException.java @@ -1,6 +1,7 @@ package com.minelittlepony; public class MissingRendererException extends RuntimeException { + private static final long serialVersionUID = -6059469512902628663L; public MissingRendererException(Class cl) { super("Could not find a renderer for " + cl.getName() + ". This is a bug."); diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java deleted file mode 100644 index f4e24fd6..00000000 --- a/src/main/java/com/minelittlepony/Pony.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.minelittlepony; - -import com.google.common.base.MoreObjects; -import com.minelittlepony.model.PMAPI; -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; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; - -import java.awt.image.BufferedImage; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@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; - - public Pony(AbstractClientPlayer player) { - this.texture = player.getLocationSkin(); - 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); - } - - public Pony(ResourceLocation resourceLocation) { - this(resourceLocation, null); - } - - 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; - } - - @Nullable - private PonyData checkPonyMeta(ResourceLocation location) { - try { - IResource res = Minecraft.getMinecraft().getResourceManager().getResource(location); - if (res.hasMetadata()) { - PonyData data = res.getMetadata(PonyDataSerialzier.NAME); - if (data != null) { - return data; - } - } - } catch (FileNotFoundException e) { - // Ignore uploaded texture - } catch (IOException e) { - MineLittlePony.logger.warn("Unable to read {} metadata", location, e); - } - return null; - } - - @Nullable - private BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { - BufferedImage skinImage = null; - try { - IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); - skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); - MineLittlePony.logger.debug("Obtained skin from resource location {}", textureResourceLocation); - // this.checkSkin(skinImage); - } catch (IOException e) { - - try { - ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation); - if (e2 instanceof ThreadDownloadImageData) { - - 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) { - - } - } - - return skinImage; - } - - private PonyData checkSkin(BufferedImage bufferedimage) { - 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; - } - 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; - } - - PlayerModel model; - if (is_a_pony) { - model = smallArms ? PMAPI.ponySmall : PMAPI.pony; - } else { - model = smallArms ? PMAPI.humanSmall : PMAPI.human; - } - return model; - } - - public ResourceLocation getTexture() { - return this.texture; - } - - public PonyData getMetadata() { - return metadata; - } - - @Override - public String 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..70a513e3 100644 --- a/src/main/java/com/minelittlepony/PonyConfig.java +++ b/src/main/java/com/minelittlepony/PonyConfig.java @@ -1,40 +1,51 @@ 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; +/** + * Storage contained for MineLP client settings. + * + */ @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; + /** + * 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 getEffectivePonyLevel(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) + 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/PonyData.java b/src/main/java/com/minelittlepony/PonyData.java deleted file mode 100644 index d9ea3dfa..00000000 --- a/src/main/java/com/minelittlepony/PonyData.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.minelittlepony; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableBiMap; - -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; - private final PonySize size; - private final int glowColor; - - public PonyData() { - this(PonyRace.HUMAN, TailLengths.FULL, PonyGender.MARE, PonySize.NORMAL, 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; - } - - public PonyRace getRace() { - return race; - } - - public TailLengths getTail() { - return tailSize; - } - - public PonyGender getGender() { - return gender; - } - - public PonySize getSize() { - return MineLittlePony.getConfig().sizes ? size : PonySize.NORMAL; - } - - public int getGlowColor() { - return glowColor; - } - - public boolean hasMagic() { - return this.race != null && this.race.hasHorn() && this.glowColor != 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("race", race) - .add("tailSize", tailSize) - .add("gender", gender) - .add("size", size) - .add("glowColor", "#" + Integer.toHexString(glowColor)) - .toString(); - } - - static PonyData 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; - } - } -} diff --git a/src/main/java/com/minelittlepony/PonyGender.java b/src/main/java/com/minelittlepony/PonyGender.java deleted file mode 100644 index 060295f3..00000000 --- a/src/main/java/com/minelittlepony/PonyGender.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.minelittlepony; - -public enum PonyGender { - MARE, - STALLION -} diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index ed340954..7e9a4254 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -5,7 +5,13 @@ import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.JsonParseException; 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; import net.minecraft.client.resources.IResourceManagerReloadListener; @@ -19,15 +25,21 @@ 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 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; @@ -40,87 +52,132 @@ 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) { - return this.poniesCache.computeIfAbsent(skinResourceLocation, Pony::new); + /** + * 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) { + ResourceLocation skin = player.getLocationSkin(); + UUID uuid = player.getGameProfile().getId(); - Pony myLittlePony = this.poniesCache.computeIfAbsent(player.getLocationSkin(), res -> new Pony(player)); + if (skin == null) return getDefaultPony(uuid); - if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.getMetadata().getRace() == PonyRace.HUMAN) { - myLittlePony = this.getPonyFromBackgroundResourceRegistry(player); - } - - return myLittlePony; + return getPony(skin, uuid); } - public Pony removePony(ResourceLocation location) { - return this.poniesCache.remove(location); + public Pony getPony(NetworkPlayerInfo playerInfo) { + ResourceLocation skin = playerInfo.getLocationSkin(); + UUID uuid = playerInfo.getGameProfile().getId(); + + if (skin == null) return getDefaultPony(uuid); + + return getPony(skin, uuid); } - private ResourceLocation getBackgroundPonyResource(UUID id) { - if (getNumberOfPonies() > 0) { - int backgroundIndex = id.hashCode() % this.getNumberOfPonies(); - if (backgroundIndex < 0) { - backgroundIndex += this.getNumberOfPonies(); - } + /** + * 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)); - return backgroundPonyList.get(backgroundIndex); + if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { + return getBackgroundPony(uuid); } - return STEVE; + + return pony; } - private Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) { - ResourceLocation textureResourceLocation; - if (player.isUser()) { - textureResourceLocation = getDefaultSkin(player.getUniqueID()); - } else { - textureResourceLocation = this.getBackgroundPonyResource(player.getUniqueID()); + /** + * 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)); } - Pony myLittlePony; - if (!this.backgroudPoniesCache.containsKey(textureResourceLocation)) { - myLittlePony = new Pony(textureResourceLocation); - this.backgroudPoniesCache.put(textureResourceLocation, myLittlePony); - } else { - myLittlePony = this.backgroudPoniesCache.get(textureResourceLocation); + return getBackgroundPony(uuid); + } + + private Pony getBackgroundPony(UUID uuid) { + if (getNumberOfPonies() == 0 || isUser(uuid)) { + return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); } - return myLittlePony; + 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. + */ + public Pony removePony(ResourceLocation resource) { + return poniesCache.remove(resource); } @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); } } - } catch (IOException e) { + } catch (IOException ignored) { // this isn't the exception you're looking for. } MineLittlePony.logger.info("Detected {} background ponies installed.", getNumberOfPonies()); } private ResourceLocation getDefaultSkin(UUID uuid) { - return (uuid.hashCode() & 1) == 0 ? STEVE : ALEX; + 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; } private int getNumberOfPonies() { @@ -142,7 +199,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/PonyRace.java b/src/main/java/com/minelittlepony/PonyRace.java deleted file mode 100644 index 7c775012..00000000 --- a/src/main/java/com/minelittlepony/PonyRace.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.minelittlepony; - -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), - ; - - private boolean wings; - private boolean horn; - - PonyRace(boolean wings, boolean horn) { - this.wings = wings; - this.horn = horn; - } - - public boolean hasHorn() { - return horn; - } - - public boolean hasWings() { - return wings; - } -} diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java new file mode 100644 index 00000000..809e305c --- /dev/null +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -0,0 +1,152 @@ +package com.minelittlepony; + +import java.util.Map; + +import com.google.common.collect.Maps; +import com.minelittlepony.mixin.MixinRenderManager; +import com.minelittlepony.hdskins.gui.EntityPonyModel; +import com.minelittlepony.hdskins.gui.RenderPonyModel; +import com.minelittlepony.model.player.PlayerModels; +import com.minelittlepony.render.player.RenderPonyPlayer; +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.RenderPonyWitch; +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.EntityWitch; +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(); + + /** + * Registers all new player skin types. (currently only pony and slimpony). + */ + public void initialisePlayerRenderers(RenderManager manager) { + // Preview on the select skin gui + ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(manager)); + + registerPlayerSkin(manager, PlayerModels.EARTH); + registerPlayerSkin(manager, PlayerModels.PEGASUS); + registerPlayerSkin(manager, PlayerModels.ALICORN); + } + + private void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { + addPlayerSkin(manager, false, playerModel); + addPlayerSkin(manager, true, playerModel); + } + + 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); + } + + /** + * Registers all entity model replacements. (except for players). + */ + public void initializeMobRenderers(RenderManager manager, PonyConfig config) { + + if (config.villagers) { + 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); + restoreRenderer(EntityWitch.class); + restoreRenderer(EntityZombieVillager.class); + } + + if (config.zombies) { + 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); + restoreRenderer(EntityHusk.class); + restoreRenderer(EntityGiantZombie.class); + } + + if (config.pigzombies) { + pushNewRenderer(manager, EntityPigZombie.class, new RenderPonyPigman(manager)); + MineLittlePony.logger.info("Zombie pigmen are now ponies."); + } else { + restoreRenderer(EntityPigZombie.class); + } + + if (config.skeletons) { + 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); + restoreRenderer(EntityStray.class); + restoreRenderer(EntityWitherSkeleton.class); + } + + if (config.illagers) { + 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); + 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/gui/PonySettingPanel.java b/src/main/java/com/minelittlepony/PonySettingPanel.java similarity index 74% rename from src/main/java/com/minelittlepony/gui/PonySettingPanel.java rename to src/main/java/com/minelittlepony/PonySettingPanel.java index f7745153..1e2095b1 100644 --- a/src/main/java/com/minelittlepony/gui/PonySettingPanel.java +++ b/src/main/java/com/minelittlepony/PonySettingPanel.java @@ -1,8 +1,6 @@ -package com.minelittlepony.gui; +package com.minelittlepony; -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; @@ -11,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."; @@ -64,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: @@ -106,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); } @@ -177,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/PonySize.java b/src/main/java/com/minelittlepony/PonySize.java deleted file mode 100644 index 9ac55246..00000000 --- a/src/main/java/com/minelittlepony/PonySize.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.minelittlepony; - -public enum PonySize { - NORMAL, - LARGE, - FOAL, - TALL -} diff --git a/src/main/java/com/minelittlepony/TailLengths.java b/src/main/java/com/minelittlepony/TailLengths.java deleted file mode 100644 index 41542a14..00000000 --- a/src/main/java/com/minelittlepony/TailLengths.java +++ /dev/null @@ -1,20 +0,0 @@ -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; - } -} 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..bf7ef895 --- /dev/null +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -0,0 +1,17 @@ +package com.minelittlepony.ducks; + +import net.minecraft.client.network.NetworkPlayerInfo; + +public interface IPlayerInfo { + /** + * Returns true if the vanilla skin (the one returned by NetworkPlayerInfo.getSkinLocation) uses the ALEX model type. + */ + boolean usesSlimArms(); + + /** + * Quick cast back to the original type. + */ + default NetworkPlayerInfo unwrap() { + return (NetworkPlayerInfo)this; + } +} 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/IRenderPony.java b/src/main/java/com/minelittlepony/ducks/IRenderPony.java index 439a3268..d630a50a 100644 --- a/src/main/java/com/minelittlepony/ducks/IRenderPony.java +++ b/src/main/java/com/minelittlepony/ducks/IRenderPony.java @@ -1,8 +1,19 @@ package com.minelittlepony.ducks; -import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.ModelWrapper; +/** + * I Render Pony now, oky? + */ public interface IRenderPony { - PlayerModel getPony(); + /** + * 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/EntityPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java index d16fc047..7b35c4a4 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java @@ -1,11 +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? + 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 ad052db1..1a540e88 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -4,16 +4,20 @@ 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; +/** + * Skin uploading GUI. Usually displayed over the main menu. + */ public class GuiSkinsMineLP extends GuiSkins { private PonyManager ponyManager; public GuiSkinsMineLP(PonyManager manager) { - this.ponyManager = manager; + ponyManager = manager; } @Override @@ -22,26 +26,26 @@ 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) { - ponyManager.removePony(this.localPlayer.getSkinTexture()); + 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); } } @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/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 88b9ab81..38e8fed9 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.Pony; -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.ModelPonyElytra; -import com.minelittlepony.model.PlayerModel; -import com.minelittlepony.renderer.layer.AbstractPonyLayer; +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; @@ -18,53 +20,67 @@ 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) { - super(renderer); + boolean renderingAsHuman = false; + + public RenderPonyModel(RenderManager manager) { + super(manager); } @Override public ModelPlayer getEntityModel(EntityPonyModel playermodel) { - ResourceLocation loc = this.getEntityTexture(playermodel); + renderingAsHuman = true; + + 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); + // 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); + } + + ModelWrapper pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); + renderingAsHuman = false; + return pm.getModel(); } @Override protected LayerRenderer getElytraLayer() { - final LayerRenderer elytra = super.getElytraLayer(); - final ModelPonyElytra modelElytra = new ModelPonyElytra(); - return new AbstractPonyLayer(this, elytra) { + return new AbstractPonyLayer(this) { + final PonyElytra ponyElytra = new PonyElytra(); + final ModelElytra modelElytra = new ModelElytra(); @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 move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { 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); - ((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(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 new file mode 100644 index 00000000..af1323ef --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -0,0 +1,31 @@ +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.PonyManager; +import com.minelittlepony.ducks.IPlayerInfo; + +import net.minecraft.client.network.NetworkPlayerInfo; + +@Mixin(NetworkPlayerInfo.class) +public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { + + @Shadow + private String skinType; + + @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())); + } + + @Override + public boolean usesSlimArms() { + if (skinType == null) return PonyManager.isSlimSkin(unwrap().getGameProfile().getId()); + return "slim".equals(skinType); + } +} 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); } } } 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..5f200841 --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java @@ -0,0 +1,15 @@ +package com.minelittlepony.mixin; + +import java.util.Map; + +import org.spongepowered.asm.mixin.Mixin; +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 interface MixinRenderManager { + @Accessor + Map getSkinMap(); +} 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..6c4f0a60 --- /dev/null +++ b/src/main/java/com/minelittlepony/mixin/MixinThreadDownloadImageData.java @@ -0,0 +1,14 @@ +package com.minelittlepony.mixin; + +import java.awt.image.BufferedImage; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import net.minecraft.client.renderer.ThreadDownloadImageData; + +@Mixin(ThreadDownloadImageData.class) +public interface MixinThreadDownloadImageData { + @Accessor("bufferedImage") + BufferedImage getBufferedImage(); +} 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 60299f09..00000000 --- a/src/main/java/com/minelittlepony/model/AbstractArmor.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.PonyData; - -public abstract class AbstractArmor { - - public AbstractPonyModel modelArmorChestplate; - public AbstractPonyModel modelArmor; - - public void apply(PonyData 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..c7b96fdd 100644 --- a/src/main/java/com/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/minelittlepony/model/AbstractPonyModel.java @@ -1,242 +1,942 @@ package com.minelittlepony.model; -import com.minelittlepony.PonyData; -import com.minelittlepony.PonySize; -import com.minelittlepony.model.pony.ModelPlayerPony; +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; 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 { +public abstract class AbstractPonyModel extends ModelPlayer implements IModel { + /** + * The model's current scale. + */ protected float scale = 0.0625F; - public ModelRenderer steveLeftArm; - public ModelRenderer steveRightArm; - public ModelRenderer steveLeftArmwear; - public ModelRenderer steveRightArmwear; - public boolean isFlying; public boolean isSleeping; - public PonyData metadata = new PonyData(); + /** + * 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 PlaneRenderer upperTorso; + public PlaneRenderer neck; + + public PonyTail tail; + public PonySnout snout; public AbstractPonyModel(boolean arms) { super(0, arms); - this.steveLeftArm = this.bipedLeftArm; - this.steveRightArm = this.bipedRightArm; - this.steveLeftArmwear = this.bipedLeftArmwear; - this.steveRightArmwear = this.bipedLeftArmwear; - } - - public void init(float yOffset, float stretch) { - this.initTextures(); - this.initPositions(yOffset, stretch); - } - - protected void initTextures() { - } - - protected void initPositions(float yOffset, float stretch) { } @Override - 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; - } - this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * 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.rotateAngleY = 0; - this.steveLeftArm.rotateAngleZ = 0; - - copyModelAngles(steveRightArm, steveRightArmwear); - copyModelAngles(steveLeftArm, steveLeftArmwear); + public PonyArmor createArmour() { + return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); } - protected boolean doCancelRender() { - return false; - } + /** + * 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 ticks, float headYaw, float headPitch, float scale, Entity entity) { + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); - public static void setRotationPoint(ModelRenderer aRenderer, float setX, float setY, float setZ) { - aRenderer.rotationPointX = setX; - aRenderer.rotationPointY = setY; - aRenderer.rotationPointZ = setZ; - } + float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; + float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F; - public static void shiftRotationPoint(ModelRenderer aRenderer, float shiftX, float shiftY, float shiftZ) { - aRenderer.rotationPointX += shiftX; - aRenderer.rotationPointY += shiftY; - aRenderer.rotationPointZ += shiftZ; - } + headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); + headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch))); - public void transform(BodyPart part) { - if (this.isRiding) { - translate(0.0F, -0.6F, -0.2F); + updateHeadRotation(headRotateAngleX, headRotateAngleY); + + float bodySwingRotation = 0; + if (swingProgress > -9990.0F && !metadata.hasMagic()) { + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; } - 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); - } + rotateLook(move, swing, bodySwingRotation, ticks); - if (this.metadata.getSize() == PonySize.FOAL || isChild) { - if (this.isSneak && !this.isFlying) { - translate(0.0F, -0.12F, 0.0F); - } + setLegs(move, swing, ticks, entity); + holdItem(swing); + swingItem(entity); - 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 (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; - if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) { - translate(0.0F, -0.08F, 0.0F); - } + bipedRightLeg.rotationPointZ = 15; + bipedRightLeg.rotationPointY = 10; + bipedRightLeg.rotateAngleX = -PI / 4; + bipedRightLeg.rotateAngleY = PI / 5; - 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; - } + bipedLeftArm.rotateAngleZ = -PI * 0.06f; + bipedRightArm.rotateAngleZ = PI * 0.06f; } else { - if (this.isSleeping) { - translate(0.0F, -0.75F, 0.25F); - } + 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(ticks); + setHead(0, 0, 0); } - if (part == BodyPart.HEAD) { - rotate(motionPitch, 1F, 0F, 0F); + + if (isSleeping) ponySleep(); + + aimBow(leftArmPose, rightArmPose, ticks); + fixSpecialRotationPoints(move); + + animateWears(); + + if (snout != null) { + 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); + } + + /** + * 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; + + 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 point. + */ + 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; + } + + /** + * + * 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, ticks, entity); + } else { + rotateLegsOnGround(move, swing, ticks, entity); + } + + bipedLeftArm.rotateAngleZ = 0; + bipedRightArm.rotateAngleZ = 0; + + adjustLegs(move, swing, ticks); + } + + /** + * 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); + + 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; + } + + /** + * 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 baseRotation = move * 0.6662F; // magic number ahoy + float scale = swing / 4; + + bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale; + bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale; + + bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale; + bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale; + + bipedLeftArm.rotateAngleY = 0; + bipedRightArm.rotateAngleY = 0; + + bipedLeftLeg.rotateAngleY = 0; + bipedRightLeg.rotateAngleY = 0; + } + + protected float getLegOutset() { + if (isSleeping) return 3.6f; + if (isCrouching()) return 1; + return 5; + } + + protected float getLegSpread() { + return rainboom ? 2 : 1; + } + + /** + * + * 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; + + float spread = getLegSpread(); + + bipedRightArm.rotationPointZ = spread + sin; + bipedLeftArm.rotationPointZ = spread - sin; + + float legRPX = cos - getLegOutset(); + + bipedRightArm.rotationPointX = -legRPX; + bipedRightLeg.rotationPointX = -legRPX; + + bipedLeftArm.rotationPointX = legRPX; + bipedLeftLeg.rotationPointX = legRPX; + + bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; + bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; + + bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; + 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; + + alignArmForAction(bipedLeftArm, leftArmPose, both, swing); + 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: + 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: + } + } + + /** + * 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); + + swingArm(getArmForSide(mainSide)); + } + } + + /** + * Animates arm swinging. + * + * @param arm The arm to swing + */ + 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; + } + + /** + * 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(ticks * 0.09F) * 0.05F + 0.05F; + float sin = MathHelper.sin(ticks * 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 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 ticks) { + arm.rotateAngleZ = 0; + arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; + arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; + arm.rotateAngleZ += MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + arm.rotateAngleX += MathHelper.sin(ticks * 0.067F) * 0.05F; + } + + /** + * 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); + } + + /** + * Loads texture values. + */ + protected void initTextures() { + boxList.clear(); + initHeadTextures(); + initBodyTextures(); + initLegTextures(); + initTailTextures(); + } + + /** + * Loads texture positions and boxes. Pretty much just finishes the job of initTextures. + */ + 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(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) + .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) + .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; + float armY = THIRDP_ARM_CENTRE_Y - 6; + float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth; + + bipedLeftArm .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 - armWidth, 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(rarmX, yOffset + rarmY, 0); + } + + if (bipedRightArmwear != null) { + 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(rarmX, yOffset, 0); + } + + if (bipedRightLegwear != null) { + bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f); + bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0); + } + } + + public ArmPose getArmPoseForSide(EnumHandSide side) { + return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; + } + + @Override + public boolean isCrouching() { + 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; + } + + @Override + public boolean isFlying(Entity entity) { + return (isFlying && metadata.getRace().hasWings()) || + (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()); + } + + @Override + public boolean isFlying() { + return isFlying; + } + + @Override + public boolean isChild() { + return metadata.getSize() == PonySize.FOAL || isChild; + } + + @Override + public float getSwingAmount() { + return swingProgress; + } + + /** + * 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 ticks Render partial ticks + */ + 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(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; + arm.rotateAngleX += sin; + + arm.rotateAngleY = direction * (0.1F - swing * 0.6F); + arm.rotateAngleZ = cos; + + } + + /** + * 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 ticks, float headYaw, float headPitch, float scale) { + + pushMatrix(); + transform(BodyPart.HEAD); + renderHead(entityIn, move, swing, ticks, headYaw, headPitch, scale); + popMatrix(); + + pushMatrix(); + transform(BodyPart.NECK); + renderNeck(); + popMatrix(); + + pushMatrix(); + transform(BodyPart.BODY); + renderBody(entityIn, move, swing, ticks, headYaw, headPitch, scale); + popMatrix(); + + pushMatrix(); + transform(BodyPart.LEGS); + renderLegs(); + popMatrix(); + } + + /** + * + * 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); + } + + protected void renderNeck() { + GlStateManager.scale(0.9, 0.9, 0.9); + neck.render(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); + } + 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 + public void transform(BodyPart part) { + if (isRiding) translate(0, -0.6F, -0.2F); + + if (isSleeping) { + rotate(90, 1, 0, 0); + rotate(180, 0, 1, 0); + } + + if (part == BodyPart.HEAD) { + rotate(motionPitch, 1, 0, 0); + } + + // TODO: Get these out of here + if (isChild()) { + transformFoal(part); + } else if (metadata.getSize() == PonySize.LARGE) { + transformLarge(part); + } else if (metadata.getSize() == PonySize.TALL) { + transformTall(part); + } else { + if (isSleeping) translate(0, -0.61F, 0.25F); + } + + } + + private void transformTall(BodyPart part) { + if (isSleeping) translate(0, -0.5F, 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 (isSleeping) translate(0, -0.98F, 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); + if (isSleeping) translate(0, -1.48F, 0.25F); + if (isRiding) translate(0, -0.1F, 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; + } + } + + /** + * 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; + rainboom = pony.rainboom; } } @Override public ModelRenderer getRandomModelBox(Random rand) { - // empty lists cause problems - ModelRenderer mr; + // 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 randomI = rand.nextInt(boxList.size()); + int index = randomI; + + ModelRenderer result; do { - // try until it's not - mr = super.getRandomModelBox(rand); - } while (mr.cubeList.isEmpty()); - return mr; + result = boxList.get(randomI); + if (!result.cubeList.isEmpty()) return result; + + index = (index + 1) % boxList.size(); + } while (index != randomI); + + return result; } } diff --git a/src/main/java/com/minelittlepony/model/ModelHornGlow.java b/src/main/java/com/minelittlepony/model/ModelHornGlow.java deleted file mode 100644 index 37d8cc8f..00000000 --- a/src/main/java/com/minelittlepony/model/ModelHornGlow.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.renderer.HornGlowRenderer; -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 ModelHornGlow extends ModelBox { - - 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); - - 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; - if (par1ModelRenderer.mirror) { - float var26 = var11; - var11 = par4; - par4 = var26; - } - - 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); - - 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); - this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{var32, var18, var21, var17}, par2, - par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, - par1ModelRenderer.textureHeight); - this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{var19, var18, var32, var15}, par2 + par9, - par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.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); - 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); - 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) { - TexturedQuad[] var22 = this.quadList; - - for (TexturedQuad var25 : var22) { - var25.flipFace(); - } - } - - } - - @Override - public void render(@Nonnull BufferBuilder buffer, float par2) { - TexturedQuad[] var3 = this.quadList; - for (TexturedQuad var6 : var3) { - var6.draw(buffer, par2); - } - - } -} 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..1edb4daa --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ModelMobPony.java @@ -0,0 +1,45 @@ +package com.minelittlepony.model; + +import com.minelittlepony.model.player.ModelAlicorn; + +import net.minecraft.util.math.MathHelper; + +/** + * Common class for all humanoid (ponioid?) non-player enemies. + * + */ +public class ModelMobPony extends ModelAlicorn { + + public ModelMobPony() { + super(false); + } + + /** + * Returns true if the angle is to the right? + */ + public boolean islookAngleRight(float move) { + return MathHelper.sin(move / 20) < 0; + } + + @Override + 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, ticks); + } else { + rotateArmHolding(bipedRightArm, -1, swingProgress, ticks); + } + } + + if (leftArmPose != ArmPose.EMPTY) { + if (!canCast()) { + unicornArmRight.setRotationPoint(-7, 12, -2); + rotateArmHolding(unicornArmLeft, -1, swingProgress, ticks); + } else { + rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); + } + } + } +} diff --git a/src/main/java/com/minelittlepony/model/ModelPlane.java b/src/main/java/com/minelittlepony/model/ModelPlane.java deleted file mode 100644 index dc82f318..00000000 --- a/src/main/java/com/minelittlepony/model/ModelPlane.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.renderer.PlaneRenderer; -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 { - - 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) { - 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; - x2 += scale; - y2 += scale; - z2 += scale; - - if (renderer.mirror) { - float v = x2; - x2 = x; - x = v; - } - - if (renderer.mirrory) { - float v = y2; - y2 = y; - y = v; - } - - if (renderer.mirrorz) { - float v = z2; - z2 = z; - z = v; - - } - - // 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); - - // east - this.quadList[0] = new TexturedQuad( - new PositionTextureVertex[]{edn, eds, eus, eun}, - textureX, textureY, - textureX + d, textureY + h, - renderer.textureWidth, renderer.textureHeight); - // west - this.quadList[1] = new TexturedQuad( - new PositionTextureVertex[]{wds, wdn, wun, wus}, - textureX, textureY, - textureX + d, textureY + h, - renderer.textureWidth, renderer.textureHeight); - // down - this.quadList[3] = new TexturedQuad( - new PositionTextureVertex[]{edn, wdn, wds, eds}, - textureX, textureY, - textureX + w, textureY + d, - renderer.textureWidth, renderer.textureHeight); - // up - this.quadList[2] = new TexturedQuad( - new PositionTextureVertex[]{eus, wus, wun, eun}, - textureX, textureY, - textureX + w, textureY + d, - renderer.textureWidth, renderer.textureHeight); - // south - this.quadList[4] = new TexturedQuad( - new PositionTextureVertex[]{eds, wds, wus, eus}, - textureX, textureY, - textureX + w, textureY + h, - renderer.textureWidth, renderer.textureHeight); - // north - this.quadList[5] = 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(); - } - } - } - - @Override - public void render(@Nonnull BufferBuilder renderer, float scale) { - this.quadList[this.face.ordinal()].draw(renderer, scale); - } - - public enum Face { - EAST, - WEST, - DOWN, - UP, - SOUTH, - NORTH - } -} diff --git a/src/main/java/com/minelittlepony/model/ModelPonyElytra.java b/src/main/java/com/minelittlepony/model/ModelPonyElytra.java deleted file mode 100644 index b83c6560..00000000 --- a/src/main/java/com/minelittlepony/model/ModelPonyElytra.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.minelittlepony.model; - -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 ModelPonyElytra extends ModelBase { - private ModelRenderer rightWing; - private ModelRenderer leftWing = new ModelRenderer(this, 22, 0); - - public ModelPonyElytra() { - 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); - } - - @Override - public void render(Entity entityIn, float p_78088_2_, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - GlStateManager.disableRescaleNormal(); - GlStateManager.disableCull(); - this.leftWing.render(scale); - this.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; - - if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).isElytraFlying()) { - float f4 = 1.0F; - - if (entityIn.motionY < 0.0D) { - Vec3d vec3d = (new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ)).normalize(); - f4 = 1.0F - (float) Math.pow(-vec3d.y, 1.5D); - } - - rotateX = f4 * PI * (2 / 3F) + (1.0F - f4) * rotateX; - rotateY = f4 * ((float) Math.PI / 2F) + (1.0F - f4) * rotateY; - } else if (entityIn.isSneaking()) { - rotateX = ((float) Math.PI * 1.175F); - rotateY = PI / 2; - rpY = PonyModelConstants.BODY_RP_Y_SNEAK; - rotateZ = PI / 4F; - } - - this.leftWing.rotationPointX = 5.0F; - this.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; - } else { - this.leftWing.rotateAngleX = rotateX; - this.leftWing.rotateAngleZ = rotateZ; - this.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; - } - -} diff --git a/src/main/java/com/minelittlepony/model/ModelWrapper.java b/src/main/java/com/minelittlepony/model/ModelWrapper.java new file mode 100644 index 00000000..eceaa90a --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ModelWrapper.java @@ -0,0 +1,45 @@ +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 implements IModelWrapper { + + 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; + armor = model.createArmour(); + armor.apply(model.metadata); + } + + public AbstractPonyModel getModel() { + return model; + } + + /** + * Returns the contained armour model. + * @return + */ + public PonyArmor getArmor() { + return armor; + } + + public void apply(IPonyData meta) { + model.metadata = meta; + armor.apply(meta); + } + + 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 1a3b3d4f..2d02aa5e 100644 --- a/src/main/java/com/minelittlepony/model/PMAPI.java +++ b/src/main/java/com/minelittlepony/model/PMAPI.java @@ -1,33 +1,45 @@ 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.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.ModelSkeletonPony; +import com.minelittlepony.model.ponies.ModelVillagerPony; +import com.minelittlepony.model.ponies.ModelWitchPony; +import com.minelittlepony.model.ponies.ModelZombiePony; 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 { - 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 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 final ModelWrapper pony = new ModelWrapper(new ModelAlicorn(false)); + public static final ModelWrapper ponySmall = new ModelWrapper(new ModelAlicorn(true)); + + public static final ModelWrapper earthpony = new ModelWrapper(new ModelEarthPony(false)); + public static final ModelWrapper earthponySmall = new ModelWrapper(new ModelEarthPony(true)); + + 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()) { 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/PegasusWings.java b/src/main/java/com/minelittlepony/model/PegasusWings.java deleted file mode 100644 index bfe6ac5f..00000000 --- a/src/main/java/com/minelittlepony/model/PegasusWings.java +++ /dev/null @@ -1,183 +0,0 @@ -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; - -public class PegasusWings extends ModelBase implements PonyModelConstants { - - - private final AbstractPonyModel pony; - - public ModelRenderer[] leftWing; - public ModelRenderer[] rightWing; - - public ModelRenderer[] leftWingExt; - public ModelRenderer[] rightWingExt; - - 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]; - - 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); - } - - @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, 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; - } - if (pony.isSneak && !pony.isFlying) { - this.sneak(); - } else { - this.unsneak(ageInTicks); - - } - - 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; - - } - - @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); - } - } - } - } - - 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; - } - } - - private void unsneak(float tick) { - if (pony.isFlying) { - float WingRotateAngleZ = MathHelper.sin(tick * 0.536F) * 1.0F; - - for (ModelRenderer aLeftWingExt : this.leftWingExt) { - aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aLeftWingExt.rotateAngleZ = -WingRotateAngleZ - ROTATE_270 - 0.4F; - } - - for (ModelRenderer aRightWingExt : this.rightWingExt) { - aRightWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X; - aRightWingExt.rotateAngleZ = WingRotateAngleZ + ROTATE_270 + 0.4F; - } - } - } - -} diff --git a/src/main/java/com/minelittlepony/model/PlayerModel.java b/src/main/java/com/minelittlepony/model/PlayerModel.java deleted file mode 100644 index dda87cf6..00000000 --- a/src/main/java/com/minelittlepony/model/PlayerModel.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.PonyData; - -public class PlayerModel { - - private final AbstractPonyModel model; - private AbstractArmor armor; - - public PlayerModel(AbstractPonyModel model) { - this.model = model; - } - - 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); - } - - public AbstractArmor getArmor() { - return armor; - } - - public void apply(PonyData meta) { - model.metadata = meta; - armor.apply(meta); - } -} diff --git a/src/main/java/com/minelittlepony/model/PonyModelConstants.java b/src/main/java/com/minelittlepony/model/PonyModelConstants.java index 9852ec74..42686b39 100644 --- a/src/main/java/com/minelittlepony/model/PonyModelConstants.java +++ b/src/main/java/com/minelittlepony/model/PonyModelConstants.java @@ -1,52 +1,75 @@ package com.minelittlepony.model; -public interface PonyModelConstants { +public final class 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; + public static final float + 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, + BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, + BODY_ROTATE_ANGLE_X_RIDING = PI * 3.8F, + + BODY_RP_Y_NOTSNEAK = 0, + BODY_RP_Y_SNEAK = 7, + BODY_RP_Y_RIDING = 1, + + BODY_RP_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, + FIRSTP_ARM_CENTRE_Y = 4, + FIRSTP_ARM_CENTRE_Z = 0, + + FRONT_LEG_RP_Y_NOTSNEAK = 8, + FRONT_LEG_RP_Y_SNEAK = 8, + + HEAD_CENTRE_X = 0, + HEAD_CENTRE_Y = -1, + HEAD_CENTRE_Z = -2, + + HEAD_RP_X = 0, + HEAD_RP_Y = 0, + HEAD_RP_Z = 0, + + HORN_X = HEAD_CENTRE_X - 0.5F, + HORN_Y = HEAD_CENTRE_Y - 10, + HORN_Z = HEAD_CENTRE_Z - 1.5F, + + LEFT_WING_EXT_RP_X = 4.5F, + LEFT_WING_EXT_RP_Y = 6, + LEFT_WING_EXT_RP_Z = 6, + + 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, + TAIL_RP_Y = 0, + TAIL_RP_Z = 0, + + TAIL_RP_Z_NOTSNEAK = 14, + TAIL_RP_Z_SNEAK = 15, + + THIRDP_ARM_CENTRE_X = 0, + THIRDP_ARM_CENTRE_Y = 10, + THIRDP_ARM_CENTRE_Z = 0, + + WING_FOLDED_RP_Y = 13, + WING_FOLDED_RP_Z = -3, + + NECK_ROT_X = 0.166F; } diff --git a/src/main/java/com/minelittlepony/model/PonySnout.java b/src/main/java/com/minelittlepony/model/PonySnout.java deleted file mode 100644 index 451e12d0..00000000 --- a/src/main/java/com/minelittlepony/model/PonySnout.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.PonyGender; -import com.minelittlepony.renderer.PlaneRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.entity.Entity; - -public class PonySnout extends ModelBase implements PonyModelConstants { - - private PonyGender gender; - - 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); - - 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); - - pony.bipedHead.addChild(stallion); - } - - @Override - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - 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/UnicornHorn.java b/src/main/java/com/minelittlepony/model/UnicornHorn.java deleted file mode 100644 index 33109cab..00000000 --- a/src/main/java/com/minelittlepony/model/UnicornHorn.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.minelittlepony.model; - -import com.minelittlepony.PonyData; -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) { - - PonyData 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/armour/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java new file mode 100644 index 00000000..59205969 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/ModelPonyArmor.java @@ -0,0 +1,207 @@ +package com.minelittlepony.model.armour; + +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 PonyRenderer flankGuard; + + public PonyRenderer saddle; + public PonyRenderer helmet; + + public PonyRenderer leftLegging; + public PonyRenderer rightLegging; + + public ModelPonyArmor() { + super(); + textureHeight = 32; + } + + @Override + 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 move, float swing, float bodySwing, float ticks) { + bipedBody.rotateAngleY = bodySwing / 5; + } + + @Override + protected void adjustBodyRiding() { + adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING); + } + + @Override + protected void setHead(float posX, float posY, float posZ) { + super.setHead(posX, posY, posZ); + helmet.setRotationPoint(posX, posY, posZ); + } + + @Override + protected void updateHeadRotation(float x, float y) { + super.updateHeadRotation(x, y); + helmet.rotateAngleX = x; + helmet.rotateAngleY = y; + } + + @Override + protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { + bipedBody.rotateAngleX = rotateAngleX; + bipedBody.rotationPointY = rotationPointY; + bipedBody.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 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); + } + + @Override + protected void renderNeck() { + // TODO: Disabling the neck like this forces more complexity lower down + } + + @Override + protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) { + + } + + @Override + 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); + } + + @Override + protected void renderLegs() { + if (!isSneak) { + 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); + rightLegging.render(scale); + leftLegging.render(scale); + } + + @Override + protected void initTextures() { + initHeadTextures(); + initBodyTextures(); + initLegTextures(); + } + + @Override + protected void initHeadTextures() { + bipedHead = new PonyRenderer(this, 0, 0); + bipedHeadwear = new PonyRenderer(this, 32, 0); + helmet = new PonyRenderer(this, 0, 0); + } + + @Override + protected void initBodyTextures() { + bipedBody = new PonyRenderer(this, 16, 16); + flankGuard = new PonyRenderer(this, 0, 0); + saddle = new PonyRenderer(this, 16, 8); + } + + @Override + protected void initLegTextures() { + bipedRightArm = new PonyRenderer(this, 0, 16); + bipedRightLeg = new PonyRenderer(this, 0, 16); + + 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); + + 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); + + 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); + } + + @Override + 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); + + flankGuard.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) + .box(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch); + 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); + + 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() { + rightLegging.rotateAt(bipedRightLeg).rotateTo(bipedRightLeg); + leftLegging.rotateAt(bipedLeftLeg).rotateTo(bipedLeftLeg); + } + + @Override + public void setVisible(boolean invisible) { + super.setVisible(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 new file mode 100644 index 00000000..a2229dff --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/ModelSkeletonPonyArmor.java @@ -0,0 +1,15 @@ +package com.minelittlepony.model.armour; + +/** + * Armour for skeleton ponies. + * + */ +public class ModelSkeletonPonyArmor extends ModelPonyArmor { + + @Override + protected void fixSpecialRotationPoints(float move) { + if (rightArmPose != ArmPose.EMPTY && !canCast()) { + 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 new file mode 100644 index 00000000..15a37cba --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/ModelZombiePonyArmor.java @@ -0,0 +1,29 @@ +package com.minelittlepony.model.armour; + +import com.minelittlepony.render.AbstractPonyRenderer; + +public class ModelZombiePonyArmor extends ModelPonyArmor { + // Copied from ModelZombiePony + @Override + 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, ticks); + } else { + rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); + } + } + + @Override + protected void fixSpecialRotationPoints(float move) { + if (rightArmPose != ArmPose.EMPTY) return; + + if (islookAngleRight(move)) { + AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + } else { + AbstractPonyRenderer.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..31aeeec6 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/armour/PonyArmor.java @@ -0,0 +1,36 @@ +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 implements IModelWrapper { + + public final AbstractPonyModel chestplate; + public final AbstractPonyModel leggings; + + public PonyArmor(AbstractPonyModel chest, AbstractPonyModel body) { + chestplate = chest; + leggings = body; + } + + public void apply(IPonyData meta) { + chestplate.metadata = meta; + leggings.metadata = meta; + } + + public void init() { + chestplate.init(0, 1); + 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/pony/package-info.java b/src/main/java/com/minelittlepony/model/armour/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/armour/package-info.java index 5ea323a5..ce1fed56 100644 --- a/src/main/java/com/minelittlepony/model/pony/package-info.java +++ b/src/main/java/com/minelittlepony/model/armour/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.model.pony; +package com.minelittlepony.model.armour; import mcp.MethodsReturnNonnullByDefault; 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..acc4e84c --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModel.java @@ -0,0 +1,49 @@ +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. + */ + 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 new file mode 100644 index 00000000..c2edccdb --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelPegasus.java @@ -0,0 +1,13 @@ +package com.minelittlepony.model.capabilities; + +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 new file mode 100644 index 00000000..9381169e --- /dev/null +++ b/src/main/java/com/minelittlepony/model/capabilities/IModelUnicorn.java @@ -0,0 +1,25 @@ +package com.minelittlepony.model.capabilities; + +import com.minelittlepony.render.PonyRenderer; + +import net.minecraft.util.EnumHandSide; + +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(); + + /** + * Gets the preferred magic color for this mode. + */ + int getMagicColor(); +} 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/ModelWing.java b/src/main/java/com/minelittlepony/model/components/ModelWing.java new file mode 100644 index 00000000..3f602d73 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/ModelWing.java @@ -0,0 +1,70 @@ +package com.minelittlepony.model.components; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.render.PonyRenderer; + +public class ModelWing { + public PonyRenderer extended; + 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); + + addClosedWing(x, y, scale); + addFeathers(mirror, y, 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) + .rotateAngleX = ROTATE_90; + } + + 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 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); + } + + public void rotateWalking(float swing) { + 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); + } else { + folded.render(scale); + } + } + + public void rotateFlying(float angle) { + extended.rotateAngleZ = angle; + } + +} diff --git a/src/main/java/com/minelittlepony/model/components/PegasusWings.java b/src/main/java/com/minelittlepony/model/components/PegasusWings.java new file mode 100644 index 00000000..9846c2bd --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/PegasusWings.java @@ -0,0 +1,62 @@ +package com.minelittlepony.model.components; + +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 { + + private final IModelPegasus pegasus; + + public final ModelWing leftWing; + public final ModelWing rightWing; + + public PegasusWings(T model, float yOffset, float stretch) { + pegasus = model; + + leftWing = new ModelWing(model, false, 4f, yOffset, stretch, 32); + rightWing = new ModelWing(model, true, -6f, yOffset, stretch, 16); + } + + public void setRotationAngles(float move, float swing, float ticks) { + float flap = 0; + float progress = pegasus.getSwingAmount(); + + if (progress > 0) { + flap = MathHelper.sin(MathHelper.sqrt(progress) * PI * 2); + } else { + 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(flap); + rightWing.rotateWalking(-flap); + + if (pegasus.wingsAreOpen()) { + float flapAngle = getWingRotationFactor(ticks); + leftWing.rotateFlying(flapAngle); + rightWing.rotateFlying(-flapAngle); + } + + } + + public float getWingRotationFactor(float ticks) { + if (pegasus.isFlying()) { + return (MathHelper.sin(ticks * 0.536f) * 1) + ROTATE_270 + 0.4f; + } + return LEFT_WING_ROTATE_ANGLE_Z_SNEAK; + } + + 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/PonyElytra.java b/src/main/java/com/minelittlepony/model/components/PonyElytra.java new file mode 100644 index 00000000..518fc2fe --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/PonyElytra.java @@ -0,0 +1,97 @@ +package com.minelittlepony.model.components; + +import com.minelittlepony.render.PonyRenderer; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.GlStateManager; +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); + + public PonyElytra() { + leftWing .box(-10, 0, 0, 10, 20, 2, 1); + 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 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 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; + float rotateZ = PI / 12; + + 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 = 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; + rotateZ = PI / 4; + rpY = BODY_RP_Y_SNEAK; + } + + leftWing.rotationPointX = 5; + leftWing.rotationPointY = rpY; + + 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 { + leftWing.rotateAngleX = rotateX; + leftWing.rotateAngleZ = rotateZ; + leftWing.rotateAngleY = rotateY; + } + + rightWing.rotationPointX = -leftWing.rotationPointX; + rightWing.rotationPointY = leftWing.rotationPointY; + rightWing.rotateAngleX = leftWing.rotateAngleX; + rightWing.rotateAngleY = -leftWing.rotateAngleY; + rightWing.rotateAngleZ = -leftWing.rotateAngleZ; + } + +} diff --git a/src/main/java/com/minelittlepony/model/components/PonySnout.java b/src/main/java/com/minelittlepony/model/components/PonySnout.java new file mode 100644 index 00000000..05c12fd9 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/PonySnout.java @@ -0,0 +1,49 @@ +package com.minelittlepony.model.components; + +import com.minelittlepony.pony.data.PonyGender; +import com.minelittlepony.render.plane.PlaneRenderer; + +import static com.minelittlepony.model.PonyModelConstants.*; + +import com.minelittlepony.model.AbstractPonyModel; + +public class PonySnout { + + private PlaneRenderer mare; + private PlaneRenderer stallion; + + 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) { + 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); + 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); + } + + public void setGender(PonyGender gender) { + mare.isHidden = gender == PonyGender.STALLION; + stallion.isHidden = !mare.isHidden; + } +} diff --git a/src/main/java/com/minelittlepony/model/components/PonyTail.java b/src/main/java/com/minelittlepony/model/components/PonyTail.java new file mode 100644 index 00000000..c806149c --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/PonyTail.java @@ -0,0 +1,113 @@ +package com.minelittlepony.model.components; + +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.render.plane.PlaneRenderer; + +public class PonyTail extends PlaneRenderer { + + 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; i++) { + addChild(new TailSegment(theModel, i, yOffset, stretch)); + } + } + + /** + * 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; + + if (theModel.isCrouching() && !rainboom) { + rotateSneak(); + } else if (theModel.isRiding) { + rotationPointZ = 13; + rotationPointY = 3; + rotateAngleX = PI / 5; + } else { + setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); + if (rainboom) { + rotateAngleX = ROTATE_90 + MathHelper.sin(move) / 10; + } else { + rotateAngleX = swing / 2; + } + + if (!rainboom) { + swingX(ticks); + } + } + + if (rainboom) { + rotationPointY += 6; + rotationPointZ++; + } + + tailStop = theModel.metadata.getTail().ordinal(); + } + + public void swingX(float ticks) { + float sinTickFactor = MathHelper.sin(ticks * 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; + } + + 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(yOffset, 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); + } + + 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/components/UnicornHorn.java b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java new file mode 100644 index 00000000..4211beb7 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/components/UnicornHorn.java @@ -0,0 +1,51 @@ +package com.minelittlepony.model.components; + +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.render.HornGlowRenderer; +import com.minelittlepony.render.PonyRenderer; + +import static org.lwjgl.opengl.GL11.*; +import static net.minecraft.client.renderer.GlStateManager.*; +import static com.minelittlepony.model.PonyModelConstants.*; + +public class UnicornHorn { + + private PonyRenderer horn; + private HornGlowRenderer glow; + + public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) { + 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) + .rotateAngleX = 0.5F; + + 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); + } + + public void render(float scale) { + horn.render(scale); + } + + public 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(); + } +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/package-info.java b/src/main/java/com/minelittlepony/model/components/package-info.java similarity index 78% rename from src/main/java/com/minelittlepony/renderer/layer/package-info.java rename to src/main/java/com/minelittlepony/model/components/package-info.java index ff86e160..34123d53 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/package-info.java +++ b/src/main/java/com/minelittlepony/model/components/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.renderer.layer; +package com.minelittlepony.model.components; import mcp.MethodsReturnNonnullByDefault; 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..5350c5fb --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelAlicorn.java @@ -0,0 +1,164 @@ +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 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. + */ +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 ticks, Entity entity) { + super.rotateLegsOnGround(move, swing, ticks, entity); + + unicornArmRight.rotateAngleY = 0; + unicornArmLeft.rotateAngleY = 0; + } + + @Override + protected void adjustLegs(float move, float swing, float ticks) { + super.adjustLegs(move, swing, ticks); + + unicornArmLeft.rotateAngleZ = 0; + unicornArmRight.rotateAngleZ = 0; + + unicornArmLeft.rotateAngleX = 0; + unicornArmRight.rotateAngleX = 0; + } + + @Override + protected void holdItem(float swing) { + if (canCast()) { + boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; + + alignArmForAction(unicornArmLeft, leftArmPose, both, swing); + alignArmForAction(unicornArmRight, rightArmPose, both, swing); + } else { + super.holdItem(swing); + } + } + + @Override + protected void swingItem(Entity entity) { + EnumHandSide mainSide = getMainHand(entity); + + if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) { + if (swingProgress > -9990.0F && !isSleeping) { + swingArm(getUnicornArmForSide(mainSide)); + } + } else { + super.swingItem(entity); + } + } + + @Override + protected void swingArms(float ticks) { + if (isSleeping) return; + + if (canCast()) { + 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; + unicornArmRight.rotateAngleX += sin; + } + + if (leftArmPose != ArmPose.EMPTY) { + unicornArmLeft.rotateAngleZ += cos; + unicornArmLeft.rotateAngleX += sin; + } + } else { + super.swingArms(ticks); + } + } + + @Override + public PonyRenderer getUnicornArmForSide(EnumHandSide side) { + return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; + } + + @Override + public boolean canCast() { + return metadata.hasMagic(); + } + + @Override + public boolean isCasting() { + return rightArmPose != ArmPose.EMPTY || leftArmPose != ArmPose.EMPTY; + } + + @Override + public int getMagicColor() { + return metadata.getGlowColor(); + } + + @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 ticks) { + if (canCast()) { + if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, ticks); + if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, ticks); + } else { + super.aimBow(leftArm, rightArm, ticks); + } + } + + @Override + 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); + if (isCasting()) { + horn.renderMagic(getMagicColor(), 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); + } + + @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/player/ModelEarthPony.java b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java new file mode 100644 index 00000000..3e682e28 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelEarthPony.java @@ -0,0 +1,63 @@ +package com.minelittlepony.model.player; + +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.render.PonyRenderer; + +import net.minecraft.entity.Entity; + +public class ModelEarthPony extends AbstractPonyModel { + + private final boolean smallArms; + + public PonyRenderer bipedCape; + + public ModelEarthPony(boolean smallArms) { + super(smallArms); + this.smallArms = smallArms; + } + + @Override + 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; + } + } + + protected float getLegOutset() { + if (smallArms) { + if (isSleeping) return 2.6f; + if (isCrouching()) return 1; + return 4; + } + return super.getLegOutset(); + } + + protected int getArmWidth() { + return smallArms ? 3 : super.getArmWidth(); + } + + protected float getLegRotationX() { + return smallArms ? 2 : super.getLegRotationX(); + } + + protected float getArmRotationY() { + return smallArms ? 8.5f : super.getArmRotationY(); + } + + protected void initHeadTextures() { + super.initHeadTextures(); + bipedCape = new PonyRenderer(this, 0, 0).size(64, 32); + } + + protected void initHeadPositions(float yOffset, float stretch) { + super.initHeadPositions(yOffset, stretch); + bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); + } + + @Override + public void renderCape(float scale) { + bipedCape.render(scale); + } +} 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..8fdadfb0 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/ModelPegasus.java @@ -0,0 +1,82 @@ +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 ticks, float headYaw, float headPitch, float scale, Entity entity) { + checkRainboom(entity, swing); + + super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + + if (bipedCape != null) { + wings.setRotationAngles(move, swing, ticks); + } + } + + @Override + protected void rotateLegsInFlight(float move, float swing, float ticks, 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, ticks, entity); + } + } + + 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); + 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/player/PlayerModels.java b/src/main/java/com/minelittlepony/model/player/PlayerModels.java new file mode 100644 index 00000000..af91e7f7 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/player/PlayerModels.java @@ -0,0 +1,41 @@ +package com.minelittlepony.model.player; + +import com.minelittlepony.model.PMAPI; +import com.minelittlepony.model.ModelWrapper; + +public enum PlayerModels { + /** + * @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; + + 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 ModelWrapper getModel(boolean slim) { + return slim ? this.slim.resolve() : normal.resolve(); + } + + public String getId(boolean useSlimArms) { + return useSlimArms ? slimKey : normalKey; + } + + /** + * FIXME: PMAPI fields are null when the game starts. + */ + static interface ModelResolver { + ModelWrapper resolve(); + } +} 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 new file mode 100644 index 00000000..79619eff --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelBreezie.java @@ -0,0 +1,180 @@ +package com.minelittlepony.model.ponies; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; +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 { + + PonyRenderer neck; + PonyRenderer tail; + PonyRenderer tailStub; + + 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)); + + bipedBody = new PonyRenderer(this, 2, 12) + .addBox(0, 0, 0, 6, 7, 14).rotate(-0.5235988F, 0, 0).around(-3, 1, -3); + + 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); + + neck = new PonyRenderer(this, 40, 0) + .addBox(0, 0, 0, 2, 5, 2) + .rotate(0.0872665F, 0, 0).around(-1, -2, -4); + + tailStub = new PonyRenderer(this, 40, 7) + .addBox(0, 0, 0, 1, 1, 3).around(-0.5F, 8, 8); + + tail = new PonyRenderer(this, 32, 0) + .addBox(0, 0, 1, 2, 9, 2).around(-1, 7, 10); + + 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); + + 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); + + } + + @Override + 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); + leftWing.render(scale); + rightWing.render(scale); + } + + @SuppressWarnings("incomplete-switch") + @Override + 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; + + bipedLeftArm.rotateAngleX = MathHelper.cos(move * 0.6662F) * swing; + bipedLeftArm.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) { + bipedLeftArm.rotateAngleX += -PI / 5; + bipedRightArm.rotateAngleX += -PI / 5; + + rotateLegRiding(((PonyRenderer)bipedLeftLeg), -1); + rotateLegRiding(((PonyRenderer)bipedRightLeg), 1); + } + + rotateArm(bipedLeftArm, leftArmPose, 1); + rotateArm(bipedRightArm, rightArmPose, 1); + + if (swingProgress > 0) { + swingArms(getMainHand(entity)); + } + + 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; + + bipedRightArm.rotateAngleX += rotX; + bipedRightArm.rotateAngleZ += rotZ; + + if (rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { + raiseArm(bipedRightArm, bipedLeftArm, -1); + } else if (leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { + 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/model/ponies/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java new file mode 100644 index 00000000..14127339 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelIllagerPony.java @@ -0,0 +1,76 @@ +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.entity.monster.AbstractIllager.IllagerArmPose; +import net.minecraft.util.EnumHandSide; +import net.minecraft.util.math.MathHelper; + +public class ModelIllagerPony extends ModelAlicorn { + + public ModelIllagerPony() { + super(false); + } + + @Override + 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(); + + boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; + + 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); + bipedRightArm.rotateAngleZ = 0.0F; + bipedLeftArm.rotateAngleZ = 0.0F; + bipedRightArm.rotateAngleY = 0.15707964F; + bipedLeftArm.rotateAngleY = -0.15707964F; + + if (rightHanded) { + 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(ticks * 0.09F) * 0.15F; + bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F; + } + + 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(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(ticks * 0.6662F) / 4; + bipedLeftArm.rotateAngleY = -1.1F; + } + + } else if (pose == IllagerArmPose.BOW_AND_ARROW) { + if (rightHanded) { + aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, ticks); + } else { + aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, ticks); + } + } + } + + public ModelRenderer getArm(EnumHandSide 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 new file mode 100644 index 00000000..0e999a26 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelSkeletonPony.java @@ -0,0 +1,72 @@ +package com.minelittlepony.model.ponies; + +import com.minelittlepony.model.ModelMobPony; +import com.minelittlepony.model.armour.ModelSkeletonPonyArmor; +import com.minelittlepony.model.armour.PonyArmor; + +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 { + + @Override + public PonyArmor createArmour() { + 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; + leftArmPose = ArmPose.EMPTY; + ItemStack itemstack = entity.getHeldItem(EnumHand.MAIN_HAND); + + if (itemstack.getItem() == Items.BOW && ((AbstractSkeleton)entity).isSwingingArms()) + { + if (entity.getPrimaryHand() == EnumHandSide.RIGHT) { + rightArmPose = ArmPose.BOW_AND_ARROW; + } else { + leftArmPose = ArmPose.BOW_AND_ARROW; + } + } + + super.setLivingAnimations(entity, move, swing, ticks); + } + + @Override + protected void fixSpecialRotationPoints(float move) { + if (rightArmPose != ArmPose.EMPTY && !canCast()) { + bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4); + } + } + + protected float getLegOutset() { + if (isSleeping) return 2.6f; + if (isCrouching()) return 0; + return 4; + } + + protected int getArmWidth() { + return 2; + } + + protected int getArmDepth() { + return 2; + } + + protected float getLegRotationX() { + return 3; + } + + protected float getArmRotationY() { + return 8; + } +} 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..c3d303cd --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelVillagerPony.java @@ -0,0 +1,99 @@ +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.*; + +import com.minelittlepony.model.player.ModelAlicorn; +import com.minelittlepony.render.plane.PlaneRenderer; + +public class ModelVillagerPony extends ModelAlicorn { + + public PlaneRenderer bag, apron, trinket; + + public ModelVillagerPony() { + super(false); + } + + @Override + 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()) { + angleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F; + } + bag.rotateAngleY = angleY; + apron.rotateAngleY = angleY; + trinket.rotateAngleY = angleY; + } + + @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); + + int profession = getProfession(entity); + if (profession > -1) { + bipedBody.postRender(this.scale); + if (profession < 2) { + bag.render(scale); + } else if (profession == 2) { + trinket.render(scale); + } else if (profession > 2) { + apron.render(scale); + } + } + } + + 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(); + 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.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( 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) + .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/ModelWitchPony.java b/src/main/java/com/minelittlepony/model/ponies/ModelWitchPony.java new file mode 100644 index 00000000..e8daea9c --- /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(); + } + + @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, ticks, 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 ticks, float headYaw, float headPitch, float scale) { + super.render(entityIn, move, swing, ticks, 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.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); + } +} 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..6faecbe5 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/ModelZombiePony.java @@ -0,0 +1,37 @@ +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 { + + @Override + public PonyArmor createArmour() { + return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor()); + } + + @Override + 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, ticks); + } else { + rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); + } + } + + @Override + protected void fixSpecialRotationPoints(float move) { + if (rightArmPose != ArmPose.EMPTY) return; + + if (islookAngleRight(move)) { + AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + } else { + AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + } + } +} diff --git a/src/main/java/com/minelittlepony/model/ponies/package-info.java b/src/main/java/com/minelittlepony/model/ponies/package-info.java new file mode 100644 index 00000000..576187ce --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ponies/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.model.ponies; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java b/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java deleted file mode 100644 index 7ec7991e..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelBreezie.java +++ /dev/null @@ -1,199 +0,0 @@ -package com.minelittlepony.model.pony; - -import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.EnumHandSide; -import net.minecraft.util.math.MathHelper; - -public class ModelBreezie extends ModelBiped { - - ModelRenderer neck; - ModelRenderer tail; - ModelRenderer tailStub; - ModelRenderer leftWing; - ModelRenderer rightWing; - - public ModelBreezie() { - textureWidth = 64; - textureHeight = 64; - - this.bipedHeadwear.showModel = false; - - 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); - - 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); - - this.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); - - bipedRightArm = new ModelRenderer(this, 36, 12); - bipedRightArm.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(-3F, 8F, -5F); - - bipedLeftArm = new ModelRenderer(this, 28, 12); - bipedLeftArm.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(1F, 8F, -5F); - - bipedLeftLeg = new ModelRenderer(this, 8, 12); - bipedLeftLeg.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(1F, 12F, 3F); - - bipedRightLeg = new ModelRenderer(this, 0, 12); - bipedRightLeg.addBox(0F, 0F, 0F, 2, 12, 2).setRotationPoint(-3F, 12F, 3F); - - neck = new ModelRenderer(this, 40, 0); - neck.addBox(0F, 0F, 0F, 2, 5, 2).setRotationPoint(-1F, -2F, -4F); - setRotation(neck, 0.0872665F, 0F, 0F); - - tailStub = new ModelRenderer(this, 40, 7); - tailStub.addBox(0F, 0F, 0F, 1, 1, 3).setRotationPoint(-0.5F, 8F, 8F); - - tail = new ModelRenderer(this, 32, 0); - tail.addBox(0F, 0F, 1F, 2, 9, 2).setRotationPoint(-1F, 7F, 10F); - - leftWing = new ModelRenderer(this, 0, 40); - leftWing.addBox(0F, -12F, 0F, 24, 24, 0); - leftWing.setRotationPoint(2F, 3F, 1F); - leftWing.setTextureSize(64, 32); - setRotation(leftWing, 0F, -0.6981317F, 0F); - - rightWing = new ModelRenderer(this, 0, 40); - rightWing.addBox(-24F, -12F, 0F, 24, 24, 0, true); - rightWing.setRotationPoint(-2F, 3F, 1F); - rightWing.setTextureSize(64, 32); - setRotation(rightWing, 0F, 0.6981317F, 0F); - - } - - @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); - } - - 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 limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - - this.bipedHead.rotateAngleY = netHeadYaw * 0.017453292F; - this.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; - - 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; - } - - this.bipedRightArm.rotateAngleY = 0; - this.bipedRightArm.rotateAngleZ = 0F; - - switch (this.leftArmPose) { - case EMPTY: - this.bipedLeftArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedLeftArm.rotateAngleY = 0.5235988F; - break; - case ITEM: - this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - this.bipedLeftArm.rotateAngleY = 0.0F; - } - - switch (this.rightArmPose) { - case EMPTY: - this.bipedRightArm.rotateAngleY = 0.0F; - break; - case BLOCK: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.9424779F; - this.bipedRightArm.rotateAngleY = -0.5235988F; - break; - case ITEM: - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F); - this.bipedRightArm.rotateAngleY = 0.0F; - } - - 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 (enumhandside == EnumHandSide.LEFT) { - this.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; - //noinspection SuspiciousNameCombination - this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; - f1 = 1.0F - this.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; - 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; - } - - 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; - - 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; - } - - } - -} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java b/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java deleted file mode 100644 index 1087319c..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelHumanPlayer.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.minelittlepony.model.pony; - -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; - -public class ModelHumanPlayer extends AbstractPonyModel { - - public ModelHumanPlayer(boolean smallArms) { - super(smallArms); - } - - @Override - protected boolean doCancelRender() { - return true; - } - - @Override - public void transform(BodyPart part) { - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java deleted file mode 100644 index 067880c7..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelIllagerPony.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.minelittlepony.model.pony; - -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 ModelIllagerPony() { - super(false); - } - - @Override - public void setRotationAngles(float swing, float move, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { - - super.setRotationAngles(swing, move, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); - AbstractIllager illager = (AbstractIllager) entityIn; - 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; - - if (rightHanded) { - this.bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; - this.bipedRightArm.rotateAngleX += f * 2.2F - f1 * 0.4F; - } else { - this.bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F; - this.bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F; - } - - this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; - this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; - } else if (pose == AbstractIllager.IllagerArmPose.SPELLCASTING) { - if (this.metadata.hasMagic()) { - this.horn.setUsingMagic(true); - } - // waving arms! - if (rightHanded) { -// this.bipedRightArm.rotationPointZ = 0.0F; -// this.bipedRightArm.rotationPointX = -5.0F; - this.bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI); - this.bipedRightArm.rotateAngleZ = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F; - this.bipedRightArm.rotateAngleY = 1.1F; - } else { -// this.bipedLeftArm.rotationPointZ = 0.0F; -// this.bipedLeftArm.rotationPointX = 5.0F; - this.bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI); - this.bipedLeftArm.rotateAngleZ = -MathHelper.cos(ageInTicks * 0.6662F) * 0.25F; - this.bipedLeftArm.rotateAngleY = -1.1F; - } - - } else if (pose == AbstractIllager.IllagerArmPose.BOW_AND_ARROW) { - if (rightHanded) { - aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, ageInTicks); - } else { - aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, ageInTicks); - } - } - } - - public ModelRenderer getArm(EnumHandSide side) { - return metadata.hasMagic() ? side == EnumHandSide.LEFT ? this.unicornArmLeft : this.unicornArmRight : this.getArmForSide(side); - } -} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java deleted file mode 100644 index 12b9ad6b..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelPlayerPony.java +++ /dev/null @@ -1,940 +0,0 @@ -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.UnicornHorn; -import com.minelittlepony.renderer.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; - -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; - -public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConstants { - - private final boolean smallArms; - public boolean rainboom; - - public ModelRenderer bipedCape; - - public PlaneRenderer[] Bodypiece; - public PlaneRenderer[] BodypieceNeck; - public ModelRenderer unicornArmRight; - public ModelRenderer unicornArmLeft; - public PlaneRenderer[] Tail; - public PonySnout snout; - public UnicornHorn horn; - public PegasusWings wings; - - public ModelPlayerPony(boolean smallArms) { - super(smallArms); - this.smallArms = smallArms; - } - - 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 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.swingTailZ(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; - - int k1; - for (k1 = 0; k1 < this.Bodypiece.length; ++k1) { - 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.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); - 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); - this.sneakTail(); - } 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.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); - - for (PlaneRenderer aTail : Tail) { - aTail.rotationPointZ = 13; - aTail.rotationPointY = 3; - aTail.rotateAngleX = (float) (Math.PI * 0.2); - } - } 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); - - 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; - } - } - - if (!this.rainboom) { - this.swingTailX(ageInTicks); - } - } - - if (this.rainboom) { - - for (k1 = 0; k1 < tailstop; ++k1) { - this.Tail[k1].rotationPointY += 6.0F; - ++this.Tail[k1].rotationPointZ; - } - } - - if (this.isSleeping) { - this.ponySleep(); - } - - this.aimBow(leftArmPose, rightArmPose, ageInTicks); - - this.fixSpecialRotations(); - this.fixSpecialRotationPoints(limbSwing); - - animateWears(); - - 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); - } - - private void animateWears() { - copyModelAngles(bipedLeftArm, bipedLeftArmwear); - copyModelAngles(bipedRightArm, bipedRightArmwear); - copyModelAngles(bipedLeftLeg, bipedLeftLegwear); - copyModelAngles(bipedRightLeg, bipedRightLegwear); - copyModelAngles(bipedBody, bipedBodyWear); - } - - 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; - } - - protected void setHead(float posX, float posY, float posZ) { - setRotationPoint(this.bipedHead, posX, posY, posZ); - setRotationPoint(this.bipedHeadwear, 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; - } - - protected void setLegs(float move, float swing, float tick, Entity entity) { - this.rotateLegs(move, swing, tick, entity); - this.adjustLegs(); - } - - 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()) { - 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.steveRightArm.rotateAngleY = 0.2F; - this.bipedRightArm.rotateAngleY = 0.2F; - this.bipedLeftArm.rotateAngleY = -0.2F; - this.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; - - this.bipedRightArm.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.unicornArmLeft.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.unicornArmLeft.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - } - - 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; - } - - if (this.isSleeping) { - legOutset = 2.6F; - } - - 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; - - 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; - - 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; - } - - 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()) { - 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; - } - - } 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; - } - } - - this.horn.setUsingMagic(this.leftArmPose != ArmPose.EMPTY || this.rightArmPose != ArmPose.EMPTY); - } - - 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; - 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; - } 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; - } - } - - } - - protected void swingArms(float tick) { - - 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) { - this.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); - this.adjustNeck(rotateAngleX, rotationPointY, rotationPointZ); - } - - protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { - 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; - } - } - - 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; - } - - } - - 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.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; - - } - - 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; - this.bipedRightLeg.rotateAngleX = ROTATE_90; - this.bipedLeftLeg.rotateAngleX = ROTATE_90; - float headPosX; - float headPosY; - float headPosZ; - if (this.isSneak) { - headPosY = 2.0F; - headPosZ = -1.0F; - headPosX = 1.0F; - } else { - headPosY = 2.0F; - headPosZ = 1.0F; - headPosX = 1.0F; - } - - 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); - } - - protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { - if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { - - if (this.metadata.hasMagic()) { - this.aimBowUnicorn(tick); - } else { - this.aimBowPony(leftArm, rightArm, tick); - } - } - } - - 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 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; - } - - protected void fixSpecialRotationPoints(float move) { - } - - @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); - popMatrix(); - - pushMatrix(); - this.transform(BodyPart.NECK); - this.renderNeck(); - popMatrix(); - - pushMatrix(); - this.transform(BodyPart.BODY); - this.renderBody(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - this.renderTail(); - popMatrix(); - - pushMatrix(); - this.transform(BodyPart.LEGS); - this.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); - - } - - protected void renderNeck() { - GlStateManager.scale(0.9, 0.9, 0.9); - for (PlaneRenderer element : this.BodypieceNeck) { - element.render(this.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); - } - for (PlaneRenderer aBodypiece : this.Bodypiece) { - aBodypiece.render(this.scale); - } - 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() { - if (!this.isSneak) { - this.bipedBody.postRender(this.scale); - } - - this.bipedLeftArm.render(this.scale); - 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); - this.bipedLeftLegwear.render(this.scale); - this.bipedRightLegwear.render(this.scale); - } - } - - @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(); - } - - 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); - } - - 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[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); - - } - - protected void initLegTextures() { - this.bipedRightArm = new ModelRenderer(this, 40, 16); - this.bipedRightLeg = new ModelRenderer(this, 0, 16); - - this.bipedLeftArm = new ModelRenderer(this, 32, 48); - this.bipedLeftLeg = new ModelRenderer(this, 16, 48); - - this.bipedRightArmwear = new ModelRenderer(this, 40, 32); - this.bipedRightLegwear = new ModelRenderer(this, 0, 32); - - this.bipedLeftArmwear = new ModelRenderer(this, 48, 48); - this.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); - - this.boxList.remove(this.steveRightArm); - 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); - } - - 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); - } - - 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[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); - - 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; - } - - 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); - } - } - 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.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.unicornArmRight.setRotationPoint(-5.0F, 2.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); - } - - 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 - public void renderCape(float scale) { - this.bipedCape.render(scale); - } - -} diff --git a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java b/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java deleted file mode 100644 index 46341e18..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelSkeletonPony.java +++ /dev/null @@ -1,150 +0,0 @@ -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 { - - public ModelSkeletonPony() { - 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; - 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); - } - - @Override - protected void fixSpecialRotationPoints(float move) { - if (this.rightArmPose != ArmPose.EMPTY && !this.metadata.hasMagic()) { - setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F); - } - - } - - @Override - protected void renderLegs() { - pushMatrix(); - translate(0.05F, -0.21F, -0.0F); - scale(0.5F, 1.15F, 0.5F); - this.bipedLeftArm.render(this.scale); - popMatrix(); - - pushMatrix(); - translate(-0.05F, -0.21F, -0.0F); - scale(0.5F, 1.2F, 0.5F); - this.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); - popMatrix(); - - pushMatrix(); - translate(-0.05F, -0.21F, 0.35F); - scale(0.5F, 1.15F, 0.5F); - this.bipedRightLeg.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 deleted file mode 100644 index 079cb49b..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelVillagerPony.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.minelittlepony.model.pony; - -import com.minelittlepony.renderer.PlaneRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.util.math.MathHelper; - -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/ModelZombiePony.java b/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java deleted file mode 100644 index 098c7d99..00000000 --- a/src/main/java/com/minelittlepony/model/pony/ModelZombiePony.java +++ /dev/null @@ -1,101 +0,0 @@ -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 { - - public ModelZombiePony() { - 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; - // 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; - } 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 * (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 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/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/ModelPonyArmor.java b/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java deleted file mode 100644 index d5725c8e..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import com.minelittlepony.model.pony.ModelPlayerPony; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; - -public class ModelPonyArmor extends ModelPlayerPony { - - public ModelRenderer Bodypiece; - public ModelRenderer extBody; - public ModelRenderer[] extHead; - public ModelRenderer[] extLegs; - - public ModelPonyArmor() { - super(false); - 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); - - - } - - @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); - } - - @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; - } - - @Override - protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) { - 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; - } - - @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); - } - - @Override - protected void renderNeck() { - } - - @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); - } - - @Override - protected void renderTail() { - } - - @Override - protected void renderLegs() { - if (!isSneak) { - boolean isLegs = this.extBody.showModel; - this.extBody.showModel = true; - this.extBody.postRender(this.scale); - this.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); - } - - @Override - protected void initTextures() { - this.extHead = new ModelRenderer[2]; - this.extLegs = new ModelRenderer[2]; - this.initHeadTextures(); - this.initBodyTextures(); - this.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); - } - - @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); - } - - @Override - protected void initLegTextures() { - this.bipedRightArm = 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.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; - } - - @Override - protected void initPositions(float yOffset, float stretch) { - this.initHeadPositions(yOffset, stretch); - this.initBodyPositions(yOffset, stretch); - this.initLegPositions(yOffset, 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.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); - 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); - } - - @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); - } - - @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[1].setRotationPoint(3.0F, 0.0F + yOffset, 0.0F); - } - - 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; - } - - @Override - protected void rotateLegs(float move, float swing, float tick, Entity entity) { - super.rotateLegs(move, swing, tick, entity); - this.syncLegs(); - } - - @Override - protected void adjustLegs() { - super.adjustLegs(); - this.syncLegs(); - } - - @Override - protected void sneakLegs() { - super.sneakLegs(); - this.syncLegs(); - } - - @Override - protected void ponySleep() { - super.ponySleep(); - this.syncLegs(); - } - - public void setVisible(boolean invisible) { - super.setVisible(invisible); - this.Bodypiece.showModel = invisible; - extBody.showModel = invisible; - for (ModelRenderer m : extHead) { - m.showModel = invisible; - } - for (ModelRenderer m : extLegs) { - m.showModel = invisible; - } - } -} 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 7383fbdf..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; - -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()) { - setRotationPoint(this.bipedRightArm, -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 b63c54c5..00000000 --- a/src/main/java/com/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.minelittlepony.model.pony.armor; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; - -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/pony/data/IPonyData.java b/src/main/java/com/minelittlepony/pony/data/IPonyData.java new file mode 100644 index 00000000..74756255 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/IPonyData.java @@ -0,0 +1,38 @@ +package com.minelittlepony.pony.data; + +import net.minecraft.client.resources.data.IMetadataSection; + +/** + * 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 new file mode 100644 index 00000000..3a967aa8 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/ITriggerPixelMapped.java @@ -0,0 +1,29 @@ +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()) { + if (i.getTriggerPixel() == pixelValue) return i; + } + return type; + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java new file mode 100644 index 00000000..270e3d1e --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -0,0 +1,129 @@ +package com.minelittlepony.pony.data; + +import com.google.common.base.MoreObjects; +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.mixin.MixinThreadDownloadImageData; +import com.minelittlepony.model.ModelWrapper; +import com.voxelmodpack.hdskins.DynamicTextureImage; +import com.voxelmodpack.hdskins.ThreadDownloadImageETag; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.ITextureObject; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.resources.IResource; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; + +import java.awt.image.BufferedImage; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; + +@Immutable +public class Pony { + + private static final AtomicInteger ponyCount = new AtomicInteger(); + + private final int ponyId = ponyCount.getAndIncrement(); + + private final ResourceLocation texture; + private final IPonyData metadata; + + private final boolean smallArms; + + public Pony(ResourceLocation resource, boolean slim) { + texture = resource; + metadata = checkSkin(texture); + smallArms = slim; + } + + private IPonyData checkSkin(ResourceLocation resource) { + IPonyData data = checkPonyMeta(resource); + if (data != null) return data; + + BufferedImage skinImage = getBufferedImage(resource); + return this.checkSkin(skinImage); + } + + @Nullable + private IPonyData checkPonyMeta(ResourceLocation resource) { + try { + IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); + if (res.hasMetadata()) { + PonyData data = res.getMetadata(PonyDataSerialzier.NAME); + if (data != null) { + return data; + } + } + } catch (FileNotFoundException e) { + // Ignore uploaded texture + } catch (IOException e) { + MineLittlePony.logger.warn("Unable to read {} metadata", resource, e); + } + return null; + } + + @Nullable + private BufferedImage getBufferedImage(@Nonnull ResourceLocation resource) { + try { + IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(resource); + BufferedImage skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); + MineLittlePony.logger.debug("Obtained skin from resource location {}", resource); + + return skinImage; + } catch (IOException ignored) { } + + try { + ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resource); + + 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) { } + + return null; + } + + private IPonyData checkSkin(BufferedImage bufferedimage) { + if (bufferedimage == null) return new PonyData(); + MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage); + return PonyData.parse(bufferedimage); + } + + public boolean isPegasusFlying(EntityPlayer player) { + //noinspection SimplifiableIfStatement + if (!getRace(false).hasWings()) return false; + + return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater() || player.isElytraFlying()); + } + + public ModelWrapper getModel(boolean ignorePony) { + return getRace(ignorePony).getModel().getModel(smallArms); + } + + public PonyRace getRace(boolean ignorePony) { + return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getEffectivePonyLevel(ignorePony)); + } + + public ResourceLocation getTexture() { + return texture; + } + + public IPonyData getMetadata() { + return metadata; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("texture", texture) + .add("metadata", metadata) + .toString(); + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/PonyData.java b/src/main/java/com/minelittlepony/pony/data/PonyData.java new file mode 100644 index 00000000..8d5f6152 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/PonyData.java @@ -0,0 +1,85 @@ +package com.minelittlepony.pony.data; + +import com.google.common.base.MoreObjects; +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; + private final TailLengths tailSize; + private final PonyGender gender; + private final PonySize size; + private final int glowColor; + + public PonyData() { + race = PonyRace.HUMAN; + tailSize = TailLengths.FULL; + gender = PonyGender.MARE; + size = PonySize.NORMAL; + glowColor = 0x4444aa; + } + + private PonyData(BufferedImage image) { + 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 + 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 race != null && race.hasHorn() && glowColor != 0; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("race", race) + .add("tailSize", tailSize) + .add("gender", gender) + .add("size", size) + .add("glowColor", "#" + Integer.toHexString(glowColor)) + .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/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/pony/data/PonyGender.java b/src/main/java/com/minelittlepony/pony/data/PonyGender.java new file mode 100644 index 00000000..4ef71a31 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/PonyGender.java @@ -0,0 +1,17 @@ +package com.minelittlepony.pony.data; + +public enum PonyGender implements ITriggerPixelMapped { + MARE(0), + STALLION(0xffffff); + + private int triggerValue; + + PonyGender(int pixel) { + triggerValue = pixel; + } + + @Override + public int getTriggerPixel() { + return triggerValue; + } +} 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..9297fc15 100644 --- a/src/main/java/com/minelittlepony/PonyLevel.java +++ b/src/main/java/com/minelittlepony/pony/data/PonyLevel.java @@ -1,7 +1,6 @@ -package com.minelittlepony; +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 new file mode 100644 index 00000000..508f8707 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/PonyRace.java @@ -0,0 +1,77 @@ +package com.minelittlepony.pony.data; + +import com.minelittlepony.model.player.PlayerModels; + +public enum PonyRace implements ITriggerPixelMapped { + + HUMAN(0, PlayerModels.HUMAN, false, 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; + + 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; + } + + /** + * 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; + } + + @Override + public int getTriggerPixel() { + return triggerPixel; + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/PonySize.java b/src/main/java/com/minelittlepony/pony/data/PonySize.java new file mode 100644 index 00000000..587d6709 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/PonySize.java @@ -0,0 +1,32 @@ +package com.minelittlepony.pony.data; + +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; + private float scale; + + PonySize(int pixel, float shadowSz, float scaleF) { + triggerValue = pixel; + shadowSize = shadowSz; + scale = scaleF; + } + + public float getShadowSize() { + return shadowSize; + } + + public float getScaleFactor() { + return scale; + } + + @Override + public int getTriggerPixel() { + return triggerValue; + } +} diff --git a/src/main/java/com/minelittlepony/pony/data/TailLengths.java b/src/main/java/com/minelittlepony/pony/data/TailLengths.java new file mode 100644 index 00000000..4e71f467 --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/TailLengths.java @@ -0,0 +1,21 @@ +package com.minelittlepony.pony.data; + +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/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java new file mode 100644 index 00000000..15d403bf --- /dev/null +++ b/src/main/java/com/minelittlepony/pony/data/TriggerPixels.java @@ -0,0 +1,46 @@ +package com.minelittlepony.pony.data; + +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), + GENDER(PonyGender.MARE, 2, 0), + SIZE(PonySize.NORMAL, 3, 0), + GLOW(null, 0, 1); + + 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 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) + */ + 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 + */ + public & ITriggerPixelMapped> T readValue(BufferedImage image) { + return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff)); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/gui/package-info.java b/src/main/java/com/minelittlepony/pony/data/package-info.java similarity index 80% rename from src/main/java/com/minelittlepony/gui/package-info.java rename to src/main/java/com/minelittlepony/pony/data/package-info.java index 4f7db50d..31822866 100644 --- a/src/main/java/com/minelittlepony/gui/package-info.java +++ b/src/main/java/com/minelittlepony/pony/data/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.gui; +package com.minelittlepony.pony.data; import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java new file mode 100644 index 00000000..6be6717a --- /dev/null +++ b/src/main/java/com/minelittlepony/render/AbstractPonyRenderer.java @@ -0,0 +1,201 @@ +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 abstract class AbstractPonyRenderer> extends ModelRenderer { + + protected final ModelBase baseModel; + + protected int textureOffsetX; + protected int textureOffsetY; + + protected float modelOffsetX; + protected float modelOffsetY; + protected float modelOffsetZ; + + public AbstractPonyRenderer(ModelBase model) { + super(model); + baseModel = model; + } + + public AbstractPonyRenderer(ModelBase model, int texX, int texY) { + super(model, texX, texY); + 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) { + this.textureOffsetX = x; + this.textureOffsetY = y; + super.setTextureOffset(x, y); + return (T) this; + } + + /** + * Flips the mirror flag. All faces are mirrored until this is called again. + */ + public T flipX() { + 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; + } + + /** + * 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. + */ + public T rotate(float x, float y, float z) { + rotateAngleX = x; + rotateAngleY = y; + rotateAngleZ = z; + 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; + renderer.offsetZ = z / 16; + 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); + } + + /** + * 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()) { + T copy = copySelf(); + child(copy.offset(modelOffsetX, modelOffsetY, modelOffsetZ)); + copy.textureHeight = textureHeight; + copy.textureWidth = textureWidth; + } + 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; + + TextureOffset tex = 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; + } + + @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 new file mode 100644 index 00000000..e5f2d558 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/HornGlow.java @@ -0,0 +1,76 @@ +package com.minelittlepony.render; + +import net.minecraft.client.renderer.BufferBuilder; + +import com.minelittlepony.util.coordinates.*; + +/** + * Like a normal box, but with the top narrowed a bit. + */ +public class HornGlow extends Box { + + private final float alpha; + + private Quad[] 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); + + this.alpha = alpha; + + float xMax = xMin + w + scale; + float yMax = yMin + h + scale; + float zMax = zMin + d + scale; + + xMin -= scale; + yMin -= scale; + zMin -= scale; + + if (renderer.mirror) { + float v = xMax; + xMax = xMin; + xMin = v; + } + + float tipInset = 0.4f; + + float tipXmin = xMin + w * tipInset; + float tipZmin = zMin + d * tipInset; + float tipXMax = xMax - w * tipInset; + float tipZMax = zMax - d * tipInset; + + // 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); + + 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(BufferBuilder buffer, float scale) { + parent.applyTint(alpha); + + for (Quad 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 new file mode 100644 index 00000000..d7a03c04 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/HornGlowRenderer.java @@ -0,0 +1,49 @@ +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 { + + int tint; + float alpha = 1; + + public HornGlowRenderer(ModelBase model, int x, int y) { + super(model, x, y); + } + + public HornGlowRenderer setAlpha(float alpha) { + this.alpha = alpha; + + return this; + } + + public HornGlowRenderer setTint(int tint) { + this.tint = tint; + + return this; + } + + public void applyTint(float alpha) { + Color.glColor(tint, 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, alpha)); + } + + @Override + public void render(float scale) { + 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/PonyRenderer.java b/src/main/java/com/minelittlepony/render/PonyRenderer.java new file mode 100644 index 00000000..c2031230 --- /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 AbstractPonyRenderer { + + public PonyRenderer(ModelBase model) { + super(model); + } + + public PonyRenderer(ModelBase model, int texX, int texY) { + super(model, texX, texY); + } + + @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 new file mode 100644 index 00000000..9223fac5 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -0,0 +1,87 @@ +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; +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; + +import javax.annotation.Nonnull; +import javax.annotation.OverridingMethodsMustInvokeSuper; + +public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { + + protected ModelWrapper playerModel; + + public RenderPonyMob(RenderManager manager, ModelWrapper model) { + super(manager, model.getModel(), 0.5F); + playerModel = model; + + addLayers(); + } + + protected void addLayers() { + addLayer(new LayerPonyArmor<>(this)); + addLayer(new LayerArrow(this)); + addLayer(new LayerPonyCustomHead<>(this)); + addLayer(new LayerPonyElytra<>(this)); + addLayer(createItemHoldingLayer()); + } + + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical<>(this); + } + + @Override + public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { + if (entity.isSneaking()) { + yPosition -= 0.125D; + } + super.doRender(entity, xPosition, yPosition, zPosition, yaw, ticks); + } + + @Override + @OverridingMethodsMustInvokeSuper + protected void preRenderCallback(T entity, float ticks) { + playerModel.getModel().isSneak = entity.isSneaking(); + playerModel.getModel().isFlying = !entity.onGround; + playerModel.getModel().isSleeping = false; + + ResourceLocation loc = getEntityTexture(entity); + playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata()); + + shadowSize = getShadowScale(); + } + + @Override + public float getShadowScale() { + if (mainModel.isChild) { + return 0.25F; + } else if (MineLittlePony.getConfig().showscale) { + return 0.4F; + } + return 0.5F; + } + + @Override + public ModelWrapper getPlayerModel() { + return playerModel; + } + + @Override + @Nonnull + protected final ResourceLocation getEntityTexture(T entity) { + return HDSkinManager.INSTANCE.getConvertedSkin(getTexture(entity)); + } + + protected abstract ResourceLocation getTexture(T entity); +} diff --git a/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java new file mode 100644 index 00000000..b895aace --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/AbstractPonyLayer.java @@ -0,0 +1,63 @@ +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; +import net.minecraft.client.renderer.entity.layers.LayerRenderer; +import net.minecraft.entity.EntityLivingBase; + +public abstract class AbstractPonyLayer implements LayerRenderer { + + private final RenderLivingBase renderer; + + public AbstractPonyLayer(RenderLivingBase renderer) { + this.renderer = renderer; + } + + @SuppressWarnings("unchecked") + @Override + 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, partialTicks, ticks, headYaw, headPitch, 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; + } + + public AbstractPonyModel getPlayerModel() { + return ((IRenderPony) getRenderer()).getPlayerModel().getModel(); + } + + @SuppressWarnings("unchecked") + public M getPonyModel() { + return (M)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 new file mode 100644 index 00000000..6a93a2c9 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerEntityOnPonyShoulder.java @@ -0,0 +1,84 @@ +package com.minelittlepony.render.layer; + +import com.minelittlepony.model.BodyPart; + +import net.minecraft.client.entity.AbstractClientPlayer; +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.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; + +import javax.annotation.Nullable; + +/** + * TODO: Looks like {@link LayerEntityOnShoulder} + */ +public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { + + private final RenderManager renderManager; + + private EntityLivingBase leftEntity; + private EntityLivingBase rightEntity; + + public LayerEntityOnPonyShoulder(RenderManager manager, RenderLivingBase renderer) { + super(renderer); + renderManager = manager; + } + + @Override + public void doPonyRender(AbstractClientPlayer player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { + + GlStateManager.enableRescaleNormal(); + GlStateManager.color(1, 1, 1, 1); + + NBTTagCompound leftTag = player.getLeftShoulderEntity(); + + if (!leftTag.hasNoTags()) { + leftEntity = renderShoulderEntity(player, leftEntity, leftTag, partialTicks, true); + } + + NBTTagCompound rightTag = player.getRightShoulderEntity(); + + if (!rightTag.hasNoTags()) { + rightEntity = renderShoulderEntity(player, rightEntity, rightTag, partialTicks, false); + } + + GlStateManager.disableRescaleNormal(); + } + + @Nullable + private EntityLivingBase renderShoulderEntity(AbstractClientPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound shoulderTag, float partialTicks, boolean left) { + + if (entity == null || !entity.getUniqueID().equals(shoulderTag.getUniqueId("UUID"))) { + entity = (EntityLivingBase) EntityList.createEntityFromNBT(shoulderTag, player.world); + // this isn't an entity. + if (entity == null) { + return null; + } + } + + Render render = renderManager.getEntityRenderObject(entity); + + if (render == null) { + return entity; + } + + GlStateManager.pushMatrix(); + + getPonyModel().transform(BodyPart.BODY); + + // render on the haunches + GlStateManager.translate(left ? 0.25F : -0.25F, 0.25F, 0.35F); + GlStateManager.scale(1, -1, -1); + GlStateManager.rotate(left ? -5 : 5, 0, 0, 1); + + 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 new file mode 100644 index 00000000..c301e574 --- /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 partialTicks, float ticks, float headYaw, float headPitch, float scale) { + if (shouldRender(entity)) { + super.doPonyRender(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale); + } + } + + @Override + protected void renderArm(EnumHandSide side) { + ((ModelIllagerPony)getPonyModel()).getArm(side).postRender(0.0625F); + } + + public boolean shouldRender(T entity) { + return entity.getArmPose() != IllagerArmPose.CROSSED; + } +} diff --git a/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java new file mode 100644 index 00000000..4203dfae --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItem.java @@ -0,0 +1,92 @@ +package com.minelittlepony.render.layer; + +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.BodyPart; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; +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.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHandSide; +import static net.minecraft.client.renderer.GlStateManager.*; + +public class LayerHeldPonyItem extends AbstractPonyLayer { + + public LayerHeldPonyItem(RenderLivingBase livingPony) { + super(livingPony); + } + + @Override + 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; + + ItemStack itemMain = entity.getHeldItemMainhand(); + ItemStack itemOff = entity.getHeldItemOffhand(); + + ItemStack left = mainRight ? itemOff : itemMain; + ItemStack right = mainRight ? itemMain : itemOff; + + if (!left.isEmpty() || !right.isEmpty()) { + ModelBase model = getRenderer().getMainModel(); + + pushMatrix(); + if (model instanceof AbstractPonyModel) { + ((AbstractPonyModel) model).transform(BodyPart.LEGS); + } + + if (model.isChild) { + translate(0, 0.625, 0); + rotate(-20, -1, 0, 0); + scale(.5, .5, .5); + } + + renderHeldItem(entity, right, TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); + renderHeldItem(entity, left, TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); + + popMatrix(); + } + } + + private void renderHeldItem(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + if (!drop.isEmpty()) { + GlStateManager.pushMatrix(); + renderArm(hand); + + if (entity.isSneaking()) { + GlStateManager.translate(0, 0.2F, 0); + } + + GlStateManager.rotate(-90, 1, 0, 0); + GlStateManager.rotate(180, 0, 1, 0); + + preItemRender(entity, drop, transform, hand); + Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, hand == EnumHandSide.LEFT); + postItemRender(entity, drop, transform, hand); + + GlStateManager.popMatrix(); + } + } + + 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 renderArm(EnumHandSide side) { + ((ModelBiped) getRenderer().getMainModel()).postRenderArm(0.0625F, side); + } + + @Override + public boolean shouldCombineTextures() { + return false; + } +} 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..8a83e6d6 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerHeldPonyItemMagical.java @@ -0,0 +1,94 @@ +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 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.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.util.EnumHandSide; + +public class LayerHeldPonyItemMagical extends LayerHeldPonyItem { + + public LayerHeldPonyItemMagical(RenderLivingBase livingPony) { + super(livingPony); + } + + protected boolean isUnicorn() { + 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); + } else { + super.preItemRender(entity, drop, transform, hand); + } + } + + @Override + protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + if (isUnicorn()) { + renderItemGlow(entity, drop, transform, hand, this.getPonyModel().getMagicColor()); + } + } + + @Override + protected void renderArm(EnumHandSide side) { + if (isUnicorn()) { + this.getPonyModel().getUnicornArmForSide(side).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 + drop = stackWithoutEnchantment(drop); + + pushMatrix(); + disableLighting(); + + GL14.glBlendColor(Color.r(glowColor), Color.g(glowColor), Color.b(glowColor), 0.2F); + + RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); + ((IRenderItem) renderItem).useTransparency(true); + + scale(1.1, 1.1, 1.1); + + translate(0, 0.01F, 0.01F); + renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); + translate(0.01F, -0.01F, -0.02F); + renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); + + ((IRenderItem) renderItem).useTransparency(false); + enableLighting(); + popMatrix(); + + // I hate rendering + } + + private ItemStack stackWithoutEnchantment(ItemStack original) { + if (original.isItemEnchanted()) { + original = original.copy(); + original.getTagCompound().removeTag("ench"); + } + return original; + } +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerOverlayBase.java b/src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java similarity index 52% rename from src/main/java/com/minelittlepony/renderer/layer/LayerOverlayBase.java rename to src/main/java/com/minelittlepony/render/layer/LayerOverlayBase.java index ec9422d6..779f8f0d 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; @@ -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,17 @@ 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); + @Override + 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, partialTicks); + overlayModel.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + + renderer.bindTexture(getOverlayTexture()); + + overlayModel.render(entity, move, swing, ticks, headYaw, headPitch, scale); } protected abstract ModelBase getOverlayModel(); diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java similarity index 56% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java index e038930e..8ae87f37 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyArmor.java @@ -1,20 +1,21 @@ -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 com.minelittlepony.util.coordinates.Color; + 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; @@ -22,73 +23,68 @@ 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; -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"); 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)); + public LayerPonyArmor(RenderLivingBase renderer) { + super(renderer); } @Override - public void doPonyRender(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - pony = ((IRenderPony) getRenderer()).getPony(); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.FEET); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.LEGS); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.CHEST); - renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.HEAD); + 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, partialTicks, ticks, 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(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) { ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); - AbstractPonyModel modelbase; - if (armorSlot == EntityEquipmentSlot.LEGS) { - modelbase = pony.getArmor().modelArmor; - } else { - modelbase = pony.getArmor().modelArmorChestplate; - } + AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot); 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, ticks, 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); + Color.glColor(itemarmor.getColor(itemstack), 1); + modelbase.render(entity, move, swing, ticks, 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, ticks, headYaw, headPitch, scale); if (itemstack.isItemEnchanted()) { - this.renderEnchantment(entity, modelbase, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + renderEnchantment(entity, modelbase, move, swing, partialTicks, ticks, headYaw, headPitch, scale); } } } - 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"; @@ -133,9 +129,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.leftLegging.showModel = isPony; + model.rightLegging.showModel = isPony; break; // legs case LEGS: @@ -144,58 +139,62 @@ 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; - for (ModelRenderer extLeg : model.extLegs) { - extLeg.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; - for (ModelRenderer head : model.extHead) { - head.showModel = isPony; - } + model.helmet.showModel = isPony; } } - private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_, float p_177183_4_, float p_177183_5_, - float p_177183_6_, float p_177183_7_, float p_177183_8_, float p_177183_9_) { - float f7 = entitylivingbaseIn.ticksExisted + p_177183_5_; - this.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(T entity, ModelBase model, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { + getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); - for (int i = 0; i < 2; ++i) { + GlStateManager.enableBlend(); + GlStateManager.depthFunc(GL11.GL_EQUAL); + GlStateManager.depthMask(false); + + float brightness = 0.5F; + GlStateManager.color(brightness, brightness, brightness, 1); + + float baseYOffset = entity.ticksExisted + partialTicks; + 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); - modelbaseIn.render(entitylivingbaseIn, 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, ticks, 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(); } @@ -209,8 +208,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 new file mode 100644 index 00000000..88161fc6 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCape.java @@ -0,0 +1,77 @@ +package com.minelittlepony.render.layer; + +import com.minelittlepony.ducks.IRenderPony; +import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.ModelWrapper; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +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 { + + public LayerPonyCape(RenderLivingBase entity) { + super(entity); + } + + @Override + 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() + && 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 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); + + float motionYaw = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * scale; + + double sin = MathHelper.sin(motionYaw * PI / 180); + double cos = (-MathHelper.cos(motionYaw * PI / 180)); + + float capeMotionY = (float) capeY * 10; + + if (capeMotionY < -6) capeMotionY = -6; + if (capeMotionY > 32) capeMotionY = 32; + + 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); + getRenderer().bindTexture(player.getLocationCape()); + model.getModel().renderCape(0.0625F); + popMatrix(); + } + } + + @Override + public boolean shouldCombineTextures() { + return false; + } + +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java similarity index 66% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index 73cf1829..a0174ce7 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -1,10 +1,9 @@ -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.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; @@ -26,65 +25,70 @@ 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) { - this.renderer = renderPony; + public LayerPonyCustomHead(RenderLivingBase 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(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(); 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, .2, 0); + + if (model instanceof AbstractPonyModel) { + translate(0, 0.2F, 0); } else { - translate(0, 0, .15); + 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(); } } - private void renderBlock(EntityLivingBase entity, ItemStack itemstack) { + private void renderBlock(T 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,12 +97,13 @@ public class LayerPonyCustomHead implements LayerRenderer { } } - TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.45F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), profile, -1, limbSwing); + // TODO: PonySkullRenderer + TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing); } - private PlayerModel getModel() { - return ((IRenderPony) renderer).getPony(); + private ModelWrapper getModel() { + return ((IRenderPony) renderer).getPlayerModel(); } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java new file mode 100644 index 00000000..0c3c9ec8 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyElytra.java @@ -0,0 +1,78 @@ +package com.minelittlepony.render.layer; + +import com.minelittlepony.model.BodyPart; +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; +import net.minecraft.client.renderer.entity.layers.LayerArmorBase; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nonnull; + +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) { + super(rp); + } + + @Override + 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) { + GlStateManager.color(1, 1, 1, 1); + + getRenderer().bindTexture(getElytraTexture(entity)); + + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0.25F, 0.125F); + getPlayerModel().transform(BodyPart.BODY); + 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, partialTicks, ticks, yaw, head, scale); + } + + GlStateManager.popMatrix(); + } + } + + 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; + } + +} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java similarity index 54% rename from src/main/java/com/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java rename to src/main/java/com/minelittlepony/render/layer/LayerPonyStrayOverlay.java index afc39a40..b58d5213 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; @@ -10,22 +11,16 @@ 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); - this.overlayModel = new ModelSkeletonPony(); - this.overlayModel.init(0F, 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); + overlayModel.init(0, 0.25F); } @Override protected ModelBase getOverlayModel() { - return this.overlayModel; + return overlayModel; } @Override diff --git a/src/main/java/com/minelittlepony/render/layer/package-info.java b/src/main/java/com/minelittlepony/render/layer/package-info.java new file mode 100644 index 00000000..d6daad76 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/layer/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.minelittlepony.render.layer; + +import mcp.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/package-info.java b/src/main/java/com/minelittlepony/render/package-info.java similarity index 82% rename from src/main/java/com/minelittlepony/util/package-info.java rename to src/main/java/com/minelittlepony/render/package-info.java index 5463a5b9..4e9d38ab 100644 --- a/src/main/java/com/minelittlepony/util/package-info.java +++ b/src/main/java/com/minelittlepony/render/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.util; +package com.minelittlepony.render; import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/render/plane/Face.java b/src/main/java/com/minelittlepony/render/plane/Face.java new file mode 100644 index 00000000..199e9c0e --- /dev/null +++ b/src/main/java/com/minelittlepony/render/plane/Face.java @@ -0,0 +1,7 @@ +package com.minelittlepony.render.plane; + +enum Face { + NORTH, SOUTH, + UP, DOWN, + 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 new file mode 100644 index 00000000..ebf41c03 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/plane/ModelPlane.java @@ -0,0 +1,82 @@ +package com.minelittlepony.render.plane; + +import net.minecraft.client.renderer.BufferBuilder; + +import javax.annotation.Nonnull; + +import com.minelittlepony.util.coordinates.*; + +public class ModelPlane extends Box { + + private Quad quad; + + public boolean hidden = 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 xMax = xMin + w + scale; + float yMax = yMin + h + scale; + float zMax = zMin + d + scale; + + xMin -= scale; + yMin -= scale; + zMin -= scale; + + if (renderer.mirror) { + float v = xMax; + xMax = xMin; + xMin = v; + } + + if (renderer.mirrory) { + float v = yMax; + yMax = yMin; + yMin = v; + } + + if (renderer.mirrorz) { + float v = zMax; + zMax = zMin; + zMin = v; + } + + // 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 eun = vert(xMax, yMax, zMax, 8, 8); + Vertex wun = vert(xMin, yMax, zMax, 8, 0); + + if (face == Face.EAST) { + quad = quad(textureX, d, textureY, h, edn, eds, eus, eun); + } + if (face == Face.WEST) { + quad = quad(textureX, d, textureY, h, wds, wdn, wun, wus); + } + if (face == Face.UP) { + quad = quad(textureX, w, textureY, d, edn, wdn, wds, eds); + } + if (face == Face.DOWN) { + quad = quad(textureX, w, textureY, d, eus, wus, wun, eun); + } + if (face == Face.SOUTH) { + quad = quad(textureX, w, textureY, h, eds, wds, wus, eus); + } + if (face == Face.NORTH) { + quad = quad(textureX, w, textureY, h, wdn, edn, eun, wun); + } + + if (renderer.mirror || renderer.mirrory || renderer.mirrorz) { + quad.flipFace(); + } + } + + @Override + public void render(@Nonnull BufferBuilder renderer, float scale) { + if (!hidden) quad.draw(renderer, scale); + } +} diff --git a/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java new file mode 100644 index 00000000..d1076f90 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/plane/PlaneRenderer.java @@ -0,0 +1,69 @@ +package com.minelittlepony.render.plane; + +import com.minelittlepony.render.AbstractPonyRenderer; + +import net.minecraft.client.model.ModelBase; + +public class PlaneRenderer extends AbstractPonyRenderer { + + public boolean mirrory, mirrorz; + + public PlaneRenderer(ModelBase model) { + super(model); + } + + public PlaneRenderer(ModelBase model, int x, int y) { + super(model, x, y); + } + + /** + * 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; + } + + + /** + * 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; + } + + @Override + protected PlaneRenderer copySelf() { + return new PlaneRenderer(baseModel, textureOffsetX, textureOffsetY); + } + + 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 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 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 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); + } +} 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/RenderPonyBase.java b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java new file mode 100644 index 00000000..8bd4c822 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyBase.java @@ -0,0 +1,143 @@ +package com.minelittlepony.render.player; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.ducks.IRenderPony; +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.ModelWrapper; +import com.minelittlepony.pony.data.Pony; +import com.minelittlepony.render.layer.LayerEntityOnPonyShoulder; +import com.minelittlepony.render.layer.LayerHeldPonyItemMagical; +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; +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 { + + private ModelWrapper playerModel; + + protected AbstractPonyModel ponyModel; + + private Pony pony; + + public RenderPonyBase(RenderManager manager, boolean useSmallArms, ModelWrapper model) { + super(manager, useSmallArms); + + setPlayerModel(model); + + layerRenderers.clear(); + addExtraLayers(); + } + + protected void addExtraLayers() { + addLayer(new LayerPonyArmor<>(this)); + addLayer(new LayerHeldPonyItemMagical<>(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 ticks) { + updateModel(player); + + ponyModel.isSneak = player.isSneaking(); + ponyModel.isSleeping = player.isPlayerSleeping(); + ponyModel.isFlying = pony.isPegasusFlying(player); + + shadowSize = getShadowScale(); + + super.doRender(player, x, y, z, entityYaw, ticks); + } + + @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()) { + transformElytraFlight(player, motionX, motionY, motionZ, ticks); + return; + } + + if (player.isEntityAlive() && player.isPlayerSleeping()) return; + + if (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; + } + + @Override + public ResourceLocation getEntityTexture(AbstractClientPlayer player) { + updateModel(player); + return pony.getTexture(); + } + + @Override + public ModelWrapper getPlayerModel() { + return playerModel; + } + + protected void setPlayerModel(ModelWrapper 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 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 new file mode 100644 index 00000000..5b0468c0 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -0,0 +1,68 @@ +package com.minelittlepony.render.player; + +import com.minelittlepony.MineLittlePony; +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 { + + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, ModelWrapper model) { + super(renderManager, useSmallArms, model); + } + + @Override + public float getShadowScale() { + if (!MineLittlePony.getConfig().showscale) return .5f; + return getPony().getMetadata().getSize().getShadowSize(); + } + + @Override + protected float getScaleFactor() { + return getPony().getMetadata().getSize().getScaleFactor(); + } + + @Override + protected void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks) { + GlStateManager.rotate(90, 1, 0, 0); + GlStateManager.translate(0, player.isSneaking() ? 0.2F : -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; + } + } + + 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(); + + double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ); + double horLook = Math.sqrt(lookDirection.x * lookDirection.x + lookDirection.z * lookDirection.z); + + 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); + } + } + + //TODO: MC1.13 transformSwimming() +} 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/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/renderer/RenderPonyPigman.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyPigman.java similarity index 74% rename from src/main/java/com/minelittlepony/renderer/RenderPonyPigman.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyPigman.java index 6d9a45b0..4323e32a 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; @@ -9,8 +11,8 @@ public class RenderPonyPigman 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/renderer/RenderPonySkeleton.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java similarity index 77% rename from src/main/java/com/minelittlepony/renderer/RenderPonySkeleton.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonySkeleton.java index 5646f897..9e9e5968 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; @@ -16,18 +18,18 @@ 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 protected void addLayers() { super.addLayers(); - this.addLayer(new LayerBipedArmor(this) { + addLayer(new LayerBipedArmor(this) { @Override protected void initArmor() { - this.modelLeggings = getPony().getArmor().modelArmor; - this.modelArmor = getPony().getArmor().modelArmorChestplate; + modelLeggings = getPlayerModel().getArmor().leggings; + modelArmor = getPlayerModel().getArmor().chestplate; } }); } @@ -41,7 +43,7 @@ public class RenderPonySkeleton extends Rende public Stray(RenderManager rm) { super(rm); - this.addLayer(new LayerPonyStrayOverlay(this)); + addLayer(new LayerPonyStrayOverlay(this)); } @Override @@ -62,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/renderer/RenderPonyVex.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java similarity index 74% rename from src/main/java/com/minelittlepony/renderer/RenderPonyVex.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyVex.java index a3126bb3..7341de76 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; @@ -15,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/renderer/RenderPonyVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java similarity index 78% rename from src/main/java/com/minelittlepony/renderer/RenderPonyVillager.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyVillager.java index 03554aae..cdd6b242 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; @@ -17,18 +19,18 @@ 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); } @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/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/java/com/minelittlepony/render/ponies/RenderPonyZombie.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java new file mode 100644 index 00000000..b4338e19 --- /dev/null +++ b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombie.java @@ -0,0 +1,65 @@ +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.monster.EntityGiantZombie; +import net.minecraft.entity.monster.EntityHusk; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.util.ResourceLocation; + +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 manager) { + super(manager, PMAPI.zombie); + } + + @Override + protected ResourceLocation getTexture(Zombie entity) { + return ZOMBIE; + } + + public static class Husk extends RenderPonyZombie { + + public Husk(RenderManager manager) { + super(manager); + } + + @Override + protected void preRenderCallback(EntityHusk entity, float ticks) { + super.preRenderCallback(entity, ticks); + GlStateManager.scale(1.0625F, 1.0625F, 1.0625F); + } + + @Override + protected ResourceLocation getTexture(EntityHusk entity) { + return HUSK; + } + + } + + public static class Giant extends RenderPonyMob { + + public Giant(RenderManager manager) { + super(manager, PMAPI.zombie); + } + + @Override + protected void preRenderCallback(EntityGiantZombie entity, float ticks) { + super.preRenderCallback(entity, ticks); + GlStateManager.scale(3, 3, 3); + } + + @Override + protected ResourceLocation getTexture(EntityGiantZombie entity) { + return ZOMBIE; + } + } + + //TODO: MC1.13 EntityDrowned +} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java b/src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java similarity index 62% rename from src/main/java/com/minelittlepony/renderer/RenderPonyZombieVillager.java rename to src/main/java/com/minelittlepony/render/ponies/RenderPonyZombieVillager.java index f2abb3b5..bfa4273c 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; @@ -16,21 +18,21 @@ public class RenderPonyZombieVillager extends RenderPonyMob { - - private static final ResourceLocation EVOKER = new ResourceLocation("minelittlepony", "textures/entity/illager/evoker_pony.png"); - - public RenderPonyEvoker(RenderManager rendermanagerIn) { - super(rendermanagerIn, 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); - } - } - - protected void translateToHand(EnumHandSide p_191361_1_) { - ((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(p_191361_1_).postRender(0.0625F); - } - }); - } - - @Override - protected ResourceLocation getTexture(EntityEvoker entity) { - return EVOKER; - } - - @Override - protected void preRenderCallback(EntityEvoker entitylivingbaseIn, float partialTickTime) { - super.preRenderCallback(entitylivingbaseIn, partialTickTime); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - } - -} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java b/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java deleted file mode 100644 index 0029c415..00000000 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyIllusionIllager.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.minelittlepony.renderer; - -import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.renderer.layer.LayerHeldPonyItem; -import net.minecraft.client.renderer.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; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; - - -public class RenderPonyIllusionIllager extends RenderPonyMob { - - private static final ResourceLocation TEXTURE = new ResourceLocation("minelittlepony", "textures/entity/illager/illusionist_pony.png"); - - public RenderPonyIllusionIllager(RenderManager renderManager) { - super(renderManager, PMAPI.illager); - } - - @Override - protected void addLayers() { - this.addLayer(new LayerHeldPonyItem(this) { - @Override - public void doPonyRender(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, - float ageInTicks, float netHeadYaw, float headPitch, float scale) { - if (((EntityIllusionIllager) entitylivingbaseIn).isSpellcasting() || ((EntityIllusionIllager) entitylivingbaseIn).isAggressive()) { - super.doPonyRender(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); - } - } - - @Override - protected void translateToHand(EnumHandSide p_191361_1_) { - ((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(p_191361_1_).postRender(0.0625F); - } - }); - } - - @Override - protected ResourceLocation getTexture(EntityIllusionIllager entity) { - return TEXTURE; - } - - protected void preRenderCallback(EntityIllusionIllager entitylivingbaseIn, float partialTickTime) { - super.preRenderCallback(entitylivingbaseIn, partialTickTime); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - } - - @Override - public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float partialTicks) { - if (entity.isInvisible()) { - Vec3d[] avec3d = entity.getRenderLocations(partialTicks); - float f = this.handleRotationFloat(entity, partialTicks); - - for (int i = 0; i < avec3d.length; ++i) { - super.doRender(entity, - x + avec3d[i].x + (double) MathHelper.cos((float) i + f * 0.5F) * 0.025D, - y + avec3d[i].y + (double) MathHelper.cos((float) i + f * 0.75F) * 0.0125D, - z + avec3d[i].z + (double) MathHelper.cos((float) i + f * 0.7F) * 0.025D, - yaw, partialTicks); - } - } else { - super.doRender(entity, x, y, z, yaw, partialTicks); - } - } - - @Override - protected boolean isVisible(EntityIllusionIllager p_193115_1_) { - return true; - } -} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java deleted file mode 100644 index 55defcab..00000000 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyMob.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.minelittlepony.renderer; - -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.voxelmodpack.hdskins.HDSkinManager; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.ResourceLocation; - -import javax.annotation.Nonnull; -import javax.annotation.OverridingMethodsMustInvokeSuper; - -public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { - - protected PlayerModel playerModel; - - public RenderPonyMob(RenderManager renderManager, PlayerModel playerModel) { - super(renderManager, playerModel.getModel(), 0.5F); - this.playerModel = playerModel; - - addLayers(); - } - - protected void addLayers() { - - this.addLayer(new LayerPonyArmor(this)); - this.addLayer(new LayerHeldPonyItem(this)); - // this.addLayer(new LayerArrow(this)); - this.addLayer(new LayerPonyCustomHead(this)); - this.addLayer(new LayerPonyElytra(this)); - } - - @Override - public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, - float partialTicks) { - double yOrigin = yPosition; - if (entity.isSneaking()) { - yOrigin -= 0.125D; - } - super.doRender(entity, xPosition, yOrigin, zPosition, yaw, partialTicks); - } - - @Override - @OverridingMethodsMustInvokeSuper - protected void preRenderCallback(T entity, float partialTickTime) { - this.playerModel.getModel().isSneak = false; - this.playerModel.getModel().isFlying = false; - this.playerModel.getModel().isSleeping = false; - - ResourceLocation loc = getEntityTexture(entity); - this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc).getMetadata()); - - if (mainModel.isChild) { - this.shadowSize = 0.25F; - } else if (MineLittlePony.getConfig().showscale) { - this.shadowSize = 0.4F; - } else { - this.shadowSize = 0.5F; - } - } - - @Override - public PlayerModel getPony() { - return playerModel; - } - - @Override - @Nonnull - protected final ResourceLocation getEntityTexture(T entity) { - return HDSkinManager.INSTANCE.getConvertedSkin(getTexture(entity)); - } - - protected abstract ResourceLocation getTexture(T entity); -} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java b/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java deleted file mode 100644 index 232c2991..00000000 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyVindicator.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.minelittlepony.renderer; - -import com.minelittlepony.model.PMAPI; -import com.minelittlepony.model.pony.ModelIllagerPony; -import com.minelittlepony.renderer.layer.LayerHeldPonyItem; -import net.minecraft.client.renderer.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; - -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); - - } - - @Override - 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); - } - } - - @Override - protected void translateToHand(EnumHandSide side) { - ((ModelIllagerPony) this.getRenderer().getMainModel()).getArm(side).postRender(0.0625F); - } - }); - } - - @Override - protected ResourceLocation getTexture(EntityVindicator entity) { - return VINDICATOR; - } - - @Override - protected void preRenderCallback(EntityVindicator entitylivingbaseIn, float partialTickTime) { - super.preRenderCallback(entitylivingbaseIn, partialTickTime); - GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); - } - -} diff --git a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java deleted file mode 100644 index 23cc1df0..00000000 --- a/src/main/java/com/minelittlepony/renderer/RenderPonyZombie.java +++ /dev/null @@ -1,43 +0,0 @@ -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.EntityHusk; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.util.ResourceLocation; - -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); - } - - @Override - protected ResourceLocation getTexture(Zombie zombie) { - return ZOMBIE; - } - - public static class Husk extends RenderPonyZombie { - - public Husk(RenderManager rendermanager) { - super(rendermanager); - } - - @Override - protected void preRenderCallback(EntityHusk entitylivingbaseIn, float partialTickTime) { - GlStateManager.scale(1.0625F, 1.0625F, 1.0625F); - super.preRenderCallback(entitylivingbaseIn, partialTickTime); - } - - @Override - protected ResourceLocation getTexture(EntityHusk zombie) { - return HUSK; - } - - } - -} diff --git a/src/main/java/com/minelittlepony/renderer/layer/AbstractPonyLayer.java b/src/main/java/com/minelittlepony/renderer/layer/AbstractPonyLayer.java deleted file mode 100644 index 733a4bba..00000000 --- a/src/main/java/com/minelittlepony/renderer/layer/AbstractPonyLayer.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.minelittlepony.renderer.layer; - -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; -import net.minecraft.entity.EntityLivingBase; - -public abstract class AbstractPonyLayer implements LayerRenderer { - - private final RenderLivingBase renderer; - private LayerRenderer layer; - - public AbstractPonyLayer(RenderLivingBase renderer, LayerRenderer humanLayer) { - this.renderer = renderer; - this.layer = humanLayer; - } - - public final void doRenderLayer(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, - float netHeadYaw, float headPitch, float scale) { - ModelBase model = renderer.getMainModel(); - if (model instanceof ModelHumanPlayer) { - // render the human layer - layer.doRenderLayer(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); - } else { - // render the pony layer - doPonyRender(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); - } - } - - protected abstract void doPonyRender(T entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale); - - protected RenderLivingBase getRenderer() { - return renderer; - } - - @Override - public boolean shouldCombineTextures() { - return false; - } -} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java b/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java deleted file mode 100644 index 83a72b8b..00000000 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerEntityOnPonyShoulder.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.minelittlepony.renderer.layer; - -import com.minelittlepony.ForgeProxy; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.pony.ModelPlayerPony; -import net.minecraft.client.entity.AbstractClientPlayer; -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; - -public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { - - private final RenderManager rm; - private EntityLivingBase leftEntity; - private EntityLivingBase rightEntity; - - public LayerEntityOnPonyShoulder(RenderManager rm, RenderLivingBase renderer) { - super(renderer, getForgeLayer(rm)); - this.rm = rm; - } - - public void doPonyRender(EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, - float ageInTicks, float netHeadYaw, float headPitch, float scale) { - - GlStateManager.enableRescaleNormal(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - - NBTTagCompound leftTag = player.getLeftShoulderEntity(); - - if (!leftTag.hasNoTags()) { - this.leftEntity = this.renderShoulderEntity(player, this.leftEntity, leftTag, - limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, 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); - } - - GlStateManager.disableRescaleNormal(); - } - - @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) { - - if (entity == null || !entity.getUniqueID().equals(tag.getUniqueId("UUID"))) { - entity = (EntityLivingBase) EntityList.createEntityFromNBT(tag, player.world); - // this isn't an entity. - if (entity == null) { - return null; - } - } - - GlStateManager.pushMatrix(); - - ModelPlayerPony model = ((ModelPlayerPony) getRenderer().getMainModel()); - 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.scale(1, -1, -1); - GlStateManager.rotate(5 * (left ? -1 : 1), 0, 0, 1); - - Render render = rm.getEntityRenderObject(entity); - if (render != null) { - render.doRender(entity, 0, 0, 0, 0, 0); - GlStateManager.popMatrix(); - } - return entity; - } - - private static LayerRenderer getForgeLayer(RenderManager rm) { - return ForgeProxy.createShoulderLayer() - .orElse(LayerEntityOnShoulder::new) - .apply(rm); - } -} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java deleted file mode 100644 index e1c9f9f2..00000000 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.minelittlepony.renderer.layer; - -import com.minelittlepony.PonyData; -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; -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.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 { - - public LayerHeldPonyItem(RenderLivingBase livingPony) { - super(livingPony, new LayerHeldItem(livingPony)); - } - - @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) { - 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; - - if (!left.isEmpty() || !right.isEmpty()) { - pushMatrix(); - if (model instanceof AbstractPonyModel) { - ((AbstractPonyModel) model).transform(BodyPart.LEGS); - } - - if (model.isChild) { - translate(0, 0.625, 0); - rotate(-20, -1, 0, 0); - 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); - - popMatrix(); - } - } - - private void renderHeldItem(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand) { - if (!drop.isEmpty()) { - GlStateManager.pushMatrix(); - translateToHand(hand); - - if (entity.isSneaking()) { - 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); - boolean isUnicorn = isUnicorn(this.getRenderer().getMainModel()); - boolean isLeft = hand == EnumHandSide.LEFT; - if (isUnicorn) { - GlStateManager.translate(isLeft ? -0.6F : 0.1F, 1, -.5); - } else { - GlStateManager.translate(0.0425F, 0.125F, -1.00F); - } - Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); - - if (isUnicorn) { - PonyData metadata = ((AbstractPonyModel) this.getRenderer().getMainModel()).metadata; - this.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 translateToHand(EnumHandSide hand) { - AbstractPonyModel thePony = ((IRenderPony) this.getRenderer()).getPony().getModel(); - if (thePony.metadata.hasMagic()) { - ModelPlayerPony playerModel = (ModelPlayerPony) thePony; - ModelRenderer unicornarm = hand == EnumHandSide.LEFT ? playerModel.unicornArmLeft : playerModel.unicornArmRight; - unicornarm.postRender(0.0625F); - } else { - ((ModelBiped) this.getRenderer().getMainModel()).postRenderArm(0.0625F, hand); - } - } - - public void renderItemGlow(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand, - int glowColor) { - - // enchantments mess up the rendering - ItemStack drop2 = drop.copy(); - if (drop2.hasEffect()) { - 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"); - } - } - - @Override - public boolean shouldCombineTextures() { - return false; - } -} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java deleted file mode 100644 index e6bd38b5..00000000 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyCape.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.minelittlepony.renderer.layer; - -import com.minelittlepony.ducks.IRenderPony; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.PlayerModel; -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; -import net.minecraft.util.math.MathHelper; - -import javax.annotation.Nonnull; - -import static net.minecraft.client.renderer.GlStateManager.*; - -public class LayerPonyCape extends AbstractPonyLayer { - - public LayerPonyCape(RenderLivingBase entity) { - super(entity, new LayerCape((RenderPlayer) entity)); - } - - @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(); - if (clientPlayer.hasPlayerInfo() && !clientPlayer.isInvisible() - && clientPlayer.isWearing(EnumPlayerModelParts.CAPE) && clientPlayer.getLocationCape() != null - && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { - pushMatrix(); - model.getModel().transform(BodyPart.BODY); - translate(0.0F, 0.24F, 0.0F); - 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; - if (f12 < -6.0F) { - f12 = -6.0F; - } - - if (f12 > 32.0F) { - f12 = 32.0F; - } - - 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 f15 = clientPlayer.prevCameraYaw + (clientPlayer.cameraYaw - clientPlayer.prevCameraYaw) * scale; - f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified + (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6.0F) * 32.0F * 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); - this.getRenderer().bindTexture(clientPlayer.getLocationCape()); - model.getModel().renderCape(0.0625F); - popMatrix(); - } - } - - @Override - public boolean shouldCombineTextures() { - return false; - } - -} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java deleted file mode 100644 index b6672a54..00000000 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyElytra.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.minelittlepony.renderer.layer; - -import com.minelittlepony.ducks.IRenderPony; -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; -import com.minelittlepony.model.ModelPonyElytra; -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; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -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(); - - public LayerPonyElytra(RenderLivingBase rp) { - super(rp, new LayerElytra(rp)); - } - - @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(); - - ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - - if (itemstack.getItem() == Items.ELYTRA) { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - - if (entity instanceof AbstractClientPlayer) { - - AbstractClientPlayer player = (AbstractClientPlayer) entity; - if (player.isPlayerInfoSet() && player.getLocationElytra() != null) { - this.getRenderer().bindTexture(player.getLocationElytra()); - } else if (player.hasPlayerInfo() && player.getLocationCape() != null && player.isWearing(EnumPlayerModelParts.CAPE)) { - this.getRenderer().bindTexture(player.getLocationCape()); - } else { - this.getRenderer().bindTexture(TEXTURE_ELYTRA); - } - } else { - this.getRenderer().bindTexture(TEXTURE_ELYTRA); - } - - GlStateManager.pushMatrix(); - GlStateManager.translate(0.0F, 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); - - if (itemstack.isItemEnchanted()) { - LayerArmorBase.renderEnchantedGlint(this.getRenderer(), entity, this.modelElytra, swing, swingAmount, ticks, age, yaw, head, scale); - } - - GlStateManager.popMatrix(); - } - } - - @Override - public boolean shouldCombineTextures() { - return false; - } - -} 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/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/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); + } +} 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..c2a30a44 --- /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); + } + + // The MCP name is misleading. + // This is meant to return a COPY with the given texture position + public Vertex setTexturePosition(float texX, float texY) { + return new Vertex(this, texX, texY); + } + + /** + * 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); + } +} diff --git a/src/main/java/com/minelittlepony/model/pony/armor/package-info.java b/src/main/java/com/minelittlepony/util/coordinates/package-info.java similarity index 78% rename from src/main/java/com/minelittlepony/model/pony/armor/package-info.java rename to src/main/java/com/minelittlepony/util/coordinates/package-info.java index 63f362af..0196ca93 100644 --- a/src/main/java/com/minelittlepony/model/pony/armor/package-info.java +++ b/src/main/java/com/minelittlepony/util/coordinates/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.model.pony.armor; +package com.minelittlepony.util.coordinates; import mcp.MethodsReturnNonnullByDefault; 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/java/com/minelittlepony/renderer/package-info.java b/src/main/java/com/minelittlepony/util/math/package-info.java similarity index 80% rename from src/main/java/com/minelittlepony/renderer/package-info.java rename to src/main/java/com/minelittlepony/util/math/package-info.java index f99a8bdb..5d02780c 100644 --- a/src/main/java/com/minelittlepony/renderer/package-info.java +++ b/src/main/java/com/minelittlepony/util/math/package-info.java @@ -1,6 +1,6 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package com.minelittlepony.renderer; +package com.minelittlepony.util.math; import mcp.MethodsReturnNonnullByDefault; 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 9dece2ec..ec8c870b 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/alex_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/alex_pony.png differ 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 60743c05..6d1ee486 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/pony/bpony_14.png and b/src/main/resources/assets/minelittlepony/textures/entity/pony/bpony_14.png differ 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 843cb758..c9ea7d7b 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_pony.png differ 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 88f51bfa..46efb341 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_wither_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/skeleton_wither_pony.png differ diff --git a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png index 6dc56927..bfa73b6d 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/skeleton/stray_pony.png differ 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 49b58025..11edcae9 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/villager/smith_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/villager/smith_pony.png differ 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 00000000..215d1400 Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/entity/witch_pony.png differ 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 5bddac77..4bffbf00 100644 Binary files a/src/main/resources/assets/minelittlepony/textures/entity/zombie_villager/zombie_farmer_pony.png and b/src/main/resources/assets/minelittlepony/textures/entity/zombie_villager/zombie_farmer_pony.png differ 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 00000000..2234de1e Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/mob/noskin.png differ diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index 3f7f8074..03138d99 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -5,7 +5,9 @@ "refmap": "minelp.mixin.refmap.json", "compatibilityLevel": "JAVA_8", "mixins": [ - "MixinRenderPlayer", - "MixinRenderItem" + "MixinThreadDownloadImageData", + "MixinNetworkPlayerInfo", + "MixinRenderItem", + "MixinRenderManager" ] }