Fixing Stuff

Fixes #101
Fixes #100
This commit is contained in:
Jeremy Diamond committed 2016-03-30 18:18:56 -07:00
1 parent cf789e46ad
commit 821a18910f
81 files changed
+2631 -439

No files matched your search

@@ -60,7 +60,6 @@ public class Config {
public static boolean special = true;
public static boolean twilight = true;
public static boolean emc = true;
public static boolean dargon = true;
//public static boolean eewand = true;
public static int bloodvis = 5;
@@ -127,7 +126,6 @@ public class Config {
tc = conf.get("compatibility", "Tinkers Construct Interaction", tc).getBoolean(true);
special = conf.get("compatibility", "Special Mobs Interaction", special).getBoolean(true);
twilight = conf.get("compatibility", "Twilight Forest Interaction", twilight).getBoolean(true);
dargon = conf.get("compatibility", "Draconic Evolution Interaction", dargon).getBoolean(true);
emc = conf.get("compatibility", "Equivalent Exchange 3 EMC", emc, "Disable if you don't want Forbidden Magic to add EMC values to items.").getBoolean(true);
//eewand = conf.get("compatibility", "Equivalent Exchange 3 Wand", eewand, "Disable to specifically disable the EMC to Vis wand.").getBoolean(true);
@@ -267,7 +267,7 @@ public class FMEventHandler {
learning -= xp;
event.entityLiving.worldObj.spawnEntityInWorld(new EntityXPOrb(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, xp));
}
} catch (Exception e) {
} catch (Throwable e) {
LogHandler.log(Level.ERROR, "Failed to educate!");
}
}
@@ -58,7 +58,7 @@ public class Forbidden {
ForbiddenItems.addItems();
ForbiddenBlocks.addBlocks();
DarkEnchantments.hex();
if(Compat.bm || Compat.dargon)
if(Compat.bm)
DarkPotions.alchemize();
proxy.registerRenderInfo();
}
@@ -2,35 +2,27 @@ package fox.spiteful.forbidden;
import java.lang.reflect.Field;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.entity.EntityLiving;
import org.apache.logging.log4j.Level;
public class XPReflectionHelper {
private static Field getField(Class clazz, String field) throws NoSuchFieldException {
public static Field stupidMojangProtectedVariable;
static {
try {
return clazz.getDeclaredField(field);
} catch (NoSuchFieldException e) {
Class superClass = clazz.getSuperclass();
if (superClass == null) {
throw e;
} else {
return getField(superClass, field);
}
stupidMojangProtectedVariable = ReflectionHelper.findField(EntityLiving.class, "experienceValue", "field_70728_aV");
stupidMojangProtectedVariable.setAccessible(true);
}
catch(Exception e){
LogHandler.log(Level.ERROR, e.toString());
e.printStackTrace();
}
}
public static int getXP(EntityLiving entityLiving) {
try {
Field f = getField(entityLiving.getClass(), "experienceValue");
f.setAccessible(true);
return (Integer) f.get(entityLiving);
} catch (NoSuchFieldException e) {
try {
Field f = getField(entityLiving.getClass(), "field_70728_aV");
f.setAccessible(true);
return (Integer) f.get(entityLiving);
} catch (Exception e2) {
return 0;
}
return stupidMojangProtectedVariable.getInt(entityLiving);
} catch (Exception e) {
e.printStackTrace();
}
@@ -3,9 +3,7 @@ package fox.spiteful.forbidden.compat;
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
import fox.spiteful.forbidden.*;
import fox.spiteful.forbidden.blocks.ForbiddenBlocks;
import fox.spiteful.forbidden.items.tools.ItemDragonslayer;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
@@ -34,7 +32,6 @@ public class Compat {
public static boolean special = false;
public static boolean twilight = false;
public static boolean ee3 = false;
public static boolean dargon = false;
public static void initiate() {
if(!Config.crossMod)
@@ -48,7 +45,6 @@ public class Compat {
special = Config.wrathCage && Config.special && Loader.isModLoaded("SpecialMobs");
twilight = Config.wrathCage && Config.twilight && Loader.isModLoaded("TwilightForest");
ee3 = (Config.emc /* || Config.eewand*/) && Loader.isModLoaded("EE3");
dargon = Config.dargon && Loader.isModLoaded("DraconicEvolution");
}
public static void compatify() {
@@ -384,29 +380,6 @@ public class Compat {
Config.spawnerMobs.put("TwilightForest.WinterWolf", Aspect.COLD);
}
if(dargon){
try {
Item ingot = Items.iron_ingot;
Item sword = Items.iron_sword;
if(twilight){
try {
ingot = getItem("TwilightForest", "item.knightMetal");
sword = getItem("TwilightForest", "item.knightlySword");
}catch (Exception e){
LogHandler.log(Level.INFO, e, "Forbidden Magic couldn't figure out Twilight Forest's progression.");
twilight = false;
}
}
((ItemDragonslayer)ForbiddenItems.dragonslayer).repair = ingot;
InfusionRecipe dragonslayer_recipe = ThaumcraftApi.addInfusionCraftingRecipe("DRAGONSLAYER", new ItemStack(ForbiddenItems.dragonslayer, 1), 6, (new AspectList()).add(Aspect.LIGHT, 16).add(Aspect.ORDER, 8).add(Aspect.MAN, 16).add(Aspect.METAL, 32), new ItemStack(sword), new ItemStack[]{new ItemStack(Items.nether_star, 1), new ItemStack(Items.golden_helmet, 1, 0), new ItemStack(Items.writable_book, 1), new ItemStack(Items.ender_pearl, 1, 2)});
(new DarkResearchItem("DRAGONSLAYER", "FORBIDDEN", "[DE]", (new AspectList()).add(Aspect.WEAPON, 16).add(Aspect.ARMOR, 8).add(Aspect.MIND, 4), 2, -6, 3, new ItemStack(ForbiddenItems.dragonslayer, 1))).setPages(new ResearchPage[]{new ResearchPage("forbidden.research_page.DRAGONSLAYER.1"), new ResearchPage(dragonslayer_recipe)}).setParents("INFUSION").setConcealed().registerResearchItem();
} catch (Exception e) {
LogHandler.log(Level.INFO, e, "Forbidden Magic wasn't unbalanced enough for Draconic Evolution.");
dargon = false;
}
}
}
public static Item getItem(String mod, String item) throws ItemNotFoundException {
@@ -1,21 +1,30 @@
package fox.spiteful.forbidden.compat;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.subtile.SubTileEntity;
import vazkii.botania.api.subtile.SubTileFunctional;
import vazkii.botania.api.subtile.SubTileGenerating;
import vazkii.botania.api.subtile.signature.BasicSignature;
import vazkii.botania.api.subtile.signature.SubTileSignature;
public class DarkSignature extends SubTileSignature {
String name;
import java.util.List;
public class DarkSignature extends BasicSignature {
IIcon icon;
public DarkSignature(String nombre){
name = nombre;
public DarkSignature(String name){
super(name);
}
@Override
public void registerIcons(IIconRegister reg){
icon = reg.registerIcon("forbidden:" + name);
icon = reg.registerIcon("forbidden:" + getName());
}
@Override
@@ -25,11 +34,12 @@ public class DarkSignature extends SubTileSignature {
@Override
public String getUnlocalizedNameForStack(ItemStack item){
return "darkflower." + name;
return "darkflower." + getName();
}
@Override
public String getUnlocalizedLoreTextForStack(ItemStack item){
return "tile.darkflower." + name + ".lore";
return "tile.darkflower." + getName() + ".lore";
}
}
@@ -171,16 +171,6 @@ public class ForbiddenItems {
}
}
if(Compat.dargon){
try {
dragonslayer = new ItemDragonslayer().setUnlocalizedName("Sword_Dragonslayer");
GameRegistry.registerItem(dragonslayer, "Dragonslayer");
}
catch (Throwable e){
Compat.dargon = false;
}
}
crystalwell = new ItemCrystalwell().setUnlocalizedName("Crystalwell");
GameRegistry.registerItem(crystalwell, "Crystalwell");
@@ -78,10 +78,11 @@ public class ItemRingNutrition extends Item implements IRunicArmor, IBauble, ICo
@Override
public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) {
if(cosmetic == null || stack == null)
if(stack == null)
return;
NBTTagCompound cmp = new NBTTagCompound();
cosmetic.writeToNBT(cmp);
if(cosmetic != null)
cosmetic.writeToNBT(cmp);
NBTTagCompound tag = stack.getTagCompound();
if(tag == null){
tag = new NBTTagCompound();
@@ -145,10 +145,11 @@ public class ItemSubCollar extends ItemAmuletVis implements ICosmeticAttachable
@Override
public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) {
if(cosmetic == null || stack == null)
if(stack == null)
return;
NBTTagCompound cmp = new NBTTagCompound();
cosmetic.writeToNBT(cmp);
if(cosmetic != null)
cosmetic.writeToNBT(cmp);
NBTTagCompound tag = stack.getTagCompound();
if(tag == null){
tag = new NBTTagCompound();
@@ -1,152 +0,0 @@
package fox.spiteful.forbidden.items.tools;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.Forbidden;
import fox.spiteful.forbidden.LogHandler;
import fox.spiteful.forbidden.compat.Compat;
import fox.spiteful.forbidden.potions.DarkPotions;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import org.apache.logging.log4j.Level;
import thaumcraft.api.IRepairable;
public class ItemDragonslayer extends ItemSword implements IRepairable {
public IIcon icon;
public Item repair;
public ItemDragonslayer() {
super(ToolMaterial.EMERALD);
this.setCreativeTab(Forbidden.tab);
MinecraftForge.EVENT_BUS.register(this);
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister ir) {
this.icon = ir.registerIcon("forbidden:dragonslayer");
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIconFromDamage(int par1) {
return this.icon;
}
@Override
public EnumRarity getRarity(ItemStack itemstack) {
return EnumRarity.epic;
}
@Override
public boolean getIsRepairable(ItemStack stack, ItemStack stack2) {
return stack2.getItem() == repair || super.getIsRepairable(stack, stack2);
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
stack.damageItem(1, player);
if (!victim.worldObj.isRemote && Compat.dargon & isDragon(victim)) {
absoluteDamage(victim, new EntityDamageSource("dragonslayer", player).setDamageBypassesArmor(), Math.max(4F, victim.getMaxHealth() / 5F));
if(victim instanceof EntityPlayer) {
EntityPlayer target = (EntityPlayer)victim;
for(int x = 0;x < 5;x++){
if(target.getEquipmentInSlot(x) != null){
ItemStack equip = target.getEquipmentInSlot(x);
if(equip.getItem() instanceof IEnergyContainerItem){
IEnergyContainerItem battery = (IEnergyContainerItem)equip.getItem();
battery.extractEnergy(equip, battery.getMaxEnergyStored(equip) / 20, false);
}
}
}
}
victim.addPotionEffect(new PotionEffect(DarkPotions.dragonwrack.getId(), 300));
}
return true;
}
public static boolean isDragon(Entity target){
if(target == null)
return false;
if(target instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)target;
for(int x = 1;x < 5;x++){
if(player.getEquipmentInSlot(x) != null){
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(player.getEquipmentInSlot(x).getItem());
if(id != null && id.modId.equals("DraconicEvolution"))
return true;
}
}
}
else if(target instanceof EntityDragon ||
target.getCommandSenderName().toLowerCase().contains("dragon") ||
target.getCommandSenderName().toLowerCase().contains("drake") ||
target.getCommandSenderName().toLowerCase().contains("dracon"))
return true;
return false;
}
public static void absoluteDamage(EntityLivingBase target, DamageSource src, float damage){
target.func_110142_aN().func_94547_a(src, target.getHealth(), damage);
target.setHealth(target.getHealth() - damage);
if(target.getHealth() < 1){
target.onDeath(src);
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onGetHurt(LivingHurtEvent event) {
if(event.entityLiving instanceof EntityPlayer && event.source.getEntity() != null){
EntityPlayer player = (EntityPlayer)event.entityLiving;
ItemStack equip = player.getCurrentEquippedItem();
if(equip != null && equip.getItem() == this && isDragon(event.source.getEntity())){
event.ammount = Math.min(event.ammount, 3F);
}
}
}
@SubscribeEvent
public void onAttacked(LivingAttackEvent event) {
if(event.entityLiving instanceof EntityPlayer && event.source.getEntity() != null){
EntityPlayer player = (EntityPlayer)event.entityLiving;
ItemStack equip = player.getCurrentEquippedItem();
if(equip != null && player.isUsingItem() && equip.getItem() == this && isDragon(event.source.getEntity())){
event.setCanceled(true);
if(event.source.getEntity() instanceof EntityPlayer) {
EntityPlayer other = (EntityPlayer)event.source.getEntity();
other.addPotionEffect(new PotionEffect(DarkPotions.dragonwrack.getId(), 300));
for(int x = 0;x < 5;x++){
if(other.getEquipmentInSlot(x) != null){
ItemStack gear = other.getEquipmentInSlot(x);
if(gear.getItem() instanceof IEnergyContainerItem){
IEnergyContainerItem battery = (IEnergyContainerItem)gear.getItem();
battery.extractEnergy(gear, battery.getMaxEnergyStored(gear) / 50, false);
}
}
}
}
}
}
}
}
@@ -37,13 +37,5 @@ public class DarkPotions {
if(Compat.bm)
bloodSeal = new PotionBloodSeal(Config.bloodSealPotionID);
if(Compat.dargon) {
try {
dragonwrack = new PotionDragonwrack(Config.dragonwrackPotionID);
}
catch (Exception e){
Compat.dargon = false;
}
}
}
}
@@ -1,60 +0,0 @@
package fox.spiteful.forbidden.potions;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fox.spiteful.forbidden.items.tools.ItemDragonslayer;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
public class PotionDragonwrack extends Potion {
DamageSource wrack;
public PotionDragonwrack(int id){
super(id, false, 0xFFFFAA);
this.setPotionName("potion.dragonwrack");
this.setIconIndex(4, 1);
wrack = new DamageSource("dragonwrack").setDamageBypassesArmor();
}
@Override
@SideOnly(Side.CLIENT)
public int getStatusIconIndex() {
Minecraft.getMinecraft().renderEngine.bindTexture(DarkPotions.icons);
return super.getStatusIconIndex();
}
@Override
public void performEffect(EntityLivingBase victim, int level)
{
if(!ItemDragonslayer.isDragon(victim) || victim.worldObj.isRemote)
return;
ItemDragonslayer.absoluteDamage(victim, wrack, Math.max(1F, victim.getMaxHealth() / 20F));
if(victim instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)victim;
for(int x = 0;x < 5;x++){
if(player.getEquipmentInSlot(x) != null){
ItemStack equip = player.getEquipmentInSlot(x);
if(equip.getItem() instanceof IEnergyContainerItem){
IEnergyContainerItem battery = (IEnergyContainerItem)equip.getItem();
battery.extractEnergy(equip, battery.getMaxEnergyStored(equip) / 50, false);
}
}
}
}
}
public boolean isReady(int tick, int level)
{
int k;
k = 40 >> level;
return k <= 0 || tick % k == 0;
}
}