Dragonrekt

This commit is contained in:
Jeremy Diamond committed 2016-01-08 05:14:04 -08:00
1 parent 1211e88fe2
commit 0eb028601d
23 files changed
+895 -4

No files matched your search

@@ -28,6 +28,7 @@ public class Config {
public static int impactEnchID;
public static int bloodSealPotionID = 70;
public static int dragonwrackPotionID = 71;
public static int hellfireUpgradeID;
public static int pandemoniumUpgradeID;
@@ -59,6 +60,7 @@ 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;
@@ -114,6 +116,7 @@ public class Config {
}
bloodSealPotionID = conf.get("potions", "Blood Seal", bloodSealPotionID).getInt(bloodSealPotionID);
dragonwrackPotionID = conf.get("potions", "Dragonwrack", dragonwrackPotionID).getInt(dragonwrackPotionID);
crossMod = conf.get("compatibility", "Cross-Mod Interaction", crossMod, "Disable to keep mods segregated.").getBoolean(true);
crossWand = conf.get("compatibility", "Conversion Wands", crossWand, "Disable to remove all conversion wands.").getBoolean(true);
@@ -124,6 +127,7 @@ 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);
@@ -58,7 +58,7 @@ public class Forbidden {
ForbiddenItems.addItems();
ForbiddenBlocks.addBlocks();
DarkEnchantments.hex();
if(Compat.bm)
if(Compat.bm || Compat.dargon)
DarkPotions.alchemize();
proxy.registerRenderInfo();
}
@@ -3,7 +3,9 @@ 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;
@@ -32,6 +34,7 @@ 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)
@@ -45,6 +48,7 @@ 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() {
@@ -379,6 +383,30 @@ public class Compat {
Config.spawnerMobs.put("TwilightForest.Yeti", Aspect.COLD);
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 {
@@ -55,6 +55,8 @@ public class ForbiddenItems {
public static Item bloodOrb;
public static Item boundwell;
public static Item dragonslayer;
public static WandRod WAND_ROD_TAINTED;
public static WandRod WAND_ROD_INFERNAL;
public static WandRod WAND_ROD_NEUTRONIUM;
@@ -143,7 +145,7 @@ public class ForbiddenItems {
WAND_CAP_VINTEUM = new DarkWandCap("vinteum", 0.9F, new ItemStack(wandCap, 1, 1), 6, new ResourceLocation("forbidden", "textures/models/wand_cap_vinteum.png"));
WAND_CAP_MANASTEEL = new DarkWandCap("manasteel", 0.9F, new ItemStack(wandCap, 1, 3), 6, new ResourceLocation("forbidden", "textures/models/wand_cap_manasteel.png"));
WAND_CAP_ELEMENTIUM = new DarkWandCap("elementium", 0.8F, new ItemStack(wandCap, 1, 5), 9, new ResourceLocation("forbidden", "textures/models/wand_cap_elementium.png"));
WAND_CAP_TERRASTEEL = new DarkWandCap("terrasteel", 1.8F, new ItemStack(wandCap, 1, 5), 1, new ResourceLocation("forbidden", "textures/models/wand_cap_terrasteel.png"));
WAND_CAP_TERRASTEEL = new DarkWandCap("terrasteel", 1.8F, new ItemStack(wandCap, 1, 2), 1, new ResourceLocation("forbidden", "textures/models/wand_cap_terrasteel.png"));
resource = new ItemResource().setUnlocalizedName("FMResource");
@@ -169,6 +171,16 @@ 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");
@@ -0,0 +1,152 @@
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);
}
}
}
}
}
}
}
}
@@ -41,7 +41,7 @@ public class ItemSkullAxe extends ItemSword implements IRepairable {
@Override
public boolean getIsRepairable(ItemStack stack, ItemStack stack2) {
return stack2.isItemEqual(new ItemStack(Config.thaumcraftResource.getItem(), 1, 2)) ? true : super.getIsRepairable(stack, stack2);
return stack2.isItemEqual(new ItemStack(Config.thaumcraftResource.getItem(), 1, 2)) || super.getIsRepairable(stack, stack2);
}
@Override
@@ -1,6 +1,7 @@
package fox.spiteful.forbidden.potions;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.compat.Compat;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
@@ -10,6 +11,7 @@ import java.lang.reflect.Modifier;
public class DarkPotions {
public static final ResourceLocation icons = new ResourceLocation("forbidden", "textures/misc/potions.png");
public static Potion bloodSeal;
public static Potion dragonwrack;
public static void alchemize(){
if(Potion.potionTypes.length < 256) {
@@ -33,6 +35,15 @@ public class DarkPotions {
}
}
bloodSeal = new PotionBloodSeal(Config.bloodSealPotionID);
if(Compat.bm)
bloodSeal = new PotionBloodSeal(Config.bloodSealPotionID);
if(Compat.dargon) {
try {
dragonwrack = new PotionDragonwrack(Config.dragonwrackPotionID);
}
catch (Exception e){
Compat.dargon = false;
}
}
}
}
@@ -0,0 +1,60 @@
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;
}
}