diff --git a/src/api/java/net/minecraftforge/client/ForgeHooksClient.java b/src/api/java/net/minecraftforge/client/ForgeHooksClient.java index 74d4f6a3..97899be4 100644 --- a/src/api/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/api/java/net/minecraftforge/client/ForgeHooksClient.java @@ -1,17 +1,19 @@ package net.minecraftforge.client; -import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; // stub public class ForgeHooksClient { - public static String getArmorTexture(EntityLivingBase entity, ItemStack armor, String def, int slot, String type) { + public static String getArmorTexture(Entity entity, ItemStack armor, String def, EntityEquipmentSlot slot, String type) { return def; } - public static ModelBase getArmorModel(EntityLivingBase entity, ItemStack item, int slot, ModelBase def) { + public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) { return def; } diff --git a/src/api/java/net/minecraftforge/fml/common/Mod.java b/src/api/java/net/minecraftforge/fml/common/Mod.java deleted file mode 100644 index b26f1c9c..00000000 --- a/src/api/java/net/minecraftforge/fml/common/Mod.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.minecraftforge.fml.common; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -// stub -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface Mod { - - String modid(); - - String name() default ""; - - String version() default ""; - - boolean clientSideOnly() default false; - - public @interface EventHandler { - - } -} diff --git a/src/api/java/net/minecraftforge/fml/common/event/FMLPostInitializationEvent.java b/src/api/java/net/minecraftforge/fml/common/event/FMLPostInitializationEvent.java deleted file mode 100644 index b24f8ec2..00000000 --- a/src/api/java/net/minecraftforge/fml/common/event/FMLPostInitializationEvent.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.minecraftforge.fml.common.event; - -// stub -public class FMLPostInitializationEvent {} diff --git a/src/main/java/com/minelittlepony/ForgeProxy.java b/src/main/java/com/minelittlepony/ForgeProxy.java new file mode 100644 index 00000000..b4e6cb3f --- /dev/null +++ b/src/main/java/com/minelittlepony/ForgeProxy.java @@ -0,0 +1,27 @@ +package com.minelittlepony; + +import com.mumfrey.liteloader.util.ModUtilities; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.ForgeHooksClient; + +public class ForgeProxy { + + private static boolean forgeLoaded = ModUtilities.fmlIsPresent(); + + public static String getArmorTexture(Entity entity, ItemStack armor, String def, EntityEquipmentSlot slot, String type) { + if (forgeLoaded) + return ForgeHooksClient.getArmorTexture(entity, armor, def, slot, type); + return def; + } + + public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) { + if (forgeLoaded) + return ForgeHooksClient.getArmorModel(entity, item, slot, def); + return def; + } + +} diff --git a/src/main/java/com/minelittlepony/MineLittlePony.java b/src/main/java/com/minelittlepony/MineLittlePony.java index ad80ed87..e2053a1a 100644 --- a/src/main/java/com/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/MineLittlePony.java @@ -57,7 +57,6 @@ public class MineLittlePony { private PonyConfig config; private PonyManager ponyManager; - private ProxyContainer proxy; private Map, Render> renderMap = Maps.newHashMap(); @@ -70,7 +69,6 @@ public class MineLittlePony { this.config = new PonyConfig(); this.ponyManager = new PonyManager(config); - this.proxy = new ProxyContainer(); LiteLoader.getInstance().registerExposable(config, null); @@ -195,10 +193,6 @@ public class MineLittlePony { return this.ponyManager; } - public static ProxyContainer getProxy() { - return getInstance().proxy; - } - public static PonyConfig getConfig() { return getInstance().config; } diff --git a/src/main/java/com/minelittlepony/ProxyContainer.java b/src/main/java/com/minelittlepony/ProxyContainer.java deleted file mode 100644 index de950d01..00000000 --- a/src/main/java/com/minelittlepony/ProxyContainer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.minelittlepony; - -import com.minelittlepony.forge.IForgeHooks; -import com.minelittlepony.forge.MLPCommonProxy; - -import javax.annotation.Nullable; - -public class ProxyContainer extends MLPCommonProxy { - - private IForgeHooks ponyArmors; - - @Override - public void setForgeHooks(IForgeHooks armors) { - this.ponyArmors = armors; - } - - @Nullable - public IForgeHooks getHooks() { - return ponyArmors; - } -} diff --git a/src/main/java/com/minelittlepony/forge/ForgePonyHooks.java b/src/main/java/com/minelittlepony/forge/ForgePonyHooks.java deleted file mode 100644 index e6d00447..00000000 --- a/src/main/java/com/minelittlepony/forge/ForgePonyHooks.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.minelittlepony.forge; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.ForgeHooksClient; - -public class ForgePonyHooks implements IForgeHooks { - - @Override - public String getArmorTexture(EntityLivingBase entity, ItemStack armor, String def, int slot, String type) { - return ForgeHooksClient.getArmorTexture(entity, armor, def, slot, type); - } - - @Override - public ModelBase getArmorModel(EntityLivingBase entity, ItemStack item, int slot, ModelBase def) { - return ForgeHooksClient.getArmorModel(entity, item, slot, def); - } - -} diff --git a/src/main/java/com/minelittlepony/forge/IForgeHooks.java b/src/main/java/com/minelittlepony/forge/IForgeHooks.java deleted file mode 100644 index 01d22673..00000000 --- a/src/main/java/com/minelittlepony/forge/IForgeHooks.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.minelittlepony.forge; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; - -public interface IForgeHooks { - - String getArmorTexture(EntityLivingBase e, ItemStack item, String def, int slot, String type); - - ModelBase getArmorModel(EntityLivingBase e, ItemStack item, int slot, ModelBase def); -} diff --git a/src/main/java/com/minelittlepony/forge/MLPCommonProxy.java b/src/main/java/com/minelittlepony/forge/MLPCommonProxy.java deleted file mode 100644 index cee67c6a..00000000 --- a/src/main/java/com/minelittlepony/forge/MLPCommonProxy.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.minelittlepony.forge; - -public abstract class MLPCommonProxy { - - private static MLPCommonProxy instance; - - public static MLPCommonProxy getInstance() { - return instance; - } - - public MLPCommonProxy() { - instance = this; - } - - public abstract void setForgeHooks(IForgeHooks armors); -} diff --git a/src/main/java/com/minelittlepony/forge/MLPForge.java b/src/main/java/com/minelittlepony/forge/MLPForge.java deleted file mode 100644 index 67001a02..00000000 --- a/src/main/java/com/minelittlepony/forge/MLPForge.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.minelittlepony.forge; - -import com.minelittlepony.MineLittlePony; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; - -@Mod( - modid = "minelp_forge", - name = "MineLP Forge Hooks", - version = MineLittlePony.MOD_VERSION, - clientSideOnly = true) -public class MLPForge { - - @SuppressWarnings("unused") - @EventHandler - public void init(FMLPostInitializationEvent init) { - MLPCommonProxy.getInstance().setForgeHooks(new ForgePonyHooks()); - } -} diff --git a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java index 8aa35671..e47f176f 100644 --- a/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/minelittlepony/renderer/layer/LayerPonyArmor.java @@ -1,9 +1,8 @@ package com.minelittlepony.renderer.layer; import com.google.common.collect.Maps; -import com.minelittlepony.MineLittlePony; +import com.minelittlepony.ForgeProxy; import com.minelittlepony.ducks.IRenderPony; -import com.minelittlepony.forge.IForgeHooks; import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.pony.ModelHumanPlayer; @@ -64,14 +63,18 @@ public class LayerPonyArmor implements LayerRenderer { if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); - boolean isLegs = armorSlot == EntityEquipmentSlot.LEGS; - AbstractPonyModel modelbase = isLegs ? pony.getArmor().modelArmor : pony.getArmor().modelArmorChestplate; - modelbase = getArmorModel(entity, itemstack, isLegs ? 2 : 1, modelbase); + AbstractPonyModel modelbase; + if (armorSlot == EntityEquipmentSlot.LEGS) { + modelbase = pony.getArmor().modelArmor; + } else { + modelbase = pony.getArmor().modelArmorChestplate; + } + modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); modelbase.setModelAttributes(this.pony.getModel()); modelbase.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity); - Tuple armors = getArmorTexture(entity, itemstack, isLegs ? 2 : 1, null); + Tuple armors = getArmorTexture(entity, itemstack, armorSlot, null); prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond()); this.renderer.bindTexture(armors.getFirst()); @@ -82,7 +85,7 @@ public class LayerPonyArmor implements LayerRenderer { float f9 = (j & 255) / 255.0F; GlStateManager.color(f7, f8, f9, 1); modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - armors = getArmorTexture(entity, itemstack, isLegs ? 2 : 1, "overlay"); + armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); this.renderer.bindTexture(armors.getFirst()); } GlStateManager.color(1, 1, 1, 1); @@ -94,7 +97,7 @@ public class LayerPonyArmor implements LayerRenderer { } } - private Tuple getArmorTexture(EntityLivingBase entity, ItemStack itemstack, int slot, String type) { + private Tuple getArmorTexture(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, String type) { ItemArmor item = (ItemArmor) itemstack.getItem(); String texture = item.getArmorMaterial().getName(); String domain = "minecraft"; @@ -103,7 +106,7 @@ public class LayerPonyArmor implements LayerRenderer { domain = texture.substring(0, idx); texture = texture.substring(idx + 1); } - String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (slot == 2 ? 2 : 1), + String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, slot == EntityEquipmentSlot.LEGS ? 2 : 1, type == null ? "" : String.format("_%s", type)); s1 = getArmorTexture(entity, itemstack, s1, slot, type); ResourceLocation human = getHumanResource(s1); @@ -230,22 +233,16 @@ public class LayerPonyArmor implements LayerRenderer { return pony; } - private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, int slot, String type) { - IForgeHooks armor = MineLittlePony.getProxy().getHooks(); - if (armor != null) { - return armor.getArmorTexture(entity, item, def, slot, type); - } - return def; + private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, EntityEquipmentSlot slot, String type) { + return ForgeProxy.getArmorTexture(entity, item, def, slot, type); } - private static AbstractPonyModel getArmorModel(EntityLivingBase entity, ItemStack itemstack, int slot, AbstractPonyModel def) { - IForgeHooks armor = MineLittlePony.getProxy().getHooks(); - if (armor != null) { - ModelBase model = armor.getArmorModel(entity, itemstack, slot, def); - if (model instanceof ModelPonyArmor) { - return (AbstractPonyModel) model; - } + private static AbstractPonyModel getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, AbstractPonyModel def) { + ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def); + if (model instanceof ModelPonyArmor) { + return (AbstractPonyModel) model; } + return def; }