From 2245e42ad096e223052dff977fa4f840c3e34bd4 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Wed, 16 Nov 2016 23:45:04 -0500 Subject: [PATCH] Initial update to 1.11. Features next. --- build.gradle | 8 +-- .../hdskins/gui/RenderPlayerModel.java | 4 +- .../minelittlepony/MineLittlePony.java | 17 +++-- .../java/com/brohoof/minelittlepony/Pony.java | 8 ++- .../brohoof/minelittlepony/PonyManager.java | 63 ++---------------- .../model/part/PegasusWings.java | 2 +- .../model/pony/ModelPlayerPony.java | 2 +- .../model/pony/ModelVillagerPony.java | 2 +- .../model/pony/armor/ModelPonyArmor.java | 2 +- .../renderer/RenderPonyMob.java | 45 ------------- .../renderer/RenderPonyPigman.java | 5 +- .../renderer/RenderPonySkeleton.java | 62 ++++++++++++----- .../renderer/RenderPonyVillager.java | 29 +++++++- .../renderer/RenderPonyZombie.java | 41 +++++++----- .../renderer/layer/LayerHeldPonyItem.java | 2 +- .../layer/LayerPonySkeletonOverlay.java | 40 ----------- .../renderer/layer/LayerPonySkull.java | 5 +- .../renderer/layer/LayerPonyStrayOverlay.java | 36 ++++++++++ .../entity/villager/villager_pony.png | Bin 0 -> 442 bytes .../minelittlepony/test/TestEnumMap.java | 20 ------ 20 files changed, 171 insertions(+), 222 deletions(-) delete mode 100644 src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java create mode 100644 src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java create mode 100644 src/main/resources/assets/minelittlepony/textures/entity/villager/villager_pony.png delete mode 100644 src/test/java/com/brohoof/minelittlepony/test/TestEnumMap.java diff --git a/build.gradle b/build.gradle index 3ff7bdeb..fb8cd7d4 100644 --- a/build.gradle +++ b/build.gradle @@ -26,12 +26,12 @@ apply plugin: 'org.spongepowered.mixin' apply plugin: 'mnm.gradle.ap-ide' group = 'com.brohoof.minelp' -version = '1.10.2.6' +version = '1.11.0.0-beta' description = 'Mine Little Pony' minecraft { - version = "1.10.2" - mappings = 'snapshot_20160704' // 'murica! F*** yeah! + version = "1.11" + mappings = 'snapshot_20161116' runDir = 'run' replace '@VERSION@',project.version } @@ -52,8 +52,6 @@ sourceSets { } } -dependencies.testCompile 'junit:junit:4.12' - litemod.json { author = 'Verdana, Rene_Z, Mumfrey, JoyJoy' description = 'Mine Little Pony turns players and mobs into ponies' diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java index 7e85bf7b..b5297275 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java @@ -29,7 +29,7 @@ public class RenderPlayerModel extends RenderLiving @Override protected boolean canRenderName(M targetEntity) { - if (Minecraft.getMinecraft().thePlayer != null) { + if (Minecraft.getMinecraft().player != null) { return super.canRenderName(targetEntity); } return false; @@ -37,7 +37,7 @@ public class RenderPlayerModel extends RenderLiving @Override protected boolean setBrightness(M entitylivingbaseIn, float partialTicks, boolean p_177092_3_) { - if (Minecraft.getMinecraft().theWorld != null) { + if (Minecraft.getMinecraft().world != null) { return super.setBrightness(entitylivingbaseIn, partialTicks, p_177092_3_); } return false; diff --git a/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java b/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java index c3d8eaf1..acacd334 100644 --- a/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java @@ -10,6 +10,7 @@ import com.brohoof.minelittlepony.renderer.RenderPonyPigman; import com.brohoof.minelittlepony.renderer.RenderPonySkeleton; import com.brohoof.minelittlepony.renderer.RenderPonyVillager; import com.brohoof.minelittlepony.renderer.RenderPonyZombie; +import com.brohoof.minelittlepony.renderer.RenderPonyZombieVillager; import com.brohoof.minelittlepony.util.MineLPLogger; import com.mumfrey.liteloader.core.LiteLoader; import com.mumfrey.liteloader.util.ModUtilities; @@ -20,9 +21,13 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntityStray; +import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.passive.EntityVillager; public class MineLittlePony { @@ -76,11 +81,13 @@ public class MineLittlePony { ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); if (this.config.villagers) { ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); + ModUtilities.addRenderer(EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); MineLPLogger.info("Villagers are now ponies."); } if (this.config.zombies) { - ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm)); + ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm)); + ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm)); MineLPLogger.info("Zombies are now ponies."); } @@ -90,7 +97,9 @@ public class MineLittlePony { } if (this.config.skeletons) { - ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm)); + ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm)); + ModUtilities.addRenderer(EntityStray.class, new RenderPonySkeleton.Stray(rm)); + ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); MineLPLogger.info("Skeletons are now ponies."); } @@ -126,8 +135,4 @@ public class MineLittlePony { return getInstance().config; } - public static String getSPUsername() { - return Minecraft.getMinecraft().getSession().getUsername(); - } - } diff --git a/src/main/java/com/brohoof/minelittlepony/Pony.java b/src/main/java/com/brohoof/minelittlepony/Pony.java index 6aa1a6c8..1bc56121 100644 --- a/src/main/java/com/brohoof/minelittlepony/Pony.java +++ b/src/main/java/com/brohoof/minelittlepony/Pony.java @@ -4,6 +4,8 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.util.List; +import javax.annotation.Nonnull; + import com.brohoof.minelittlepony.model.PMAPI; import com.brohoof.minelittlepony.model.PlayerModel; import com.brohoof.minelittlepony.util.MineLPLogger; @@ -41,7 +43,7 @@ public class Pony { private int skinCheckCount; private boolean skinChecked; - public Pony(AbstractClientPlayer player) { + public Pony(@Nonnull AbstractClientPlayer player) { this.profile = player.getGameProfile(); this.textureResourceLocation = player.getLocationSkin(); MineLPLogger.debug("+ Initialising new pony #%d for player %s (%s) with resource location %s.", this.ponyId, @@ -50,7 +52,7 @@ public class Pony { this.checkMeta(profile); } - public Pony(ResourceLocation aTextureResourceLocation) { + public Pony(@Nonnull ResourceLocation aTextureResourceLocation) { this.textureResourceLocation = aTextureResourceLocation; MineLPLogger.debug("+ Initialising new pony #%d with resource location %s.", this.ponyId, this.textureResourceLocation); this.checkSkin(this.textureResourceLocation); @@ -118,7 +120,7 @@ public class Pony { metadata.setGlowColor(Integer.parseInt(prefs.apply(MineLittlePony.MLP_MAGIC))); } - public BufferedImage getBufferedImage(ResourceLocation textureResourceLocation) { + public BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { BufferedImage skinImage = null; try { IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); diff --git a/src/main/java/com/brohoof/minelittlepony/PonyManager.java b/src/main/java/com/brohoof/minelittlepony/PonyManager.java index 5bdf83fd..11ad14ab 100644 --- a/src/main/java/com/brohoof/minelittlepony/PonyManager.java +++ b/src/main/java/com/brohoof/minelittlepony/PonyManager.java @@ -12,8 +12,6 @@ import org.apache.commons.compress.utils.IOUtils; import com.brohoof.minelittlepony.model.PMAPI; import com.brohoof.minelittlepony.util.MineLPLogger; import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gson.Gson; @@ -23,48 +21,14 @@ import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.entity.monster.SkeletonType; -import net.minecraft.entity.monster.ZombieType; -import net.minecraft.entity.passive.EntityVillager; import net.minecraft.util.ResourceLocation; public class PonyManager implements IResourceManagerReloadListener { - public static final String NAMESPACE = "minelittlepony"; - public static final ResourceLocation ZOMBIE = new ResourceLocation(NAMESPACE, "textures/entity/zombie/zombie_pony.png"); - public static final ResourceLocation ZOMBIE_VILLAGER = new ResourceLocation(NAMESPACE, "textures/entity/zombie_villager/zombie_villager_pony.png"); + public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"); + public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"); - public static final Map ZOMBIES = Maps.immutableEnumMap(ImmutableMap. builder() - .put(ZombieType.NORMAL, ZOMBIE) - .put(ZombieType.HUSK, new ResourceLocation(NAMESPACE, "textures/entity/zombie/zombie_husk_pony.png")) - .put(ZombieType.VILLAGER_FARMER, new ResourceLocation(NAMESPACE, "textures/entity/zombie_villager/zombie_farmer_pony.png")) - .put(ZombieType.VILLAGER_LIBRARIAN, new ResourceLocation(NAMESPACE, "textures/entity/zombie_villager/zombie_librarian_pony.png")) - .put(ZombieType.VILLAGER_PRIEST, new ResourceLocation(NAMESPACE, "textures/entity/zombie_villager/zombie_priest_pony.png")) - .put(ZombieType.VILLAGER_SMITH, new ResourceLocation(NAMESPACE, "textures/entity/zombie_villager/zombie_smith_pony.png")) - .put(ZombieType.VILLAGER_BUTCHER, new ResourceLocation(NAMESPACE, "textures/entity/zombie_villager/zombie_butcher_pony.png")) - .build()); - - public static final List VILLAGER_LIST = ImmutableList. builder() - .add(new ResourceLocation(NAMESPACE, "textures/entity/villager/farmer_pony.png")) - .add(new ResourceLocation(NAMESPACE, "textures/entity/villager/librarian_pony.png")) - .add(new ResourceLocation(NAMESPACE, "textures/entity/villager/priest_pony.png")) - .add(new ResourceLocation(NAMESPACE, "textures/entity/villager/smith_pony.png")) - .add(new ResourceLocation(NAMESPACE, "textures/entity/villager/butcher_pony.png")) - .add(new ResourceLocation(NAMESPACE, "textures/entity/villager/villager_pony.png")) - .build(); - - public static final ResourceLocation PIGMAN = new ResourceLocation(NAMESPACE, "textures/entity/zombie/zombie_pigman_pony.png"); - public static final ResourceLocation SKELETON = new ResourceLocation(NAMESPACE, "textures/entity/skeleton/skeleton_pony.png"); - - public static final Map SKELETONS = Maps.immutableEnumMap(ImmutableMap. builder() - .put(SkeletonType.NORMAL, SKELETON) - .put(SkeletonType.WITHER, new ResourceLocation(NAMESPACE, "textures/entity/skeleton/skeleton_wither_pony.png")) - .put(SkeletonType.STRAY, new ResourceLocation(NAMESPACE, "textures/entity/skeleton/stray_pony.png")) - .build()); - public static final ResourceLocation STEVE = new ResourceLocation(NAMESPACE, "textures/entity/steve_pony.png"); - public static final ResourceLocation ALEX = new ResourceLocation(NAMESPACE, "textures/entity/alex_pony.png"); - - private static final ResourceLocation BGPONIES_JSON = new ResourceLocation(NAMESPACE, "textures/entity/pony/bgponies.json"); + private static final ResourceLocation BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json"); private List backgroundPonyList = Lists.newArrayList(); private PonyConfig config; @@ -113,21 +77,6 @@ public class PonyManager implements IResourceManagerReloadListener { return myLittlePony; } - public Pony getPonyFromResourceRegistry(EntityVillager entity) { - int profession = entity.getProfession(); - - ResourceLocation villagerResourceLocation; - try { - villagerResourceLocation = VILLAGER_LIST.get(profession); - } catch (IndexOutOfBoundsException var5) { - villagerResourceLocation = VILLAGER_LIST.get(5); - } - - Pony myLittlePony = this.getPonyFromResourceRegistry(villagerResourceLocation); - // myLittlePony.setVillager(profession); - return myLittlePony; - } - public ResourceLocation getBackgroundPonyResource(UUID id) { if (getNumberOfPonies() > 0) { int backgroundIndex = id.hashCode() % this.getNumberOfPonies(); @@ -190,11 +139,11 @@ public class PonyManager implements IResourceManagerReloadListener { } } - public static ResourceLocation getDefaultSkin(UUID uuid) { + private ResourceLocation getDefaultSkin(UUID uuid) { return (uuid.hashCode() & 1) == 0 ? STEVE : ALEX; } - public int getNumberOfPonies() { + private int getNumberOfPonies() { return backgroundPonyList.size(); } @@ -205,7 +154,7 @@ public class PonyManager implements IResourceManagerReloadListener { @Override public ResourceLocation apply(String input) { - return new ResourceLocation(NAMESPACE, String.format("textures/entity/pony/%s.png", input)); + return new ResourceLocation("minelittlepony", String.format("textures/entity/pony/%s.png", input)); } public List getPonies() { diff --git a/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java b/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java index e59e6f7f..2991d3e7 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java +++ b/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java @@ -101,7 +101,7 @@ public class PegasusWings implements IPonyPart, PonyModelConstants { float bodySwingRotation = 0.0F; if (pony.swingProgress > -9990.0F && !metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt_float(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F; + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } for (int i = 0; i < this.leftWing.length; ++i) { this.leftWing[i].rotateAngleY = bodySwingRotation * 0.2F; diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java index e7d7f62e..47f2df94 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java @@ -51,7 +51,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.swingTailZ(move, swing); float bodySwingRotation = 0.0F; if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt_float(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } this.bipedBody.rotateAngleY = bodySwingRotation * 0.2F; diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java index aae834a0..53ac879d 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java @@ -22,7 +22,7 @@ public class ModelVillagerPony extends ModelPlayerPony { super.animate(move, swing, tick, horz, vert, entity); float bodySwingRotation = 0.0F; if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt_float(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } for (int i = 0; i < this.VillagerBagPiece.length; ++i) { this.VillagerBagPiece[i].rotateAngleY = bodySwingRotation * 0.2F; diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java index 912fa8bb..8e763ac6 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java @@ -30,7 +30,7 @@ public class ModelPonyArmor extends ModelPlayerPony { this.rotateHead(horz, vert); float bodySwingRotation = 0.0F; if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { - bodySwingRotation = MathHelper.sin(MathHelper.sqrt_float(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; + bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; } this.bipedBody.rotateAngleY = bodySwingRotation * 0.2F; diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java index c2957167..09be89c1 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java @@ -12,13 +12,9 @@ import com.brohoof.minelittlepony.renderer.layer.LayerPonyArmor; import com.brohoof.minelittlepony.renderer.layer.LayerPonySkull; import com.voxelmodpack.hdskins.HDSkinManager; -import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLiving; -import net.minecraft.item.EnumAction; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHandSide; import net.minecraft.util.ResourceLocation; public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { @@ -49,47 +45,6 @@ public abstract class RenderPonyMob extends RenderLiving @Override protected void preRenderCallback(T entity, float partialTickTime) { - ItemStack main = entity.getHeldItemMainhand(); - ItemStack off = entity.getHeldItemOffhand(); - ArmPose mainPose = ArmPose.EMPTY; - ArmPose offPose = ArmPose.EMPTY; - - if (main != null) { - mainPose = ArmPose.ITEM; - - if (entity.getItemInUseCount() > 0) { - EnumAction action = main.getItemUseAction(); - - if (action == EnumAction.BLOCK) { - mainPose = ArmPose.BLOCK; - } else if (action == EnumAction.BOW) { - mainPose = ArmPose.BOW_AND_ARROW; - } - } - } - - if (off != null) { - offPose = ArmPose.ITEM; - - if (entity.getItemInUseCount() > 0) { - EnumAction action = off.getItemUseAction(); - - if (action == EnumAction.BLOCK) { - offPose = ArmPose.BLOCK; - } else if (action == EnumAction.BOW) { - offPose = ArmPose.BOW_AND_ARROW; - } - } - } - - if (entity.getPrimaryHand() == EnumHandSide.RIGHT) { - this.playerModel.getModel().rightArmPose = mainPose; - this.playerModel.getModel().leftArmPose = offPose; - } else { - this.playerModel.getModel().rightArmPose = offPose; - this.playerModel.getModel().leftArmPose = mainPose; - } - this.playerModel.getModel().isSneak = false; this.playerModel.getModel().isFlying = false; this.playerModel.getModel().isSleeping = false; diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyPigman.java b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyPigman.java index 399f7fb2..e875d680 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyPigman.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyPigman.java @@ -1,6 +1,5 @@ package com.brohoof.minelittlepony.renderer; -import com.brohoof.minelittlepony.PonyManager; import com.brohoof.minelittlepony.model.PMAPI; import net.minecraft.client.renderer.entity.RenderManager; @@ -9,13 +8,15 @@ import net.minecraft.util.ResourceLocation; 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); } @Override protected ResourceLocation getEntityTexture(EntityPigZombie entity) { - return getTexture(PonyManager.PIGMAN); + return getTexture(PIGMAN); } } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonySkeleton.java b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonySkeleton.java index 0403e58d..ef270c9f 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonySkeleton.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonySkeleton.java @@ -3,21 +3,26 @@ package com.brohoof.minelittlepony.renderer; import java.util.Random; import com.brohoof.minelittlepony.PonyGender; -import com.brohoof.minelittlepony.PonyManager; import com.brohoof.minelittlepony.PonyRace; import com.brohoof.minelittlepony.PonySize; import com.brohoof.minelittlepony.TailLengths; import com.brohoof.minelittlepony.model.PMAPI; -import com.brohoof.minelittlepony.renderer.layer.LayerPonySkeletonOverlay; +import com.brohoof.minelittlepony.renderer.layer.LayerPonyStrayOverlay; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.SkeletonType; +import net.minecraft.entity.monster.AbstractSkeleton; +import net.minecraft.entity.monster.EntityStray; +import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.util.ResourceLocation; -public class RenderPonySkeleton extends RenderPonyMob { +public class RenderPonySkeleton extends RenderPonyMob { + + private static final ResourceLocation SKELETON = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_pony.png"); + 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); this.addLayer(new LayerBipedArmor(this) { @@ -27,15 +32,11 @@ public class RenderPonySkeleton extends RenderPonyMob { this.modelArmor = PMAPI.skeleton.getArmor().modelArmorChestplate; } }); - this.addLayer(new LayerPonySkeletonOverlay(this)); } @Override - protected void preRenderCallback(EntitySkeleton skeleton, float partialTicks) { + protected void preRenderCallback(Skeleton skeleton, float partialTicks) { super.preRenderCallback(skeleton, partialTicks); - if (skeleton.getSkeletonType() == SkeletonType.WITHER) { - GlStateManager.scale(1.2F, 1.2F, 1.2F); - } Random rand = new Random(skeleton.getUniqueID().hashCode()); this.playerModel.getModel().metadata.setGender(rand.nextBoolean() ? PonyGender.MARE : PonyGender.STALLION); @@ -58,11 +59,40 @@ public class RenderPonySkeleton extends RenderPonyMob { } @Override - protected ResourceLocation getEntityTexture(EntitySkeleton skeleton) { - SkeletonType type = skeleton.getSkeletonType(); - ResourceLocation loc = PonyManager.SKELETONS.get(type); - if (loc == null) - loc = PonyManager.SKELETON; - return getTexture(loc); + protected ResourceLocation getEntityTexture(Skeleton entity) { + return getTexture(SKELETON); } + + public static class Stray extends RenderPonySkeleton { + + public Stray(RenderManager rm) { + super(rm); + } + + @Override + protected ResourceLocation getEntityTexture(EntityStray entity) { + return getTexture(STRAY); + } + } + + public static class Wither extends RenderPonySkeleton { + + public Wither(RenderManager rm) { + super(rm); + this.addLayer(new LayerPonyStrayOverlay(this)); + } + + @Override + protected ResourceLocation getEntityTexture(EntityWitherSkeleton entity) { + return getTexture(WITHER); + } + + @Override + protected void preRenderCallback(EntityWitherSkeleton skeleton, float partialTicks) { + super.preRenderCallback(skeleton, partialTicks); + GlStateManager.scale(1.2F, 1.2F, 1.2F); + } + + } + } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyVillager.java b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyVillager.java index 6677cc19..952d0b2d 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyVillager.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyVillager.java @@ -1,7 +1,6 @@ package com.brohoof.minelittlepony.renderer; import com.brohoof.minelittlepony.MineLittlePony; -import com.brohoof.minelittlepony.Pony; import com.brohoof.minelittlepony.model.PMAPI; import com.brohoof.minelittlepony.model.pony.ModelVillagerPony; @@ -12,6 +11,13 @@ import net.minecraft.util.ResourceLocation; public class RenderPonyVillager extends RenderPonyMob { + private static final ResourceLocation GENERIC = new ResourceLocation("minelittlepony", "textures/entity/villager/villager_pony.png"); + private static final ResourceLocation FARMER = new ResourceLocation("minelittlepony", "textures/entity/villager/farmer_pony.png"); + private static final ResourceLocation LIBRARIAN = new ResourceLocation("minelittlepony", "textures/entity/villager/librarian_pony.png"); + private static final ResourceLocation PRIEST = new ResourceLocation("minelittlepony", "textures/entity/villager/priest_pony.png"); + private static final ResourceLocation SMITH = new ResourceLocation("minelittlepony", "textures/entity/villager/smith_pony.png"); + private static final ResourceLocation BUTCHER = new ResourceLocation("minelittlepony", "textures/entity/villager/butcher_pony.png"); + public RenderPonyVillager(RenderManager rm) { super(rm, PMAPI.villager); } @@ -34,7 +40,24 @@ public class RenderPonyVillager extends RenderPonyMob { @Override protected ResourceLocation getEntityTexture(EntityVillager villager) { - Pony aVillagerPony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(villager); - return getTexture(aVillagerPony.getTextureResourceLocation()); + return getTexture(getTextureForVillager(villager)); + } + + private ResourceLocation getTextureForVillager(EntityVillager villager) { + switch (villager.getProfession()) { + case 0: + return FARMER; + case 1: + return LIBRARIAN; + case 2: + return PRIEST; + case 3: + return SMITH; + case 4: + return BUTCHER; + case 5: + default: + return GENERIC; + } } } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyZombie.java b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyZombie.java index f64dbf21..221594de 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyZombie.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyZombie.java @@ -3,24 +3,28 @@ package com.brohoof.minelittlepony.renderer; import java.util.Random; import com.brohoof.minelittlepony.PonyGender; -import com.brohoof.minelittlepony.PonyManager; import com.brohoof.minelittlepony.PonyRace; import com.brohoof.minelittlepony.PonySize; import com.brohoof.minelittlepony.TailLengths; import com.brohoof.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 { +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/zombie_husk_pony.png"); public RenderPonyZombie(RenderManager rendermanager) { super(rendermanager, PMAPI.zombie); } @Override - protected void preRenderCallback(EntityZombie entity, float partick) { + protected void preRenderCallback(Zombie entity, float partick) { super.preRenderCallback(entity, partick); Random rand = new Random(entity.getUniqueID().hashCode()); @@ -58,26 +62,33 @@ public class RenderPonyZombie extends RenderPonyMob { } - private > T randEnum(Random rand, Class en) { + private static > T randEnum(Random rand, Class en) { T[] values = en.getEnumConstants(); return values[rand.nextInt(values.length)]; } @Override - protected void rotateCorpse(EntityZombie zombie, float xPosition, float yPosition, float zPosition) { - super.rotateCorpse(zombie, xPosition, yPosition, zPosition); - if (zombie.isConverting()) { - yPosition += (float) (Math.cos(zombie.ticksExisted * 3.25D) * Math.PI * 0.25D); - } + protected ResourceLocation getEntityTexture(Zombie zombie) { + return getTexture(ZOMBIE); } - @Override - protected ResourceLocation getEntityTexture(EntityZombie zombie) { - ResourceLocation loc = PonyManager.ZOMBIES.get(zombie.getZombieType()); - if (loc == null) { - loc = zombie.isVillager() ? PonyManager.ZOMBIE_VILLAGER : PonyManager.ZOMBIE; + public static class Husk extends RenderPonyZombie { + + public Husk(RenderManager rendermanager) { + super(rendermanager); } - return getTexture(loc); + + @Override + protected void preRenderCallback(EntityHusk entitylivingbaseIn, float partialTickTime) { + GlStateManager.scale(1.0625F, 1.0625F, 1.0625F); + super.preRenderCallback(entitylivingbaseIn, partialTickTime); + } + + @Override + protected ResourceLocation getEntityTexture(EntityHusk zombie) { + return getTexture(HUSK); + } + } } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java index 94264710..4826419c 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java @@ -121,7 +121,7 @@ public class LayerHeldPonyItem implements LayerRenderer { GL14.glBlendColor(red, green, blue, alpha); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - IBakedModel model = renderItem.getItemModelWithOverrides(drop, entity.worldObj, entity); + IBakedModel model = renderItem.getItemModelWithOverrides(drop, entity.world, entity); ItemCameraTransforms itemcameratransforms = model.getItemCameraTransforms(); ItemCameraTransforms.applyTransformSide(itemcameratransforms.getTransform(transform), hand == EnumHandSide.LEFT); diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java deleted file mode 100644 index b0ebb032..00000000 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkeletonOverlay.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.brohoof.minelittlepony.renderer.layer; - -import com.brohoof.minelittlepony.PonyManager; -import com.brohoof.minelittlepony.model.pony.ModelSkeletonPony; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.SkeletonType; -import net.minecraft.util.ResourceLocation; - -public class LayerPonySkeletonOverlay extends LayerOverlayBase { - - public static final ResourceLocation STRAY_SKELETON_OVERLAY = new ResourceLocation(PonyManager.NAMESPACE, "textures/entity/skeleton/stray_pony_overlay.png"); - - private final ModelSkeletonPony overlayModel; - - public LayerPonySkeletonOverlay(RenderLivingBase render) { - super(render); - this.overlayModel = new ModelSkeletonPony(); - this.overlayModel.init(0F, 0.25F); - } - - @Override - public void doRenderLayer(EntitySkeleton skele, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - if (skele.getSkeletonType() == SkeletonType.STRAY) { - this.renderOverlay(skele, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); - } - } - - @Override - protected ModelBase getOverlayModel() { - return this.overlayModel; - } - - @Override - protected ResourceLocation getOverlayTexture() { - return STRAY_SKELETON_OVERLAY; - } -} diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java index adfdef8c..11324925 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java @@ -15,7 +15,7 @@ import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; @@ -44,8 +44,7 @@ public class LayerPonySkull implements LayerRenderer { Item item = itemstack.getItem(); pushMatrix(); - boolean isVillager = entity instanceof EntityVillager - || entity instanceof EntityZombie && ((EntityZombie) entity).isVillager(); + boolean isVillager = entity instanceof EntityVillager || entity instanceof EntityZombieVillager; model.transform(BodyPart.HEAD); model.bipedHead.postRender(0.0625f); diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java new file mode 100644 index 00000000..55ed0ab2 --- /dev/null +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyStrayOverlay.java @@ -0,0 +1,36 @@ +package com.brohoof.minelittlepony.renderer.layer; + +import com.brohoof.minelittlepony.model.pony.ModelSkeletonPony; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.entity.monster.EntityStray; +import net.minecraft.util.ResourceLocation; + +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; + + 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); + } + + @Override + protected ModelBase getOverlayModel() { + return this.overlayModel; + } + + @Override + protected ResourceLocation getOverlayTexture() { + return STRAY_SKELETON_OVERLAY; + } +} diff --git a/src/main/resources/assets/minelittlepony/textures/entity/villager/villager_pony.png b/src/main/resources/assets/minelittlepony/textures/entity/villager/villager_pony.png new file mode 100644 index 0000000000000000000000000000000000000000..3353efc67ff2fd256428db457c5d5f96e1018ace GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU~KesaSW-r^>(JCUyFfA+s#>L zVtW+Tq{7#I<ntL>>Ps4(7}P3PRx-@tW{^H~l-b~H)@L(@ z+Pv=!F~^PhPuB7=&i{FrVZxSue`O+g4_s?&)=fC`yI4Snq0Fbwnc1xR))Om7R`I#f zj0ZSb_!-h8FMm;DINW;o>W05RYW|=9|FmkUlfapjZGlfube_?F&A7gOWA)D>Nk$W6 zx4nncZ5fUq&hP%;qCZ{IVNJ^2c%}vKe_6eozpmXNRI}mZ`N`YACNJB2Z%6k3B!-N~ z*|W}Dvba2RX4sNw{Or`!iiw}D`mdQGwqCShb=^&dDRspvd$@?2>^k#wHN>Z literal 0 HcmV?d00001 diff --git a/src/test/java/com/brohoof/minelittlepony/test/TestEnumMap.java b/src/test/java/com/brohoof/minelittlepony/test/TestEnumMap.java deleted file mode 100644 index 57b44c67..00000000 --- a/src/test/java/com/brohoof/minelittlepony/test/TestEnumMap.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.brohoof.minelittlepony.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.brohoof.minelittlepony.PonyManager; - -import net.minecraft.entity.monster.ZombieType; - -public class TestEnumMap { - - @Test - public void testMapCompletion() { - int size = PonyManager.ZOMBIES.size(); - - assertEquals(size, ZombieType.values().length); - } - -}