();
+
+ /**
+ * 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));
+ index++;
+ } while (index<16 && tmp==null);
+ }
+ 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) {}
+ }
+
+
+ /**
+ * 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));
+ * @param item
+ * @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);
+ }
+
+ } catch (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) {}
+ }
+ }
+ }
+
+ /**
+ * Used to assign aspects to the given item/block.
+ * Attempts to automatically generate aspect tags by checking registered recipes.
+ * Here is an example of the declaration for pistons:
+ * ThaumcraftApi.registerComplexObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.MECHANISM, 2).add(Aspect.MOTION, 4));
+ * IMPORTANT - this should only be used if you are not happy with the default aspects the object would be assigned.
+ * @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()) {
+ aspects.add(tag, tmp.getAmount(tag));
+ }
+ }
+ registerObjectTag(item,aspects);
+ } else {
+ AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item);
+ for(Aspect tag:aspects.getAspects()) {
+ tmp.merge(tag, tmp.getAmount(tag));
+ }
+ 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);
+ }
+
+ /**
+ * 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;
+ 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;
+ }
+
+ //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;
+ }
+ }
+ }
+ }
+
+ //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.
+ *
+ * Standard crops work like normal vanilla crops - they grow until a certain metadata
+ * value is reached and you harvest them by destroying the block and collecting the blocks.
+ * You need to create and ItemStack that tells the golem what block id and metadata represents
+ * the crop when fully grown. Sending a metadata of [OreDictionary.WILDCARD_VALUE] will mean the metadata won't get
+ * checked.
+ * Example for vanilla wheat:
+ * FMLInterModComms.sendMessage("Thaumcraft", "harvestStandardCrop", new ItemStack(Block.crops,1,7));
+ *
+ * Clickable crops are crops that you right click to gather their bounty instead of destroying them.
+ * As for standard crops, you need to create and ItemStack that tells the golem what block id
+ * and metadata represents the crop when fully grown. The golem will trigger the blocks onBlockActivated method.
+ * Sending a metadata of [OreDictionary.WILDCARD_VALUE] will mean the metadata won't get checked.
+ * Example (this will technically do nothing since clicking wheat does nothing, but you get the idea):
+ * FMLInterModComms.sendMessage("Thaumcraft", "harvestClickableCrop", new ItemStack(Block.crops,1,7));
+ *
+ * Stacked crops (like reeds) are crops that you wish the bottom block should remain after harvesting.
+ * As for standard crops, you need to create and ItemStack that tells the golem what block id
+ * and metadata represents the crop when fully grown. Sending a metadata of [OreDictionary.WILDCARD_VALUE] will mean the actualy md won't get
+ * checked. If it has the order upgrade it will only harvest if the crop is more than one block high.
+ * 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.
+ * The format should be:
+ * "[ore item/block id],[ore item/block metadata],[cluster item/block id],[cluster item/block metadata],[chance modifier float]"
+ *
+ * NOTE: The chance modifier is a multiplier applied to the default chance for that cluster to be produced (default 27.5% for a pickaxe of the core)
+ *
+ * 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
+ * in your @Mod.Init method using the "lampBlacklist" itemstack message.
+ * Sending a metadata of [OreDictionary.WILDCARD_VALUE] will mean the metadata won't get checked.
+ * 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
+ * in your @Mod.Init method using the "dimensionBlacklist" string message in the format "[dimension]:[level]"
+ * The level values are as follows:
+ * [0] stop all tc spawning and generation
+ * [1] allow ore and node generation (and node special features)
+ * [2] allow mob spawning
+ * [3] allow ore and node gen + mob spawning (and node special features)
+ * Example:
+ * FMLInterModComms.sendMessage("Thaumcraft", "dimensionBlacklist", "15:1");
+ */
+
+ //BIOME BLACKLIST ///////////////////////////////////////////////////////////////////////////
+ /**
+ * You can blacklist a biome to not spawn certain thaumcraft features
+ * in your @Mod.Init method using the "biomeBlacklist" string message in the format "[biome id]:[level]"
+ * The level values are as follows:
+ * [0] stop all tc spawning and generation
+ * [1] allow ore and node generation (and node special features)
+ * [2] allow mob spawning
+ * [3] allow ore and node gen + mob spawning (and node special features)
+ * 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
+ * the "championWhiteList" string message in the format "[Entity]:[level]"
+ * The entity must extend EntityMob.
+ * [Entity] is in a similar format to what is used for mob spawners and such (see EntityList.class for vanilla examples).
+ * The [level] value indicate how rare the champion version will be - the higher the number the more common.
+ * The number roughly equals the [n] in 100 chance of a mob being a champion version.
+ * You can give 0 or negative numbers to allow champions to spawn with a very low chance only in particularly dangerous places.
+ * However anything less than about -2 will probably result in no spawns at all.
+ * Example:
+ * FMLInterModComms.sendMessage("Thaumcraft", "championWhiteList", "Thaumcraft.Wisp:1");
+ */
+}
diff --git a/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java b/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java
new file mode 100644
index 00000000..77d55885
--- /dev/null
+++ b/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java
@@ -0,0 +1,467 @@
+package thaumcraft.api;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.oredict.OreDictionary;
+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)
+ temp2.add(tag, temp.getAmount(tag));
+ }
+ 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()) {
+ ta *= .9f;
+ } else {
+ if (!tag.getComponents()[0].isPrimal()) {
+ ta *= 1.1f;
+ if (!tag.getComponents()[0].getComponents()[0].isPrimal()) {
+ ta *= 1.05f;
+ }
+ if (!tag.getComponents()[0].getComponents()[1].isPrimal()) {
+ ta *= 1.05f;
+ }
+ }
+ if (!tag.getComponents()[1].isPrimal()) {
+ ta *= 1.1f;
+ if (!tag.getComponents()[1].getComponents()[0].isPrimal()) {
+ ta *= 1.05f;
+ }
+ 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);
+ }
+
+
+ /**
+ * 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
+ * @param wand the wand itemstack
+ * @param player the player using the wand
+ * @param cost the cost of the operation.
+ * @param doit actually subtract the vis from the wand if true - if false just simulate the result
+ * @param crafting is this a crafting operation or not - if
+ * 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) {
+ 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
+ * Must NOT be multiplied by 100 - send the actual vis cost
+ * @param wand the wand itemstack
+ * @param player the player using the wand
+ * @param cost the cost of the operation.
+ * @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) {
+ 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
+ * frugal don't effect them
+ * @param player the player using the wand
+ * @param cost the cost of the operation.
+ * @return was the vis successfully subtracted
+ */
+ 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) {
+ 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) {
+ ThaumcraftApi.internalMethods.addStickyWarpToPlayer(player, amount);
+ }
+
+ 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;
+ }
+ }
+}
diff --git a/src/api/java/thaumcraft/api/TileThaumcraft.java b/src/api/java/thaumcraft/api/TileThaumcraft.java
new file mode 100644
index 00000000..56ccae87
--- /dev/null
+++ b/src/api/java/thaumcraft/api/TileThaumcraft.java
@@ -0,0 +1,63 @@
+package thaumcraft.api;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ *
+ * @author azanor
+ *
+ * Custom tile entity class I use for most of my tile entities. Setup in such a way that only
+ * the nbt data within readCustomNBT / writeCustomNBT will be sent to the client when the tile
+ * updates. Apart from all the normal TE data that gets sent that is.
+ *
+ */
+public class TileThaumcraft extends TileEntity {
+
+ //NBT stuff
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ readCustomNBT(nbttagcompound);
+ }
+
+ public void readCustomNBT(NBTTagCompound nbttagcompound)
+ {
+ //TODO
+ }
+
+ @Override
+ 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);
+ }
+
+ @Override
+ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
+ super.onDataPacket(net, pkt);
+ this.readCustomNBT(pkt.func_148857_g());
+ }
+
+
+
+
+}
diff --git a/src/api/java/thaumcraft/api/WorldCoordinates.java b/src/api/java/thaumcraft/api/WorldCoordinates.java
new file mode 100644
index 00000000..6c620af5
--- /dev/null
+++ b/src/api/java/thaumcraft/api/WorldCoordinates.java
@@ -0,0 +1,117 @@
+package thaumcraft.api;
+
+import net.minecraft.nbt.NBTTagCompound;
+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);
+ }
+
+}
diff --git a/src/api/java/thaumcraft/api/aspects/AspectList.java b/src/api/java/thaumcraft/api/aspects/AspectList.java
new file mode 100644
index 00000000..b5781410
--- /dev/null
+++ b/src/api/java/thaumcraft/api/aspects/AspectList.java
@@ -0,0 +1,292 @@
+package thaumcraft.api.aspects;
+
+import java.io.Serializable;
+import java.util.LinkedHashMap;
+
+import net.minecraft.item.ItemStack;
+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
+
+
+ /**
+ * 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));
+ }
+ } catch (Exception e) {}
+ }
+
+ public AspectList() {
+ }
+
+ public AspectList copy() {
+ AspectList out = new AspectList();
+ for (Aspect a:this.getAspects())
+ out.add(a, this.getAmount(a));
+ return out;
+ }
+
+ /**
+ * @return the amount of different aspects in this collection
+ */
+ public int size() {
+ return aspects.size();
+ }
+
+ /**
+ * @return the amount of total vis in this collection
+ */
+ public int visSize() {
+ int q = 0;
+
+ for (Aspect as:aspects.keySet()) {
+ q+=this.getAmount(as);
+ }
+
+ return q;
+ }
+
+ /**
+ * @return an array of all the aspects in this collection
+ */
+ public Aspect[] getAspects() {
+ 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);
+ }
+ }
+ 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) {
+ out[a] = e2;
+ out[a+1] = e1;
+ change = true;
+ break;
+ }
+ }
+ } while (change==true);
+ return out;
+ } catch (Exception e) {
+ return this.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];
+ out[a] = eb;
+ out[a+1] = ea;
+ change = true;
+ break;
+ }
+ }
+ } while (change==true);
+ return out;
+ } catch (Exception e) {
+ return this.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);
+ }
+
+ /**
+ * 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;
+ 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.
+ * @param key
+ * @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);
+ return this;
+ }
+
+ /**
+ * Simply removes the aspect from the list
+ * @param key
+ * @param amount
+ * @return
+ */
+ 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.
+ * @param aspect
+ * @param amount
+ * @return
+ */
+ public AspectList add(Aspect aspect, int amount) {
+ if (this.aspects.containsKey(aspect)) {
+ int oldamount = this.aspects.get(aspect);
+ amount+=oldamount;
+ }
+ this.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.
+ * @param aspect
+ * @param amount
+ * @return
+ */
+ public AspectList merge(Aspect aspect, int amount) {
+ if (this.aspects.containsKey(aspect)) {
+ int oldamount = this.aspects.get(aspect);
+ if (amount0?aspects:null;
+ }
+ return null;
+ }
+
+ @Override
+ public void setAspects(ItemStack itemstack, AspectList aspects) {
+ if (!itemstack.hasTagCompound()) itemstack.setTagCompound(new NBTTagCompound());
+ aspects.writeToNBT(itemstack.getTagCompound());
+ }
+*/
\ No newline at end of file
diff --git a/src/api/java/thaumcraft/api/aspects/IEssentiaTransport.java b/src/api/java/thaumcraft/api/aspects/IEssentiaTransport.java
new file mode 100644
index 00000000..fecbc160
--- /dev/null
+++ b/src/api/java/thaumcraft/api/aspects/IEssentiaTransport.java
@@ -0,0 +1,100 @@
+package thaumcraft.api.aspects;
+
+import net.minecraftforge.common.util.ForgeDirection;
+
+
+/**
+ * @author Azanor
+ * This interface is used by tiles that use or transport vis.
+ * Only tiles that implement this interface will be able to connect to vis conduits or other thaumic devices
+ */
+public interface IEssentiaTransport {
+ /**
+ * Is this tile able to connect to other vis users/sources on the specified side?
+ * @param face
+ * @return
+ */
+ public boolean isConnectable(ForgeDirection face);
+
+ /**
+ * Is this side used to input essentia?
+ * @param face
+ * @return
+ */
+ boolean canInputFrom(ForgeDirection face);
+
+ /**
+ * Is this side used to output essentia?
+ * @param face
+ * @return
+ */
+ boolean canOutputTo(ForgeDirection face);
+
+ /**
+ * Sets the amount of suction this block will apply
+ * @param suction
+ */
+ public void setSuction(Aspect aspect, int amount);
+
+ /**
+ * Returns the type of suction this block is applying.
+ * @param loc
+ * the location from where the suction is being checked
+ * @return
+ * a return type of null indicates the suction is untyped and the first thing available will be drawn
+ */
+ public Aspect getSuctionType(ForgeDirection face);
+
+ /**
+ * Returns the strength of suction this block is applying.
+ * @param loc
+ * the location from where the suction is being checked
+ * @return
+ */
+ public int getSuctionAmount(ForgeDirection face);
+
+ /**
+ * remove the specified amount of essentia from this transport tile
+ * @return how much was actually taken
+ */
+ public int takeEssentia(Aspect aspect, int amount, ForgeDirection face);
+
+ /**
+ * add the specified amount of essentia to this transport tile
+ * @return how much was actually added
+ */
+ public int addEssentia(Aspect aspect, int amount, ForgeDirection face);
+
+ /**
+ * What type of essentia this contains
+ * @param face
+ * @return
+ */
+ public Aspect getEssentiaType(ForgeDirection face);
+
+ /**
+ * How much essentia this block contains
+ * @param face
+ * @return
+ */
+ public int getEssentiaAmount(ForgeDirection face);
+
+
+
+ /**
+ * Essentia will not be drawn from this container unless the suction exceeds this amount.
+ * @return the amount
+ */
+ public int getMinimumSuction();
+
+ /**
+ * Return true if you want the conduit to extend a little further into the block.
+ * Used by jars and alembics that have smaller than normal hitboxes
+ * @return
+ */
+ boolean renderExtendedTube();
+
+
+
+}
+
diff --git a/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java b/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java
new file mode 100644
index 00000000..595b6e53
--- /dev/null
+++ b/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java
@@ -0,0 +1,91 @@
+package thaumcraft.api.crafting;
+
+import java.util.ArrayList;
+
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+import thaumcraft.api.ThaumcraftApiHelper;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+
+public class CrucibleRecipe {
+
+ private ItemStack recipeOutput;
+
+ public Object catalyst;
+ public AspectList aspects;
+ public String key;
+
+ public int hash;
+
+ public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
+ recipeOutput = result;
+ this.aspects = tags;
+ this.key = researchKey;
+ this.catalyst = cat;
+ if (cat instanceof String) {
+ this.catalyst = OreDictionary.getOres((String) cat);
+ }
+ String hc = researchKey + result.toString();
+ for (Aspect tag:tags.getAspects()) {
+ hc += tag.getTag()+tags.getAmount(tag);
+ }
+ if (cat instanceof ItemStack) {
+ hc += ((ItemStack)cat).toString();
+ } else
+ if (cat instanceof ArrayList && ((ArrayList)catalyst).size()>0) {
+ for (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)) {
+ 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) {
+ 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();
+ temptags.aspects.putAll(itags.aspects);
+
+ for (Aspect tag:aspects.getAspects()) {
+ temptags.remove(tag, aspects.getAmount(tag));
+ }
+
+ itags = temptags;
+ return itags;
+ }
+
+ 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
new file mode 100644
index 00000000..bb5036d2
--- /dev/null
+++ b/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java
@@ -0,0 +1,35 @@
+package thaumcraft.api.crafting;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+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();
+
+
+}
diff --git a/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java b/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java
new file mode 100644
index 00000000..bdc5f505
--- /dev/null
+++ b/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java
@@ -0,0 +1,154 @@
+package thaumcraft.api.crafting;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import net.minecraftforge.oredict.OreDictionary;
+import thaumcraft.api.ThaumcraftApiHelper;
+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) {
+ this.research = research;
+ this.enchantment = input;
+ this.aspects = aspects2;
+ this.components = recipe;
+ this.instability = inst;
+ this.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)) {
+ 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;
+ }
+ }
+
+ ItemStack i2 = null;
+
+ ArrayList ii = new ArrayList();
+ for (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;
+ }
+
+ ItemStack i2 = central.copy();
+ 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) {
+ 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() {
+ return aspects;
+ }
+
+ @Override
+ public AspectList getAspects(IInventory inv) {
+ return aspects;
+ }
+
+ @Override
+ 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
new file mode 100644
index 00000000..3b1eaeb8
--- /dev/null
+++ b/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java
@@ -0,0 +1,161 @@
+package thaumcraft.api.crafting;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import net.minecraftforge.oredict.OreDictionary;
+import thaumcraft.api.ThaumcraftApiHelper;
+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() {
+ return aspects;
+ }
+
+ @Override
+ public AspectList getAspects(IInventory inv) {
+ return aspects;
+ }
+
+ @Override
+ 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
new file mode 100644
index 00000000..1562d052
--- /dev/null
+++ b/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java
@@ -0,0 +1,32 @@
+package thaumcraft.api.damagesource;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.EntityDamageSourceIndirect;
+
+public class DamageSourceIndirectThaumcraftEntity extends EntityDamageSourceIndirect {
+
+ private boolean fireDamage;
+ private float hungerDamage;
+ private boolean isUnblockable;
+
+
+ public DamageSourceIndirectThaumcraftEntity(String par1Str,
+ Entity par2Entity, Entity par3Entity) {
+ super(par1Str, par2Entity, par3Entity);
+ }
+
+
+ public DamageSource setFireDamage()
+ {
+ this.fireDamage = true;
+ return this;
+ }
+
+ public DamageSource setDamageBypassesArmor()
+ {
+ this.isUnblockable = true;
+ this.hungerDamage = 0.0F;
+ return this;
+ }
+}
diff --git a/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java b/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java
new file mode 100644
index 00000000..bb55672b
--- /dev/null
+++ b/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java
@@ -0,0 +1,47 @@
+package thaumcraft.api.damagesource;
+
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.util.DamageSource;
+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) {
+ 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;
+
+ /**
+ * 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);
+ }
+
+}
diff --git a/src/api/java/thaumcraft/api/entities/IEldritchMob.java b/src/api/java/thaumcraft/api/entities/IEldritchMob.java
new file mode 100644
index 00000000..79fc75b5
--- /dev/null
+++ b/src/api/java/thaumcraft/api/entities/IEldritchMob.java
@@ -0,0 +1,5 @@
+package thaumcraft.api.entities;
+
+public interface IEldritchMob {
+
+}
diff --git a/src/api/java/thaumcraft/api/entities/ITaintedMob.java b/src/api/java/thaumcraft/api/entities/ITaintedMob.java
new file mode 100644
index 00000000..83fb1fcb
--- /dev/null
+++ b/src/api/java/thaumcraft/api/entities/ITaintedMob.java
@@ -0,0 +1,5 @@
+package thaumcraft.api.entities;
+
+public interface ITaintedMob {
+
+}
diff --git a/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java b/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java
new file mode 100644
index 00000000..9af8c30e
--- /dev/null
+++ b/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java
@@ -0,0 +1,78 @@
+package thaumcraft.api.internal;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+
+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) {
+
+ }
+
+ @Override
+ public boolean isResearchComplete(String username, String researchkey) {
+ return false;
+ }
+
+ @Override
+ public boolean hasDiscoveredAspect(String username, Aspect aspect) {
+ return false;
+ }
+
+ @Override
+ public AspectList getDiscoveredAspects(String username) {
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInRowAndColumn(Object instance, int row, int column) {
+ return null;
+ }
+
+ @Override
+ public AspectList getObjectAspects(ItemStack is) {
+ return null;
+ }
+
+ @Override
+ public AspectList getBonusObjectTags(ItemStack is, AspectList ot) {
+ return null;
+ }
+
+ @Override
+ public AspectList generateTags(Item item, int meta) {
+ return null;
+ }
+
+ @Override
+ 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) {
+ return false;
+ }
+
+ @Override
+ public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) {
+ return false;
+ }
+
+ @Override
+ public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) {
+ }
+
+ @Override
+ 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
new file mode 100644
index 00000000..73fce669
--- /dev/null
+++ b/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java
@@ -0,0 +1,25 @@
+package thaumcraft.api.internal;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+
+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 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 consumeVisFromInventory(EntityPlayer player, AspectList cost);
+ 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
new file mode 100644
index 00000000..4ac6ee7d
--- /dev/null
+++ b/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java
@@ -0,0 +1,24 @@
+package thaumcraft.api.internal;
+
+import java.util.ArrayList;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.WeightedRandom;
+
+
+public class WeightedRandomLoot extends WeightedRandom.Item {
+
+ /** The Item/Block ID to generate in the bag. */
+ public ItemStack item;
+
+ 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
new file mode 100644
index 00000000..61da1f77
--- /dev/null
+++ b/src/api/java/thaumcraft/api/nodes/INode.java
@@ -0,0 +1,53 @@
+package thaumcraft.api.nodes;
+
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.aspects.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
+ */
+ public NodeType getNodeType();
+
+ /**
+ * Set the type of node
+ * @return
+ */
+ public void setNodeType(NodeType nodeType);
+
+ /**
+ * Set the node modifier
+ * @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
+ */
+ public int getNodeVisBase(Aspect aspect);
+
+ /**
+ * Set the maximum capacity of each aspect the node can hold
+ * @return
+ */
+ public void setNodeVisBase(Aspect aspect, short nodeVisBase);
+
+}
diff --git a/src/api/java/thaumcraft/api/nodes/NodeModifier.java b/src/api/java/thaumcraft/api/nodes/NodeModifier.java
new file mode 100644
index 00000000..885b8678
--- /dev/null
+++ b/src/api/java/thaumcraft/api/nodes/NodeModifier.java
@@ -0,0 +1,6 @@
+package thaumcraft.api.nodes;
+
+public enum NodeModifier
+{
+ BRIGHT, PALE, FADING
+}
\ No newline at end of file
diff --git a/src/api/java/thaumcraft/api/nodes/NodeType.java b/src/api/java/thaumcraft/api/nodes/NodeType.java
new file mode 100644
index 00000000..355324b5
--- /dev/null
+++ b/src/api/java/thaumcraft/api/nodes/NodeType.java
@@ -0,0 +1,6 @@
+package thaumcraft.api.nodes;
+
+public enum NodeType
+{
+ NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE
+}
\ No newline at end of file
diff --git a/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java b/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java
new file mode 100644
index 00000000..b950de0e
--- /dev/null
+++ b/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java
@@ -0,0 +1,67 @@
+package thaumcraft.api.potions;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.potion.Potion;
+import net.minecraft.util.ResourceLocation;
+import thaumcraft.api.damagesource.DamageSourceThaumcraft;
+import thaumcraft.api.entities.ITaintedMob;
+import cpw.mods.fml.relauncher.Side;
+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);
+ }
+
+ @Override
+ public boolean isBadEffect() {
+ return true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getStatusIconIndex() {
+ Minecraft.getMinecraft().renderEngine.bindTexture(rl);
+ return super.getStatusIconIndex();
+ }
+
+ static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png");
+
+ @Override
+ public void performEffect(EntityLivingBase target, int par2) {
+ if (target instanceof ITaintedMob) {
+ target.heal(1);
+ } else
+ if (!target.isEntityUndead() && !(target instanceof EntityPlayer))
+ {
+ target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
+ }
+ else
+ if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer)))
+ {
+ target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
+ }
+ }
+
+ public boolean isReady(int par1, int par2)
+ {
+ 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
new file mode 100644
index 00000000..cd7fc18c
--- /dev/null
+++ b/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java
@@ -0,0 +1,48 @@
+package thaumcraft.api.potions;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.potion.Potion;
+import net.minecraft.util.ResourceLocation;
+import cpw.mods.fml.relauncher.Side;
+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);
+ }
+
+ @Override
+ public boolean isBadEffect() {
+ return true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getStatusIconIndex() {
+ Minecraft.getMinecraft().renderEngine.bindTexture(rl);
+ return super.getStatusIconIndex();
+ }
+
+ static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png");
+
+ @Override
+ 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
new file mode 100644
index 00000000..d0efac5f
--- /dev/null
+++ b/src/api/java/thaumcraft/api/research/IScanEventHandler.java
@@ -0,0 +1,9 @@
+package thaumcraft.api.research;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+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
new file mode 100644
index 00000000..82309b36
--- /dev/null
+++ b/src/api/java/thaumcraft/api/research/ResearchCategories.java
@@ -0,0 +1,101 @@
+package thaumcraft.api.research;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import org.apache.logging.log4j.Level;
+
+import cpw.mods.fml.common.FMLLog;
+
+public class ResearchCategories {
+
+ //Research
+ public static LinkedHashMap researchCategories = new LinkedHashMap ();
+
+ /**
+ * @param key
+ * @return the research item linked to this 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);
+ }
+
+ /**
+ * @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;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This should only be done at the PostInit stage
+ * @param key the key used for this category
+ * @param icon the icon to be used for the research category tab
+ * @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);
+ 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()+"]");
+ 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;
+ }
+ }
+ }
+}
diff --git a/src/api/java/thaumcraft/api/research/ResearchCategoryList.java b/src/api/java/thaumcraft/api/research/ResearchCategoryList.java
new file mode 100644
index 00000000..7eed0101
--- /dev/null
+++ b/src/api/java/thaumcraft/api/research/ResearchCategoryList.java
@@ -0,0 +1,37 @@
+package thaumcraft.api.research;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.util.ResourceLocation;
+
+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) {
+ this.icon = icon;
+ this.background = background;
+ }
+
+ //Research
+ 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
new file mode 100644
index 00000000..1d5fd8bf
--- /dev/null
+++ b/src/api/java/thaumcraft/api/research/ResearchItem.java
@@ -0,0 +1,369 @@
+package thaumcraft.api.research;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+
+public class ResearchItem
+{
+ /**
+ * A short string used as a key for this research. Must be unique
+ */
+ 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;
+
+ /**
+ * 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;
+
+ /**
+ * 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;
+ }
+
+
+
+ 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() {
+ 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() {
+ return itemTriggers;
+ }
+
+ public String[] getEntityTriggers() {
+ return entityTriggers;
+ }
+
+ 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() {
+ return isAutoUnlock;
+ }
+
+ public ResearchItem setAutoUnlock()
+ {
+ this.isAutoUnlock = true;
+ return this;
+ }
+
+ public boolean isRound() {
+ return isRound;
+ }
+
+ public ResearchItem setRound() {
+ this.isRound = true;
+ return this;
+ }
+
+ public boolean isSecondary() {
+ return isSecondary;
+ }
+
+ public ResearchItem setSecondary() {
+ this.isSecondary = true;
+ return this;
+ }
+
+ public int getComplexity() {
+ return complexity;
+ }
+
+ public ResearchItem setComplexity(int complexity) {
+ this.complexity = complexity;
+ return this;
+ }
+
+ /**
+ * @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);
+ };
+ }
+ return aspect;
+ }
+
+}
diff --git a/src/api/java/thaumcraft/api/research/ResearchPage.java b/src/api/java/thaumcraft/api/research/ResearchPage.java
new file mode 100644
index 00000000..fdada843
--- /dev/null
+++ b/src/api/java/thaumcraft/api/research/ResearchPage.java
@@ -0,0 +1,193 @@
+package thaumcraft.api.research;
+
+import java.util.List;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.FurnaceRecipes;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.crafting.CrucibleRecipe;
+import thaumcraft.api.crafting.IArcaneRecipe;
+import thaumcraft.api.crafting.InfusionEnchantmentRecipe;
+import thaumcraft.api.crafting.InfusionRecipe;
+
+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;
+
+ /**
+ * @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;
+ 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;
+ this.research = research;
+ this.text = text;
+ }
+
+ /**
+ * @param recipe a vanilla crafting recipe.
+ */
+ public ResearchPage(IRecipe recipe) {
+ this.type = PageType.NORMAL_CRAFTING;
+ this.recipe = recipe;
+ this.recipeOutput = recipe.getRecipeOutput();
+ }
+
+ /**
+ * @param recipe a collection of vanilla crafting recipes.
+ */
+ public ResearchPage(IRecipe[] recipe) {
+ this.type = PageType.NORMAL_CRAFTING;
+ this.recipe = recipe;
+ }
+
+ /**
+ * @param recipe a collection of arcane crafting recipes.
+ */
+ public ResearchPage(IArcaneRecipe[] recipe) {
+ this.type = PageType.ARCANE_CRAFTING;
+ this.recipe = recipe;
+ }
+
+ /**
+ * @param recipe a collection of arcane crafting recipes.
+ */
+ public ResearchPage(CrucibleRecipe[] recipe) {
+ this.type = PageType.CRUCIBLE_CRAFTING;
+ this.recipe = recipe;
+ }
+
+ /**
+ * @param recipe a collection of infusion crafting recipes.
+ */
+ public ResearchPage(InfusionRecipe[] recipe) {
+ this.type = PageType.INFUSION_CRAFTING;
+ this.recipe = recipe;
+ }
+
+ /**
+ * @param recipe a compound crafting recipe.
+ */
+ public ResearchPage(List recipe) {
+ this.type = PageType.COMPOUND_CRAFTING;
+ this.recipe = recipe;
+ }
+
+ /**
+ * @param recipe an arcane worktable crafting recipe.
+ */
+ public ResearchPage(IArcaneRecipe recipe) {
+ this.type = PageType.ARCANE_CRAFTING;
+ this.recipe = recipe;
+ this.recipeOutput = recipe.getRecipeOutput();
+ }
+
+ /**
+ * @param recipe an alchemy crafting recipe.
+ */
+ public ResearchPage(CrucibleRecipe recipe) {
+ this.type = PageType.CRUCIBLE_CRAFTING;
+ this.recipe = recipe;
+ this.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);
+ }
+
+ /**
+ * @param recipe an infusion crafting recipe.
+ */
+ public ResearchPage(InfusionRecipe recipe) {
+ this.type = PageType.INFUSION_CRAFTING;
+ this.recipe = recipe;
+ if (recipe.getRecipeOutput() instanceof ItemStack) {
+ this.recipeOutput = (ItemStack) recipe.getRecipeOutput();
+ } else {
+ this.recipeOutput = recipe.getRecipeInput();
+ }
+ }
+
+ /**
+ * @param recipe an infusion crafting recipe.
+ */
+ public ResearchPage(InfusionEnchantmentRecipe recipe) {
+ this.type = PageType.INFUSION_ENCHANTMENT;
+ this.recipe = recipe;
+// 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;
+ this.image = image;
+ this.text = caption;
+ }
+
+ /**
+ * This function should really not be called directly - used internally
+ */
+ public ResearchPage(AspectList as) {
+ this.type = PageType.ASPECTS;
+ this.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) {
+ ret = StatCollector.translateToLocal(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
new file mode 100644
index 00000000..e1498f31
--- /dev/null
+++ b/src/api/java/thaumcraft/api/research/ScanResult.java
@@ -0,0 +1,39 @@
+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 ScanResult(byte type, int blockId, int blockMeta, Entity entity,
+ String phenomena) {
+ super();
+ this.type = type;
+ this.id = blockId;
+ this.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)
+ return false;
+ if (type == 1
+ && (id != sr.id || meta != sr.meta))
+ return false;
+ if (type == 2 && entity.getEntityId() != sr.entity.getEntityId())
+ return false;
+ 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
new file mode 100644
index 00000000..204879e6
--- /dev/null
+++ b/src/api/java/thaumcraft/api/visnet/TileVisNode.java
@@ -0,0 +1,188 @@
+package thaumcraft.api.visnet;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import thaumcraft.api.TileThaumcraft;
+import thaumcraft.api.WorldCoordinates;
+import thaumcraft.api.aspects.Aspect;
+
+/**
+ * @author Azanor
+ *
+ * The tile entity used by nodes in the vis energy network. A node is either a source (like an aura node),
+ * a transport relay or vis receiver (like the infernal furnace).
+ *
+ */
+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() {
+ 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) {
+ triggerConsumeEffect(aspect);
+ }
+ return out;
+ }
+ return 0;
+ }
+
+ public void removeThisNode() {
+ for (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;
+ }
+ this.setParent(null);
+ this.parentChanged();
+
+ if (this.isSource()) {
+ HashMap> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId);
+ if (sourcelist==null) {
+ sourcelist = new HashMap>();
+ }
+ sourcelist.remove(getLocation());
+ VisNetHandler.sources.put( worldObj.provider.dimensionId, sourcelist );
+ }
+
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ }
+
+
+
+ @Override
+ public void invalidate() {
+ removeThisNode();
+ super.invalidate();
+ }
+
+ public void triggerConsumeEffect(Aspect aspect) { }
+
+ /**
+ * @return
+ */
+ public WeakReference getParent() {
+ return parent;
+ }
+
+ /**
+ * @return
+ */
+ public WeakReference getRootSource() {
+ return VisNetHandler.isNodeValid(getParent()) ?
+ getParent().get().getRootSource() : this.isSource() ?
+ new WeakReference(this) : null;
+ }
+
+ /**
+ * @param parent
+ */
+ public void setParent(WeakReference parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * @return
+ */
+ public ArrayList> getChildren() {
+ return children;
+ }
+
+ @Override
+ public boolean canUpdate() {
+ return true;
+ }
+
+ protected int nodeCounter = 0;
+ private boolean nodeRegged = false;
+ public boolean nodeRefresh = false;
+
+ @Override
+ 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;
+ break;
+ }
+ }
+ }
+
+ //refresh linked nodes
+ if (nodeRefresh) {
+ for (WeakReference n:children) {
+ if (n.get()!=null) {
+ n.get().nodeRefresh=true;
+ }
+ }
+ children.clear();
+ parent=null;
+ }
+
+ //redo stuff
+ if (isSource() && !nodeRegged) {
+ VisNetHandler.addSource(getWorldObj(), this);
+ nodeRegged = true;
+ } else
+ if (!isSource() && !VisNetHandler.isNodeValid(getParent())) {
+ setParent(VisNetHandler.addNode(getWorldObj(), this));
+ nodeRefresh=true;
+ }
+
+ if (nodeRefresh) {
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ parentChanged();
+ }
+ nodeRefresh=false;
+ }
+
+ }
+
+ 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() {
+ return -1;
+ }
+
+
+}
diff --git a/src/api/java/thaumcraft/api/visnet/VisNetHandler.java b/src/api/java/thaumcraft/api/visnet/VisNetHandler.java
new file mode 100644
index 00000000..7ac4c699
--- /dev/null
+++ b/src/api/java/thaumcraft/api/visnet/VisNetHandler.java
@@ -0,0 +1,282 @@
+package thaumcraft.api.visnet;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.MovingObjectPosition.MovingObjectType;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.World;
+import thaumcraft.api.ThaumcraftApi;
+import thaumcraft.api.ThaumcraftApiHelper;
+import thaumcraft.api.WorldCoordinates;
+import thaumcraft.api.aspects.Aspect;
+
+public class VisNetHandler {
+
+ // NODE DRAINING
+ /**
+ * This method drains vis from a relay or source near the passed in
+ * location. The amount received can be less than the amount requested so
+ * take that into account.
+ *
+ * @param world
+ * @param x the x position of the draining block or entity
+ * @param y the y position of the draining block or entity
+ * @param z the z position of the draining block or entity
+ * @param aspect what aspect to drain
+ * @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) {
+
+ int drainedAmount = 0;
+
+ WorldCoordinates drainer = new WorldCoordinates(x, y, z,
+ world.provider.dimensionId);
+ 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;
+ }
+ }
+
+ return drainedAmount;
+ }
+
+ 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 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));
+ sources.put(world.provider.dimensionId, sourcelist);
+ nearbyNodes.clear();
+ }
+
+ 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);
+
+ 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))
+ continue;
+
+ 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 });
+ }
+
+ 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])) {
+ dist = (Float) o[1];
+ closest = (TileVisNode) o[0];
+ }
+ }
+ }
+ if (closest != null) {
+ closest.getChildren().add(ref);
+ nearbyNodes.clear();
+ return new WeakReference(closest);
+ }
+
+ 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;
+ 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 });
+ }
+
+ in = findClosestNodes(target, child, in);
+ }
+ }
+ return in;
+ }
+
+ private static float inRange(World world, WorldCoordinates cc1,
+ WorldCoordinates cc2, int range) {
+ float distance = cc1.getDistanceSquaredToWorldCoordinates(cc2);
+ return distance > range * range ? -1 : distance;
+ }
+
+ private static HashMap>> nearbyNodes = new HashMap>>();
+
+ private static void calculateNearbyNodes(World world, int x, int y, int z) {
+
+ 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,
+ world.provider.dimensionId);
+
+ ArrayList nearby = new ArrayList();
+
+ for (WeakReference root : sourcelist.values()) {
+
+ if (!isNodeValid(root))
+ continue;
+
+ TileVisNode source = root.get();
+
+ TileVisNode closest = null;
+ float range = Float.MAX_VALUE;
+
+ 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) {
+ range = r2;
+ closest = n;
+ }
+ }
+ }
+
+ 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)) {
+ list.add(child);
+ 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 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 HashMap>
+ // noderef = new HashMap>();
+ //
+ // public static TileVisNode getClosestNodeWithinRadius(World world, int x,
+ // int y, int z, int radius) {
+ // TileVisNode out = null;
+ // WorldCoordinates wc = null;
+ // float cd = Float.MAX_VALUE;
+ // for (int sx = x - radius; sx <= x + radius; sx++) {
+ // for (int sy = y - radius; sy <= y + radius; sy++) {
+ // for (int sz = z - radius; sz <= z + radius; sz++) {
+ // wc = new WorldCoordinates(sx,sy,sz,world.provider.dimensionId);
+ // if (noderef.containsKey(wc)) {
+ // float d = wc.getDistanceSquared(x, y, z);
+ // if (d=types.length) {
+ FocusUpgradeType[] temp = new FocusUpgradeType[id+1];
+ System.arraycopy(types, 0, temp, 0, types.length);
+ types = temp;
+ }
+
+ types[id] = this;
+ }
+
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(name);
+ }
+
+ 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;
+ }
+
+ // 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));
+
+
+}
diff --git a/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java b/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java
new file mode 100644
index 00000000..4ef8c849
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java
@@ -0,0 +1,16 @@
+package thaumcraft.api.wands;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+/**
+ *
+ * @author azanor
+ *
+ * Implemented by a class that you wish to be called whenever a wand with this rod performs its
+ * update tick.
+ *
+ */
+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
new file mode 100644
index 00000000..7c299deb
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java
@@ -0,0 +1,15 @@
+package thaumcraft.api.wands;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+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);
+
+}
diff --git a/src/api/java/thaumcraft/api/wands/IWandable.java b/src/api/java/thaumcraft/api/wands/IWandable.java
new file mode 100644
index 00000000..aeb9bac7
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/IWandable.java
@@ -0,0 +1,25 @@
+package thaumcraft.api.wands;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+/**
+ *
+ * @author azanor
+ *
+ * Add this to a tile entity that you wish wands to interact with in some way.
+ *
+ */
+
+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
new file mode 100644
index 00000000..e8938e91
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java
@@ -0,0 +1,276 @@
+package thaumcraft.api.wands;
+
+import java.text.DecimalFormat;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+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;
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public IIcon getIconFromDamage(int par1) {
+ return icon;
+ }
+
+ @Override
+ 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);
+ }
+ }
+ 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) {
+ int amt = 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)):""));
+ }
+ }
+
+ /**
+ * Purely for display on the focus tooltip (see addInformation method above)
+ */
+ public boolean isVisCostPerTick(ItemStack focusstack) {
+ return false;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack focusstack)
+ {
+ return EnumRarity.rare;
+ }
+
+ /**
+ * What color will the focus orb be rendered on the held wand
+ */
+ 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) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * An icon to be rendered inside the focus itself
+ */
+ public IIcon getFocusDepthLayerIcon(ItemStack focusstack) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public enum WandFocusAnimation {
+ WAVE, CHARGE;
+ }
+
+ 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)) {
+ out = out + id;
+ }
+ return out;
+ }
+
+
+ /**
+ * How much vis does this focus consume per activation.
+ */
+ 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) {
+ return 0;
+ }
+
+ /**
+ * Used by foci like equal trade to determine their area in artchitect mode
+ */
+ 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) {
+ 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 boolean applyUpgrade(ItemStack focusstack, FocusUpgradeType type, int rank) {
+ short[] upgrades = getAppliedUpgrades(focusstack);
+ if (upgrades[rank-1]!=-1 || rank<1 || rank>5) {
+ return false;
+ }
+ 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) {
+ return true;
+ }
+
+ /**
+ * Does this focus have the passed upgrade type
+ */
+ 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++;
+ }
+ }
+ 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) {
+ // TODO Auto-generated method stub
+ }
+
+ 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) {
+ // 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())
+ focusstack.setTagCompound(new NBTTagCompound());
+ NBTTagCompound nbttagcompound = focusstack.getTagCompound();
+ NBTTagList tlist = new NBTTagList();
+ nbttagcompound.setTag("upgrade", tlist);
+ for (short id : upgrades) {
+ 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")) {
+ 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
new file mode 100644
index 00000000..e7ae90f0
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/StaffRod.java
@@ -0,0 +1,48 @@
+package thaumcraft.api.wands;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+
+/**
+ *
+ * @author Azanor
+ *
+ * This class is used to keep the material information for the various rods.
+ * It is also used to generate the wand recipes ingame.
+ *
+ */
+public class StaffRod extends WandRod {
+
+ boolean runes=false;
+
+ 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");
+ }
+
+ 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,
+ ResourceLocation texture) {
+ super(tag+"_staff", capacity, item, craftCost, texture);
+ }
+
+ public boolean hasRunes() {
+ return runes;
+ }
+
+ public void setRunes(boolean hasRunes) {
+ this.runes = hasRunes;
+ }
+
+
+}
diff --git a/src/api/java/thaumcraft/api/wands/WandCap.java b/src/api/java/thaumcraft/api/wands/WandCap.java
new file mode 100644
index 00000000..17b4581c
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/WandCap.java
@@ -0,0 +1,129 @@
+package thaumcraft.api.wands;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import thaumcraft.api.aspects.Aspect;
+
+/**
+ * This class is used to keep the material information for the various caps.
+ * It is also used to generate the wand recipes ingame.
+ * @author Azanor
+ *
+ */
+public class WandCap {
+
+ private String tag;
+
+ /**
+ * Cost to craft this wand. Combined with the rod cost.
+ */
+ private int craftCost;
+
+ /**
+ * the amount by which all aspect costs are multiplied
+ */
+ float baseCostModifier;
+
+ /**
+ * specifies a list of primal aspects that use the special discount figure instead of the normal discount.
+ */
+ List specialCostModifierAspects;
+
+ /**
+ * the amount by which the specified aspect costs are multiplied
+ */
+ float specialCostModifier;
+
+ /**
+ * The texture that will be used for the ingame wand cap
+ */
+ 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);
+ 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);
+ caps.put(tag, this);
+ }
+
+ public float getBaseCostModifier() {
+ return baseCostModifier;
+ }
+
+ public List getSpecialCostModifierAspects() {
+ return specialCostModifierAspects;
+ }
+
+ public float getSpecialCostModifier() {
+ return specialCostModifier;
+ }
+
+ public ResourceLocation getTexture() {
+ return texture;
+ }
+
+ public void setTexture(ResourceLocation texture) {
+ this.texture = texture;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+
+ public ItemStack getItem() {
+ return item;
+ }
+
+ public void setItem(ItemStack item) {
+ this.item = item;
+ }
+
+ public int getCraftCost() {
+ return 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();
+ }
+
+ // 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
new file mode 100644
index 00000000..85954e46
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/WandRod.java
@@ -0,0 +1,158 @@
+package thaumcraft.api.wands;
+
+import java.util.LinkedHashMap;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+
+/**
+ *
+ * @author Azanor
+ *
+ * This class is used to keep the material information for the various rods.
+ * It is also used to generate the wand recipes ingame.
+ *
+ */
+public class WandRod {
+
+
+ private String tag;
+
+ /**
+ * Cost to craft this wand. Combined with the rod cost.
+ */
+ 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;
+
+ /**
+ * The texture that will be used for the ingame wand rod
+ */
+ protected ResourceLocation texture;
+
+ /**
+ * the actual item that makes up this rod and will be used to generate the wand recipes
+ */
+ ItemStack item;
+
+ /**
+ * A class that will be called whenever the wand onUpdate tick is run
+ */
+ IWandRodOnUpdate onUpdate;
+
+ /**
+ * Does the rod glow in the dark?
+ */
+ boolean glow;
+
+ public static LinkedHashMap rods = new LinkedHashMap();
+
+ public WandRod (String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) {
+ this.setTag(tag);
+ this.capacity = capacity;
+ this.texture = texture;
+ this.item=item;
+ this.setCraftCost(craftCost);
+ rods.put(tag, this);
+ }
+
+ public WandRod (String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) {
+ this.setTag(tag);
+ this.capacity = capacity;
+ this.texture = texture;
+ this.item=item;
+ this.setCraftCost(craftCost);
+ rods.put(tag, this);
+ this.onUpdate = onUpdate;
+ }
+
+ public WandRod (String tag, int capacity, ItemStack item, int craftCost) {
+ this.setTag(tag);
+ this.capacity = capacity;
+ this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+getTag()+".png");
+ this.item=item;
+ this.setCraftCost(craftCost);
+ rods.put(tag, this);
+ }
+
+ public WandRod (String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) {
+ this.setTag(tag);
+ this.capacity = capacity;
+ this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+getTag()+".png");
+ this.item=item;
+ this.setCraftCost(craftCost);
+ rods.put(tag, this);
+ this.onUpdate = onUpdate;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public int getCapacity() {
+ return capacity;
+ }
+
+ public void setCapacity(int capacity) {
+ this.capacity = capacity;
+ }
+
+ public ResourceLocation getTexture() {
+ return texture;
+ }
+
+ public void setTexture(ResourceLocation texture) {
+ this.texture = texture;
+ }
+
+ public ItemStack getItem() {
+ return item;
+ }
+
+ public void setItem(ItemStack item) {
+ this.item = item;
+ }
+
+ public int getCraftCost() {
+ return craftCost;
+ }
+
+ public void setCraftCost(int craftCost) {
+ this.craftCost = craftCost;
+ }
+
+ public IWandRodOnUpdate getOnUpdate() {
+ return onUpdate;
+ }
+
+ public void setOnUpdate(IWandRodOnUpdate onUpdate) {
+ this.onUpdate = onUpdate;
+ }
+
+ public boolean isGlowing() {
+ return glow;
+ }
+
+ public void setGlowing(boolean hasGlow) {
+ this.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();
+ }
+
+ // Some examples:
+ // WandRod WAND_ROD_WOOD = new WandRod("wood",25,new ItemStack(Item.stick),1);
+ // WandRod WAND_ROD_BLAZE = new WandRod("blaze",100,new ItemStack(Item.blazeRod),7,new WandRodBlazeOnUpdate());
+}
diff --git a/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java b/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java
new file mode 100644
index 00000000..7224e12f
--- /dev/null
+++ b/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java
@@ -0,0 +1,126 @@
+package thaumcraft.api.wands;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+/**
+ * This class serves a similar function to IWandable in that it allows wands to interact
+ * with object in the world. In this case it is most useful for adding interaction with non-mod
+ * blocks where you can't control what happens in their code.
+ * Example where it is used is in crafting the thaumonomicon from a bookshelf and the
+ * crucible from a cauldron
+ *
+ * @author azanor
+ *
+ */
+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.
+ * A manager class needs to be created that implements IWandTriggerManager.
+ * @param manager
+ * @param event a logical number that you can use to differentiate different events or actions
+ * @param block
+ * @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());
+ }
+ 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) {
+ 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;
+ }
+ 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;
+ return false;
+ }
+
+
+ /**
+ * This is called by the onItemUseFirst function in wands.
+ * Parameters and return value functions like you would expect for that function.
+ * @param world
+ * @param wand
+ * @param player
+ * @param x
+ * @param y
+ * @param z
+ * @param side
+ * @param block
+ * @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;
+ }
+ 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);
+ return manager.performTrigger(world, wand, player, x, y, z, side, event);
+ }
+
+}
diff --git a/src/main/java/crazypants/enderio/ClientProxy.java b/src/main/java/crazypants/enderio/ClientProxy.java
index a08e0875..afc22ef6 100644
--- a/src/main/java/crazypants/enderio/ClientProxy.java
+++ b/src/main/java/crazypants/enderio/ClientProxy.java
@@ -8,7 +8,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
@@ -22,6 +21,8 @@ import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.conduit.BlockConduitBundle;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.TileConduitBundle;
@@ -132,6 +133,7 @@ import crazypants.enderio.teleport.anchor.TravelEntitySpecialRenderer;
import crazypants.enderio.teleport.telepad.TeleportEntityRenderHandler;
import crazypants.render.IconUtil;
+@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy {
// @formatter:off
@@ -225,7 +227,7 @@ public class ClientProxy extends CommonProxy {
BlockSolarPanel.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new SolarPanelRenderer());
-
+
EnchanterModelRenderer emr = new EnchanterModelRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, emr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnchanter), emr);
@@ -260,7 +262,7 @@ public class ClientProxy extends CommonProxy {
BlockWeatherObelisk.renderId = BlockAttractor.renderId;
ClientRegistry.bindTileEntitySpecialRenderer(TileWeatherObelisk.class, twr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockWeatherObelisk), twr);
-
+
if(Config.useCombustionGenModel) {
CombustionGeneratorModelRenderer cgmr = new CombustionGeneratorModelRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileCombustionGenerator.class, cgmr);
diff --git a/src/main/java/crazypants/enderio/EnderIO.java b/src/main/java/crazypants/enderio/EnderIO.java
index 125c5a2e..1cf312a6 100644
--- a/src/main/java/crazypants/enderio/EnderIO.java
+++ b/src/main/java/crazypants/enderio/EnderIO.java
@@ -1,9 +1,5 @@
package crazypants.enderio;
-import static crazypants.enderio.EnderIO.MODID;
-import static crazypants.enderio.EnderIO.MOD_NAME;
-import static crazypants.enderio.EnderIO.VERSION;
-
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -155,9 +151,12 @@ import crazypants.enderio.teleport.TravelController;
import crazypants.enderio.teleport.anchor.BlockTravelAnchor;
import crazypants.enderio.teleport.telepad.BlockTelePad;
import crazypants.enderio.teleport.telepad.ItemCoordSelector;
+import crazypants.enderio.thaumcraft.ThaumcraftCompat;
import crazypants.util.EntityUtil;
-@Mod(modid = MODID, name = MOD_NAME, version = VERSION, dependencies = "required-after:Forge@10.13.0.1150,);after:MineFactoryReloaded;after:Waila@[1.5.8,)", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO")
+import static crazypants.enderio.EnderIO.*;
+
+@Mod(modid = MODID, name = MOD_NAME, version = VERSION, dependencies = "required-after:Forge@10.13.0.1150,);after:MineFactoryReloaded;after:Waila@[1.5.8,);after:Thaumcraft", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO")
public class EnderIO {
public static final String MODID = "EnderIO";
@@ -478,7 +477,7 @@ public class EnderIO {
public void load(FMLInitializationEvent event) {
Config.init();
-
+
instance = this;
PacketHandler.INSTANCE.registerMessage(MessageTileNBT.class, MessageTileNBT.class, PacketHandler.nextID(), Side.SERVER);
@@ -559,14 +558,13 @@ public class EnderIO {
TeleportRecipes.addRecipes();
proxy.load();
-
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
Config.postInit();
-
+
//Regsiter the enchants
Enchantments.getInstance();
@@ -627,7 +625,7 @@ public class EnderIO {
try {
Field getField = Class.forName("openblocks.Config").getField("xpFluidId");
openBlocksXPJuiceName = (String) getField.get(null);
- }catch(Exception e) {
+ } catch (Exception e) {
}
if(openBlocksXPJuiceName != null && !Config.xpJuiceName.equals(openBlocksXPJuiceName)) {
@@ -657,7 +655,8 @@ public class EnderIO {
Log.info("Failed to registered Capacitor Banks as Tinkers Construct Flux Upgrades");
}
}
-
+
+ ThaumcraftCompat.load();
}
@EventHandler
diff --git a/src/main/java/crazypants/enderio/EnderIOTab.java b/src/main/java/crazypants/enderio/EnderIOTab.java
index 28db9720..0918e159 100644
--- a/src/main/java/crazypants/enderio/EnderIOTab.java
+++ b/src/main/java/crazypants/enderio/EnderIOTab.java
@@ -1,10 +1,10 @@
package crazypants.enderio;
+import static crazypants.enderio.EnderIO.MODID;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import static crazypants.enderio.EnderIO.*;
public class EnderIOTab extends CreativeTabs {
@@ -27,6 +27,7 @@ public class EnderIOTab extends CreativeTabs {
}
@Override
+ @SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return EnderIO.itemEnderface;
}
diff --git a/src/main/java/crazypants/enderio/block/BlockDarkSteelPressurePlate.java b/src/main/java/crazypants/enderio/block/BlockDarkSteelPressurePlate.java
index b9093130..a00e1c03 100644
--- a/src/main/java/crazypants/enderio/block/BlockDarkSteelPressurePlate.java
+++ b/src/main/java/crazypants/enderio/block/BlockDarkSteelPressurePlate.java
@@ -56,6 +56,7 @@ public class BlockDarkSteelPressurePlate extends BlockPressurePlate implements I
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
blockIcon = iIconRegister.registerIcon("enderio:" + ModObject.blockDarkSteelPressurePlate.unlocalisedName);
}
@@ -69,6 +70,7 @@ public class BlockDarkSteelPressurePlate extends BlockPressurePlate implements I
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
diff --git a/src/main/java/crazypants/enderio/conduit/AbstractConduit.java b/src/main/java/crazypants/enderio/conduit/AbstractConduit.java
index cd6173e1..7afff2a9 100644
--- a/src/main/java/crazypants/enderio/conduit/AbstractConduit.java
+++ b/src/main/java/crazypants/enderio/conduit/AbstractConduit.java
@@ -437,9 +437,6 @@ public abstract class AbstractConduit implements IConduit {
bundle.getEntity().getBlockType());
}
}
- if(getNetwork() != null) {
- getNetwork().onUpdateEntity(this);
- }
}
@Override
diff --git a/src/main/java/crazypants/enderio/conduit/AbstractConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/AbstractConduitNetwork.java
index 54d030c2..6400530a 100644
--- a/src/main/java/crazypants/enderio/conduit/AbstractConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/AbstractConduitNetwork.java
@@ -12,10 +12,12 @@ public abstract class AbstractConduitNetwork {
protected final List conduits = new ArrayList();
- protected Class implClass;
+ protected final Class implClass;
+ protected final Class baseConduitClass;
- protected AbstractConduitNetwork(Class implClass) {
+ protected AbstractConduitNetwork(Class implClass, Class baseConduitClass) {
this.implClass = implClass;
+ this.baseConduitClass = baseConduitClass;
}
public void init(IConduitBundle tile, Collection connections, World world) {
@@ -35,7 +37,9 @@ public abstract class AbstractConduitNetwork {
notifyNetworkOfUpdate();
}
- public abstract Class getBaseConduitType();
+ public final Class getBaseConduitType() {
+ return baseConduitClass;
+ }
protected void setNetwork(World world, IConduitBundle tile) {
@@ -58,6 +62,9 @@ public abstract class AbstractConduitNetwork {
public void addConduit(I con) {
if(!conduits.contains(con)) {
+ if(conduits.isEmpty()) {
+ ConduitNetworkTickHandler.instance.registerNetwork(this);
+ }
conduits.add(con);
}
}
@@ -67,6 +74,7 @@ public abstract class AbstractConduitNetwork {
con.setNetwork(null);
}
conduits.clear();
+ ConduitNetworkTickHandler.instance.unregisterNetwork(this);
}
public List getConduits() {
@@ -90,7 +98,6 @@ public abstract class AbstractConduitNetwork {
return "AbstractConduitNetwork [conduits=" + sb.toString() + "]";
}
- public void onUpdateEntity(IConduit conduit) {
+ public void doNetworkTick() {
}
-
}
diff --git a/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java b/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java
index 4346e7c7..58e4cfc0 100644
--- a/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java
+++ b/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java
@@ -14,6 +14,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
@@ -43,6 +45,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
int index = 0;
for (ItemConduitSubtype subtype : subtypes) {
@@ -108,6 +111,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, subtypes.length - 1);
return icons[damage];
@@ -122,6 +126,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int j = 0; j < subtypes.length; ++j) {
par3List.add(new ItemStack(this, 1, j));
diff --git a/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java b/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java
index 4e5623c5..320abf12 100644
--- a/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java
+++ b/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java
@@ -337,14 +337,15 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
}
}
}
-
+
@Override
+ @SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return 1;
}
-
+
public static volatile int theRenderPass;
-
+
@Override
public boolean canRenderInPass(int pass) {
theRenderPass = pass;
@@ -760,6 +761,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
}
@Override
+ @SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int
y, int z) {
@@ -851,7 +853,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
}
IConduitBundle bundle = (IConduitBundle) te;
List hits = new ArrayList();
-
+
if (player == null) {
player = EnderIO.proxy.getClientPlayer();
}
diff --git a/src/main/java/crazypants/enderio/conduit/ConduitNetworkTickHandler.java b/src/main/java/crazypants/enderio/conduit/ConduitNetworkTickHandler.java
index 06df29f0..e846d700 100644
--- a/src/main/java/crazypants/enderio/conduit/ConduitNetworkTickHandler.java
+++ b/src/main/java/crazypants/enderio/conduit/ConduitNetworkTickHandler.java
@@ -1,6 +1,7 @@
package crazypants.enderio.conduit;
import java.util.ArrayList;
+import java.util.IdentityHashMap;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -19,6 +20,9 @@ public class ConduitNetworkTickHandler {
private final List listeners = new ArrayList();
+ private final IdentityHashMap, Boolean> networks =
+ new IdentityHashMap, Boolean>();
+
public void addListener(TickListener listener) {
listeners.add(listener);
}
@@ -27,6 +31,14 @@ public class ConduitNetworkTickHandler {
listeners.remove(listener);
}
+ public void registerNetwork(AbstractConduitNetwork,?> cn) {
+ networks.put(cn, Boolean.TRUE);
+ }
+
+ public void unregisterNetwork(AbstractConduitNetwork,?> cn) {
+ networks.remove(cn);
+ }
+
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if(event.phase == Phase.START) {
@@ -47,6 +59,9 @@ public class ConduitNetworkTickHandler {
h.tickEnd(event);
}
listeners.clear();
+ for(AbstractConduitNetwork,?> cn : networks.keySet()) {
+ cn.doNetworkTick();
+ }
}
}
diff --git a/src/main/java/crazypants/enderio/conduit/TileConduitBundle.java b/src/main/java/crazypants/enderio/conduit/TileConduitBundle.java
index dbdb63e2..f113779f 100644
--- a/src/main/java/crazypants/enderio/conduit/TileConduitBundle.java
+++ b/src/main/java/crazypants/enderio/conduit/TileConduitBundle.java
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -33,7 +34,6 @@ import crazypants.enderio.conduit.geom.ConduitConnectorType;
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
import crazypants.enderio.conduit.geom.Offset;
import crazypants.enderio.conduit.geom.Offsets;
-import crazypants.enderio.conduit.geom.Offsets.Axis;
import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.liquid.ILiquidConduit;
import crazypants.enderio.conduit.me.IMEConduit;
@@ -224,7 +224,6 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
@Override
public void updateEntity() {
-
if(worldObj == null) {
return;
}
@@ -234,62 +233,74 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
}
if(conduitsDirty) {
- if(!worldObj.isRemote) {
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- markDirty();
- }
- conduitsDirty = false;
+ doConduitsDirty();
}
if(facadeChanged) {
- //force re-calc of lighting for both client and server
- ConduitUtil.forceSkylightRecalculation(worldObj, xCoord, yCoord, zCoord);
- //worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
- worldObj.func_147451_t(xCoord, yCoord, zCoord);
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- facadeChanged = false;
+ doFacadeChanged();
}
//client side only, check for changes in rendering of the bundle
if(worldObj.isRemote) {
+ updateEntityClient();
+ }
+ }
- boolean markForUpdate = false;
- if(clientUpdated) {
- //TODO: This is not the correct solution here but just marking the block for a render update server side
- //seems to get out of sync with the client sometimes so connections are not rendered correctly
+ private void doConduitsDirty() {
+ if(!worldObj.isRemote) {
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ markDirty();
+ }
+ conduitsDirty = false;
+ }
+
+ private void doFacadeChanged() {
+ //force re-calc of lighting for both client and server
+ ConduitUtil.forceSkylightRecalculation(worldObj, xCoord, yCoord, zCoord);
+ //worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
+ worldObj.func_147451_t(xCoord, yCoord, zCoord);
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, EnderIO.blockConduitBundle);
+ facadeChanged = false;
+ }
+
+ private void updateEntityClient() {
+ boolean markForUpdate = false;
+ if(clientUpdated) {
+ //TODO: This is not the correct solution here but just marking the block for a render update server side
+ //seems to get out of sync with the client sometimes so connections are not rendered correctly
+ markForUpdate = true;
+ clientUpdated = false;
+ }
+
+ FacadeRenderState curRS = getFacadeRenderedAs();
+ FacadeRenderState rs = ConduitUtil.getRequiredFacadeRenderState(this, EnderIO.proxy.getClientPlayer());
+
+ if(Config.updateLightingWhenHidingFacades) {
+ int curLO = getLightOpacity();
+ int shouldBeLO = rs == FacadeRenderState.FULL ? 255 : 0;
+ if(curLO != shouldBeLO) {
+ setLightOpacity(shouldBeLO);
+ //worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
+ worldObj.func_147451_t(xCoord, yCoord, zCoord);
+ }
+ }
+
+ if(curRS != rs) {
+ setFacadeRenderAs(rs);
+ if(!ConduitUtil.forceSkylightRecalculation(worldObj, xCoord, yCoord, zCoord)) {
markForUpdate = true;
- clientUpdated = false;
+ }
+ } else { //can do the else as only need to update once
+ ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(EnderIO.proxy.getClientPlayer().getCurrentEquippedItem());
+ if(curMode != lastMode) {
+ markForUpdate = true;
+ lastMode = curMode;
}
- FacadeRenderState curRS = getFacadeRenderedAs();
- FacadeRenderState rs = ConduitUtil.getRequiredFacadeRenderState(this, EnderIO.proxy.getClientPlayer());
-
- if(Config.updateLightingWhenHidingFacades) {
- int curLO = getLightOpacity();
- int shouldBeLO = rs == FacadeRenderState.FULL ? 255 : 0;
- if(curLO != shouldBeLO) {
- setLightOpacity(shouldBeLO);
- //worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
- worldObj.func_147451_t(xCoord, yCoord, zCoord);
- }
- }
-
- if(curRS != rs) {
- setFacadeRenderAs(rs);
- if(!ConduitUtil.forceSkylightRecalculation(worldObj, xCoord, yCoord, zCoord)) {
- markForUpdate = true;
- }
- } else { //can do the else as only need to update once
- ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(EnderIO.proxy.getClientPlayer().getCurrentEquippedItem());
- if(curMode != lastMode) {
- markForUpdate = true;
- lastMode = curMode;
- }
-
- }
- if(markForUpdate) {
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- }
+ }
+ if(markForUpdate) {
+ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@@ -421,7 +432,7 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
@Override
public Set getAllConnections() {
- Set result = new HashSet();
+ EnumSet result = EnumSet.noneOf(ForgeDirection.class);
for (IConduit con : conduits) {
result.addAll(con.getConduitConnections());
}
@@ -582,7 +593,7 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
}
// External Connectors
- Set externalDirs = new HashSet();
+ EnumSet externalDirs = EnumSet.noneOf(ForgeDirection.class);
for (IConduit con : conduits) {
Set extCons = con.getExternalConnections();
if(extCons != null) {
@@ -603,20 +614,6 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
connectorsDirty = false;
}
- private boolean axisOfConnectionsEqual(Set cons) {
- Axis axis = null;
- for (ForgeDirection dir : cons) {
- if(axis == null) {
- axis = Offsets.getAxisForDir(dir);
- } else {
- if(axis != Offsets.getAxisForDir(dir)) {
- return false;
- }
- }
- }
- return true;
- }
-
private void addConduitCores(List result, IConduit con) {
CollidableCache cc = CollidableCache.instance;
Class extends IConduit> type = con.getCollidableType();
@@ -632,43 +629,6 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
}
}
- // private boolean containsOnlySingleVerticalConnections() {
- // return getConnectionCount(ForgeDirection.UP) < 2 && getConnectionCount(ForgeDirection.DOWN) < 2;
- // }
- //
- // private boolean containsOnlySingleHorizontalConnections() {
- // return getConnectionCount(ForgeDirection.WEST) < 2 && getConnectionCount(ForgeDirection.EAST) < 2 &&
- // getConnectionCount(ForgeDirection.NORTH) < 2 && getConnectionCount(ForgeDirection.SOUTH) < 2;
- // }
- //
- // private boolean allDirectionsHaveSameConnectionCount() {
- // for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
- // boolean hasCon = conduits.get(0).isConnectedTo(dir);
- // for (int i = 1; i < conduits.size(); i++) {
- // if(hasCon != conduits.get(i).isConnectedTo(dir)) {
- // return false;
- // }
- // }
- // }
- // return true;
- // }
-
- // private boolean containsOnlyHorizontalConnections() {
- // for (IConduit con : conduits) {
- // for (ForgeDirection dir : con.getConduitConnections()) {
- // if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) {
- // return false;
- // }
- // }
- // for (ForgeDirection dir : con.getExternalConnections()) {
- // if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) {
- // return false;
- // }
- // }
- // }
- // return true;
- // }
-
private int getConnectionCount(ForgeDirection dir) {
if(dir == ForgeDirection.UNKNOWN) {
return conduits.size();
@@ -916,7 +876,6 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
@Override
@Method(modid = "appliedenergistics2")
public void securityBreak() {
- ;
}
@Override
diff --git a/src/main/java/crazypants/enderio/conduit/facade/BlockConduitFacade.java b/src/main/java/crazypants/enderio/conduit/facade/BlockConduitFacade.java
index 4fc9b819..d692ab3c 100644
--- a/src/main/java/crazypants/enderio/conduit/facade/BlockConduitFacade.java
+++ b/src/main/java/crazypants/enderio/conduit/facade/BlockConduitFacade.java
@@ -32,6 +32,7 @@ public class BlockConduitFacade extends BlockEio implements IPaintedBlock {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:conduitFacade");
}
diff --git a/src/main/java/crazypants/enderio/conduit/facade/ItemConduitFacade.java b/src/main/java/crazypants/enderio/conduit/facade/ItemConduitFacade.java
index 0d0b51b7..2f8dffad 100644
--- a/src/main/java/crazypants/enderio/conduit/facade/ItemConduitFacade.java
+++ b/src/main/java/crazypants/enderio/conduit/facade/ItemConduitFacade.java
@@ -27,8 +27,8 @@ import crazypants.enderio.machine.painter.BasicPainterTemplate;
import crazypants.enderio.machine.painter.IPaintedBlock;
import crazypants.enderio.machine.painter.PaintSourceValidator;
import crazypants.enderio.machine.painter.PainterUtil;
-import crazypants.util.Util;
import crazypants.util.Lang;
+import crazypants.util.Util;
public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider, IResourceTooltipProvider {
@@ -63,6 +63,7 @@ public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider,
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) {
for (FacadeType t : FacadeType.values()) {
list.add(new ItemStack(item, 1, t.ordinal()));
@@ -80,6 +81,7 @@ public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider,
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
icons = new IIcon[FacadeType.values().length];
icons[0] = itemIcon = IIconRegister.registerIcon("enderio:conduitFacade");
@@ -92,6 +94,7 @@ public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider,
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return icons[damage % icons.length];
}
diff --git a/src/main/java/crazypants/enderio/conduit/gas/AbstractGasTankConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/gas/AbstractGasTankConduitNetwork.java
index 1bb2b2ac..9b3a7503 100644
--- a/src/main/java/crazypants/enderio/conduit/gas/AbstractGasTankConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/gas/AbstractGasTankConduitNetwork.java
@@ -8,18 +8,13 @@ public class AbstractGasTankConduitNetwork ext
protected GasStack gasType;
protected AbstractGasTankConduitNetwork(Class cl) {
- super(cl);
+ super(cl, IGasConduit.class);
}
public GasStack getGasType() {
return gasType;
}
- @Override
- public Class getBaseConduitType() {
- return IGasConduit.class;
- }
-
@Override
public void addConduit(T con) {
super.addConduit(con);
diff --git a/src/main/java/crazypants/enderio/conduit/gas/GasConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/gas/GasConduitNetwork.java
index 18066c9e..3505bf88 100644
--- a/src/main/java/crazypants/enderio/conduit/gas/GasConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/gas/GasConduitNetwork.java
@@ -9,9 +9,6 @@ import mekanism.api.gas.IGasHandler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
import crazypants.enderio.conduit.IConduit;
import crazypants.util.BlockCoord;
@@ -29,19 +26,10 @@ public class GasConduitNetwork extends AbstractGasTankConduitNetwork
private int lastSyncedVolume = -1;
- private long timeAtLastApply;
-
- private final InnerTickHandler tickHandler = new InnerTickHandler();
-
public GasConduitNetwork() {
super(GasConduit.class);
}
- @Override
- public Class getBaseConduitType() {
- return IGasConduit.class;
- }
-
@Override
public void addConduit(GasConduit con) {
tank.setCapacity(tank.getMaxGas() + GasConduit.CONDUIT_VOLUME);
@@ -97,24 +85,7 @@ public class GasConduitNetwork extends AbstractGasTankConduitNetwork
}
@Override
- public void onUpdateEntity(IConduit conduit) {
- World world = conduit.getBundle().getEntity().getWorldObj();
- if(world == null) {
- return;
- }
- if(world.isRemote) {
- return;
- }
-
- long curTime = world.getTotalWorldTime();
- if(curTime > 0 && curTime != timeAtLastApply) {
- timeAtLastApply = curTime;
- ConduitNetworkTickHandler.instance.addListener(tickHandler);
- }
-
- }
-
- private void doTick() {
+ public void doNetworkTick() {
if(gasType == null || outputs.isEmpty() || !tank.containsValidGas() || tank.isEmpty()) {
updateActiveState();
return;
@@ -294,16 +265,4 @@ public class GasConduitNetwork extends AbstractGasTankConduitNetwork
lastSyncedVolume = tank.getStored();
}
- private class InnerTickHandler implements TickListener {
-
- @Override
- public void tickStart(ServerTickEvent evt) {
- }
-
- @Override
- public void tickEnd(ServerTickEvent evt) {
- doTick();
- }
- }
-
}
diff --git a/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java b/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java
index 9791f87b..2707ab64 100644
--- a/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java
+++ b/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java
@@ -17,33 +17,22 @@ import crazypants.enderio.conduit.gui.item.InventoryFilterUpgrade;
import crazypants.enderio.conduit.gui.item.InventorySpeedUpgrades;
import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.item.SpeedUpgrade;
-import crazypants.enderio.conduit.item.filter.IItemFilter;
public class ExternalConnectionContainer extends Container {
- private InventoryPlayer playerInv;
- private IConduitBundle bundle;
- private ForgeDirection dir;
- private IItemConduit itemConduit;
+ private final IItemConduit itemConduit;
private int speedUpgradeSlotLimit = 15;
- private IItemFilter inputFilter;
- private IItemFilter outputFilter;
private int outputFilterUpgradeSlot = 36;
private int inputFilterUpgradeSlot = 37;
private int speedUpgradeSlot = 38;
- private int startFilterSlot = 39;
private List slotLocations = new ArrayList();
List filterListeners = new ArrayList();
public ExternalConnectionContainer(InventoryPlayer playerInv, IConduitBundle bundle, ForgeDirection dir) {
- this.playerInv = playerInv;
- this.bundle = bundle;
- this.dir = dir;
-
int x;
int y;
@@ -67,7 +56,6 @@ public class ExternalConnectionContainer extends Container {
itemConduit = bundle.getConduit(IItemConduit.class);
if(itemConduit != null) {
-
x = 10;
y = 47;
InventoryFilterUpgrade fi = new InventoryFilterUpgrade(itemConduit, dir, false);
@@ -96,48 +84,14 @@ public class ExternalConnectionContainer extends Container {
}
});
slotLocations.add(new Point(x, y));
-
- addFilterSlots(dir);
}
-
}
public void addFilterListener(FilterChangeListener list) {
filterListeners.add(list);
}
- private void addFilterSlots(ForgeDirection dir) {
-
- List slots;
- inputFilter = itemConduit.getInputFilter(dir);
- if(inputFilter != null && inputFilter.getSlotCount() > 0) {
- slots = inputFilter.getSlots(33, 69);
- for (Slot slot : slots) {
- addSlotToContainer(slot);
- slotLocations.add(new Point(slot.xDisplayPosition, slot.yDisplayPosition));
- }
- }
-
- outputFilter = itemConduit.getOutputFilter(dir);
- if(outputFilter != null && outputFilter.getSlotCount() > 0) {
- slots = outputFilter.getSlots(33, 69);
- for (Slot slot : slots) {
- addSlotToContainer(slot);
- slotLocations.add(new Point(slot.xDisplayPosition, slot.yDisplayPosition));
- }
- }
- }
-
protected void filterChanged() {
- int slotsToRemove = inventorySlots.size() - startFilterSlot;
- for (int i = 0; i < slotsToRemove; i++) {
- int removeIndex = inventorySlots.size() - 1;
- inventorySlots.remove(removeIndex);
- inventoryItemStacks.remove(removeIndex);
- slotLocations.remove(removeIndex);
- }
- addFilterSlots(dir);
-
for (FilterChangeListener list : filterListeners) {
list.onFilterChanged();
}
@@ -149,31 +103,14 @@ public class ExternalConnectionContainer extends Container {
}
setSlotsVisible(visible, inputFilterUpgradeSlot, inputFilterUpgradeSlot + 1);
setSlotsVisible(visible, speedUpgradeSlot, speedUpgradeSlot + 1);
-
- if(inputFilter == null || inputFilter.getSlotCount() == 0) {
- return;
- }
- int startIndex = startFilterSlot;
- int endIndex = inputFilter.getSlotCount() + startIndex;
- setSlotsVisible(visible, startIndex, endIndex);
-
}
public void setOutputSlotsVisible(boolean visible) {
-
if(itemConduit == null) {
return;
}
setSlotsVisible(visible, outputFilterUpgradeSlot, outputFilterUpgradeSlot + 1);
-
- if(outputFilter == null || outputFilter.getSlotCount() == 0) {
- return;
- }
- int startIndex = startFilterSlot + (inputFilter == null ? 0 : inputFilter.getSlotCount());
- int endIndex = startIndex + outputFilter.getSlotCount();
- setSlotsVisible(visible, startIndex, endIndex);
-
}
public void setInventorySlotsVisible(boolean visible) {
@@ -205,12 +142,6 @@ public class ExternalConnectionContainer extends Container {
SpeedUpgrade speedUpgrade = EnderIO.itemExtractSpeedUpgrade.getSpeedUpgrade(st);
speedUpgradeSlotLimit = speedUpgrade.maxStackSize;
}
- if(par4EntityPlayer.worldObj != null) {
- if(par1 >= startFilterSlot && itemConduit != null) {
- itemConduit.setInputFilter(dir, inputFilter);
- itemConduit.setOutputFilter(dir, outputFilter);
- }
- }
try {
return super.slotClick(par1, par2, par3, par4EntityPlayer);
} catch (Exception e) {
@@ -226,9 +157,8 @@ public class ExternalConnectionContainer extends Container {
}
private class FilterSlot extends Slot {
+ final boolean isInput;
- boolean isInput;
-
public FilterSlot(IInventory par1iInventory, int par2, int par3, int par4, boolean isInput) {
super(par1iInventory, par2, par3, par4);
this.isInput = isInput;
diff --git a/src/main/java/crazypants/enderio/conduit/gui/GuiExternalConnection.java b/src/main/java/crazypants/enderio/conduit/gui/GuiExternalConnection.java
index 717666a6..c1236fba 100644
--- a/src/main/java/crazypants/enderio/conduit/gui/GuiExternalConnection.java
+++ b/src/main/java/crazypants/enderio/conduit/gui/GuiExternalConnection.java
@@ -199,6 +199,7 @@ public class GuiExternalConnection extends GuiContainerBase {
tes.draw();
}
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
}
public ForgeDirection getDir() {
diff --git a/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java b/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java
index bc8cb2bb..7daa8bcc 100644
--- a/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java
+++ b/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java
@@ -21,19 +21,19 @@ public class BasicItemFilterGui implements IItemFilterGui {
private static final int ID_ORE_DICT = GuiExternalConnection.nextButtonId();
private static final int ID_STICKY = GuiExternalConnection.nextButtonId();
- private GuiContainerBase gui;
+ private final GuiContainerBase gui;
- private ToggleButtonEIO useMetaB;
- private ToggleButtonEIO useNbtB;
- private IconButtonEIO whiteListB;
- private ToggleButtonEIO useOreDictB;
- private ToggleButtonEIO stickyB;
+ private final ToggleButtonEIO useMetaB;
+ private final ToggleButtonEIO useNbtB;
+ private final IconButtonEIO whiteListB;
+ private final ToggleButtonEIO useOreDictB;
+ private final ToggleButtonEIO stickyB;
- boolean isAdvanced;
- boolean isStickyModeAvailable;
+ final boolean isAdvanced;
+ final boolean isStickyModeAvailable;
- private IItemFilterContainer filterContainer;
- private ItemFilter filter;
+ private final IItemFilterContainer filterContainer;
+ private final ItemFilter filter;
private int buttonIdOffset;
private int xOffset;
@@ -58,8 +58,8 @@ public class BasicItemFilterGui implements IItemFilterGui {
isAdvanced = filter.isAdvanced();
int butLeft = xOffset + 92;
- int x = butLeft ;
- int y = yOffset;
+ int x = butLeft;
+ int y = yOffset + 1;
whiteListB = new IconButtonEIO(gui, ID_WHITELIST + buttonIdOffset, x, y, IconEIO.FILTER_WHITELIST);
whiteListB.setToolTip(Lang.localize("gui.conduit.item.whitelist"));
@@ -91,6 +91,15 @@ public class BasicItemFilterGui implements IItemFilterGui {
useOreDictB.setUnselectedToolTip(Lang.localize("gui.conduit.item.oreDicDisabled"));
useOreDictB.setPaintSelectedBorder(false);
}
+
+ public void createFilterSlots() {
+ filter.createGhostSlots(gui.getGhostSlots(), xOffset+1, yOffset+1, new Runnable() {
+ @Override
+ public void run() {
+ sendFilterChange();
+ }
+ });
+ }
@Override
public void mouseClicked(int x, int y, int par3) {
@@ -98,9 +107,8 @@ public class BasicItemFilterGui implements IItemFilterGui {
@Override
public void updateButtons() {
-
ItemFilter activeFilter = filter;
-
+
if(isAdvanced) {
useNbtB.onGuiInit();
useNbtB.setSelected(activeFilter.isMatchNBT());
diff --git a/src/main/java/crazypants/enderio/conduit/gui/item/ItemSettings.java b/src/main/java/crazypants/enderio/conduit/gui/item/ItemSettings.java
index 18e9f9ec..db0daaf1 100644
--- a/src/main/java/crazypants/enderio/conduit/gui/item/ItemSettings.java
+++ b/src/main/java/crazypants/enderio/conduit/gui/item/ItemSettings.java
@@ -54,16 +54,16 @@ public class ItemSettings extends BaseSettingsPanel {
private String inputHeading;
private String outputHeading;
- private IconButtonEIO nextFilterB;
+ private final IconButtonEIO nextFilterB;
- private ToggleButtonEIO loopB;
- private ToggleButtonEIO roundRobinB;
+ private final ToggleButtonEIO loopB;
+ private final ToggleButtonEIO roundRobinB;
- private IconButtonEIO priUpB;
- private IconButtonEIO priDownB;
+ private final IconButtonEIO priUpB;
+ private final IconButtonEIO priDownB;
- private RedstoneModeButton rsB;
- private ColorButton colorB;
+ private final RedstoneModeButton rsB;
+ private final ColorButton colorB;
private ColorButton channelB;
@@ -74,9 +74,9 @@ public class ItemSettings extends BaseSettingsPanel {
private int priLeft;
private int priWidth = 32;
- private GuiToolTip priorityTooltip;
- private GuiToolTip speedUpgradeTooltip;
- private GuiToolTip filterUpgradeTooltip;
+ private final GuiToolTip priorityTooltip;
+ private final GuiToolTip speedUpgradeTooltip;
+ private final GuiToolTip filterUpgradeTooltip;
private IItemFilterGui filterGui;
@@ -150,12 +150,10 @@ public class ItemSettings extends BaseSettingsPanel {
priDownB.setSize(8, 8);
gui.getContainer().addFilterListener(new FilterChangeListener() {
-
@Override
public void onFilterChanged() {
filtersChanged();
}
-
});
}
@@ -180,9 +178,12 @@ public class ItemSettings extends BaseSettingsPanel {
}
private void updateGuiVisibility() {
-
deactivate();
+ createFilterGUI();
+ updateButtons();
+ }
+ private void createFilterGUI() {
boolean showInput = false;
boolean showOutput = false;
@@ -191,15 +192,10 @@ public class ItemSettings extends BaseSettingsPanel {
showInput = true;
} else if(mode == ConnectionMode.OUTPUT) {
showOutput = true;
-
} else if(mode == ConnectionMode.IN_OUT) {
-
- if(nextFilterB != null) {
- nextFilterB.onGuiInit();
- }
+ nextFilterB.onGuiInit();
showInput = inOutShowIn;
showOutput = !inOutShowIn;
-
}
if(!showInput && !showOutput) {
@@ -212,7 +208,6 @@ public class ItemSettings extends BaseSettingsPanel {
gui.getContainer().setOutputSlotsVisible(false);
if(activeFilter != null) {
filterGui = getFilterGui(activeFilter, true);
-
}
} else if(showOutput) {
activeFilter = itemConduit.getOutputFilter(gui.getDir());
@@ -223,54 +218,24 @@ public class ItemSettings extends BaseSettingsPanel {
filterGui = getFilterGui(activeFilter, false);
}
}
-
- updateButtons();
-
}
private void filtersChanged() {
- if(filterGui != null) {
- filterGui.deactivate();
- filterGui = null;
- }
+ deactiveFilterGUI();
+ createFilterGUI();
- ConnectionMode mode = con.getConnectionMode(gui.getDir());
- if(mode == ConnectionMode.DISABLED) {
- return;
- }
-
- boolean showInput = mode == ConnectionMode.INPUT || (mode == ConnectionMode.IN_OUT && inOutShowIn);
- if(showInput) {
- gui.getContainer().setInventorySlotsVisible(true);
- gui.getContainer().setInputSlotsVisible(true);
- gui.getContainer().setOutputSlotsVisible(false);
-
- activeFilter = itemConduit.getInputFilter(gui.getDir());
- if(activeFilter != null) {
- filterGui = getFilterGui(activeFilter, true);
- }
- } else {
- gui.getContainer().setInventorySlotsVisible(true);
- gui.getContainer().setInputSlotsVisible(false);
- gui.getContainer().setOutputSlotsVisible(true);
-
- activeFilter = itemConduit.getOutputFilter(gui.getDir());
- if(activeFilter != null) {
- filterGui = getFilterGui(activeFilter, false);
- }
-
- }
if(filterGui != null) {
filterGui.updateButtons();
}
-
}
private IItemFilterGui getFilterGui(IItemFilter filter, boolean isInput) {
//TODO: move to a factory
if(filter instanceof ItemFilter) {
ItemConduitFilterContainer cont = new ItemConduitFilterContainer(itemConduit, gui.getDir(), isInput);
- return new BasicItemFilterGui(gui, cont, !isInput);
+ BasicItemFilterGui basicItemFilterGui = new BasicItemFilterGui(gui, cont, !isInput);
+ basicItemFilterGui.createFilterSlots();
+ return basicItemFilterGui;
} else if(filter instanceof ExistingItemFilter) {
return new ExistingItemFilterGui(gui, itemConduit, isInput);
} else if(filter instanceof ModItemFilter) {
@@ -329,7 +294,6 @@ public class ItemSettings extends BaseSettingsPanel {
if(filterGui != null) {
filterGui.updateButtons();
}
-
}
@Override
@@ -343,37 +307,35 @@ public class ItemSettings extends BaseSettingsPanel {
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(itemConduit, gui.getDir()));
} else if(guiButton.id == ID_LOOP) {
itemConduit.setSelfFeedEnabled(gui.getDir(), !itemConduit.isSelfFeedEnabled(gui.getDir()));
- PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
+ sendFilterChange();
} else if(guiButton.id == ID_ROUND_ROBIN) {
itemConduit.setRoundRobinEnabled(gui.getDir(), !itemConduit.isRoundRobinEnabled(gui.getDir()));
- PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
+ sendFilterChange();
} else if(guiButton.id == ID_PRIORITY_UP) {
itemConduit.setOutputPriority(gui.getDir(), itemConduit.getOutputPriority(gui.getDir()) + 1);
- PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
+ sendFilterChange();
} else if(guiButton.id == ID_PRIORITY_DOWN) {
itemConduit.setOutputPriority(gui.getDir(), itemConduit.getOutputPriority(gui.getDir()) - 1);
- PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
+ sendFilterChange();
} else if(guiButton.id == ID_CHANNEL) {
DyeColor col = DyeColor.values()[channelB.getColorIndex()];
- boolean input;
if(isInputVisible()) {
- col = DyeColor.values()[channelB.getColorIndex()];
itemConduit.setInputColor(gui.getDir(), col);
- input = true;
} else {
- itemConduit.setOutputColor(gui.getDir(), DyeColor.values()[channelB.getColorIndex()]);
- input = false;
+ itemConduit.setOutputColor(gui.getDir(), col);
}
- PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
+ sendFilterChange();
}
if(filterGui != null) {
filterGui.actionPerformed(guiButton);
}
}
-
-
+
+ private void sendFilterChange() {
+ PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
+ }
@Override
public void mouseClicked(int x, int y, int par3) {
@@ -406,7 +368,6 @@ public class ItemSettings extends BaseSettingsPanel {
FontRenderer fr = gui.getFontRenderer();
String heading = getHeading();
- int headingWidth = fr.getStringWidth(heading);
int x = 0;
int rgb = ColorUtil.getRGB(Color.darkGray);
fr.drawString(heading, left + x, top, rgb);
@@ -433,7 +394,6 @@ public class ItemSettings extends BaseSettingsPanel {
if(filterGui != null) {
filterGui.renderCustomOptions(top, par1, par2, par3);
}
-
}
@Override
@@ -452,11 +412,15 @@ public class ItemSettings extends BaseSettingsPanel {
gui.removeToolTip(speedUpgradeTooltip);
gui.removeToolTip(filterUpgradeTooltip);
channelB.detach();
+ deactiveFilterGUI();
+ }
+ private void deactiveFilterGUI() {
if(filterGui != null) {
filterGui.deactivate();
filterGui = null;
}
+ gui.getGhostSlots().clear();
}
}
diff --git a/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java
index f435d24b..874f7d8e 100644
--- a/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java
@@ -8,13 +8,8 @@ import java.util.Map;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.conduit.AbstractConduitNetwork;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
-import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.item.NetworkedInventory.Target;
import crazypants.enderio.conduit.item.filter.IItemFilter;
import crazypants.util.BlockCoord;
@@ -22,8 +17,6 @@ import crazypants.util.Lang;
public class ItemConduitNetwork extends AbstractConduitNetwork {
- private long timeAtLastApply;
-
final List inventories = new ArrayList();
private final Map> invMap = new HashMap>();
@@ -33,15 +26,8 @@ public class ItemConduitNetwork extends AbstractConduitNetwork getBaseConduitType() {
- return IItemConduit.class;
+ super(IItemConduit.class, IItemConduit.class);
}
@Override
@@ -146,7 +132,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork 0 || !canExtract() || !con.isExtractionRedstoneConditionMet(conDir)) {
//do nothing
} else {
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ExistingItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ExistingItemFilter.java
index 7011f90a..c84a346d 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ExistingItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ExistingItemFilter.java
@@ -3,10 +3,8 @@ package crazypants.enderio.conduit.item.filter;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -14,6 +12,7 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.oredict.OreDictionary;
import crazypants.enderio.conduit.item.NetworkedInventory;
import crazypants.enderio.network.NetworkUtil;
+import crazypants.gui.GhostSlot;
import net.minecraft.inventory.IInventory;
public class ExistingItemFilter implements IItemFilter {
@@ -88,8 +87,7 @@ public class ExistingItemFilter implements IItemFilter {
}
@Override
- public List getSlots(int xOffset, int yOffset) {
- return Collections.emptyList();
+ public void createGhostSlots(List slots, int xOffset, int yOffset, Runnable cb) {
}
@Override
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/IItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/IItemFilter.java
index 44ac05b5..b096d78a 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/IItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/IItemFilter.java
@@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf;
import java.util.List;
-import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import crazypants.enderio.conduit.item.NetworkedInventory;
+import crazypants.gui.GhostSlot;
public interface IItemFilter {
@@ -27,7 +27,7 @@ public interface IItemFilter {
boolean isSticky();
- List getSlots(int xOffset, int yOffset);
+ void createGhostSlots(List slots, int xOffset, int yOffset, Runnable cb);
int getSlotCount();
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ItemBasicItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ItemBasicItemFilter.java
index 4c4bdd3b..99081d70 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ItemBasicItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ItemBasicItemFilter.java
@@ -53,23 +53,25 @@ public class ItemBasicItemFilter extends Item implements IItemFilterUpgrade {
filter = new ItemFilter(true);
}
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("filter")) {
- filter.readFromNBT(stack.stackTagCompound.getCompoundTag("filter"));
+ filter.readFromNBT(stack.stackTagCompound.getCompoundTag("filter"));
}
return filter;
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, 1);
return icons[damage];
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
-
+
icons[0] = IIconRegister.registerIcon("enderio:filterUpgradeBasic");
icons[1] = IIconRegister.registerIcon("enderio:filterUpgradeAdvanced");
-
+
}
@Override
@@ -80,6 +82,7 @@ public class ItemBasicItemFilter extends Item implements IItemFilterUpgrade {
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int j = 0; j < 2; ++j) {
par3List.add(new ItemStack(this, 1, j));
@@ -88,18 +91,18 @@ public class ItemBasicItemFilter extends Item implements IItemFilterUpgrade {
@Override
@SideOnly(Side.CLIENT)
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
- if(FilterRegister.isFilterSet(par1ItemStack)) {
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ if(FilterRegister.isFilterSet(par1ItemStack)) {
if(!TooltipAddera.instance.showAdvancedTooltips()) {
par3List.add(Lang.localize("itemConduitFilterUpgrade"));
TooltipAddera.instance.addShowDetailsTooltip(par3List);
} else {
par3List.add(EnumChatFormatting.ITALIC + Lang.localize("itemConduitFilterUpgrade.configured"));
par3List.add(EnumChatFormatting.ITALIC + Lang.localize("itemConduitFilterUpgrade.clearConfigMethod"));
- }
+ }
} else {
par3List.add(Lang.localize("itemConduitFilterUpgrade"));
}
}
-
+
}
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ItemExistingItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ItemExistingItemFilter.java
index eda825c6..3d100ae5 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ItemExistingItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ItemExistingItemFilter.java
@@ -4,9 +4,13 @@ import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -17,10 +21,6 @@ import crazypants.enderio.gui.IResourceTooltipProvider;
import crazypants.enderio.gui.TooltipAddera;
import crazypants.util.ItemUtil;
import crazypants.util.Lang;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.world.World;
public class ItemExistingItemFilter extends Item implements IItemFilterUpgrade, IResourceTooltipProvider {
@@ -76,6 +76,7 @@ public class ItemExistingItemFilter extends Item implements IItemFilterUpgrade,
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:existingItemFilter");
}
@@ -84,7 +85,7 @@ public class ItemExistingItemFilter extends Item implements IItemFilterUpgrade,
public String getUnlocalizedNameForTooltip(ItemStack stack) {
return getUnlocalizedName();
}
-
+
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ItemFilter.java
index 25f30209..810a238e 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ItemFilter.java
@@ -8,7 +8,6 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
@@ -16,7 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.oredict.OreDictionary;
import crazypants.enderio.conduit.item.NetworkedInventory;
import crazypants.enderio.network.NetworkUtil;
-import crazypants.gui.TemplateSlot;
+import crazypants.gui.GhostSlot;
public class ItemFilter implements IInventory, IItemFilter {
@@ -340,9 +339,7 @@ public class ItemFilter implements IInventory, IItemFilter {
}
@Override
- public List getSlots(int xOffset, int yOffset) {
- List result = new ArrayList();
-
+ public void createGhostSlots(List slots, int xOffset, int yOffset, Runnable cb) {
int topY = yOffset;
int leftX = xOffset;
int index = 0;
@@ -351,13 +348,12 @@ public class ItemFilter implements IInventory, IItemFilter {
for (int col = 0; col < 5; ++col) {
int x = leftX + col * 18;
int y = topY + row * 20;
- result.add(new TemplateSlot(this, index, x, y));
+ slots.add(new ItemFilterGhostSlot(index, x, y, cb));
index++;
}
- }
- return result;
+ }
}
-
+
@Override
public int getSlotCount() {
return getSizeInventory();
@@ -381,7 +377,31 @@ public class ItemFilter implements IInventory, IItemFilter {
// + sticky + ", items=" + Arrays.toString(items) + ", oreIds=" + Arrays.toString(oreIds) + ", isAdvanced=" + isAdvanced + "]";
return "ItemFilter [isAdvanced=" + isAdvanced + ", items=" + Arrays.toString(items) + "]";
}
-
-
+ class ItemFilterGhostSlot extends GhostSlot {
+ private final int slot;
+ private final Runnable cb;
+
+ ItemFilterGhostSlot(int slot, int x, int y, Runnable cb) {
+ this.x = x;
+ this.y = y;
+ this.slot = slot;
+ this.cb = cb;
+ }
+
+ @Override
+ public void putStack(ItemStack stack) {
+ if(stack != null) {
+ stack = stack.copy();
+ stack.stackSize = 1;
+ }
+ items[slot] = stack;
+ cb.run();
+ }
+
+ @Override
+ public ItemStack getStack() {
+ return items[slot];
+ }
+ }
}
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ItemModItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ItemModItemFilter.java
index 60f3452d..4a53db3a 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ItemModItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ItemModItemFilter.java
@@ -27,7 +27,7 @@ public class ItemModItemFilter extends Item implements IItemFilterUpgrade, IReso
protected ItemModItemFilter() {
setCreativeTab(EnderIOTab.tabEnderIO);
- setUnlocalizedName(ModObject.itemModItemFilter.unlocalisedName);
+ setUnlocalizedName(ModObject.itemModItemFilter.unlocalisedName);
setMaxDamage(0);
setMaxStackSize(64);
}
@@ -46,6 +46,7 @@ public class ItemModItemFilter extends Item implements IItemFilterUpgrade, IReso
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:modItemFilter");
}
@@ -54,15 +55,15 @@ public class ItemModItemFilter extends Item implements IItemFilterUpgrade, IReso
public String getUnlocalizedNameForTooltip(ItemStack stack) {
return getUnlocalizedName();
}
-
+
@Override
@SideOnly(Side.CLIENT)
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
- if(FilterRegister.isFilterSet(par1ItemStack)) {
- if(TooltipAddera.instance.showAdvancedTooltips()) {
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ if(FilterRegister.isFilterSet(par1ItemStack)) {
+ if(TooltipAddera.instance.showAdvancedTooltips()) {
par3List.add(EnumChatFormatting.ITALIC + Lang.localize("itemConduitFilterUpgrade.configured"));
par3List.add(EnumChatFormatting.ITALIC + Lang.localize("itemConduitFilterUpgrade.clearConfigMethod"));
- }
+ }
}
}
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ItemPowerItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ItemPowerItemFilter.java
index 03d2a206..d1fc9c62 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ItemPowerItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ItemPowerItemFilter.java
@@ -1,24 +1,14 @@
package crazypants.enderio.conduit.item.filter;
-import java.util.List;
-
import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.IIcon;
-import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
-import crazypants.enderio.conduit.item.FilterRegister;
import crazypants.enderio.gui.IResourceTooltipProvider;
-import crazypants.enderio.gui.TooltipAddera;
-import crazypants.util.Lang;
/**
*
@@ -54,6 +44,7 @@ public class ItemPowerItemFilter extends Item implements IItemFilterUpgrade, IRe
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:filterUpgradePower");
}
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/ModItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/ModItemFilter.java
index b441e75a..bc6e10c1 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/ModItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/ModItemFilter.java
@@ -2,16 +2,15 @@ package crazypants.enderio.conduit.item.filter;
import io.netty.buffer.ByteBuf;
-import java.util.Collections;
import java.util.List;
-import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import crazypants.enderio.conduit.item.NetworkedInventory;
import crazypants.enderio.network.NetworkUtil;
+import crazypants.gui.GhostSlot;
public class ModItemFilter implements IItemFilter {
@@ -91,8 +90,7 @@ public class ModItemFilter implements IItemFilter {
}
@Override
- public List getSlots(int xOffset, int yOffset) {
- return Collections.emptyList();
+ public void createGhostSlots(List slots, int xOffset, int yOffset, Runnable cb) {
}
@Override
diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/PowerItemFilter.java b/src/main/java/crazypants/enderio/conduit/item/filter/PowerItemFilter.java
index fa6d73ae..d2930696 100644
--- a/src/main/java/crazypants/enderio/conduit/item/filter/PowerItemFilter.java
+++ b/src/main/java/crazypants/enderio/conduit/item/filter/PowerItemFilter.java
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import crazypants.enderio.conduit.item.NetworkedInventory;
import crazypants.enderio.network.NetworkUtil;
+import crazypants.gui.GhostSlot;
/**
*
@@ -80,8 +81,7 @@ public class PowerItemFilter implements IItemFilter {
}
@Override
- public List getSlots(int xOffset, int yOffset) {
- return Collections.emptyList();
+ public void createGhostSlots(List slots, int xOffset, int yOffset, Runnable cb) {
}
@Override
diff --git a/src/main/java/crazypants/enderio/conduit/liquid/AbstractTankConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/liquid/AbstractTankConduitNetwork.java
index 51143ced..5ba25700 100644
--- a/src/main/java/crazypants/enderio/conduit/liquid/AbstractTankConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/liquid/AbstractTankConduitNetwork.java
@@ -9,18 +9,13 @@ public class AbstractTankConduitNetwork extends A
protected boolean fluidTypeLocked = false;
protected AbstractTankConduitNetwork(Class cl) {
- super(cl);
+ super(cl, ILiquidConduit.class);
}
public FluidStack getFluidType() {
return liquidType;
}
- @Override
- public Class getBaseConduitType() {
- return ILiquidConduit.class;
- }
-
@Override
public void addConduit(T con) {
super.addConduit(con);
diff --git a/src/main/java/crazypants/enderio/conduit/liquid/AdvancedLiquidConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/liquid/AdvancedLiquidConduitNetwork.java
index 2c3999c6..590071f5 100644
--- a/src/main/java/crazypants/enderio/conduit/liquid/AdvancedLiquidConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/liquid/AdvancedLiquidConduitNetwork.java
@@ -9,9 +9,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
import crazypants.enderio.conduit.IConduit;
import crazypants.util.BlockCoord;
import crazypants.util.FluidUtil;
@@ -24,27 +21,16 @@ public class AdvancedLiquidConduitNetwork extends AbstractTankConduitNetwork outputIterator;
- private int ticksActiveUnsynced;
-
private boolean lastSyncedActive = false;
private int lastSyncedVolume = -1;
- private long timeAtLastApply;
-
- private final InnerTickHandler tickHandler = new InnerTickHandler();
-
private int ticksEmpty;
public AdvancedLiquidConduitNetwork() {
super(AdvancedLiquidConduit.class);
}
- @Override
- public Class getBaseConduitType() {
- return ILiquidConduit.class;
- }
-
@Override
public void addConduit(AdvancedLiquidConduit con) {
tank.setCapacity(tank.getCapacity() + AdvancedLiquidConduit.CONDUIT_VOLUME);
@@ -108,24 +94,7 @@ public class AdvancedLiquidConduitNetwork extends AbstractTankConduitNetwork 0 && curTime != timeAtLastApply) {
- timeAtLastApply = curTime;
- ConduitNetworkTickHandler.instance.addListener(tickHandler);
- }
-
- }
-
- private void doTick() {
+ public void doNetworkTick() {
if(liquidType == null || outputs.isEmpty() || !tank.containsValidLiquid() || tank.isEmpty()) {
updateActiveState();
return;
@@ -172,7 +141,6 @@ public class AdvancedLiquidConduitNetwork extends AbstractTankConduitNetwork getBaseConduitType() {
- return ILiquidConduit.class;
+ super(EnderLiquidConduit.class, ILiquidConduit.class);
}
public void connectionChanged(EnderLiquidConduit con, ForgeDirection conDir) {
diff --git a/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java
index 2f5805ed..18bd3226 100644
--- a/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitNetwork.java
@@ -5,15 +5,10 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
-import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
import crazypants.enderio.conduit.ConduitUtil;
-import crazypants.enderio.conduit.IConduit;
import crazypants.util.BlockCoord;
public class LiquidConduitNetwork extends AbstractTankConduitNetwork {
@@ -22,8 +17,6 @@ public class LiquidConduitNetwork extends AbstractTankConduitNetwork 0 && curTime != timeAtLastApply) {
- timeAtLastApply = curTime;
- ConduitNetworkTickHandler.instance.addListener(tickHandler);
- }
- }
-
- private void doTick() {
-
+ public void doNetworkTick() {
List cons = getConduits();
if(cons == null || cons.isEmpty()) {
return;
@@ -114,7 +88,7 @@ public class LiquidConduitNetwork extends AbstractTankConduitNetwork {
public MEConduitNetwork() {
- super(IMEConduit.class);
+ super(IMEConduit.class, IMEConduit.class);
}
- @Override
- public Class getBaseConduitType() {
- return IMEConduit.class;
- }
-
- @Override
- public void addConduit(IMEConduit con) {
- // TODO Auto-generated method stub
- super.addConduit(con);
- }
}
\ No newline at end of file
diff --git a/src/main/java/crazypants/enderio/conduit/power/NetworkPowerManager.java b/src/main/java/crazypants/enderio/conduit/power/NetworkPowerManager.java
index 7fe43eab..f50adeec 100644
--- a/src/main/java/crazypants/enderio/conduit/power/NetworkPowerManager.java
+++ b/src/main/java/crazypants/enderio/conduit/power/NetworkPowerManager.java
@@ -11,10 +11,7 @@ import java.util.Set;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.Log;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler;
-import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.power.PowerConduitNetwork.ReceptorEntry;
import crazypants.enderio.config.Config;
@@ -23,11 +20,10 @@ import crazypants.enderio.power.IPowerStorage;
public class NetworkPowerManager {
- private PowerConduitNetwork network;
+ private final PowerConduitNetwork network;
int maxEnergyStored;
int energyStored;
- private int reserved;
private int updateRenderTicks = 10;
private int inactiveTicks = 100;
@@ -41,12 +37,10 @@ public class NetworkPowerManager {
private final Map powerTrackers = new HashMap();
- private PowerTracker networkPowerTracker = new PowerTracker();
+ private final PowerTracker networkPowerTracker = new PowerTracker();
private final CapBankSupply capSupply = new CapBankSupply();
- private InnerTickHandler applyPowerCallback = new InnerTickHandler();
-
public NetworkPowerManager(PowerConduitNetwork netowrk, World world) {
network = netowrk;
maxEnergyStored = 64;
@@ -113,8 +107,11 @@ public class NetworkPowerManager {
}
public void applyRecievedPower() {
- //want to do this after all conduits have updated so all connections have been checked etc
- ConduitNetworkTickHandler.instance.addListener(applyPowerCallback);
+ try {
+ doApplyRecievedPower();
+ } catch (Exception e) {
+ Log.warn("NetworkPowerManager: Exception thrown when updating power network " + e);
+ }
}
public void doApplyRecievedPower() {
@@ -458,9 +455,7 @@ public class NetworkPowerManager {
long use = (int) Math.ceil(ratio * entry.canExtract);
use = Math.min(use, amount);
use = Math.min(use, entry.canExtract);
- if(!entry.capBank.isCreative()) {
- entry.capBank.addEnergy((int) -use);
- }
+ entry.capBank.addEnergy((int) -use);
trackerRecieve(entry.emmiter, (int) use, true);
amount -= use;
if(amount == 0) {
@@ -479,9 +474,7 @@ public class NetworkPowerManager {
long add = (int) Math.ceil(ratio * entry.canFill);
add = Math.min(add, entry.canFill);
add = Math.min(add, amount);
- if(!entry.capBank.isCreative()) {
- entry.capBank.addEnergy((int) add);
- }
+ entry.capBank.addEnergy((int) add);
trackerSend(entry.emmiter, (int) add, true);
amount -= add;
if(amount == 0) {
@@ -527,20 +520,4 @@ public class NetworkPowerManager {
}
- private class InnerTickHandler implements TickListener {
-
- @Override
- public void tickStart(ServerTickEvent evt) {
- }
-
- @Override
- public void tickEnd(ServerTickEvent evt) {
- try {
- doApplyRecievedPower();
- } catch (Exception e) {
- Log.warn("NetworkPowerManager: Exception thrown when updating power network " + e);
- }
- }
- }
-
}
diff --git a/src/main/java/crazypants/enderio/conduit/power/PowerConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/power/PowerConduitNetwork.java
index 8d91bbf4..a43f6f77 100644
--- a/src/main/java/crazypants/enderio/conduit/power/PowerConduitNetwork.java
+++ b/src/main/java/crazypants/enderio/conduit/power/PowerConduitNetwork.java
@@ -11,7 +11,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import crazypants.enderio.conduit.AbstractConduitNetwork;
-import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.power.IPowerInterface;
import crazypants.util.BlockCoord;
@@ -22,12 +21,10 @@ public class PowerConduitNetwork extends AbstractConduitNetwork powerReceptors = new HashMap();
-
- private long timeAtLastApply = -1;
+ private final Map powerReceptors = new HashMap();
public PowerConduitNetwork() {
- super(IPowerConduit.class);
+ super(IPowerConduit.class, IPowerConduit.class);
}
@Override
@@ -68,11 +65,6 @@ public class PowerConduitNetwork extends AbstractConduitNetwork getBaseConduitType() {
- return IPowerConduit.class;
- }
-
public void powerReceptorAdded(IPowerConduit powerConduit, ForgeDirection direction, int x, int y, int z, IPowerInterface powerReceptor) {
if(powerReceptor == null) {
return;
@@ -108,19 +100,8 @@ public class PowerConduitNetwork extends AbstractConduitNetwork getBaseConduitType() {
- return IRedstoneConduit.class;
+ super(IRedstoneConduit.class, IRedstoneConduit.class);
}
@Override
@@ -144,9 +139,7 @@ public class RedstoneConduitNetwork extends AbstractConduitNetwork");
+ sb.append("<").append(te.xCoord).append(",").append(te.yCoord).append(",").append(te.zCoord).append(">");
}
return sb.toString();
}
diff --git a/src/main/java/crazypants/enderio/conduit/redstone/RedstoneSwitch.java b/src/main/java/crazypants/enderio/conduit/redstone/RedstoneSwitch.java
index 1a81def9..6d9c66e5 100644
--- a/src/main/java/crazypants/enderio/conduit/redstone/RedstoneSwitch.java
+++ b/src/main/java/crazypants/enderio/conduit/redstone/RedstoneSwitch.java
@@ -10,6 +10,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.RaytraceResult;
import crazypants.enderio.conduit.geom.CollidableComponent;
@@ -29,6 +31,7 @@ public class RedstoneSwitch extends RedstoneConduit {
private boolean isOn;
+ @SideOnly(Side.CLIENT)
public static void initIcons() {
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
diff --git a/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java b/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java
index 3dc10aab..bfaabe18 100644
--- a/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java
+++ b/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java
@@ -34,8 +34,8 @@ import crazypants.enderio.conduit.ConduitUtil;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
-import crazypants.enderio.conduit.RaytraceResult;
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
+import crazypants.enderio.conduit.RaytraceResult;
import crazypants.enderio.conduit.TileConduitBundle;
import crazypants.enderio.conduit.facade.BlockConduitFacade;
import crazypants.enderio.conduit.geom.CollidableComponent;
@@ -49,6 +49,7 @@ import crazypants.render.RenderUtil;
import crazypants.util.BlockCoord;
import crazypants.util.IBlockAccessWrapper;
+@SideOnly(Side.CLIENT)
public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
public ConduitBundleRenderer(float conduitScale) {
@@ -105,7 +106,7 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rb) {
- //If the MC renderer is told that an alpha pass is required ( see BlockConduitBundle.getRenderBlockPass() ) put
+ //If the MC renderer is told that an alpha pass is required ( see BlockConduitBundle.getRenderBlockPass() ) put
//nothing is actually added to the tessellator in this pass then the renderer will crash. We cant selectively
//enable the alpha pass based on state so the only work around is to ensure we always render something in this
//pass. Throwing in a polygon with a 0 area does the job
@@ -121,9 +122,9 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
boolean renderedFacade = renderFacade(x, y, z, rb, bundle, player);
- boolean renderConduit = !renderedFacade;
+ boolean renderConduit = !renderedFacade || ConduitUtil.isFacadeHidden(bundle, player);
- if(renderConduit) {
+ if(renderConduit && BlockConduitBundle.theRenderPass == 0) {
BlockCoord loc = bundle.getLocation();
float brightness;
if(!Config.updateLightingWhenHidingFacades && bundle.hasFacade() && ConduitUtil.isFacadeHidden(bundle, player)) {
@@ -141,7 +142,7 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
private boolean renderFacade(int x, int y, int z, RenderBlocks rb, IConduitBundle bundle, EntityClientPlayerMP player) {
boolean res = false;
if(bundle.hasFacade()) {
-
+ res = true;
Block facadeId = bundle.getFacadeId();
if(ConduitUtil.isFacadeHidden(bundle, player)) {
Tessellator.instance.setColorOpaque_F(1, 1, 1);
@@ -156,12 +157,10 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
rb.renderStandardBlock(facb, x, y, z);
}
facb.setBlockOverride(null);
-
bundle.setFacadeId(facadeId, false);
} else if(facadeId != null) {
bundle.setFacadeRenderAs(FacadeRenderState.FULL);
boolean isFacadeOpaque = facadeId.isOpaqueCube();
- res = isFacadeOpaque;
if((isFacadeOpaque && BlockConduitBundle.theRenderPass == 0) ||
(rb.hasOverrideBlockTexture() || (!isFacadeOpaque && BlockConduitBundle.theRenderPass == 1))) {
diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java
index 9c6ec817..9b172485 100644
--- a/src/main/java/crazypants/enderio/config/Config.java
+++ b/src/main/java/crazypants/enderio/config/Config.java
@@ -316,6 +316,7 @@ public final class Config {
public static int poweredSpawnerLevelTwoPowerPerTickRF = 500;
public static int poweredSpawnerLevelThreePowerPerTickRF = 1500;
public static int poweredSpawnerMaxPlayerDistance = 0;
+ public static int poweredSpawnerDespawnTimeSeconds = 120;
public static boolean poweredSpawnerUseVanillaSpawChecks = false;
public static double brokenSpawnerDropChance = 1;
public static String[] brokenSpawnerToolBlacklist = new String[] {
@@ -1000,6 +1001,8 @@ public final class Config {
"RF per tick for a level 3 spawner").getInt(poweredSpawnerLevelThreePowerPerTickRF);
poweredSpawnerMaxPlayerDistance = config.get(sectionSpawner.name, "poweredSpawnerMaxPlayerDistance", poweredSpawnerMaxPlayerDistance,
"Max distance of the closest player for the spawner to be active. A zero value will remove the player check").getInt(poweredSpawnerMaxPlayerDistance);
+ poweredSpawnerDespawnTimeSeconds = config.get(sectionSpawner.name, "poweredSpawnerDespawnTimeSeconds" , poweredSpawnerDespawnTimeSeconds,
+ "Number of seconds in which spawned entities are protected from despawning").getInt(poweredSpawnerDespawnTimeSeconds);
poweredSpawnerUseVanillaSpawChecks = config.get(sectionSpawner.name, "poweredSpawnerUseVanillaSpawChecks", poweredSpawnerUseVanillaSpawChecks,
"If true, regular spawn checks such as lighting level and dimension will be made before spawning mobs").getBoolean(poweredSpawnerUseVanillaSpawChecks);
brokenSpawnerDropChance = (float) config.get(sectionSpawner.name, "brokenSpawnerDropChance", brokenSpawnerDropChance,
diff --git a/src/main/java/crazypants/enderio/enderface/BlockEnderIO.java b/src/main/java/crazypants/enderio/enderface/BlockEnderIO.java
index 5f97fed9..fbfd2620 100644
--- a/src/main/java/crazypants/enderio/enderface/BlockEnderIO.java
+++ b/src/main/java/crazypants/enderio/enderface/BlockEnderIO.java
@@ -125,6 +125,7 @@ public class BlockEnderIO extends BlockEio implements IResourceTooltipProvider {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
super.registerBlockIcons(iIconRegister);
frameIcon = iIconRegister.registerIcon("enderio:enderIOFrame");
diff --git a/src/main/java/crazypants/enderio/enderface/EnderIoRenderer.java b/src/main/java/crazypants/enderio/enderface/EnderIoRenderer.java
index f3f93998..1bb17732 100644
--- a/src/main/java/crazypants/enderio/enderface/EnderIoRenderer.java
+++ b/src/main/java/crazypants/enderio/enderface/EnderIoRenderer.java
@@ -12,6 +12,8 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.teleport.anchor.TravelEntitySpecialRenderer;
import crazypants.render.BoundingBox;
@@ -21,6 +23,7 @@ import crazypants.vecmath.Matrix4d;
import crazypants.vecmath.VecmathUtil;
import crazypants.vecmath.Vector3d;
+@SideOnly(Side.CLIENT)
public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
private TravelEntitySpecialRenderer selectionRenderer = new TravelEntitySpecialRenderer() {
@@ -42,7 +45,7 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
-
+
EntityLivingBase entityPlayer = Minecraft.getMinecraft().thePlayer;
Matrix4d lookMat = RenderUtil.createBillboardMatrix(te, entityPlayer);
diff --git a/src/main/java/crazypants/enderio/enderface/ItemEnderface.java b/src/main/java/crazypants/enderio/enderface/ItemEnderface.java
index 8211f69a..6a0421b4 100644
--- a/src/main/java/crazypants/enderio/enderface/ItemEnderface.java
+++ b/src/main/java/crazypants/enderio/enderface/ItemEnderface.java
@@ -8,6 +8,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
@@ -38,11 +40,13 @@ public class ItemEnderface extends Item implements IGuiHandler {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:enderface");
}
@Override
+ @SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack par1ItemStack, int pass) {
return true;
}
diff --git a/src/main/java/crazypants/enderio/fluid/BlockFluidEio.java b/src/main/java/crazypants/enderio/fluid/BlockFluidEio.java
index 5b79ed25..151cead3 100644
--- a/src/main/java/crazypants/enderio/fluid/BlockFluidEio.java
+++ b/src/main/java/crazypants/enderio/fluid/BlockFluidEio.java
@@ -26,7 +26,7 @@ public class BlockFluidEio extends BlockFluidClassic {
public static BlockFluidEio create(Fluid fluid, Material material) {
BlockFluidEio res = new BlockFluidEio(fluid, material);
res.init();
- fluid.setBlock(res);
+ fluid.setBlock(res);
return res;
}
@@ -46,6 +46,7 @@ public class BlockFluidEio extends BlockFluidClassic {
protected IIcon[] icons;
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side != 0 && side != 1 ? this.icons[1] : this.icons[0];
}
diff --git a/src/main/java/crazypants/enderio/item/ItemMagnet.java b/src/main/java/crazypants/enderio/item/ItemMagnet.java
index 19639ebd..5b244d76 100644
--- a/src/main/java/crazypants/enderio/item/ItemMagnet.java
+++ b/src/main/java/crazypants/enderio/item/ItemMagnet.java
@@ -23,9 +23,9 @@ import crazypants.enderio.machine.power.PowerDisplayUtil;
import crazypants.util.ItemUtil;
public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipProvider {
-
+
private static final String ACTIVE_KEY = "magnetActive";
-
+
public static void setActive(ItemStack item, boolean active) {
if(item == null) {
return;
@@ -33,7 +33,7 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
NBTTagCompound nbt = ItemUtil.getOrCreateNBT(item);
nbt.setBoolean(ACTIVE_KEY, active);
}
-
+
public static boolean isActive(ItemStack item) {
if(item == null) {
return false;
@@ -44,29 +44,29 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
if(!item.stackTagCompound.hasKey(ACTIVE_KEY)) {
return false;
}
- return item.stackTagCompound.getBoolean(ACTIVE_KEY);
+ return item.stackTagCompound.getBoolean(ACTIVE_KEY);
}
-
- public static boolean hasPower(ItemStack itemStack) {
+
+ public static boolean hasPower(ItemStack itemStack) {
return EnderIO.itemMagnet.getEnergyStored(itemStack) > 0;
}
public static void drainPerSecondPower(ItemStack itemStack) {
- EnderIO.itemMagnet.extractEnergy(itemStack, Config.magnetPowerUsePerSecondRF, false);
+ EnderIO.itemMagnet.extractEnergy(itemStack, Config.magnetPowerUsePerSecondRF, false);
}
- public static ItemMagnet create() {
+ public static ItemMagnet create() {
ItemMagnet result = new ItemMagnet();
- result.init();
- FMLCommonHandler.instance().bus().register(new MagnetController());
+ result.init();
+ FMLCommonHandler.instance().bus().register(new MagnetController());
return result;
}
-
+
protected ItemMagnet() {
super(Config.magnetPowerCapacityRF, Config.magnetPowerCapacityRF/100);
setCreativeTab(EnderIOTab.tabEnderIO);
- setUnlocalizedName(ModObject.itemMagnet.unlocalisedName);
+ setUnlocalizedName(ModObject.itemMagnet.unlocalisedName);
setMaxDamage(16);
setMaxStackSize(1);
setHasSubtypes(true);
@@ -81,7 +81,7 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:magnet");
}
-
+
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) {
@@ -93,7 +93,7 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
setEnergy(is, 0);
par3List.add(is);
}
-
+
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
@@ -102,17 +102,18 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
+ PowerDisplayUtil.formatPower(getMaxEnergyStored(itemStack)) + " " + PowerDisplayUtil.abrevation();
list.add(str);
}
-
+
@Override
- public boolean hasEffect(ItemStack item, int pass) {
+ @SideOnly(Side.CLIENT)
+ public boolean hasEffect(ItemStack item, int pass) {
return isActive(item);
}
-
+
@Override
public void onCreated(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
setEnergy(itemStack, 0);
}
-
+
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
int res = super.receiveEnergy(container, maxReceive, simulate);
@@ -151,10 +152,10 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
@Override
- public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
- if(player.isSneaking()) {
+ public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
+ if(player.isSneaking()) {
setActive(equipped, !isActive(equipped));
- }
+ }
return equipped;
}
diff --git a/src/main/java/crazypants/enderio/item/ItemSoulVessel.java b/src/main/java/crazypants/enderio/item/ItemSoulVessel.java
index e33de3a7..c8db0778 100644
--- a/src/main/java/crazypants/enderio/item/ItemSoulVessel.java
+++ b/src/main/java/crazypants/enderio/item/ItemSoulVessel.java
@@ -47,7 +47,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
}
private IIcon filledIcon;
-
+
private List blackList;
protected ItemSoulVessel() {
@@ -79,21 +79,22 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
public IIcon getIcon(ItemStack item, int arg1, EntityPlayer arg2, ItemStack arg3, int arg4) {
if(containsSoul(item)) {
return filledIcon;
- }
- return itemIcon;
- }
+ }
+ return itemIcon;
+ }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack item) {
if(containsSoul(item)) {
return filledIcon;
- }
+ }
return itemIcon;
}
@Override
- public boolean hasEffect(ItemStack item, int pass) {
+ @SideOnly(Side.CLIENT)
+ public boolean hasEffect(ItemStack item, int pass) {
return containsSoul(item);
}
@@ -114,7 +115,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
}
Entity mob;
- NBTTagCompound root = itemstack.stackTagCompound;
+ NBTTagCompound root = itemstack.stackTagCompound;
if(root.hasKey("isStub")) {
String entityId = root.getString("id");
mob = EntityList.createEntityByName(entityId, world);
@@ -122,18 +123,18 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
mob = EntityList.createEntityFromNBT(root, world);
}
if (mob == null) {
- return true;
+ return true;
}
mob.readFromNBT(root);
-
- Block blk = world.getBlock(x,y,z);
+
+ Block blk = world.getBlock(x,y,z);
double spawnX = x + Facing.offsetsXForSide[side] + 0.5;
double spawnY = y + Facing.offsetsYForSide[side];
double spawnZ = z + Facing.offsetsZForSide[side] + 0.5;
if(side == ForgeDirection.UP.ordinal() && (blk instanceof BlockFence || blk instanceof BlockWall)) {
spawnY += 0.5;
- }
- mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);
+ }
+ mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);
boolean spaceClear = world.checkNoEntityCollision(mob.boundingBox)
&& world.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty();
@@ -145,26 +146,26 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
((EntityLiving)mob).setCustomNameTag(itemstack.getDisplayName());
}
- world.spawnEntityInWorld(mob);
+ world.spawnEntityInWorld(mob);
if(mob instanceof EntityLiving) {
((EntityLiving)mob).playLivingSound();
}
-
+
Entity riddenByEntity = mob.riddenByEntity;
- while(riddenByEntity != null) {
- riddenByEntity.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
+ while(riddenByEntity != null) {
+ riddenByEntity.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
world.spawnEntityInWorld(riddenByEntity);
if(riddenByEntity instanceof EntityLiving) {
((EntityLiving)riddenByEntity).playLivingSound();
- }
+ }
riddenByEntity = riddenByEntity.riddenByEntity;
}
-
-
+
+
if(player == null || !player.capabilities.isCreativeMode) {
itemstack.setTagCompound(null);
}
-
+
return true;
}
@@ -181,20 +182,20 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
if(entity instanceof EntityPlayer) {
return false;
}
-
+
String entityId = EntityList.getEntityString(entity);
if(isBlackListed(entityId)) {
return false;
}
-
+
if(!Config.soulVesselCapturesBosses && entity instanceof IBossDisplayData) {
return false;
}
-
+
NBTTagCompound root = new NBTTagCompound();
- root.setString("id", entityId);
+ root.setString("id", entityId);
entity.writeToNBT(root);
-
+
ItemStack capturedMobVessel = new ItemStack(EnderIO.itemSoulVessel);
capturedMobVessel.setTagCompound(root);
setDisplayNameFromEntityNameTag(capturedMobVessel, entity);
@@ -222,7 +223,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
}
return false;
}
-
+
public ItemStack createVesselWithEntityStub(String entityId) {
NBTTagCompound root = new NBTTagCompound();
root.setString("id", entityId);
@@ -265,10 +266,10 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
}
if(item.getItem() != this) {
return false;
- }
- return item.stackTagCompound != null && item.stackTagCompound.hasKey("id");
+ }
+ return item.stackTagCompound != null && item.stackTagCompound.hasKey("id");
}
-
+
public String getMobTypeFromStack(ItemStack item) {
if(!containsSoul(item)) {
return null;
@@ -355,7 +356,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName(itemStack);
}
-
+
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
@@ -393,6 +394,6 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
}
}
-
+
}
diff --git a/src/main/java/crazypants/enderio/item/ItemYetaWrench.java b/src/main/java/crazypants/enderio/item/ItemYetaWrench.java
index 73ee1139..ef6f4572 100644
--- a/src/main/java/crazypants/enderio/item/ItemYetaWrench.java
+++ b/src/main/java/crazypants/enderio/item/ItemYetaWrench.java
@@ -23,7 +23,6 @@ import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.enderio.api.tool.IConduitControl;
import crazypants.enderio.api.tool.ITool;
-import crazypants.enderio.conduit.BlockConduitBundle;
import crazypants.enderio.conduit.ConduitDisplayMode;
import crazypants.enderio.config.Config;
import crazypants.enderio.gui.IAdvancedTooltipProvider;
@@ -105,6 +104,7 @@ public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdv
}
@Override
+ @SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
@@ -122,30 +122,30 @@ public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdv
@Override
public void used(ItemStack stack, EntityPlayer player, int x, int y, int z) {
}
-
+
@Override
public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) {
ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(stack);
return curMode != ConduitDisplayMode.NONE;
}
-
+
@Override
public boolean showOverlay(ItemStack stack, EntityPlayer player) {
return true;
}
/* IAdvancedTooltipProvider */
-
+
@SuppressWarnings("rawtypes")
@Override
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
}
-
+
@SuppressWarnings("rawtypes")
@Override
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
}
-
+
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
@@ -158,7 +158,7 @@ public class ItemYetaWrench extends Item implements ITool, IConduitControl, IAdv
}
/* InvocationHandler */
-
+
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
System.out.println("ItemYetaWrench.invoke: method = " + method.getName());
diff --git a/src/main/java/crazypants/enderio/item/KeyTracker.java b/src/main/java/crazypants/enderio/item/KeyTracker.java
index 0424f85b..39d45c09 100644
--- a/src/main/java/crazypants/enderio/item/KeyTracker.java
+++ b/src/main/java/crazypants/enderio/item/KeyTracker.java
@@ -14,17 +14,17 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
import crazypants.enderio.EnderIO;
-import crazypants.enderio.item.darksteel.DarkSteelItems;
import crazypants.enderio.api.tool.IConduitControl;
import crazypants.enderio.conduit.ConduitDisplayMode;
import crazypants.enderio.item.darksteel.DarkSteelController;
-import crazypants.enderio.item.darksteel.GogglesOfRevealingUpgrade;
+import crazypants.enderio.item.darksteel.DarkSteelItems;
import crazypants.enderio.item.darksteel.JumpUpgrade;
import crazypants.enderio.item.darksteel.PacketUpgradeState;
import crazypants.enderio.item.darksteel.SoundDetector;
import crazypants.enderio.item.darksteel.SoundDetectorUpgrade;
import crazypants.enderio.item.darksteel.SpeedUpgrade;
import crazypants.enderio.network.PacketHandler;
+import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
import crazypants.util.Lang;
public class KeyTracker {
diff --git a/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java b/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java
index c7f2ce8f..1f4ebe7f 100644
--- a/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java
+++ b/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java
@@ -19,6 +19,8 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import crazypants.enderio.EnderIO;
import crazypants.enderio.material.Alloy;
+import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
+import crazypants.enderio.thaumcraft.ThaumcraftCompat;
import crazypants.util.Lang;
public class DarkSteelRecipeManager {
@@ -47,7 +49,7 @@ public class DarkSteelRecipeManager {
upgrades.add(SolarUpgrade.SOLAR_ONE);
upgrades.add(SolarUpgrade.SOLAR_TWO);
if(Loader.isModLoaded("Thaumcraft")) {
- upgrades.add(GogglesOfRevealingUpgrade.INSTANCE);
+ ThaumcraftCompat.loadUpgrades(upgrades);
}
if(Loader.isModLoaded("Forestry")) {
upgrades.add(NaturalistEyeUpgrade.INSTANCE);
diff --git a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java
index 1c9bdcb3..bf009d4c 100644
--- a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java
+++ b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java
@@ -30,6 +30,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.config.Config;
import crazypants.enderio.gui.IAdvancedTooltipProvider;
+import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
import crazypants.util.ItemUtil;
import crazypants.util.Lang;
import forestry.api.apiculture.IArmorApiarist;
diff --git a/src/main/java/crazypants/enderio/item/darksteel/ItemGliderWing.java b/src/main/java/crazypants/enderio/item/darksteel/ItemGliderWing.java
index a9b73e7e..c467bcab 100644
--- a/src/main/java/crazypants/enderio/item/darksteel/ItemGliderWing.java
+++ b/src/main/java/crazypants/enderio/item/darksteel/ItemGliderWing.java
@@ -2,24 +2,20 @@ package crazypants.enderio.item.darksteel;
import java.util.List;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.enderio.gui.IResourceTooltipProvider;
-import crazypants.enderio.material.ItemCapacitor;
import crazypants.enderio.power.BasicCapacitor;
import crazypants.enderio.power.Capacitors;
-import crazypants.enderio.power.ICapacitor;
-import crazypants.util.Lang;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.IIcon;
-import net.minecraft.util.MathHelper;
public class ItemGliderWing extends Item implements IResourceTooltipProvider {
@@ -46,6 +42,7 @@ public class ItemGliderWing extends Item implements IResourceTooltipProvider {
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, 1);
if(damage == 0) {
@@ -55,6 +52,7 @@ public class ItemGliderWing extends Item implements IResourceTooltipProvider {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
itemIcon = register.registerIcon("enderio:itemGliderWing");
wingsIcon = register.registerIcon("enderio:itemGliderWings");
@@ -71,6 +69,7 @@ public class ItemGliderWing extends Item implements IResourceTooltipProvider {
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int j = 0; j < 2; ++j) {
par3List.add(new ItemStack(par1, 1, j));
@@ -82,7 +81,7 @@ public class ItemGliderWing extends Item implements IResourceTooltipProvider {
return getUnlocalizedName(itemStack);
}
-
+
// @Override
// @SideOnly(Side.CLIENT)
// public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
@@ -91,5 +90,5 @@ public class ItemGliderWing extends Item implements IResourceTooltipProvider {
// }
//
// }
-
+
}
diff --git a/src/main/java/crazypants/enderio/item/darksteel/SoundRenderer.java b/src/main/java/crazypants/enderio/item/darksteel/SoundRenderer.java
index 9f7f5d9c..9b9d9856 100644
--- a/src/main/java/crazypants/enderio/item/darksteel/SoundRenderer.java
+++ b/src/main/java/crazypants/enderio/item/darksteel/SoundRenderer.java
@@ -8,25 +8,28 @@ import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.gui.IconEIO;
+@SideOnly(Side.CLIENT)
public class SoundRenderer extends RenderEntity {
@Override
public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
SoundEntity se = ((SoundEntity) entity);
-
+
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
+
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
float alpha = 0.5f;
-
+
GL11.glColor4f(1, 1, 1, alpha);
float scale = se.lifeSpan / 20f;
@@ -36,9 +39,9 @@ public class SoundRenderer extends RenderEntity {
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glRotatef(-player.rotationYaw, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(player.rotationPitch, 1.0F, 0.0F, 0.0F);
-
+
double size = 0.5 * se.lifeSpan / 20f;
-
+
IconEIO.SOUND.renderIcon(-size/2, -size/2, size,size,0,true,true);
GL11.glPopAttrib();
diff --git a/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java b/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java
index fc987b33..2e3345ae 100644
--- a/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java
+++ b/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java
@@ -1,6 +1,5 @@
package crazypants.enderio.item.skull;
-import cpw.mods.fml.common.Optional;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
@@ -9,12 +8,13 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import thaumcraft.api.crafting.IInfusionStabiliser;
+import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.BlockEio;
import crazypants.enderio.ModObject;
-import thaumcraft.api.crafting.IInfusionStabiliser;
@Optional.Interface(iface = "thaumcraft.api.crafting.IInfusionStabiliser", modid = "Thaumcraft")
public class BlockEndermanSkull extends BlockEio implements IInfusionStabiliser {
@@ -22,22 +22,22 @@ public class BlockEndermanSkull extends BlockEio implements IInfusionStabiliser
public static int renderId = -1;
public enum SkullType {
-
+
BASE("base",false),
REANIMATED("reanimated",true),
TORMENTED("tormented",false),
REANIMATED_TORMENTED("reanimatedTormented",true);
-
+
final String name;
final boolean showEyes;
-
-
+
+
SkullType(String name, boolean showEyes) {
this.name = name;
this.showEyes = showEyes;
}
}
-
+
public static BlockEndermanSkull create() {
BlockEndermanSkull res = new BlockEndermanSkull();
res.init();
@@ -53,18 +53,19 @@ public class BlockEndermanSkull extends BlockEio implements IInfusionStabiliser
super(ModObject.blockEndermanSkull.unlocalisedName, TileEndermanSkull.class, Material.circuits);
setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
}
-
-
+
+
@Override
protected void init() {
- GameRegistry.registerBlock(this, ItemEndermanSkull.class, name);
- GameRegistry.registerTileEntity(teClass, name + "TileEntity");
+ GameRegistry.registerBlock(this, ItemEndermanSkull.class, name);
+ GameRegistry.registerTileEntity(teClass, name + "TileEntity");
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
frontIcon = iIconRegister.registerIcon("enderio:endermanSkullFront");
frontIconEyes = iIconRegister.registerIcon("enderio:endermanSkullFrontEyes");
@@ -86,18 +87,22 @@ public class BlockEndermanSkull extends BlockEio implements IInfusionStabiliser
return sideIcon;
}
+ @Override
public int getRenderType() {
return renderId;
}
+ @Override
public boolean isOpaqueCube() {
return false;
}
+ @Override
public boolean renderAsNormalBlock() {
return false;
}
+ @Override
@SideOnly(Side.CLIENT)
public String getItemIconName() {
return "enderio:endermanSkull";
@@ -105,9 +110,9 @@ public class BlockEndermanSkull extends BlockEio implements IInfusionStabiliser
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
-
- int inc = MathHelper.floor_double((double)(player.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
- float facingYaw = -22.5f * inc;
+
+ int inc = MathHelper.floor_double(player.rotationYaw * 16.0F / 360.0F + 0.5D) & 15;
+ float facingYaw = -22.5f * inc;
TileEndermanSkull te = (TileEndermanSkull) world.getTileEntity(x, y, z);
te.setYaw(facingYaw);
if(world.isRemote) {
diff --git a/src/main/java/crazypants/enderio/item/skull/ItemEndermanSkull.java b/src/main/java/crazypants/enderio/item/skull/ItemEndermanSkull.java
index 39c22fd8..0f6ad521 100644
--- a/src/main/java/crazypants/enderio/item/skull/ItemEndermanSkull.java
+++ b/src/main/java/crazypants/enderio/item/skull/ItemEndermanSkull.java
@@ -2,16 +2,16 @@ package crazypants.enderio.item.skull;
import java.util.List;
-import crazypants.enderio.EnderIOTab;
-import crazypants.enderio.item.skull.BlockEndermanSkull.SkullType;
-import crazypants.enderio.material.BlockFusedQuartz;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
-import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBlockWithMetadata;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import crazypants.enderio.EnderIOTab;
+import crazypants.enderio.item.skull.BlockEndermanSkull.SkullType;
public class ItemEndermanSkull extends ItemBlockWithMetadata {
@@ -19,7 +19,7 @@ public class ItemEndermanSkull extends ItemBlockWithMetadata {
super(block, block);
setCreativeTab(EnderIOTab.tabEnderIO);
}
-
+
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int meta = par1ItemStack.getItemDamage();
@@ -29,6 +29,7 @@ public class ItemEndermanSkull extends ItemBlockWithMetadata {
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int j = 0; j < SkullType.values().length; ++j) {
if(!SkullType.values()[j].showEyes) {
diff --git a/src/main/java/crazypants/enderio/machine/alloy/BlockAlloySmelter.java b/src/main/java/crazypants/enderio/machine/alloy/BlockAlloySmelter.java
index 7658041d..39a98c00 100644
--- a/src/main/java/crazypants/enderio/machine/alloy/BlockAlloySmelter.java
+++ b/src/main/java/crazypants/enderio/machine/alloy/BlockAlloySmelter.java
@@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
@@ -31,6 +32,7 @@ public class BlockAlloySmelter extends AbstractMachineBlock {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
super.registerBlockIcons(iIconRegister);
vanillaSmeltingOn = iIconRegister.registerIcon("enderio:furnaceSmeltingOn");
diff --git a/src/main/java/crazypants/enderio/machine/alloy/TileAlloySmelter.java b/src/main/java/crazypants/enderio/machine/alloy/TileAlloySmelter.java
index 131fdf16..e1dbdc4b 100644
--- a/src/main/java/crazypants/enderio/machine/alloy/TileAlloySmelter.java
+++ b/src/main/java/crazypants/enderio/machine/alloy/TileAlloySmelter.java
@@ -12,7 +12,6 @@ import crazypants.enderio.machine.IMachineRecipe.ResultStack;
import crazypants.enderio.machine.MachineRecipeInput;
import crazypants.enderio.machine.MachineRecipeRegistry;
import crazypants.enderio.machine.SlotDefinition;
-import crazypants.enderio.machine.generator.stirling.TileEntityStirlingGenerator;
import crazypants.enderio.machine.recipe.ManyToOneMachineRecipe;
public class TileAlloySmelter extends AbstractPoweredTaskEntity {
@@ -186,15 +185,19 @@ public class TileAlloySmelter extends AbstractPoweredTaskEntity {
}
@Override
- public void readCustomNBT(NBTTagCompound nbtRoot) {
- super.readCustomNBT(nbtRoot);
+ public void readCommon(NBTTagCompound nbtRoot) {
+ super.readCommon(nbtRoot);
short mb = nbtRoot.getShort("mode");
- mode = Mode.values()[mb];
+ Mode[] modes = Mode.values();
+ if(mb < 0 || mb >= modes.length) {
+ mb = 0;
+ }
+ mode = modes[mb];
}
@Override
- public void writeCustomNBT(NBTTagCompound nbtRoot) {
- super.writeCustomNBT(nbtRoot);
+ public void writeCommon(NBTTagCompound nbtRoot) {
+ super.writeCommon(nbtRoot);
nbtRoot.setShort("mode", (short) mode.ordinal());
}
diff --git a/src/main/java/crazypants/enderio/machine/attractor/ObeliskRenderer.java b/src/main/java/crazypants/enderio/machine/attractor/ObeliskRenderer.java
index f2fc8cb7..0856056f 100644
--- a/src/main/java/crazypants/enderio/machine/attractor/ObeliskRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/attractor/ObeliskRenderer.java
@@ -22,6 +22,8 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.render.BoundingBox;
import crazypants.render.CubeRenderer;
@@ -32,12 +34,13 @@ import crazypants.vecmath.Vector3f;
import crazypants.vecmath.Vertex;
import static org.lwjgl.opengl.GL11.*;
+@SideOnly(Side.CLIENT)
public class ObeliskRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler, IItemRenderer {
private VertXForm xform = new VertXForm();
private VertXForm2 xform2 = new VertXForm2();
private ItemStack floatingStack;
-
+
private Random rand = new Random();
public ObeliskRenderer(ItemStack itemStack) {
@@ -80,7 +83,7 @@ public class ObeliskRenderer extends TileEntitySpecialRend
default:
break;
}
-
+
renderInventoryBlock(EnderIO.blockAttractor, item.getItemDamage(), 0, (RenderBlocks) data[0]);
Timer t = RenderUtil.getTimer();
renderItemStack(null, Minecraft.getMinecraft().theWorld, 0, 0, 0, t.renderPartialTicks);
@@ -99,18 +102,19 @@ public class ObeliskRenderer extends TileEntitySpecialRend
int l1 = l % 65536;
int l2 = l / 65536;
Tessellator.instance.setColorOpaque_F(f, f, f);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
renderItemStack((T) te, world, x, y, z, tick);
}
private void renderItemStack(T te, World world, double x, double y, double z, float tick) {
if(ei == null) {
- ei = new EntityItem(world, 0, 0, 0, getFloatingItem((T) te));
+ ei = new EntityItem(world, 0, 0, 0, getFloatingItem(te));
}
ei.setEntityItemStack(getFloatingItem(te));
- ei.hoverStart = (float) world.getTotalWorldTime() * 0.05f + (tick * 0.05f);
+ ei.hoverStart = world.getTotalWorldTime() * 0.05f + (tick * 0.05f);
+ ei.age = 0;
glPushMatrix();
glPushAttrib(GL_ALL_ATTRIB_BITS);
@@ -132,7 +136,7 @@ public class ObeliskRenderer extends TileEntitySpecialRend
glPopAttrib();
glPopMatrix();
}
-
+
/**
* @param te CAN BE NULL
*/
@@ -156,7 +160,7 @@ public class ObeliskRenderer extends TileEntitySpecialRend
BoundingBox bb = BoundingBox.UNIT_CUBE;
Tessellator.instance.addTranslation(x, y, z);
-
+
IIcon icon = EnderIO.blockAttractor.getOnIcon();
if(world != null) {
icon = block.getIcon(world, x, y, z, 0);
diff --git a/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java b/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java
index 396f8ab7..8647fd5e 100644
--- a/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java
+++ b/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java
@@ -1,7 +1,5 @@
package crazypants.enderio.machine.buffer;
-import java.util.ArrayList;
-
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
@@ -13,9 +11,6 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
-
-import com.google.common.collect.Lists;
-
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -94,11 +89,13 @@ public class BlockBuffer extends AbstractMachineBlock implements IFa
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(int blockSide, int blockMeta) {
return blockSide > 1 ? textures[blockMeta] : super.getIcon(blockSide, blockMeta);
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileBuffer) {
@@ -161,8 +158,11 @@ public class BlockBuffer extends AbstractMachineBlock implements IFa
if(paintSource == null) {
return new ResultStack[0];
}
- return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(MachineRecipeInput.getInputForSlot(0, inputs).copy(),
- Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
+ ItemStack target = MachineRecipeInput.getInputForSlot(0, inputs);
+ target = target.copy();
+ target.stackSize = 1;
+ return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(target, Block.getBlockFromItem(paintSource.getItem()),
+ paintSource.getItemDamage())) };
}
}
diff --git a/src/main/java/crazypants/enderio/machine/buffer/BlockItemBuffer.java b/src/main/java/crazypants/enderio/machine/buffer/BlockItemBuffer.java
index e2326ba8..5489d14a 100644
--- a/src/main/java/crazypants/enderio/machine/buffer/BlockItemBuffer.java
+++ b/src/main/java/crazypants/enderio/machine/buffer/BlockItemBuffer.java
@@ -10,6 +10,8 @@ import net.minecraft.item.ItemBlockWithMetadata;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.ModObject;
@@ -20,11 +22,11 @@ public class BlockItemBuffer extends ItemBlockWithMetadata {
POWER(false, true, false),
OMNI(true, true, false),
CREATIVE(true, true, true);
-
+
final boolean hasInventory;
final boolean hasPower;
final boolean isCreative;
-
+
private Type(boolean hasInventory, boolean hasPower, boolean isCreative) {
this.hasInventory = hasInventory;
this.hasPower = hasPower;
@@ -34,7 +36,7 @@ public class BlockItemBuffer extends ItemBlockWithMetadata {
public static Type get(TileBuffer buffer) {
return !buffer.hasPower() ? ITEM : !buffer.hasInventory() ? POWER : !buffer.isCreative() ? OMNI : CREATIVE;
}
-
+
public String getUnlocalizedName() {
return "tile." + ModObject.blockBuffer.unlocalisedName + "." + name().toLowerCase();
}
@@ -43,24 +45,25 @@ public class BlockItemBuffer extends ItemBlockWithMetadata {
return new ItemStack(EnderIO.blockBuffer, 1, type.ordinal());
}
}
-
+
public BlockItemBuffer(Block block) {
super(block, block);
}
-
+
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (Type type : Type.values()) {
list.add(new ItemStack(item, 1, type.ordinal()));
}
}
-
+
@Override
public String getUnlocalizedName(ItemStack stack) {
return Type.values()[stack.getItemDamage()].getUnlocalizedName();
}
-
+
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
diff --git a/src/main/java/crazypants/enderio/machine/buffer/TileBuffer.java b/src/main/java/crazypants/enderio/machine/buffer/TileBuffer.java
index cdb9ef31..b7d780f8 100644
--- a/src/main/java/crazypants/enderio/machine/buffer/TileBuffer.java
+++ b/src/main/java/crazypants/enderio/machine/buffer/TileBuffer.java
@@ -63,7 +63,7 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
if (!isCreative()) {
setEnergyStored(getEnergyStored() - transmitted);
}
- return transmitted > 0;
+ return false;
}
@Override
@@ -106,7 +106,7 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return hasPower() && getIoMode(from).canRecieveInput() ? super.receiveEnergy(from, maxReceive, isCreative() || simulate) : 0;
}
-
+
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return 0;
diff --git a/src/main/java/crazypants/enderio/machine/capbank/BlockCapBank.java b/src/main/java/crazypants/enderio/machine/capbank/BlockCapBank.java
index e1ce8eb8..1184043f 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/BlockCapBank.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/BlockCapBank.java
@@ -272,6 +272,7 @@ public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTool
}
@Override
+ @SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
Block i1 = par1IBlockAccess.getBlock(par2, par3, par4);
return i1 == this ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
diff --git a/src/main/java/crazypants/enderio/machine/capbank/GuiCapBank.java b/src/main/java/crazypants/enderio/machine/capbank/GuiCapBank.java
index 9421c96c..ab6e8f89 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/GuiCapBank.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/GuiCapBank.java
@@ -20,7 +20,6 @@ import crazypants.enderio.machine.IRedstoneModeControlable;
import crazypants.enderio.machine.IoMode;
import crazypants.enderio.machine.RedstoneControlMode;
import crazypants.enderio.machine.capbank.network.CapBankClientNetwork;
-import crazypants.enderio.machine.capbank.network.NetworkState;
import crazypants.enderio.machine.capbank.packet.PacketGuiChange;
import crazypants.enderio.machine.capbank.packet.PacketNetworkStateRequest;
import crazypants.enderio.machine.gui.GuiButtonIoConfig;
@@ -37,8 +36,6 @@ import crazypants.vecmath.VecmathUtil;
public class GuiCapBank extends GuiContainerBase {
- private static final NetworkState EMPTY_STATE = new NetworkState();
-
private static final CapBankClientNetwork NULL_NETWORK = new CapBankClientNetwork(-1);
protected static final int INPUT_BUTTON_ID = 18;
@@ -369,4 +366,4 @@ public class GuiCapBank extends GuiContainerBase {
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/crazypants/enderio/machine/capbank/TileCapBank.java b/src/main/java/crazypants/enderio/machine/capbank/TileCapBank.java
index 25a19265..ce0eac34 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/TileCapBank.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/TileCapBank.java
@@ -2,7 +2,6 @@ package crazypants.enderio.machine.capbank;
import java.util.ArrayList;
import java.util.EnumMap;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -360,7 +359,7 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerHandler,
}
if(faceDisplayTypes == null) {
- faceDisplayTypes = new HashMap();
+ faceDisplayTypes = new EnumMap(ForgeDirection.class);
}
if(type == InfoDisplayType.NONE) {
@@ -678,7 +677,7 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerHandler,
if(mode == IoMode.DISABLED || mode == IoMode.PUSH) {
return 0;
}
- return network.recieveEnergy(maxReceive, simulate);
+ return network.receiveEnergy(maxReceive, simulate);
}
@Override
diff --git a/src/main/java/crazypants/enderio/machine/capbank/network/CapBankClientNetwork.java b/src/main/java/crazypants/enderio/machine/capbank/network/CapBankClientNetwork.java
index d92abc0a..a87ded96 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/network/CapBankClientNetwork.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/network/CapBankClientNetwork.java
@@ -36,7 +36,8 @@ public class CapBankClientNetwork implements ICapBankNetwork {
private final InventoryImpl inventory = new InventoryImpl();
- private float aveChange;
+ private float avgInput;
+ private float avgOutput;
private long lastPowerRequestTick = -1;
@@ -56,8 +57,10 @@ public class CapBankClientNetwork implements ICapBankNetwork {
if(lastPowerRequestTick == -1 || curTick - lastPowerRequestTick >= interval) {
if(stateUpdateCount == 0) {
PacketHandler.INSTANCE.sendToServer(new PacketNetworkStateRequest(capBank));
+ // the network state also contains the energy data
+ } else {
+ PacketHandler.INSTANCE.sendToServer(new PacketNetworkEnergyRequest(capBank));
}
- PacketHandler.INSTANCE.sendToServer(new PacketNetworkEnergyRequest(capBank));
lastPowerRequestTick = curTick;
}
}
@@ -80,8 +83,9 @@ public class CapBankClientNetwork implements ICapBankNetwork {
inventory.setCapBank((TileCapBank) te);
}
}
- aveChange = state.getAverageChange();
-
+ avgInput = state.getAverageInput();
+ avgOutput = state.getAverageOutput();
+
stateUpdateCount++;
}
@@ -190,11 +194,22 @@ public class CapBankClientNetwork implements ICapBankNetwork {
@Override
public float getAverageChangePerTick() {
- return aveChange;
+ return avgInput - avgOutput;
}
- public void setAverageChangePerTick(float aveChange) {
- this.aveChange = aveChange;
+ @Override
+ public float getAverageInputPerTick() {
+ return avgInput;
+ }
+
+ @Override
+ public float getAverageOutputPerTick() {
+ return avgOutput;
+ }
+
+ public void setAverageIOPerTick(float input, float output) {
+ this.avgInput = input;
+ this.avgOutput = output;
}
@Override
@@ -211,7 +226,7 @@ public class CapBankClientNetwork implements ICapBankNetwork {
}
@Override
- public int recieveEnergy(int maxReceive, boolean simulate) {
+ public int receiveEnergy(int maxReceive, boolean simulate) {
return 0;
}
diff --git a/src/main/java/crazypants/enderio/machine/capbank/network/CapBankNetwork.java b/src/main/java/crazypants/enderio/machine/capbank/network/CapBankNetwork.java
index d227bff3..2c67d92c 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/network/CapBankNetwork.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/network/CapBankNetwork.java
@@ -50,12 +50,14 @@ public class CapBankNetwork implements ICapBankNetwork {
private long energyStored;
private long prevEnergyStored = -1;
+ private long energyReceived;
+ private long energySend;
private long maxEnergyStored;
private CapBankType type;
- private Set redstoneRecievers = new HashSet();
+ private final Set redstoneRecievers = new HashSet();
private RedstoneControlMode inputControlMode = RedstoneControlMode.IGNORE;
private RedstoneControlMode outputControlMode = RedstoneControlMode.IGNORE;
@@ -63,9 +65,10 @@ public class CapBankNetwork implements ICapBankNetwork {
private boolean inputRedstoneConditionMet = true;
private boolean outputRedstoneConditionMet = true;
- private TickListener tickListener;
+ private final TickListener tickListener = new TickReciever();
- private PerTickIntAverageCalculator powerTracker = new PerTickIntAverageCalculator(2);
+ private final PerTickIntAverageCalculator powerTrackerIn = new PerTickIntAverageCalculator(2);
+ private final PerTickIntAverageCalculator powerTrackerOut = new PerTickIntAverageCalculator(2);
private final InventoryImpl inventory = new InventoryImpl();
@@ -82,8 +85,6 @@ public class CapBankNetwork implements ICapBankNetwork {
throw new UnsupportedOperationException();
}
- tickListener = new TickReciever();
-
type = cap.getType();
inputControlMode = cap.getInputControlMode();
outputControlMode = cap.getOutputControlMode();
@@ -223,10 +224,11 @@ public class CapBankNetwork implements ICapBankNetwork {
if(energyStored != prevEnergyStored) {
distributeEnergyToBanks();
}
- if(prevEnergyStored != -1) {
- powerTracker.tick((int) (energyStored - prevEnergyStored));
- }
+ powerTrackerIn.tick(energyReceived);
+ powerTrackerOut.tick(energySend);
prevEnergyStored = energyStored;
+ energyReceived = 0;
+ energySend = 0;
if(firstUpate) {
if(!capBanks.isEmpty()) {
@@ -265,9 +267,7 @@ public class CapBankNetwork implements ICapBankNetwork {
totalSent += sent;
available -= sent;
}
- if(!type.isCreative()) {
- addEnergy(-totalSent);
- }
+ addEnergy(-totalSent);
}
protected int getEnergyAvailableForTick(int limit) {
@@ -316,9 +316,7 @@ public class CapBankNetwork implements ICapBankNetwork {
}
if(used > 0) {
- if(!type.isCreative()) {
- addEnergy(-used);
- }
+ addEnergy(-used);
chargedItem = true;
available -= used;
}
@@ -344,11 +342,21 @@ public class CapBankNetwork implements ICapBankNetwork {
@Override
public float getAverageChangePerTick() {
- return powerTracker.getAverage();
+ return powerTrackerIn.getAverage() - powerTrackerOut.getAverage();
}
@Override
- public int recieveEnergy(int maxReceive, boolean simulate) {
+ public float getAverageInputPerTick() {
+ return powerTrackerIn.getAverage();
+ }
+
+ @Override
+ public float getAverageOutputPerTick() {
+ return powerTrackerOut.getAverage();
+ }
+
+ @Override
+ public int receiveEnergy(int maxReceive, boolean simulate) {
if(maxReceive <= 0 || !inputRedstoneConditionMet) {
return 0;
}
@@ -360,20 +368,25 @@ public class CapBankNetwork implements ICapBankNetwork {
int res = Math.min(maxReceive, (int) spaceAvailable);
res = Math.min(res, getMaxInput());
if(!simulate) {
- if(!type.isCreative()) {
- addEnergy(res);
- }
+ addEnergy(res);
}
return res;
}
@Override
public void addEnergy(int energy) {
- energyStored += energy;
- if(energyStored > maxEnergyStored) {
- energyStored = maxEnergyStored;
- } else if(energyStored < 0) {
- energyStored = 0;
+ if(energy > 0) {
+ energyReceived += energy;
+ } else {
+ energySend -= energy;
+ }
+ if(!type.isCreative()) {
+ energyStored += energy;
+ if(energyStored > maxEnergyStored) {
+ energyStored = maxEnergyStored;
+ } else if(energyStored < 0) {
+ energyStored = 0;
+ }
}
}
diff --git a/src/main/java/crazypants/enderio/machine/capbank/network/ClientNetworkManager.java b/src/main/java/crazypants/enderio/machine/capbank/network/ClientNetworkManager.java
index 41b78d75..4dc913bd 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/network/ClientNetworkManager.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/network/ClientNetworkManager.java
@@ -14,16 +14,15 @@ public class ClientNetworkManager {
return instance;
}
- private Map networks = new HashMap();
+ private final Map networks = new HashMap();
ClientNetworkManager() {
}
public void destroyNetwork(int id) {
- CapBankClientNetwork res = networks.get(id);
+ CapBankClientNetwork res = networks.remove(id);
if(res != null) {
res.destroyNetwork();
- networks.remove(res);
}
}
@@ -32,13 +31,13 @@ public class ClientNetworkManager {
network.setState(world, state);
}
- public void updateEnergy(int id, long energyStored, float avChange) {
+ public void updateEnergy(int id, long energyStored, float avgInput, float avgOutput) {
CapBankClientNetwork res = networks.get(id);
if(res == null) {
return;
}
res.setEnergyStored(energyStored);
- res.setAverageChangePerTick(avChange);
+ res.setAverageIOPerTick(avgInput, avgOutput);
}
public CapBankClientNetwork getOrCreateNetwork(int id) {
diff --git a/src/main/java/crazypants/enderio/machine/capbank/network/ICapBankNetwork.java b/src/main/java/crazypants/enderio/machine/capbank/network/ICapBankNetwork.java
index eadd8941..3f1e02ab 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/network/ICapBankNetwork.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/network/ICapBankNetwork.java
@@ -31,7 +31,7 @@ public interface ICapBankNetwork extends IPowerStorage {
@Override
void addEnergy(int energy);
- int recieveEnergy(int maxReceive, boolean simulate);
+ int receiveEnergy(int maxReceive, boolean simulate);
@Override
long getMaxEnergyStoredL();
@@ -50,6 +50,10 @@ public interface ICapBankNetwork extends IPowerStorage {
float getAverageChangePerTick();
+ float getAverageInputPerTick();
+
+ float getAverageOutputPerTick();
+
void removeReceptors(Collection receptors);
void addReceptors(Collection receptors);
diff --git a/src/main/java/crazypants/enderio/machine/capbank/network/NetworkState.java b/src/main/java/crazypants/enderio/machine/capbank/network/NetworkState.java
index e5c3e25f..ef8d36fe 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/network/NetworkState.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/network/NetworkState.java
@@ -15,14 +15,11 @@ public class NetworkState {
private final RedstoneControlMode inputMode;
private final RedstoneControlMode outputMode;
private final BlockCoord invImplLoc;
- private final float averageChange;
-
- public NetworkState() {
- this(0, 0, 0, 0, 0, RedstoneControlMode.IGNORE, RedstoneControlMode.IGNORE, null, 0);
- }
+ private final float averageInput;
+ private final float averageOutput;
public NetworkState(long energyStored, long maxEnergyStored, int maxIO, int maxInput, int maxOutput, RedstoneControlMode inputMode,
- RedstoneControlMode outputMode, BlockCoord invImplLoc, float averageChange) {
+ RedstoneControlMode outputMode, BlockCoord invImplLoc, float averageInput, float averageOutput) {
this.energyStored = energyStored;
this.maxEnergyStored = maxEnergyStored;
this.maxIO = maxIO;
@@ -31,7 +28,8 @@ public class NetworkState {
this.inputMode = inputMode;
this.outputMode = outputMode;
this.invImplLoc = invImplLoc;
- this.averageChange = averageChange;
+ this.averageInput = averageInput;
+ this.averageOutput = averageOutput;
}
public NetworkState(ICapBankNetwork network) {
@@ -48,7 +46,8 @@ public class NetworkState {
} else {
invImplLoc = null;
}
- averageChange = network.getAverageChangePerTick();
+ averageInput = network.getAverageInputPerTick();
+ averageOutput = network.getAverageOutputPerTick();
}
public long getEnergyStored() {
@@ -83,8 +82,12 @@ public class NetworkState {
return invImplLoc;
}
- public float getAverageChange() {
- return averageChange;
+ public float getAverageInput() {
+ return averageInput;
+ }
+
+ public float getAverageOutput() {
+ return averageOutput;
}
public void writeToBuf(ByteBuf buf) {
@@ -99,13 +102,14 @@ public class NetworkState {
if(invImplLoc != null) {
invImplLoc.writeToBuf(buf);
}
- buf.writeFloat(averageChange);
+ buf.writeFloat(averageInput);
+ buf.writeFloat(averageOutput);
}
public static NetworkState readFromBuf(ByteBuf buf) {
return new NetworkState(buf.readLong(), buf.readLong(), buf.readInt(), buf.readInt(), buf.readInt(),
RedstoneControlMode.values()[buf.readShort()], RedstoneControlMode.values()[buf.readShort()],
- buf.readBoolean() ? BlockCoord.readFromBuf(buf) : null, buf.readFloat());
+ buf.readBoolean() ? BlockCoord.readFromBuf(buf) : null, buf.readFloat(), buf.readFloat());
}
@Override
diff --git a/src/main/java/crazypants/enderio/machine/capbank/packet/PacketNetworkEnergyResponse.java b/src/main/java/crazypants/enderio/machine/capbank/packet/PacketNetworkEnergyResponse.java
index 15def115..d62c7592 100644
--- a/src/main/java/crazypants/enderio/machine/capbank/packet/PacketNetworkEnergyResponse.java
+++ b/src/main/java/crazypants/enderio/machine/capbank/packet/PacketNetworkEnergyResponse.java
@@ -11,7 +11,8 @@ public class PacketNetworkEnergyResponse implements IMessage, IMessageHandler 0) {
- heading = HeadingText.GAIN;
- } else if(change < 0) {
- heading = HeadingText.LOSS;
- }
+ HeadingText heading1 = HeadingText.STABLE;
+ HeadingText heading2 = null;
+ String text1;
+ String text2 = "";
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
- String changeText = getChangeText(change, fr);
-
float size = 0.15f * Math.min(info.width, info.height);
float scale = size / fr.FONT_HEIGHT;
+ float offset;
+
+ if(info.height*3 >= info.width*4) {
+ heading1 = HeadingText.INPUT;
+ heading2 = HeadingText.OUTPUT;
+ text1 = getChangeText(nw.getAverageInputPerTick(), fr);
+ text2 = getChangeText(nw.getAverageOutputPerTick(), fr);
+ offset = -size*2.5f;
+ } else {
+ int change = Math.round(nw.getAverageChangePerTick());
+ if(change > 0) {
+ heading1 = HeadingText.GAIN;
+ } else if(change < 0) {
+ heading1 = HeadingText.LOSS;
+ }
+ text1 = getChangeText(change, fr);
+ offset = -size;
+ }
ForgeDirection right = dir.getRotation(ForgeDirection.UP);
@@ -167,24 +176,40 @@ public class IoDisplay implements IInfoRenderer {
GL11.glRotatef(90, 0, 1, 0);
}
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
+
+ offset = drawText(heading1, text1, offset, scale, size, fr);
+ if(heading2 != null) {
+ drawText(heading2, text2, offset, scale, size, fr);
+ }
+
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+ }
+
+ private float drawText(HeadingText heading, String text, float offset, float scale, float size, FontRenderer fr) {
GL11.glPushMatrix();
- GL11.glTranslatef(0, -size, 0);
+ GL11.glTranslatef(0, offset, 0);
GL11.glScalef(scale, scale, scale);
fr.drawString(heading.text, -fr.getStringWidth(heading.text) / 2, 0, 0);
GL11.glPopMatrix();
+ offset += size * 1.5f;
GL11.glPushMatrix();
- GL11.glTranslatef(0, size / 2, 0);
+ GL11.glTranslatef(0, offset, 0);
GL11.glScalef(scale, scale, scale);
- fr.drawString(changeText, -fr.getStringWidth(changeText) / 2, 0, heading.color);
- GL11.glPopMatrix();
-
+ fr.drawString(text, -fr.getStringWidth(text) / 2, 0, heading.color);
GL11.glPopMatrix();
+ offset += size * 1.5f;
+ return offset;
}
- protected String getChangeText(int change, FontRenderer fr) {
- change = Math.abs(change);
+ protected String getChangeText(float average, FontRenderer fr) {
+ int change = Math.round(Math.abs(average));
String txt = PowerDisplayUtil.INT_NF.format(change);
int width = fr.getStringWidth(txt);
if(width > 38 && change > 1000) {
@@ -197,7 +222,9 @@ public class IoDisplay implements IInfoRenderer {
static enum HeadingText {
STABLE(ColorUtil.getRGB(0, 0, 0)),
GAIN(ColorUtil.getRGB(0, 0.25f, 0)),
- LOSS(ColorUtil.getRGB(0.25f, 0, 0));
+ LOSS(ColorUtil.getRGB(0.25f, 0, 0)),
+ INPUT(ColorUtil.getRGB(0, 0.25f, 0)),
+ OUTPUT(ColorUtil.getRGB(0.25f, 0, 0));
final String text;
final int color;
diff --git a/src/main/java/crazypants/enderio/machine/crafter/BlockCrafter.java b/src/main/java/crazypants/enderio/machine/crafter/BlockCrafter.java
index 7dbb3a9b..1d4e6406 100644
--- a/src/main/java/crazypants/enderio/machine/crafter/BlockCrafter.java
+++ b/src/main/java/crazypants/enderio/machine/crafter/BlockCrafter.java
@@ -1,15 +1,18 @@
package crazypants.enderio.machine.crafter;
+import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
+import crazypants.enderio.network.PacketHandler;
public class BlockCrafter extends AbstractMachineBlock {
public static BlockCrafter create() {
+ PacketHandler.INSTANCE.registerMessage(PacketCrafter.class,PacketCrafter.class,PacketHandler.nextID(), Side.SERVER);
BlockCrafter res = new BlockCrafter();
res.init();
return res;
diff --git a/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java b/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java
index 1ded7860..a2c03fb7 100644
--- a/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java
+++ b/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java
@@ -1,29 +1,26 @@
package crazypants.enderio.machine.crafter;
import java.awt.Point;
+import java.util.List;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import crazypants.enderio.machine.gui.AbstractMachineContainer;
-import crazypants.gui.TemplateSlot;
+import crazypants.enderio.network.PacketHandler;
+import crazypants.gui.GhostSlot;
public class ContainerCrafter extends AbstractMachineContainer {
- private TileCrafter crafter;
- private DummyCraftingGrid craftingGrid;
+ private final TileCrafter crafter;
public ContainerCrafter(InventoryPlayer playerInv, TileCrafter te) {
super(playerInv, te);
- addCrafterSlots();
+ crafter = (TileCrafter) tileEntity;
}
- private void addCrafterSlots() {
- crafter = (TileCrafter) tileEntity;
- craftingGrid = crafter.craftingGrid;
-
+ public void addCrafterSlots(List ghostSlots) {
int topY = 16;
int leftX = 31;
int index = 0;
@@ -32,12 +29,12 @@ public class ContainerCrafter extends AbstractMachineContainer {
for (int col = 0; col < 3; ++col) {
int x = leftX + col * 18;
int y = topY + row * 18;
- addSlotToContainer(new DummySlot(craftingGrid, index, x, y));
+ ghostSlots.add(new DummySlot(index, x, y));
index++;
}
}
- addSlotToContainer(new DummySlot(craftingGrid, 9, 90, 34));
+ ghostSlots.add(new DummySlot(9, 90, 34));
}
@Override
@@ -45,19 +42,17 @@ public class ContainerCrafter extends AbstractMachineContainer {
return new Point(30, 84);
}
+ @Override
public Point getUpgradeOffset() {
return new Point(6, 60);
}
@Override
protected void addMachineSlots(InventoryPlayer playerInv) {
-
int topY = 16;
- int leftX = 31;
+ int leftX = 113;
int index = 0;
- leftX = 113;
- index = 0;
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 3; ++col) {
int x = leftX + col * 18;
@@ -73,18 +68,6 @@ public class ContainerCrafter extends AbstractMachineContainer {
}
});
}
-
- @Override
- public ItemStack slotClick(int par1, int par2, int par3,
- EntityPlayer par4EntityPlayer) {
- if(par1 >= 0 && par1 < inventorySlots.size()) {
- Slot slot = getSlot(par1);
- if(slot.getHasStack() && slot instanceof DummySlot) {
- slot.putStack(null);
- }
- }
- return super.slotClick(par1, par2, par3, par4EntityPlayer);
- }
private class InputSlot extends Slot {
@@ -103,35 +86,30 @@ public class ContainerCrafter extends AbstractMachineContainer {
}
}
- private class DummySlot extends TemplateSlot {
+ private class DummySlot extends GhostSlot {
+ private final int slotIndex;
- public DummySlot(IInventory inventory, int slotIndex, int x, int y) {
- super(inventory, slotIndex, x, y);
+ public DummySlot(int slotIndex, int x, int y) {
+ this.slotIndex = slotIndex;
+ this.x = x;
+ this.y = y;
}
@Override
- public boolean isItemValid(ItemStack itemStack) {
- return true;
+ public ItemStack getStack() {
+ return crafter.craftingGrid.getStackInSlot(slotIndex);
}
@Override
- public void putStack(ItemStack par1ItemStack) {
- if(par1ItemStack != null) {
- par1ItemStack.stackSize = 0;
+ public void putStack(ItemStack stack) {
+ if(slotIndex >= 9) {
+ return;
}
- inventory.setInventorySlotContents(slotIndex, par1ItemStack);
- onSlotChanged();
- }
-
- @Override
- public void onSlotChanged() {
- super.onSlotChanged();
- crafter.updateCraftingOutput();
- }
-
- @Override
- public boolean canTakeStack(EntityPlayer player) {
- return false;
+ if(stack != null) {
+ stack = stack.copy();
+ stack.stackSize = 1;
+ }
+ PacketHandler.INSTANCE.sendToServer(PacketCrafter.setSlot(crafter, slotIndex, stack));
}
}
}
diff --git a/src/main/java/crazypants/enderio/machine/crafter/GuiCrafter.java b/src/main/java/crazypants/enderio/machine/crafter/GuiCrafter.java
index bb501738..7267c7ad 100644
--- a/src/main/java/crazypants/enderio/machine/crafter/GuiCrafter.java
+++ b/src/main/java/crazypants/enderio/machine/crafter/GuiCrafter.java
@@ -10,17 +10,19 @@ import org.lwjgl.opengl.GL11;
import crazypants.enderio.config.Config;
import crazypants.enderio.gui.IconEIO;
import crazypants.enderio.gui.ToggleButtonEIO;
-import crazypants.enderio.machine.IItemBuffer;
import crazypants.enderio.machine.PacketItemBuffer;
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
import crazypants.enderio.machine.power.PowerDisplayUtil;
import crazypants.enderio.network.PacketHandler;
+import crazypants.gui.GhostSlot;
import crazypants.render.RenderUtil;
import crazypants.util.Lang;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
public class GuiCrafter extends GuiPoweredMachineBase {
- private ToggleButtonEIO bufferSizeB;
+ private final ToggleButtonEIO bufferSizeB;
public GuiCrafter(InventoryPlayer par1InventoryPlayer, TileCrafter te) {
super(te, new ContainerCrafter(par1InventoryPlayer, te));
@@ -38,6 +40,22 @@ public class GuiCrafter extends GuiPoweredMachineBase {
public void initGui() {
super.initGui();
bufferSizeB.onGuiInit();
+ ((ContainerCrafter) inventorySlots).addCrafterSlots(ghostSlots);
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int button, long par4) {
+ if(!ghostSlots.isEmpty()) {
+ GhostSlot slot = getGhostSlot(mouseX, mouseY);
+ if(slot != null) {
+ ItemStack st = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
+ // don't replace already set slots while dragging an item
+ if(st == null || slot.getStack() == null) {
+ slot.putStack(st);
+ }
+ }
+ }
+ super.mouseClickMove(mouseX, mouseY, button, par4);
}
@Override
@@ -55,7 +73,7 @@ public class GuiCrafter extends GuiPoweredMachineBase {
}
@Override
- public int getXSize() {
+ public final int getXSize() {
return 219;
}
diff --git a/src/main/java/crazypants/enderio/machine/crafter/PacketCrafter.java b/src/main/java/crazypants/enderio/machine/crafter/PacketCrafter.java
new file mode 100644
index 00000000..3abf08f3
--- /dev/null
+++ b/src/main/java/crazypants/enderio/machine/crafter/PacketCrafter.java
@@ -0,0 +1,59 @@
+package crazypants.enderio.machine.crafter;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import crazypants.enderio.network.MessageTileEntity;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.item.ItemStack;
+
+public class PacketCrafter extends MessageTileEntity implements IMessageHandler {
+
+ private int slot;
+ private ItemStack stack;
+
+ public PacketCrafter() {
+ }
+
+ private PacketCrafter(TileCrafter tile) {
+ super(tile);
+ }
+
+ public static PacketCrafter setSlot(TileCrafter te, int slot, ItemStack stack) {
+ PacketCrafter msg = new PacketCrafter(te);
+ msg.slot = slot;
+ msg.stack = stack;
+ msg.execute(te);
+ return msg;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ super.fromBytes(buf);
+ slot = buf.readShort();
+ stack = ByteBufUtils.readItemStack(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ super.toBytes(buf);
+ buf.writeShort(slot);
+ ByteBufUtils.writeItemStack(buf, stack);
+ }
+
+ @Override
+ public IMessage onMessage(PacketCrafter msg, MessageContext ctx) {
+ TileCrafter te = msg.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
+ if(te != null) {
+ msg.execute(te);
+ }
+ return null;
+ }
+
+ private void execute(TileCrafter te) {
+ te.craftingGrid.setInventorySlotContents(slot, stack);
+ te.updateCraftingOutput();
+ }
+
+}
diff --git a/src/main/java/crazypants/enderio/machine/crusher/BlockCrusher.java b/src/main/java/crazypants/enderio/machine/crusher/BlockCrusher.java
index 6708740c..af6fd0a5 100644
--- a/src/main/java/crazypants/enderio/machine/crusher/BlockCrusher.java
+++ b/src/main/java/crazypants/enderio/machine/crusher/BlockCrusher.java
@@ -7,17 +7,17 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
-import crazypants.enderio.machine.generator.stirling.TileEntityStirlingGenerator;
import crazypants.enderio.network.PacketHandler;
public class BlockCrusher extends AbstractMachineBlock {
public static BlockCrusher create() {
PacketHandler.INSTANCE.registerMessage(PacketGrindingBall.class, PacketGrindingBall.class, PacketHandler.nextID(), Side.CLIENT);
-
+
BlockCrusher res = new BlockCrusher();
res.init();
return res;
@@ -59,8 +59,9 @@ public class BlockCrusher extends AbstractMachineBlock {
}
return "enderio:crusherFront";
}
-
+
@Override
+ @SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
TileCrusher te = (TileCrusher) world.getTileEntity(x, y, z);
if(te != null && te.isActive()) {
@@ -73,7 +74,7 @@ public class BlockCrusher extends AbstractMachineBlock {
double v = 0.05;
double vx = 0;
double vz = 0;
-
+
if(front == ForgeDirection.NORTH || front == ForgeDirection.SOUTH) {
px += world.rand.nextFloat() * 0.8 - 0.4;
vz += front == ForgeDirection.NORTH ? -v : v;
diff --git a/src/main/java/crazypants/enderio/machine/enchanter/EnchanterModelRenderer.java b/src/main/java/crazypants/enderio/machine/enchanter/EnchanterModelRenderer.java
index f60e08da..f4615570 100644
--- a/src/main/java/crazypants/enderio/machine/enchanter/EnchanterModelRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/enchanter/EnchanterModelRenderer.java
@@ -12,8 +12,11 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.render.RenderUtil;
+@SideOnly(Side.CLIENT)
public class EnchanterModelRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
private static final String TEXTURE = "enderio:models/BookStand.png";
@@ -31,11 +34,11 @@ public class EnchanterModelRenderer extends TileEntitySpecialRenderer implements
int l1 = l % 65536;
int l2 = l / 65536;
Tessellator.instance.setColorOpaque_F(f, f, f);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
- renderModel(gen.getFacing());
+ renderModel(gen.getFacing());
GL11.glPopMatrix();
}
diff --git a/src/main/java/crazypants/enderio/machine/farm/BlockFarmStation.java b/src/main/java/crazypants/enderio/machine/farm/BlockFarmStation.java
index 1db1e047..642bde50 100644
--- a/src/main/java/crazypants/enderio/machine/farm/BlockFarmStation.java
+++ b/src/main/java/crazypants/enderio/machine/farm/BlockFarmStation.java
@@ -76,7 +76,7 @@ public class BlockFarmStation extends AbstractMachineBlock {
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
return true;
}
-
+
@Override
public int getLightOpacity() {
return 7;
@@ -107,6 +107,7 @@ public class BlockFarmStation extends AbstractMachineBlock {
}
@Override
+ @SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
}
diff --git a/src/main/java/crazypants/enderio/machine/farm/FarmingStationSpecialRenderer.java b/src/main/java/crazypants/enderio/machine/farm/FarmingStationSpecialRenderer.java
index 34c6938b..e6a68882 100644
--- a/src/main/java/crazypants/enderio/machine/farm/FarmingStationSpecialRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/farm/FarmingStationSpecialRenderer.java
@@ -5,10 +5,13 @@ import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.config.Config;
import crazypants.render.RenderUtil;
import crazypants.vecmath.Vector3f;
+@SideOnly(Side.CLIENT)
public class FarmingStationSpecialRenderer extends TileEntitySpecialRenderer{
private void renderFarmStationAt(TileFarmStation tile, double x, double y, double z, float partialTickTime) {
@@ -17,13 +20,13 @@ public class FarmingStationSpecialRenderer extends TileEntitySpecialRenderer{
if ("".equals(toRender) || Config.disableFarmNotification) {
return;
}
-
+
glDisable(GL_LIGHTING);
RenderUtil.drawBillboardedText(new Vector3f(x + 0.5, y + 1.5, z + 0.5), toRender, 0.25f);
glEnable(GL_LIGHTING);
- }
-
+ }
+
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) {
if (tile instanceof TileFarmStation) {
diff --git a/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java b/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java
index 03d84bf0..0381eb52 100644
--- a/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java
+++ b/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java
@@ -14,10 +14,13 @@ import crazypants.enderio.gui.ToggleButtonEIO;
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
import crazypants.render.ColorUtil;
import crazypants.render.RenderUtil;
+import crazypants.util.Lang;
import crazypants.vecmath.Vector4f;
public class GuiFarmStation extends GuiPoweredMachineBase {
-
+
+ private static final int LOCK_ID = 1234;
+
public GuiFarmStation(InventoryPlayer par1InventoryPlayer, TileFarmStation machine) {
super(machine, new FarmStationContainer(par1InventoryPlayer, machine));
}
@@ -30,25 +33,23 @@ public class GuiFarmStation extends GuiPoweredMachineBase {
int x = getGuiLeft() + 36;
int y = getGuiTop() + 36;
- buttonList.add(createButton(x, y));
- buttonList.add(createButton(x + 52, y));
- buttonList.add(createButton(x, y + 20));
- buttonList.add(createButton(x + 52, y + 20));
- id = 0;
+ buttonList.add(createLockButton(TileFarmStation.minSupSlot + 0, x, y));
+ buttonList.add(createLockButton(TileFarmStation.minSupSlot + 1, x + 52, y));
+ buttonList.add(createLockButton(TileFarmStation.minSupSlot + 2, x, y + 20));
+ buttonList.add(createLockButton(TileFarmStation.minSupSlot + 3, x + 52, y + 20));
}
- private int id = 0;
- private IconButtonEIO createButton(int x, int y) {
- return new ToggleButtonEIO(this, id, x, y, IconEIO.FARM_UNLOCK, IconEIO.FARM_LOCK).setSelected(getTileEntity().lockedSlots.contains(id++ + getTileEntity().minSupSlot));
+ private IconButtonEIO createLockButton(int slot, int x, int y) {
+ return new ToggleButtonEIO(this, LOCK_ID+slot, x, y, IconEIO.FARM_UNLOCK, IconEIO.FARM_LOCK).setSelected(getTileEntity().isSlotLocked(slot));
}
@Override
protected void drawForegroundImpl(int mouseX, int mouseY) {
super.drawForegroundImpl(mouseX, mouseY);
- if(inventorySlots.inventorySlots.size() >= getTileEntity().maxSupSlot && !isConfigOverlayEnabled()) {
- for (int i : getTileEntity().lockedSlots) {
- if (i < inventorySlots.inventorySlots.size()) { // hack to allow old broken farms to be opened
+ if(!isConfigOverlayEnabled()) {
+ for(int i=TileFarmStation.minSupSlot ; i<=TileFarmStation.maxSupSlot ; i++) {
+ if(getTileEntity().isSlotLocked(i)) {
Slot slot = inventorySlots.getSlot(i);
GL11.glEnable(GL11.GL_BLEND);
RenderUtil.renderQuad2D(slot.xDisplayPosition, slot.yDisplayPosition, 0, 16, 16, new Vector4f(0, 0, 0, 0.5));
@@ -81,8 +82,8 @@ public class GuiFarmStation extends GuiPoweredMachineBase {
@Override
protected void actionPerformed(GuiButton b) {
- if (b instanceof ToggleButtonEIO) {
- getTileEntity().toggleLockedState(b.id);
+ if (b.id >= LOCK_ID+TileFarmStation.minSupSlot && b.id <= LOCK_ID+TileFarmStation.maxSupSlot) {
+ getTileEntity().toggleLockedState(b.id - LOCK_ID);
}
super.actionPerformed(b);
}
@@ -92,7 +93,8 @@ public class GuiFarmStation extends GuiPoweredMachineBase {
return false;
}
+ @Override
protected String getPowerOutputLabel() {
- return "Base Use: ";
+ return Lang.localize("farm.gui.baseUse");
}
}
diff --git a/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java b/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java
index b8e8c5e4..76474002 100644
--- a/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java
+++ b/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java
@@ -1,7 +1,6 @@
package crazypants.enderio.machine.farm;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.BitSet;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
@@ -10,8 +9,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
-import net.minecraft.item.ItemAxe;
-import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
@@ -39,6 +36,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
public enum ToolType {
HOE {
+ @Override
boolean match(ItemStack item) {
for (ItemStack stack : Config.farmHoes) {
if (stack.getItem() == item.getItem()) {
@@ -83,15 +81,13 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
private BlockCoord lastScanned;
private EntityPlayerMP farmerJoe;
- private int farmSize = Config.farmDefaultSize;
+ private static final int minToolSlot = 0;
+ private static final int maxToolSlot = 1;
- private int minToolSlot = 0;
- private int maxToolSlot = 1;
-
- int minSupSlot = maxToolSlot + 1;
- int maxSupSlot = minSupSlot + 4;
+ public static final int minSupSlot = maxToolSlot + 1;
+ public static final int maxSupSlot = minSupSlot + 4;
- List lockedSlots = new ArrayList();
+ private final BitSet lockedSlots = new BitSet();
private final int upgradeBonusSize = 2;
@@ -108,7 +104,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
}
public int getFarmSize() {
- return farmSize + getUpgradeDist();
+ return Config.farmDefaultSize + getUpgradeDist();
}
public void actionPerformed(boolean isAxe) {
@@ -408,7 +404,6 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
}
}
}
- return;
}
private boolean isOutputFull() {
@@ -424,10 +419,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
public boolean hasSeed(ItemStack seeds, BlockCoord bc) {
int slot = getSupplySlotForCoord(bc);
ItemStack inv = inventory[slot];
- if(inv != null && (inv.stackSize > 1 || !isSlotLocked(slot)) && inv.isItemEqual(seeds)) {
- return true;
- }
- return false;
+ return inv != null && (inv.stackSize > 1 || !isSlotLocked(slot)) && inv.isItemEqual(seeds);
}
public ItemStack takeSeedFromSupplies(ItemStack stack, BlockCoord forBlock) {
@@ -555,19 +547,15 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
return new BlockCoord(nextX, lastScanned.y, nextZ);
}
- public void toggleLockedState(int buttonID) {
+ public void toggleLockedState(int slot) {
if (worldObj.isRemote) {
- PacketHandler.INSTANCE.sendToServer(new PacketFarmLockedSlot(this, buttonID));
- }
- buttonID += minSupSlot;
- if (lockedSlots.contains(buttonID)) {
- lockedSlots.remove((Integer) buttonID); // hard cast otherwise it removes by index
- } else {
- lockedSlots.add(buttonID);
+ PacketHandler.INSTANCE.sendToServer(new PacketFarmLockedSlot(this, slot));
}
+ lockedSlots.flip(slot);
}
+
public boolean isSlotLocked(int slot) {
- return lockedSlots.contains(slot);
+ return lockedSlots.get(slot);
}
@Override
@@ -627,11 +615,17 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
public void readCustomNBT(NBTTagCompound nbtRoot) {
super.readCustomNBT(nbtRoot);
currentTask = createTask();
+ }
+
+ @Override
+ public void readCommon(NBTTagCompound nbtRoot) {
+ super.readCommon(nbtRoot);
+ lockedSlots.clear();
for (int i : nbtRoot.getIntArray("lockedSlots")) {
- lockedSlots.add(i);
+ lockedSlots.set(i);
}
}
-
+
IPoweredTask createTask() {
return new ContinuousTask(getPowerUsePerTick());
}
@@ -640,11 +634,18 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
public void writeCustomNBT(NBTTagCompound nbtRoot) {
super.writeCustomNBT(nbtRoot);
nbtRoot.setBoolean("isActive", isActive());
- int[] locked = new int[lockedSlots.size()];
- for (int i = 0; i < lockedSlots.size(); i++) {
- locked[i] = lockedSlots.get(i);
+ }
+
+ @Override
+ public void writeCommon(NBTTagCompound nbtRoot) {
+ super.writeCommon(nbtRoot);
+ if(!lockedSlots.isEmpty()) {
+ int[] locked = new int[lockedSlots.cardinality()];
+ for (int i=0,bit=-1; (bit=lockedSlots.nextSetBit(bit+1)) >= 0; i++) {
+ locked[i] = bit;
+ }
+ nbtRoot.setIntArray("lockedSlots", locked);
}
- nbtRoot.setIntArray("lockedSlots", locked);
}
}
diff --git a/src/main/java/crazypants/enderio/machine/generator/combustion/BlockCombustionGenerator.java b/src/main/java/crazypants/enderio/machine/generator/combustion/BlockCombustionGenerator.java
index d642cd02..1e165eb0 100644
--- a/src/main/java/crazypants/enderio/machine/generator/combustion/BlockCombustionGenerator.java
+++ b/src/main/java/crazypants/enderio/machine/generator/combustion/BlockCombustionGenerator.java
@@ -10,6 +10,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
@@ -24,7 +25,7 @@ public class BlockCombustionGenerator extends AbstractMachineBlock extends Gu
}
renderSlotHighlights();
+
+ super.drawGuiContainerBackgroundLayer(par1, par2, par3);
}
public void renderSlotHighlights() {
@@ -153,7 +155,7 @@ public abstract class GuiMachineBase extends Gu
addToolTip(tt);
}
- private void updateProgressTooltips(int scaledProgress, float progress) {
+ protected final void updateProgressTooltips(int scaledProgress, float progress) {
if(lastProgressTooltipValue == scaledProgress || progressTooltips == null) {
return;
}
diff --git a/src/main/java/crazypants/enderio/machine/gui/GuiPoweredMachineBase.java b/src/main/java/crazypants/enderio/machine/gui/GuiPoweredMachineBase.java
index 65ffbb90..1276a9aa 100644
--- a/src/main/java/crazypants/enderio/machine/gui/GuiPoweredMachineBase.java
+++ b/src/main/java/crazypants/enderio/machine/gui/GuiPoweredMachineBase.java
@@ -46,7 +46,7 @@ public abstract class GuiPoweredMachineBase text) {
- text.add(getPowerOutputLabel() + PowerDisplayUtil.formatPower(getPowerOutputValue()) + " " + PowerDisplayUtil.abrevation()
+ text.add(getPowerOutputLabel() + " " + PowerDisplayUtil.formatPower(getPowerOutputValue()) + " " + PowerDisplayUtil.abrevation()
+ PowerDisplayUtil.perTickStr());
text.add(PowerDisplayUtil.formatStoredPower(getTileEntity().getEnergyStored(), getTileEntity().getCapacitor().getMaxEnergyStored()));
}
diff --git a/src/main/java/crazypants/enderio/machine/hypercube/BlockHyperCube.java b/src/main/java/crazypants/enderio/machine/hypercube/BlockHyperCube.java
index ead17b7d..d9caf463 100644
--- a/src/main/java/crazypants/enderio/machine/hypercube/BlockHyperCube.java
+++ b/src/main/java/crazypants/enderio/machine/hypercube/BlockHyperCube.java
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.Random;
import java.util.UUID;
-import crazypants.util.PlayerUtil;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
@@ -23,6 +22,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.BlockEio;
import crazypants.enderio.EnderIO;
import crazypants.enderio.GuiHandler;
@@ -32,7 +32,7 @@ import crazypants.enderio.machine.hypercube.TileHyperCube.IoMode;
import crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.power.PowerHandlerUtil;
-import crazypants.enderio.tool.ToolUtil;
+import crazypants.util.PlayerUtil;
import crazypants.util.Util;
public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTooltipProvider {
@@ -79,6 +79,7 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTo
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:tesseractPortal");
}
diff --git a/src/main/java/crazypants/enderio/machine/hypercube/HyperCubeRenderer.java b/src/main/java/crazypants/enderio/machine/hypercube/HyperCubeRenderer.java
index 3bb7c6bd..0a825d77 100644
--- a/src/main/java/crazypants/enderio/machine/hypercube/HyperCubeRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/hypercube/HyperCubeRenderer.java
@@ -11,12 +11,15 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.config.Config;
import crazypants.render.BoundingBox;
import crazypants.render.CubeRenderer;
import crazypants.render.RenderUtil;
+@SideOnly(Side.CLIENT)
public class HyperCubeRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
private IModel model;
diff --git a/src/main/java/crazypants/enderio/machine/killera/KillerJoeRenderer.java b/src/main/java/crazypants/enderio/machine/killera/KillerJoeRenderer.java
index cc6b9c45..77059cb2 100644
--- a/src/main/java/crazypants/enderio/machine/killera/KillerJoeRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/killera/KillerJoeRenderer.java
@@ -1,10 +1,8 @@
package crazypants.enderio.machine.killera;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
@@ -14,12 +12,13 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;
-import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidTank;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.machine.generator.zombie.ModelZombieJar;
import crazypants.render.BoundingBox;
import crazypants.render.CubeRenderer;
@@ -27,6 +26,7 @@ import crazypants.render.RenderUtil;
import crazypants.util.ForgeDirectionOffsets;
import crazypants.vecmath.Vector3d;
+@SideOnly(Side.CLIENT)
public class KillerJoeRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
private static final String TEXTURE = "enderio:models/KillerJoe.png";
@@ -47,7 +47,7 @@ public class KillerJoeRenderer extends TileEntitySpecialRenderer implements IIte
int l1 = l % 65536;
int l2 = l / 65536;
Tessellator.instance.setColorOpaque_F(f, f, f);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
@@ -140,10 +140,10 @@ public class KillerJoeRenderer extends TileEntitySpecialRenderer implements IIte
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
- GL11.glColor3f(1, 1, 1);
-
+ GL11.glColor3f(1, 1, 1);
+
tes.draw();
GL11.glDepthMask(true);
GL11.glPopAttrib();
diff --git a/src/main/java/crazypants/enderio/machine/light/BlockElectricLight.java b/src/main/java/crazypants/enderio/machine/light/BlockElectricLight.java
index e878b6b3..44bdad0a 100644
--- a/src/main/java/crazypants/enderio/machine/light/BlockElectricLight.java
+++ b/src/main/java/crazypants/enderio/machine/light/BlockElectricLight.java
@@ -1,12 +1,7 @@
package crazypants.enderio.machine.light;
-import java.util.ArrayList;
-import java.util.Random;
-
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
@@ -22,8 +17,6 @@ import crazypants.enderio.BlockEio;
import crazypants.enderio.ModObject;
import crazypants.enderio.TileEntityEio;
import crazypants.enderio.api.redstone.IRedstoneConnectable;
-import crazypants.enderio.api.tool.ITool;
-import crazypants.enderio.tool.ToolUtil;
import crazypants.vecmath.Vector3f;
public class BlockElectricLight extends BlockEio implements IRedstoneConnectable {
@@ -63,6 +56,7 @@ public class BlockElectricLight extends BlockEio implements IRedstoneConnectable
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
blockIcon = iIconRegister.registerIcon("enderio:blockElectricLightFace");
blockIconOff = iIconRegister.registerIcon("enderio:blockElectricLightFaceOff");
@@ -215,7 +209,7 @@ public class BlockElectricLight extends BlockEio implements IRedstoneConnectable
}
/* IRedstoneConnectable */
-
+
@Override
public boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from) {
return true;
diff --git a/src/main/java/crazypants/enderio/machine/light/BlockItemElectricLight.java b/src/main/java/crazypants/enderio/machine/light/BlockItemElectricLight.java
index dff1abba..7f05b1a0 100644
--- a/src/main/java/crazypants/enderio/machine/light/BlockItemElectricLight.java
+++ b/src/main/java/crazypants/enderio/machine/light/BlockItemElectricLight.java
@@ -12,6 +12,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.gui.IResourceTooltipProvider;
@@ -24,21 +26,21 @@ public class BlockItemElectricLight extends ItemBlockWithMetadata implements IRe
BASIC_INV("item.itemLightInverted", true, false, false),
WIRELESS("item.itemWirelessLight", false, true, true),
WIRELESS_INV("item.itemWirelessLightInverted", true, true, true);
-
+
final String unlocName;
final boolean isInverted;
final boolean isPowered;
final boolean isWireless;
-
+
private Type(String unlocName, boolean isInverted, boolean isPowered, boolean isWireless) {
this.unlocName = unlocName;
this.isInverted = isInverted;
this.isPowered = isPowered;
this.isWireless = isWireless;
}
-
+
}
-
+
public BlockItemElectricLight(Block block) {
super(block, block);
setCreativeTab(EnderIOTab.tabEnderIO);
@@ -53,6 +55,7 @@ public class BlockItemElectricLight extends ItemBlockWithMetadata implements IRe
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(Type type : Type.values()) {
par3List.add(new ItemStack(this,1,type.ordinal()));
@@ -68,7 +71,7 @@ public class BlockItemElectricLight extends ItemBlockWithMetadata implements IRe
ForgeDirection onFace = ForgeDirection.values()[side].getOpposite();
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileElectricLight) {
- TileElectricLight el = ((TileElectricLight) te);
+ TileElectricLight el = ((TileElectricLight) te);
el.setFace(onFace);
Type t= Type.values()[metadata];
el.setInverted(t.isInverted);
@@ -80,7 +83,7 @@ public class BlockItemElectricLight extends ItemBlockWithMetadata implements IRe
}
@Override
- public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
+ public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName(itemStack);
}
}
diff --git a/src/main/java/crazypants/enderio/machine/light/BlockLightNode.java b/src/main/java/crazypants/enderio/machine/light/BlockLightNode.java
index ea0d4ac6..b90035e6 100644
--- a/src/main/java/crazypants/enderio/machine/light/BlockLightNode.java
+++ b/src/main/java/crazypants/enderio/machine/light/BlockLightNode.java
@@ -8,6 +8,8 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.BlockEio;
import crazypants.enderio.ModObject;
@@ -21,7 +23,7 @@ public class BlockLightNode extends BlockEio {
public BlockLightNode() {
super(ModObject.blockLightNode.unlocalisedName, TileLightNode.class, Material.air);
- setCreativeTab(null);
+ setCreativeTab(null);
setBlockBounds(0, 0, 0, 0, 0, 0);
}
@@ -88,12 +90,13 @@ public class BlockLightNode extends BlockEio {
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
blockIcon = iIconRegister.registerIcon("enderio:blockElectricLightFace");
}
@Override
- public int quantityDropped(Random p_149745_1_) {
+ public int quantityDropped(Random p_149745_1_) {
return 0;
}
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedCarpet.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedCarpet.java
index 43df89db..243122b0 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedCarpet.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedCarpet.java
@@ -63,6 +63,7 @@ public class BlockPaintedCarpet extends BlockCarpet implements ITileEntityProvid
}
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
ItemStack stack = new ItemStack(item);
PainterUtil.setSourceBlock(stack, Blocks.stone, 0);
@@ -160,6 +161,7 @@ public class BlockPaintedCarpet extends BlockCarpet implements ITileEntityProvid
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFence.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFence.java
index d38ccf31..6da5f306 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFence.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFence.java
@@ -65,10 +65,11 @@ public class BlockPaintedFence extends BlockFence implements ITileEntityProvider
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(PainterUtil.applyDefaultPaintedState(new ItemStack(item)));
}
-
+
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World world, MovingObjectPosition target,
@@ -177,6 +178,7 @@ public class BlockPaintedFence extends BlockFence implements ITileEntityProvider
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
@@ -287,7 +289,7 @@ public class BlockPaintedFence extends BlockFence implements ITileEntityProvider
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
}
-
+
}
}
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFenceGate.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFenceGate.java
index e9f0c103..924d6d68 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFenceGate.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedFenceGate.java
@@ -56,13 +56,14 @@ public class BlockPaintedFenceGate extends BlockFenceGate implements ITileEntity
GameRegistry.registerTileEntity(TileEntityPaintedBlock.class, ModObject.blockPaintedFenceGate.unlocalisedName + "TileEntity");
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate());
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(PainterUtil.applyDefaultPaintedState(new ItemStack(item)));
}
-
+
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World world, MovingObjectPosition target,
@@ -162,6 +163,7 @@ public class BlockPaintedFenceGate extends BlockFenceGate implements ITileEntity
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
@@ -241,7 +243,7 @@ public class BlockPaintedFenceGate extends BlockFenceGate implements ITileEntity
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
}
-
+
}
}
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java
index f847b3fb..a4d5dc25 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java
@@ -37,7 +37,7 @@ import crazypants.util.IFacade;
import crazypants.util.Lang;
public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvider, IPaintedBlock, IFacade, IRotatableFacade {
-
+
public static int renderId = -1;
public static BlockPaintedGlowstone create() {
@@ -70,9 +70,10 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
PainterUtil.setSourceBlock(result, block, damage);
return result;
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(PainterUtil.applyDefaultPaintedState(new ItemStack(item)));
}
@@ -86,7 +87,7 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
if(tef.getSourceBlock() != null) {
return tef.getSourceBlock().colorMultiplier(world, x, y, z);
}
- }
+ }
return super.colorMultiplier(world, x, y, z);
}
@@ -168,11 +169,12 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
}
@Override
- public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
+ public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return true;
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
@@ -183,7 +185,7 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
}
return Blocks.anvil.getIcon(world, x, y, z, blockSide);
}
-
+
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister IIconRegister) {
@@ -220,14 +222,14 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
drop.stackTagCompound = (NBTTagCompound) itemStack.stackTagCompound.copy();
}
}
-
+
@Override
public boolean doNormalDrops(World world, int x, int y, int z) {
return false;
}
@Override
- public int getRenderType() {
+ public int getRenderType() {
return renderId;
}
@@ -244,7 +246,7 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
if(paintSource == null) {
return new ResultStack[0];
}
-
+
if (paintSource.getItem() == Item.getItemFromBlock(Blocks.glowstone)) {
ItemStack stack = new ItemStack(Blocks.glowstone);
stack.stackTagCompound = new NBTTagCompound();
@@ -252,10 +254,10 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid
stack.stackTagCompound.setBoolean(tagName, true);
return new ResultStack[] { new ResultStack(stack) };
}
-
+
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
}
-
+
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
if (event.itemStack != null && Block.getBlockFromItem(event.itemStack.getItem()) == Blocks.glowstone && event.itemStack.stackTagCompound != null) {
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedSlab.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedSlab.java
index 3c16a9ad..3810a1ad 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedSlab.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedSlab.java
@@ -68,14 +68,16 @@ public class BlockPaintedSlab extends BlockSlab implements ITileEntityProvider,
PainterUtil.setSourceBlock(result, source, damage);
return result;
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(PainterUtil.applyDefaultPaintedState(new ItemStack(item)));
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
@@ -269,7 +271,7 @@ public class BlockPaintedSlab extends BlockSlab implements ITileEntityProvider,
Block blk = Block.getBlockFromItem(target.getItem());
return blk instanceof BlockSlab;
}
-
+
}
}
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedStair.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedStair.java
index fa42240f..cb9e28a7 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedStair.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedStair.java
@@ -59,9 +59,10 @@ public class BlockPaintedStair extends BlockStairs implements ITileEntityProvide
PainterUtil.setSourceBlock(result, block, damage);
return result;
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(PainterUtil.applyDefaultPaintedState(new ItemStack(item)));
}
@@ -151,6 +152,7 @@ public class BlockPaintedStair extends BlockStairs implements ITileEntityProvide
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
@@ -255,7 +257,7 @@ public class BlockPaintedStair extends BlockStairs implements ITileEntityProvide
Block blk = Block.getBlockFromItem(target.getItem());
return blk instanceof BlockStairs;
}
-
+
}
}
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedWall.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedWall.java
index e9284299..d439496f 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedWall.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedWall.java
@@ -57,9 +57,10 @@ public class BlockPaintedWall extends BlockWall implements ITileEntityProvider,
PainterUtil.setSourceBlock(result, id, damage);
return result;
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
+ @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(PainterUtil.applyDefaultPaintedState(new ItemStack(item)));
}
@@ -171,6 +172,7 @@ public class BlockPaintedWall extends BlockWall implements ITileEntityProvider,
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPainter.java b/src/main/java/crazypants/enderio/machine/painter/BlockPainter.java
index b935273e..95dd36f5 100644
--- a/src/main/java/crazypants/enderio/machine/painter/BlockPainter.java
+++ b/src/main/java/crazypants/enderio/machine/painter/BlockPainter.java
@@ -24,7 +24,7 @@ public class BlockPainter extends AbstractMachineBlock {
}
private IIcon invisibleIcon;
-
+
private BlockPainter() {
super(ModObject.blockPainter, TileEntityPainter.class);
}
@@ -41,6 +41,7 @@ public class BlockPainter extends AbstractMachineBlock {
}
@Override
+ @SideOnly(Side.CLIENT)
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
return new GuiPainter(player.inventory, (TileEntityPainter) te);
@@ -50,7 +51,7 @@ public class BlockPainter extends AbstractMachineBlock {
protected int getGuiId() {
return GuiHandler.GUI_ID_PAINTER;
}
-
+
public IIcon getInvisibleIcon() {
return invisibleIcon;
}
@@ -61,7 +62,7 @@ public class BlockPainter extends AbstractMachineBlock {
@Override
@SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister iIconRegister) {
+ public void registerBlockIcons(IIconRegister iIconRegister) {
super.registerBlockIcons(iIconRegister);
invisibleIcon = iIconRegister.registerIcon("enderio:invisblePaint");
}
diff --git a/src/main/java/crazypants/enderio/machine/painter/PainterUtil.java b/src/main/java/crazypants/enderio/machine/painter/PainterUtil.java
index 479bae34..ea52cd0f 100644
--- a/src/main/java/crazypants/enderio/machine/painter/PainterUtil.java
+++ b/src/main/java/crazypants/enderio/machine/painter/PainterUtil.java
@@ -57,8 +57,11 @@ public final class PainterUtil {
Block sourceId = PainterUtil.getSourceBlock(item);
int meta = PainterUtil.getSourceBlockMetadata(item);
if(sourceId != null) {
- ItemStack is = new ItemStack(Item.getItemFromBlock(sourceId), 1, meta);
- sourceName = is.getDisplayName();
+ Item itemFromBlock = Item.getItemFromBlock(sourceId);
+ if (itemFromBlock != null) {
+ ItemStack is = new ItemStack(itemFromBlock, 1, meta);
+ sourceName = is.getDisplayName();
+ }
}
return Lang.localize("blockPainter.paintedWith") + " " + sourceName;
}
diff --git a/src/main/java/crazypants/enderio/machine/power/BlockCapacitorBank.java b/src/main/java/crazypants/enderio/machine/power/BlockCapacitorBank.java
index 7160e067..0424f85e 100644
--- a/src/main/java/crazypants/enderio/machine/power/BlockCapacitorBank.java
+++ b/src/main/java/crazypants/enderio/machine/power/BlockCapacitorBank.java
@@ -138,10 +138,10 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
return true;
}
-
+
return super.onBlockActivated(world, x, y, z, entityPlayer, side, par7, par8, par9);
}
-
+
@Override
protected boolean openGui(World world, int x, int y, int z, EntityPlayer entityPlayer, int side) {
if(!world.isRemote) {
@@ -200,6 +200,7 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
}
@Override
+ @SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
Block i1 = par1IBlockAccess.getBlock(par2, par3, par4);
return i1 == this ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
@@ -318,12 +319,12 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
if(te instanceof TileCapacitorBank) {
if(((TileCapacitorBank)te).isMaxSize()) {
((EntityPlayer)player).addChatComponentMessage(new ChatComponentText("Capacitor bank is at maximum size"));
- }
- }
+ }
+ }
}
-
+
}
-
+
}
world.markBlockForUpdate(x, y, z);
}
@@ -370,12 +371,12 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
}
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
-
+
@Override
public boolean hasComparatorInputOverride() {
return true;
}
-
+
@Override
public int getComparatorInputOverride(World w, int x, int y, int z, int side) {
TileEntity te = w.getTileEntity(x, y, z);
@@ -391,7 +392,7 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
if (te instanceof TileCapacitorBank) {
TileCapacitorBank cap = (TileCapacitorBank) te;
String format = Util.TAB + Util.ALIGNRIGHT + EnumChatFormatting.WHITE;
-
+
tooltip.add(String.format("%s : %s%s%sRF/t ", Lang.localize("capbank.maxIO"), format, fmt.format(cap.getMaxIO()), Util.TAB + Util.ALIGNRIGHT));
tooltip.add(String.format("%s : %s%s%sRF/t ", Lang.localize("capbank.maxIn"), format, fmt.format(cap.getMaxInput()), Util.TAB + Util.ALIGNRIGHT));
tooltip.add(String.format("%s : %s%s%sRF/t ", Lang.localize("capbank.maxOut"), format, fmt.format(cap.getMaxOutput()), Util.TAB + Util.ALIGNRIGHT));
diff --git a/src/main/java/crazypants/enderio/machine/power/BlockItemCapacitorBank.java b/src/main/java/crazypants/enderio/machine/power/BlockItemCapacitorBank.java
index e579a5cc..ea6ce3fe 100644
--- a/src/main/java/crazypants/enderio/machine/power/BlockItemCapacitorBank.java
+++ b/src/main/java/crazypants/enderio/machine/power/BlockItemCapacitorBank.java
@@ -8,6 +8,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import cofh.api.energy.IEnergyContainerItem;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.power.PowerHandlerUtil;
@@ -48,6 +50,7 @@ public class BlockItemCapacitorBank extends ItemBlock implements IEnergyContaine
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
ItemStack stack = createItemStackWithPower(0);
par3List.add(stack);
diff --git a/src/main/java/crazypants/enderio/machine/power/CapacitorBankRenderer.java b/src/main/java/crazypants/enderio/machine/power/CapacitorBankRenderer.java
index ba4d4482..f9d1bbab 100644
--- a/src/main/java/crazypants/enderio/machine/power/CapacitorBankRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/power/CapacitorBankRenderer.java
@@ -15,6 +15,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.power.PowerHandlerUtil;
import crazypants.render.BoundingBox;
@@ -26,6 +28,7 @@ import crazypants.vecmath.Vector2f;
import crazypants.vecmath.Vector4d;
import crazypants.vecmath.Vertex;
+@SideOnly(Side.CLIENT)
public class CapacitorBankRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
private static final BlockCoord DEFAULT_BC = new BlockCoord(0, 0, 0);
diff --git a/src/main/java/crazypants/enderio/machine/ranged/RangeRenerer.java b/src/main/java/crazypants/enderio/machine/ranged/RangeRenerer.java
index f72ceb95..b3931ec4 100644
--- a/src/main/java/crazypants/enderio/machine/ranged/RangeRenerer.java
+++ b/src/main/java/crazypants/enderio/machine/ranged/RangeRenerer.java
@@ -6,45 +6,49 @@ import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.render.BoundingBox;
import crazypants.render.CubeRenderer;
import crazypants.render.IconUtil;
import crazypants.render.RenderUtil;
+@SideOnly(Side.CLIENT)
public class RangeRenerer extends RenderEntity {
+ @Override
public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
RangeEntity se = ((RangeEntity) entity);
-
- GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
-
+
float scale = 1 - ( se.lifeSpan / (float)se.totalLife);
scale = Math.min(scale, 1);
scale *= se.range;
-
- GL11.glPushMatrix();
+
+ GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
-
- GL11.glTranslatef(0.5f,0.5f,0.5f);
+
+ GL11.glTranslatef(0.5f,0.5f,0.5f);
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(-0.5f,-0.5f,-0.5f);
-
- GL11.glColor4f(1, 1, 1, 0.4f);
-
+
+ GL11.glColor4f(1, 1, 1, 0.4f);
+
RenderUtil.bindBlockTexture();
Tessellator.instance.startDrawingQuads();
Tessellator.instance.setBrightness(15 << 20 | 15 << 4);
CubeRenderer.render(BoundingBox.UNIT_CUBE, IconUtil.whiteTexture);
Tessellator.instance.draw();
-
+
RenderUtil.bindItemTexture();
-
+
GL11.glDepthMask(true);
GL11.glPopAttrib();
GL11.glPopMatrix();
diff --git a/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java b/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java
index 43488482..cb269c50 100644
--- a/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java
+++ b/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java
@@ -54,10 +54,12 @@ public class OreDictionaryRecipeInput extends RecipeInput {
if(res == null || res.isEmpty()) {
return null;
}
- for(ItemStack st : res) {
- st.stackSize = getInput().stackSize;
+ ItemStack[] res2 = res.toArray(new ItemStack[res.size()]);
+ for(int i = 0; i < res.size(); ++i) {
+ res2[i] = res2[i].copy();
+ res2[i].stackSize = getInput().stackSize;
}
- return res.toArray(new ItemStack[res.size()]);
+ return res2;
}
@Override
diff --git a/src/main/java/crazypants/enderio/machine/reservoir/BlockReservoir.java b/src/main/java/crazypants/enderio/machine/reservoir/BlockReservoir.java
index 445a6087..96472cce 100644
--- a/src/main/java/crazypants/enderio/machine/reservoir/BlockReservoir.java
+++ b/src/main/java/crazypants/enderio/machine/reservoir/BlockReservoir.java
@@ -82,8 +82,8 @@ public class BlockReservoir extends BlockEio implements IResourceTooltipProvider
} else {
// Handle empty containers
- FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
- if(available != null && available.amount > 0) {
+ FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
+ if(available != null && available.amount > 0) {
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
if(current.getItem() == Items.bucket) {
filled = new ItemStack(Items.water_bucket);
@@ -187,6 +187,7 @@ public class BlockReservoir extends BlockEio implements IResourceTooltipProvider
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:reservoir");
for (MbFace face : MbFace.values()) {
@@ -201,7 +202,7 @@ public class BlockReservoir extends BlockEio implements IResourceTooltipProvider
if (y < 0 || y >= 256) { // getTileEntity is not safe for out of bounds coords
return false;
}
-
+
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileReservoir)) {
return true;
@@ -214,6 +215,7 @@ public class BlockReservoir extends BlockEio implements IResourceTooltipProvider
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
// used to render the block in the world
TileEntity te = world.getTileEntity(x, y, z);
diff --git a/src/main/java/crazypants/enderio/machine/reservoir/ReservoirRenderer.java b/src/main/java/crazypants/enderio/machine/reservoir/ReservoirRenderer.java
index 2911986b..0749d92d 100644
--- a/src/main/java/crazypants/enderio/machine/reservoir/ReservoirRenderer.java
+++ b/src/main/java/crazypants/enderio/machine/reservoir/ReservoirRenderer.java
@@ -11,12 +11,15 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.render.BoundingBox;
import crazypants.render.CubeRenderer;
import crazypants.render.RenderUtil;
import crazypants.vecmath.Vector3d;
import crazypants.vecmath.Vector3f;
+@SideOnly(Side.CLIENT)
public class ReservoirRenderer extends TileEntitySpecialRenderer {
private ResourceLocation texName = null;
diff --git a/src/main/java/crazypants/enderio/machine/solar/BlockItemSolarPanel.java b/src/main/java/crazypants/enderio/machine/solar/BlockItemSolarPanel.java
index a15ec040..72fce79f 100644
--- a/src/main/java/crazypants/enderio/machine/solar/BlockItemSolarPanel.java
+++ b/src/main/java/crazypants/enderio/machine/solar/BlockItemSolarPanel.java
@@ -8,6 +8,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlockWithMetadata;
import net.minecraft.item.ItemStack;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.config.Config;
@@ -24,47 +26,48 @@ public class BlockItemSolarPanel extends ItemBlockWithMetadata implements IAdvan
setHasSubtypes(true);
setCreativeTab(EnderIOTab.tabEnderIO);
}
-
+
public BlockItemSolarPanel(Block block) {
super(block, block);
setHasSubtypes(true);
setCreativeTab(EnderIOTab.tabEnderIO);
}
-
+
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int meta = par1ItemStack.getItemDamage();
- String result = super.getUnlocalizedName(par1ItemStack);
+ String result = super.getUnlocalizedName(par1ItemStack);
if(meta == 1) {
result += ".advanced";
}
return result;
}
-
+
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
ItemStack stack = new ItemStack(this, 1,0);
par3List.add(stack);
stack = new ItemStack(this, 1,1);
par3List.add(stack);
}
-
+
@SuppressWarnings("rawtypes")
@Override
- public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
+ public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
TooltipAddera.addCommonTooltipFromResources(list, itemstack);
}
@SuppressWarnings("rawtypes")
@Override
- public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
+ public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
- TooltipAddera.addDetailedTooltipFromResources(list, itemstack);
+ TooltipAddera.addDetailedTooltipFromResources(list, itemstack);
int prod = Config.maxPhotovoltaicOutputRF;
if(itemstack.getItemDamage() == 1) {
prod = Config.maxPhotovoltaicAdvancedOutputRF;
diff --git a/src/main/java/crazypants/enderio/machine/solar/BlockSolarPanel.java b/src/main/java/crazypants/enderio/machine/solar/BlockSolarPanel.java
index f2321179..e7310449 100644
--- a/src/main/java/crazypants/enderio/machine/solar/BlockSolarPanel.java
+++ b/src/main/java/crazypants/enderio/machine/solar/BlockSolarPanel.java
@@ -14,18 +14,15 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import cofh.api.energy.EnergyStorage;
import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.BlockEio;
import crazypants.enderio.ModObject;
-import crazypants.enderio.api.tool.ITool;
import crazypants.enderio.config.Config;
import crazypants.enderio.gui.IResourceTooltipProvider;
-import crazypants.enderio.tool.ToolUtil;
import crazypants.enderio.waila.IWailaInfoProvider;
-import crazypants.enderio.waila.WailaCompat;
import crazypants.util.Lang;
-import crazypants.util.Util;
public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvider, IWailaInfoProvider {
@@ -78,6 +75,7 @@ public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvide
}
@Override
+ @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if(side == ForgeDirection.UP.ordinal()) {
return meta == 0 ? blockIcon : advancedIcon;
@@ -103,6 +101,7 @@ public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvide
}
@Override
+ @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
blockIcon = register.registerIcon("enderio:solarPanelTop");
advancedIcon = register.registerIcon("enderio:solarPanelAdvancedTop");
diff --git a/src/main/java/crazypants/enderio/machine/spawner/BlockPoweredSpawner.java b/src/main/java/crazypants/enderio/machine/spawner/BlockPoweredSpawner.java
index 548c4151..11c2f647 100644
--- a/src/main/java/crazypants/enderio/machine/spawner/BlockPoweredSpawner.java
+++ b/src/main/java/crazypants/enderio/machine/spawner/BlockPoweredSpawner.java
@@ -193,7 +193,7 @@ public class BlockPoweredSpawner extends AbstractMachineBlock