[1.12.x] Implement hooks allowing mods to add horse armor. Partially addresses #3975. (#3994)

This commit is contained in:
Daomephsta authored and LexManos committed 2018-01-18 12:04:37 -08:00
1 parent 61a16066e5
commit adf3c7164a
11 files changed
+278 -5

No files matched your search

@@ -75,6 +75,8 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.HorseArmorType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
@@ -754,4 +756,11 @@ public class ForgeHooksClient
{
MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput));
}
public static String getHorseArmorTexture(EntityHorse horse, ItemStack armorStack)
{
String texture = armorStack.getItem().getHorseArmorTexture(horse, armorStack);
if(texture == null) texture = horse.getHorseArmorType().getTextureName();
return texture;
}
}
@@ -34,6 +34,7 @@ import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityPainting.EnumArt;
import net.minecraft.entity.passive.HorseArmorType;
import net.minecraft.entity.player.EntityPlayer.SleepResult;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
@@ -74,7 +75,8 @@ public class EnumHelper
{EnumSkyBlock.class, int.class},
{SleepResult.class},
{ToolMaterial.class, int.class, int.class, float.class, float.class, int.class},
{EnumRarity.class, TextFormatting.class, String.class}
{EnumRarity.class, TextFormatting.class, String.class},
{HorseArmorType.class, String.class, int.class}
};
@Nullable
@@ -143,6 +145,19 @@ public class EnumHelper
return addEnum(EnumRarity.class, name, color, displayName);
}
/**
*
* @param name the name of the new {@code HorseArmorType}
* @param textureLocation the path to the texture for this armor type. It must follow the format domain:path and be relative to the assets folder.
* @param armorStrength how much protection this armor type should give
* @return the new {@code HorseArmorType}, or null if it could not be created
*/
@Nullable
public static HorseArmorType addHorseArmor(String name, String textureLocation, int armorStrength)
{
return addEnum(HorseArmorType.class, name, textureLocation, armorStrength);
}
private static void setup()
{
if (isSetup)