Remove ForgeHooks

This commit is contained in:
Sollace 2020-02-22 16:57:35 +02:00
parent a76c1c56b0
commit 47f63f1825
3 changed files with 12 additions and 76 deletions

View file

@ -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 <T extends LivingEntity> BipedEntityModel<T> getArmorModel(T entity, ItemStack item, EquipmentSlot slot, BipedEntityModel<T> def) {
/*if (MineLPClient.getInstance().getModUtilities().hasFml()) {
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
}*/
return def;
}
}

View file

@ -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<T extends LivingEntity> implements IArmourTextureResolver<T> {
private final Map<String, Identifier> HUMAN_ARMOUR = Maps.newHashMap();
private final Map<Identifier, Identifier> PONY_ARMOUR = Maps.newHashMap();
private final Map<String, Identifier> HUMAN_ARMOUR = new HashMap<>();
private final Map<Identifier, Identifier> 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<T extends LivingEntity> 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<T extends LivingEntity> 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);

View file

@ -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<T extends LivingEntity, M extends EntityModel<T> & IP
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ArmorItem) {
V armour = ArmourFeature.getArmorModel(entity, itemstack, armorSlot, layer, pony.<V>getArmor().getArmorForLayer(layer));
V armour = pony.<V>getArmor().getArmorForLayer(layer);
if (armour.prepareToRender(armorSlot, layer)) {
pony.getBody().copyAttributes(armour);
@ -94,19 +92,4 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & IP
}
}
}
@SuppressWarnings("unchecked")
private static <T extends LivingEntity, V extends BipedEntityModel<T> & IArmour> V getArmorModel(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, V def) {
BipedEntityModel<T> model = ForgeProxy.getArmorModel(entity, itemstack, slot, def);
if (model instanceof IArmour) {
return (V)model;
}
if (model instanceof IEquestrianArmour) {
return ((IEquestrianArmour<V>) model).getArmorForLayer(layer);
}
return def;
}
}