From 47f63f1825297ca70f3c4d315ed3207e01e54a08 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 22 Feb 2020 16:57:35 +0200 Subject: [PATCH] Remove ForgeHooks --- .../com/minelittlepony/client/ForgeProxy.java | 46 ------------------- .../armour/DefaultArmourTextureResolver.java | 23 +++++----- .../render/entity/feature/ArmourFeature.java | 19 +------- 3 files changed, 12 insertions(+), 76 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/client/ForgeProxy.java diff --git a/src/main/java/com/minelittlepony/client/ForgeProxy.java b/src/main/java/com/minelittlepony/client/ForgeProxy.java deleted file mode 100644 index 7af26738..00000000 --- a/src/main/java/com/minelittlepony/client/ForgeProxy.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.minelittlepony.client; - -import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; - -import javax.annotation.Nullable; - -/** - * Proxy class for accessing forge fields and methods. - */ -public class ForgeProxy { - - /** - * 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, EquipmentSlot slot, @Nullable String type) { - /*if (MineLPClient.getInstance().getModUtilities().hasFml()) - 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 BipedEntityModel getArmorModel(T entity, ItemStack item, EquipmentSlot slot, BipedEntityModel def) { - /*if (MineLPClient.getInstance().getModUtilities().hasFml()) { - return ForgeHooksClient.getArmorModel(entity, item, slot, def); - }*/ - return def; - } -} diff --git a/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java b/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java index 4b26b12a..32075675 100644 --- a/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java +++ b/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java @@ -9,8 +9,6 @@ import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; import com.google.common.base.Strings; -import com.google.common.collect.Maps; -import com.minelittlepony.client.ForgeProxy; import com.minelittlepony.model.armour.ArmourLayer; import com.minelittlepony.model.armour.ArmourVariant; import com.minelittlepony.model.armour.IArmourTextureResolver; @@ -19,15 +17,18 @@ import javax.annotation.Nullable; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.HashMap; import java.util.Map; public class DefaultArmourTextureResolver implements IArmourTextureResolver { - private final Map HUMAN_ARMOUR = Maps.newHashMap(); - private final Map PONY_ARMOUR = Maps.newHashMap(); + private final Map HUMAN_ARMOUR = new HashMap<>(); + private final Map PONY_ARMOUR = new HashMap<>(); @Override public Identifier getArmourTexture(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type) { + type = Strings.nullToEmpty(type); + ArmorItem item = (ArmorItem) itemstack.getItem(); String texture = item.getMaterial().getName(); @@ -39,15 +40,15 @@ public class DefaultArmourTextureResolver implements IAr texture = texture.substring(idx + 1); } - String customType = type == null ? "" : String.format("_%s", type); + String customType = type.isEmpty() ? "" : String.format("_%s", type); String ponyRes = String.format("%s:textures/models/armor/%s_layer_%s%s.png", domain, texture, layer.name().toLowerCase(), customType); String oldPonyRes = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, layer == ArmourLayer.INNER ? 2 : 1, customType); - Identifier human = getArmorTexture(entity, itemstack, ponyRes, slot, type); + Identifier human = getArmorTexture(ponyRes, type); Identifier pony = ponifyResource(human); - Identifier oldHuman = getArmorTexture(entity, itemstack, oldPonyRes, slot, type); + Identifier oldHuman = getArmorTexture(oldPonyRes, type); Identifier oldPony = ponifyResource(oldHuman); return resolve(pony, oldPony, oldHuman, human); @@ -78,15 +79,13 @@ public class DefaultArmourTextureResolver implements IAr }); } - private Identifier getArmorTexture(T entity, ItemStack item, String def, EquipmentSlot slot, @Nullable String type) { + private Identifier getArmorTexture(String def, @Nullable String type) { - String modTexture = Strings.nullToEmpty(ForgeProxy.getArmorTexture(entity, item, def, slot, type)); - - if (modTexture.isEmpty() || modTexture.equals(def)) { + if (type.isEmpty() || type.equals(def)) { return HUMAN_ARMOUR.computeIfAbsent(def, Identifier::new); } - return HUMAN_ARMOUR.computeIfAbsent(modTexture, s -> { + return HUMAN_ARMOUR.computeIfAbsent(type, s -> { Identifier modId = new Identifier(s); Identifier defId = new Identifier(def); diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java index c1e14f8b..0512fb34 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/ArmourFeature.java @@ -1,6 +1,5 @@ package com.minelittlepony.client.render.entity.feature; -import com.minelittlepony.client.ForgeProxy; import com.minelittlepony.client.model.IPonyModel; import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.armour.DefaultArmourTextureResolver; @@ -8,7 +7,6 @@ import com.minelittlepony.client.render.IPonyRenderContext; import com.minelittlepony.model.armour.ArmourLayer; import com.minelittlepony.model.armour.IArmour; import com.minelittlepony.model.armour.IArmourTextureResolver; -import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.util.Color; import net.minecraft.client.render.OverlayTexture; @@ -53,7 +51,7 @@ public class ArmourFeature & IP if (!itemstack.isEmpty() && itemstack.getItem() instanceof ArmorItem) { - V armour = ArmourFeature.getArmorModel(entity, itemstack, armorSlot, layer, pony.getArmor().getArmorForLayer(layer)); + V armour = pony.getArmor().getArmorForLayer(layer); if (armour.prepareToRender(armorSlot, layer)) { pony.getBody().copyAttributes(armour); @@ -94,19 +92,4 @@ public class ArmourFeature & IP } } } - - @SuppressWarnings("unchecked") - private static & IArmour> V getArmorModel(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, V def) { - BipedEntityModel model = ForgeProxy.getArmorModel(entity, itemstack, slot, def); - - if (model instanceof IArmour) { - return (V)model; - } - - if (model instanceof IEquestrianArmour) { - return ((IEquestrianArmour) model).getArmorForLayer(layer); - } - - return def; - } }