Fix crash when SmartRenderer not installed.
This commit is contained in:
parent
ee386d1158
commit
eb3f4aa016
|
@ -5,6 +5,5 @@ import net.machinemuse.api.electricity.IModularItem;
|
||||||
/**
|
/**
|
||||||
* Ported to Java by lehjr on 11/4/16.
|
* Ported to Java by lehjr on 11/4/16.
|
||||||
*/
|
*/
|
||||||
public interface IArmorTraits extends IModularItem, IApiaristArmor
|
public interface IArmorTraits extends IModularItem, IApiaristArmor {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,28 @@
|
||||||
package net.machinemuse.powersuits.client.render.item;
|
package net.machinemuse.powersuits.client.render.item;
|
||||||
|
|
||||||
import net.machinemuse.numina.general.MuseLogger;
|
import net.machinemuse.numina.general.MuseLogger;
|
||||||
|
import net.machinemuse.powersuits.common.ModCompatibility;
|
||||||
import net.minecraft.client.model.ModelBiped;
|
import net.minecraft.client.model.ModelBiped;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: MachineMuse (Claire Semple)
|
* Author: MachineMuse (Claire Semple)
|
||||||
* Created: 10:01 PM, 11/07/13
|
* Created: 10:01 PM, 11/07/13
|
||||||
*/
|
*/
|
||||||
public class ArmorModelInstance {
|
public class ArmorModelInstance {
|
||||||
private static ModelBiped instance = null;
|
private static ModelBiped instance = null;
|
||||||
private static NBTTagCompound renderSpec;
|
|
||||||
|
|
||||||
public static ModelBiped getInstance() {
|
public static ModelBiped getInstance() {
|
||||||
// TODO: Actual (skinned) vanilla model as low bandwitdth alternative
|
// TODO: Actual (skinned) vanilla model as low bandwitdth alternative
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
try {
|
if ( ModCompatibility.isRenderPlayerAPILoaded()) {
|
||||||
MuseLogger.logInfo("Attempting to load Smart Moving armor model.");
|
try {
|
||||||
instance = SMovingArmorModel.getInstance();
|
MuseLogger.logInfo("Attempting to load SmartMoving armor model.");
|
||||||
MuseLogger.logInfo("Smart Moving armor model loaded successfully!");
|
instance = Class.forName("net.machinemuse.powersuits.client.render.item.SMovingArmorModel").asSubclass(ModelBiped.class).newInstance();
|
||||||
} catch (Throwable e) {
|
MuseLogger.logInfo("SmartMoving armor model loaded successfully!");
|
||||||
MuseLogger.logInfo("Smart Moving armor model did not load successfully. Either Smart Moving is not installed, or there was another problem.");
|
} catch (Exception e) {
|
||||||
|
MuseLogger.logInfo("Smart Moving armor model did not load successfully. Either Smart Moving is not installed, or there was another problem.");
|
||||||
|
instance = VanillaArmorModel.getInstance();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
instance = VanillaArmorModel.getInstance();
|
instance = VanillaArmorModel.getInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.machinemuse.powersuits.client.render.item;
|
package net.machinemuse.powersuits.client.render.item;
|
||||||
|
|
||||||
import api.player.model.ModelPlayer;
|
import api.player.model.ModelPlayer;
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import net.machinemuse.powersuits.client.render.modelspec.RenderPart;
|
import net.machinemuse.powersuits.client.render.modelspec.RenderPart;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -24,7 +25,7 @@ public class SMovingArmorModel extends ModelPlayer implements IArmorModel {
|
||||||
public static int visibleSection = 0;
|
public static int visibleSection = 0;
|
||||||
private SmartRenderModelPlayerBase renderPlayerBase = SmartRender.getPlayerBase(this);
|
private SmartRenderModelPlayerBase renderPlayerBase = SmartRender.getPlayerBase(this);
|
||||||
|
|
||||||
private SMovingArmorModel() {
|
public SMovingArmorModel() {
|
||||||
super(0);
|
super(0);
|
||||||
|
|
||||||
SmartRenderModel model = renderPlayerBase.getRenderModel();
|
SmartRenderModel model = renderPlayerBase.getRenderModel();
|
||||||
|
|
|
@ -86,6 +86,9 @@ public class Config {
|
||||||
/**
|
/**
|
||||||
* Called in post-init. Extracts recipes if the configuration value is not found.
|
* Called in post-init. Extracts recipes if the configuration value is not found.
|
||||||
*/
|
*/
|
||||||
|
// TODO: a better idea might be to extract all of the recipes and then only read the ones that are valid.
|
||||||
|
// This would save on requests for recipe downloads
|
||||||
|
|
||||||
public static void extractRecipes() {
|
public static void extractRecipes() {
|
||||||
String key = "Auto-extract recipes";
|
String key = "Auto-extract recipes";
|
||||||
if (!config.hasKey(Configuration.CATEGORY_GENERAL, key) || config.get(Configuration.CATEGORY_GENERAL, key, false).getBoolean()) {
|
if (!config.hasKey(Configuration.CATEGORY_GENERAL, key) || config.get(Configuration.CATEGORY_GENERAL, key, false).getBoolean()) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package net.machinemuse.powersuits.common;
|
package net.machinemuse.powersuits.common;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
import cpw.mods.fml.common.ModAPIManager;
|
import cpw.mods.fml.common.ModAPIManager;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.electricity.IModularItem;
|
import net.machinemuse.api.electricity.IModularItem;
|
||||||
import net.machinemuse.numina.general.MuseLogger;
|
import net.machinemuse.numina.general.MuseLogger;
|
||||||
|
@ -81,6 +83,10 @@ public class ModCompatibility {
|
||||||
return Loader.isModLoaded("CompactMachines");
|
return Loader.isModLoaded("CompactMachines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isRenderPlayerAPILoaded() {
|
||||||
|
return Loader.isModLoaded("RenderPlayerAPI");
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean enableThaumGogglesModule() {
|
public static boolean enableThaumGogglesModule() {
|
||||||
boolean defaultval = isThaumCraftLoaded();
|
boolean defaultval = isThaumCraftLoaded();
|
||||||
return Config.getConfig().get("Special Modules", "Thaumcraft Goggles Module", defaultval).getBoolean(defaultval);
|
return Config.getConfig().get("Special Modules", "Thaumcraft Goggles Module", defaultval).getBoolean(defaultval);
|
||||||
|
|
|
@ -37,17 +37,17 @@ import java.util.UUID;
|
||||||
* Ported to Java by lehjr on 11/4/16.
|
* Ported to Java by lehjr on 11/4/16.
|
||||||
*/
|
*/
|
||||||
public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpecialArmor, IArmorTraits {
|
public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpecialArmor, IArmorTraits {
|
||||||
public ItemPowerArmor(final int renderIndex, final int armorType) {
|
public ItemPowerArmor(int renderIndex, int armorType) {
|
||||||
super(ItemArmor.ArmorMaterial.IRON, renderIndex, armorType);
|
super(ItemArmor.ArmorMaterial.IRON, renderIndex, armorType);
|
||||||
this.setMaxStackSize(1);
|
this.setMaxStackSize(1);
|
||||||
this.setCreativeTab(Config.getCreativeTab());
|
this.setCreativeTab(Config.getCreativeTab());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISpecialArmor.ArmorProperties getProperties(final EntityLivingBase player, final ItemStack armor, final DamageSource source, final double damage, final int slot) {
|
public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||||
final int priority = 0;
|
int priority = 0;
|
||||||
Label_0057: {
|
Label_0057: {
|
||||||
if (source.isFireDamage()) {
|
if (source.isFireDamage()) {
|
||||||
final DamageSource overheatDamage = MuseHeatUtils.overheatDamage;
|
DamageSource overheatDamage = MuseHeatUtils.overheatDamage;
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
if (overheatDamage == null) {
|
if (overheatDamage == null) {
|
||||||
break Label_0057;
|
break Label_0057;
|
||||||
|
@ -69,7 +69,7 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
else {
|
else {
|
||||||
armorDouble2 = 2.0;
|
armorDouble2 = 2.0;
|
||||||
}
|
}
|
||||||
final double armorDouble = armorDouble2;
|
double armorDouble = armorDouble2;
|
||||||
double absorbRatio = 0.04 * armorDouble;
|
double absorbRatio = 0.04 * armorDouble;
|
||||||
int absorbMax = (int)armorDouble * 75;
|
int absorbMax = (int)armorDouble * 75;
|
||||||
if (source.isUnblockable()) {
|
if (source.isUnblockable()) {
|
||||||
|
@ -79,18 +79,18 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
return new ISpecialArmor.ArmorProperties(priority, absorbRatio, absorbMax);
|
return new ISpecialArmor.ArmorProperties(priority, absorbRatio, absorbMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArmorTexture(final ItemStack itemstack, final Entity entity, final int slot, final int layer) {
|
public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, int layer) {
|
||||||
return Config.BLANK_ARMOR_MODEL_PATH;
|
return Config.BLANK_ARMOR_MODEL_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor(final ItemStack stack) {
|
public int getColor(ItemStack stack) {
|
||||||
final Colour c = this.getColorFromItemStack(stack);
|
Colour c = this.getColorFromItemStack(stack);
|
||||||
return c.getInt();
|
return c.getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public ModelBiped getArmorModel(final EntityLivingBase entity, final ItemStack itemstack, final int armorSlot) {
|
public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack itemstack, int armorSlot) {
|
||||||
final ModelBiped model = ArmorModelInstance.getInstance();
|
ModelBiped model = ArmorModelInstance.getInstance();
|
||||||
((IArmorModel)model).setVisibleSection(armorSlot);
|
((IArmorModel)model).setVisibleSection(armorSlot);
|
||||||
if (itemstack != null) {
|
if (itemstack != null) {
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
|
@ -111,8 +111,8 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
return (ModelBiped)model;
|
return (ModelBiped)model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Multimap<?, ?> getAttributeModifiers(final ItemStack stack) {
|
public Multimap<?, ?> getAttributeModifiers(ItemStack stack) {
|
||||||
final Multimap parent = super.getAttributeModifiers(stack);
|
Multimap parent = super.getAttributeModifiers(stack);
|
||||||
parent.put((Object)"generic.knockbackResistance", (Object)new AttributeModifier(UUID.fromString("448ef0e9-9b7c-4e56-bf3a-6b52aeabff8d"), "generic.knockbackResistance", 0.25, 0));
|
parent.put((Object)"generic.knockbackResistance", (Object)new AttributeModifier(UUID.fromString("448ef0e9-9b7c-4e56-bf3a-6b52aeabff8d"), "generic.knockbackResistance", 0.25, 0));
|
||||||
return (Multimap<?, ?>)parent;
|
return (Multimap<?, ?>)parent;
|
||||||
}
|
}
|
||||||
|
@ -121,27 +121,27 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasColor(final ItemStack stack) {
|
public boolean hasColor(ItemStack stack) {
|
||||||
final NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
NBTTagCompound itemTag = MuseItemUtils.getMuseItemTag(stack);
|
||||||
return ModuleManager.tagHasModule(itemTag, "Red Tint") || ModuleManager.tagHasModule(itemTag, "Green Tint") || ModuleManager.tagHasModule(itemTag, "Blue Tint");
|
return ModuleManager.tagHasModule(itemTag, "Red Tint") || ModuleManager.tagHasModule(itemTag, "Green Tint") || ModuleManager.tagHasModule(itemTag, "Blue Tint");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getArmorDisplay(final EntityPlayer player, final ItemStack armor, final int slot) {
|
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||||
return (int)this.getArmorDouble(player, armor);
|
return (int)this.getArmorDouble(player, armor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getHeatResistance(final EntityPlayer player, final ItemStack stack) {
|
public double getHeatResistance(EntityPlayer player, ItemStack stack) {
|
||||||
return MuseHeatUtils.getMaxHeat(stack);
|
return MuseHeatUtils.getMaxHeat(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getArmorDouble(final EntityPlayer player, final ItemStack stack) {
|
public double getArmorDouble(EntityPlayer player, ItemStack stack) {
|
||||||
double totalArmor = 0.0;
|
double totalArmor = 0.0;
|
||||||
final NBTTagCompound props = MuseItemUtils.getMuseItemTag(stack);
|
NBTTagCompound props = MuseItemUtils.getMuseItemTag(stack);
|
||||||
final double energy = ElectricItemUtils.getPlayerEnergy(player);
|
double energy = ElectricItemUtils.getPlayerEnergy(player);
|
||||||
final double physArmor = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_VALUE_PHYSICAL);
|
double physArmor = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_VALUE_PHYSICAL);
|
||||||
final double enerArmor = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_VALUE_ENERGY);
|
double enerArmor = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_VALUE_ENERGY);
|
||||||
final double enerConsum = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_ENERGY_CONSUMPTION);
|
double enerConsum = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_ENERGY_CONSUMPTION);
|
||||||
totalArmor += physArmor;
|
totalArmor += physArmor;
|
||||||
if (energy > enerConsum) {
|
if (energy > enerConsum) {
|
||||||
totalArmor += enerArmor;
|
totalArmor += enerArmor;
|
||||||
|
@ -154,10 +154,10 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
* Inherited from ISpecialArmor, allows us to customize how the armor
|
* Inherited from ISpecialArmor, allows us to customize how the armor
|
||||||
* handles being damaged.
|
* handles being damaged.
|
||||||
*/
|
*/
|
||||||
public void damageArmor(final EntityLivingBase entity, final ItemStack stack, final DamageSource source, final int damage, final int slot) {
|
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
|
||||||
final NBTTagCompound itemProperties = MuseItemUtils.getMuseItemTag(stack);
|
NBTTagCompound itemProperties = MuseItemUtils.getMuseItemTag(stack);
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
final DamageSource overheatDamage = MuseHeatUtils.overheatDamage;
|
DamageSource overheatDamage = MuseHeatUtils.overheatDamage;
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
if (overheatDamage == null) {
|
if (overheatDamage == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -167,14 +167,14 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (source.isFireDamage()) {
|
if (source.isFireDamage()) {
|
||||||
final EntityPlayer player = (EntityPlayer)entity;
|
EntityPlayer player = (EntityPlayer)entity;
|
||||||
if (!source.equals(DamageSource.onFire) || MuseHeatUtils.getPlayerHeat(player) < MuseHeatUtils.getMaxHeat(player)) {
|
if (!source.equals(DamageSource.onFire) || MuseHeatUtils.getPlayerHeat(player) < MuseHeatUtils.getMaxHeat(player)) {
|
||||||
MuseHeatUtils.heatPlayer(player, damage);
|
MuseHeatUtils.heatPlayer(player, damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final double enerConsum = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_ENERGY_CONSUMPTION);
|
double enerConsum = ModuleManager.computeModularProperty(stack, MuseCommonStrings.ARMOR_ENERGY_CONSUMPTION);
|
||||||
final double drain = enerConsum * damage;
|
double drain = enerConsum * damage;
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
ElectricItemUtils.drainPlayerEnergy((EntityPlayer)entity, drain);
|
ElectricItemUtils.drainPlayerEnergy((EntityPlayer)entity, drain);
|
||||||
}
|
}
|
||||||
|
@ -186,12 +186,12 @@ public abstract class ItemPowerArmor extends ItemElectricArmor implements ISpeci
|
||||||
}
|
}
|
||||||
|
|
||||||
@Optional.Method(modid = "Forestry")
|
@Optional.Method(modid = "Forestry")
|
||||||
public boolean protectPlayer(final EntityPlayer player, final ItemStack armor, final String cause, final boolean doProtect) {
|
public boolean protectPlayer(EntityPlayer player, ItemStack armor, String cause, boolean doProtect) {
|
||||||
return ApiaristArmor.getInstance().protectPlayer(player, armor, cause, doProtect);
|
return ApiaristArmor.getInstance().protectPlayer(player, armor, cause, doProtect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Optional.Method(modid = "Forestry")
|
@Optional.Method(modid = "Forestry")
|
||||||
public boolean protectEntity(final EntityLivingBase player, final ItemStack armor, final String cause, final boolean doProtect) {
|
public boolean protectEntity(EntityLivingBase player, ItemStack armor, String cause, boolean doProtect) {
|
||||||
return ApiaristArmor.getInstance().protectEntity(player, armor, cause, doProtect);
|
return ApiaristArmor.getInstance().protectEntity(player, armor, cause, doProtect);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue