diff --git a/build.prop b/build.prop index f2ecf9d..ec0353c 100644 --- a/build.prop +++ b/build.prop @@ -1,6 +1,6 @@ minecraft_version=1.7.10 forge_version=10.13.4.1558-1.7.10 tfc_version=0.79.27 -mod_version=1.06 +mod_version=1.07 mod_id=TerraFirmaPunkTweaks group_name=com.JAWolfe.tfptweaks \ No newline at end of file diff --git a/builds/Minetweaker Instructions.zs b/builds/Minetweaker Instructions.zs index 0cf931f..af2814f 100644 --- a/builds/Minetweaker Instructions.zs +++ b/builds/Minetweaker Instructions.zs @@ -1,28 +1,32 @@ //======================================================================== -// Heating items +// Heating items //======================================================================== +//----------------------------------------------- //Add Recipe - +//----------------------------------------------- //OutputStack, InputStack or InputOre, MeltingTemp(Default: 600, Normal Range 0-2000)[Optional], SpecificHeat(Default: 1, Normal Range 0-1)[Optional] //mods.tfptweaks.ItemHeat.addRecipe(,); //mods.tfptweaks.ItemHeat.addRecipe(,, 40); -//mods.tfptweaks.ItemHeat.addRecipe(,, 40, 1); +//mods.tfptweaks.ItemHeat.addRecipe(,, 1200, 1); //mods.tfptweaks.ItemHeat.addRecipe(,); //mods.tfptweaks.ItemHeat.addRecipe(,, 40); //mods.tfptweaks.ItemHeat.addRecipe(,, 40, 1); +//mods.tfptweaks.ItemHeat.addRecipe(,, 1535, 0.35); +//----------------------------------------------- //Remove Recipe - +//----------------------------------------------- //InputStack //mods.tfptweaks.ItemHeat.removeRecipe(); //======================================================================== -// Loom Recipes +// Loom Recipes //======================================================================== +//----------------------------------------------- //Add Recipe - +//----------------------------------------------- //OutputStack, InputStack, CosmeticLoomOverlay (Range 1-3: 1-String, 2-Silk, 3-Rope)[Optional] //mods.tfptweaks.Loom.addRecipe(, * 4); //mods.tfptweaks.Loom.addRecipe(, * 4, 1); @@ -30,35 +34,153 @@ //OutputStack, InputStack, ImageOverlayLocation("modID:location") //mods.tfptweaks.Loom.addRecipe(, * 4, "minecraft:blocks/wool_colored_blue"); +//----------------------------------------------- //Remove Recipe - +//----------------------------------------------- //InputStack {Stack size must be the same as the recipe to be removed} //mods.tfptweaks.Loom.removeRecipe( * 16); //======================================================================== -// Quern Recipes +// Quern Recipes //======================================================================== +//----------------------------------------------- //Add Recipe - +//----------------------------------------------- //OutputStack, InputStack //mods.tfptweaks.Quern.addRecipe( * 3, ); +//----------------------------------------------- //Remove Recipe - +//----------------------------------------------- //OutputStack, InputStack {Stack sizes must be the same as the recipe to be removed} +//mods.tfptweaks.Quern.removeRecipe( * 2, ); //mods.tfptweaks.Quern.removeRecipe(, ); //======================================================================== -// Barrel Recipe(NOT FULLY IMPLEMENTED DO NOT USE) +// Barrel Recipes //======================================================================== -//Add Recipe +//------------------------------------------------- +//Add Fluid Conversion Recipe +//------------------------------------------------- +//OutputStack, OutputFluid(in mb), InputStack, InputFluid(in mb), MinTechLevel (Default: 1), Sealed (Default: true), SealedTime (Default: 8), RemoveLiquid (Default: true), AllowAnyStack (Default: true) +//mods.tfptweaks.Barrel.addItemFluidConversion(, * 1000, , * 1000, 0, true, 1, true, true); +//mods.tfptweaks.Barrel.addItemFluidConversion(, * 1000, , * 1000, 0, true, 1, true); +//mods.tfptweaks.Barrel.addItemFluidConversion(, * 1000, , * 1000, 0, true, 1); +//mods.tfptweaks.Barrel.addItemFluidConversion(, * 1000, , * 1000, 0) +//mods.tfptweaks.Barrel.addItemFluidConversion(, * 1000, , * 1000) -//OutputStack, OutputFluid, InputStack, InputFluid, sealtime, removesLiquid, sealed, minTechLevel, allowAnyStack -//mods.tfptweaks.Barrel.addRecipe(); +//OutputFluid(in mb), InputStack, InputFluid(in mb), MinTechLevel (Default: 1), Sealed (Default: true), SealedTime (Default: 8), RemoveLiquid (Default: true), AllowAnyStack (Default: true) +//mods.tfptweaks.Barrel.addItemFluidConversion( * 1000, , * 1000, 0, false, 0, true, true); +//mods.tfptweaks.Barrel.addItemFluidConversion( * 1000, , * 1000, 0, false, 0, true); +//mods.tfptweaks.Barrel.addItemFluidConversion( * 1000, , * 1000, 0, false, 0); +//mods.tfptweaks.Barrel.addItemFluidConversion( * 1000, , * 1000, 0); +//mods.tfptweaks.Barrel.addItemFluidConversion( * 1000, , * 1000); -//Add Multi-Item Recipe +//------------------------------------------------- +//Remove Fluid Conversion Recipe +//------------------------------------------------- +//InputStack, InputFluid(in mb) +//mods.tfptweaks.Barrel.removeItemFluidConversion(, * 1000); -//OutputStack, InputStack, inputFS, sealed, minTechLevel, allowAnyStack, keepstacksize -//mods.tfptweaks.Barrel.addMultiItemRecipe(); \ No newline at end of file +//----------------------------------------------- +//Add Item Conversion Recipe +//----------------------------------------------- + +//OutputStack, InputStack, InputFluid(in mb), KeepStackSize (Default: true), MinTechLevel (Default: 1), Sealed (Default: true), AllowAnyStack (Default: true) +//mods.tfptweaks.Barrel.addItemConversion( * 16, * 16, * 100, false, 0, true, true); +//mods.tfptweaks.Barrel.addItemConversion( * 16, * 16, * 100, false, 0, true); +//mods.tfptweaks.Barrel.addItemConversion( * 16, * 16, * 100, false, 0); +//mods.tfptweaks.Barrel.addItemConversion( * 16, * 16, * 100, false); +//mods.tfptweaks.Barrel.addItemConversion( * 16, * 16, * 100); + +//----------------------------------------------- +//Remove Item Conversion Recipe +//----------------------------------------------- +//InputStack, InputFluid(in mb) +//mods.tfptweaks.Barrel.removeItemConversion(, * 100); + +//----------------------------------------------- +//Add Aged Fluid Recipe +//----------------------------------------------- +//OutputFluid(in mb), InputFluid(in mb), int minTechLevel, boolean sealed, int sealtime +//mods.tfptweaks.Barrel.ageFluid( * 1000, * 1000, 0, true, 8); +//mods.tfptweaks.Barrel.ageFluid( * 1000, * 1000, 0); +//mods.tfptweaks.Barrel.ageFluid( * 1000, * 1000); + +//----------------------------------------------- +//Add Fluid Combination Recipe +//----------------------------------------------- +//OutputFluid(in mb), BarrelFluid(in mb), InputFluid(in mb) +//mods.tfptweaks.Barrel.addFluidCombination( * 2000, * 1000, * 1000); + +//----------------------------------------------- +//Remove Fluid Combination Recipe +//----------------------------------------------- +// OutputFluid(in mb), BarrelFluid(in mb), InputFluid(in mb) +//mods.tfptweaks.Barrel.removeFluidCombination( * 10000, * 9000, * 1000); + +//======================================================================== +// Anvil Recipes +//======================================================================== + +//Default Plans: +//---------------------- +//Components: "ingot", "sheet", "refinebloom", "splitbloom", +//Tools: "pickaxe", "shovel", "axe", "hoe", "hammer", "chisel", "propick", "saw", "scythe", "bucket", "shears", "tuyere", "knife", +//Weapons: "sword", "mace", "javelin", +//Armor: "chestplate", "legsplate", "bootsplate", "helmplate", +//Misc: "trapdoor", "grill", "oillamp", "hopper" + +//Anvil Tiers: Stone=0, Copper=1, Bronze=2, Bismuth Bronze=2, Black Bronze=2, Rose Gold=2, Wrought Iron=3, Steel=4, Black Steel=5, Red Steel=6, Blue Steel=7 + +//----------------------------------------------- +//Add Anvil Recipe +//----------------------------------------------- +//OutputStack, InputStack1, InputStack2, PlanName, AnvilType +//mods.tfptweaks.Anvil.addAnvilRecipe(, , , "shears", 3); + +//OutputStack, InputStack, PlanName, AnvilType +//mods.tfptweaks.Anvil.addAnvilRecipe(, , "sword", 3); + +//----------------------------------------------- +//Remove Anvil Recipe +//----------------------------------------------- +//OutputStack, InputStack1, InputStack2, PlanName, AnvilType +//mods.tfptweaks.Anvil.removeAnvilRecipe(,,,"shears",3); + +//OutputStack, InputStack, PlanName, AnvilType +//mods.tfptweaks.Anvil.removeAnvilRecipe(, , "scythe", 3); + +//----------------------------------------------- +//Add Weld Recipe +//----------------------------------------------- +//OutputStack, InputStack1, InputStack2, AnvilType +//mods.tfptweaks.Anvil.addWeldRecipe(, , , 1); + +//----------------------------------------------- +//Remove Weld Recipe +//----------------------------------------------- +//OutputStack, InputStack1, InputStack2, AnvilType +//mods.tfptweaks.Anvil.removeWeldRecipe(, ,, 2); + +//----------------------------------------------- +//Add Plan Recipe +//(Works but will not show proper localized plan +// name if a custom plan is created) +//----------------------------------------------- + +//Plan Rules: Any=1, BendAny=2, BendLast=3, BendLastTwo=4, BendNotLast=5, BendSecondFromLast=6, BendThirdFromLast=7, DrawAny=8, DrawLast=9, DrawLastTwo=10, DrawNotLast=11, +// DrawSecondFromLast=12, DrawThirdFromLast=13, HitAny=14, HitLast=15, HitLastTwo=16, HitNotLast=17, HitSecondFromLast=18, HitThirdFromLast=19, PunchAny=20, PunchLast=21, +// PunchLastTwo=22, PunchNotLast=23, PunchSecondFromLast=24, PunchThridFromLast=25, ShrinkAny=26, ShrinkLast=27, ShrinkLastTwo=28, ShrinkNotLast=29, ShrinkSecondFromLast=30, +// ShrinkThirdFromLast=31, UpsetAny=32, UpetLast=33, UpsetLastTwo=34, UpsetNotLast=35, UpsetSecondFromLast=36, UpsetThirdFromLast=37 + +//PlanName, LastHit, Hit2ndFromLast, Hit3rdFromLast +//mods.tfptweaks.Anvil.addPlanRecipe("vanillasword", 33, 8, 19); + +//----------------------------------------------- +//Remove Plan Recipe +//----------------------------------------------- +//PlanName, LastHit, Hit2ndFromLast, Hit3rdFromLast +//mods.tfptweaks.Anvil.removePlanRecipe("sword", 15, 6, 7); \ No newline at end of file diff --git a/builds/TerraFirmaPunkTweaks-1.7.10-1.06.jar b/builds/TerraFirmaPunkTweaks-1.7.10-1.06.jar deleted file mode 100644 index 5707211..0000000 Binary files a/builds/TerraFirmaPunkTweaks-1.7.10-1.06.jar and /dev/null differ diff --git a/builds/TerraFirmaPunkTweaks-1.7.10-1.07.jar b/builds/TerraFirmaPunkTweaks-1.7.10-1.07.jar new file mode 100644 index 0000000..d54196b Binary files /dev/null and b/builds/TerraFirmaPunkTweaks-1.7.10-1.07.jar differ diff --git a/builds/TerraFirmaPunkTweaks-1.7.10-deobf-1.06.jar b/builds/TerraFirmaPunkTweaks-1.7.10-deobf-1.06.jar deleted file mode 100644 index d86bded..0000000 Binary files a/builds/TerraFirmaPunkTweaks-1.7.10-deobf-1.06.jar and /dev/null differ diff --git a/builds/TerraFirmaPunkTweaks-1.7.10-deobf-1.07.jar b/builds/TerraFirmaPunkTweaks-1.7.10-deobf-1.07.jar new file mode 100644 index 0000000..f4708a0 Binary files /dev/null and b/builds/TerraFirmaPunkTweaks-1.7.10-deobf-1.07.jar differ diff --git a/builds/TerraFirmaPunkTweaks-1.7.10-src-1.06.jar b/builds/TerraFirmaPunkTweaks-1.7.10-src-1.06.jar deleted file mode 100644 index 71bd16d..0000000 Binary files a/builds/TerraFirmaPunkTweaks-1.7.10-src-1.06.jar and /dev/null differ diff --git a/builds/TerraFirmaPunkTweaks-1.7.10-src-1.07.jar b/builds/TerraFirmaPunkTweaks-1.7.10-src-1.07.jar new file mode 100644 index 0000000..7bd8d37 Binary files /dev/null and b/builds/TerraFirmaPunkTweaks-1.7.10-src-1.07.jar differ diff --git a/changelog.txt b/changelog.txt index 4c79a99..55c3ec8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,23 @@ Changelog ================================================= ------------------------------------------------- +TFP Tweaks 1.07 +------------------------------------------------- +New Features ++Added Minetweaker support for the Assembly Table for Buildcraft 7.1 ++Added Minetweaker support for the barrel and anvil for Terrafirmacraft + +Tweaks ++Added config setting to set the method and values for stopping poison and wither ++Added config to set the damage multipliers for damage done by weapons and non-weapons ++Added damage can now be set to values lower than 20 ++Added correct tooltip on heated items for non-TFC items to show temperature, can work/weld, and if it has been worked tooltips ++Added witches can now insta-kill other witches if they are directly hit with a splash potion + +Bug Fixes ++Fixed crashes from attack tweak loops ++Fixed heated item specific heat not supporting decimal points for Minetweaker support of firepit or forge +------------------------------------------------- TFP Tweaks 1.06 ------------------------------------------------- New Features diff --git a/src/main/java/com/JAWolfe/tfptweaks/TerraFirmaPunkTweaks.java b/src/main/java/com/JAWolfe/tfptweaks/TerraFirmaPunkTweaks.java index 9414ffe..902a13f 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/TerraFirmaPunkTweaks.java +++ b/src/main/java/com/JAWolfe/tfptweaks/TerraFirmaPunkTweaks.java @@ -7,14 +7,12 @@ import com.JAWolfe.tfptweaks.proxy.CommonProxy; import com.JAWolfe.tfptweaks.reference.References; import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.ExistingSubstitutionException; import net.minecraftforge.common.MinecraftForge; @Mod(modid = References.ModID, name = References.ModName, version = References.ModVersion, dependencies = References.ModDependencies) @@ -41,17 +39,16 @@ public class TerraFirmaPunkTweaks public void initialize(FMLInitializationEvent event) { RecipeTweaks.RecipeFixes(); - + MinecraftForge.EVENT_BUS.register(new PlayerInteractionHandler()); MinecraftForge.EVENT_BUS.register(new PlayerDamageHandler()); - MinecraftForge.EVENT_BUS.register(new SpawnHandler()); proxy.registerWAILA(); } @EventHandler public void postInit(FMLPostInitializationEvent event) - { + { TFCTweaker.postInit(); RecipeTweaks.SC2RecipeTweaks(); diff --git a/src/main/java/com/JAWolfe/tfptweaks/handlers/ConfigHandler.java b/src/main/java/com/JAWolfe/tfptweaks/handlers/ConfigHandler.java index b37e987..44e9e9d 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/handlers/ConfigHandler.java +++ b/src/main/java/com/JAWolfe/tfptweaks/handlers/ConfigHandler.java @@ -51,22 +51,34 @@ public class ConfigHandler true, "Enable vanilla magic damage to TFC scaling: "); ConfigSettings.VanillaMagicMultipier = config.getInt("VanillaMagicMultipier", "MagicScaling", - 25, 20, 1000, "Multiplier used to scale vanilla magic damage to TFC levels: "); + 25, 1, 1000, "Multiplier used to scale vanilla magic damage to TFC levels: "); + ConfigSettings.FiniteMagicDamageCutoff = config.getBoolean("EnableFiniteMagicDamageCutoff", "MagicScaling.CutOff", + true, "Enable magic cutoff damage at specific value: "); + + ConfigSettings.FiniteMagicDamageCutoffValue = config.getInt("FiniteMagicDamageCutoffValue", "MagicScaling.CutOff", + 0, 0, 1000, "Value to stop applying magic damage if EnableFiniteMagicDamageCutoff is true: "); + + ConfigSettings.PercentMagicDamageCutoffValue = config.getInt("PercentMagicDamageCutoffValue", "MagicScaling.CutOff", + 10, 0, 100, "Percent health to stop applying magic damage if EnableFiniteMagicDamageCutoff is false: "); + ConfigSettings.VanillaDamageScaling = config.getBoolean("EnableVanillaDamageScaling", "HitScaling", true, "Enable vanilla hit damage to TFC scaling: "); ConfigSettings.VanillaPvPDamageScaling = config.getBoolean("EnableVanillaPvPDamageScaling", "HitScaling.PvP", true, "Enable vanilla PvP hit damage to TFC scaling: "); - ConfigSettings.VanillaPvPDamageMultipier = config.getInt("VanillaPvPDamageMultipier", "HitScaling.PvP", - 25, 20, 1000, "Multiplier used to scale vanilla PvP hit damage to TFC levels: "); + ConfigSettings.VanillaPvPNonWeaponDamageMultipier = config.getInt("VanillaPvPNonWeaponDamageMultipier", "HitScaling.PvP", + 10, 1, 1000, "Multiplier used to scale vanilla PvP non-weapon hit damage to TFC levels: "); + + ConfigSettings.VanillaPvPWeaponDamageMultipier = config.getInt("VanillaPvPWeaponDamageMultipier", "HitScaling.PvP", + 25, 1, 1000, "Multiplier used to scale vanilla PvP weapon hit damage to TFC levels: "); ConfigSettings.VanillaMobDamageScaling = config.getBoolean("EnableVanillaMobDamageScaling", "HitScaling.mob", true, "Enable vanilla mob hit damage to TFC scaling: "); ConfigSettings.VanillaMobDamageMultipier = config.getInt("VanillaMobDamageMultipier", "HitScaling.mob", - 50, 20, 1000, "Multiplier used to scale vanilla mob hit damage to TFC levels: "); + 50, 1, 1000, "Multiplier used to scale vanilla mob hit damage to TFC levels: "); ConfigSettings.InstantHealingScaling = config.getBoolean("EnableInstantHealingScaling", "HealScaling", true, "Enable vanilla instant healing potion to TFC scaling: "); diff --git a/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerDamageHandler.java b/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerDamageHandler.java index 8be167c..efe5f82 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerDamageHandler.java +++ b/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerDamageHandler.java @@ -2,6 +2,7 @@ package com.JAWolfe.tfptweaks.handlers; import java.util.Random; +import com.JAWolfe.tfptweaks.LogHelper; import com.JAWolfe.tfptweaks.reference.ConfigSettings; import com.bioxx.tfc.Items.ItemTFCArmor; import com.bioxx.tfc.api.Enums.EnumDamageType; @@ -15,6 +16,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.EntityWitch; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -28,56 +30,87 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; public class PlayerDamageHandler { + /** + * TFC scaled damage handling + * @param event + **/ @SubscribeEvent public void onDamaged(LivingHurtEvent event) - { - if(event.entity instanceof EntityPlayer) + { + //Reset Attacking tag on attacking entity + if(event.source.getEntity() != null && event.source.getEntity().getEntityData().hasKey("Attacking") && + event.source.getEntity().getEntityData().getBoolean("Attacking")) + event.source.getEntity().getEntityData().setBoolean("Attacking", false); + + //Check if damage is already processed by TFC + if (event.source == DamageSource.onFire || event.source == DamageSource.fall || event.source == DamageSource.drown || + event.source == DamageSource.lava || event.source == DamageSource.inWall || event.source == DamageSource.fallingBlock || + event.source.isExplosion() || event.source == DamageSource.inFire || event.source == DamageSource.starve) + return; + + //Process magic damage for all entities + else if((event.source == DamageSource.magic || event.source == DamageSource.wither) && event.ammount < 20 && ConfigSettings.VanillaMagicScaling) + { + event.ammount = event.ammount * ConfigSettings.VanillaMagicMultipier; + + float remainingHealth = event.entityLiving.getHealth() - event.ammount; + float cutoffValue = ConfigSettings.FiniteMagicDamageCutoffValue; + + if(!ConfigSettings.FiniteMagicDamageCutoff) + cutoffValue = (event.entityLiving.getMaxHealth() * ConfigSettings.PercentMagicDamageCutoffValue)/100; + + if(remainingHealth <= cutoffValue) + event.setCanceled(true); + } + + //Handle unblockable damage to players + else if(event.source.getSourceOfDamage() instanceof EntityLivingBase && ConfigSettings.VanillaDamageScaling && + event.source.isUnblockable() && event.entity instanceof EntityPlayer) { - if (event.source == DamageSource.onFire || event.source == DamageSource.fall || event.source == DamageSource.drown || - event.source == DamageSource.lava || event.source == DamageSource.inWall || event.source == DamageSource.fallingBlock || - event.source.isExplosion() || event.source == DamageSource.inFire || event.source == DamageSource.starve) - return; - else if((event.source == DamageSource.magic || event.source == DamageSource.wither) && event.ammount < 20 && ConfigSettings.VanillaMagicScaling) + float damage = (float)((EntityLivingBase)event.source.getSourceOfDamage()).getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + + if(event.source.getSourceOfDamage() instanceof EntityPlayer && damage < 20 && ConfigSettings.VanillaPvPDamageScaling) { - event.ammount = event.ammount * ConfigSettings.VanillaMagicMultipier; + if(damage == 1) + damage *= ConfigSettings.VanillaPvPNonWeaponDamageMultipier; + else + damage *= ConfigSettings.VanillaPvPWeaponDamageMultipier; + } - if((event.source == DamageSource.magic || event.source == DamageSource.wither) && (event.entityLiving.getHealth() - event.ammount) <= 0) - event.setCanceled(true); - } - else + if(!(event.source.getSourceOfDamage() instanceof EntityPlayer) && damage < 20 && ConfigSettings.VanillaMobDamageScaling) { - if(event.source.getSourceOfDamage() instanceof EntityLivingBase && ConfigSettings.VanillaDamageScaling) - { - if(event.source.isUnblockable()) - { - float damage = (float)((EntityLivingBase)event.source.getSourceOfDamage()).getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); - - if(event.source.getSourceOfDamage() instanceof EntityPlayer && damage < 20 && ConfigSettings.VanillaPvPDamageScaling) - damage *= ConfigSettings.VanillaPvPDamageMultipier; - - if(!(event.source.getSourceOfDamage() instanceof EntityPlayer) && damage < 20 && ConfigSettings.VanillaMobDamageScaling) - damage *= ConfigSettings.VanillaMobDamageMultipier; - - event.ammount = applyArmorCalculations(event.entityLiving, event.source, event.ammount > damage ? event.ammount : damage); - } - } + damage *= ConfigSettings.VanillaMobDamageMultipier; } + + event.ammount = applyArmorCalculations(event.entityLiving, event.source, event.ammount > damage ? event.ammount : damage); } } + /** + * TFC scaled attack handling + * @param event + */ @SubscribeEvent public void entityAttack(LivingAttackEvent event) - { + { + //Don't run if client sided if(event.entityLiving.worldObj.isRemote) return; + //Don't run if damage is already processed by TFC or other damage handlers if(event.source == DamageSource.onFire || event.source == DamageSource.fall || event.source == DamageSource.drown || event.source == DamageSource.lava || event.source == DamageSource.inWall || event.source == DamageSource.fallingBlock || event.source.isExplosion() || event.source == DamageSource.inFire || event.source == DamageSource.starve || event.source == DamageSource.magic || event.source == DamageSource.wither) return; - else if(event.ammount < 20 && event.entity instanceof EntityPlayer && ConfigSettings.VanillaDamageScaling) + + //Handle attacks done to the player in the vanilla range and there is no attacking tag or is false + else if(event.ammount < 20 && event.entity instanceof EntityPlayer && ConfigSettings.VanillaDamageScaling && + event.source != null && event.source.getEntity() != null && + (!event.source.getEntity().getEntityData().hasKey("Attacking") || + (event.source.getEntity().getEntityData().hasKey("Attacking") && !event.source.getEntity().getEntityData().getBoolean("Attacking")))) { + //Handle attacks from a player to the player if(event.source.getEntity() instanceof EntityPlayer && ConfigSettings.VanillaPvPDamageScaling) { EntityLivingBase attacker = (EntityLivingBase)event.source.getEntity(); @@ -91,12 +124,15 @@ public class PlayerDamageHandler { if (!target.hitByEntity(target)) { - float damageAmount = ConfigSettings.VanillaPvPDamageMultipier; + float damageAmount = ConfigSettings.VanillaPvPNonWeaponDamageMultipier; if(attacker.getHeldItem() != null) { damageAmount = (float)player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); - damageAmount *= ConfigSettings.VanillaPvPDamageMultipier; + if(damageAmount <= 1) + damageAmount *= ConfigSettings.VanillaPvPNonWeaponDamageMultipier; + else + damageAmount *= ConfigSettings.VanillaPvPWeaponDamageMultipier; } if (player.isPotionActive(Potion.damageBoost)) @@ -121,20 +157,62 @@ public class PlayerDamageHandler damageAmount += enchantmentDamage; + //Add "Attacking" tag to attacking entity + event.source.getEntity().getEntityData().setBoolean("Attacking", true); target.attackEntityFrom(DamageSource.causePlayerDamage(player), damageAmount); } } } } + //Handle attacks from non-TFC mobs to the player if(!(event.source.getEntity() instanceof EntityPlayer) && event.source.getEntity() != null && - !event.source.getEntity().getClass().getName().contains("bioxx.tfc") && ConfigSettings.VanillaMobDamageScaling) + !event.source.getEntity().getClass().getName().contains("bioxx.tfc")) { - event.entity.attackEntityFrom(event.source, event.ammount * ConfigSettings.VanillaMobDamageMultipier); + //Add "Attacking" tag to attacking entity + event.source.getEntity().getEntityData().setBoolean("Attacking", true); + + //Add damage for general damage + if(ConfigSettings.VanillaMobDamageScaling && !"indirectMagic".contentEquals(event.source.damageType)) + event.entity.attackEntityFrom(event.source, event.ammount * ConfigSettings.VanillaMobDamageMultipier); + + //Add damage for indirect magic damage + if(ConfigSettings.VanillaMagicScaling && "indirectMagic".contentEquals(event.source.damageType)) + event.entity.attackEntityFrom(event.source, ConfigSettings.VanillaPvPNonWeaponDamageMultipier); } } + + //Handle attacks done to mobs in the vanilla range from a non-TFC source and there is no attacking tag or is false + else if(event.ammount < 20 && !(event.entity instanceof EntityPlayer) && event.source != null && event.source.getEntity() != null && + !event.source.getEntity().getClass().getName().contains("bioxx.tfc") && + (!event.source.getEntity().getEntityData().hasKey("Attacking") || + (event.source.getEntity().getEntityData().hasKey("Attacking") && !event.source.getEntity().getEntityData().getBoolean("Attacking")))) + { + //Add "Attacking" tag to attacking entity + event.source.getEntity().getEntityData().setBoolean("Attacking", true); + + //Add damage for general damage + if(ConfigSettings.VanillaMobDamageScaling && !"indirectMagic".contentEquals(event.source.damageType)) + event.entity.attackEntityFrom(event.source, event.ammount * ConfigSettings.VanillaMobDamageMultipier); + + //Add damage for indirect magic damage + if(ConfigSettings.VanillaMagicScaling && "indirectMagic".contentEquals(event.source.damageType)) + { + event.entity.attackEntityFrom(event.source, ConfigSettings.VanillaPvPNonWeaponDamageMultipier); + + if(event.entity instanceof EntityWitch || event.entity.getClass().toString().contains("EntityWitherWitch")) + { + //Direct hit of a magic bottle kills a witch + event.entity.attackEntityFrom(event.source, 100000); + } + } + } } + /** + * TFC scaled healing handler + * @param event + */ @SubscribeEvent public void onHeal(LivingHealEvent event) { @@ -216,6 +294,11 @@ public class PlayerDamageHandler return 0; } + /** + * Random armor slot selector + * @param rand + * @return + */ private int getRandomSlot(Random rand) { int chance = rand.nextInt(100); @@ -229,6 +312,11 @@ public class PlayerDamageHandler return 1;//Legs } + /** + * Damage reduction amount + * @param armorRating + * @return + */ protected float getDamageReduction(int armorRating) { if(armorRating == -1000) @@ -236,6 +324,15 @@ public class PlayerDamageHandler return 1000f / (1000f + armorRating); } + /** + * TFC Damage Processing + * @param source + * @param damage + * @param pierceMult + * @param slashMult + * @param crushMult + * @return + */ private float processDamageSource(DamageSource source, float damage, float pierceMult, float slashMult, float crushMult) { @@ -260,6 +357,11 @@ public class PlayerDamageHandler return Math.max(0, damage); } + /** + * TFC Damage types + * @param source + * @return + */ private EnumDamageType getDamageType(DamageSource source) { //4.1 Determine the source of the damage and get the appropriate Damage Type @@ -289,6 +391,12 @@ public class PlayerDamageHandler return EnumDamageType.GENERIC; } + /** + * TFC Armor damage processing + * @param armor + * @param baseDamage + * @return + */ private float processArmorDamage(ItemStack armor, float baseDamage) { if(armor.hasTagCompound()) diff --git a/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerInteractionHandler.java b/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerInteractionHandler.java index 6990e56..19c540b 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerInteractionHandler.java +++ b/src/main/java/com/JAWolfe/tfptweaks/handlers/PlayerInteractionHandler.java @@ -4,7 +4,14 @@ import java.util.Random; import com.JAWolfe.tfptweaks.blocks.TFPBlocks; import com.JAWolfe.tfptweaks.reference.ConfigSettings; +import com.JAWolfe.tfptweaks.reference.ReferenceLists; +import com.bioxx.tfc.Core.TFC_Core; +import com.bioxx.tfc.Items.ItemTerra; +import com.bioxx.tfc.TileEntities.TEAnvil; +import com.bioxx.tfc.api.HeatIndex; +import com.bioxx.tfc.api.HeatRegistry; import com.bioxx.tfc.api.TFCBlocks; +import com.bioxx.tfc.api.TFC_ItemHeat; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -17,22 +24,70 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; public class PlayerInteractionHandler { - /*@SubscribeEvent + @SubscribeEvent public void onToolTip(ItemTooltipEvent event) { ItemStack object = event.itemStack; - if(!(object.getItem() instanceof ISize)) + + /*if(!(object.getItem() instanceof ISize)) event.toolTip.add("\u2696" + TFC_Core.translate("gui.Weight." + EnumWeight.LIGHT.getName()) + " \u21F2" + - TFC_Core.translate("gui.Size." + EnumSize.VERYSMALL.getName().replace(" ", ""))); - }*/ + TFC_Core.translate("gui.Size." + EnumSize.VERYSMALL.getName().replace(" ", "")));*/ + + if(!(object.getItem() instanceof ItemTerra)) + { + if (object.hasTagCompound()) + { + if(TFC_ItemHeat.hasTemp(object)) + { + float temp = TFC_ItemHeat.getTemp(object); + float meltTemp = -1; + HeatIndex hi = HeatRegistry.getInstance().findMatchingIndex(object); + if(hi != null) + meltTemp = hi.meltTemp; + + if(meltTemp != -1) + { + event.toolTip.add(TFC_ItemHeat.getHeatColor(temp, meltTemp)); + } + + if(ReferenceLists.getInstance().isAnvilInged(object)) + { + String s = ""; + if(HeatRegistry.getInstance().isTemperatureDanger(object)) + { + s += EnumChatFormatting.WHITE + TFC_Core.translate("gui.ingot.danger") + " | "; + } + + if(HeatRegistry.getInstance().isTemperatureWeldable(object)) + { + s += EnumChatFormatting.WHITE + TFC_Core.translate("gui.ingot.weldable") + " | "; + } + + if(HeatRegistry.getInstance().isTemperatureWorkable(object)) + { + s += EnumChatFormatting.WHITE + TFC_Core.translate("gui.ingot.workable"); + } + + if (!"".equals(s)) + event.toolTip.add(s); + } + } + + if (object.getTagCompound().hasKey(TEAnvil.ITEM_CRAFTING_VALUE_TAG) || object.getTagCompound().hasKey(TEAnvil.ITEM_CRAFTING_RULE_1_TAG)) + event.toolTip.add(TFC_Core.translate("gui.ItemWorked")); + } + } + } @SubscribeEvent public void onItemPickup(EntityItemPickupEvent event) diff --git a/src/main/java/com/JAWolfe/tfptweaks/handlers/SpawnHandler.java b/src/main/java/com/JAWolfe/tfptweaks/handlers/SpawnHandler.java deleted file mode 100644 index a4ca315..0000000 --- a/src/main/java/com/JAWolfe/tfptweaks/handlers/SpawnHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.JAWolfe.tfptweaks.handlers; - -public class SpawnHandler -{ - /*@SubscribeEvent - public void onSpawn(EntityJoinWorldEvent event) - { - /*if(event.entity instanceof EntityProjectileBase) - { - EntityProjectileBase projectile = (EntityProjectileBase)event.entity; - projectile.baseDamage = 2; - LogHelper.info(projectile.getDamage(null)); - } - /*if(!event.entity.getClass().getSimpleName().contains("EntityItem") && !event.entity.getClass().getSimpleName().contains("EntityBat") - && !event.entity.getClass().getSimpleName().contains("TFC")) - LogHelper.info(event.entity.getClass().getSimpleName()); - }*/ -} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Anvil.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Anvil.java deleted file mode 100644 index 54a8fd0..0000000 --- a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Anvil.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.JAWolfe.tfptweaks.minetweaker; - -import stanhebben.zenscript.annotations.ZenClass; - -@ZenClass("mods.tfptweaks.Anvil") -public class Anvil -{ - -} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Barrel.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Barrel.java deleted file mode 100644 index 60668c4..0000000 --- a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Barrel.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.JAWolfe.tfptweaks.minetweaker; - -import java.util.List; - -import com.bioxx.tfc.api.Crafting.BarrelManager; -import com.bioxx.tfc.api.Crafting.BarrelMultiItemRecipe; -import com.bioxx.tfc.api.Crafting.BarrelRecipe; - -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IItemStack; -import minetweaker.api.liquid.ILiquidStack; -import minetweaker.api.minecraft.MineTweakerMC; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -@ZenClass("mods.tfptweaks.Barrel") -public class Barrel -{ - @ZenMethod - public static void convertFluid(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int sealtime, boolean removesLiquid, boolean sealed, int minTechLevel, boolean allowAnyStack) - { - ItemStack inputStack = MineTweakerMC.getItemStack(inputIS); - FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); - FluidStack outputFluid = MineTweakerMC.getLiquidStack(outputFS); - - MineTweakerAPI.apply(new convertFluidAction(inputStack, inputFluid, outputFluid, sealtime, removesLiquid, sealed, minTechLevel, allowAnyStack)); - } - - @ZenMethod - public static void convertFluid(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int sealtime, boolean removesLiquid, boolean sealed, int minTechLevel) - { - convertFluid(outputFS, inputIS, inputFS, sealtime, removesLiquid, sealed, minTechLevel, true); - } - - @ZenMethod - public static void convertFluid(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int sealtime, boolean removesLiquid, boolean sealed) - { - convertFluid(outputFS, inputIS, inputFS, sealtime, removesLiquid, sealed, 1, true); - } - - @ZenMethod - public static void convertFluid(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int sealtime, boolean removesLiquid) - { - convertFluid(outputFS, inputIS, inputFS, sealtime, removesLiquid, true, 1, true); - } - - @ZenMethod - public static void convertFluid(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int sealtime) - { - convertFluid(outputFS, inputIS, inputFS, sealtime, true, true, 1, true); - } - - @ZenMethod - public static void convertFluid(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS) - { - convertFluid(outputFS, inputIS, inputFS, 8, true, true, 1, true); - } - - @ZenMethod - public static void convertItem(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean sealed, int minTechLevel, boolean allowAnyStack, boolean keepstacksize) - { - ItemStack inputStack = MineTweakerMC.getItemStack(inputIS); - ItemStack outputStack = MineTweakerMC.getItemStack(outputIS); - FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); - - MineTweakerAPI.apply(new addBarrelMultiItemAction(inputStack, inputFluid, outputStack, sealed, minTechLevel, allowAnyStack, keepstacksize)); - } - - @ZenMethod - public static void convertItem(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean sealed, int minTechLevel, boolean allowAnyStack) - { - convertItem(outputIS, inputIS, inputFS, sealed, minTechLevel, allowAnyStack, true); - } - - @ZenMethod - public static void convertItem(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean sealed, int minTechLevel) - { - convertItem(outputIS, inputIS, inputFS, sealed, minTechLevel, true, true); - } - - @ZenMethod - public static void convertItem(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean sealed) - { - convertItem(outputIS, inputIS, inputFS, sealed, 1, true, true); - } - - @ZenMethod - public static void convertItem(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS) - { - convertItem(outputIS, inputIS, inputFS, true, 1, true, true); - } - - private static class convertFluidAction implements IUndoableAction - { - ItemStack inputStack; - ItemStack outputStack; - FluidStack inputFluid; - FluidStack outputFluid; - int sealtime; - boolean removesLiquid; - boolean sealed; - int minTechLevel; - boolean allowAnyStack; - - public convertFluidAction(ItemStack inputIS, FluidStack inputFS, FluidStack outputFS, int sealtime, boolean removesLiquid, boolean sealed, int minTechLevel, boolean allowAnyStack) - { - this.inputStack = inputIS; - this.inputFluid = inputFS; - this.outputFluid = outputFS; - this.sealtime = sealtime; - this.removesLiquid = removesLiquid; - this.sealed = sealed; - this.minTechLevel = minTechLevel; - this.allowAnyStack = allowAnyStack; - } - - @Override - public void apply() - { - BarrelManager.getInstance().addRecipe(new BarrelRecipe(inputStack, inputFluid, outputStack, outputFluid, sealtime).setRemovesLiquid(removesLiquid).setAllowAnyStack(allowAnyStack).setMinTechLevel(minTechLevel).setSealedRecipe(sealed)); - } - - @Override - public String describe() - { - if(outputStack != null) - return "Adding item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() - + "' to barrel yeilding '" + outputStack.getDisplayName() + "'"; - else - return "Adding item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() - + "' to barrel yeilding '" + outputFluid.getLocalizedName() + "'"; - } - - @Override - public boolean canUndo() - { - return true; - } - - @Override - public void undo() - { - List BarrelList = BarrelManager.getInstance().getRecipes(); - for (int i = 0; i < BarrelList.size(); i++) - { - if (BarrelList.get(i) != null) - { - if (BarrelList.get(i).matches(inputStack, inputFluid)) - BarrelList.remove(i--); - } - } - } - - @Override - public String describeUndo() - { - return "Removing item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + "' from barrel '"; - } - - @Override - public Object getOverrideKey() { - return null; - } - } - - private static class addBarrelMultiItemAction implements IUndoableAction - { - ItemStack inputStack; - ItemStack outputStack; - FluidStack inputFluid; - boolean sealed; - int minTechLevel; - boolean allowAnyStack; - - public addBarrelMultiItemAction(ItemStack inputIS, FluidStack inputFS, ItemStack outputIS, boolean sealed, int minTechLevel, boolean allowAnyStack, boolean keepstacksize) - { - this.inputStack = inputIS; - this.inputFluid = inputFS; - this.outputStack = outputIS; - this.sealed = sealed; - this.minTechLevel = minTechLevel; - this.allowAnyStack = allowAnyStack; - } - - @Override - public void apply() - { - BarrelManager.getInstance().addRecipe(new BarrelMultiItemRecipe(inputStack, inputFluid, outputStack, inputFluid).setAllowAnyStack(allowAnyStack).setMinTechLevel(minTechLevel).setSealedRecipe(sealed)); - } - - @Override - public String describe() - { - return "Adding item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() - + "' to barrel yeilding '" + outputStack.getDisplayName() + "'"; - } - - @Override - public boolean canUndo() - { - return true; - } - - @Override - public void undo() - { - List BarrelList = BarrelManager.getInstance().getRecipes(); - for (int i = 0; i < BarrelList.size(); i++) - { - if (BarrelList.get(i) != null) - { - if (BarrelList.get(i).matches(inputStack, inputFluid)) - BarrelList.remove(i--); - } - } - } - - @Override - public String describeUndo() - { - return "Removing item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + "' from barrel '"; - } - - @Override - public Object getOverrideKey() { - return null; - } - } -} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Buildcraft/AssemblyTable.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Buildcraft/AssemblyTable.java new file mode 100644 index 0000000..232e68b --- /dev/null +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Buildcraft/AssemblyTable.java @@ -0,0 +1,140 @@ +package com.JAWolfe.tfptweaks.minetweaker.Buildcraft; + +import java.util.List; + +import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.api.recipes.IFlexibleRecipe; +import buildcraft.core.recipes.FlexibleRecipe; +import minetweaker.IUndoableAction; +import minetweaker.MineTweakerAPI; +import minetweaker.annotations.ModOnly; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.minecraft.MineTweakerMC; +import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.Optional; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@ZenClass("mods.buildcraft.AssemblyTable") +@ModOnly(value="BuildCraft|Core", version="7.1") +public class AssemblyTable +{ + private static int iCounter = 0; + + @ZenMethod + public static void addRecipe(IItemStack output, int energy, IItemStack[] ingredients) + { + MineTweakerAPI.apply(new AddRecipeAction(iCounter++, output, energy, ingredients)); + } + + @ZenMethod + public static void remove(IIngredient output) { + removeRecipe(output, null, false); + } + + @ZenMethod + public static void removeRecipe(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard) { + List> toRemove = BuildcraftRecipes.removeRecipes( + output, + ingredients, + BuildcraftRecipeRegistry.assemblyTable.getRecipes()); + + for (IFlexibleRecipe recipe : toRemove) + { + @SuppressWarnings("rawtypes") + ItemStack recipeOutput = recipe instanceof FlexibleRecipe ? (ItemStack)(((FlexibleRecipe) recipe).output) : null; + MineTweakerAPI.apply(new RemoveRecipeAction(recipe, recipeOutput)); + } + } + + // ###################### + // ### Action classes ### + // ###################### + + private static class AddRecipeAction implements IUndoableAction { + ItemStack output; + int energy; + ItemStack[] ingredients; + String id; + + public AddRecipeAction(int id, IItemStack output, int energy, IItemStack[] ingredients) + { + this.output = MineTweakerMC.getItemStack(output); + this.energy = energy; + this.ingredients = MineTweakerMC.getItemStacks(ingredients); + this.id = "terrafirmapunktweaks:recipe" + id; + } + + @Override + public void apply() + { + BuildcraftRecipeRegistry.assemblyTable.addRecipe(id, energy, output, (Object[])ingredients); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + BuildcraftRecipeRegistry.assemblyTable.removeRecipe(id); + } + + @Override + public String describe() { + return "Adding assembly table recipe for " + output; + } + + @Override + public String describeUndo() { + return "Removing assembly table recipe for " + output; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + private static class RemoveRecipeAction implements IUndoableAction { + private final IFlexibleRecipe recipe; + private final ItemStack output; + + public RemoveRecipeAction(IFlexibleRecipe recipe, ItemStack output) { + this.recipe = recipe; + this.output = output; + } + + @Override + public void apply() { + BuildcraftRecipeRegistry.assemblyTable.removeRecipe(recipe); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + BuildcraftRecipeRegistry.assemblyTable.addRecipe(recipe); + } + + @Override + public String describe() { + return "Removing assembly table recipe for " + MineTweakerMC.getIItemStack(output); + } + + @Override + public String describeUndo() { + return "Restoring assembly table recipe for " + MineTweakerMC.getIItemStack(output); + } + + @Override + public Object getOverrideKey() { + return null; + } + } +} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Buildcraft/BuildcraftRecipes.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Buildcraft/BuildcraftRecipes.java new file mode 100644 index 0000000..f05fbd6 --- /dev/null +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Buildcraft/BuildcraftRecipes.java @@ -0,0 +1,60 @@ +package com.JAWolfe.tfptweaks.minetweaker.Buildcraft; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import buildcraft.api.recipes.IFlexibleRecipe; +import buildcraft.core.recipes.FlexibleRecipe; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IngredientAny; +import minetweaker.api.minecraft.MineTweakerMC; +import net.minecraft.item.ItemStack; + +public class BuildcraftRecipes +{ +private BuildcraftRecipes() {} + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static List> removeRecipes(IIngredient output, IIngredient[] inputs, Collection> recipes) + { + if (output == IngredientAny.INSTANCE && (inputs == null || inputs.length == 0)) + return new ArrayList>(recipes); + + List> results = new ArrayList>(); + for (IFlexibleRecipe recipe : recipes) + { + if (recipe instanceof FlexibleRecipe && matches(output, inputs, (FlexibleRecipe) recipe)) + results.add(recipe); + } + + return results; + } + + private static boolean matches(IIngredient output, IIngredient[] inputs, FlexibleRecipe recipe) + { + ItemStack recipeOutput = (ItemStack) recipe.getOutput(); + if (!output.matches(MineTweakerMC.getIItemStack(recipeOutput))) + return false; + + if (inputs == null || inputs.length == 0) + return true; + + boolean[] matches = new boolean[inputs.length]; + outer: for (Object recipeInputObject : recipe.getInputs()) + { + IIngredient recipeIngredient = MineTweakerMC.getIIngredient(recipeInputObject); + for (int i = 0; i < inputs.length; i++) + { + if (!matches[i] && inputs[i].contains(recipeIngredient)) + { + matches[i] = true; + continue outer; + } + } + return false; + } + + return true; + } +} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Anvil.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Anvil.java new file mode 100644 index 0000000..3eb52da --- /dev/null +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Anvil.java @@ -0,0 +1,570 @@ +package com.JAWolfe.tfptweaks.minetweaker.TFC; + +import java.util.List; +import java.util.Random; + +import com.JAWolfe.tfptweaks.LogHelper; +import com.JAWolfe.tfptweaks.reference.ReferenceLists; +import com.JAWolfe.tfptweaks.reference.References; +import com.bioxx.tfc.api.Crafting.AnvilManager; +import com.bioxx.tfc.api.Crafting.AnvilRecipe; +import com.bioxx.tfc.api.Crafting.AnvilReq; +import com.bioxx.tfc.api.Crafting.PlanRecipe; +import com.bioxx.tfc.api.Enums.RuleEnum; + +import minetweaker.IUndoableAction; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IItemStack; +import minetweaker.api.minecraft.MineTweakerMC; +import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@ZenClass("mods.tfptweaks.Anvil") +public class Anvil +{ + @ZenMethod + public static void addAnvilRecipe(IItemStack Output, IItemStack Input1, IItemStack Input2, String plan, int AnvilReq) + { + ItemStack result = MineTweakerMC.getItemStack(Output); + ItemStack input1 = MineTweakerMC.getItemStack(Input1); + ItemStack input2 = null; + if(Input2 != null) + input2 = MineTweakerMC.getItemStack(Input2); + + MineTweakerAPI.apply(new addAnvilRecipeAction(result, input1, input2, plan, AnvilReq)); + } + + @ZenMethod + public static void addAnvilRecipe(IItemStack Output, IItemStack Input1, String plan, int AnvilReq) + { + addAnvilRecipe(Output, Input1, null, plan, AnvilReq); + } + + @ZenMethod + public static void removeAnvilRecipe(IItemStack Output, IItemStack Input1, IItemStack Input2, String plan, int AnvilReq) + { + ItemStack result = MineTweakerMC.getItemStack(Output); + ItemStack input1 = MineTweakerMC.getItemStack(Input1); + ItemStack input2 = null; + if(Input2 != null) + input2 = MineTweakerMC.getItemStack(Input2); + + MineTweakerAPI.apply(new removeAnvilRecipeAction(result, input1, input2, plan, AnvilReq)); + } + + @ZenMethod + public static void removeAnvilRecipe(IItemStack Output, IItemStack Input1, String plan, int AnvilReq) + { + removeAnvilRecipe(Output, Input1, null, plan, AnvilReq); + } + + @ZenMethod + public static void addWeldRecipe(IItemStack Output, IItemStack Input1, IItemStack Input2, int AnvilReq) + { + ItemStack result = MineTweakerMC.getItemStack(Output); + ItemStack input1 = MineTweakerMC.getItemStack(Input1); + ItemStack input2 = MineTweakerMC.getItemStack(Input2); + + MineTweakerAPI.apply(new addWeldRecipeAction(result, input1, input2, AnvilReq)); + } + + @ZenMethod + public static void removeWeldRecipe(IItemStack Output, IItemStack Input1, IItemStack Input2, int AnvilReq) + { + ItemStack result = MineTweakerMC.getItemStack(Output); + ItemStack input1 = MineTweakerMC.getItemStack(Input1); + ItemStack input2 = MineTweakerMC.getItemStack(Input2); + + MineTweakerAPI.apply(new removeWeldRecipeAction(result, input1, input2, AnvilReq)); + } + + @ZenMethod + public static void addPlanRecipe(String planName, int lastHitRef, int Hit2Ref, int Hit3Ref) + { + MineTweakerAPI.apply(new addPlanRecipeAction(planName, lastHitRef, Hit2Ref, Hit3Ref)); + } + + @ZenMethod + public static void removePlanRecipe(String planName, int lastHitRef, int Hit2Ref, int Hit3Ref) + { + MineTweakerAPI.apply(new removePlanRecipeAction(planName, lastHitRef, Hit2Ref, Hit3Ref)); + } + + private static class addAnvilRecipeAction implements IUndoableAction + { + Random r = new Random(); + ItemStack input1; + ItemStack input2; + ItemStack result; + String plan; + int craftingvalue; + int anvilReq; + + public addAnvilRecipeAction(ItemStack result, ItemStack input1, ItemStack input2, String plan, int anvilReq) + { + this.input1 = input1; + this.input2 = input2; + this.result = result; + this.plan = plan; + this.craftingvalue = 70 + r.nextInt(50); + this.anvilReq = anvilReq; + } + + @Override + public void apply() + { + if(input1 != null) + ReferenceLists.getInstance().addAnvilIngred(input1); + + if(input2 != null) + ReferenceLists.getInstance().addAnvilIngred(input2); + + AnvilManager.getInstance().addRecipe(new AnvilRecipe(input1, input2, plan, craftingvalue, false, anvilReq, result)); + } + + @Override + public String describe() + { + if(input2 != null) + return "Adding '" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + else + return "Adding '" + input1.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + List AnvilList = AnvilManager.getInstance().getRecipeList(); + for (int i = 0; i < AnvilList.size(); i++) + { + if (AnvilList.get(i) != null) + { + if(input2 != null) + { + if (AnvilList.get(i).matches(new AnvilRecipe(input1, input2, plan, craftingvalue, false, anvilReq, result))) + AnvilList.remove(i--); + } + else + if (AnvilList.get(i).matches(new AnvilRecipe(input1, null, plan, craftingvalue, false, anvilReq, result))) + AnvilList.remove(i--); + } + } + } + + @Override + public String describeUndo() + { + if(input2 != null) + return "Removing '" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeild '" + result.getDisplayName() + "'"; + else + return "Removing '" + input1.getDisplayName() + "' to anvil yeild '" + result.getDisplayName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + private static class removeAnvilRecipeAction implements IUndoableAction + { + Random r = new Random(); + ItemStack input1; + ItemStack input2; + ItemStack result; + String plan; + int anvilReq; + + public removeAnvilRecipeAction(ItemStack result, ItemStack input1, ItemStack input2, String plan, int anvilReq) + { + this.input1 = input1; + this.input2 = input2; + this.result = result; + this.plan = plan; + this.anvilReq = anvilReq; + } + + @Override + public void apply() + { + List AnvilList = AnvilManager.getInstance().getRecipeList(); + for (int i = 0; i < AnvilList.size(); i++) + { + if (AnvilList.get(i) != null) + { + if(input2 != null) + { + if (AnvilList.get(i).matches(new AnvilRecipe(input1, input2, plan, 1, false, anvilReq, result))) + AnvilList.remove(i--); + } + else + if (AnvilList.get(i).matches(new AnvilRecipe(input1, null, plan, 1, false, anvilReq, result))) + AnvilList.remove(i--); + } + } + } + + @Override + public String describe() + { + if(input2 != null) + return "Removing '" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeild '" + result.getDisplayName() + "'"; + else + return "Removing '" + input1.getDisplayName() + "' to anvil yeild '" + result.getDisplayName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + AnvilManager.getInstance().addRecipe(new AnvilRecipe(input1, input2, plan, 70 + r.nextInt(50), false, anvilReq, result)); + } + + @Override + public String describeUndo() + { + if(input2 != null) + return "Adding '" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + else + return "Adding '" + input1.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + private static class addWeldRecipeAction implements IUndoableAction + { + ItemStack input1; + ItemStack input2; + ItemStack result; + AnvilReq anvilReq; + + public addWeldRecipeAction(ItemStack result, ItemStack input1, ItemStack input2, int anvilReq) + { + this.input1 = input1; + this.input2 = input2; + this.result = result; + this.anvilReq = AnvilReq.getReqFromInt(anvilReq); + } + + @Override + public void apply() + { + if(input1 != null) + ReferenceLists.getInstance().addAnvilIngred(input1); + + if(input2 != null) + ReferenceLists.getInstance().addAnvilIngred(input2); + + AnvilManager.getInstance().addWeldRecipe(new AnvilRecipe(input1, input2, anvilReq, result)); + } + + @Override + public String describe() + { + return "Adding weld'" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + List AnvilList = AnvilManager.getInstance().getWeldRecipeList(); + for (int i = 0; i < AnvilList.size(); i++) + { + if (AnvilList.get(i) != null) + { + if( areItemStacksEqual(input1, AnvilList.get(i).input1) && + areItemStacksEqual(input2, AnvilList.get(i).input2) && + areItemStacksEqual(result, AnvilList.get(i).result) && + AnvilReq.matches(anvilReq.Tier, AnvilList.get(i).anvilreq)) + { + AnvilList.remove(i--); + } + } + } + } + + @Override + public String describeUndo() + { + return "Removing weld'" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + + private boolean areItemStacksEqual(ItemStack is1, ItemStack is2) + { + if (is1 != null && is2 != null) + { + if (is1.getItem() != is2.getItem()) + return false; + + if (is1.getItemDamage() != 32767 && is1.getItemDamage() != is2.getItemDamage()) + return false; + } + else if (is1 == null && is2 != null || is1 != null && is2 == null) // XOR, if both are null return true + return false; + + return true; + } + } + + private static class removeWeldRecipeAction implements IUndoableAction + { + ItemStack input1; + ItemStack input2; + ItemStack result; + int anvilReq; + + public removeWeldRecipeAction(ItemStack result, ItemStack input1, ItemStack input2, int anvilReq) + { + this.input1 = input1; + this.input2 = input2; + this.result = result; + this.anvilReq = anvilReq; + } + + @Override + public void apply() + { + List AnvilList = AnvilManager.getInstance().getWeldRecipeList(); + for (int i = 0; i < AnvilList.size(); i++) + { + if (AnvilList.get(i) != null) + { + if( areItemStacksEqual(input1, AnvilList.get(i).input1) && + areItemStacksEqual(input2, AnvilList.get(i).input2) && + areItemStacksEqual(result, AnvilList.get(i).result) && + AnvilReq.matches(anvilReq, AnvilList.get(i).anvilreq)) + { + AnvilList.remove(i--); + } + } + } + } + + @Override + public String describe() + { + return "Removing weld'" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + if(input1 != null) + ReferenceLists.getInstance().addAnvilIngred(input1); + + if(input2 != null) + ReferenceLists.getInstance().addAnvilIngred(input2); + + AnvilManager.getInstance().addWeldRecipe(new AnvilRecipe(input1, input2, AnvilReq.getReqFromInt(anvilReq), result)); + } + + @Override + public String describeUndo() + { + return "Adding weld'" + input1.getDisplayName() + "' with '" + input2.getDisplayName() + "' to anvil yeilding '" + result.getDisplayName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + + private boolean areItemStacksEqual(ItemStack is1, ItemStack is2) + { + if (is1 != null && is2 != null) + { + if (is1.getItem() != is2.getItem()) + return false; + + if (is1.getItemDamage() != 32767 && is1.getItemDamage() != is2.getItemDamage()) + return false; + } + else if (is1 == null && is2 != null || is1 != null && is2 == null) // XOR, if both are null return true + return false; + + return true; + } + } + + private static class addPlanRecipeAction implements IUndoableAction + { + String planName; + RuleEnum lastHit; + RuleEnum hit2Last; + RuleEnum hit3Last; + + public addPlanRecipeAction(String planName, int lastHit, int hit2Last, int hit3Last) + { + this.lastHit = getRule(lastHit); + this.hit2Last = getRule(hit2Last); + this.hit3Last = getRule(hit3Last); + this.planName = planName; + } + + @Override + public void apply() + { + AnvilManager.getInstance().addPlan(planName, new PlanRecipe(new RuleEnum[]{lastHit, hit2Last, hit3Last})); + } + + @Override + public String describe() + { + return "Adding plan '" + planName + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + AnvilManager.getInstance().getPlans().remove(planName); + } + + @Override + public String describeUndo() + { + return "Removing plan '" + planName + "'"; + } + + @Override + public Object getOverrideKey() + { + return null; + } + } + + private static class removePlanRecipeAction implements IUndoableAction + { + String planName; + RuleEnum lastHit; + RuleEnum hit2Last; + RuleEnum hit3Last; + + public removePlanRecipeAction(String planName, int lastHit, int hit2Last, int hit3Last) + { + this.lastHit = getRule(lastHit); + this.hit2Last = getRule(hit2Last); + this.hit3Last = getRule(hit3Last); + this.planName = planName; + } + + @Override + public void apply() + { + AnvilManager.getInstance().getPlans().remove(planName); + } + + @Override + public String describe() + { + return "Removing plan '" + planName + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + AnvilManager.getInstance().addPlan(planName, new PlanRecipe(new RuleEnum[]{lastHit, hit2Last, hit3Last})); + } + + @Override + public String describeUndo() + { + return "Adding plan '" + planName + "'"; + } + + @Override + public Object getOverrideKey() + { + return null; + } + } + + private static RuleEnum getRule(int ruleRef) + { + switch(ruleRef) + { + case 1: return RuleEnum.ANY; + case 2: return RuleEnum.BENDANY; + case 3: return RuleEnum.BENDLAST; + case 4: return RuleEnum.BENDLASTTWO; + case 5: return RuleEnum.BENDNOTLAST; + case 6: return RuleEnum.BENDSECONDFROMLAST; + case 7: return RuleEnum.BENDTHIRDFROMLAST; + case 8: return RuleEnum.DRAWANY; + case 9: return RuleEnum.DRAWLAST; + case 10: return RuleEnum.DRAWLASTTWO; + case 11: return RuleEnum.DRAWNOTLAST; + case 12: return RuleEnum.DRAWSECONDFROMLAST; + case 13: return RuleEnum.DRAWTHIRDFROMLAST; + case 14: return RuleEnum.HITANY; + case 15: return RuleEnum.HITLAST; + case 16: return RuleEnum.HITLASTTWO; + case 17: return RuleEnum.HITNOTLAST; + case 18: return RuleEnum.HITSECONDFROMLAST; + case 19: return RuleEnum.HITTHIRDFROMLAST; + case 20: return RuleEnum.PUNCHANY; + case 21: return RuleEnum.PUNCHLAST; + case 22: return RuleEnum.PUNCHLASTTWO; + case 23: return RuleEnum.PUNCHNOTLAST; + case 24: return RuleEnum.PUNCHSECONDFROMLAST; + case 25: return RuleEnum.PUNCHTHIRDFROMLAST; + case 26: return RuleEnum.SHRINKANY; + case 27: return RuleEnum.SHRINKLAST; + case 28: return RuleEnum.SHRINKLASTTWO; + case 29: return RuleEnum.SHRINKNOTLAST; + case 30: return RuleEnum.SHRINKSECONDFROMLAST; + case 31: return RuleEnum.SHRINKTHIRDFROMLAST; + case 32: return RuleEnum.UPSETANY; + case 33: return RuleEnum.UPSETLAST; + case 34: return RuleEnum.UPSETLASTTWO; + case 35: return RuleEnum.UPSETNOTLAST; + case 36: return RuleEnum.UPSETSECONDFROMLAST; + case 37: return RuleEnum.UPSETTHIRDFROMLAST; + default: return RuleEnum.ANY; + } + } +} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Barrel.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Barrel.java new file mode 100644 index 0000000..38bcce3 --- /dev/null +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Barrel.java @@ -0,0 +1,613 @@ +package com.JAWolfe.tfptweaks.minetweaker.TFC; + +import java.util.List; + +import com.bioxx.tfc.api.Crafting.BarrelLiquidToLiquidRecipe; +import com.bioxx.tfc.api.Crafting.BarrelManager; +import com.bioxx.tfc.api.Crafting.BarrelMultiItemRecipe; +import com.bioxx.tfc.api.Crafting.BarrelRecipe; + +import minetweaker.IUndoableAction; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IItemStack; +import minetweaker.api.liquid.ILiquidStack; +import minetweaker.api.minecraft.MineTweakerMC; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@ZenClass("mods.tfptweaks.Barrel") +public class Barrel +{ + //BarrelRecipe + @ZenMethod + public static void addItemFluidConversion(IItemStack outputIS, ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime, boolean removesLiquid, boolean allowAnyStack) + { + ItemStack inputStack = MineTweakerMC.getItemStack(inputIS); + FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); + ItemStack outputStack = MineTweakerMC.getItemStack(outputIS); + FluidStack outputFluid = MineTweakerMC.getLiquidStack(outputFS); + + if(inputFluid == null || inputFluid.getFluid() == null) + MineTweakerAPI.logError("Missing InputFluid"); + else if(inputFluid.amount <= 0) + MineTweakerAPI.logError("InputFluid must contain more than 0 mb of fluid"); + else if(outputFluid == null || outputFluid.getFluid() == null) + MineTweakerAPI.logError("Missing OutputFluid"); + else if(outputFluid.amount <= 0) + MineTweakerAPI.logError("OutputFluid must contain more than 0 mb of fluid"); + else if(sealed == false && sealtime > 0) + MineTweakerAPI.logError("Sealed time must be 0 if barrel is unsealed"); + else + MineTweakerAPI.apply(new addFluidConversionAction(inputStack, inputFluid, outputStack, outputFluid, sealtime, removesLiquid, sealed, minTechLevel, allowAnyStack)); + } + + @ZenMethod + public static void addItemFluidConversion(IItemStack outputIS, ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime, boolean removesLiquid) + { + addItemFluidConversion(outputIS, outputFS, inputIS, inputFS, minTechLevel, sealed, sealtime, removesLiquid, true); + } + + @ZenMethod + public static void addItemFluidConversion(IItemStack outputIS, ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime) + { + addItemFluidConversion(outputIS, outputFS, inputIS, inputFS, minTechLevel, sealed, sealtime, true, true); + } + + @ZenMethod + public static void addItemFluidConversion(IItemStack outputIS, ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel) + { + addItemFluidConversion(outputIS, outputFS, inputIS, inputFS, minTechLevel, true, 8, true, true); + } + + @ZenMethod + public static void addItemFluidConversion(IItemStack outputIS, ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS) + { + addItemFluidConversion(outputIS, outputFS, inputIS, inputFS, 1, true, 8, true, true); + } + + @ZenMethod + public static void addItemFluidConversion(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime, boolean removesLiquid, boolean allowAnyStack) + { + addItemFluidConversion(null, outputFS, inputIS, inputFS, minTechLevel, sealed, sealtime, removesLiquid, allowAnyStack); + } + + @ZenMethod + public static void addItemFluidConversion(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime, boolean removesLiquid) + { + addItemFluidConversion(null, outputFS, inputIS, inputFS, minTechLevel, sealed, sealtime, removesLiquid, true); + } + + @ZenMethod + public static void addItemFluidConversion(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime) + { + addItemFluidConversion(null, outputFS, inputIS, inputFS, minTechLevel, sealed, sealtime, true, true); + } + + @ZenMethod + public static void addItemFluidConversion(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS, int minTechLevel) + { + addItemFluidConversion(null, outputFS, inputIS, inputFS, minTechLevel, true, 8, true, true); + } + + @ZenMethod + public static void addItemFluidConversion(ILiquidStack outputFS, IItemStack inputIS, ILiquidStack inputFS) + { + addItemFluidConversion(null, outputFS, inputIS, inputFS, 1, true, 8, true, true); + } + + @ZenMethod + public static void removeItemFluidConversion(IItemStack inputIS, ILiquidStack inputFS) + { + ItemStack inputStack = MineTweakerMC.getItemStack(inputIS); + FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); + + if(inputStack == null || inputStack.getItem() == null) + MineTweakerAPI.logError("Missing InputStack"); + else if(inputFluid == null || inputFluid.getFluid() == null) + MineTweakerAPI.logError("Missing InputFluid"); + else if(inputFluid.amount <= 0) + MineTweakerAPI.logError("InputFluid must contain more than 0 mb of fluid"); + else + MineTweakerAPI.apply(new removeItemFluidConversionAction(inputStack, inputFluid)); + } + + //BarrelMultiItemRecipe - Better for converting items as the outputstack size can match the input + @ZenMethod + public static void addItemConversion(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean keepstacksize, int minTechLevel, boolean sealed, boolean allowAnyStack) + { + ItemStack inputStack = MineTweakerMC.getItemStack(inputIS); + ItemStack outputStack = MineTweakerMC.getItemStack(outputIS); + FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); + + MineTweakerAPI.apply(new addItemConversionAction(inputStack, inputFluid, outputStack, sealed, minTechLevel, allowAnyStack, keepstacksize)); + } + + @ZenMethod + public static void addItemConversion(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean keepstacksize, int minTechLevel, boolean sealed) + { + addItemConversion(outputIS, inputIS, inputFS, keepstacksize, minTechLevel, sealed, true); + } + + @ZenMethod + public static void addItemConversion(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean keepstacksize, int minTechLevel) + { + addItemConversion(outputIS, inputIS, inputFS, keepstacksize, minTechLevel, true, true); + } + + @ZenMethod + public static void addItemConversion(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS, boolean keepstacksize) + { + addItemConversion(outputIS, inputIS, inputFS, keepstacksize, 1, true, true); + } + + @ZenMethod + public static void addItemConversion(IItemStack outputIS, IItemStack inputIS, ILiquidStack inputFS) + { + addItemConversion(outputIS, inputIS, inputFS, true, 1, true, true); + } + + @ZenMethod + public static void removeItemConversion(IItemStack inputIS, ILiquidStack inputFS) + { + ItemStack inputStack = MineTweakerMC.getItemStack(inputIS); + FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); + + MineTweakerAPI.apply(new removeItemFluidConversionAction(inputStack, inputFluid)); + } + + @ZenMethod + public static void ageFluid(ILiquidStack outputFS, ILiquidStack inputFS, int minTechLevel, boolean sealed, int sealtime) + { + FluidStack inputFluid = MineTweakerMC.getLiquidStack(inputFS); + FluidStack outputFluid = MineTweakerMC.getLiquidStack(outputFS); + + if(inputFluid.amount <= 0) + MineTweakerAPI.logError("InputFluid must contain more than 0 mb of fluid"); + else if(outputFluid == null || outputFluid.getFluid() == null) + MineTweakerAPI.logError("Missing OutputFluid"); + else if(outputFluid.amount <= 0) + MineTweakerAPI.logError("OutputFluid must contain more than 0 mb of fluid"); + else if(sealed == false && sealtime > 0) + MineTweakerAPI.logError("Sealed time must be 0 if barrel is unsealed"); + else + MineTweakerAPI.apply(new addAgedFluidAction(inputFluid, outputFluid, sealtime, sealed, minTechLevel)); + } + + @ZenMethod + public static void ageFluid(ILiquidStack outputFS, ILiquidStack inputFS, int minTechLevel) + { + ageFluid(outputFS, inputFS, minTechLevel, true, 8); + } + + @ZenMethod + public static void ageFluid(ILiquidStack outputFS, ILiquidStack inputFS) + { + ageFluid(outputFS, inputFS, 1, true, 8); + } + + //BarrelLiquidToLiquidRecipe + @ZenMethod + public static void addFluidCombination(ILiquidStack outputFluid, ILiquidStack fluidInBarrel, ILiquidStack inputFluid) + { + FluidStack barrelContents = MineTweakerMC.getLiquidStack(fluidInBarrel); + FluidStack inputfluid = MineTweakerMC.getLiquidStack(inputFluid); + FluidStack outputfluid = MineTweakerMC.getLiquidStack(outputFluid); + + MineTweakerAPI.apply(new addFluidCombinationAction(barrelContents, inputfluid, outputfluid)); + } + + @ZenMethod + public static void removeFluidCombination(ILiquidStack outputFluid, ILiquidStack fluidInBarrel, ILiquidStack inputFluid) + { + FluidStack barrelContents = MineTweakerMC.getLiquidStack(fluidInBarrel); + FluidStack inputfluid = MineTweakerMC.getLiquidStack(inputFluid); + FluidStack outputfluid = MineTweakerMC.getLiquidStack(outputFluid); + + MineTweakerAPI.apply(new removeFluidCombinationAction(barrelContents, inputfluid, outputfluid)); + } + + // ###################### + // ### Action classes ### + // ###################### + + //Add Fluid Conversion + + private static class addFluidConversionAction implements IUndoableAction + { + ItemStack inputStack; + ItemStack outputStack; + FluidStack inputFluid; + FluidStack outputFluid; + int sealtime; + boolean removesLiquid; + boolean sealed; + int minTechLevel; + boolean allowAnyStack; + + public addFluidConversionAction(ItemStack inputIS, FluidStack inputFS, ItemStack outputIS, FluidStack outputFS, int sealtime, boolean removesLiquid, boolean sealed, int minTechLevel, boolean allowAnyStack) + { + this.inputStack = inputIS; + this.inputFluid = inputFS; + this.outputFluid = outputFS; + this.outputStack = outputIS; + this.sealtime = sealtime; + this.removesLiquid = removesLiquid; + this.sealed = sealed; + this.minTechLevel = minTechLevel; + this.allowAnyStack = allowAnyStack; + } + + @Override + public void apply() + { + BarrelManager.getInstance().addRecipe(new BarrelRecipe(inputStack, inputFluid, outputStack, outputFluid, sealtime).setRemovesLiquid(removesLiquid).setAllowAnyStack(allowAnyStack).setMinTechLevel(minTechLevel).setSealedRecipe(sealed)); + } + + @Override + public String describe() + { + if(outputStack != null) + return "Adding item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + + "' to barrel yeilding '" + outputStack.getDisplayName() + "'"; + else + return "Adding item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + + "' to barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + List BarrelList = BarrelManager.getInstance().getRecipes(); + for (int i = 0; i < BarrelList.size(); i++) + { + if (BarrelList.get(i) != null) + { + if (BarrelList.get(i).matches(inputStack, inputFluid)) + BarrelList.remove(i--); + } + } + } + + @Override + public String describeUndo() + { + return "Removing item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + "' from barrel '"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + //Remove Fluid Conversion & Remove Item Conversion Action + + private static class removeItemFluidConversionAction implements IUndoableAction + { + ItemStack inputStack; + FluidStack inputFluid; + + public removeItemFluidConversionAction(ItemStack inputIS, FluidStack inputFS) + { + this.inputStack = inputIS; + this.inputFluid = inputFS; + } + + @Override + public void apply() + { + List BarrelList = BarrelManager.getInstance().getRecipes(); + for (int i = 0; i < BarrelList.size(); i++) + { + if (BarrelList.get(i) != null) + { + if (BarrelList.get(i).matches(inputStack, inputFluid)) + BarrelList.remove(i--); + } + } + } + + @Override + public String describe() + { + return "Removing item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + "' from barrel '"; + } + + @Override + public boolean canUndo() + { + return false; + } + + @Override + public void undo() + { + } + + @Override + public String describeUndo() + { + return null; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + //Add Item Conversion Action + + private static class addItemConversionAction implements IUndoableAction + { + ItemStack inputStack; + ItemStack outputStack; + FluidStack inputFluid; + boolean sealed; + int minTechLevel; + boolean allowAnyStack; + + public addItemConversionAction(ItemStack inputIS, FluidStack inputFS, ItemStack outputIS, boolean sealed, int minTechLevel, boolean allowAnyStack, boolean keepstacksize) + { + this.inputStack = inputIS; + this.inputFluid = inputFS; + this.outputStack = outputIS; + this.sealed = sealed; + this.minTechLevel = minTechLevel; + this.allowAnyStack = allowAnyStack; + } + + @Override + public void apply() + { + BarrelManager.getInstance().addRecipe(new BarrelMultiItemRecipe(inputStack, inputFluid, outputStack, inputFluid).setAllowAnyStack(allowAnyStack).setMinTechLevel(minTechLevel).setSealedRecipe(sealed)); + } + + @Override + public String describe() + { + return "Adding item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + + "' to barrel yeilding '" + outputStack.getDisplayName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + List BarrelList = BarrelManager.getInstance().getRecipes(); + for (int i = 0; i < BarrelList.size(); i++) + { + if (BarrelList.get(i) != null) + { + if (BarrelList.get(i).matches(inputStack, inputFluid)) + BarrelList.remove(i--); + } + } + } + + @Override + public String describeUndo() + { + return "Removing item '" + inputStack.getDisplayName() + "' with '" + inputFluid.getLocalizedName() + "' from barrel '"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + //Add Fluid Combination Action + + private static class addFluidCombinationAction implements IUndoableAction + { + FluidStack barrelContents; + FluidStack inputFluid; + FluidStack outputFluid; + + public addFluidCombinationAction(FluidStack barrelContents, FluidStack inputFS, FluidStack outputFS) + { + this.barrelContents = barrelContents; + this.inputFluid = inputFS; + this.outputFluid = outputFS; + } + + @Override + public void apply() + { + BarrelManager.getInstance().addRecipe(new BarrelLiquidToLiquidRecipe(barrelContents, inputFluid, outputFluid).setSealedRecipe(false).setMinTechLevel(0).setRemovesLiquid(false)); + } + + @Override + public String describe() + { + return "Combining '" + barrelContents.getLocalizedName() + "' with '" + inputFluid.getLocalizedName() + + "' in barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + List BarrelList = BarrelManager.getInstance().getRecipes(); + for (int i = 0; i < BarrelList.size(); i++) + { + if (BarrelList.get(i) != null) + { + if(BarrelList.get(i) instanceof BarrelLiquidToLiquidRecipe) + { + if(BarrelList.get(i).getInItem() == null && BarrelList.get(i).getRecipeOutIS() == null && + ((BarrelLiquidToLiquidRecipe)BarrelList.get(i)).getInputfluid().isFluidEqual(inputFluid) && + BarrelList.get(i).getInFluid().isFluidEqual(barrelContents) && + BarrelList.get(i).getRecipeOutFluid().isFluidEqual(outputFluid)) + { + BarrelList.remove(i--); + } + } + } + } + } + + @Override + public String describeUndo() + { + return "Removing combination of '" + barrelContents.getLocalizedName() + "' with '" + inputFluid.getLocalizedName() + + "' in barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + //Remove Fluid Combination Action + + private static class removeFluidCombinationAction implements IUndoableAction + { + FluidStack barrelContents; + FluidStack inputFluid; + FluidStack outputFluid; + + public removeFluidCombinationAction(FluidStack barrelContents, FluidStack inputFS, FluidStack outputFS) + { + this.barrelContents = barrelContents; + this.inputFluid = inputFS; + this.outputFluid = outputFS; + } + + @Override + public void apply() + { + List BarrelList = BarrelManager.getInstance().getRecipes(); + for (int i = 0; i < BarrelList.size(); i++) + { + if (BarrelList.get(i) != null) + { + if(BarrelList.get(i) instanceof BarrelLiquidToLiquidRecipe) + { + if(BarrelList.get(i).getInItem() == null && BarrelList.get(i).getRecipeOutIS() == null && + ((BarrelLiquidToLiquidRecipe)BarrelList.get(i)).getInputfluid().isFluidEqual(inputFluid) && + BarrelList.get(i).getInFluid().isFluidEqual(barrelContents) && + BarrelList.get(i).getRecipeOutFluid().isFluidEqual(outputFluid)) + { + BarrelList.remove(i--); + } + } + } + } + } + + @Override + public String describe() + { + return "Removing combination of '" + barrelContents.getLocalizedName() + "' with '" + inputFluid.getLocalizedName() + + "' in barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + BarrelManager.getInstance().addRecipe(new BarrelLiquidToLiquidRecipe(barrelContents, inputFluid, outputFluid).setSealedRecipe(false).setMinTechLevel(0).setRemovesLiquid(false)); + } + + @Override + public String describeUndo() + { + return "Adding Combination of '" + barrelContents.getLocalizedName() + "' with '" + inputFluid.getLocalizedName() + + "' in barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } + + //Add Fluid Aging + + private static class addAgedFluidAction implements IUndoableAction + { + FluidStack inputFluid; + FluidStack outputFluid; + int sealtime; + boolean sealed; + int minTechLevel; + + public addAgedFluidAction(FluidStack inputFS, FluidStack outputFS, int sealtime, boolean sealed, int minTechLevel) + { + this.inputFluid = inputFS; + this.outputFluid = outputFS; + this.sealtime = sealtime; + this.sealed = sealed; + this.minTechLevel = minTechLevel; + } + + @Override + public void apply() + { + BarrelManager.getInstance().addRecipe(new BarrelRecipe(null, inputFluid, null, outputFluid, sealtime).setRemovesLiquid(false).setMinTechLevel(minTechLevel).setSealedRecipe(sealed)); + } + + @Override + public String describe() + { + return "Adding aging to '" + inputFluid.getLocalizedName() + "' in barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public boolean canUndo() + { + return true; + } + + @Override + public void undo() + { + List BarrelList = BarrelManager.getInstance().getRecipes(); + for (int i = 0; i < BarrelList.size(); i++) + { + if (BarrelList.get(i) != null) + { + if (BarrelList.get(i).getRecipeOutIS() == null && BarrelList.get(i).getInItem() == null && + BarrelList.get(i).getInFluid() == inputFluid && BarrelList.get(i).getRecipeOutFluid() == outputFluid) + BarrelList.remove(i--); + } + } + } + + @Override + public String describeUndo() { + return "Remove aging to '" + inputFluid.getLocalizedName() + "' in barrel yeilding '" + outputFluid.getLocalizedName() + "'"; + } + + @Override + public Object getOverrideKey() { + return null; + } + } +} diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/ItemHeat.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/ItemHeat.java similarity index 91% rename from src/main/java/com/JAWolfe/tfptweaks/minetweaker/ItemHeat.java rename to src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/ItemHeat.java index ef47604..ac2163a 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/ItemHeat.java +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/ItemHeat.java @@ -1,4 +1,4 @@ -package com.JAWolfe.tfptweaks.minetweaker; +package com.JAWolfe.tfptweaks.minetweaker.TFC; import java.util.List; @@ -18,7 +18,7 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ItemHeat { @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input, int heat, int specHeat) + public static void addRecipe(IItemStack output, IItemStack input, double heat, double specHeat) { ItemStack inputStack = MineTweakerMC.getItemStack(input); ItemStack outputStack = MineTweakerMC.getItemStack(output); @@ -48,7 +48,7 @@ public class ItemHeat } @ZenMethod - public static void addRecipe(IItemStack output, IOreDictEntry oredictentry, int heat, int specHeat) + public static void addRecipe(IItemStack output, IOreDictEntry oredictentry, double heat, double specHeat) { if (oredictentry != null && oredictentry.getAmount() > 0) { @@ -61,7 +61,7 @@ public class ItemHeat } @ZenMethod - public static void addRecipe(IItemStack output, IOreDictEntry oredictentry, int heat) + public static void addRecipe(IItemStack output, IOreDictEntry oredictentry, double heat) { addRecipe(output, oredictentry, heat, 1); } @@ -85,12 +85,12 @@ public class ItemHeat private static class addHeatingAction implements IUndoableAction { - private ItemStack inputStack; - private ItemStack outputStack; - private int meltingPoint; - private int specificHeat; + ItemStack inputStack; + ItemStack outputStack; + double meltingPoint; + double specificHeat; - public addHeatingAction(ItemStack output, ItemStack input, int heat, int specHeat) + public addHeatingAction(ItemStack output, ItemStack input, double heat, double specHeat) { this.outputStack = output; this.inputStack = input; @@ -101,7 +101,7 @@ public class ItemHeat @Override public void apply() { - HeatRegistry.getInstance().addIndex(new HeatIndex(inputStack, specificHeat, meltingPoint, outputStack).setMinMax(outputStack.getItemDamage())); + HeatRegistry.getInstance().addIndex(new HeatIndex(inputStack, specificHeat, meltingPoint, outputStack).setKeepNBT(true).setMinMax(outputStack.getItemDamage())); } @Override diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Loom.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Loom.java similarity index 98% rename from src/main/java/com/JAWolfe/tfptweaks/minetweaker/Loom.java rename to src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Loom.java index ceb691b..ebc0845 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Loom.java +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Loom.java @@ -1,4 +1,4 @@ -package com.JAWolfe.tfptweaks.minetweaker; +package com.JAWolfe.tfptweaks.minetweaker.TFC; import java.util.List; diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Quern.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Quern.java similarity index 99% rename from src/main/java/com/JAWolfe/tfptweaks/minetweaker/Quern.java rename to src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Quern.java index a87c7f9..15c2e46 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/Quern.java +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFC/Quern.java @@ -1,4 +1,4 @@ -package com.JAWolfe.tfptweaks.minetweaker; +package com.JAWolfe.tfptweaks.minetweaker.TFC; import java.util.List; diff --git a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFCTweaker.java b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFCTweaker.java index 452806e..3741d81 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFCTweaker.java +++ b/src/main/java/com/JAWolfe/tfptweaks/minetweaker/TFCTweaker.java @@ -1,5 +1,11 @@ package com.JAWolfe.tfptweaks.minetweaker; +import com.JAWolfe.tfptweaks.minetweaker.Buildcraft.AssemblyTable; +import com.JAWolfe.tfptweaks.minetweaker.TFC.Anvil; +import com.JAWolfe.tfptweaks.minetweaker.TFC.Barrel; +import com.JAWolfe.tfptweaks.minetweaker.TFC.ItemHeat; +import com.JAWolfe.tfptweaks.minetweaker.TFC.Loom; +import com.JAWolfe.tfptweaks.minetweaker.TFC.Quern; import com.JAWolfe.tfptweaks.reference.ConfigSettings; import cpw.mods.fml.common.Loader; @@ -14,8 +20,13 @@ public class TFCTweaker MineTweakerAPI.registerClass(ItemHeat.class); MineTweakerAPI.registerClass(Loom.class); MineTweakerAPI.registerClass(Quern.class); - //MineTweakerAPI.registerClass(Barrel.class); - //MineTweakerAPI.registerClass(Anvil.class); + MineTweakerAPI.registerClass(Barrel.class); + MineTweakerAPI.registerClass(Anvil.class); + } + + if(Loader.isModLoaded("BuildCraft|Core")) + { + MineTweakerAPI.registerClass(AssemblyTable.class); } } } diff --git a/src/main/java/com/JAWolfe/tfptweaks/reference/ConfigSettings.java b/src/main/java/com/JAWolfe/tfptweaks/reference/ConfigSettings.java index c69cbe8..615c0c1 100644 --- a/src/main/java/com/JAWolfe/tfptweaks/reference/ConfigSettings.java +++ b/src/main/java/com/JAWolfe/tfptweaks/reference/ConfigSettings.java @@ -9,9 +9,13 @@ public class ConfigSettings public static boolean FSPWailaIntegration = true; public static boolean VanillaMagicScaling = true; public static int VanillaMagicMultipier = 25; + public static boolean FiniteMagicDamageCutoff = true; + public static int FiniteMagicDamageCutoffValue = 0; + public static int PercentMagicDamageCutoffValue = 10; public static boolean VanillaDamageScaling = true; public static boolean VanillaPvPDamageScaling = true; - public static int VanillaPvPDamageMultipier = 25; + public static int VanillaPvPWeaponDamageMultipier = 25; + public static int VanillaPvPNonWeaponDamageMultipier = 10; public static boolean VanillaMobDamageScaling = true; public static int VanillaMobDamageMultipier = 50; public static boolean InstantHealingScaling = true; diff --git a/src/main/java/com/JAWolfe/tfptweaks/reference/ReferenceLists.java b/src/main/java/com/JAWolfe/tfptweaks/reference/ReferenceLists.java new file mode 100644 index 0000000..f9a4e4e --- /dev/null +++ b/src/main/java/com/JAWolfe/tfptweaks/reference/ReferenceLists.java @@ -0,0 +1,51 @@ +package com.JAWolfe.tfptweaks.reference; + +import java.util.ArrayList; +import java.util.List; + +import com.JAWolfe.tfptweaks.LogHelper; + +import net.minecraft.item.ItemStack; + +public class ReferenceLists +{ + private static final ReferenceLists INSTANCE = new ReferenceLists(); + public static final ReferenceLists getInstance() + { + return INSTANCE; + } + + public List anvilIngredList; + + private ReferenceLists() + { + anvilIngredList = new ArrayList(); + } + + public void addAnvilIngred(ItemStack newIS) + { + if(!isAnvilInged(newIS)) + { + anvilIngredList.add(newIS); + } + } + + public boolean isAnvilInged(ItemStack is) + { + for(int i = 0; i < anvilIngredList.size(); i++) + { + ItemStack listIS = anvilIngredList.get(i); + if(is != null && listIS != null) + { + if(is.getItem() != listIS.getItem()) + return false; + + if(is.getItemDamage() != listIS.getItemDamage()) + return false; + } + else if(is == null && listIS != null || is != null && listIS == null) + return false; + } + return true; + } +}