MineLittlePony/src/main/java/com/minelittlepony/ForgeProxy.java

66 lines
2.2 KiB
Java
Raw Normal View History

package com.minelittlepony;
import com.mumfrey.liteloader.util.ModUtilities;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.ForgeHooksClient;
2017-06-13 05:55:50 +02:00
import javax.annotation.Nullable;
import java.util.Optional;
import java.util.function.Function;
2017-06-13 05:55:50 +02:00
/**
* Proxy class for accessing forge fields and methods.
*/
public class ForgeProxy {
/**
* True if forge is present.
*/
private static boolean forgeLoaded = ModUtilities.fmlIsPresent();
/**
* Gets the mod armour texture for 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, EntityEquipmentSlot slot, @Nullable String type) {
if (forgeLoaded)
return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);
return def;
}
/**
* Gets the mod armour texture for 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 ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
if (forgeLoaded)
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
return def;
}
public static Optional<Function<RenderManager,LayerRenderer<EntityPlayer>>> createShoulderLayer() {
if (forgeLoaded) {
// TODO
}
return Optional.empty();
}
}