From d10fd21692bad49e75a7d665005df940c91942f8 Mon Sep 17 00:00:00 2001 From: Lance5057 Date: Sat, 6 Aug 2016 21:47:17 -0500 Subject: Launch update Only a week behind... --- src/api/java/thaumcraft/api/BlockCoordinates.java | 207 +++--- src/api/java/thaumcraft/api/IArchitect.java | 13 +- src/api/java/thaumcraft/api/IGoggles.java | 5 +- src/api/java/thaumcraft/api/IRepairable.java | 6 +- .../java/thaumcraft/api/IRepairableExtended.java | 7 +- src/api/java/thaumcraft/api/IRunicArmor.java | 6 +- src/api/java/thaumcraft/api/IScribeTools.java | 6 +- src/api/java/thaumcraft/api/IVisDiscountGear.java | 8 +- src/api/java/thaumcraft/api/IWarpingGear.java | 6 +- src/api/java/thaumcraft/api/ItemApi.java | 53 +- src/api/java/thaumcraft/api/ItemRunic.java | 26 +- src/api/java/thaumcraft/api/ThaumcraftApi.java | 646 ++++++++++-------- .../java/thaumcraft/api/ThaumcraftApiHelper.java | 728 +++++++++++---------- src/api/java/thaumcraft/api/TileThaumcraft.java | 61 +- src/api/java/thaumcraft/api/WorldCoordinates.java | 224 ++++--- src/api/java/thaumcraft/api/aspects/Aspect.java | 406 ++++++++---- .../java/thaumcraft/api/aspects/AspectList.java | 340 ++++++---- .../thaumcraft/api/aspects/AspectSourceHelper.java | 60 +- .../thaumcraft/api/aspects/IAspectContainer.java | 27 +- .../java/thaumcraft/api/aspects/IAspectSource.java | 9 +- .../api/aspects/IEssentiaContainerItem.java | 9 +- .../thaumcraft/api/aspects/IEssentiaTransport.java | 27 +- .../thaumcraft/api/crafting/CrucibleRecipe.java | 127 ++-- .../thaumcraft/api/crafting/IArcaneRecipe.java | 49 +- .../api/crafting/IInfusionStabiliser.java | 5 +- .../api/crafting/InfusionEnchantmentRecipe.java | 240 ++++--- .../thaumcraft/api/crafting/InfusionRecipe.java | 217 +++--- .../api/crafting/ShapedArcaneRecipe.java | 492 +++++++------- .../api/crafting/ShapelessArcaneRecipe.java | 290 ++++---- .../DamageSourceIndirectThaumcraftEntity.java | 32 +- .../api/damagesource/DamageSourceThaumcraft.java | 53 +- .../java/thaumcraft/api/entities/IEldritchMob.java | 3 +- .../java/thaumcraft/api/entities/ITaintedMob.java | 3 +- .../api/internal/DummyInternalMethodHandler.java | 52 +- .../api/internal/IInternalMethodHandler.java | 23 +- .../api/internal/WeightedRandomLoot.java | 26 +- src/api/java/thaumcraft/api/nodes/INode.java | 13 +- src/api/java/thaumcraft/api/nodes/IRevealer.java | 6 +- .../java/thaumcraft/api/nodes/NodeModifier.java | 4 +- src/api/java/thaumcraft/api/nodes/NodeType.java | 4 +- src/api/java/thaumcraft/api/package-info.java | 1 + .../thaumcraft/api/potions/PotionFluxTaint.java | 77 +-- .../thaumcraft/api/potions/PotionVisExhaust.java | 51 +- .../thaumcraft/api/research/IScanEventHandler.java | 3 +- .../api/research/ResearchCategories.java | 117 ++-- .../api/research/ResearchCategoryList.java | 45 +- .../java/thaumcraft/api/research/ResearchItem.java | 639 +++++++++--------- .../java/thaumcraft/api/research/ResearchPage.java | 195 +++--- .../java/thaumcraft/api/research/ScanResult.java | 46 +- .../java/thaumcraft/api/visnet/TileVisNode.java | 185 +++--- .../java/thaumcraft/api/visnet/VisNetHandler.java | 273 ++++---- .../thaumcraft/api/wands/FocusUpgradeType.java | 205 +++--- .../thaumcraft/api/wands/IWandRodOnUpdate.java | 3 +- .../thaumcraft/api/wands/IWandTriggerManager.java | 8 +- src/api/java/thaumcraft/api/wands/IWandable.java | 11 +- .../java/thaumcraft/api/wands/ItemFocusBasic.java | 290 ++++---- src/api/java/thaumcraft/api/wands/StaffRod.java | 45 +- src/api/java/thaumcraft/api/wands/WandCap.java | 118 ++-- src/api/java/thaumcraft/api/wands/WandRod.java | 135 ++-- .../thaumcraft/api/wands/WandTriggerRegistry.java | 132 ++-- 60 files changed, 3995 insertions(+), 3103 deletions(-) (limited to 'src/api/java/thaumcraft') diff --git a/src/api/java/thaumcraft/api/BlockCoordinates.java b/src/api/java/thaumcraft/api/BlockCoordinates.java index 27a28f8..9fb5dd8 100644 --- a/src/api/java/thaumcraft/api/BlockCoordinates.java +++ b/src/api/java/thaumcraft/api/BlockCoordinates.java @@ -5,104 +5,111 @@ import net.minecraft.tileentity.TileEntity; public class BlockCoordinates implements Comparable { - public int x; - - /** the y coordinate */ - public int y; - - /** the z coordinate */ - public int z; - - public BlockCoordinates() {} - - public BlockCoordinates(int par1, int par2, int par3) - { - this.x = par1; - this.y = par2; - this.z = par3; - } - - public BlockCoordinates(TileEntity tile) - { - this.x = tile.xCoord; - this.y = tile.yCoord; - this.z = tile.zCoord; - } - - public BlockCoordinates(BlockCoordinates par1ChunkCoordinates) - { - this.x = par1ChunkCoordinates.x; - this.y = par1ChunkCoordinates.y; - this.z = par1ChunkCoordinates.z; - } - - public boolean equals(Object par1Obj) - { - if (!(par1Obj instanceof BlockCoordinates)) - { - return false; - } - else - { - BlockCoordinates coordinates = (BlockCoordinates)par1Obj; - return this.x == coordinates.x && this.y == coordinates.y && this.z == coordinates.z ; - } - } - - public int hashCode() - { - return this.x + this.y << 8 + this.z << 16; - } - - /** - * Compare the coordinate with another coordinate - */ - public int compareWorldCoordinate(BlockCoordinates par1) - { - return this.y == par1.y ? (this.z == par1.z ? this.x - par1.x : this.z - par1.z) : this.y - par1.y; - } - - public void set(int par1, int par2, int par3, int d) - { - this.x = par1; - this.y = par2; - this.z = par3; - } - - /** - * Returns the squared distance between this coordinates and the coordinates given as argument. - */ - public float getDistanceSquared(int par1, int par2, int par3) - { - float f = (float)(this.x - par1); - float f1 = (float)(this.y - par2); - float f2 = (float)(this.z - par3); - return f * f + f1 * f1 + f2 * f2; - } - - /** - * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. - */ - public float getDistanceSquaredToWorldCoordinates(BlockCoordinates par1ChunkCoordinates) - { - return this.getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); - } - - public int compareTo(Object par1Obj) - { - return this.compareWorldCoordinate((BlockCoordinates)par1Obj); - } - - public void readNBT(NBTTagCompound nbt) { - this.x = nbt.getInteger("b_x"); - this.y = nbt.getInteger("b_y"); - this.z = nbt.getInteger("b_z"); - } - - public void writeNBT(NBTTagCompound nbt) { - nbt.setInteger("b_x",x); - nbt.setInteger("b_y",y); - nbt.setInteger("b_z",z); - } - + public int x; + + /** the y coordinate */ + public int y; + + /** the z coordinate */ + public int z; + + public BlockCoordinates() + { + } + + public BlockCoordinates(int par1, int par2, int par3) + { + x = par1; + y = par2; + z = par3; + } + + public BlockCoordinates(TileEntity tile) + { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + } + + public BlockCoordinates(BlockCoordinates par1ChunkCoordinates) + { + x = par1ChunkCoordinates.x; + y = par1ChunkCoordinates.y; + z = par1ChunkCoordinates.z; + } + + @Override + public boolean equals(Object par1Obj) + { + if(!(par1Obj instanceof BlockCoordinates)) + { + return false; + } + else + { + final BlockCoordinates coordinates = (BlockCoordinates) par1Obj; + return x == coordinates.x && y == coordinates.y && z == coordinates.z; + } + } + + @Override + public int hashCode() + { + return x + y << 8 + z << 16; + } + + /** + * Compare the coordinate with another coordinate + */ + public int compareWorldCoordinate(BlockCoordinates par1) + { + return y == par1.y ? (z == par1.z ? x - par1.x : z - par1.z) : y - par1.y; + } + + public void set(int par1, int par2, int par3, int d) + { + x = par1; + y = par2; + z = par3; + } + + /** + * Returns the squared distance between this coordinates and the coordinates given as argument. + */ + public float getDistanceSquared(int par1, int par2, int par3) + { + final float f = x - par1; + final float f1 = y - par2; + final float f2 = z - par3; + return f * f + f1 * f1 + f2 * f2; + } + + /** + * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. + */ + public float getDistanceSquaredToWorldCoordinates(BlockCoordinates par1ChunkCoordinates) + { + return getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); + } + + @Override + public int compareTo(Object par1Obj) + { + return compareWorldCoordinate((BlockCoordinates) par1Obj); + } + + public void readNBT(NBTTagCompound nbt) + { + x = nbt.getInteger("b_x"); + y = nbt.getInteger("b_y"); + z = nbt.getInteger("b_z"); + } + + public void writeNBT(NBTTagCompound nbt) + { + nbt.setInteger("b_x", x); + nbt.setInteger("b_y", y); + nbt.setInteger("b_z", z); + } + } diff --git a/src/api/java/thaumcraft/api/IArchitect.java b/src/api/java/thaumcraft/api/IArchitect.java index c733af5..ba25d98 100644 --- a/src/api/java/thaumcraft/api/IArchitect.java +++ b/src/api/java/thaumcraft/api/IArchitect.java @@ -6,20 +6,21 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IArchitect { +public interface IArchitect +{ /** * Returns a list of blocks that should be highlighted in world. */ - public ArrayList getArchitectBlocks(ItemStack stack, World world, - int x, int y, int z, int side, EntityPlayer player); - + public ArrayList getArchitectBlocks(ItemStack stack, World world, int x, int y, int z, int side, EntityPlayer player); + /** * which axis should be displayed. */ public boolean showAxis(ItemStack stack, World world, EntityPlayer player, int side, EnumAxis axis); - - public enum EnumAxis { + + public enum EnumAxis + { X, // east / west Y, // up / down Z; // north / south diff --git a/src/api/java/thaumcraft/api/IGoggles.java b/src/api/java/thaumcraft/api/IGoggles.java index 2f53d81..743e0e9 100644 --- a/src/api/java/thaumcraft/api/IGoggles.java +++ b/src/api/java/thaumcraft/api/IGoggles.java @@ -12,8 +12,9 @@ import net.minecraft.item.ItemStack; * */ -public interface IGoggles { - +public interface IGoggles +{ + /* * If this method returns true things like block essentia contents will be shown. */ diff --git a/src/api/java/thaumcraft/api/IRepairable.java b/src/api/java/thaumcraft/api/IRepairable.java index 48c6dff..a742f2b 100644 --- a/src/api/java/thaumcraft/api/IRepairable.java +++ b/src/api/java/thaumcraft/api/IRepairable.java @@ -1,13 +1,11 @@ package thaumcraft.api; - - /** * @author Azanor * Items, armor and tools with this interface can receive the Repair enchantment. * Repairs 1 point of durability every 10 seconds (2 for repair II) */ -public interface IRepairable { - +public interface IRepairable +{ } diff --git a/src/api/java/thaumcraft/api/IRepairableExtended.java b/src/api/java/thaumcraft/api/IRepairableExtended.java index 3382712..87e4479 100644 --- a/src/api/java/thaumcraft/api/IRepairableExtended.java +++ b/src/api/java/thaumcraft/api/IRepairableExtended.java @@ -3,15 +3,14 @@ package thaumcraft.api; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - - /** * @author Azanor * Items, armor and tools with this interface can receive the Repair enchantment. * Repairs 1 point of durability every 10 seconds (2 for repair II) */ -public interface IRepairableExtended extends IRepairable { - +public interface IRepairableExtended extends IRepairable +{ + public boolean doRepair(ItemStack stack, EntityPlayer player, int enchantlevel); } diff --git a/src/api/java/thaumcraft/api/IRunicArmor.java b/src/api/java/thaumcraft/api/IRunicArmor.java index 5dd3110..d9ed818 100644 --- a/src/api/java/thaumcraft/api/IRunicArmor.java +++ b/src/api/java/thaumcraft/api/IRunicArmor.java @@ -11,12 +11,12 @@ import net.minecraft.item.ItemStack; * */ -public interface IRunicArmor { - +public interface IRunicArmor +{ + /** * returns how much charge this item can provide. This is the base shielding value - any hardening is stored and calculated internally. */ public int getRunicCharge(ItemStack itemstack); - } diff --git a/src/api/java/thaumcraft/api/IScribeTools.java b/src/api/java/thaumcraft/api/IScribeTools.java index 8800fa5..d6dbb8d 100644 --- a/src/api/java/thaumcraft/api/IScribeTools.java +++ b/src/api/java/thaumcraft/api/IScribeTools.java @@ -1,6 +1,5 @@ package thaumcraft.api; - /** * * @author Azanor @@ -9,6 +8,7 @@ package thaumcraft.api; * */ -public interface IScribeTools { - +public interface IScribeTools +{ + } diff --git a/src/api/java/thaumcraft/api/IVisDiscountGear.java b/src/api/java/thaumcraft/api/IVisDiscountGear.java index 3793ea3..6032b07 100644 --- a/src/api/java/thaumcraft/api/IVisDiscountGear.java +++ b/src/api/java/thaumcraft/api/IVisDiscountGear.java @@ -4,17 +4,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.Aspect; - - - /** * @author Azanor * ItemArmor with this interface will grant a discount to the vis cost of actions the wearer performs with casting wands. * The amount returned is the percentage by which the cost is discounted. There is a built-int max discount of 50%, but * individual items really shouldn't have a discount more than 5% */ -public interface IVisDiscountGear { - +public interface IVisDiscountGear +{ + int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect); } diff --git a/src/api/java/thaumcraft/api/IWarpingGear.java b/src/api/java/thaumcraft/api/IWarpingGear.java index e7415ab..674054f 100644 --- a/src/api/java/thaumcraft/api/IWarpingGear.java +++ b/src/api/java/thaumcraft/api/IWarpingGear.java @@ -11,12 +11,12 @@ import net.minecraft.item.ItemStack; * */ -public interface IWarpingGear { - +public interface IWarpingGear +{ + /** * returns how much warp this item adds while worn or held. */ public int getWarp(ItemStack itemstack, EntityPlayer player); - } diff --git a/src/api/java/thaumcraft/api/ItemApi.java b/src/api/java/thaumcraft/api/ItemApi.java index 25dda28..3aea4f1 100644 --- a/src/api/java/thaumcraft/api/ItemApi.java +++ b/src/api/java/thaumcraft/api/ItemApi.java @@ -13,38 +13,53 @@ import cpw.mods.fml.common.FMLLog; * require a bit of work for you to get hold of everything you need. * */ -public class ItemApi { - - public static ItemStack getItem(String itemString, int meta) { +public class ItemApi +{ + + public static ItemStack getItem(String itemString, int meta) + { ItemStack item = null; - try { - String itemClass = "thaumcraft.common.config.ConfigItems"; - Object obj = Class.forName(itemClass).getField(itemString).get(null); - if (obj instanceof Item) { - item = new ItemStack((Item) obj,1,meta); - } else if (obj instanceof ItemStack) { + try + { + final String itemClass = "thaumcraft.common.config.ConfigItems"; + final Object obj = Class.forName(itemClass).getField(itemString).get(null); + if(obj instanceof Item) + { + item = new ItemStack((Item) obj, 1, meta); + } + else if(obj instanceof ItemStack) + { item = (ItemStack) obj; } - } catch (Exception ex) { + } + catch(final Exception ex) + { FMLLog.warning("[Thaumcraft] Could not retrieve item identified by: " + itemString); } return item; } - - public static ItemStack getBlock(String itemString, int meta) { + + public static ItemStack getBlock(String itemString, int meta) + { ItemStack item = null; - try { - String itemClass = "thaumcraft.common.config.ConfigBlocks"; - Object obj = Class.forName(itemClass).getField(itemString).get(null); - if (obj instanceof Block) { - item = new ItemStack((Block) obj,1,meta); - } else if (obj instanceof ItemStack) { + try + { + final String itemClass = "thaumcraft.common.config.ConfigBlocks"; + final Object obj = Class.forName(itemClass).getField(itemString).get(null); + if(obj instanceof Block) + { + item = new ItemStack((Block) obj, 1, meta); + } + else if(obj instanceof ItemStack) + { item = (ItemStack) obj; } - } catch (Exception ex) { + } + catch(final Exception ex) + { FMLLog.warning("[Thaumcraft] Could not retrieve block identified by: " + itemString); } diff --git a/src/api/java/thaumcraft/api/ItemRunic.java b/src/api/java/thaumcraft/api/ItemRunic.java index 80251f5..3517558 100644 --- a/src/api/java/thaumcraft/api/ItemRunic.java +++ b/src/api/java/thaumcraft/api/ItemRunic.java @@ -3,19 +3,21 @@ package thaumcraft.api; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemRunic extends Item implements IRunicArmor { - - int charge; - - public ItemRunic (int charge) - { - super(); - this.charge = charge; - } - +public class ItemRunic extends Item implements IRunicArmor +{ + + int charge; + + public ItemRunic(int charge) + { + super(); + this.charge = charge; + } + @Override - public int getRunicCharge(ItemStack itemstack) { + public int getRunicCharge(ItemStack itemstack) + { return charge; } - + } diff --git a/src/api/java/thaumcraft/api/ThaumcraftApi.java b/src/api/java/thaumcraft/api/ThaumcraftApi.java index fbf7880..c01d521 100644 --- a/src/api/java/thaumcraft/api/ThaumcraftApi.java +++ b/src/api/java/thaumcraft/api/ThaumcraftApi.java @@ -31,7 +31,6 @@ import thaumcraft.api.research.ResearchCategoryList; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; - /** * @author Azanor * @@ -39,66 +38,76 @@ import thaumcraft.api.research.ResearchPage; * IMPORTANT: If you are adding your own aspects to items it is a good idea to do it AFTER Thaumcraft adds its aspects, otherwise odd things may happen. * */ -public class ThaumcraftApi { - +public class ThaumcraftApi +{ + //Materials - public static ToolMaterial toolMatThaumium = EnumHelper.addToolMaterial("THAUMIUM", 3, 400, 7F, 2, 22); - public static ToolMaterial toolMatVoid = EnumHelper.addToolMaterial("VOID", 4, 150, 8F, 3, 10); - public static ToolMaterial toolMatElemental = EnumHelper.addToolMaterial("THAUMIUM_ELEMENTAL", 3, 1500, 10F, 3, 18); - public static ArmorMaterial armorMatThaumium = EnumHelper.addArmorMaterial("THAUMIUM", 25, new int[] { 2, 6, 5, 2 }, 25); - public static ArmorMaterial armorMatSpecial = EnumHelper.addArmorMaterial("SPECIAL", 25, new int[] { 1, 3, 2, 1 }, 25); - public static ArmorMaterial armorMatThaumiumFortress = EnumHelper.addArmorMaterial("FORTRESS", 40, new int[] { 3, 7, 6, 3 }, 25); - public static ArmorMaterial armorMatVoid = EnumHelper.addArmorMaterial("VOID", 10, new int[] { 3, 7, 6, 3 }, 10); - public static ArmorMaterial armorMatVoidFortress = EnumHelper.addArmorMaterial("VOIDFORTRESS", 18, new int[] { 4, 8, 7, 4 }, 10); - + public static ToolMaterial toolMatThaumium = EnumHelper.addToolMaterial("THAUMIUM", 3, 400, 7F, 2, 22); + public static ToolMaterial toolMatVoid = EnumHelper.addToolMaterial("VOID", 4, 150, 8F, 3, 10); + public static ToolMaterial toolMatElemental = EnumHelper.addToolMaterial("THAUMIUM_ELEMENTAL", 3, 1500, 10F, 3, 18); + public static ArmorMaterial armorMatThaumium = EnumHelper.addArmorMaterial("THAUMIUM", 25, new int[] {2, 6, 5, 2}, 25); + public static ArmorMaterial armorMatSpecial = EnumHelper.addArmorMaterial("SPECIAL", 25, new int[] {1, 3, 2, 1}, 25); + public static ArmorMaterial armorMatThaumiumFortress = EnumHelper.addArmorMaterial("FORTRESS", 40, new int[] {3, 7, 6, 3}, 25); + public static ArmorMaterial armorMatVoid = EnumHelper.addArmorMaterial("VOID", 10, new int[] {3, 7, 6, 3}, 10); + public static ArmorMaterial armorMatVoidFortress = EnumHelper.addArmorMaterial("VOIDFORTRESS", 18, new int[] {4, 8, 7, 4}, 10); + //Enchantment references - public static int enchantFrugal; - public static int enchantPotency; - public static int enchantWandFortune; - public static int enchantHaste; - public static int enchantRepair; - + public static int enchantFrugal; + public static int enchantPotency; + public static int enchantWandFortune; + public static int enchantHaste; + public static int enchantRepair; + //Miscellaneous /** * Portable Hole Block-id Blacklist. * Simply add the block-id's of blocks you don't want the portable hole to go through. */ - public static ArrayList portableHoleBlackList = new ArrayList(); - + public static ArrayList portableHoleBlackList = new ArrayList(); + //Internal (Do not alter this unless you like pretty explosions) //Calling methods from this will only work properly once Thaumcraft is past the FMLPreInitializationEvent phase. - public static IInternalMethodHandler internalMethods = new DummyInternalMethodHandler(); - + public static IInternalMethodHandler internalMethods = new DummyInternalMethodHandler(); + //RESEARCH///////////////////////////////////////// - public static ArrayList scanEventhandlers = new ArrayList(); - public static ArrayList scanEntities = new ArrayList(); - public static class EntityTagsNBT { - public EntityTagsNBT(String name, Object value) { + public static ArrayList scanEventhandlers = new ArrayList(); + public static ArrayList scanEntities = new ArrayList(); + + public static class EntityTagsNBT + { + public EntityTagsNBT(String name, Object value) + { this.name = name; this.value = value; } - public String name; - public Object value; + + public String name; + public Object value; } - public static class EntityTags { - public EntityTags(String entityName, AspectList aspects, EntityTagsNBT... nbts) { + + public static class EntityTags + { + public EntityTags(String entityName, AspectList aspects, EntityTagsNBT... nbts) + { this.entityName = entityName; this.nbts = nbts; this.aspects = aspects; } - public String entityName; - public EntityTagsNBT[] nbts; - public AspectList aspects; + + public String entityName; + public EntityTagsNBT[] nbts; + public AspectList aspects; } - + /** * not really working atm, so ignore it for now * @param scanEventHandler */ - public static void registerScanEventhandler(IScanEventHandler scanEventHandler) { + public static void registerScanEventhandler(IScanEventHandler scanEventHandler) + { scanEventhandlers.add(scanEventHandler); } - + /** * This is used to add aspects to entities which you can then scan using a thaumometer. * Also used to calculate vis drops from mobs. @@ -109,83 +118,92 @@ public class ThaumcraftApi { *
ThaumcraftApi.registerEntityTag("Skeleton", (new AspectList()).add(Aspect.DEATH, 5)); *
ThaumcraftApi.registerEntityTag("Skeleton", (new AspectList()).add(Aspect.DEATH, 8), new NBTTagByte("SkeletonType",(byte) 1)); */ - public static void registerEntityTag(String entityName, AspectList aspects, EntityTagsNBT... nbt ) { - scanEntities.add(new EntityTags(entityName,aspects,nbt)); + public static void registerEntityTag(String entityName, AspectList aspects, EntityTagsNBT... nbt) + { + scanEntities.add(new EntityTags(entityName, aspects, nbt)); } - + //RECIPES///////////////////////////////////////// - private static ArrayList craftingRecipes = new ArrayList(); - private static HashMap smeltingBonus = new HashMap(); - + private static ArrayList craftingRecipes = new ArrayList(); + private static HashMap smeltingBonus = new HashMap(); + /** * This method is used to determine what bonus items are generated when the infernal furnace smelts items * @param in The input of the smelting operation. e.g. new ItemStack(Block.oreGold) * @param out The bonus item that can be produced from the smelting operation e.g. new ItemStack(nuggetGold,0,0). * Stacksize should be 0 unless you want to guarantee that at least 1 item is always produced. */ - public static void addSmeltingBonus(ItemStack in, ItemStack out) { - smeltingBonus.put( - Arrays.asList(in.getItem(),in.getItemDamage()), - new ItemStack(out.getItem(),0,out.getItemDamage())); + public static void addSmeltingBonus(ItemStack in, ItemStack out) + { + smeltingBonus.put(Arrays.asList(in.getItem(), in.getItemDamage()), new ItemStack( + out.getItem(), 0, out.getItemDamage())); } - + /** * This method is used to determine what bonus items are generated when the infernal furnace smelts items * @param in The ore dictionary input of the smelting operation. e.g. "oreGold" * @param out The bonus item that can be produced from the smelting operation e.g. new ItemStack(nuggetGold,0,0). * Stacksize should be 0 unless you want to guarantee that at least 1 item is always produced. */ - public static void addSmeltingBonus(String in, ItemStack out) { - smeltingBonus.put( in, new ItemStack(out.getItem(),0,out.getItemDamage())); + public static void addSmeltingBonus(String in, ItemStack out) + { + smeltingBonus.put(in, new ItemStack(out.getItem(), 0, + out.getItemDamage())); } - + /** * Returns the bonus item produced from a smelting operation in the infernal furnace * @param in The input of the smelting operation. e.g. new ItemStack(oreGold) * @return the The bonus item that can be produced */ - public static ItemStack getSmeltingBonus(ItemStack in) { - ItemStack out = smeltingBonus.get(Arrays.asList(in.getItem(),in.getItemDamage())); - if (out==null) { - out = smeltingBonus.get(Arrays.asList(in.getItem(),OreDictionary.WILDCARD_VALUE)); + public static ItemStack getSmeltingBonus(ItemStack in) + { + ItemStack out = smeltingBonus.get(Arrays.asList(in.getItem(), in.getItemDamage())); + if(out == null) + { + out = smeltingBonus.get(Arrays.asList(in.getItem(), OreDictionary.WILDCARD_VALUE)); } - if (out==null) { - String od = OreDictionary.getOreName( OreDictionary.getOreID(in)); + if(out == null) + { + final String od = OreDictionary.getOreName(OreDictionary.getOreID(in)); out = smeltingBonus.get(od); } return out; } - - public static List getCraftingRecipes() { + + public static List getCraftingRecipes() + { return craftingRecipes; } - + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param result the recipe output * @param aspects the vis cost per aspect. * @param recipe The recipe. Format is exactly the same as vanilla recipes. Input itemstacks are NBT sensitive. */ - public static ShapedArcaneRecipe addArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object ... recipe) - { - ShapedArcaneRecipe r= new ShapedArcaneRecipe(research, result, aspects, recipe); - craftingRecipes.add(r); + public static ShapedArcaneRecipe addArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + final ShapedArcaneRecipe r = new ShapedArcaneRecipe(research, result, + aspects, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param result the recipe output * @param aspects the vis cost per aspect * @param recipe The recipe. Format is exactly the same as vanilla shapeless recipes. Input itemstacks are NBT sensitive. */ - public static ShapelessArcaneRecipe addShapelessArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object ... recipe) - { - ShapelessArcaneRecipe r = new ShapelessArcaneRecipe(research, result, aspects, recipe); - craftingRecipes.add(r); + public static ShapelessArcaneRecipe addShapelessArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + final ShapelessArcaneRecipe r = new ShapelessArcaneRecipe(research, result, + aspects, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param result the recipe output. It can either be an itemstack or an nbt compound tag that will be added to the central item @@ -197,14 +215,18 @@ public class ThaumcraftApi { * Infusion crafting components are automatically "fuzzy" and the oredict will be checked for possible matches. * */ - public static InfusionRecipe addInfusionCraftingRecipe(String research, Object result, int instability, AspectList aspects, ItemStack input,ItemStack[] recipe) - { - if (!(result instanceof ItemStack || result instanceof Object[])) return null; - InfusionRecipe r= new InfusionRecipe(research, result, instability, aspects, input, recipe); - craftingRecipes.add(r); + public static InfusionRecipe addInfusionCraftingRecipe(String research, Object result, int instability, AspectList aspects, ItemStack input, ItemStack[] recipe) + { + if(!(result instanceof ItemStack || result instanceof Object[])) + { + return null; + } + final InfusionRecipe r = new InfusionRecipe(research, result, instability, + aspects, input, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param enchantment the enchantment that will be applied to the item @@ -216,158 +238,214 @@ public class ThaumcraftApi { * */ public static InfusionEnchantmentRecipe addInfusionEnchantmentRecipe(String research, Enchantment enchantment, int instability, AspectList aspects, ItemStack[] recipe) - { - InfusionEnchantmentRecipe r= new InfusionEnchantmentRecipe(research, enchantment, instability, aspects, recipe); - craftingRecipes.add(r); + { + final InfusionEnchantmentRecipe r = new InfusionEnchantmentRecipe(research, + enchantment, instability, aspects, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param stack the recipe result * @return the recipe */ - public static InfusionRecipe getInfusionRecipe(ItemStack res) { - for (Object r:getCraftingRecipes()) { - if (r instanceof InfusionRecipe) { - if (((InfusionRecipe)r).getRecipeOutput() instanceof ItemStack) { - if (((ItemStack) ((InfusionRecipe)r).getRecipeOutput()).isItemEqual(res)) - return (InfusionRecipe)r; - } + public static InfusionRecipe getInfusionRecipe(ItemStack res) + { + for(final Object r : getCraftingRecipes()) + { + if(r instanceof InfusionRecipe) + { + if(((InfusionRecipe) r).getRecipeOutput() instanceof ItemStack) + { + if(((ItemStack) ((InfusionRecipe) r).getRecipeOutput()).isItemEqual(res)) + { + return (InfusionRecipe) r; + } + } } } return null; } - - /** - * @param key the research key required for this recipe to work. - * @param result the output result - * @param catalyst an itemstack of the catalyst or a string if it is an ore dictionary item - * @param cost the vis cost - * @param tags the aspects required to craft this - */ - public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) { - CrucibleRecipe rc = new CrucibleRecipe(key, result, catalyst, tags); - getCraftingRecipes().add(rc); + /** + * @param key the research key required for this recipe to work. + * @param result the output result + * @param catalyst an itemstack of the catalyst or a string if it is an ore dictionary item + * @param cost the vis cost + * @param tags the aspects required to craft this + */ + public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) + { + final CrucibleRecipe rc = new CrucibleRecipe(key, result, catalyst, tags); + getCraftingRecipes().add(rc); return rc; } - - + /** * @param stack the recipe result * @return the recipe */ - public static CrucibleRecipe getCrucibleRecipe(ItemStack stack) { - for (Object r:getCraftingRecipes()) { - if (r instanceof CrucibleRecipe) { - if (((CrucibleRecipe)r).getRecipeOutput().isItemEqual(stack)) - return (CrucibleRecipe)r; + public static CrucibleRecipe getCrucibleRecipe(ItemStack stack) + { + for(final Object r : getCraftingRecipes()) + { + if(r instanceof CrucibleRecipe) + { + if(((CrucibleRecipe) r).getRecipeOutput().isItemEqual(stack)) + { + return (CrucibleRecipe) r; + } } } return null; } - + /** * @param hash the unique recipe code * @return the recipe */ - public static CrucibleRecipe getCrucibleRecipeFromHash(int hash) { - for (Object r:getCraftingRecipes()) { - if (r instanceof CrucibleRecipe) { - if (((CrucibleRecipe)r).hash==hash) - return (CrucibleRecipe)r; + public static CrucibleRecipe getCrucibleRecipeFromHash(int hash) + { + for(final Object r : getCraftingRecipes()) + { + if(r instanceof CrucibleRecipe) + { + if(((CrucibleRecipe) r).hash == hash) + { + return (CrucibleRecipe) r; + } } } return null; } - + /** * Used by the thaumonomicon drilldown feature. * @param stack the item * @return the thaumcraft recipe key that produces that item. */ - private static HashMap keyCache = new HashMap(); - - public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) { - int[] key = new int[] {Item.getIdFromItem(stack.getItem()),stack.getItemDamage()}; - if (keyCache.containsKey(key)) { - if (keyCache.get(key)==null) return null; - if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String)(keyCache.get(key))[0])) + private static HashMap keyCache = new HashMap(); + + public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) + { + final int[] key = new int[] {Item.getIdFromItem(stack.getItem()), stack.getItemDamage()}; + if(keyCache.containsKey(key)) + { + if(keyCache.get(key) == null) + { + return null; + } + if(ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String) (keyCache.get(key))[0])) + { return keyCache.get(key); - else + } + else + { return null; + } } - for (ResearchCategoryList rcl:ResearchCategories.researchCategories.values()) { - for (ResearchItem ri:rcl.research.values()) { - if (ri.getPages()==null) continue; - for (int a=0;a objectTags = new ConcurrentHashMap(); - public static ConcurrentHashMap groupedObjectTags = new ConcurrentHashMap(); - + + public static ConcurrentHashMap objectTags = new ConcurrentHashMap(); + public static ConcurrentHashMap groupedObjectTags = new ConcurrentHashMap(); + /** * Checks to see if the passed item/block already has aspects associated with it. * @param id * @param meta * @return */ - public static boolean exists(Item item, int meta) { - AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,meta)); - if (tmp==null) { - tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,OreDictionary.WILDCARD_VALUE)); - if (meta==OreDictionary.WILDCARD_VALUE && tmp==null) { - int index=0; - do { - tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,index)); + public static boolean exists(Item item, int meta) + { + AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item, meta)); + if(tmp == null) + { + tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item, OreDictionary.WILDCARD_VALUE)); + if(meta == OreDictionary.WILDCARD_VALUE && tmp == null) + { + int index = 0; + do + { + tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item, index)); index++; - } while (index<16 && tmp==null); + } + while(index < 16 && tmp == null); + } + if(tmp == null) + { + return false; } - if (tmp==null) return false; } - + return true; } - + /** * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:

* ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1)); * @param item the item passed. Pass OreDictionary.WILDCARD_VALUE if all damage values of this item/block should have the same aspects * @param aspects A ObjectTags object of the associated aspects */ - public static void registerObjectTag(ItemStack item, AspectList aspects) { - if (aspects==null) aspects=new AspectList(); - try { - objectTags.put(Arrays.asList(item.getItem(),item.getItemDamage()), aspects); - } catch (Exception e) {} - } - - + public static void registerObjectTag(ItemStack item, AspectList aspects) + { + if(aspects == null) + { + aspects = new AspectList(); + } + try + { + objectTags.put(Arrays.asList(item.getItem(), item.getItemDamage()), aspects); + } + catch(final Exception e) + { + } + } + /** * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:

* ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), new int[]{0,1}, (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1)); @@ -375,34 +453,53 @@ public class ThaumcraftApi { * @param meta A range of meta values if you wish to lump several item meta's together as being the "same" item (i.e. stair orientations) * @param aspects A ObjectTags object of the associated aspects */ - public static void registerObjectTag(ItemStack item, int[] meta, AspectList aspects) { - if (aspects==null) aspects=new AspectList(); - try { - objectTags.put(Arrays.asList(item.getItem(),meta[0]), aspects); - for (int m:meta) { - groupedObjectTags.put(Arrays.asList(item.getItem(),m), meta); + public static void registerObjectTag(ItemStack item, int[] meta, AspectList aspects) + { + if(aspects == null) + { + aspects = new AspectList(); + } + try + { + objectTags.put(Arrays.asList(item.getItem(), meta[0]), aspects); + for(final int m : meta) + { + groupedObjectTags.put(Arrays.asList(item.getItem(), m), meta); } - - } catch (Exception e) {} + + } + catch(final Exception e) + { + } } - + /** * Used to assign apsects to the given ore dictionary item. * @param oreDict the ore dictionary name * @param aspects A ObjectTags object of the associated aspects */ - public static void registerObjectTag(String oreDict, AspectList aspects) { - if (aspects==null) aspects=new AspectList(); - ArrayList ores = OreDictionary.getOres(oreDict); - if (ores!=null && ores.size()>0) { - for (ItemStack ore:ores) { - try { - objectTags.put(Arrays.asList(ore.getItem(), ore.getItemDamage()), aspects); - } catch (Exception e) {} + public static void registerObjectTag(String oreDict, AspectList aspects) + { + if(aspects == null) + { + aspects = new AspectList(); + } + final ArrayList ores = OreDictionary.getOres(oreDict); + if(ores != null && ores.size() > 0) + { + for(final ItemStack ore : ores) + { + try + { + objectTags.put(Arrays.asList(ore.getItem(), ore.getItemDamage()), aspects); + } + catch(final Exception e) + { + } } } } - + /** * Used to assign aspects to the given item/block. * Attempts to automatically generate aspect tags by checking registered recipes. @@ -412,90 +509,121 @@ public class ThaumcraftApi { * @param item, pass OreDictionary.WILDCARD_VALUE to meta if all damage values of this item/block should have the same aspects * @param aspects A ObjectTags object of the associated aspects */ - public static void registerComplexObjectTag(ItemStack item, AspectList aspects ) { - if (!exists(item.getItem(),item.getItemDamage())) { - AspectList tmp = ThaumcraftApiHelper.generateTags(item.getItem(), item.getItemDamage()); - if (tmp != null && tmp.size()>0) { - for(Aspect tag:tmp.getAspects()) { + public static void registerComplexObjectTag(ItemStack item, AspectList aspects) + { + if(!exists(item.getItem(), item.getItemDamage())) + { + final AspectList tmp = ThaumcraftApiHelper.generateTags(item.getItem(), item.getItemDamage()); + if(tmp != null && tmp.size() > 0) + { + for(final Aspect tag : tmp.getAspects()) + { aspects.add(tag, tmp.getAmount(tag)); } } - registerObjectTag(item,aspects); - } else { - AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item); - for(Aspect tag:aspects.getAspects()) { + registerObjectTag(item, aspects); + } + else + { + final AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item); + for(final Aspect tag : aspects.getAspects()) + { tmp.merge(tag, tmp.getAmount(tag)); } - registerObjectTag(item,tmp); + registerObjectTag(item, tmp); } } - + //WARP /////////////////////////////////////////////////////////////////////////////////////// - private static HashMap warpMap = new HashMap(); - - /** - * This method is used to determine how much warp is gained if the item is crafted. The warp - * added is "sticky" warp - * @param craftresult The item crafted - * @param amount how much warp is gained - */ - public static void addWarpToItem(ItemStack craftresult, int amount) { - warpMap.put(Arrays.asList(craftresult.getItem(),craftresult.getItemDamage()),amount); + private static HashMap warpMap = new HashMap(); + + /** + * This method is used to determine how much warp is gained if the item is crafted. The warp + * added is "sticky" warp + * @param craftresult The item crafted + * @param amount how much warp is gained + */ + public static void addWarpToItem(ItemStack craftresult, int amount) + { + warpMap.put(Arrays.asList(craftresult.getItem(), craftresult.getItemDamage()), amount); + } + + /** + * This method is used to determine how much permanent warp is gained if the research is completed + * @param in The item crafted + * @param amount how much warp is gained + */ + public static void addWarpToResearch(String research, int amount) + { + warpMap.put(research, amount); + } + + /** + * Returns how much warp is gained from the item or research passed in + * @param in itemstack or string + * @return how much warp it will give + */ + public static int getWarp(Object in) + { + if(in == null) + { + return 0; } - - /** - * This method is used to determine how much permanent warp is gained if the research is completed - * @param in The item crafted - * @param amount how much warp is gained - */ - public static void addWarpToResearch(String research, int amount) { - warpMap.put(research, amount); + if(in instanceof ItemStack && warpMap.containsKey(Arrays.asList(((ItemStack) in).getItem(), ((ItemStack) in).getItemDamage()))) + { + return warpMap.get(Arrays.asList(((ItemStack) in).getItem(), ((ItemStack) in).getItemDamage())); } - - /** - * Returns how much warp is gained from the item or research passed in - * @param in itemstack or string - * @return how much warp it will give - */ - public static int getWarp(Object in) { - if (in==null) return 0; - if (in instanceof ItemStack && warpMap.containsKey(Arrays.asList(((ItemStack)in).getItem(),((ItemStack)in).getItemDamage()))) { - return warpMap.get(Arrays.asList(((ItemStack)in).getItem(),((ItemStack)in).getItemDamage())); - } else - if (in instanceof String && warpMap.containsKey((String)in)) { - return warpMap.get((String)in); - } - return 0; + else if(in instanceof String && warpMap.containsKey(in)) + { + return warpMap.get(in); } - + return 0; + } + //LOOT BAGS ////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Used to add possible loot to treasure bags. As a reference, the weight of gold coins are 2000 - * and a diamond is 50. - * The weights are the same for all loot bag types - the only difference is how many items the bag - * contains. - * @param item - * @param weight - * @param bagTypes array of which type of bag to add this loot to. Multiple types can be specified - * 0 = common, 1 = uncommon, 2 = rare - */ - public static void addLootBagItem(ItemStack item, int weight, int... bagTypes) { - if (bagTypes==null || bagTypes.length==0) - WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot(item,weight)); - else { - for (int rarity:bagTypes) { - switch(rarity) { - case 0: WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot(item,weight)); break; - case 1: WeightedRandomLoot.lootBagUncommon.add(new WeightedRandomLoot(item,weight)); break; - case 2: WeightedRandomLoot.lootBagRare.add(new WeightedRandomLoot(item,weight)); break; - } + + /** + * Used to add possible loot to treasure bags. As a reference, the weight of gold coins are 2000 + * and a diamond is 50. + * The weights are the same for all loot bag types - the only difference is how many items the bag + * contains. + * @param item + * @param weight + * @param bagTypes array of which type of bag to add this loot to. Multiple types can be specified + * 0 = common, 1 = uncommon, 2 = rare + */ + public static void addLootBagItem(ItemStack item, int weight, int... bagTypes) + { + if(bagTypes == null || bagTypes.length == 0) + { + WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot(item, + weight)); + } + else + { + for(final int rarity : bagTypes) + { + switch(rarity) + { + case 0: + WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot( + item, weight)); + break; + case 1: + WeightedRandomLoot.lootBagUncommon.add(new WeightedRandomLoot( + item, weight)); + break; + case 2: + WeightedRandomLoot.lootBagRare.add(new WeightedRandomLoot( + item, weight)); + break; } } } - + } + //CROPS ////////////////////////////////////////////////////////////////////////////////////////// - + /** * To define mod crops you need to use FMLInterModComms in your @Mod.Init method. * There are two 'types' of crops you can add. Standard crops and clickable crops. @@ -522,9 +650,9 @@ public class ThaumcraftApi { * Example: * FMLInterModComms.sendMessage("Thaumcraft", "harvestStackedCrop", new ItemStack(Block.reed,1,7)); */ - + //NATIVE CLUSTERS ////////////////////////////////////////////////////////////////////////////////// - + /** * You can define certain ores that will have a chance to produce native clusters via FMLInterModComms * in your @Mod.Init method using the "nativeCluster" string message. @@ -536,7 +664,7 @@ public class ThaumcraftApi { * Example for vanilla iron ore to produce one of my own native iron clusters (assuming default id's) at double the default chance: * FMLInterModComms.sendMessage("Thaumcraft", "nativeCluster","15,0,25016,16,2.0"); */ - + //LAMP OF GROWTH BLACKLIST /////////////////////////////////////////////////////////////////////////// /** * You can blacklist crops that should not be effected by the Lamp of Growth via FMLInterModComms @@ -545,7 +673,7 @@ public class ThaumcraftApi { * Example for vanilla wheat: * FMLInterModComms.sendMessage("Thaumcraft", "lampBlacklist", new ItemStack(Block.crops,1,OreDictionary.WILDCARD_VALUE)); */ - + //DIMENSION BLACKLIST /////////////////////////////////////////////////////////////////////////// /** * You can blacklist a dimension to not spawn certain thaumcraft features @@ -558,7 +686,7 @@ public class ThaumcraftApi { * Example: * FMLInterModComms.sendMessage("Thaumcraft", "dimensionBlacklist", "15:1"); */ - + //BIOME BLACKLIST /////////////////////////////////////////////////////////////////////////// /** * You can blacklist a biome to not spawn certain thaumcraft features @@ -571,7 +699,7 @@ public class ThaumcraftApi { * Example: * FMLInterModComms.sendMessage("Thaumcraft", "biomeBlacklist", "180:2"); */ - + //CHAMPION MOB WHITELIST /////////////////////////////////////////////////////////////////////////// /** * You can whitelist an entity class so it can rarely spawn champion versions in your @Mod.Init method using diff --git a/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java b/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java index 77d5588..83ac4d2 100644 --- a/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java +++ b/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java @@ -19,181 +19,236 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.IEssentiaTransport; -public class ThaumcraftApiHelper { - - public static AspectList cullTags(AspectList temp) { - AspectList temp2 = new AspectList(); - for (Aspect tag:temp.getAspects()) { - if (tag!=null) +public class ThaumcraftApiHelper +{ + + public static AspectList cullTags(AspectList temp) + { + final AspectList temp2 = new AspectList(); + for(final Aspect tag : temp.getAspects()) + { + if(tag != null) + { temp2.add(tag, temp.getAmount(tag)); + } } - while (temp2!=null && temp2.size()>6) { + while(temp2 != null && temp2.size() > 6) + { Aspect lowest = null; float low = Short.MAX_VALUE; - for (Aspect tag:temp2.getAspects()) { - if (tag==null) continue; - float ta=temp2.getAmount(tag); - if (tag.isPrimal()) { + for(final Aspect tag : temp2.getAspects()) + { + if(tag == null) + { + continue; + } + float ta = temp2.getAmount(tag); + if(tag.isPrimal()) + { ta *= .9f; - } else { - if (!tag.getComponents()[0].isPrimal()) { + } + else + { + if(!tag.getComponents()[0].isPrimal()) + { ta *= 1.1f; - if (!tag.getComponents()[0].getComponents()[0].isPrimal()) { + if(!tag.getComponents()[0].getComponents()[0].isPrimal()) + { ta *= 1.05f; } - if (!tag.getComponents()[0].getComponents()[1].isPrimal()) { + if(!tag.getComponents()[0].getComponents()[1].isPrimal()) + { ta *= 1.05f; } } - if (!tag.getComponents()[1].isPrimal()) { + if(!tag.getComponents()[1].isPrimal()) + { ta *= 1.1f; - if (!tag.getComponents()[1].getComponents()[0].isPrimal()) { + if(!tag.getComponents()[1].getComponents()[0].isPrimal()) + { ta *= 1.05f; } - if (!tag.getComponents()[1].getComponents()[1].isPrimal()) { + if(!tag.getComponents()[1].getComponents()[1].isPrimal()) + { ta *= 1.05f; } } } - - if (ta allAspects= new HashMap(); - private static HashMap allCompoundAspects= new HashMap(); - - public static AspectList getAllAspects(int amount) { - if (allAspects.get(amount)==null) { - AspectList al = new AspectList(); - for (Aspect aspect:Aspect.aspects.values()) { - al.add(aspect, amount); - } - allAspects.put(amount, al); - } - return allAspects.get(amount); - } - - public static AspectList getAllCompoundAspects(int amount) { - if (allCompoundAspects.get(amount)==null) { - AspectList al = new AspectList(); - for (Aspect aspect:Aspect.getCompoundAspects()) { - al.add(aspect, amount); - } - allCompoundAspects.put(amount, al); - } - return allCompoundAspects.get(amount); - } - - + + private static HashMap allAspects = new HashMap(); + private static HashMap allCompoundAspects = new HashMap(); + + public static AspectList getAllAspects(int amount) + { + if(allAspects.get(amount) == null) + { + final AspectList al = new AspectList(); + for(final Aspect aspect : Aspect.aspects.values()) + { + al.add(aspect, amount); + } + allAspects.put(amount, al); + } + return allAspects.get(amount); + } + + public static AspectList getAllCompoundAspects(int amount) + { + if(allCompoundAspects.get(amount) == null) + { + final AspectList al = new AspectList(); + for(final Aspect aspect : Aspect.getCompoundAspects()) + { + al.add(aspect, amount); + } + allCompoundAspects.put(amount, al); + } + return allCompoundAspects.get(amount); + } + /** * Use to subtract vis from a wand for most operations * Wands store vis differently so "real" vis costs need to be multiplied by 100 before calling this method @@ -205,11 +260,11 @@ public class ThaumcraftApiHelper { * false then things like frugal and potency will apply to the costs * @return was the vis successfully subtracted */ - public static boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, - AspectList cost, boolean doit, boolean crafting) { + public static boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit, boolean crafting) + { return ThaumcraftApi.internalMethods.consumeVisFromWand(wand, player, cost, doit, crafting); } - + /** * Subtract vis for use by a crafting mechanic. Costs are calculated slightly * differently and things like the frugal enchant is ignored @@ -220,11 +275,11 @@ public class ThaumcraftApiHelper { * @param doit actually subtract the vis from the wand if true - if false just simulate the result * @return was the vis successfully subtracted */ - public static boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, - AspectList cost, boolean doit) { + public static boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit) + { return ThaumcraftApi.internalMethods.consumeVisFromWandCrafting(wand, player, cost, doit); } - + /** * Subtract vis from a wand the player is carrying. Works like consumeVisFromWand in that actual vis * costs should be multiplied by 100. The costs are handled like crafting however and things like @@ -233,235 +288,236 @@ public class ThaumcraftApiHelper { * @param cost the cost of the operation. * @return was the vis successfully subtracted */ - public static boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) { + public static boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) + { return ThaumcraftApi.internalMethods.consumeVisFromInventory(player, cost); } - - + /** * This adds permanents or temporary warp to a player. It will automatically be synced clientside * @param player the player using the wand * @param amount how much warp to add. Negative amounts are only valid for temporary warp * @param temporary add temporary warp instead of permanent */ - public static void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) { + public static void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) + { ThaumcraftApi.internalMethods.addWarpToPlayer(player, amount, temporary); } - + /** * This "sticky" warp to a player. Sticky warp is permanent warp that can be removed. * It will automatically be synced clientside * @param player the player using the wand * @param amount how much warp to add. Can have negative amounts. */ - public static void addStickyWarpToPlayer(EntityPlayer player, int amount) { + public static void addStickyWarpToPlayer(EntityPlayer player, int amount) + { ThaumcraftApi.internalMethods.addStickyWarpToPlayer(player, amount); } - public static MovingObjectPosition rayTraceIgnoringSource(World world, Vec3 v1, Vec3 v2, - boolean bool1, boolean bool2, boolean bool3) + public static MovingObjectPosition rayTraceIgnoringSource(World world, Vec3 v1, Vec3 v2, boolean bool1, boolean bool2, boolean bool3) { - if (!Double.isNaN(v1.xCoord) && !Double.isNaN(v1.yCoord) && !Double.isNaN(v1.zCoord)) - { - if (!Double.isNaN(v2.xCoord) && !Double.isNaN(v2.yCoord) && !Double.isNaN(v2.zCoord)) - { - int i = MathHelper.floor_double(v2.xCoord); - int j = MathHelper.floor_double(v2.yCoord); - int k = MathHelper.floor_double(v2.zCoord); - int l = MathHelper.floor_double(v1.xCoord); - int i1 = MathHelper.floor_double(v1.yCoord); - int j1 = MathHelper.floor_double(v1.zCoord); - Block block = world.getBlock(l, i1, j1); - int k1 = world.getBlockMetadata(l, i1, j1); - - MovingObjectPosition movingobjectposition2 = null; - k1 = 200; - - while (k1-- >= 0) - { - if (Double.isNaN(v1.xCoord) || Double.isNaN(v1.yCoord) || Double.isNaN(v1.zCoord)) - { - return null; - } - - if (l == i && i1 == j && j1 == k) - { - continue; - } - - boolean flag6 = true; - boolean flag3 = true; - boolean flag4 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (i > l) - { - d0 = (double)l + 1.0D; - } - else if (i < l) - { - d0 = (double)l + 0.0D; - } - else - { - flag6 = false; - } - - if (j > i1) - { - d1 = (double)i1 + 1.0D; - } - else if (j < i1) - { - d1 = (double)i1 + 0.0D; - } - else - { - flag3 = false; - } - - if (k > j1) - { - d2 = (double)j1 + 1.0D; - } - else if (k < j1) - { - d2 = (double)j1 + 0.0D; - } - else - { - flag4 = false; - } - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = v2.xCoord - v1.xCoord; - double d7 = v2.yCoord - v1.yCoord; - double d8 = v2.zCoord - v1.zCoord; - - if (flag6) - { - d3 = (d0 - v1.xCoord) / d6; - } - - if (flag3) - { - d4 = (d1 - v1.yCoord) / d7; - } - - if (flag4) - { - d5 = (d2 - v1.zCoord) / d8; - } - - boolean flag5 = false; - byte b0; - - if (d3 < d4 && d3 < d5) - { - if (i > l) - { - b0 = 4; - } - else - { - b0 = 5; - } - - v1.xCoord = d0; - v1.yCoord += d7 * d3; - v1.zCoord += d8 * d3; - } - else if (d4 < d5) - { - if (j > i1) - { - b0 = 0; - } - else - { - b0 = 1; - } - - v1.xCoord += d6 * d4; - v1.yCoord = d1; - v1.zCoord += d8 * d4; - } - else - { - if (k > j1) - { - b0 = 2; - } - else - { - b0 = 3; - } - - v1.xCoord += d6 * d5; - v1.yCoord += d7 * d5; - v1.zCoord = d2; - } - - Vec3 vec32 = Vec3.createVectorHelper(v1.xCoord, v1.yCoord, v1.zCoord); - l = (int)(vec32.xCoord = (double)MathHelper.floor_double(v1.xCoord)); - - if (b0 == 5) - { - --l; - ++vec32.xCoord; - } - - i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(v1.yCoord)); - - if (b0 == 1) - { - --i1; - ++vec32.yCoord; - } - - j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(v1.zCoord)); - - if (b0 == 3) - { - --j1; - ++vec32.zCoord; - } - - Block block1 = world.getBlock(l, i1, j1); - int l1 = world.getBlockMetadata(l, i1, j1); - - if (!bool2 || block1.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) - { - if (block1.canCollideCheck(l1, bool1)) - { - MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(world, l, i1, j1, v1, v2); - - if (movingobjectposition1 != null) - { - return movingobjectposition1; - } - } - else - { - movingobjectposition2 = new MovingObjectPosition(l, i1, j1, b0, v1, false); - } - } - } - - return bool3 ? movingobjectposition2 : null; - } - else - { - return null; - } - } - else - { - return null; - } + if(!Double.isNaN(v1.xCoord) && !Double.isNaN(v1.yCoord) && !Double.isNaN(v1.zCoord)) + { + if(!Double.isNaN(v2.xCoord) && !Double.isNaN(v2.yCoord) && !Double.isNaN(v2.zCoord)) + { + final int i = MathHelper.floor_double(v2.xCoord); + final int j = MathHelper.floor_double(v2.yCoord); + final int k = MathHelper.floor_double(v2.zCoord); + int l = MathHelper.floor_double(v1.xCoord); + int i1 = MathHelper.floor_double(v1.yCoord); + int j1 = MathHelper.floor_double(v1.zCoord); + world.getBlock(l, i1, j1); + int k1 = world.getBlockMetadata(l, i1, j1); + + MovingObjectPosition movingobjectposition2 = null; + k1 = 200; + + while(k1-- >= 0) + { + if(Double.isNaN(v1.xCoord) || Double.isNaN(v1.yCoord) || Double.isNaN(v1.zCoord)) + { + return null; + } + + if(l == i && i1 == j && j1 == k) + { + continue; + } + + boolean flag6 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if(i > l) + { + d0 = l + 1.0D; + } + else if(i < l) + { + d0 = l + 0.0D; + } + else + { + flag6 = false; + } + + if(j > i1) + { + d1 = i1 + 1.0D; + } + else if(j < i1) + { + d1 = i1 + 0.0D; + } + else + { + flag3 = false; + } + + if(k > j1) + { + d2 = j1 + 1.0D; + } + else if(k < j1) + { + d2 = j1 + 0.0D; + } + else + { + flag4 = false; + } + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + final double d6 = v2.xCoord - v1.xCoord; + final double d7 = v2.yCoord - v1.yCoord; + final double d8 = v2.zCoord - v1.zCoord; + + if(flag6) + { + d3 = (d0 - v1.xCoord) / d6; + } + + if(flag3) + { + d4 = (d1 - v1.yCoord) / d7; + } + + if(flag4) + { + d5 = (d2 - v1.zCoord) / d8; + } + + byte b0; + + if(d3 < d4 && d3 < d5) + { + if(i > l) + { + b0 = 4; + } + else + { + b0 = 5; + } + + v1.xCoord = d0; + v1.yCoord += d7 * d3; + v1.zCoord += d8 * d3; + } + else if(d4 < d5) + { + if(j > i1) + { + b0 = 0; + } + else + { + b0 = 1; + } + + v1.xCoord += d6 * d4; + v1.yCoord = d1; + v1.zCoord += d8 * d4; + } + else + { + if(k > j1) + { + b0 = 2; + } + else + { + b0 = 3; + } + + v1.xCoord += d6 * d5; + v1.yCoord += d7 * d5; + v1.zCoord = d2; + } + + final Vec3 vec32 = Vec3.createVectorHelper(v1.xCoord, v1.yCoord, v1.zCoord); + l = (int) (vec32.xCoord = MathHelper.floor_double(v1.xCoord)); + + if(b0 == 5) + { + --l; + ++vec32.xCoord; + } + + i1 = (int) (vec32.yCoord = MathHelper.floor_double(v1.yCoord)); + + if(b0 == 1) + { + --i1; + ++vec32.yCoord; + } + + j1 = (int) (vec32.zCoord = MathHelper.floor_double(v1.zCoord)); + + if(b0 == 3) + { + --j1; + ++vec32.zCoord; + } + + final Block block1 = world.getBlock(l, i1, j1); + final int l1 = world.getBlockMetadata(l, i1, j1); + + if(!bool2 || block1.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) + { + if(block1.canCollideCheck(l1, bool1)) + { + final MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(world, l, i1, j1, v1, v2); + + if(movingobjectposition1 != null) + { + return movingobjectposition1; + } + } + else + { + movingobjectposition2 = new MovingObjectPosition(l, + i1, j1, b0, v1, false); + } + } + } + + return bool3 ? movingobjectposition2 : null; + } + else + { + return null; + } + } + else + { + return null; + } } } diff --git a/src/api/java/thaumcraft/api/TileThaumcraft.java b/src/api/java/thaumcraft/api/TileThaumcraft.java index 56ccae8..8bcb4c7 100644 --- a/src/api/java/thaumcraft/api/TileThaumcraft.java +++ b/src/api/java/thaumcraft/api/TileThaumcraft.java @@ -15,49 +15,50 @@ import net.minecraft.tileentity.TileEntity; * updates. Apart from all the normal TE data that gets sent that is. * */ -public class TileThaumcraft extends TileEntity { - +public class TileThaumcraft extends TileEntity +{ + //NBT stuff - + @Override public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - readCustomNBT(nbttagcompound); - } - + { + super.readFromNBT(nbttagcompound); + readCustomNBT(nbttagcompound); + } + public void readCustomNBT(NBTTagCompound nbttagcompound) - { - //TODO - } + { + //TODO + } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - writeCustomNBT(nbttagcompound); - } - + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + writeCustomNBT(nbttagcompound); + } + public void writeCustomNBT(NBTTagCompound nbttagcompound) - { + { //TODO - } - + } + //Client Packet stuff @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - this.writeCustomNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, nbttagcompound); + public Packet getDescriptionPacket() + { + final NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, + zCoord, -999, nbttagcompound); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - super.onDataPacket(net, pkt); - this.readCustomNBT(pkt.func_148857_g()); + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) + { + super.onDataPacket(net, pkt); + readCustomNBT(pkt.func_148857_g()); } - - - } diff --git a/src/api/java/thaumcraft/api/WorldCoordinates.java b/src/api/java/thaumcraft/api/WorldCoordinates.java index 6c620af..cab4082 100644 --- a/src/api/java/thaumcraft/api/WorldCoordinates.java +++ b/src/api/java/thaumcraft/api/WorldCoordinates.java @@ -5,113 +5,119 @@ import net.minecraft.tileentity.TileEntity; public class WorldCoordinates implements Comparable { - public int x; - - /** the y coordinate */ - public int y; - - /** the z coordinate */ - public int z; - - public int dim; - - public WorldCoordinates() {} - - public WorldCoordinates(int par1, int par2, int par3, int d) - { - this.x = par1; - this.y = par2; - this.z = par3; - this.dim = d; - } - - public WorldCoordinates(TileEntity tile) - { - this.x = tile.xCoord; - this.y = tile.yCoord; - this.z = tile.zCoord; - this.dim = tile.getWorldObj().provider.dimensionId; - } - - public WorldCoordinates(WorldCoordinates par1ChunkCoordinates) - { - this.x = par1ChunkCoordinates.x; - this.y = par1ChunkCoordinates.y; - this.z = par1ChunkCoordinates.z; - this.dim = par1ChunkCoordinates.dim; - } - - public boolean equals(Object par1Obj) - { - if (!(par1Obj instanceof WorldCoordinates)) - { - return false; - } - else - { - WorldCoordinates coordinates = (WorldCoordinates)par1Obj; - return this.x == coordinates.x && this.y == coordinates.y && this.z == coordinates.z && this.dim == coordinates.dim ; - } - } - - public int hashCode() - { - return this.x + this.y << 8 + this.z << 16 + this.dim << 24; - } - - /** - * Compare the coordinate with another coordinate - */ - public int compareWorldCoordinate(WorldCoordinates par1) - { - return this.dim == par1.dim ? ( - this.y == par1.y ? (this.z == par1.z ? this.x - par1.x : this.z - par1.z) : this.y - par1.y) : -1; - } - - public void set(int par1, int par2, int par3, int d) - { - this.x = par1; - this.y = par2; - this.z = par3; - this.dim = d; - } - - /** - * Returns the squared distance between this coordinates and the coordinates given as argument. - */ - public float getDistanceSquared(int par1, int par2, int par3) - { - float f = (float)(this.x - par1); - float f1 = (float)(this.y - par2); - float f2 = (float)(this.z - par3); - return f * f + f1 * f1 + f2 * f2; - } - - /** - * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. - */ - public float getDistanceSquaredToWorldCoordinates(WorldCoordinates par1ChunkCoordinates) - { - return this.getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); - } - - public int compareTo(Object par1Obj) - { - return this.compareWorldCoordinate((WorldCoordinates)par1Obj); - } - - public void readNBT(NBTTagCompound nbt) { - this.x = nbt.getInteger("w_x"); - this.y = nbt.getInteger("w_y"); - this.z = nbt.getInteger("w_z"); - this.dim = nbt.getInteger("w_d"); - } - - public void writeNBT(NBTTagCompound nbt) { - nbt.setInteger("w_x",x); - nbt.setInteger("w_y",y); - nbt.setInteger("w_z",z); - nbt.setInteger("w_d",dim); - } - + public int x; + + /** the y coordinate */ + public int y; + + /** the z coordinate */ + public int z; + + public int dim; + + public WorldCoordinates() + { + } + + public WorldCoordinates(int par1, int par2, int par3, int d) + { + x = par1; + y = par2; + z = par3; + dim = d; + } + + public WorldCoordinates(TileEntity tile) + { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + dim = tile.getWorldObj().provider.dimensionId; + } + + public WorldCoordinates(WorldCoordinates par1ChunkCoordinates) + { + x = par1ChunkCoordinates.x; + y = par1ChunkCoordinates.y; + z = par1ChunkCoordinates.z; + dim = par1ChunkCoordinates.dim; + } + + @Override + public boolean equals(Object par1Obj) + { + if(!(par1Obj instanceof WorldCoordinates)) + { + return false; + } + else + { + final WorldCoordinates coordinates = (WorldCoordinates) par1Obj; + return x == coordinates.x && y == coordinates.y && z == coordinates.z && dim == coordinates.dim; + } + } + + @Override + public int hashCode() + { + return x + y << 8 + z << 16 + dim << 24; + } + + /** + * Compare the coordinate with another coordinate + */ + public int compareWorldCoordinate(WorldCoordinates par1) + { + return dim == par1.dim ? (y == par1.y ? (z == par1.z ? x - par1.x : z - par1.z) : y - par1.y) : -1; + } + + public void set(int par1, int par2, int par3, int d) + { + x = par1; + y = par2; + z = par3; + dim = d; + } + + /** + * Returns the squared distance between this coordinates and the coordinates given as argument. + */ + public float getDistanceSquared(int par1, int par2, int par3) + { + final float f = x - par1; + final float f1 = y - par2; + final float f2 = z - par3; + return f * f + f1 * f1 + f2 * f2; + } + + /** + * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. + */ + public float getDistanceSquaredToWorldCoordinates(WorldCoordinates par1ChunkCoordinates) + { + return getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); + } + + @Override + public int compareTo(Object par1Obj) + { + return compareWorldCoordinate((WorldCoordinates) par1Obj); + } + + public void readNBT(NBTTagCompound nbt) + { + x = nbt.getInteger("w_x"); + y = nbt.getInteger("w_y"); + z = nbt.getInteger("w_z"); + dim = nbt.getInteger("w_d"); + } + + public void writeNBT(NBTTagCompound nbt) + { + nbt.setInteger("w_x", x); + nbt.setInteger("w_y", y); + nbt.setInteger("w_z", z); + nbt.setInteger("w_d", dim); + } + } diff --git a/src/api/java/thaumcraft/api/aspects/Aspect.java b/src/api/java/thaumcraft/api/aspects/Aspect.java index 0ea13f5..c6c548e 100644 --- a/src/api/java/thaumcraft/api/aspects/Aspect.java +++ b/src/api/java/thaumcraft/api/aspects/Aspect.java @@ -9,14 +9,15 @@ import net.minecraft.util.StatCollector; import org.apache.commons.lang3.text.WordUtils; -public class Aspect { - - String tag; - Aspect[] components; - int color; - private String chatcolor; - ResourceLocation image; - int blend; +public class Aspect +{ + + String tag; + Aspect[] components; + int color; + private String chatcolor; + ResourceLocation image; + int blend; /** * Use this constructor to register your own aspects. @@ -26,8 +27,12 @@ public class Aspect { * @param image ResourceLocation pointing to a 32x32 icon of the aspect * @param blend GL11 blendmode (1 or 771). Used for rendering nodes. Default is 1 */ - public Aspect(String tag, int color, Aspect[] components, ResourceLocation image, int blend) { - if (aspects.containsKey(tag)) throw new IllegalArgumentException(tag+" already registered!"); + public Aspect(String tag, int color, Aspect[] components, ResourceLocation image, int blend) + { + if(aspects.containsKey(tag)) + { + throw new IllegalArgumentException(tag + " already registered!"); + } this.tag = tag; this.components = components; this.color = color; @@ -35,167 +40,338 @@ public class Aspect { this.blend = blend; aspects.put(tag, this); } - + /** * Shortcut constructor I use for the default aspects - you shouldn't be using this. */ - public Aspect(String tag, int color, Aspect[] components) { - this(tag,color,components,new ResourceLocation("thaumcraft","textures/aspects/"+tag.toLowerCase()+".png"),1); + public Aspect(String tag, int color, Aspect[] components) + { + this(tag, color, components, new ResourceLocation("thaumcraft", + "textures/aspects/" + tag.toLowerCase() + ".png"), 1); } - + /** * Shortcut constructor I use for the default aspects - you shouldn't be using this. */ - public Aspect(String tag, int color, Aspect[] components, int blend) { - this(tag,color,components,new ResourceLocation("thaumcraft","textures/aspects/"+tag.toLowerCase()+".png"),blend); + public Aspect(String tag, int color, Aspect[] components, int blend) + { + this(tag, color, components, new ResourceLocation("thaumcraft", + "textures/aspects/" + tag.toLowerCase() + ".png"), blend); } /** * Shortcut constructor I use for the primal aspects - * you shouldn't use this as making your own primal aspects will break all the things. */ - public Aspect(String tag, int color, String chatcolor, int blend) { - this(tag,color,(Aspect[])null, blend); - this.setChatcolor(chatcolor); + public Aspect(String tag, int color, String chatcolor, int blend) + { + this(tag, color, (Aspect[]) null, blend); + setChatcolor(chatcolor); } - - public int getColor() { + + public int getColor() + { return color; } - - public String getName() { + + public String getName() + { return WordUtils.capitalizeFully(tag); } - - public String getLocalizedDescription() { - return StatCollector.translateToLocal("tc.aspect."+tag); + + public String getLocalizedDescription() + { + return StatCollector.translateToLocal("tc.aspect." + tag); } - - public String getTag() { + + public String getTag() + { return tag; } - public void setTag(String tag) { + public void setTag(String tag) + { this.tag = tag; } - public Aspect[] getComponents() { + public Aspect[] getComponents() + { return components; } - public void setComponents(Aspect[] components) { + public void setComponents(Aspect[] components) + { this.components = components; } - - public ResourceLocation getImage() { + + public ResourceLocation getImage() + { return image; } - - public static Aspect getAspect(String tag) { + + public static Aspect getAspect(String tag) + { return aspects.get(tag); } - - public int getBlend() { + + public int getBlend() + { return blend; } - public void setBlend(int blend) { + public void setBlend(int blend) + { this.blend = blend; } - - public boolean isPrimal() { - return getComponents()==null || getComponents().length!=2; + + public boolean isPrimal() + { + return getComponents() == null || getComponents().length != 2; } - + /////////////////////////////// - public static ArrayList getPrimalAspects() { - ArrayList primals = new ArrayList(); - Collection pa = aspects.values(); - for (Aspect aspect:pa) { - if (aspect.isPrimal()) primals.add(aspect); + public static ArrayList getPrimalAspects() + { + final ArrayList primals = new ArrayList(); + final Collection pa = aspects.values(); + for(final Aspect aspect : pa) + { + if(aspect.isPrimal()) + { + primals.add(aspect); + } } return primals; } - - public static ArrayList getCompoundAspects() { - ArrayList compounds = new ArrayList(); - Collection pa = aspects.values(); - for (Aspect aspect:pa) { - if (!aspect.isPrimal()) compounds.add(aspect); + + public static ArrayList getCompoundAspects() + { + final ArrayList compounds = new ArrayList(); + final Collection pa = aspects.values(); + for(final Aspect aspect : pa) + { + if(!aspect.isPrimal()) + { + compounds.add(aspect); + } } return compounds; } - public String getChatcolor() { + public String getChatcolor() + { return chatcolor; } - public void setChatcolor(String chatcolor) { + public void setChatcolor(String chatcolor) + { this.chatcolor = chatcolor; } - /////////////////////////////// - public static LinkedHashMap aspects = new LinkedHashMap(); - + public static LinkedHashMap aspects = new LinkedHashMap(); + //PRIMAL - public static final Aspect AIR = new Aspect("aer",0xffff7e,"e",1); - public static final Aspect EARTH = new Aspect("terra",0x56c000,"2",1); - public static final Aspect FIRE = new Aspect("ignis",0xff5a01,"c",1); - public static final Aspect WATER = new Aspect("aqua",0x3cd4fc,"3",1); - public static final Aspect ORDER = new Aspect("ordo",0xd5d4ec,"7",1); - public static final Aspect ENTROPY = new Aspect("perditio",0x404040,"8",771); - + public static final Aspect AIR = new Aspect("aer", + 0xffff7e, + "e", 1); + public static final Aspect EARTH = new Aspect( + "terra", + 0x56c000, + "2", 1); + public static final Aspect FIRE = new Aspect( + "ignis", + 0xff5a01, + "c", 1); + public static final Aspect WATER = new Aspect( + "aqua", + 0x3cd4fc, + "3", 1); + public static final Aspect ORDER = new Aspect( + "ordo", + 0xd5d4ec, + "7", 1); + public static final Aspect ENTROPY = new Aspect( + "perditio", + 0x404040, + "8", 771); + //SECONDARY - public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {AIR, ENTROPY},771); - public static final Aspect LIGHT = new Aspect("lux",0xfff663, new Aspect[] {AIR, FIRE}); - public static final Aspect WEATHER = new Aspect("tempestas",0xFFFFFF, new Aspect[] {AIR, WATER}); - public static final Aspect MOTION = new Aspect("motus",0xcdccf4, new Aspect[] {AIR, ORDER}); - public static final Aspect COLD = new Aspect("gelum",0xe1ffff, new Aspect[] {FIRE, ENTROPY}); - public static final Aspect CRYSTAL = new Aspect("vitreus",0x80ffff, new Aspect[] {EARTH, ORDER}); - public static final Aspect LIFE = new Aspect("victus",0xde0005, new Aspect[] {WATER, EARTH}); - public static final Aspect POISON = new Aspect("venenum",0x89f000, new Aspect[] {WATER, ENTROPY}); - public static final Aspect ENERGY = new Aspect("potentia",0xc0ffff, new Aspect[] {ORDER, FIRE}); - public static final Aspect EXCHANGE = new Aspect("permutatio",0x578357, new Aspect[] {ENTROPY, ORDER}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {AIR, EARTH}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, EARTH}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, WATER}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {ORDER, WATER}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {EARTH, ENTROPY}); - + public static final Aspect VOID = new Aspect( + "vacuos", + 0x888888, + new Aspect[] {AIR, ENTROPY}, + 771); + public static final Aspect LIGHT = new Aspect( + "lux", + 0xfff663, + new Aspect[] {AIR, FIRE}); + public static final Aspect WEATHER = new Aspect( + "tempestas", + 0xFFFFFF, + new Aspect[] {AIR, WATER}); + public static final Aspect MOTION = new Aspect( + "motus", + 0xcdccf4, + new Aspect[] {AIR, ORDER}); + public static final Aspect COLD = new Aspect( + "gelum", + 0xe1ffff, + new Aspect[] {FIRE, ENTROPY}); + public static final Aspect CRYSTAL = new Aspect( + "vitreus", + 0x80ffff, + new Aspect[] {EARTH, ORDER}); + public static final Aspect LIFE = new Aspect( + "victus", + 0xde0005, + new Aspect[] {WATER, EARTH}); + public static final Aspect POISON = new Aspect( + "venenum", + 0x89f000, + new Aspect[] {WATER, ENTROPY}); + public static final Aspect ENERGY = new Aspect( + "potentia", + 0xc0ffff, + new Aspect[] {ORDER, FIRE}); + public static final Aspect EXCHANGE = new Aspect( + "permutatio", + 0x578357, + new Aspect[] {ENTROPY, ORDER}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {AIR, EARTH}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, EARTH}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, WATER}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {ORDER, WATER}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {EARTH, ENTROPY}); + //TERTIARY - public static final Aspect METAL = new Aspect("metallum",0xb5b5cd, new Aspect[] {EARTH, CRYSTAL}); - public static final Aspect DEATH = new Aspect("mortuus",0x887788, new Aspect[] {LIFE, ENTROPY}); - public static final Aspect FLIGHT = new Aspect("volatus",0xe7e7d7, new Aspect[] {AIR, MOTION}); - public static final Aspect DARKNESS = new Aspect("tenebrae",0x222222, new Aspect[] {VOID, LIGHT}); - public static final Aspect SOUL = new Aspect("spiritus",0xebebfb, new Aspect[] {LIFE, DEATH}); - public static final Aspect HEAL = new Aspect("sano",0xff2f34, new Aspect[] {LIFE, ORDER}); - public static final Aspect TRAVEL = new Aspect("iter",0xe0585b, new Aspect[] {MOTION, EARTH}); - public static final Aspect ELDRITCH = new Aspect("alienis",0x805080, new Aspect[] {VOID, DARKNESS}); - public static final Aspect MAGIC = new Aspect("praecantatio",0x9700c0, new Aspect[] {VOID, ENERGY}); - public static final Aspect AURA = new Aspect("auram",0xffc0ff, new Aspect[] {MAGIC, AIR}); - public static final Aspect TAINT = new Aspect("vitium",0x800080, new Aspect[] {MAGIC, ENTROPY}); - public static final Aspect SLIME = new Aspect("limus",0x01f800, new Aspect[] {LIFE, WATER}); - public static final Aspect PLANT = new Aspect("herba",0x01ac00, new Aspect[] {LIFE, EARTH}); - public static final Aspect TREE = new Aspect("arbor",0x876531, new Aspect[] {AIR, PLANT}); - public static final Aspect BEAST = new Aspect("bestia",0x9f6409, new Aspect[] {MOTION, LIFE}); - public static final Aspect FLESH = new Aspect("corpus",0xee478d, new Aspect[] {DEATH, BEAST}); - public static final Aspect UNDEAD = new Aspect("exanimis",0x3a4000, new Aspect[] {MOTION, DEATH}); - public static final Aspect MIND = new Aspect("cognitio",0xffc2b3, new Aspect[] {FIRE, SOUL}); - public static final Aspect SENSES = new Aspect("sensus",0x0fd9ff, new Aspect[] {AIR, SOUL}); - public static final Aspect MAN = new Aspect("humanus",0xffd7c0, new Aspect[] {BEAST, MIND}); - public static final Aspect CROP = new Aspect("messis",0xe1b371, new Aspect[] {PLANT, MAN}); - public static final Aspect MINE = new Aspect("perfodio",0xdcd2d8, new Aspect[] {MAN, EARTH}); - public static final Aspect TOOL = new Aspect("instrumentum",0x4040ee, new Aspect[] {MAN, ORDER}); - public static final Aspect HARVEST = new Aspect("meto",0xeead82, new Aspect[] {CROP, TOOL}); - public static final Aspect WEAPON = new Aspect("telum",0xc05050, new Aspect[] {TOOL, FIRE}); - public static final Aspect ARMOR = new Aspect("tutamen",0x00c0c0, new Aspect[] {TOOL, EARTH}); - public static final Aspect HUNGER = new Aspect("fames",0x9a0305, new Aspect[] {LIFE, VOID}); - public static final Aspect GREED = new Aspect("lucrum",0xe6be44, new Aspect[] {MAN, HUNGER}); - public static final Aspect CRAFT = new Aspect("fabrico",0x809d80, new Aspect[] {MAN, TOOL}); - public static final Aspect CLOTH = new Aspect("pannus",0xeaeac2, new Aspect[] {TOOL, BEAST}); - public static final Aspect MECHANISM = new Aspect("machina",0x8080a0, new Aspect[] {MOTION, TOOL}); - public static final Aspect TRAP = new Aspect("vinculum",0x9a8080, new Aspect[] {MOTION, ENTROPY}); - - + public static final Aspect METAL = new Aspect( + "metallum", + 0xb5b5cd, + new Aspect[] {EARTH, CRYSTAL}); + public static final Aspect DEATH = new Aspect( + "mortuus", + 0x887788, + new Aspect[] {LIFE, ENTROPY}); + public static final Aspect FLIGHT = new Aspect( + "volatus", + 0xe7e7d7, + new Aspect[] {AIR, MOTION}); + public static final Aspect DARKNESS = new Aspect( + "tenebrae", + 0x222222, + new Aspect[] {VOID, LIGHT}); + public static final Aspect SOUL = new Aspect( + "spiritus", + 0xebebfb, + new Aspect[] {LIFE, DEATH}); + public static final Aspect HEAL = new Aspect( + "sano", + 0xff2f34, + new Aspect[] {LIFE, ORDER}); + public static final Aspect TRAVEL = new Aspect( + "iter", + 0xe0585b, + new Aspect[] {MOTION, EARTH}); + public static final Aspect ELDRITCH = new Aspect( + "alienis", + 0x805080, + new Aspect[] {VOID, DARKNESS}); + public static final Aspect MAGIC = new Aspect( + "praecantatio", + 0x9700c0, + new Aspect[] {VOID, ENERGY}); + public static final Aspect AURA = new Aspect( + "auram", + 0xffc0ff, + new Aspect[] {MAGIC, AIR}); + public static final Aspect TAINT = new Aspect( + "vitium", + 0x800080, + new Aspect[] {MAGIC, ENTROPY}); + public static final Aspect SLIME = new Aspect( + "limus", + 0x01f800, + new Aspect[] {LIFE, WATER}); + public static final Aspect PLANT = new Aspect( + "herba", + 0x01ac00, + new Aspect[] {LIFE, EARTH}); + public static final Aspect TREE = new Aspect( + "arbor", + 0x876531, + new Aspect[] {AIR, PLANT}); + public static final Aspect BEAST = new Aspect( + "bestia", + 0x9f6409, + new Aspect[] {MOTION, LIFE}); + public static final Aspect FLESH = new Aspect( + "corpus", + 0xee478d, + new Aspect[] {DEATH, BEAST}); + public static final Aspect UNDEAD = new Aspect( + "exanimis", + 0x3a4000, + new Aspect[] {MOTION, DEATH}); + public static final Aspect MIND = new Aspect( + "cognitio", + 0xffc2b3, + new Aspect[] {FIRE, SOUL}); + public static final Aspect SENSES = new Aspect( + "sensus", + 0x0fd9ff, + new Aspect[] {AIR, SOUL}); + public static final Aspect MAN = new Aspect( + "humanus", + 0xffd7c0, + new Aspect[] {BEAST, MIND}); + public static final Aspect CROP = new Aspect( + "messis", + 0xe1b371, + new Aspect[] {PLANT, MAN}); + public static final Aspect MINE = new Aspect( + "perfodio", + 0xdcd2d8, + new Aspect[] {MAN, EARTH}); + public static final Aspect TOOL = new Aspect( + "instrumentum", + 0x4040ee, + new Aspect[] {MAN, ORDER}); + public static final Aspect HARVEST = new Aspect( + "meto", + 0xeead82, + new Aspect[] {CROP, TOOL}); + public static final Aspect WEAPON = new Aspect( + "telum", + 0xc05050, + new Aspect[] {TOOL, FIRE}); + public static final Aspect ARMOR = new Aspect( + "tutamen", + 0x00c0c0, + new Aspect[] {TOOL, EARTH}); + public static final Aspect HUNGER = new Aspect( + "fames", + 0x9a0305, + new Aspect[] {LIFE, VOID}); + public static final Aspect GREED = new Aspect( + "lucrum", + 0xe6be44, + new Aspect[] {MAN, HUNGER}); + public static final Aspect CRAFT = new Aspect( + "fabrico", + 0x809d80, + new Aspect[] {MAN, TOOL}); + public static final Aspect CLOTH = new Aspect( + "pannus", + 0xeaeac2, + new Aspect[] {TOOL, BEAST}); + public static final Aspect MECHANISM = new Aspect( + "machina", + 0x8080a0, + new Aspect[] {MOTION, TOOL}); + public static final Aspect TRAP = new Aspect( + "vinculum", + 0x9a8080, + new Aspect[] {MOTION, ENTROPY}); + } diff --git a/src/api/java/thaumcraft/api/aspects/AspectList.java b/src/api/java/thaumcraft/api/aspects/AspectList.java index b578141..fb80b48 100644 --- a/src/api/java/thaumcraft/api/aspects/AspectList.java +++ b/src/api/java/thaumcraft/api/aspects/AspectList.java @@ -8,154 +8,192 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import thaumcraft.api.ThaumcraftApiHelper; -public class AspectList implements Serializable { - - public LinkedHashMap aspects = new LinkedHashMap();//aspects associated with this object +public class AspectList implements Serializable +{ + + public LinkedHashMap aspects = new LinkedHashMap(); //aspects associated with this object - /** * this creates a new aspect list with preloaded values based off the aspects of the given item. * @param the itemstack of the given item */ - public AspectList(ItemStack stack) { - try { - AspectList temp = ThaumcraftApiHelper.getObjectAspects(stack); - if (temp!=null) - for (Aspect tag:temp.getAspects()) { - add(tag,temp.getAmount(tag)); + public AspectList(ItemStack stack) + { + try + { + final AspectList temp = ThaumcraftApiHelper.getObjectAspects(stack); + if(temp != null) + { + for(final Aspect tag : temp.getAspects()) + { + add(tag, temp.getAmount(tag)); + } } - } catch (Exception e) {} + } + catch(final Exception e) + { + } } - - public AspectList() { + + public AspectList() + { } - - public AspectList copy() { - AspectList out = new AspectList(); - for (Aspect a:this.getAspects()) - out.add(a, this.getAmount(a)); + + public AspectList copy() + { + final AspectList out = new AspectList(); + for(final Aspect a : getAspects()) + { + out.add(a, getAmount(a)); + } return out; } - + /** * @return the amount of different aspects in this collection */ - public int size() { + public int size() + { return aspects.size(); } - + /** * @return the amount of total vis in this collection */ - public int visSize() { + public int visSize() + { int q = 0; - - for (Aspect as:aspects.keySet()) { - q+=this.getAmount(as); + + for(final Aspect as : aspects.keySet()) + { + q += getAmount(as); } - + return q; } - + /** * @return an array of all the aspects in this collection */ - public Aspect[] getAspects() { - Aspect[] q = new Aspect[1]; + public Aspect[] getAspects() + { + final Aspect[] q = new Aspect[1]; return aspects.keySet().toArray(q); } - + /** * @return an array of all the aspects in this collection */ - public Aspect[] getPrimalAspects() { - AspectList t = new AspectList(); - for (Aspect as:aspects.keySet()) { - if (as.isPrimal()) { - t.add(as,1); + public Aspect[] getPrimalAspects() + { + final AspectList t = new AspectList(); + for(final Aspect as : aspects.keySet()) + { + if(as.isPrimal()) + { + t.add(as, 1); } } - Aspect[] q = new Aspect[1]; + final Aspect[] q = new Aspect[1]; return t.aspects.keySet().toArray(q); } - + /** * @return an array of all the aspects in this collection sorted by name */ - public Aspect[] getAspectsSorted() { - try { - Aspect[] out = aspects.keySet().toArray(new Aspect[]{}); - boolean change=false; - do { - change=false; - for(int a=0;a0) { + public Aspect[] getAspectsSorted() + { + try + { + final Aspect[] out = aspects.keySet().toArray(new Aspect[] {}); + boolean change = false; + do + { + change = false; + for(int a = 0; a < out.length - 1; a++) + { + final Aspect e1 = out[a]; + final Aspect e2 = out[a + 1]; + if(e1 != null && e2 != null && e1.getTag().compareTo(e2.getTag()) > 0) + { out[a] = e2; - out[a+1] = e1; + out[a + 1] = e1; change = true; break; } } - } while (change==true); + } + while(change == true); return out; - } catch (Exception e) { - return this.getAspects(); + } + catch(final Exception e) + { + return getAspects(); } } - + /** * @return an array of all the aspects in this collection sorted by amount */ - public Aspect[] getAspectsSortedAmount() { - try { - Aspect[] out = aspects.keySet().toArray(new Aspect[1]); - boolean change=false; - do { - change=false; - for(int a=0;a0 && e2>0 && e2>e1) { - Aspect ea = out[a]; - Aspect eb = out[a+1]; + public Aspect[] getAspectsSortedAmount() + { + try + { + final Aspect[] out = aspects.keySet().toArray(new Aspect[1]); + boolean change = false; + do + { + change = false; + for(int a = 0; a < out.length - 1; a++) + { + final int e1 = getAmount(out[a]); + final int e2 = getAmount(out[a + 1]); + if(e1 > 0 && e2 > 0 && e2 > e1) + { + final Aspect ea = out[a]; + final Aspect eb = out[a + 1]; out[a] = eb; - out[a+1] = ea; + out[a + 1] = ea; change = true; break; } } - } while (change==true); + } + while(change == true); return out; - } catch (Exception e) { - return this.getAspects(); + } + catch(final Exception e) + { + return getAspects(); } } - + /** * @param key * @return the amount associated with the given aspect in this collection */ - public int getAmount(Aspect key) { - return aspects.get(key)==null?0:aspects.get(key); + public int getAmount(Aspect key) + { + return aspects.get(key) == null ? 0 : aspects.get(key); } - + /** * Reduces the amount of an aspect in this collection by the given amount. * @param key * @param amount * @return */ - public boolean reduce(Aspect key, int amount) { - if (getAmount(key)>=amount) { - int am = getAmount(key)-amount; + public boolean reduce(Aspect key, int amount) + { + if(getAmount(key) >= amount) + { + final int am = getAmount(key) - amount; aspects.put(key, am); return true; } return false; } - + /** * Reduces the amount of an aspect in this collection by the given amount. * If reduced to 0 or less the aspect will be removed completely. @@ -163,24 +201,32 @@ public class AspectList implements Serializable { * @param amount * @return */ - public AspectList remove(Aspect key, int amount) { - int am = getAmount(key)-amount; - if (am<=0) aspects.remove(key); else - this.aspects.put(key, am); + public AspectList remove(Aspect key, int amount) + { + final int am = getAmount(key) - amount; + if(am <= 0) + { + aspects.remove(key); + } + else + { + aspects.put(key, am); + } return this; } - + /** * Simply removes the aspect from the list * @param key * @param amount * @return */ - public AspectList remove(Aspect key) { - aspects.remove(key); + public AspectList remove(Aspect key) + { + aspects.remove(key); return this; } - + /** * Adds this aspect and amount to the collection. * If the aspect exists then its value will be increased by the given amount. @@ -188,16 +234,17 @@ public class AspectList implements Serializable { * @param amount * @return */ - public AspectList add(Aspect aspect, int amount) { - if (this.aspects.containsKey(aspect)) { - int oldamount = this.aspects.get(aspect); - amount+=oldamount; + public AspectList add(Aspect aspect, int amount) + { + if(aspects.containsKey(aspect)) + { + final int oldamount = aspects.get(aspect); + amount += oldamount; } - this.aspects.put( aspect, amount ); + aspects.put(aspect, amount); return this; } - /** * Adds this aspect and amount to the collection. * If the aspect exists then only the highest of the old or new amount will be used. @@ -205,88 +252,107 @@ public class AspectList implements Serializable { * @param amount * @return */ - public AspectList merge(Aspect aspect, int amount) { - if (this.aspects.containsKey(aspect)) { - int oldamount = this.aspects.get(aspect); - if (amount)catalyst).size()>0) { - for (ItemStack is :(ArrayList)catalyst) { + if(cat instanceof ItemStack) + { + hc += ((ItemStack) cat).toString(); + } + else if(cat instanceof ArrayList && ((ArrayList) catalyst).size() > 0) + { + for(final ItemStack is : (ArrayList) catalyst) + { hc += is.toString(); } } - + hash = hc.hashCode(); } - - - public boolean matches(AspectList itags, ItemStack cat) { - if (catalyst instanceof ItemStack && - !ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) { + public boolean matches(AspectList itags, ItemStack cat) + { + if(catalyst instanceof ItemStack && !ThaumcraftApiHelper.itemMatches((ItemStack) catalyst, cat, false)) + { return false; - } else - if (catalyst instanceof ArrayList && ((ArrayList)catalyst).size()>0) { - ItemStack[] ores = ((ArrayList)catalyst).toArray(new ItemStack[]{}); - if (!ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{cat},ores)) return false; } - if (itags==null) return false; - for (Aspect tag:aspects.getAspects()) { - if (itags.getAmount(tag)) catalyst).size() > 0) + { + final ItemStack[] ores = ((ArrayList) catalyst).toArray(new ItemStack[] {}); + if(!ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {cat}, ores)) + { + return false; + } + } + if(itags == null) + { + return false; + } + for(final Aspect tag : aspects.getAspects()) + { + if(itags.getAmount(tag) < aspects.getAmount(tag)) + { + return false; + } } return true; } - - public boolean catalystMatches(ItemStack cat) { - if (catalyst instanceof ItemStack && ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) { + + public boolean catalystMatches(ItemStack cat) + { + if(catalyst instanceof ItemStack && ThaumcraftApiHelper.itemMatches((ItemStack) catalyst, cat, false)) + { return true; - } else - if (catalyst instanceof ArrayList && ((ArrayList)catalyst).size()>0) { - ItemStack[] ores = ((ArrayList)catalyst).toArray(new ItemStack[]{}); - if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{cat},ores)) return true; + } + else if(catalyst instanceof ArrayList && ((ArrayList) catalyst).size() > 0) + { + final ItemStack[] ores = ((ArrayList) catalyst).toArray(new ItemStack[] {}); + if(ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {cat}, ores)) + { + return true; + } } return false; } - - public AspectList removeMatching(AspectList itags) { - AspectList temptags = new AspectList(); + + public AspectList removeMatching(AspectList itags) + { + final AspectList temptags = new AspectList(); temptags.aspects.putAll(itags.aspects); - - for (Aspect tag:aspects.getAspects()) { + + for(final Aspect tag : aspects.getAspects()) + { temptags.remove(tag, aspects.getAmount(tag)); } - + itags = temptags; return itags; } - - public ItemStack getRecipeOutput() { + + public ItemStack getRecipeOutput() + { return recipeOutput; } - } diff --git a/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java b/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java index bb5036d..1b0a933 100644 --- a/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java @@ -8,28 +8,29 @@ import thaumcraft.api.aspects.AspectList; public interface IArcaneRecipe { - - - /** - * Used to check if a recipe matches current crafting inventory - * @param player - */ - boolean matches(IInventory var1, World world, EntityPlayer player); - - /** - * Returns an Item that is the result of this recipe - */ - ItemStack getCraftingResult(IInventory var1); - - /** - * Returns the size of the recipe area - */ - int getRecipeSize(); - - ItemStack getRecipeOutput(); - AspectList getAspects(); - AspectList getAspects(IInventory var1); - String getResearch(); - - + + /** + * Used to check if a recipe matches current crafting inventory + * @param player + */ + boolean matches(IInventory var1, World world, EntityPlayer player); + + /** + * Returns an Item that is the result of this recipe + */ + ItemStack getCraftingResult(IInventory var1); + + /** + * Returns the size of the recipe area + */ + int getRecipeSize(); + + ItemStack getRecipeOutput(); + + AspectList getAspects(); + + AspectList getAspects(IInventory var1); + + String getResearch(); + } diff --git a/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java b/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java index d137ff2..f0a1226 100644 --- a/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java +++ b/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java @@ -9,8 +9,9 @@ import net.minecraft.world.World; * Blocks that implement this interface act as infusion crafting stabilisers like candles and skulls * */ -public interface IInfusionStabiliser { - +public interface IInfusionStabiliser +{ + /** * returns true if the block can stabilise things */ diff --git a/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java b/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java index bdc5f50..60ed52e 100644 --- a/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java @@ -15,139 +15,173 @@ import thaumcraft.api.aspects.AspectList; public class InfusionEnchantmentRecipe { - - public AspectList aspects; - public String research; - public ItemStack[] components; - public Enchantment enchantment; - public int recipeXP; - public int instability; - - public InfusionEnchantmentRecipe(String research, Enchantment input, int inst, - AspectList aspects2, ItemStack[] recipe) { + + public AspectList aspects; + public String research; + public ItemStack[] components; + public Enchantment enchantment; + public int recipeXP; + public int instability; + + public InfusionEnchantmentRecipe(String research, Enchantment input, int inst, AspectList aspects2, ItemStack[] recipe) + { this.research = research; - this.enchantment = input; - this.aspects = aspects2; - this.components = recipe; - this.instability = inst; - this.recipeXP = Math.max(1, input.getMinEnchantability(1)/3); + enchantment = input; + aspects = aspects2; + components = recipe; + instability = inst; + recipeXP = Math.max(1, input.getMinEnchantability(1) / 3); } /** - * Used to check if a recipe matches current crafting inventory - * @param player - */ - public boolean matches(ArrayList input, ItemStack central, World world, EntityPlayer player) { - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - - if (!enchantment.canApply(central) || !central.getItem().isItemTool(central)) { + * Used to check if a recipe matches current crafting inventory + * @param player + */ + public boolean matches(ArrayList input, ItemStack central, World world, EntityPlayer player) + { + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + + if(!enchantment.canApply(central) || !central.getItem().isItemTool(central)) + { return false; } - - Map map1 = EnchantmentHelper.getEnchantments(central); - Iterator iterator = map1.keySet().iterator(); - while (iterator.hasNext()) - { - int j1 = ((Integer)iterator.next()).intValue(); - Enchantment ench = Enchantment.enchantmentsList[j1]; - if (j1 == enchantment.effectId && - EnchantmentHelper.getEnchantmentLevel(j1, central)>=ench.getMaxLevel()) - return false; - if (enchantment.effectId != ench.effectId && - (!enchantment.canApplyTogether(ench) || - !ench.canApplyTogether(enchantment))) { - return false; - } - } - + + final Map map1 = EnchantmentHelper.getEnchantments(central); + final Iterator iterator = map1.keySet().iterator(); + while(iterator.hasNext()) + { + final int j1 = ((Integer) iterator.next()).intValue(); + final Enchantment ench = Enchantment.enchantmentsList[j1]; + if(j1 == enchantment.effectId && EnchantmentHelper.getEnchantmentLevel(j1, central) >= ench.getMaxLevel()) + { + return false; + } + if(enchantment.effectId != ench.effectId && (!enchantment.canApplyTogether(ench) || !ench.canApplyTogether(enchantment))) + { + return false; + } + } + ItemStack i2 = null; - - ArrayList ii = new ArrayList(); - for (ItemStack is:input) { + + final ArrayList ii = new ArrayList(); + for(final ItemStack is : input) + { ii.add(is.copy()); } - - for (ItemStack comp:components) { - boolean b=false; - for (int a=0;a input, ItemStack central, World world, EntityPlayer player) { - if (getRecipeInput()==null) return false; - - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - + * Used to check if a recipe matches current crafting inventory + * @param player + */ + public boolean matches(ArrayList input, ItemStack central, World world, EntityPlayer player) + { + if(getRecipeInput() == null) + { + return false; + } + + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + ItemStack i2 = central.copy(); - if (getRecipeInput().getItemDamage()==OreDictionary.WILDCARD_VALUE) { + if(getRecipeInput().getItemDamage() == OreDictionary.WILDCARD_VALUE) + { i2.setItemDamage(OreDictionary.WILDCARD_VALUE); } - - if (!areItemStacksEqual(i2, getRecipeInput(), true)) return false; - - ArrayList ii = new ArrayList(); - for (ItemStack is:input) { + + if(!areItemStacksEqual(i2, getRecipeInput(), true)) + { + return false; + } + + final ArrayList ii = new ArrayList(); + for(final ItemStack is : input) + { ii.add(is.copy()); } - - for (ItemStack comp:getComponents()) { - boolean b=false; - for (int a=0;a itemMap = new HashMap(); - - for (; idx < recipe.length; idx += 2) - { - Character chr = (Character)recipe[idx]; - Object in = recipe[idx + 1]; - - if (in instanceof ItemStack) - { - itemMap.put(chr, ((ItemStack)in).copy()); - } - else if (in instanceof Item) - { - itemMap.put(chr, new ItemStack((Item)in)); - } - else if (in instanceof Block) - { - itemMap.put(chr, new ItemStack((Block)in, 1, OreDictionary.WILDCARD_VALUE)); - } - else if (in instanceof String) - { - itemMap.put(chr, OreDictionary.getOres((String)in)); - } - else - { - String ret = "Invalid shaped ore recipe: "; - for (Object tmp : recipe) - { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } - } - - input = new Object[width * height]; - int x = 0; - for (char chr : shape.toCharArray()) - { - input[x++] = itemMap.get(chr); - } - } - - @Override - public ItemStack getCraftingResult(IInventory var1){ return output.copy(); } - - @Override - public int getRecipeSize(){ return input.length; } - - @Override - public ItemStack getRecipeOutput(){ return output; } - - @Override - public boolean matches(IInventory inv, World world, EntityPlayer player) - { - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) - { - for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) - { - if (checkMatch(inv, x, y, false)) - { - return true; - } - - if (mirrored && checkMatch(inv, x, y, true)) - { - return true; - } - } - } - - return false; - } - - private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror) - { - for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) - { - for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) - { - int subX = x - startX; - int subY = y - startY; - Object target = null; - - if (subX >= 0 && subY >= 0 && subX < width && subY < height) - { - if (mirror) - { - target = input[width - subX - 1 + subY * width]; - } - else - { - target = input[subX + subY * width]; - } - } - - ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y); - - if (target instanceof ItemStack) - { - if (!checkItemEquals((ItemStack)target, slot)) - { - return false; - } - } - else if (target instanceof ArrayList) - { - boolean matched = false; - - for (ItemStack item : (ArrayList)target) - { - matched = matched || checkItemEquals(item, slot); - } - - if (!matched) - { - return false; - } - } - else if (target == null && slot != null) - { - return false; - } - } - } - - return true; - } - - private boolean checkItemEquals(ItemStack target, ItemStack input) - { - if (input == null && target != null || input != null && target == null) - { - return false; - } - return (target.getItem() == input.getItem() && - (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) && - (target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage())); - } - - public ShapedArcaneRecipe setMirrored(boolean mirror) - { - mirrored = mirror; - return this; - } - - /** - * Returns the input for this recipe, any mod accessing this value should never - * manipulate the values in this array as it will effect the recipe itself. - * @return The recipes input vales. - */ - public Object[] getInput() - { - return this.input; - } - - @Override - public AspectList getAspects() { + //Added in for future ease of change, but hard coded for now. + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; + + public ItemStack output = null; + public Object[] input = null; + public AspectList aspects = null; + public String research; + public int width = 0; + public int height = 0; + private boolean mirrored = true; + + public ShapedArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapedArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapedArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + output = result.copy(); + this.research = research; + this.aspects = aspects; + String shape = ""; + + int idx = 0; + + if(recipe[idx] instanceof Boolean) + { + mirrored = (Boolean) recipe[idx]; + if(recipe[idx + 1] instanceof Object[]) + { + recipe = (Object[]) recipe[idx + 1]; + } + else + { + idx = 1; + } + } + + if(recipe[idx] instanceof String[]) + { + final String[] parts = ((String[]) recipe[idx++]); + + for(final String s : parts) + { + width = s.length(); + shape += s; + } + + height = parts.length; + } + else + { + while(recipe[idx] instanceof String) + { + final String s = (String) recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } + + if(width * height != shape.length()) + { + String ret = "Invalid shaped ore recipe: "; + for(final Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + + final HashMap itemMap = new HashMap(); + + for(; idx < recipe.length; idx += 2) + { + final Character chr = (Character) recipe[idx]; + final Object in = recipe[idx + 1]; + + if(in instanceof ItemStack) + { + itemMap.put(chr, ((ItemStack) in).copy()); + } + else if(in instanceof Item) + { + itemMap.put(chr, new ItemStack((Item) in)); + } + else if(in instanceof Block) + { + itemMap.put(chr, new ItemStack((Block) in, 1, + OreDictionary.WILDCARD_VALUE)); + } + else if(in instanceof String) + { + itemMap.put(chr, OreDictionary.getOres((String) in)); + } + else + { + String ret = "Invalid shaped ore recipe: "; + for(final Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + + input = new Object[width * height]; + int x = 0; + for(final char chr : shape.toCharArray()) + { + input[x++] = itemMap.get(chr); + } + } + + @Override + public ItemStack getCraftingResult(IInventory var1) + { + return output.copy(); + } + + @Override + public int getRecipeSize() + { + return input.length; + } + + @Override + public ItemStack getRecipeOutput() + { + return output; + } + + @Override + public boolean matches(IInventory inv, World world, EntityPlayer player) + { + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + for(int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) + { + for(int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) + { + if(checkMatch(inv, x, y, false)) + { + return true; + } + + if(mirrored && checkMatch(inv, x, y, true)) + { + return true; + } + } + } + + return false; + } + + private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror) + { + for(int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) + { + for(int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) + { + final int subX = x - startX; + final int subY = y - startY; + Object target = null; + + if(subX >= 0 && subY >= 0 && subX < width && subY < height) + { + if(mirror) + { + target = input[width - subX - 1 + subY * width]; + } + else + { + target = input[subX + subY * width]; + } + } + + final ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y); + + if(target instanceof ItemStack) + { + if(!checkItemEquals((ItemStack) target, slot)) + { + return false; + } + } + else if(target instanceof ArrayList) + { + boolean matched = false; + + for(final ItemStack item : (ArrayList) target) + { + matched = matched || checkItemEquals(item, slot); + } + + if(!matched) + { + return false; + } + } + else if(target == null && slot != null) + { + return false; + } + } + } + + return true; + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + if(input == null && target != null || input != null && target == null) + { + return false; + } + return(target.getItem() == input.getItem() && (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input, target)) && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage())); + } + + public ShapedArcaneRecipe setMirrored(boolean mirror) + { + mirrored = mirror; + return this; + } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public Object[] getInput() + { + return input; + } + + @Override + public AspectList getAspects() + { return aspects; } - - @Override - public AspectList getAspects(IInventory inv) { + + @Override + public AspectList getAspects(IInventory inv) + { return aspects; } - + @Override - public String getResearch() { + public String getResearch() + { return research; } } diff --git a/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java b/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java index 3b1eaeb..d6890c1 100644 --- a/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java @@ -15,147 +15,165 @@ import thaumcraft.api.aspects.AspectList; public class ShapelessArcaneRecipe implements IArcaneRecipe { - private ItemStack output = null; - private ArrayList input = new ArrayList(); - - public AspectList aspects = null; - public String research; - - public ShapelessArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe){ this(research,new ItemStack(result),aspects, recipe); } - public ShapelessArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe){ this(research,new ItemStack(result),aspects, recipe); } - - public ShapelessArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) - { - output = result.copy(); - this.research = research; - this.aspects = aspects; - for (Object in : recipe) - { - if (in instanceof ItemStack) - { - input.add(((ItemStack)in).copy()); - } - else if (in instanceof Item) - { - input.add(new ItemStack((Item)in)); - } - else if (in instanceof Block) - { - input.add(new ItemStack((Block)in)); - } - else if (in instanceof String) - { - input.add(OreDictionary.getOres((String)in)); - } - else - { - String ret = "Invalid shapeless ore recipe: "; - for (Object tmp : recipe) - { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } - } - } - - @Override - public int getRecipeSize(){ return input.size(); } - - @Override - public ItemStack getRecipeOutput(){ return output; } - - @Override - public ItemStack getCraftingResult(IInventory var1){ return output.copy(); } - - @Override - public boolean matches(IInventory var1, World world, EntityPlayer player) - { - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - - ArrayList required = new ArrayList(input); - - for (int x = 0; x < 9; x++) - { - ItemStack slot = var1.getStackInSlot(x); - - if (slot != null) - { - boolean inRecipe = false; - Iterator req = required.iterator(); - - while (req.hasNext()) - { - boolean match = false; - - Object next = req.next(); - - if (next instanceof ItemStack) - { - match = checkItemEquals((ItemStack)next, slot); - } - else if (next instanceof ArrayList) - { - for (ItemStack item : (ArrayList)next) - { - match = match || checkItemEquals(item, slot); - } - } - - if (match) - { - inRecipe = true; - required.remove(next); - break; - } - } - - if (!inRecipe) - { - return false; - } - } - } - - return required.isEmpty(); - } - - private boolean checkItemEquals(ItemStack target, ItemStack input) - { - if (input == null && target != null || input != null && target == null) - { - return false; - } - return (target.getItem() == input.getItem() && - (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) && - (target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage())); - } - - /** - * Returns the input for this recipe, any mod accessing this value should never - * manipulate the values in this array as it will effect the recipe itself. - * @return The recipes input vales. - */ - public ArrayList getInput() - { - return this.input; - } - - @Override - public AspectList getAspects() { + private ItemStack output = null; + private final ArrayList input = new ArrayList(); + + public AspectList aspects = null; + public String research; + + public ShapelessArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapelessArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapelessArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + output = result.copy(); + this.research = research; + this.aspects = aspects; + for(final Object in : recipe) + { + if(in instanceof ItemStack) + { + input.add(((ItemStack) in).copy()); + } + else if(in instanceof Item) + { + input.add(new ItemStack((Item) in)); + } + else if(in instanceof Block) + { + input.add(new ItemStack((Block) in)); + } + else if(in instanceof String) + { + input.add(OreDictionary.getOres((String) in)); + } + else + { + String ret = "Invalid shapeless ore recipe: "; + for(final Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + } + + @Override + public int getRecipeSize() + { + return input.size(); + } + + @Override + public ItemStack getRecipeOutput() + { + return output; + } + + @Override + public ItemStack getCraftingResult(IInventory var1) + { + return output.copy(); + } + + @Override + public boolean matches(IInventory var1, World world, EntityPlayer player) + { + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + + final ArrayList required = new ArrayList(input); + + for(int x = 0; x < 9; x++) + { + final ItemStack slot = var1.getStackInSlot(x); + + if(slot != null) + { + boolean inRecipe = false; + final Iterator req = required.iterator(); + + while(req.hasNext()) + { + boolean match = false; + + final Object next = req.next(); + + if(next instanceof ItemStack) + { + match = checkItemEquals((ItemStack) next, slot); + } + else if(next instanceof ArrayList) + { + for(final ItemStack item : (ArrayList) next) + { + match = match || checkItemEquals(item, slot); + } + } + + if(match) + { + inRecipe = true; + required.remove(next); + break; + } + } + + if(!inRecipe) + { + return false; + } + } + } + + return required.isEmpty(); + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + if(input == null && target != null || input != null && target == null) + { + return false; + } + return(target.getItem() == input.getItem() && (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input, target)) && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage())); + } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public ArrayList getInput() + { + return input; + } + + @Override + public AspectList getAspects() + { return aspects; } - - @Override - public AspectList getAspects(IInventory inv) { + + @Override + public AspectList getAspects(IInventory inv) + { return aspects; } - + @Override - public String getResearch() { + public String getResearch() + { return research; } } diff --git a/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java b/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java index 1562d05..52fc3c3 100644 --- a/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java +++ b/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java @@ -4,29 +4,23 @@ import net.minecraft.entity.Entity; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSourceIndirect; -public class DamageSourceIndirectThaumcraftEntity extends EntityDamageSourceIndirect { +public class DamageSourceIndirectThaumcraftEntity extends EntityDamageSourceIndirect +{ - private boolean fireDamage; - private float hungerDamage; - private boolean isUnblockable; - - - public DamageSourceIndirectThaumcraftEntity(String par1Str, - Entity par2Entity, Entity par3Entity) { + public DamageSourceIndirectThaumcraftEntity(String par1Str, Entity par2Entity, Entity par3Entity) + { super(par1Str, par2Entity, par3Entity); } - + @Override public DamageSource setFireDamage() - { - this.fireDamage = true; - return this; - } - + { + return this; + } + + @Override public DamageSource setDamageBypassesArmor() - { - this.isUnblockable = true; - this.hungerDamage = 0.0F; - return this; - } + { + return this; + } } diff --git a/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java b/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java index bb55672..a05f5c5 100644 --- a/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java +++ b/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java @@ -6,42 +6,29 @@ import net.minecraft.util.EntityDamageSource; public class DamageSourceThaumcraft extends DamageSource { - - public static DamageSource taint = new DamageSourceThaumcraft("taint").setDamageBypassesArmor().setMagicDamage(); - public static DamageSource tentacle = new DamageSourceThaumcraft("tentacle"); - public static DamageSource swarm = new DamageSourceThaumcraft("swarm"); - public static DamageSource dissolve = new DamageSourceThaumcraft("dissolve").setDamageBypassesArmor(); - - protected DamageSourceThaumcraft(String par1Str) { + + public static DamageSource taint = new DamageSourceThaumcraft( + "taint").setDamageBypassesArmor().setMagicDamage(); + public static DamageSource tentacle = new DamageSourceThaumcraft( + "tentacle"); + public static DamageSource swarm = new DamageSourceThaumcraft( + "swarm"); + public static DamageSource dissolve = new DamageSourceThaumcraft( + "dissolve").setDamageBypassesArmor(); + + protected DamageSourceThaumcraft(String par1Str) + { super(par1Str); } - - /** This kind of damage can be blocked or not. */ - private boolean isUnblockable = false; - private boolean isDamageAllowedInCreativeMode = false; - private float hungerDamage = 0.3F; - - /** This kind of damage is based on fire or not. */ - private boolean fireDamage; - /** This kind of damage is based on a projectile or not. */ - private boolean projectile; + public static DamageSource causeSwarmDamage(EntityLivingBase par0EntityLiving) + { + return new EntityDamageSource("swarm", par0EntityLiving); + } - /** - * Whether this damage source will have its damage amount scaled based on the current difficulty. - */ - private boolean difficultyScaled; - private boolean magicDamage = false; - private boolean explosion = false; - - public static DamageSource causeSwarmDamage(EntityLivingBase par0EntityLiving) - { - return new EntityDamageSource("swarm", par0EntityLiving); - } + public static DamageSource causeTentacleDamage(EntityLivingBase par0EntityLiving) + { + return new EntityDamageSource("tentacle", par0EntityLiving); + } - public static DamageSource causeTentacleDamage(EntityLivingBase par0EntityLiving) - { - return new EntityDamageSource("tentacle", par0EntityLiving); - } - } diff --git a/src/api/java/thaumcraft/api/entities/IEldritchMob.java b/src/api/java/thaumcraft/api/entities/IEldritchMob.java index 79fc75b..a23d228 100644 --- a/src/api/java/thaumcraft/api/entities/IEldritchMob.java +++ b/src/api/java/thaumcraft/api/entities/IEldritchMob.java @@ -1,5 +1,6 @@ package thaumcraft.api.entities; -public interface IEldritchMob { +public interface IEldritchMob +{ } diff --git a/src/api/java/thaumcraft/api/entities/ITaintedMob.java b/src/api/java/thaumcraft/api/entities/ITaintedMob.java index 83fb1fc..1b1b793 100644 --- a/src/api/java/thaumcraft/api/entities/ITaintedMob.java +++ b/src/api/java/thaumcraft/api/entities/ITaintedMob.java @@ -1,5 +1,6 @@ package thaumcraft.api.entities; -public interface ITaintedMob { +public interface ITaintedMob +{ } diff --git a/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java b/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java index 9af8c30..fcf31de 100644 --- a/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java +++ b/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java @@ -6,73 +6,83 @@ import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class DummyInternalMethodHandler implements IInternalMethodHandler { +public class DummyInternalMethodHandler implements IInternalMethodHandler +{ @Override - public void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) { - + public void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) + { + } @Override - public boolean isResearchComplete(String username, String researchkey) { + public boolean isResearchComplete(String username, String researchkey) + { return false; } - + @Override - public boolean hasDiscoveredAspect(String username, Aspect aspect) { + public boolean hasDiscoveredAspect(String username, Aspect aspect) + { return false; } - + @Override - public AspectList getDiscoveredAspects(String username) { + public AspectList getDiscoveredAspects(String username) + { return null; } @Override - public ItemStack getStackInRowAndColumn(Object instance, int row, int column) { + public ItemStack getStackInRowAndColumn(Object instance, int row, int column) + { return null; } @Override - public AspectList getObjectAspects(ItemStack is) { + public AspectList getObjectAspects(ItemStack is) + { return null; } @Override - public AspectList getBonusObjectTags(ItemStack is, AspectList ot) { + public AspectList getBonusObjectTags(ItemStack is, AspectList ot) + { return null; } @Override - public AspectList generateTags(Item item, int meta) { + public AspectList generateTags(Item item, int meta) + { return null; } @Override - public boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, - AspectList cost, boolean doit, boolean crafting) { + public boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit, boolean crafting) + { return false; } @Override - public boolean consumeVisFromWandCrafting(ItemStack wand, - EntityPlayer player, AspectList cost, boolean doit) { + public boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit) + { return false; } @Override - public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) { + public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) + { return false; } @Override - public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) { + public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) + { } @Override - public void addStickyWarpToPlayer(EntityPlayer player, int amount) { + public void addStickyWarpToPlayer(EntityPlayer player, int amount) + { } - - } diff --git a/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java b/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java index 73fce66..749c954 100644 --- a/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java +++ b/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java @@ -6,20 +6,33 @@ import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public interface IInternalMethodHandler { +public interface IInternalMethodHandler +{ public void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color); + public boolean isResearchComplete(String username, String researchkey); + public ItemStack getStackInRowAndColumn(Object instance, int row, int column); + public AspectList getObjectAspects(ItemStack is); - public AspectList getBonusObjectTags(ItemStack is,AspectList ot); + + public AspectList getBonusObjectTags(ItemStack is, AspectList ot); + public AspectList generateTags(Item item, int meta); + public boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit, boolean crafting); - public boolean consumeVisFromWandCrafting(ItemStack wand,EntityPlayer player, AspectList cost, boolean doit); + + public boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit); + public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost); - public void addWarpToPlayer(EntityPlayer player, int amount,boolean temporary); + + public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary); + public void addStickyWarpToPlayer(EntityPlayer player, int amount); + public boolean hasDiscoveredAspect(String username, Aspect aspect); + public AspectList getDiscoveredAspects(String username); - + } diff --git a/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java b/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java index 4ac6ee7..9ea95dd 100644 --- a/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java +++ b/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java @@ -5,20 +5,20 @@ import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandom; +public class WeightedRandomLoot extends WeightedRandom.Item +{ -public class WeightedRandomLoot extends WeightedRandom.Item { - /** The Item/Block ID to generate in the bag. */ - public ItemStack item; + public ItemStack item; + + public WeightedRandomLoot(ItemStack stack, int weight) + { + super(weight); + item = stack; + } + + public static ArrayList lootBagCommon = new ArrayList(); + public static ArrayList lootBagUncommon = new ArrayList(); + public static ArrayList lootBagRare = new ArrayList(); - public WeightedRandomLoot(ItemStack stack, int weight) - { - super(weight); - this.item = stack; - } - - public static ArrayList lootBagCommon = new ArrayList(); - public static ArrayList lootBagUncommon = new ArrayList(); - public static ArrayList lootBagRare = new ArrayList(); - } diff --git a/src/api/java/thaumcraft/api/nodes/INode.java b/src/api/java/thaumcraft/api/nodes/INode.java index 61da1f7..4ef8fee 100644 --- a/src/api/java/thaumcraft/api/nodes/INode.java +++ b/src/api/java/thaumcraft/api/nodes/INode.java @@ -4,16 +4,17 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.IAspectContainer; -public interface INode extends IAspectContainer { +public interface INode extends IAspectContainer +{ /** * Unique identifier to distinguish nodes. Normal node id's are based on world id and coordinates * @return */ public String getId(); - + public AspectList getAspectsBase(); - + /** * Return the type of node * @return @@ -31,13 +32,13 @@ public interface INode extends IAspectContainer { * @return */ public void setNodeModifier(NodeModifier nodeModifier); - + /** * Return the node modifier * @return */ public NodeModifier getNodeModifier(); - + /** * Return the maximum capacity of each aspect the node can hold * @return @@ -49,5 +50,5 @@ public interface INode extends IAspectContainer { * @return */ public void setNodeVisBase(Aspect aspect, short nodeVisBase); - + } diff --git a/src/api/java/thaumcraft/api/nodes/IRevealer.java b/src/api/java/thaumcraft/api/nodes/IRevealer.java index 14a19b5..0f241e1 100644 --- a/src/api/java/thaumcraft/api/nodes/IRevealer.java +++ b/src/api/java/thaumcraft/api/nodes/IRevealer.java @@ -11,12 +11,12 @@ import net.minecraft.item.ItemStack; * */ -public interface IRevealer { - +public interface IRevealer +{ + /* * If this method returns true the nodes will be visible. */ public boolean showNodes(ItemStack itemstack, EntityLivingBase player); - } diff --git a/src/api/java/thaumcraft/api/nodes/NodeModifier.java b/src/api/java/thaumcraft/api/nodes/NodeModifier.java index 885b867..2e0e95e 100644 --- a/src/api/java/thaumcraft/api/nodes/NodeModifier.java +++ b/src/api/java/thaumcraft/api/nodes/NodeModifier.java @@ -2,5 +2,5 @@ package thaumcraft.api.nodes; public enum NodeModifier { - BRIGHT, PALE, FADING -} \ No newline at end of file + BRIGHT, PALE, FADING +} diff --git a/src/api/java/thaumcraft/api/nodes/NodeType.java b/src/api/java/thaumcraft/api/nodes/NodeType.java index 355324b..4fc26c3 100644 --- a/src/api/java/thaumcraft/api/nodes/NodeType.java +++ b/src/api/java/thaumcraft/api/nodes/NodeType.java @@ -2,5 +2,5 @@ package thaumcraft.api.nodes; public enum NodeType { - NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE -} \ No newline at end of file + NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE +} diff --git a/src/api/java/thaumcraft/api/package-info.java b/src/api/java/thaumcraft/api/package-info.java index cceaf89..4de2404 100644 --- a/src/api/java/thaumcraft/api/package-info.java +++ b/src/api/java/thaumcraft/api/package-info.java @@ -2,3 +2,4 @@ package thaumcraft.api; import cpw.mods.fml.common.API; + diff --git a/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java b/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java index b950de0..facc2cc 100644 --- a/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java +++ b/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java @@ -12,56 +12,59 @@ import cpw.mods.fml.relauncher.SideOnly; public class PotionFluxTaint extends Potion { - public static PotionFluxTaint instance = null; // will be instantiated at runtime - private int statusIconIndex = -1; - - public PotionFluxTaint(int par1, boolean par2, int par3) - { - super(par1,par2,par3); - setIconIndex(0, 0); - } - - public static void init() - { - instance.setPotionName("potion.fluxtaint"); - instance.setIconIndex(3, 1); - instance.setEffectiveness(0.25D); - } - + public static PotionFluxTaint instance = null; // will be instantiated at runtime + public PotionFluxTaint(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + setIconIndex(0, 0); + } + + public static void init() + { + instance.setPotionName("potion.fluxtaint"); + instance.setIconIndex(3, 1); + instance.setEffectiveness(0.25D); + } + @Override - public boolean isBadEffect() { + public boolean isBadEffect() + { return true; } @Override @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { + public int getStatusIconIndex() + { Minecraft.getMinecraft().renderEngine.bindTexture(rl); return super.getStatusIconIndex(); } - - static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png"); - + + static final ResourceLocation rl = new ResourceLocation("thaumcraft", + "textures/misc/potions.png"); + @Override - public void performEffect(EntityLivingBase target, int par2) { - if (target instanceof ITaintedMob) { + public void performEffect(EntityLivingBase target, int par2) + { + if(target instanceof ITaintedMob) + { target.heal(1); - } else - if (!target.isEntityUndead() && !(target instanceof EntityPlayer)) - { + } + else if(!target.isEntityUndead() && !(target instanceof EntityPlayer)) + { target.attackEntityFrom(DamageSourceThaumcraft.taint, 1); - } - else - if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer))) - { + } + else if(!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer))) + { target.attackEntityFrom(DamageSourceThaumcraft.taint, 1); - } + } } - + + @Override public boolean isReady(int par1, int par2) - { - int k = 40 >> par2; - return k > 0 ? par1 % k == 0 : true; - } - + { + final int k = 40 >> par2; + return k > 0 ? par1 % k == 0 : true; + } + } diff --git a/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java b/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java index cd7fc18..baa0f9c 100644 --- a/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java +++ b/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java @@ -9,40 +9,41 @@ import cpw.mods.fml.relauncher.SideOnly; public class PotionVisExhaust extends Potion { - public static PotionVisExhaust instance = null; // will be instantiated at runtime - private int statusIconIndex = -1; - - public PotionVisExhaust(int par1, boolean par2, int par3) - { - super(par1,par2,par3); - setIconIndex(0, 0); - } - - public static void init() - { - instance.setPotionName("potion.visexhaust"); - instance.setIconIndex(5, 1); - instance.setEffectiveness(0.25D); - } - + public static PotionVisExhaust instance = null; // will be instantiated at runtime + public PotionVisExhaust(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + setIconIndex(0, 0); + } + + public static void init() + { + instance.setPotionName("potion.visexhaust"); + instance.setIconIndex(5, 1); + instance.setEffectiveness(0.25D); + } + @Override - public boolean isBadEffect() { + public boolean isBadEffect() + { return true; } @Override @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { + public int getStatusIconIndex() + { Minecraft.getMinecraft().renderEngine.bindTexture(rl); return super.getStatusIconIndex(); } - - static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png"); - + + static final ResourceLocation rl = new ResourceLocation("thaumcraft", + "textures/misc/potions.png"); + @Override - public void performEffect(EntityLivingBase target, int par2) { - + public void performEffect(EntityLivingBase target, int par2) + { + } - - + } diff --git a/src/api/java/thaumcraft/api/research/IScanEventHandler.java b/src/api/java/thaumcraft/api/research/IScanEventHandler.java index d0efac5..219cb5d 100644 --- a/src/api/java/thaumcraft/api/research/IScanEventHandler.java +++ b/src/api/java/thaumcraft/api/research/IScanEventHandler.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IScanEventHandler { +public interface IScanEventHandler +{ ScanResult scanPhenomena(ItemStack stack, World world, EntityPlayer player); } diff --git a/src/api/java/thaumcraft/api/research/ResearchCategories.java b/src/api/java/thaumcraft/api/research/ResearchCategories.java index 82309b3..01c648b 100644 --- a/src/api/java/thaumcraft/api/research/ResearchCategories.java +++ b/src/api/java/thaumcraft/api/research/ResearchCategories.java @@ -10,43 +10,52 @@ import org.apache.logging.log4j.Level; import cpw.mods.fml.common.FMLLog; -public class ResearchCategories { - +public class ResearchCategories +{ + //Research - public static LinkedHashMap researchCategories = new LinkedHashMap (); - + public static LinkedHashMap researchCategories = new LinkedHashMap(); + /** * @param key * @return the research item linked to this key */ - public static ResearchCategoryList getResearchList(String key) { + public static ResearchCategoryList getResearchList(String key) + { return researchCategories.get(key); } - + /** * @param key * @return the name of the research category linked to this key. * Must be stored as localization information in the LanguageRegistry. */ - public static String getCategoryName(String key) { - return StatCollector.translateToLocal("tc.research_category."+key); + public static String getCategoryName(String key) + { + return StatCollector.translateToLocal("tc.research_category." + key); } - + /** * @param key the research key * @return the ResearchItem object. */ - public static ResearchItem getResearch(String key) { - Collection rc = researchCategories.values(); - for (Object cat:rc) { - Collection rl = ((ResearchCategoryList)cat).research.values(); - for (Object ri:rl) { - if ((((ResearchItem)ri).key).equals(key)) return (ResearchItem)ri; + public static ResearchItem getResearch(String key) + { + final Collection rc = researchCategories.values(); + for(final Object cat : rc) + { + final Collection rl = ((ResearchCategoryList) cat).research.values(); + for(final Object ri : rl) + { + if((((ResearchItem) ri).key).equals(key)) + { + return (ResearchItem) ri; + } } } return null; } - + /** * This should only be done at the PostInit stage * @param key the key used for this category @@ -54,48 +63,54 @@ public class ResearchCategories { * @param background the resource location of the background image to use for this category * @return the name of the research linked to this key */ - public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { - if (getResearchList(key)==null) { - ResearchCategoryList rl = new ResearchCategoryList(icon, background); + public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) + { + if(getResearchList(key) == null) + { + final ResearchCategoryList rl = new ResearchCategoryList(icon, background); researchCategories.put(key, rl); } } - - public static void addResearch(ResearchItem ri) { - ResearchCategoryList rl = getResearchList(ri.category); - if (rl!=null && !rl.research.containsKey(ri.key)) { - - if (!ri.isVirtual()) { - for (ResearchItem rr:rl.research.values()) { - if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { - FMLLog.log(Level.FATAL, "[Thaumcraft] Research ["+ri.getName()+"] not added as it overlaps with existing research ["+rr.getName()+"]"); + + public static void addResearch(ResearchItem ri) + { + final ResearchCategoryList rl = getResearchList(ri.category); + if(rl != null && !rl.research.containsKey(ri.key)) + { + + if(!ri.isVirtual()) + { + for(final ResearchItem rr : rl.research.values()) + { + if(rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) + { + FMLLog.log(Level.FATAL, "[Thaumcraft] Research [" + ri.getName() + "] not added as it overlaps with existing research [" + rr.getName() + "]"); return; } } } - - + rl.research.put(ri.key, ri); - - if (ri.displayColumn < rl.minDisplayColumn) - { - rl.minDisplayColumn = ri.displayColumn; - } - - if (ri.displayRow < rl.minDisplayRow) - { - rl.minDisplayRow = ri.displayRow; - } - - if (ri.displayColumn > rl.maxDisplayColumn) - { - rl.maxDisplayColumn = ri.displayColumn; - } - - if (ri.displayRow > rl.maxDisplayRow) - { - rl.maxDisplayRow = ri.displayRow; - } - } + + if(ri.displayColumn < rl.minDisplayColumn) + { + rl.minDisplayColumn = ri.displayColumn; + } + + if(ri.displayRow < rl.minDisplayRow) + { + rl.minDisplayRow = ri.displayRow; + } + + if(ri.displayColumn > rl.maxDisplayColumn) + { + rl.maxDisplayColumn = ri.displayColumn; + } + + if(ri.displayRow > rl.maxDisplayRow) + { + rl.maxDisplayRow = ri.displayRow; + } + } } } diff --git a/src/api/java/thaumcraft/api/research/ResearchCategoryList.java b/src/api/java/thaumcraft/api/research/ResearchCategoryList.java index 7eed010..289604d 100644 --- a/src/api/java/thaumcraft/api/research/ResearchCategoryList.java +++ b/src/api/java/thaumcraft/api/research/ResearchCategoryList.java @@ -5,33 +5,32 @@ import java.util.Map; import net.minecraft.util.ResourceLocation; -public class ResearchCategoryList { - +public class ResearchCategoryList +{ + /** Is the smallest column used on the GUI. */ - public int minDisplayColumn; - - /** Is the smallest row used on the GUI. */ - public int minDisplayRow; - - /** Is the biggest column used on the GUI. */ - public int maxDisplayColumn; - - /** Is the biggest row used on the GUI. */ - public int maxDisplayRow; - - /** display variables **/ - public ResourceLocation icon; - public ResourceLocation background; - - public ResearchCategoryList(ResourceLocation icon, ResourceLocation background) { + public int minDisplayColumn; + + /** Is the smallest row used on the GUI. */ + public int minDisplayRow; + + /** Is the biggest column used on the GUI. */ + public int maxDisplayColumn; + + /** Is the biggest row used on the GUI. */ + public int maxDisplayRow; + + /** display variables **/ + public ResourceLocation icon; + public ResourceLocation background; + + public ResearchCategoryList(ResourceLocation icon, ResourceLocation background) + { this.icon = icon; this.background = background; } //Research - public Map research = new HashMap(); - - - - + public Map research = new HashMap(); + } diff --git a/src/api/java/thaumcraft/api/research/ResearchItem.java b/src/api/java/thaumcraft/api/research/ResearchItem.java index 1d5fd8b..b8b9e88 100644 --- a/src/api/java/thaumcraft/api/research/ResearchItem.java +++ b/src/api/java/thaumcraft/api/research/ResearchItem.java @@ -6,346 +6,365 @@ import net.minecraft.util.StatCollector; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class ResearchItem +public class ResearchItem { /** * A short string used as a key for this research. Must be unique */ - public final String key; - + public final String key; + /** * A short string used as a reference to the research category to which this must be added. */ - public final String category; + public final String category; /** * The aspect tags and their values required to complete this research */ - public final AspectList tags; - - /** - * This links to any research that needs to be completed before this research can be discovered or learnt. - */ - public String[] parents = null; - - /** - * Like parent above, but a line will not be displayed in the thaumonomicon linking them. Just used to prevent clutter. - */ - public String[] parentsHidden = null; - /** - * any research linked to this that will be unlocked automatically when this research is complete - */ - public String[] siblings = null; - - /** - * the horizontal position of the research icon - */ - public final int displayColumn; - - /** - * the vertical position of the research icon - */ - public final int displayRow; - - /** - * the icon to be used for this research - */ - public final ItemStack icon_item; - - /** - * the icon to be used for this research - */ - public final ResourceLocation icon_resource; - - /** - * How large the research grid is. Valid values are 1 to 3. - */ - private int complexity; - - /** - * Special research has a spiky border. Used for important research milestones. - */ - private boolean isSpecial; - - /** - * Research that can be directly purchased with RP in normal research difficulty. - */ - private boolean isSecondary; - + public final AspectList tags; + + /** + * This links to any research that needs to be completed before this research can be discovered or learnt. + */ + public String[] parents = null; + + /** + * Like parent above, but a line will not be displayed in the thaumonomicon linking them. Just used to prevent clutter. + */ + public String[] parentsHidden = null; + /** + * any research linked to this that will be unlocked automatically when this research is complete + */ + public String[] siblings = null; + /** - * This indicates if the research should use a circular icon border. Usually used for "passive" research - * that doesn't have recipes and grants passive effects, or that unlock automatically. - */ - private boolean isRound; - - /** - * Stub research cannot be discovered by normal means, but can be unlocked via the sibling system. - */ - private boolean isStub; - - /** - * This indicated that the research is completely hidden and cannot be discovered by any - * player-controlled means. The recipes will never show up in the thaumonomicon. - * Usually used to unlock "hidden" recipes via sibling unlocking, like - * the various cap and rod combos for wands. - */ - private boolean isVirtual; - - - - /** - * Concealed research does not display in the thaumonomicon until parent researches are discovered. - */ - private boolean isConcealed; - - /** - * Hidden research can only be discovered via scanning or knowledge fragments - */ - private boolean isHidden; - - /** - * This is the same as isHidden, except it cannot be discovered with knowledge fragments, only scanning. - */ - private boolean isLost; - - /** - * These research items will automatically unlock for all players on game start - */ - private boolean isAutoUnlock; - - /** - * Scanning these items will have a chance of revealing hidden knowledge in the thaumonomicon - */ - private ItemStack[] itemTriggers; - - /** - * Scanning these entities will have a chance of revealing hidden knowledge in the thaumonomicon - */ - private String[] entityTriggers; - - /** - * Scanning things with these aspects will have a chance of revealing hidden knowledge in the thaumonomicon - */ - private Aspect[] aspectTriggers; - - private ResearchPage[] pages = null; - + * the horizontal position of the research icon + */ + public final int displayColumn; + + /** + * the vertical position of the research icon + */ + public final int displayRow; + + /** + * the icon to be used for this research + */ + public final ItemStack icon_item; + + /** + * the icon to be used for this research + */ + public final ResourceLocation icon_resource; + + /** + * How large the research grid is. Valid values are 1 to 3. + */ + private int complexity; + + /** + * Special research has a spiky border. Used for important research milestones. + */ + private boolean isSpecial; + + /** + * Research that can be directly purchased with RP in normal research difficulty. + */ + private boolean isSecondary; + + /** + * This indicates if the research should use a circular icon border. Usually used for "passive" research + * that doesn't have recipes and grants passive effects, or that unlock automatically. + */ + private boolean isRound; + + /** + * Stub research cannot be discovered by normal means, but can be unlocked via the sibling system. + */ + private boolean isStub; + + /** + * This indicated that the research is completely hidden and cannot be discovered by any + * player-controlled means. The recipes will never show up in the thaumonomicon. + * Usually used to unlock "hidden" recipes via sibling unlocking, like + * the various cap and rod combos for wands. + */ + private boolean isVirtual; + + /** + * Concealed research does not display in the thaumonomicon until parent researches are discovered. + */ + private boolean isConcealed; + + /** + * Hidden research can only be discovered via scanning or knowledge fragments + */ + private boolean isHidden; + + /** + * This is the same as isHidden, except it cannot be discovered with knowledge fragments, only scanning. + */ + private boolean isLost; + + /** + * These research items will automatically unlock for all players on game start + */ + private boolean isAutoUnlock; + + /** + * Scanning these items will have a chance of revealing hidden knowledge in the thaumonomicon + */ + private ItemStack[] itemTriggers; + + /** + * Scanning these entities will have a chance of revealing hidden knowledge in the thaumonomicon + */ + private String[] entityTriggers; + + /** + * Scanning things with these aspects will have a chance of revealing hidden knowledge in the thaumonomicon + */ + private Aspect[] aspectTriggers; + + private ResearchPage[] pages = null; + public ResearchItem(String key, String category) - { - this.key = key; - this.category = category; - this.tags = new AspectList(); - this.icon_resource = null; - this.icon_item = null; - this.displayColumn = 0; - this.displayRow = 0; - this.setVirtual(); - - } - - public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ResourceLocation icon) - { - this.key = key; - this.category = category; - this.tags = tags; - this.icon_resource = icon; - this.icon_item = null; - this.displayColumn = col; - this.displayRow = row; - this.complexity = complex; - if (complexity < 1) this.complexity = 1; - if (complexity > 3) this.complexity = 3; - } - - public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ItemStack icon) - { - this.key = key; - this.category = category; - this.tags = tags; - this.icon_item = icon; - this.icon_resource = null; - this.displayColumn = col; - this.displayRow = row; - this.complexity = complex; - if (complexity < 1) this.complexity = 1; - if (complexity > 3) this.complexity = 3; - } - - public ResearchItem setSpecial() - { - this.isSpecial = true; - return this; - } - - public ResearchItem setStub() - { - this.isStub = true; - return this; - } - - public ResearchItem setLost() - { - this.isLost = true; - return this; - } - - public ResearchItem setConcealed() - { - this.isConcealed = true; - return this; - } - - public ResearchItem setHidden() - { - this.isHidden = true; - return this; - } - - public ResearchItem setVirtual() - { - this.isVirtual = true; - return this; - } - - public ResearchItem setParents(String... par) - { - this.parents = par; - return this; - } - - + { + this.key = key; + this.category = category; + tags = new AspectList(); + icon_resource = null; + icon_item = null; + displayColumn = 0; + displayRow = 0; + setVirtual(); + + } + + public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ResourceLocation icon) + { + this.key = key; + this.category = category; + this.tags = tags; + icon_resource = icon; + icon_item = null; + displayColumn = col; + displayRow = row; + complexity = complex; + if(complexity < 1) + { + complexity = 1; + } + if(complexity > 3) + { + complexity = 3; + } + } + + public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ItemStack icon) + { + this.key = key; + this.category = category; + this.tags = tags; + icon_item = icon; + icon_resource = null; + displayColumn = col; + displayRow = row; + complexity = complex; + if(complexity < 1) + { + complexity = 1; + } + if(complexity > 3) + { + complexity = 3; + } + } + + public ResearchItem setSpecial() + { + isSpecial = true; + return this; + } + + public ResearchItem setStub() + { + isStub = true; + return this; + } + + public ResearchItem setLost() + { + isLost = true; + return this; + } + + public ResearchItem setConcealed() + { + isConcealed = true; + return this; + } + + public ResearchItem setHidden() + { + isHidden = true; + return this; + } + + public ResearchItem setVirtual() + { + isVirtual = true; + return this; + } + + public ResearchItem setParents(String... par) + { + parents = par; + return this; + } public ResearchItem setParentsHidden(String... par) - { - this.parentsHidden = par; - return this; - } - - public ResearchItem setSiblings(String... sib) - { - this.siblings = sib; - return this; - } - - public ResearchItem setPages(ResearchPage... par) - { - this.pages = par; - return this; - } - - public ResearchPage[] getPages() { + { + parentsHidden = par; + return this; + } + + public ResearchItem setSiblings(String... sib) + { + siblings = sib; + return this; + } + + public ResearchItem setPages(ResearchPage... par) + { + pages = par; + return this; + } + + public ResearchPage[] getPages() + { return pages; } - - public ResearchItem setItemTriggers(ItemStack... par) - { - this.itemTriggers = par; - return this; - } - - public ResearchItem setEntityTriggers(String... par) - { - this.entityTriggers = par; - return this; - } - - public ResearchItem setAspectTriggers(Aspect... par) - { - this.aspectTriggers = par; - return this; - } - - public ItemStack[] getItemTriggers() { + + public ResearchItem setItemTriggers(ItemStack... par) + { + itemTriggers = par; + return this; + } + + public ResearchItem setEntityTriggers(String... par) + { + entityTriggers = par; + return this; + } + + public ResearchItem setAspectTriggers(Aspect... par) + { + aspectTriggers = par; + return this; + } + + public ItemStack[] getItemTriggers() + { return itemTriggers; } - public String[] getEntityTriggers() { + public String[] getEntityTriggers() + { return entityTriggers; } - - public Aspect[] getAspectTriggers() { + + public Aspect[] getAspectTriggers() + { return aspectTriggers; } public ResearchItem registerResearchItem() - { - ResearchCategories.addResearch(this); - return this; - } - - public String getName() - { - return StatCollector.translateToLocal("tc.research_name."+key); - } - - public String getText() - { - return StatCollector.translateToLocal("tc.research_text."+key); - } - - public boolean isSpecial() - { - return this.isSpecial; - } - - public boolean isStub() - { - return this.isStub; - } - - public boolean isLost() - { - return this.isLost; - } - - public boolean isConcealed() - { - return this.isConcealed; - } - - public boolean isHidden() - { - return this.isHidden; - } - - public boolean isVirtual() - { - return this.isVirtual; - } - - public boolean isAutoUnlock() { + { + ResearchCategories.addResearch(this); + return this; + } + + public String getName() + { + return StatCollector.translateToLocal("tc.research_name." + key); + } + + public String getText() + { + return StatCollector.translateToLocal("tc.research_text." + key); + } + + public boolean isSpecial() + { + return isSpecial; + } + + public boolean isStub() + { + return isStub; + } + + public boolean isLost() + { + return isLost; + } + + public boolean isConcealed() + { + return isConcealed; + } + + public boolean isHidden() + { + return isHidden; + } + + public boolean isVirtual() + { + return isVirtual; + } + + public boolean isAutoUnlock() + { return isAutoUnlock; } - + public ResearchItem setAutoUnlock() - { - this.isAutoUnlock = true; - return this; - } - - public boolean isRound() { + { + isAutoUnlock = true; + return this; + } + + public boolean isRound() + { return isRound; } - public ResearchItem setRound() { - this.isRound = true; + public ResearchItem setRound() + { + isRound = true; return this; } - - public boolean isSecondary() { + + public boolean isSecondary() + { return isSecondary; } - public ResearchItem setSecondary() { - this.isSecondary = true; + public ResearchItem setSecondary() + { + isSecondary = true; return this; } - public int getComplexity() { + public int getComplexity() + { return complexity; } - public ResearchItem setComplexity(int complexity) { + public ResearchItem setComplexity(int complexity) + { this.complexity = complexity; return this; } @@ -353,17 +372,23 @@ public class ResearchItem /** * @return the aspect aspects ordinal with the highest value. Used to determine scroll color and similar things */ - public Aspect getResearchPrimaryTag() { - Aspect aspect=null; - int highest=0; - if (tags!=null) - for (Aspect tag:tags.getAspects()) { - if (tags.getAmount(tag)>highest) { - aspect=tag; - highest=tags.getAmount(tag); - }; + public Aspect getResearchPrimaryTag() + { + Aspect aspect = null; + int highest = 0; + if(tags != null) + { + for(final Aspect tag : tags.getAspects()) + { + if(tags.getAmount(tag) > highest) + { + aspect = tag; + highest = tags.getAmount(tag); + } + ; + } } return aspect; } - + } diff --git a/src/api/java/thaumcraft/api/research/ResearchPage.java b/src/api/java/thaumcraft/api/research/ResearchPage.java index fdada84..415350a 100644 --- a/src/api/java/thaumcraft/api/research/ResearchPage.java +++ b/src/api/java/thaumcraft/api/research/ResearchPage.java @@ -13,181 +13,194 @@ import thaumcraft.api.crafting.IArcaneRecipe; import thaumcraft.api.crafting.InfusionEnchantmentRecipe; import thaumcraft.api.crafting.InfusionRecipe; -public class ResearchPage { +public class ResearchPage +{ public static enum PageType - { - TEXT, - TEXT_CONCEALED, - IMAGE, - CRUCIBLE_CRAFTING, - ARCANE_CRAFTING, - ASPECTS, - NORMAL_CRAFTING, - INFUSION_CRAFTING, - COMPOUND_CRAFTING, - INFUSION_ENCHANTMENT, - SMELTING - } - - public PageType type = PageType.TEXT; - - public String text=null; - public String research=null; - public ResourceLocation image=null; - public AspectList aspects=null; - public Object recipe=null; - public ItemStack recipeOutput=null; - + { + TEXT, TEXT_CONCEALED, IMAGE, CRUCIBLE_CRAFTING, ARCANE_CRAFTING, ASPECTS, NORMAL_CRAFTING, INFUSION_CRAFTING, COMPOUND_CRAFTING, INFUSION_ENCHANTMENT, SMELTING + } + + public PageType type = PageType.TEXT; + + public String text = null; + public String research = null; + public ResourceLocation image = null; + public AspectList aspects = null; + public Object recipe = null; + public ItemStack recipeOutput = null; + /** * @param text this can (but does not have to) be a reference to a localization variable, not the actual text. */ - public ResearchPage(String text) { - this.type = PageType.TEXT; + public ResearchPage(String text) + { + type = PageType.TEXT; this.text = text; } - + /** * @param research this page will only be displayed if the player has discovered this research * @param text this can (but does not have to) be a reference to a localization variable, not the actual text. */ - public ResearchPage(String research, String text) { - this.type = PageType.TEXT_CONCEALED; + public ResearchPage(String research, String text) + { + type = PageType.TEXT_CONCEALED; this.research = research; this.text = text; } - + /** * @param recipe a vanilla crafting recipe. */ - public ResearchPage(IRecipe recipe) { - this.type = PageType.NORMAL_CRAFTING; + public ResearchPage(IRecipe recipe) + { + type = PageType.NORMAL_CRAFTING; this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); + recipeOutput = recipe.getRecipeOutput(); } - + /** * @param recipe a collection of vanilla crafting recipes. */ - public ResearchPage(IRecipe[] recipe) { - this.type = PageType.NORMAL_CRAFTING; + public ResearchPage(IRecipe[] recipe) + { + type = PageType.NORMAL_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a collection of arcane crafting recipes. */ - public ResearchPage(IArcaneRecipe[] recipe) { - this.type = PageType.ARCANE_CRAFTING; + public ResearchPage(IArcaneRecipe[] recipe) + { + type = PageType.ARCANE_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a collection of arcane crafting recipes. */ - public ResearchPage(CrucibleRecipe[] recipe) { - this.type = PageType.CRUCIBLE_CRAFTING; + public ResearchPage(CrucibleRecipe[] recipe) + { + type = PageType.CRUCIBLE_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a collection of infusion crafting recipes. */ - public ResearchPage(InfusionRecipe[] recipe) { - this.type = PageType.INFUSION_CRAFTING; + public ResearchPage(InfusionRecipe[] recipe) + { + type = PageType.INFUSION_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a compound crafting recipe. */ - public ResearchPage(List recipe) { - this.type = PageType.COMPOUND_CRAFTING; + public ResearchPage(List recipe) + { + type = PageType.COMPOUND_CRAFTING; this.recipe = recipe; } - + /** * @param recipe an arcane worktable crafting recipe. */ - public ResearchPage(IArcaneRecipe recipe) { - this.type = PageType.ARCANE_CRAFTING; + public ResearchPage(IArcaneRecipe recipe) + { + type = PageType.ARCANE_CRAFTING; this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); + recipeOutput = recipe.getRecipeOutput(); } - + /** * @param recipe an alchemy crafting recipe. */ - public ResearchPage(CrucibleRecipe recipe) { - this.type = PageType.CRUCIBLE_CRAFTING; + public ResearchPage(CrucibleRecipe recipe) + { + type = PageType.CRUCIBLE_CRAFTING; this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); + recipeOutput = recipe.getRecipeOutput(); } - + /** * @param recipe a furnace smelting crafting recipe. */ - public ResearchPage(ItemStack input) { - this.type = PageType.SMELTING; - this.recipe = input; - this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); + public ResearchPage(ItemStack input) + { + type = PageType.SMELTING; + recipe = input; + recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); } - + /** * @param recipe an infusion crafting recipe. */ - public ResearchPage(InfusionRecipe recipe) { - this.type = PageType.INFUSION_CRAFTING; + public ResearchPage(InfusionRecipe recipe) + { + type = PageType.INFUSION_CRAFTING; this.recipe = recipe; - if (recipe.getRecipeOutput() instanceof ItemStack) { - this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); - } else { - this.recipeOutput = recipe.getRecipeInput(); + if(recipe.getRecipeOutput() instanceof ItemStack) + { + recipeOutput = (ItemStack) recipe.getRecipeOutput(); + } + else + { + recipeOutput = recipe.getRecipeInput(); } } - + /** * @param recipe an infusion crafting recipe. */ - public ResearchPage(InfusionEnchantmentRecipe recipe) { - this.type = PageType.INFUSION_ENCHANTMENT; + public ResearchPage(InfusionEnchantmentRecipe recipe) + { + type = PageType.INFUSION_ENCHANTMENT; this.recipe = recipe; -// if (recipe.recipeOutput instanceof ItemStack) { -// this.recipeOutput = (ItemStack) recipe.recipeOutput; -// } else { -// this.recipeOutput = recipe.recipeInput; -// } + // if (recipe.recipeOutput instanceof ItemStack) { + // this.recipeOutput = (ItemStack) recipe.recipeOutput; + // } else { + // this.recipeOutput = recipe.recipeInput; + // } } - + /** * @param image * @param caption this can (but does not have to) be a reference to a localization variable, not the actual text. */ - public ResearchPage(ResourceLocation image, String caption) { - this.type = PageType.IMAGE; + public ResearchPage(ResourceLocation image, String caption) + { + type = PageType.IMAGE; this.image = image; - this.text = caption; + text = caption; } - + /** * This function should really not be called directly - used internally */ - public ResearchPage(AspectList as) { - this.type = PageType.ASPECTS; - this.aspects = as; + public ResearchPage(AspectList as) + { + type = PageType.ASPECTS; + aspects = as; } - + /** * returns a localized text of the text field (if one exists). Returns the text field itself otherwise. * @return */ - public String getTranslatedText() { - String ret=""; - if (text != null) { + public String getTranslatedText() + { + String ret = ""; + if(text != null) + { ret = StatCollector.translateToLocal(text); - if (ret.isEmpty()) ret = text; + if(ret.isEmpty()) + { + ret = text; + } } return ret; } - - + } diff --git a/src/api/java/thaumcraft/api/research/ScanResult.java b/src/api/java/thaumcraft/api/research/ScanResult.java index e1498f3..8c04c69 100644 --- a/src/api/java/thaumcraft/api/research/ScanResult.java +++ b/src/api/java/thaumcraft/api/research/ScanResult.java @@ -2,36 +2,46 @@ package thaumcraft.api.research; import net.minecraft.entity.Entity; -public class ScanResult { - public byte type = 0; //1=blocks,2=entities,3=phenomena - public int id; - public int meta; - public Entity entity; - public String phenomena; +public class ScanResult +{ + public byte type = 0; //1=blocks,2=entities,3=phenomena + public int id; + public int meta; + public Entity entity; + public String phenomena; - public ScanResult(byte type, int blockId, int blockMeta, Entity entity, - String phenomena) { + public ScanResult(byte type, int blockId, int blockMeta, Entity entity, String phenomena) + { super(); this.type = type; - this.id = blockId; - this.meta = blockMeta; + id = blockId; + meta = blockMeta; this.entity = entity; this.phenomena = phenomena; } @Override - public boolean equals(Object obj) { - if (obj instanceof ScanResult) { - ScanResult sr = (ScanResult) obj; - if (type != sr.type) + public boolean equals(Object obj) + { + if(obj instanceof ScanResult) + { + final ScanResult sr = (ScanResult) obj; + if(type != sr.type) + { return false; - if (type == 1 - && (id != sr.id || meta != sr.meta)) + } + if(type == 1 && (id != sr.id || meta != sr.meta)) + { return false; - if (type == 2 && entity.getEntityId() != sr.entity.getEntityId()) + } + if(type == 2 && entity.getEntityId() != sr.entity.getEntityId()) + { return false; - if (type == 3 && !phenomena.equals(sr.phenomena)) + } + if(type == 3 && !phenomena.equals(sr.phenomena)) + { return false; + } } return true; } diff --git a/src/api/java/thaumcraft/api/visnet/TileVisNode.java b/src/api/java/thaumcraft/api/visnet/TileVisNode.java index 204879e..56dbafe 100644 --- a/src/api/java/thaumcraft/api/visnet/TileVisNode.java +++ b/src/api/java/thaumcraft/api/visnet/TileVisNode.java @@ -15,174 +15,203 @@ import thaumcraft.api.aspects.Aspect; * a transport relay or vis receiver (like the infernal furnace). * */ -public abstract class TileVisNode extends TileThaumcraft { - - WeakReference parent = null; - ArrayList> children = new ArrayList>(); - +public abstract class TileVisNode extends TileThaumcraft +{ + + WeakReference parent = null; + ArrayList> children = new ArrayList>(); + /** * @return the WorldCoordinates location of where this node is located */ - public WorldCoordinates getLocation() { + public WorldCoordinates getLocation() + { return new WorldCoordinates(this); } - + /** * @return the number of blocks away this node will check for parent nodes to connect to. */ public abstract int getRange(); - + /** * @return true if this is the source or root node of the vis network. */ public abstract boolean isSource(); - + /** * This method should never be called directly. Use VisNetHandler.drainVis() instead * @param aspect what aspect to drain * @param vis how much to drain * @return how much was actually drained */ - public int consumeVis(Aspect aspect, int vis) { - if (VisNetHandler.isNodeValid(getParent())) { - int out = getParent().get().consumeVis(aspect, vis); - if (out>0) { + public int consumeVis(Aspect aspect, int vis) + { + if(VisNetHandler.isNodeValid(getParent())) + { + final int out = getParent().get().consumeVis(aspect, vis); + if(out > 0) + { triggerConsumeEffect(aspect); } return out; } return 0; } - - public void removeThisNode() { - for (WeakReference n:getChildren()) { - if (n!=null && n.get()!=null) { + + public void removeThisNode() + { + for(final WeakReference n : getChildren()) + { + if(n != null && n.get() != null) + { n.get().removeThisNode(); } - } - + } + children = new ArrayList>(); - if (VisNetHandler.isNodeValid(this.getParent())) { - this.getParent().get().nodeRefresh=true; + if(VisNetHandler.isNodeValid(getParent())) + { + getParent().get().nodeRefresh = true; } - this.setParent(null); - this.parentChanged(); - - if (this.isSource()) { + setParent(null); + parentChanged(); + + if(isSource()) + { HashMap> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId); - if (sourcelist==null) { + if(sourcelist == null) + { sourcelist = new HashMap>(); } sourcelist.remove(getLocation()); - VisNetHandler.sources.put( worldObj.provider.dimensionId, sourcelist ); + VisNetHandler.sources.put(worldObj.provider.dimensionId, sourcelist); } - + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } - - @Override - public void invalidate() { + public void invalidate() + { removeThisNode(); super.invalidate(); } - public void triggerConsumeEffect(Aspect aspect) { } + public void triggerConsumeEffect(Aspect aspect) + { + } /** * @return */ - public WeakReference getParent() { + public WeakReference getParent() + { return parent; } - + /** * @return */ - public WeakReference getRootSource() { - return VisNetHandler.isNodeValid(getParent()) ? - getParent().get().getRootSource() : this.isSource() ? - new WeakReference(this) : null; + public WeakReference getRootSource() + { + return VisNetHandler.isNodeValid(getParent()) ? getParent().get().getRootSource() : isSource() ? new WeakReference( + this) : null; } - + /** * @param parent */ - public void setParent(WeakReference parent) { + public void setParent(WeakReference parent) + { this.parent = parent; } - + /** * @return */ - public ArrayList> getChildren() { + public ArrayList> getChildren() + { return children; } - + @Override - public boolean canUpdate() { + public boolean canUpdate() + { return true; } - - protected int nodeCounter = 0; - private boolean nodeRegged = false; - public boolean nodeRefresh = false; + + protected int nodeCounter = 0; + private boolean nodeRegged = false; + public boolean nodeRefresh = false; @Override - public void updateEntity() { - - if (!worldObj.isRemote && ((nodeCounter++) % 40==0 || nodeRefresh)) { + public void updateEntity() + { + + if(!worldObj.isRemote && ((nodeCounter++) % 40 == 0 || nodeRefresh)) + { //check for changes - if (!nodeRefresh && children.size()>0) { - for (WeakReference n:children) { - if (n==null || n.get()==null || !VisNetHandler.canNodeBeSeen(this, n.get())) { - nodeRefresh=true; + if(!nodeRefresh && children.size() > 0) + { + for(final WeakReference n : children) + { + if(n == null || n.get() == null || !VisNetHandler.canNodeBeSeen(this, n.get())) + { + nodeRefresh = true; break; } - } + } } - + //refresh linked nodes - if (nodeRefresh) { - for (WeakReference n:children) { - if (n.get()!=null) { - n.get().nodeRefresh=true; + if(nodeRefresh) + { + for(final WeakReference n : children) + { + if(n.get() != null) + { + n.get().nodeRefresh = true; } } children.clear(); - parent=null; + parent = null; } - + //redo stuff - if (isSource() && !nodeRegged) { + if(isSource() && !nodeRegged) + { VisNetHandler.addSource(getWorldObj(), this); nodeRegged = true; - } else - if (!isSource() && !VisNetHandler.isNodeValid(getParent())) { - setParent(VisNetHandler.addNode(getWorldObj(), this)); - nodeRefresh=true; } - - if (nodeRefresh) { + else if(!isSource() && !VisNetHandler.isNodeValid(getParent())) + { + setParent(VisNetHandler.addNode(getWorldObj(), this)); + nodeRefresh = true; + } + + if(nodeRefresh) + { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); parentChanged(); } - nodeRefresh=false; + nodeRefresh = false; } - + + } + + public void parentChanged() + { } - - public void parentChanged() { } - + /** * @return the type of shard this is attuned to: * none -1, air 0, fire 1, water 2, earth 3, order 4, entropy 5 * Should return -1 for most implementations */ - public byte getAttunement() { + public byte getAttunement() + { return -1; } - - + } diff --git a/src/api/java/thaumcraft/api/visnet/VisNetHandler.java b/src/api/java/thaumcraft/api/visnet/VisNetHandler.java index 7ac4c69..c8a4826 100644 --- a/src/api/java/thaumcraft/api/visnet/VisNetHandler.java +++ b/src/api/java/thaumcraft/api/visnet/VisNetHandler.java @@ -13,7 +13,8 @@ import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.WorldCoordinates; import thaumcraft.api.aspects.Aspect; -public class VisNetHandler { +public class VisNetHandler +{ // NODE DRAINING /** @@ -29,49 +30,61 @@ public class VisNetHandler { * @param amount how much to drain * @return how much was actually drained */ - public static int drainVis(World world, int x, int y, int z, Aspect aspect, int amount) { + public static int drainVis(World world, int x, int y, int z, Aspect aspect, int amount) + { int drainedAmount = 0; - WorldCoordinates drainer = new WorldCoordinates(x, y, z, + final WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId); - if (!nearbyNodes.containsKey(drainer)) { + if(!nearbyNodes.containsKey(drainer)) + { calculateNearbyNodes(world, x, y, z); } - ArrayList> nodes = nearbyNodes.get(drainer); - if (nodes!=null && nodes.size()>0) - for (WeakReference noderef : nodes) { - - TileVisNode node = noderef.get(); - - if (node == null) continue; - - int a = node.consumeVis(aspect, amount); - drainedAmount += a; - amount -= a; - if (a>0) { - int color = Aspect.getPrimalAspects().indexOf(aspect); - generateVisEffect(world.provider.dimensionId, x, y, z, node.xCoord, node.yCoord, node.zCoord, color); - } - if (amount <= 0) { - break; + final ArrayList> nodes = nearbyNodes.get(drainer); + if(nodes != null && nodes.size() > 0) + { + for(final WeakReference noderef : nodes) + { + + final TileVisNode node = noderef.get(); + + if(node == null) + { + continue; + } + + final int a = node.consumeVis(aspect, amount); + drainedAmount += a; + amount -= a; + if(a > 0) + { + final int color = Aspect.getPrimalAspects().indexOf(aspect); + generateVisEffect(world.provider.dimensionId, x, y, z, node.xCoord, node.yCoord, node.zCoord, color); + } + if(amount <= 0) + { + break; + } } } - + return drainedAmount; } - - public static void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) { + + public static void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) + { ThaumcraftApi.internalMethods.generateVisEffect(dim, x, y, z, x2, y2, z2, color); } - public static HashMap>> sources = new HashMap>>(); + public static HashMap>> sources = new HashMap>>(); - public static void addSource(World world, TileVisNode vs) { - HashMap> sourcelist = sources - .get(world.provider.dimensionId); - if (sourcelist == null) { + public static void addSource(World world, TileVisNode vs) + { + HashMap> sourcelist = sources.get(world.provider.dimensionId); + if(sourcelist == null) + { sourcelist = new HashMap>(); } sourcelist.put(vs.getLocation(), new WeakReference(vs)); @@ -79,54 +92,63 @@ public class VisNetHandler { nearbyNodes.clear(); } - public static boolean isNodeValid(WeakReference node) { - if (node == null || node.get() == null || node.get().isInvalid()) + public static boolean isNodeValid(WeakReference node) + { + if(node == null || node.get() == null || node.get().isInvalid()) + { return false; + } return true; } - public static WeakReference addNode(World world, TileVisNode vn) { - WeakReference ref = new WeakReference(vn); + public static WeakReference addNode(World world, TileVisNode vn) + { + final WeakReference ref = new WeakReference(vn); - HashMap> sourcelist = sources - .get(world.provider.dimensionId); - if (sourcelist == null) { + HashMap> sourcelist = sources.get(world.provider.dimensionId); + if(sourcelist == null) + { sourcelist = new HashMap>(); return null; } ArrayList nearby = new ArrayList(); - for (WeakReference root : sourcelist.values()) { - if (!isNodeValid(root)) + for(final WeakReference root : sourcelist.values()) + { + if(!isNodeValid(root)) + { continue; + } - TileVisNode source = root.get(); + final TileVisNode source = root.get(); - float r = inRange(world, vn.getLocation(), source.getLocation(), - vn.getRange()); - if (r > 0) { - nearby.add(new Object[] { source, r - vn.getRange() * 2 }); + final float r = inRange(world, vn.getLocation(), source.getLocation(), vn.getRange()); + if(r > 0) + { + nearby.add(new Object[] {source, r - vn.getRange() * 2}); } - + nearby = findClosestNodes(vn, source, nearby); cache.clear(); } float dist = Float.MAX_VALUE; TileVisNode closest = null; - if (nearby.size() > 0) { - for (Object[] o : nearby) { - if ((Float) o[1] < dist && - (vn.getAttunement() == -1 || ((TileVisNode) o[0]).getAttunement() == -1 || - vn.getAttunement() == ((TileVisNode) o[0]).getAttunement())//) { - && canNodeBeSeen(vn,(TileVisNode)o[0])) { + if(nearby.size() > 0) + { + for(final Object[] o : nearby) + { + if((Float) o[1] < dist && (vn.getAttunement() == -1 || ((TileVisNode) o[0]).getAttunement() == -1 || vn.getAttunement() == ((TileVisNode) o[0]).getAttunement())//) { + && canNodeBeSeen(vn, (TileVisNode) o[0])) + { dist = (Float) o[1]; - closest = (TileVisNode) o[0]; + closest = (TileVisNode) o[0]; } } } - if (closest != null) { + if(closest != null) + { closest.getChildren().add(ref); nearbyNodes.clear(); return new WeakReference(closest); @@ -135,121 +157,134 @@ public class VisNetHandler { return null; } - static ArrayList cache = new ArrayList(); - public static ArrayList findClosestNodes(TileVisNode target, - TileVisNode parent, ArrayList in) { - - if (cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) return in; + static ArrayList cache = new ArrayList(); + + public static ArrayList findClosestNodes(TileVisNode target, TileVisNode parent, ArrayList in) + { + + if(cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) + { + return in; + } cache.add(new WorldCoordinates(parent)); - - for (WeakReference childWR : parent.getChildren()) { - TileVisNode child = childWR.get(); - - if (child != null && !child.equals(target) && !child.equals(parent)) { - float r2 = inRange(child.getWorldObj(), child.getLocation(), - target.getLocation(), target.getRange()); - if (r2 > 0) { - in.add(new Object[] { child, r2 }); + + for(final WeakReference childWR : parent.getChildren()) + { + final TileVisNode child = childWR.get(); + + if(child != null && !child.equals(target) && !child.equals(parent)) + { + final float r2 = inRange(child.getWorldObj(), child.getLocation(), target.getLocation(), target.getRange()); + if(r2 > 0) + { + in.add(new Object[] {child, r2}); } - + in = findClosestNodes(target, child, in); } } return in; } - private static float inRange(World world, WorldCoordinates cc1, - WorldCoordinates cc2, int range) { - float distance = cc1.getDistanceSquaredToWorldCoordinates(cc2); + private static float inRange(World world, WorldCoordinates cc1, WorldCoordinates cc2, int range) + { + final float distance = cc1.getDistanceSquaredToWorldCoordinates(cc2); return distance > range * range ? -1 : distance; } - private static HashMap>> nearbyNodes = new HashMap>>(); + private static HashMap>> nearbyNodes = new HashMap>>(); - private static void calculateNearbyNodes(World world, int x, int y, int z) { + private static void calculateNearbyNodes(World world, int x, int y, int z) + { - HashMap> sourcelist = sources - .get(world.provider.dimensionId); - if (sourcelist == null) { + HashMap> sourcelist = sources.get(world.provider.dimensionId); + if(sourcelist == null) + { sourcelist = new HashMap>(); return; } - ArrayList> cn = new ArrayList>(); - WorldCoordinates drainer = new WorldCoordinates(x, y, z, + final ArrayList> cn = new ArrayList>(); + final WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId); - ArrayList nearby = new ArrayList(); + new ArrayList(); - for (WeakReference root : sourcelist.values()) { - - if (!isNodeValid(root)) + for(final WeakReference root : sourcelist.values()) + { + + if(!isNodeValid(root)) + { continue; + } + + final TileVisNode source = root.get(); - TileVisNode source = root.get(); - TileVisNode closest = null; float range = Float.MAX_VALUE; - float r = inRange(world, drainer, source.getLocation(), - source.getRange()); - if (r > 0) { + final float r = inRange(world, drainer, source.getLocation(), source.getRange()); + if(r > 0) + { range = r; closest = source; } - + ArrayList> children = new ArrayList>(); - children = getAllChildren(source,children); - - for (WeakReference child : children) { - TileVisNode n = child.get(); - if (n != null && !n.equals(root)) { - - float r2 = inRange(n.getWorldObj(), n.getLocation(), - drainer, n.getRange()); - if (r2 > 0 && r2 < range) { + children = getAllChildren(source, children); + + for(final WeakReference child : children) + { + final TileVisNode n = child.get(); + if(n != null && !n.equals(root)) + { + + final float r2 = inRange(n.getWorldObj(), n.getLocation(), drainer, n.getRange()); + if(r2 > 0 && r2 < range) + { range = r2; closest = n; } } } - if (closest != null) { - + if(closest != null) + { + cn.add(new WeakReference(closest)); } } nearbyNodes.put(drainer, cn); } - - private static ArrayList> getAllChildren(TileVisNode source, ArrayList> list) { - for (WeakReference child : source.getChildren()) { - TileVisNode n = child.get(); - - if (n != null && n.getWorldObj()!=null && isChunkLoaded(n.getWorldObj(), n.xCoord, n.zCoord)) { + + private static ArrayList> getAllChildren(TileVisNode source, ArrayList> list) + { + for(final WeakReference child : source.getChildren()) + { + final TileVisNode n = child.get(); + + if(n != null && n.getWorldObj() != null && isChunkLoaded(n.getWorldObj(), n.xCoord, n.zCoord)) + { list.add(child); - list = getAllChildren(n,list); + list = getAllChildren(n, list); } } return list; } - - public static boolean isChunkLoaded(World world, int x, int z) { - int xx = x >> 4; - int zz = z >> 4; - return world.getChunkProvider().chunkExists(xx, zz); + + public static boolean isChunkLoaded(World world, int x, int z) + { + final int xx = x >> 4; + final int zz = z >> 4; + return world.getChunkProvider().chunkExists(xx, zz); } - public static boolean canNodeBeSeen(TileVisNode source,TileVisNode target) - { - MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(source.getWorldObj(), - Vec3.createVectorHelper(source.xCoord+.5, source.yCoord+.5,source.zCoord+.5), - Vec3.createVectorHelper(target.xCoord+.5, target.yCoord+.5,target.zCoord+.5), - false, true, false); - return mop == null || (mop.typeOfHit==MovingObjectType.BLOCK && - mop.blockX==target.xCoord && mop.blockY==target.yCoord && mop.blockZ==target.zCoord); - } + public static boolean canNodeBeSeen(TileVisNode source, TileVisNode target) + { + final MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(source.getWorldObj(), Vec3.createVectorHelper(source.xCoord + .5, source.yCoord + .5, source.zCoord + .5), Vec3.createVectorHelper(target.xCoord + .5, target.yCoord + .5, target.zCoord + .5), false, true, false); + return mop == null || (mop.typeOfHit == MovingObjectType.BLOCK && mop.blockX == target.xCoord && mop.blockY == target.yCoord && mop.blockZ == target.zCoord); + } // public static HashMap> // noderef = new HashMap>(); diff --git a/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java b/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java index 5c4269e..32ee1ef 100644 --- a/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java +++ b/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java @@ -8,107 +8,152 @@ import org.apache.logging.log4j.LogManager; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class FocusUpgradeType { - - public static FocusUpgradeType[] types = new FocusUpgradeType[20]; - - public short id; - - public ResourceLocation icon; - - public String name; - - public String text; - +public class FocusUpgradeType +{ + + public static FocusUpgradeType[] types = new FocusUpgradeType[20]; + + public short id; + + public ResourceLocation icon; + + public String name; + + public String text; + /** * What aspects are used to calculate the cost of this upgrade. The amounts given is ignored, just the type is used for the calculation. */ - public AspectList aspects; - - + public AspectList aspects; - public FocusUpgradeType(int id, ResourceLocation icon, String name, String text, AspectList aspects) { - this.id = (short) id; + public FocusUpgradeType(int id, ResourceLocation icon, String name, String text, AspectList aspects) + { + this.id = (short) id; this.icon = icon; this.name = name; this.text = text; this.aspects = aspects; - - if (id=types.length) { - FocusUpgradeType[] temp = new FocusUpgradeType[id+1]; + if(id >= types.length) + { + final FocusUpgradeType[] temp = new FocusUpgradeType[id + 1]; System.arraycopy(types, 0, temp, 0, types.length); types = temp; } - + types[id] = this; - } - - public String getLocalizedName() { + } + + public String getLocalizedName() + { return StatCollector.translateToLocal(name); } - - public String getLocalizedText() { + + public String getLocalizedText() + { return StatCollector.translateToLocal(text); } - + @Override - public boolean equals(Object obj) { - if (obj instanceof FocusUpgradeType) { - return this.id == ((FocusUpgradeType)obj).id; - } else return false; + public boolean equals(Object obj) + { + if(obj instanceof FocusUpgradeType) + { + return id == ((FocusUpgradeType) obj).id; + } + else + { + return false; + } } // basic upgrade types - public static FocusUpgradeType potency = new FocusUpgradeType( 0, - new ResourceLocation("thaumcraft", "textures/foci/potency.png"), - "focus.upgrade.potency.name","focus.upgrade.potency.text", - new AspectList().add(Aspect.WEAPON,1)); - - public static FocusUpgradeType frugal = new FocusUpgradeType( 1, - new ResourceLocation("thaumcraft", "textures/foci/frugal.png"), - "focus.upgrade.frugal.name","focus.upgrade.frugal.text", - new AspectList().add(Aspect.HUNGER,1)); - - public static FocusUpgradeType treasure = new FocusUpgradeType( 2, - new ResourceLocation("thaumcraft", "textures/foci/treasure.png"), - "focus.upgrade.treasure.name","focus.upgrade.treasure.text", - new AspectList().add(Aspect.GREED,1)); - - public static FocusUpgradeType enlarge = new FocusUpgradeType( 3, - new ResourceLocation("thaumcraft", "textures/foci/enlarge.png"), - "focus.upgrade.enlarge.name","focus.upgrade.enlarge.text", - new AspectList().add(Aspect.TRAVEL,1)); - - public static FocusUpgradeType alchemistsfire = new FocusUpgradeType( 4, - new ResourceLocation("thaumcraft", "textures/foci/alchemistsfire.png"), - "focus.upgrade.alchemistsfire.name","focus.upgrade.alchemistsfire.text", - new AspectList().add(Aspect.ENERGY,1).add(Aspect.SLIME,1)); - - public static FocusUpgradeType alchemistsfrost = new FocusUpgradeType( 5, - new ResourceLocation("thaumcraft", "textures/foci/alchemistsfrost.png"), - "focus.upgrade.alchemistsfrost.name","focus.upgrade.alchemistsfrost.text", - new AspectList().add(Aspect.COLD,1).add(Aspect.TRAP,1)); - - public static FocusUpgradeType architect = new FocusUpgradeType( 6, - new ResourceLocation("thaumcraft", "textures/foci/architect.png"), - "focus.upgrade.architect.name","focus.upgrade.architect.text", - new AspectList().add(Aspect.CRAFT,1)); - - public static FocusUpgradeType extend = new FocusUpgradeType( 7, - new ResourceLocation("thaumcraft", "textures/foci/extend.png"), - "focus.upgrade.extend.name","focus.upgrade.extend.text", - new AspectList().add(Aspect.EXCHANGE,1)); - - public static FocusUpgradeType silktouch = new FocusUpgradeType( 8, - new ResourceLocation("thaumcraft", "textures/foci/silktouch.png"), - "focus.upgrade.silktouch.name","focus.upgrade.silktouch.text", - new AspectList().add(Aspect.GREED,1)); - - + public static FocusUpgradeType potency = new FocusUpgradeType( + 0, + new ResourceLocation( + "thaumcraft", + "textures/foci/potency.png"), + "focus.upgrade.potency.name", + "focus.upgrade.potency.text", + new AspectList().add(Aspect.WEAPON, 1)); + + public static FocusUpgradeType frugal = new FocusUpgradeType( + 1, + new ResourceLocation( + "thaumcraft", + "textures/foci/frugal.png"), + "focus.upgrade.frugal.name", + "focus.upgrade.frugal.text", + new AspectList().add(Aspect.HUNGER, 1)); + + public static FocusUpgradeType treasure = new FocusUpgradeType( + 2, + new ResourceLocation( + "thaumcraft", + "textures/foci/treasure.png"), + "focus.upgrade.treasure.name", + "focus.upgrade.treasure.text", + new AspectList().add(Aspect.GREED, 1)); + + public static FocusUpgradeType enlarge = new FocusUpgradeType( + 3, + new ResourceLocation( + "thaumcraft", + "textures/foci/enlarge.png"), + "focus.upgrade.enlarge.name", + "focus.upgrade.enlarge.text", + new AspectList().add(Aspect.TRAVEL, 1)); + + public static FocusUpgradeType alchemistsfire = new FocusUpgradeType( + 4, + new ResourceLocation( + "thaumcraft", + "textures/foci/alchemistsfire.png"), + "focus.upgrade.alchemistsfire.name", + "focus.upgrade.alchemistsfire.text", + new AspectList().add(Aspect.ENERGY, 1).add(Aspect.SLIME, 1)); + + public static FocusUpgradeType alchemistsfrost = new FocusUpgradeType( + 5, + new ResourceLocation( + "thaumcraft", + "textures/foci/alchemistsfrost.png"), + "focus.upgrade.alchemistsfrost.name", + "focus.upgrade.alchemistsfrost.text", + new AspectList().add(Aspect.COLD, 1).add(Aspect.TRAP, 1)); + + public static FocusUpgradeType architect = new FocusUpgradeType( + 6, + new ResourceLocation( + "thaumcraft", + "textures/foci/architect.png"), + "focus.upgrade.architect.name", + "focus.upgrade.architect.text", + new AspectList().add(Aspect.CRAFT, 1)); + + public static FocusUpgradeType extend = new FocusUpgradeType( + 7, + new ResourceLocation( + "thaumcraft", + "textures/foci/extend.png"), + "focus.upgrade.extend.name", + "focus.upgrade.extend.text", + new AspectList().add(Aspect.EXCHANGE, 1)); + + public static FocusUpgradeType silktouch = new FocusUpgradeType( + 8, + new ResourceLocation( + "thaumcraft", + "textures/foci/silktouch.png"), + "focus.upgrade.silktouch.name", + "focus.upgrade.silktouch.text", + new AspectList().add(Aspect.GREED, 1)); + } diff --git a/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java b/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java index 4ef8c84..dbceaa5 100644 --- a/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java +++ b/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack; * update tick. * */ -public interface IWandRodOnUpdate { +public interface IWandRodOnUpdate +{ void onUpdate(ItemStack itemstack, EntityPlayer player); } diff --git a/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java b/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java index 7c299de..ae47992 100644 --- a/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java +++ b/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java @@ -4,12 +4,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IWandTriggerManager { +public interface IWandTriggerManager +{ /** * This class will be called by wands with the proper parameters. It is up to you to decide what to do with them. */ - public boolean performTrigger(World world, ItemStack wand, EntityPlayer player, - int x, int y, int z, int side, int event); - + public boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, int event); + } diff --git a/src/api/java/thaumcraft/api/wands/IWandable.java b/src/api/java/thaumcraft/api/wands/IWandable.java index aeb9bac..7cc0362 100644 --- a/src/api/java/thaumcraft/api/wands/IWandable.java +++ b/src/api/java/thaumcraft/api/wands/IWandable.java @@ -12,14 +12,15 @@ import net.minecraft.world.World; * */ -public interface IWandable { +public interface IWandable +{ public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, int md); - + public ItemStack onWandRightClick(World world, ItemStack wandstack, EntityPlayer player); - + public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count); - + public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count); - + } diff --git a/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java b/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java index e8938e9..70d0dba 100644 --- a/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java +++ b/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java @@ -21,256 +21,294 @@ import thaumcraft.api.aspects.AspectList; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemFocusBasic extends Item { - - public ItemFocusBasic () - { - super(); - maxStackSize = 1; - canRepair=false; - this.setMaxDamage(0); - } - - public IIcon icon; - +public class ItemFocusBasic extends Item +{ + + public ItemFocusBasic() + { + super(); + maxStackSize = 1; + canRepair = false; + setMaxDamage(0); + } + + public IIcon icon; + @SideOnly(Side.CLIENT) @Override - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int par1) + { return icon; } - + @Override - public boolean isDamageable() { + public boolean isDamageable() + { return false; } @Override - public void addInformation(ItemStack stack,EntityPlayer player, List list, boolean par4) { - AspectList al = this.getVisCost(stack); - if (al!=null && al.size()>0) { - list.add(StatCollector.translateToLocal(isVisCostPerTick(stack)?"item.Focus.cost2":"item.Focus.cost1")); - for (Aspect aspect:al.getAspectsSorted()) { - DecimalFormat myFormatter = new DecimalFormat("#####.##"); - String amount = myFormatter.format(al.getAmount(aspect)/100f); - list.add(" \u00A7"+aspect.getChatcolor()+aspect.getName()+"\u00A7r x "+ amount); + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + final AspectList al = getVisCost(stack); + if(al != null && al.size() > 0) + { + list.add(StatCollector.translateToLocal(isVisCostPerTick(stack) ? "item.Focus.cost2" : "item.Focus.cost1")); + for(final Aspect aspect : al.getAspectsSorted()) + { + final DecimalFormat myFormatter = new DecimalFormat("#####.##"); + final String amount = myFormatter.format(al.getAmount(aspect) / 100f); + list.add(" \u00A7" + aspect.getChatcolor() + aspect.getName() + "\u00A7r x " + amount); } } - addFocusInformation(stack,player,list,par4); + addFocusInformation(stack, player, list, par4); } - - public void addFocusInformation(ItemStack focusstack,EntityPlayer player, List list, boolean par4) { - LinkedHashMap map = new LinkedHashMap(); - for (short id:this.getAppliedUpgrades(focusstack)) { - if (id>=0) { + + public void addFocusInformation(ItemStack focusstack, EntityPlayer player, List list, boolean par4) + { + final LinkedHashMap map = new LinkedHashMap(); + for(final short id : getAppliedUpgrades(focusstack)) + { + if(id >= 0) + { int amt = 1; - if (map.containsKey(id)) { - amt = map.get(id) + 1; + if(map.containsKey(id)) + { + amt = map.get(id) + 1; } map.put(id, amt); } } - for (Short id:map.keySet()) { - list.add(EnumChatFormatting.DARK_PURPLE +FocusUpgradeType.types[id].getLocalizedName()+ - (map.get(id)>1?" "+StatCollector.translateToLocal("enchantment.level." + map.get(id)):"")); + for(final Short id : map.keySet()) + { + list.add(EnumChatFormatting.DARK_PURPLE + FocusUpgradeType.types[id].getLocalizedName() + (map.get(id) > 1 ? " " + StatCollector.translateToLocal("enchantment.level." + map.get(id)) : "")); } } - + /** * Purely for display on the focus tooltip (see addInformation method above) */ - public boolean isVisCostPerTick(ItemStack focusstack) { + public boolean isVisCostPerTick(ItemStack focusstack) + { return false; } - + @Override public EnumRarity getRarity(ItemStack focusstack) - { - return EnumRarity.rare; - } - + { + return EnumRarity.rare; + } + /** * What color will the focus orb be rendered on the held wand */ - public int getFocusColor(ItemStack focusstack) { + public int getFocusColor(ItemStack focusstack) + { return 0; } - /** * Does the focus have ornamentation like the focus of the nine hells. Ornamentation is a standard icon rendered in a cross around the focus - */ - public IIcon getOrnament(ItemStack focusstack) { + */ + public IIcon getOrnament(ItemStack focusstack) + { // TODO Auto-generated method stub return null; } - + /** * An icon to be rendered inside the focus itself */ - public IIcon getFocusDepthLayerIcon(ItemStack focusstack) { + public IIcon getFocusDepthLayerIcon(ItemStack focusstack) + { // TODO Auto-generated method stub return null; } - - public enum WandFocusAnimation { + + public enum WandFocusAnimation + { WAVE, CHARGE; } - public WandFocusAnimation getAnimation(ItemStack focusstack) { + public WandFocusAnimation getAnimation(ItemStack focusstack) + { return WandFocusAnimation.WAVE; } - + /** * Just insert two alphanumeric characters before this string in your focus item class */ - public String getSortingHelper(ItemStack focusstack) { - String out=""; - for (short id:this.getAppliedUpgrades(focusstack)) { + public String getSortingHelper(ItemStack focusstack) + { + String out = ""; + for(final short id : getAppliedUpgrades(focusstack)) + { out = out + id; } return out; } - - + /** * How much vis does this focus consume per activation. */ - public AspectList getVisCost(ItemStack focusstack) { + public AspectList getVisCost(ItemStack focusstack) + { return null; } - + /** * This returns how many milliseconds must pass before the focus can be activated again. - */ - public int getActivationCooldown(ItemStack focusstack) { + */ + public int getActivationCooldown(ItemStack focusstack) + { return 0; - } - + } + /** * Used by foci like equal trade to determine their area in artchitect mode */ - public int getMaxAreaSize(ItemStack focusstack) { + public int getMaxAreaSize(ItemStack focusstack) + { return 1; } - + /** * What upgrades can be applied to this focus for ranks 1 to 5 */ - public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) { + public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) + { return null; } - + /** * What upgrades does the focus currently have */ - public short[] getAppliedUpgrades(ItemStack focusstack) { - short[] l = new short[] {-1,-1,-1,-1,-1}; - NBTTagList nbttaglist = getFocusUpgradeTagList(focusstack); - if (nbttaglist == null) - { - return l; - } - else - { - for (int j = 0; j < nbttaglist.tagCount(); ++j) - { - if (j>=5) break; - l[j] = nbttaglist.getCompoundTagAt(j).getShort("id"); - } - - return l; - } + public short[] getAppliedUpgrades(ItemStack focusstack) + { + final short[] l = new short[] {-1, -1, -1, -1, -1}; + final NBTTagList nbttaglist = getFocusUpgradeTagList(focusstack); + if(nbttaglist == null) + { + return l; + } + else + { + for(int j = 0; j < nbttaglist.tagCount(); ++j) + { + if(j >= 5) + { + break; + } + l[j] = nbttaglist.getCompoundTagAt(j).getShort("id"); + } + + return l; + } } - - public boolean applyUpgrade(ItemStack focusstack, FocusUpgradeType type, int rank) { - short[] upgrades = getAppliedUpgrades(focusstack); - if (upgrades[rank-1]!=-1 || rank<1 || rank>5) { + + public boolean applyUpgrade(ItemStack focusstack, FocusUpgradeType type, int rank) + { + final short[] upgrades = getAppliedUpgrades(focusstack); + if(upgrades[rank - 1] != -1 || rank < 1 || rank > 5) + { return false; } - upgrades[rank-1] = type.id; + upgrades[rank - 1] = type.id; setFocusUpgradeTagList(focusstack, upgrades); return true; } - + /** * Use this method to define custom logic about which upgrades can be applied. This can be used to set up upgrade "trees" * that make certain upgrades available only when others are unlocked first, when certain research is completed, or similar logic. * */ - public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) { + public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) + { return true; } /** * Does this focus have the passed upgrade type */ - public boolean isUpgradedWith(ItemStack focusstack, FocusUpgradeType focusUpgradetype) { - return getUpgradeLevel(focusstack,focusUpgradetype)>0; + public boolean isUpgradedWith(ItemStack focusstack, FocusUpgradeType focusUpgradetype) + { + return getUpgradeLevel(focusstack, focusUpgradetype) > 0; } /** * What level is the passed upgrade type on the focus. If it is not present it returns 0 */ - public int getUpgradeLevel(ItemStack focusstack, FocusUpgradeType focusUpgradetype) { - short[] list = getAppliedUpgrades(focusstack); - int level=0; - for (short id:list) { - if (id == focusUpgradetype.id) - { - level++; - } + public int getUpgradeLevel(ItemStack focusstack, FocusUpgradeType focusUpgradetype) + { + final short[] list = getAppliedUpgrades(focusstack); + int level = 0; + for(final short id : list) + { + if(id == focusUpgradetype.id) + { + level++; + } } - return level; - } - - public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) { + return level; + } + + public ItemStack onFocusRightClick(ItemStack wandstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) + { // TODO Auto-generated method stub return null; } - - public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player,int count) { + + public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player, int count) + { // TODO Auto-generated method stub } - - public void onPlayerStoppedUsingFocus(ItemStack wandstack, World world, EntityPlayer player, int count) { + + public void onPlayerStoppedUsingFocus(ItemStack wandstack, World world, EntityPlayer player, int count) + { // TODO Auto-generated method stub - + } - - public boolean onFocusBlockStartBreak(ItemStack wandstack, int x, int y,int z, EntityPlayer player) { + + public boolean onFocusBlockStartBreak(ItemStack wandstack, int x, int y, int z, EntityPlayer player) + { // TODO Auto-generated method stub return false; } - + /** * Internal helper methods */ private NBTTagList getFocusUpgradeTagList(ItemStack focusstack) - { - return focusstack.stackTagCompound == null ? null : focusstack.stackTagCompound.getTagList("upgrade", 10); - } - - private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) { - if (!focusstack.hasTagCompound()) + { + return focusstack.stackTagCompound == null ? null : focusstack.stackTagCompound.getTagList("upgrade", 10); + } + + private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) + { + if(!focusstack.hasTagCompound()) + { focusstack.setTagCompound(new NBTTagCompound()); - NBTTagCompound nbttagcompound = focusstack.getTagCompound(); - NBTTagList tlist = new NBTTagList(); + } + final NBTTagCompound nbttagcompound = focusstack.getTagCompound(); + final NBTTagList tlist = new NBTTagList(); nbttagcompound.setTag("upgrade", tlist); - for (short id : upgrades) { - NBTTagCompound f = new NBTTagCompound(); + for(final short id : upgrades) + { + final NBTTagCompound f = new NBTTagCompound(); f.setShort("id", id); tlist.appendTag(f); } } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { - if (stack.stackTagCompound !=null && stack.stackTagCompound.hasKey("ench")) { + public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) + { + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("ench")) + { stack.stackTagCompound.removeTag("ench"); } super.onUpdate(stack, world, entity, p_77663_4_, p_77663_5_); } - - } diff --git a/src/api/java/thaumcraft/api/wands/StaffRod.java b/src/api/java/thaumcraft/api/wands/StaffRod.java index e7ae90f..1dc474c 100644 --- a/src/api/java/thaumcraft/api/wands/StaffRod.java +++ b/src/api/java/thaumcraft/api/wands/StaffRod.java @@ -11,38 +11,43 @@ import net.minecraft.util.ResourceLocation; * It is also used to generate the wand recipes ingame. * */ -public class StaffRod extends WandRod { - - boolean runes=false; +public class StaffRod extends WandRod +{ - public StaffRod(String tag, int capacity, ItemStack item, int craftCost) { - super(tag+"_staff", capacity, item, craftCost); - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+tag+".png"); + boolean runes = false; + + public StaffRod(String tag, int capacity, ItemStack item, int craftCost) + { + super(tag + "_staff", capacity, item, craftCost); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + tag + ".png"); } - public StaffRod(String tag, int capacity, ItemStack item, int craftCost, - IWandRodOnUpdate onUpdate, ResourceLocation texture) { - super(tag+"_staff", capacity, item, craftCost, onUpdate, texture); + public StaffRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) + { + super(tag + "_staff", capacity, item, craftCost, onUpdate, texture); } - public StaffRod(String tag, int capacity, ItemStack item, int craftCost, - IWandRodOnUpdate onUpdate) { - super(tag+"_staff", capacity, item, craftCost, onUpdate); - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+tag+".png"); + public StaffRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) + { + super(tag + "_staff", capacity, item, craftCost, onUpdate); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + tag + ".png"); } - public StaffRod(String tag, int capacity, ItemStack item, int craftCost, - ResourceLocation texture) { - super(tag+"_staff", capacity, item, craftCost, texture); + public StaffRod(String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) + { + super(tag + "_staff", capacity, item, craftCost, texture); } - public boolean hasRunes() { + public boolean hasRunes() + { return runes; } - public void setRunes(boolean hasRunes) { - this.runes = hasRunes; + public void setRunes(boolean hasRunes) + { + runes = hasRunes; } - } diff --git a/src/api/java/thaumcraft/api/wands/WandCap.java b/src/api/java/thaumcraft/api/wands/WandCap.java index 17b4581..e5726ef 100644 --- a/src/api/java/thaumcraft/api/wands/WandCap.java +++ b/src/api/java/thaumcraft/api/wands/WandCap.java @@ -13,117 +13,133 @@ import thaumcraft.api.aspects.Aspect; * @author Azanor * */ -public class WandCap { +public class WandCap +{ + + private String tag; - private String tag; - /** * Cost to craft this wand. Combined with the rod cost. */ - private int craftCost; - + private int craftCost; + /** * the amount by which all aspect costs are multiplied */ - float baseCostModifier; - + float baseCostModifier; + /** * specifies a list of primal aspects that use the special discount figure instead of the normal discount. */ - List specialCostModifierAspects; - + List specialCostModifierAspects; + /** * the amount by which the specified aspect costs are multiplied */ - float specialCostModifier; - + float specialCostModifier; + /** * The texture that will be used for the ingame wand cap */ - ResourceLocation texture; - + ResourceLocation texture; + /** * the actual item that makes up this cap and will be used to generate the wand recipes */ - ItemStack item; - - public static LinkedHashMap caps = new LinkedHashMap(); - - public WandCap (String tag, float discount, ItemStack item, int craftCost) { - this.setTag(tag); - this.baseCostModifier = discount; - this.specialCostModifierAspects = null; - texture = new ResourceLocation("thaumcraft","textures/models/wand_cap_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + ItemStack item; + + public static LinkedHashMap caps = new LinkedHashMap(); + + public WandCap(String tag, float discount, ItemStack item, int craftCost) + { + setTag(tag); + baseCostModifier = discount; + specialCostModifierAspects = null; + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_cap_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); caps.put(tag, this); } - - public WandCap (String tag, float discount, List specialAspects, float discountSpecial, ItemStack item, int craftCost) { - this.setTag(tag); - this.baseCostModifier = discount; - this.specialCostModifierAspects = specialAspects; - this.specialCostModifier = discountSpecial; - texture = new ResourceLocation("thaumcraft","textures/models/wand_cap_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + + public WandCap(String tag, float discount, List specialAspects, float discountSpecial, ItemStack item, int craftCost) + { + setTag(tag); + baseCostModifier = discount; + specialCostModifierAspects = specialAspects; + specialCostModifier = discountSpecial; + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_cap_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); caps.put(tag, this); } - - public float getBaseCostModifier() { + + public float getBaseCostModifier() + { return baseCostModifier; } - public List getSpecialCostModifierAspects() { + public List getSpecialCostModifierAspects() + { return specialCostModifierAspects; } - public float getSpecialCostModifier() { + public float getSpecialCostModifier() + { return specialCostModifier; } - public ResourceLocation getTexture() { + public ResourceLocation getTexture() + { return texture; } - public void setTexture(ResourceLocation texture) { + public void setTexture(ResourceLocation texture) + { this.texture = texture; } - public String getTag() { + public String getTag() + { return tag; } - public void setTag(String tag) { + public void setTag(String tag) + { this.tag = tag; } - - public ItemStack getItem() { + public ItemStack getItem() + { return item; } - public void setItem(ItemStack item) { + public void setItem(ItemStack item) + { this.item = item; } - public int getCraftCost() { + public int getCraftCost() + { return craftCost; } - public void setCraftCost(int craftCost) { + public void setCraftCost(int craftCost) + { this.craftCost = craftCost; } - + /** * The research a player needs to have finished to be able to craft a wand with this cap. */ - public String getResearch() { - return "CAP_"+getTag(); + public String getResearch() + { + return "CAP_" + getTag(); } - + // Some examples: // WandCap WAND_CAP_IRON = new WandCap("iron", 1.1f, Arrays.asList(Aspect.ORDER),1, new ItemStack(ConfigItems.itemWandCap,1,0),1); // WandCap WAND_CAP_GOLD = new WandCap("gold", 1f, new ItemStack(ConfigItems.itemWandCap,1,1),3); - + } diff --git a/src/api/java/thaumcraft/api/wands/WandRod.java b/src/api/java/thaumcraft/api/wands/WandRod.java index 85954e4..9b6907d 100644 --- a/src/api/java/thaumcraft/api/wands/WandRod.java +++ b/src/api/java/thaumcraft/api/wands/WandRod.java @@ -13,143 +13,164 @@ import net.minecraft.util.ResourceLocation; * It is also used to generate the wand recipes ingame. * */ -public class WandRod { +public class WandRod +{ + + private String tag; - - private String tag; - /** * Cost to craft this wand. Combined with the rod cost. */ - private int craftCost; - + private int craftCost; + /** * The amount of vis that can be stored - this number is actually multiplied * by 100 for use by the wands internals */ - int capacity; + int capacity; /** * The texture that will be used for the ingame wand rod */ - protected ResourceLocation texture; - + protected ResourceLocation texture; + /** * the actual item that makes up this rod and will be used to generate the wand recipes */ - ItemStack item; - + ItemStack item; + /** * A class that will be called whenever the wand onUpdate tick is run */ - IWandRodOnUpdate onUpdate; - + IWandRodOnUpdate onUpdate; + /** * Does the rod glow in the dark? */ - boolean glow; + boolean glow; + + public static LinkedHashMap rods = new LinkedHashMap(); - public static LinkedHashMap rods = new LinkedHashMap(); - - public WandRod (String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) { - this.setTag(tag); + public WandRod(String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) + { + setTag(tag); this.capacity = capacity; this.texture = texture; - this.item=item; - this.setCraftCost(craftCost); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); } - - public WandRod (String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) { - this.setTag(tag); + + public WandRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) + { + setTag(tag); this.capacity = capacity; this.texture = texture; - this.item=item; - this.setCraftCost(craftCost); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); this.onUpdate = onUpdate; } - public WandRod (String tag, int capacity, ItemStack item, int craftCost) { - this.setTag(tag); + public WandRod(String tag, int capacity, ItemStack item, int craftCost) + { + setTag(tag); this.capacity = capacity; - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); } - - public WandRod (String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) { - this.setTag(tag); + + public WandRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) + { + setTag(tag); this.capacity = capacity; - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); this.onUpdate = onUpdate; } - - public String getTag() { + + public String getTag() + { return tag; } - - public void setTag(String tag) { + + public void setTag(String tag) + { this.tag = tag; } - public int getCapacity() { + public int getCapacity() + { return capacity; } - public void setCapacity(int capacity) { + public void setCapacity(int capacity) + { this.capacity = capacity; } - public ResourceLocation getTexture() { + public ResourceLocation getTexture() + { return texture; } - public void setTexture(ResourceLocation texture) { + public void setTexture(ResourceLocation texture) + { this.texture = texture; } - public ItemStack getItem() { + public ItemStack getItem() + { return item; } - public void setItem(ItemStack item) { + public void setItem(ItemStack item) + { this.item = item; } - - public int getCraftCost() { + + public int getCraftCost() + { return craftCost; } - public void setCraftCost(int craftCost) { + public void setCraftCost(int craftCost) + { this.craftCost = craftCost; } - public IWandRodOnUpdate getOnUpdate() { + public IWandRodOnUpdate getOnUpdate() + { return onUpdate; } - public void setOnUpdate(IWandRodOnUpdate onUpdate) { + public void setOnUpdate(IWandRodOnUpdate onUpdate) + { this.onUpdate = onUpdate; } - public boolean isGlowing() { + public boolean isGlowing() + { return glow; } - public void setGlowing(boolean hasGlow) { - this.glow = hasGlow; + public void setGlowing(boolean hasGlow) + { + glow = hasGlow; } - + /** * The research a player needs to have finished to be able to craft a wand with this rod. */ - public String getResearch() { - return "ROD_"+getTag(); + public String getResearch() + { + return "ROD_" + getTag(); } // Some examples: diff --git a/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java b/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java index 7224e12..c9c24f2 100644 --- a/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java +++ b/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java @@ -19,10 +19,11 @@ import net.minecraft.world.World; * @author azanor * */ -public class WandTriggerRegistry { - - private static HashMap> triggers = new HashMap>(); - private static final String DEFAULT = "default"; +public class WandTriggerRegistry +{ + + private static HashMap> triggers = new HashMap>(); + private static final String DEFAULT = "default"; /** * Registers an action to perform when a casting wand right clicks on a specific block. @@ -33,49 +34,61 @@ public class WandTriggerRegistry { * @param meta send -1 as a wildcard value for all possible meta values * @param modid a unique identifier. It is best to register your own triggers using your mod id to avoid conflicts with mods that register triggers for the same block */ - public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta, String modid) { - if (!triggers.containsKey(modid)) { - triggers.put(modid, new HashMap()); + public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta, String modid) + { + if(!triggers.containsKey(modid)) + { + triggers.put(modid, new HashMap()); } - HashMap temp = triggers.get(modid); - temp.put(Arrays.asList(block,meta),Arrays.asList(manager,event)); + final HashMap temp = triggers.get(modid); + temp.put(Arrays.asList(block, meta), Arrays.asList(manager, event)); triggers.put(modid, temp); } - + /** * for legacy support */ - public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta) { + public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta) + { registerWandBlockTrigger(manager, event, block, meta, DEFAULT); } - + /** * Checks all trigger registries if one exists for the given block and meta * @param block * @param meta * @return */ - public static boolean hasTrigger(Block block, int meta) { - for (String modid:triggers.keySet()) { - HashMap temp = triggers.get(modid); - if (temp.containsKey(Arrays.asList(block,meta)) || - temp.containsKey(Arrays.asList(block,-1))) return true; + public static boolean hasTrigger(Block block, int meta) + { + for(final String modid : triggers.keySet()) + { + final HashMap temp = triggers.get(modid); + if(temp.containsKey(Arrays.asList(block, meta)) || temp.containsKey(Arrays.asList(block, -1))) + { + return true; + } } return false; } - + /** * modid sensitive version */ - public static boolean hasTrigger(Block block, int meta, String modid) { - if (!triggers.containsKey(modid)) return false; - HashMap temp = triggers.get(modid); - if (temp.containsKey(Arrays.asList(block,meta)) || - temp.containsKey(Arrays.asList(block,-1))) return true; + public static boolean hasTrigger(Block block, int meta, String modid) + { + if(!triggers.containsKey(modid)) + { + return false; + } + final HashMap temp = triggers.get(modid); + if(temp.containsKey(Arrays.asList(block, meta)) || temp.containsKey(Arrays.asList(block, -1))) + { + return true; + } return false; } - - + /** * This is called by the onItemUseFirst function in wands. * Parameters and return value functions like you would expect for that function. @@ -90,37 +103,56 @@ public class WandTriggerRegistry { * @param meta * @return */ - public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, - int x, int y, int z, int side, Block block, int meta) { - - for (String modid:triggers.keySet()) { - HashMap temp = triggers.get(modid); - List l = temp.get(Arrays.asList(block,meta)); - if (l==null) l = temp.get(Arrays.asList(block,-1)); - if (l==null) continue; - - IWandTriggerManager manager = (IWandTriggerManager) l.get(0); - int event = (Integer) l.get(1); - boolean result = manager.performTrigger(world, wand, player, x, y, z, side, event); - if (result) return true; + public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, Block block, int meta) + { + + for(final String modid : triggers.keySet()) + { + final HashMap temp = triggers.get(modid); + List l = temp.get(Arrays.asList(block, meta)); + if(l == null) + { + l = temp.get(Arrays.asList(block, -1)); + } + if(l == null) + { + continue; + } + + final IWandTriggerManager manager = (IWandTriggerManager) l.get(0); + final int event = (Integer) l.get(1); + final boolean result = manager.performTrigger(world, wand, player, x, y, z, side, event); + if(result) + { + return true; + } } return false; } - + /** * modid sensitive version */ - public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, - int x, int y, int z, int side, Block block, int meta, String modid) { - if (!triggers.containsKey(modid)) return false; - HashMap temp = triggers.get(modid); - List l = temp.get(Arrays.asList(block,meta)); - if (l==null) l = temp.get(Arrays.asList(block,-1)); - if (l==null) return false; - - IWandTriggerManager manager = (IWandTriggerManager) l.get(0); - int event = (Integer) l.get(1); + public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, Block block, int meta, String modid) + { + if(!triggers.containsKey(modid)) + { + return false; + } + final HashMap temp = triggers.get(modid); + List l = temp.get(Arrays.asList(block, meta)); + if(l == null) + { + l = temp.get(Arrays.asList(block, -1)); + } + if(l == null) + { + return false; + } + + final IWandTriggerManager manager = (IWandTriggerManager) l.get(0); + final int event = (Integer) l.get(1); return manager.performTrigger(world, wand, player, x, y, z, side, event); } - + } -- cgit v1.2.3