diff options
| author | Lance5057 <Lance5057@gmail.com> | 2016-08-06 21:47:17 -0500 |
|---|---|---|
| committer | Lance5057 <Lance5057@gmail.com> | 2016-08-06 21:47:17 -0500 |
| commit | d10fd21692bad49e75a7d665005df940c91942f8 (patch) | |
| tree | fdc1be156df395c88a934f6f97487e78b36a8138 /src/api | |
| parent | ff41fd97eb377dd1ebd78b4b56e81c59ca786667 (diff) | |
Launch update
Only a week behind...
Diffstat (limited to 'src/api')
249 files changed, 7472 insertions, 5756 deletions
diff --git a/src/api/java/buildcraft/api/tools/IToolWrench.java b/src/api/java/buildcraft/api/tools/IToolWrench.java index c5c9d86..e48ae06 100644 --- a/src/api/java/buildcraft/api/tools/IToolWrench.java +++ b/src/api/java/buildcraft/api/tools/IToolWrench.java @@ -13,7 +13,8 @@ import net.minecraft.entity.player.EntityPlayer; /*** * Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft */ -public interface IToolWrench { +public interface IToolWrench +{ /*** * Called to ensure that the wrench can be used. To get the ItemStack that is used, check player.inventory.getCurrentItem() diff --git a/src/api/java/cofh/api/block/IDismantleable.java b/src/api/java/cofh/api/block/IDismantleable.java index 12c09e3..9a9c19a 100644 --- a/src/api/java/cofh/api/block/IDismantleable.java +++ b/src/api/java/cofh/api/block/IDismantleable.java @@ -12,7 +12,8 @@ import net.minecraft.world.World; * @author King Lemming * */ -public interface IDismantleable { +public interface IDismantleable +{ /** * Dismantles the block. If returnDrops is true, the drop(s) should be placed into the player's inventory. diff --git a/src/api/java/cofh/api/energy/EnergyStorage.java b/src/api/java/cofh/api/energy/EnergyStorage.java index 25e0126..01ec59b 100644 --- a/src/api/java/cofh/api/energy/EnergyStorage.java +++ b/src/api/java/cofh/api/energy/EnergyStorage.java @@ -8,80 +8,95 @@ import net.minecraft.nbt.NBTTagCompound; * @author King Lemming * */ -public class EnergyStorage implements IEnergyStorage { +public class EnergyStorage implements IEnergyStorage +{ - protected int energy; - protected int capacity; - protected int maxReceive; - protected int maxExtract; + protected int energy; + protected int capacity; + protected int maxReceive; + protected int maxExtract; - public EnergyStorage(int capacity) { + public EnergyStorage(int capacity) + { this(capacity, capacity, capacity); } - public EnergyStorage(int capacity, int maxTransfer) { + public EnergyStorage(int capacity, int maxTransfer) + { this(capacity, maxTransfer, maxTransfer); } - public EnergyStorage(int capacity, int maxReceive, int maxExtract) { + public EnergyStorage(int capacity, int maxReceive, int maxExtract) + { this.capacity = capacity; this.maxReceive = maxReceive; this.maxExtract = maxExtract; } - public EnergyStorage readFromNBT(NBTTagCompound nbt) { + public EnergyStorage readFromNBT(NBTTagCompound nbt) + { - this.energy = nbt.getInteger("Energy"); + energy = nbt.getInteger("Energy"); - if (energy > capacity) { + if(energy > capacity) + { energy = capacity; } return this; } - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + public NBTTagCompound writeToNBT(NBTTagCompound nbt) + { - if (energy < 0) { + if(energy < 0) + { energy = 0; } nbt.setInteger("Energy", energy); return nbt; } - public void setCapacity(int capacity) { + public void setCapacity(int capacity) + { this.capacity = capacity; - if (energy > capacity) { + if(energy > capacity) + { energy = capacity; } } - public void setMaxTransfer(int maxTransfer) { + public void setMaxTransfer(int maxTransfer) + { setMaxReceive(maxTransfer); setMaxExtract(maxTransfer); } - public void setMaxReceive(int maxReceive) { + public void setMaxReceive(int maxReceive) + { this.maxReceive = maxReceive; } - public void setMaxExtract(int maxExtract) { + public void setMaxExtract(int maxExtract) + { this.maxExtract = maxExtract; } - public int getMaxReceive() { + public int getMaxReceive() + { return maxReceive; } - public int getMaxExtract() { + public int getMaxExtract() + { return maxExtract; } @@ -92,13 +107,17 @@ public class EnergyStorage implements IEnergyStorage { * * @param energy */ - public void setEnergyStored(int energy) { + public void setEnergyStored(int energy) + { this.energy = energy; - if (this.energy > capacity) { + if(this.energy > capacity) + { this.energy = capacity; - } else if (this.energy < 0) { + } + else if(this.energy < 0) + { this.energy = 0; } } @@ -109,48 +128,58 @@ public class EnergyStorage implements IEnergyStorage { * * @param energy */ - public void modifyEnergyStored(int energy) { + public void modifyEnergyStored(int energy) + { this.energy += energy; - if (this.energy > capacity) { + if(this.energy > capacity) + { this.energy = capacity; - } else if (this.energy < 0) { + } + else if(this.energy < 0) + { this.energy = 0; } } /* IEnergyStorage */ @Override - public int receiveEnergy(int maxReceive, boolean simulate) { + public int receiveEnergy(int maxReceive, boolean simulate) + { - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + final int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { + if(!simulate) + { energy += energyReceived; } return energyReceived; } @Override - public int extractEnergy(int maxExtract, boolean simulate) { + public int extractEnergy(int maxExtract, boolean simulate) + { - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + final int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { + if(!simulate) + { energy -= energyExtracted; } return energyExtracted; } @Override - public int getEnergyStored() { + public int getEnergyStored() + { return energy; } @Override - public int getMaxEnergyStored() { + public int getMaxEnergyStored() + { return capacity; } diff --git a/src/api/java/cofh/api/energy/IEnergyConnection.java b/src/api/java/cofh/api/energy/IEnergyConnection.java index 301271e..a1fad46 100644 --- a/src/api/java/cofh/api/energy/IEnergyConnection.java +++ b/src/api/java/cofh/api/energy/IEnergyConnection.java @@ -11,7 +11,8 @@ import net.minecraftforge.common.util.ForgeDirection; * @author King Lemming * */ -public interface IEnergyConnection { +public interface IEnergyConnection +{ /** * Returns TRUE if the TileEntity can connect on a given side. diff --git a/src/api/java/cofh/api/energy/IEnergyContainerItem.java b/src/api/java/cofh/api/energy/IEnergyContainerItem.java index 3ef7257..43a570b 100644 --- a/src/api/java/cofh/api/energy/IEnergyContainerItem.java +++ b/src/api/java/cofh/api/energy/IEnergyContainerItem.java @@ -10,7 +10,8 @@ import net.minecraft.item.ItemStack; * @author King Lemming * */ -public interface IEnergyContainerItem { +public interface IEnergyContainerItem +{ /** * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. diff --git a/src/api/java/cofh/api/energy/IEnergyHandler.java b/src/api/java/cofh/api/energy/IEnergyHandler.java index 6a4600a..ea6d8fa 100644 --- a/src/api/java/cofh/api/energy/IEnergyHandler.java +++ b/src/api/java/cofh/api/energy/IEnergyHandler.java @@ -10,7 +10,8 @@ import net.minecraftforge.common.util.ForgeDirection; * @author King Lemming * */ -public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver { +public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver +{ // merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things) diff --git a/src/api/java/cofh/api/energy/IEnergyProvider.java b/src/api/java/cofh/api/energy/IEnergyProvider.java index 05287b3..0437e11 100644 --- a/src/api/java/cofh/api/energy/IEnergyProvider.java +++ b/src/api/java/cofh/api/energy/IEnergyProvider.java @@ -10,7 +10,8 @@ import net.minecraftforge.common.util.ForgeDirection; * @author King Lemming * */ -public interface IEnergyProvider extends IEnergyConnection { +public interface IEnergyProvider extends IEnergyConnection +{ /** * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. diff --git a/src/api/java/cofh/api/energy/IEnergyReceiver.java b/src/api/java/cofh/api/energy/IEnergyReceiver.java index c726e09..226e61d 100644 --- a/src/api/java/cofh/api/energy/IEnergyReceiver.java +++ b/src/api/java/cofh/api/energy/IEnergyReceiver.java @@ -10,7 +10,8 @@ import net.minecraftforge.common.util.ForgeDirection; * @author King Lemming * */ -public interface IEnergyReceiver extends IEnergyConnection { +public interface IEnergyReceiver extends IEnergyConnection +{ /** * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. diff --git a/src/api/java/cofh/api/energy/IEnergyStorage.java b/src/api/java/cofh/api/energy/IEnergyStorage.java index 414b265..4ea5935 100644 --- a/src/api/java/cofh/api/energy/IEnergyStorage.java +++ b/src/api/java/cofh/api/energy/IEnergyStorage.java @@ -9,7 +9,8 @@ package cofh.api.energy; * @author King Lemming * */ -public interface IEnergyStorage { +public interface IEnergyStorage +{ /** * Adds energy to the storage. Returns quantity of energy that was accepted. diff --git a/src/api/java/cofh/api/energy/ItemEnergyContainer.java b/src/api/java/cofh/api/energy/ItemEnergyContainer.java index 2d3659c..3e8e4fb 100644 --- a/src/api/java/cofh/api/energy/ItemEnergyContainer.java +++ b/src/api/java/cofh/api/energy/ItemEnergyContainer.java @@ -10,66 +10,78 @@ import net.minecraft.nbt.NBTTagCompound; * @author King Lemming * */ -public class ItemEnergyContainer extends Item implements IEnergyContainerItem { +public class ItemEnergyContainer extends Item implements IEnergyContainerItem +{ - protected int capacity; - protected int maxReceive; - protected int maxExtract; + protected int capacity; + protected int maxReceive; + protected int maxExtract; - public ItemEnergyContainer() { + public ItemEnergyContainer() + { } - public ItemEnergyContainer(int capacity) { + public ItemEnergyContainer(int capacity) + { this(capacity, capacity, capacity); } - public ItemEnergyContainer(int capacity, int maxTransfer) { + public ItemEnergyContainer(int capacity, int maxTransfer) + { this(capacity, maxTransfer, maxTransfer); } - public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { + public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) + { this.capacity = capacity; this.maxReceive = maxReceive; this.maxExtract = maxExtract; } - public ItemEnergyContainer setCapacity(int capacity) { + public ItemEnergyContainer setCapacity(int capacity) + { this.capacity = capacity; return this; } - public void setMaxTransfer(int maxTransfer) { + public void setMaxTransfer(int maxTransfer) + { setMaxReceive(maxTransfer); setMaxExtract(maxTransfer); } - public void setMaxReceive(int maxReceive) { + public void setMaxReceive(int maxReceive) + { this.maxReceive = maxReceive; } - public void setMaxExtract(int maxExtract) { + public void setMaxExtract(int maxExtract) + { this.maxExtract = maxExtract; } /* IEnergyContainerItem */ @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) + { - if (container.stackTagCompound == null) { + if(container.stackTagCompound == null) + { container.stackTagCompound = new NBTTagCompound(); } int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + final int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { + if(!simulate) + { energy += energyReceived; container.stackTagCompound.setInteger("Energy", energy); } @@ -77,15 +89,18 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem { } @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) + { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + if(container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) + { return 0; } int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + final int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { + if(!simulate) + { energy -= energyExtracted; container.stackTagCompound.setInteger("Energy", energy); } @@ -93,16 +108,19 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem { } @Override - public int getEnergyStored(ItemStack container) { + public int getEnergyStored(ItemStack container) + { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + if(container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) + { return 0; } return container.stackTagCompound.getInteger("Energy"); } @Override - public int getMaxEnergyStored(ItemStack container) { + public int getMaxEnergyStored(ItemStack container) + { return capacity; } diff --git a/src/api/java/cofh/api/energy/TileEnergyHandler.java b/src/api/java/cofh/api/energy/TileEnergyHandler.java index 7cc655e..b50940b 100644 --- a/src/api/java/cofh/api/energy/TileEnergyHandler.java +++ b/src/api/java/cofh/api/energy/TileEnergyHandler.java @@ -10,19 +10,22 @@ import net.minecraftforge.common.util.ForgeDirection; * @author King Lemming * */ -public class TileEnergyHandler extends TileEntity implements IEnergyHandler { +public class TileEnergyHandler extends TileEntity implements IEnergyHandler +{ - protected EnergyStorage storage = new EnergyStorage(32000); + protected EnergyStorage storage = new EnergyStorage(32000); @Override - public void readFromNBT(NBTTagCompound nbt) { + public void readFromNBT(NBTTagCompound nbt) + { super.readFromNBT(nbt); storage.readFromNBT(nbt); } @Override - public void writeToNBT(NBTTagCompound nbt) { + public void writeToNBT(NBTTagCompound nbt) + { super.writeToNBT(nbt); storage.writeToNBT(nbt); @@ -30,34 +33,39 @@ public class TileEnergyHandler extends TileEntity implements IEnergyHandler { /* IEnergyConnection */ @Override - public boolean canConnectEnergy(ForgeDirection from) { + public boolean canConnectEnergy(ForgeDirection from) + { return true; } /* IEnergyReceiver */ @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) + { return storage.receiveEnergy(maxReceive, simulate); } /* IEnergyProvider */ @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) + { return storage.extractEnergy(maxExtract, simulate); } /* IEnergyReceiver and IEnergyProvider */ @Override - public int getEnergyStored(ForgeDirection from) { + public int getEnergyStored(ForgeDirection from) + { return storage.getEnergyStored(); } @Override - public int getMaxEnergyStored(ForgeDirection from) { + public int getMaxEnergyStored(ForgeDirection from) + { return storage.getMaxEnergyStored(); } diff --git a/src/api/java/cofh/api/item/IToolHammer.java b/src/api/java/cofh/api/item/IToolHammer.java index f1b4bb9..efa5d07 100644 --- a/src/api/java/cofh/api/item/IToolHammer.java +++ b/src/api/java/cofh/api/item/IToolHammer.java @@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on subclasses of Item to have that item work as a tool for CoFH mods. */ -public interface IToolHammer { +public interface IToolHammer +{ /** * Called to ensure that the tool can be used. diff --git a/src/api/java/cofh/core/item/IEqualityOverrideItem.java b/src/api/java/cofh/core/item/IEqualityOverrideItem.java index c2dc3ac..e09423e 100644 --- a/src/api/java/cofh/core/item/IEqualityOverrideItem.java +++ b/src/api/java/cofh/core/item/IEqualityOverrideItem.java @@ -2,8 +2,9 @@ package cofh.core.item; import net.minecraft.item.ItemStack; -public interface IEqualityOverrideItem { +public interface IEqualityOverrideItem +{ public boolean isLastHeldItemEqual(ItemStack current, ItemStack previous); -}
\ No newline at end of file +} diff --git a/src/api/java/cofh/lib/util/helpers/BlockHelper.java b/src/api/java/cofh/lib/util/helpers/BlockHelper.java index 5342727..3b06035 100644 --- a/src/api/java/cofh/lib/util/helpers/BlockHelper.java +++ b/src/api/java/cofh/lib/util/helpers/BlockHelper.java @@ -24,64 +24,69 @@ import net.minecraftforge.common.util.ForgeDirection; * @author King Lemming * */ -public final class BlockHelper { +public final class BlockHelper +{ - private BlockHelper() { + private BlockHelper() + { } - public static int MAX_ID = 1024; - public static byte[] rotateType = new byte[MAX_ID]; - public static final int[][] SIDE_COORD_MOD = { { 0, -1, 0 }, { 0, 1, 0 }, { 0, 0, -1 }, { 0, 0, 1 }, { -1, 0, 0 }, { 1, 0, 0 } }; - public static float[][] SIDE_COORD_AABB = { { 1, -2, 1 }, { 1, 2, 1 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 1, 1 }, { 2, 1, 1 } }; - public static final byte[] SIDE_LEFT = { 4, 5, 5, 4, 2, 3 }; - public static final byte[] SIDE_RIGHT = { 5, 4, 4, 5, 3, 2 }; - public static final byte[] SIDE_OPPOSITE = { 1, 0, 3, 2, 5, 4 }; - public static final byte[] SIDE_ABOVE = { 3, 2, 1, 1, 1, 1 }; - public static final byte[] SIDE_BELOW = { 2, 3, 0, 0, 0, 0 }; + public static int MAX_ID = 1024; + public static byte[] rotateType = new byte[MAX_ID]; + public static final int[][] SIDE_COORD_MOD = { {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}, {-1, 0, 0}, {1, 0, 0}}; + public static float[][] SIDE_COORD_AABB = { {1, -2, 1}, {1, 2, 1}, {1, 1, 1}, {1, 1, 2}, {1, 1, 1}, {2, 1, 1}}; + public static final byte[] SIDE_LEFT = {4, 5, 5, 4, 2, 3}; + public static final byte[] SIDE_RIGHT = {5, 4, 4, 5, 3, 2}; + public static final byte[] SIDE_OPPOSITE = {1, 0, 3, 2, 5, 4}; + public static final byte[] SIDE_ABOVE = {3, 2, 1, 1, 1, 1}; + public static final byte[] SIDE_BELOW = {2, 3, 0, 0, 0, 0}; // These assume facing is towards negative - looking AT side 1, 3, or 5. - public static final byte[] ROTATE_CLOCK_Y = { 0, 1, 4, 5, 3, 2 }; - public static final byte[] ROTATE_CLOCK_Z = { 5, 4, 2, 3, 0, 1 }; - public static final byte[] ROTATE_CLOCK_X = { 2, 3, 1, 0, 4, 5 }; + public static final byte[] ROTATE_CLOCK_Y = {0, 1, 4, 5, 3, 2}; + public static final byte[] ROTATE_CLOCK_Z = {5, 4, 2, 3, 0, 1}; + public static final byte[] ROTATE_CLOCK_X = {2, 3, 1, 0, 4, 5}; - public static final byte[] ROTATE_COUNTER_Y = { 0, 1, 5, 4, 2, 3 }; - public static final byte[] ROTATE_COUNTER_Z = { 4, 5, 2, 3, 1, 0 }; - public static final byte[] ROTATE_COUNTER_X = { 3, 2, 0, 1, 4, 5 }; + public static final byte[] ROTATE_COUNTER_Y = {0, 1, 5, 4, 2, 3}; + public static final byte[] ROTATE_COUNTER_Z = {4, 5, 2, 3, 1, 0}; + public static final byte[] ROTATE_COUNTER_X = {3, 2, 0, 1, 4, 5}; - public static final byte[] INVERT_AROUND_Y = { 0, 1, 3, 2, 5, 4 }; - public static final byte[] INVERT_AROUND_Z = { 1, 0, 2, 3, 5, 4 }; - public static final byte[] INVERT_AROUND_X = { 1, 0, 3, 2, 4, 5 }; + public static final byte[] INVERT_AROUND_Y = {0, 1, 3, 2, 5, 4}; + public static final byte[] INVERT_AROUND_Z = {1, 0, 2, 3, 5, 4}; + public static final byte[] INVERT_AROUND_X = {1, 0, 3, 2, 4, 5}; // Map which gives relative Icon to use on a block which can be placed on any side. - public static final byte[][] ICON_ROTATION_MAP = new byte[6][]; - - static { - ICON_ROTATION_MAP[0] = new byte[] { 0, 1, 2, 3, 4, 5 }; - ICON_ROTATION_MAP[1] = new byte[] { 1, 0, 2, 3, 4, 5 }; - ICON_ROTATION_MAP[2] = new byte[] { 3, 2, 0, 1, 4, 5 }; - ICON_ROTATION_MAP[3] = new byte[] { 3, 2, 1, 0, 5, 4 }; - ICON_ROTATION_MAP[4] = new byte[] { 3, 2, 5, 4, 0, 1 }; - ICON_ROTATION_MAP[5] = new byte[] { 3, 2, 4, 5, 1, 0 }; - } - - public static final class RotationType { - - public static final int PREVENT = -1; - public static final int FOUR_WAY = 1; - public static final int SIX_WAY = 2; - public static final int RAIL = 3; - public static final int PUMPKIN = 4; - public static final int STAIRS = 5; - public static final int REDSTONE = 6; - public static final int LOG = 7; - public static final int SLAB = 8; - public static final int CHEST = 9; - public static final int LEVER = 10; - public static final int SIGN = 11; - } - - static { // TODO: review which of these can be removed in favor of the vanilla handler + public static final byte[][] ICON_ROTATION_MAP = new byte[6][]; + + static + { + ICON_ROTATION_MAP[0] = new byte[] {0, 1, 2, 3, 4, 5}; + ICON_ROTATION_MAP[1] = new byte[] {1, 0, 2, 3, 4, 5}; + ICON_ROTATION_MAP[2] = new byte[] {3, 2, 0, 1, 4, 5}; + ICON_ROTATION_MAP[3] = new byte[] {3, 2, 1, 0, 5, 4}; + ICON_ROTATION_MAP[4] = new byte[] {3, 2, 5, 4, 0, 1}; + ICON_ROTATION_MAP[5] = new byte[] {3, 2, 4, 5, 1, 0}; + } + + public static final class RotationType + { + + public static final int PREVENT = -1; + public static final int FOUR_WAY = 1; + public static final int SIX_WAY = 2; + public static final int RAIL = 3; + public static final int PUMPKIN = 4; + public static final int STAIRS = 5; + public static final int REDSTONE = 6; + public static final int LOG = 7; + public static final int SLAB = 8; + public static final int CHEST = 9; + public static final int LEVER = 10; + public static final int SIGN = 11; + } + + static + { // TODO: review which of these can be removed in favor of the vanilla handler rotateType[Block.getIdFromBlock(Blocks.bed)] = RotationType.PREVENT; rotateType[Block.getIdFromBlock(Blocks.stone_slab)] = RotationType.SLAB; @@ -129,144 +134,167 @@ public final class BlockHelper { rotateType[Block.getIdFromBlock(Blocks.quartz_stairs)] = RotationType.STAIRS; } - public static int getMicroBlockAngle(int side, float hitX, float hitY, float hitZ) { + public static int getMicroBlockAngle(int side, float hitX, float hitY, float hitZ) + { int direction = side ^ 1; - float degreeCenter = 0.32f / 2; + final float degreeCenter = 0.32f / 2; float x = 0, y = 0; - switch (side >> 1) { - case 0: - x = hitX; - y = hitZ; - break; - case 1: - x = hitX; - y = hitY; - break; - case 2: - x = hitY; - y = hitZ; - break; + switch(side >> 1) + { + case 0: + x = hitX; + y = hitZ; + break; + case 1: + x = hitX; + y = hitY; + break; + case 2: + x = hitY; + y = hitZ; + break; } x -= .5f; y -= .5f; - if (x * x + y * y > degreeCenter * degreeCenter) { + if(x * x + y * y > degreeCenter * degreeCenter) + { int a = (int) ((Math.atan2(x, y) + Math.PI) * 4 / Math.PI); a = ++a & 7; - switch (a >> 1) { - case 0: - case 4: - direction = 2; - break; - case 1: - direction = 4; - break; - case 2: - direction = 3; - break; - case 3: - direction = 5; - break; + switch(a >> 1) + { + case 0: + case 4: + direction = 2; + break; + case 1: + direction = 4; + break; + case 2: + direction = 3; + break; + case 3: + direction = 5; + break; } } return direction; } - public static ForgeDirection getMicroBlockAngle(ForgeDirection side, float hitX, float hitY, float hitZ) { + public static ForgeDirection getMicroBlockAngle(ForgeDirection side, float hitX, float hitY, float hitZ) + { return ForgeDirection.VALID_DIRECTIONS[getMicroBlockAngle(side.ordinal(), hitX, hitY, hitZ)]; } - public static int getHighestY(World world, int x, int z) { + public static int getHighestY(World world, int x, int z) + { return world.getChunkFromBlockCoords(x, z).getTopFilledSegment() + 16; } - public static int getSurfaceBlockY(World world, int x, int z) { + public static int getSurfaceBlockY(World world, int x, int z) + { int y = world.getChunkFromBlockCoords(x, z).getTopFilledSegment() + 16; Block block; - do { - if (--y < 0) { + do + { + if(--y < 0) + { break; } block = world.getBlock(x, y, z); - } while (block.isAir(world, x, y, z) || block.isReplaceable(world, x, y, z) || block.isLeaves(world, x, y, z) || block.isFoliage(world, x, y, z) - || block.canBeReplacedByLeaves(world, x, y, z)); + } + while(block.isAir(world, x, y, z) || block.isReplaceable(world, x, y, z) || block.isLeaves(world, x, y, z) || block.isFoliage(world, x, y, z) || block.canBeReplacedByLeaves(world, x, y, z)); return y; } - public static int getTopBlockY(World world, int x, int z) { + public static int getTopBlockY(World world, int x, int z) + { int y = world.getChunkFromBlockCoords(x, z).getTopFilledSegment() + 16; Block block; - do { - if (--y < 0) { + do + { + if(--y < 0) + { break; } block = world.getBlock(x, y, z); - } while (block.isAir(world, x, y, z)); + } + while(block.isAir(world, x, y, z)); return y; } - public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player, double distance, boolean fluid) { + public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player, double distance, boolean fluid) + { - Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); + final Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); Vec3 lookVec = player.getLook(1); posVec.yCoord += player.getEyeHeight(); lookVec = posVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance); return player.worldObj.rayTraceBlocks(posVec, lookVec, fluid); } - public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player, double distance) { + public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player, double distance) + { return getCurrentMovingObjectPosition(player, distance, false); } - public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player, boolean fluid) { + public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player, boolean fluid) + { return getCurrentMovingObjectPosition(player, player.capabilities.isCreativeMode ? 5.0F : 4.5F, fluid); } - public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player) { + public static MovingObjectPosition getCurrentMovingObjectPosition(EntityPlayer player) + { return getCurrentMovingObjectPosition(player, player.capabilities.isCreativeMode ? 5.0F : 4.5F, false); } - public static int getCurrentMousedOverSide(EntityPlayer player) { + public static int getCurrentMousedOverSide(EntityPlayer player) + { - MovingObjectPosition mouseOver = getCurrentMovingObjectPosition(player); + final MovingObjectPosition mouseOver = getCurrentMovingObjectPosition(player); return mouseOver == null ? 0 : mouseOver.sideHit; } - public static int determineXZPlaceFacing(EntityLivingBase living) { + public static int determineXZPlaceFacing(EntityLivingBase living) + { - int quadrant = MathHelper.floor_double(living.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + final int quadrant = MathHelper.floor_double(living.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - switch (quadrant) { - case 0: - return 2; - case 1: - return 5; - case 2: - return 3; - case 3: - return 4; + switch(quadrant) + { + case 0: + return 2; + case 1: + return 5; + case 2: + return 3; + case 3: + return 4; } return 3; } - public static boolean isEqual(Block blockA, Block blockB) { + public static boolean isEqual(Block blockA, Block blockB) + { - if (blockA == blockB) { + if(blockA == blockB) + { return true; } - if (blockA == null | blockB == null) { + if(blockA == null | blockB == null) + { return false; } return blockA.equals(blockB) || blockA.isAssociatedBlock(blockB); @@ -298,7 +326,8 @@ public final class BlockHelper { // ForgeDirection.values()[side]); // } - public static Block getAdjacentBlock(World world, int x, int y, int z, ForgeDirection dir) { + public static Block getAdjacentBlock(World world, int x, int y, int z, ForgeDirection dir) + { x += dir.offsetX; y += dir.offsetY; @@ -306,13 +335,15 @@ public final class BlockHelper { return world == null || !world.blockExists(x, y, z) ? Blocks.air : world.getBlock(x, y, z); } - public static Block getAdjacentBlock(World world, int x, int y, int z, int side) { + public static Block getAdjacentBlock(World world, int x, int y, int z, int side) + { return world == null ? Blocks.air : getAdjacentBlock(world, x, y, z, ForgeDirection.getOrientation(side)); } /* Safe Tile Entity Retrieval */ - public static TileEntity getAdjacentTileEntity(World world, int x, int y, int z, ForgeDirection dir) { + public static TileEntity getAdjacentTileEntity(World world, int x, int y, int z, ForgeDirection dir) + { x += dir.offsetX; y += dir.offsetY; @@ -320,233 +351,283 @@ public final class BlockHelper { return world == null || !world.blockExists(x, y, z) ? null : world.getTileEntity(x, y, z); } - public static TileEntity getAdjacentTileEntity(World world, int x, int y, int z, int side) { + public static TileEntity getAdjacentTileEntity(World world, int x, int y, int z, int side) + { return world == null ? null : getAdjacentTileEntity(world, x, y, z, ForgeDirection.getOrientation(side)); } - public static TileEntity getAdjacentTileEntity(TileEntity refTile, ForgeDirection dir) { + public static TileEntity getAdjacentTileEntity(TileEntity refTile, ForgeDirection dir) + { return refTile == null ? null : getAdjacentTileEntity(refTile.getWorldObj(), refTile.xCoord, refTile.yCoord, refTile.zCoord, dir); } - public static TileEntity getAdjacentTileEntity(TileEntity refTile, int side) { + public static TileEntity getAdjacentTileEntity(TileEntity refTile, int side) + { - return refTile == null ? null : getAdjacentTileEntity(refTile.getWorldObj(), refTile.xCoord, refTile.yCoord, refTile.zCoord, - ForgeDirection.values()[side]); + return refTile == null ? null : getAdjacentTileEntity(refTile.getWorldObj(), refTile.xCoord, refTile.yCoord, refTile.zCoord, ForgeDirection.values()[side]); } - public static int determineAdjacentSide(TileEntity refTile, int x, int y, int z) { + public static int determineAdjacentSide(TileEntity refTile, int x, int y, int z) + { return y > refTile.yCoord ? 1 : y < refTile.yCoord ? 0 : z > refTile.zCoord ? 3 : z < refTile.zCoord ? 2 : x > refTile.xCoord ? 5 : 4; } /* COORDINATE TRANSFORM */ - public static int[] getAdjacentCoordinatesForSide(MovingObjectPosition pos) { + public static int[] getAdjacentCoordinatesForSide(MovingObjectPosition pos) + { return getAdjacentCoordinatesForSide(pos.blockX, pos.blockY, pos.blockZ, pos.sideHit); } - public static int[] getAdjacentCoordinatesForSide(int x, int y, int z, int side) { + public static int[] getAdjacentCoordinatesForSide(int x, int y, int z, int side) + { - return new int[] { x + SIDE_COORD_MOD[side][0], y + SIDE_COORD_MOD[side][1], z + SIDE_COORD_MOD[side][2] }; + return new int[] {x + SIDE_COORD_MOD[side][0], y + SIDE_COORD_MOD[side][1], z + SIDE_COORD_MOD[side][2]}; } - public static AxisAlignedBB getAdjacentAABBForSide(MovingObjectPosition pos) { + public static AxisAlignedBB getAdjacentAABBForSide(MovingObjectPosition pos) + { return getAdjacentAABBForSide(pos.blockX, pos.blockY, pos.blockZ, pos.sideHit); } - public static AxisAlignedBB getAdjacentAABBForSide(int x, int y, int z, int side) { + public static AxisAlignedBB getAdjacentAABBForSide(int x, int y, int z, int side) + { - return AxisAlignedBB.getBoundingBox(x + SIDE_COORD_MOD[side][0], y + SIDE_COORD_MOD[side][1], z + SIDE_COORD_MOD[side][2], - x + SIDE_COORD_AABB[side][0], y + SIDE_COORD_AABB[side][1], z + SIDE_COORD_AABB[side][2]); + return AxisAlignedBB.getBoundingBox(x + SIDE_COORD_MOD[side][0], y + SIDE_COORD_MOD[side][1], z + SIDE_COORD_MOD[side][2], x + SIDE_COORD_AABB[side][0], y + SIDE_COORD_AABB[side][1], z + SIDE_COORD_AABB[side][2]); } - public static int getLeftSide(int side) { + public static int getLeftSide(int side) + { return SIDE_LEFT[side]; } - public static int getRightSide(int side) { + public static int getRightSide(int side) + { return SIDE_RIGHT[side]; } - public static int getOppositeSide(int side) { + public static int getOppositeSide(int side) + { return SIDE_OPPOSITE[side]; } - public static int getAboveSide(int side) { + public static int getAboveSide(int side) + { return SIDE_ABOVE[side]; } - public static int getBelowSide(int side) { + public static int getBelowSide(int side) + { return SIDE_BELOW[side]; } /* BLOCK ROTATION */ - public static boolean canRotate(Block block) { + public static boolean canRotate(Block block) + { - int bId = Block.getIdFromBlock(block); + final int bId = Block.getIdFromBlock(block); return bId < MAX_ID ? rotateType[Block.getIdFromBlock(block)] != 0 : false; } - public static int rotateVanillaBlock(World world, Block block, int x, int y, int z) { + public static int rotateVanillaBlock(World world, Block block, int x, int y, int z) + { - int bId = Block.getIdFromBlock(block), bMeta = world.getBlockMetadata(x, y, z); - switch (rotateType[bId]) { - case RotationType.FOUR_WAY: - return SIDE_LEFT[bMeta]; - case RotationType.SIX_WAY: - if (bMeta < 6) { - return ++bMeta % 6; - } - return bMeta; - case RotationType.RAIL: - if (bMeta < 2) { - return ++bMeta % 2; - } - return bMeta; - case RotationType.PUMPKIN: - return ++bMeta % 4; - case RotationType.STAIRS: - return ++bMeta % 8; - case RotationType.REDSTONE: - int upper = bMeta & 0xC; - int lower = bMeta & 0x3; - return upper + ++lower % 4; - case RotationType.LOG: - return (bMeta + 4) % 12; - case RotationType.SLAB: - return (bMeta + 8) % 16; - case RotationType.CHEST: - int coords[] = new int[3]; - for (int i = 2; i < 6; i++) { - coords = getAdjacentCoordinatesForSide(x, y, z, i); - if (isEqual(world.getBlock(coords[0], coords[1], coords[2]), block)) { - world.setBlockMetadataWithNotify(coords[0], coords[1], coords[2], SIDE_OPPOSITE[bMeta], 1); - return SIDE_OPPOSITE[bMeta]; + final int bId = Block.getIdFromBlock(block); + int bMeta = world.getBlockMetadata(x, y, z); + switch(rotateType[bId]) + { + case RotationType.FOUR_WAY: + return SIDE_LEFT[bMeta]; + case RotationType.SIX_WAY: + if(bMeta < 6) + { + return ++bMeta % 6; } - } - return SIDE_LEFT[bMeta]; - case RotationType.LEVER: - int shift = 0; - if (bMeta > 7) { - bMeta -= 8; - shift = 8; - } - if (bMeta == 5) { - return 6 + shift; - } else if (bMeta == 6) { - return 5 + shift; - } else if (bMeta == 7) { - return 0 + shift; - } else if (bMeta == 0) { - return 7 + shift; - } - return bMeta + shift; - case RotationType.SIGN: - return ++bMeta % 16; - case RotationType.PREVENT: - default: - return bMeta; + return bMeta; + case RotationType.RAIL: + if(bMeta < 2) + { + return ++bMeta % 2; + } + return bMeta; + case RotationType.PUMPKIN: + return ++bMeta % 4; + case RotationType.STAIRS: + return ++bMeta % 8; + case RotationType.REDSTONE: + final int upper = bMeta & 0xC; + int lower = bMeta & 0x3; + return upper + ++lower % 4; + case RotationType.LOG: + return (bMeta + 4) % 12; + case RotationType.SLAB: + return (bMeta + 8) % 16; + case RotationType.CHEST: + int coords[] = new int[3]; + for(int i = 2; i < 6; i++) + { + coords = getAdjacentCoordinatesForSide(x, y, z, i); + if(isEqual(world.getBlock(coords[0], coords[1], coords[2]), block)) + { + world.setBlockMetadataWithNotify(coords[0], coords[1], coords[2], SIDE_OPPOSITE[bMeta], 1); + return SIDE_OPPOSITE[bMeta]; + } + } + return SIDE_LEFT[bMeta]; + case RotationType.LEVER: + int shift = 0; + if(bMeta > 7) + { + bMeta -= 8; + shift = 8; + } + if(bMeta == 5) + { + return 6 + shift; + } + else if(bMeta == 6) + { + return 5 + shift; + } + else if(bMeta == 7) + { + return 0 + shift; + } + else if(bMeta == 0) + { + return 7 + shift; + } + return bMeta + shift; + case RotationType.SIGN: + return ++bMeta % 16; + case RotationType.PREVENT: + default: + return bMeta; } } - public static int rotateVanillaBlockAlt(World world, Block block, int x, int y, int z) { + public static int rotateVanillaBlockAlt(World world, Block block, int x, int y, int z) + { - int bId = Block.getIdFromBlock(block), bMeta = world.getBlockMetadata(x, y, z); - switch (rotateType[bId]) { - case RotationType.FOUR_WAY: - return SIDE_RIGHT[bMeta]; - case RotationType.SIX_WAY: - if (bMeta < 6) { - return (bMeta + 5) % 6; - } - return bMeta; - case RotationType.RAIL: - if (bMeta < 2) { - return ++bMeta % 2; - } - return bMeta; - case RotationType.PUMPKIN: - return (bMeta + 3) % 4; - case RotationType.STAIRS: - return (bMeta + 7) % 8; - case RotationType.REDSTONE: - int upper = bMeta & 0xC; - int lower = bMeta & 0x3; - return upper + (lower + 3) % 4; - case RotationType.LOG: - return (bMeta + 8) % 12; - case RotationType.SLAB: - return (bMeta + 8) % 16; - case RotationType.CHEST: - int coords[] = new int[3]; - for (int i = 2; i < 6; i++) { - coords = getAdjacentCoordinatesForSide(x, y, z, i); - if (isEqual(world.getBlock(coords[0], coords[1], coords[2]), block)) { - world.setBlockMetadataWithNotify(coords[0], coords[1], coords[2], SIDE_OPPOSITE[bMeta], 1); - return SIDE_OPPOSITE[bMeta]; + final int bId = Block.getIdFromBlock(block); + int bMeta = world.getBlockMetadata(x, y, z); + switch(rotateType[bId]) + { + case RotationType.FOUR_WAY: + return SIDE_RIGHT[bMeta]; + case RotationType.SIX_WAY: + if(bMeta < 6) + { + return (bMeta + 5) % 6; } - } - return SIDE_RIGHT[bMeta]; - case RotationType.LEVER: - int shift = 0; - if (bMeta > 7) { - bMeta -= 8; - shift = 8; - } - if (bMeta == 5) { - return 6 + shift; - } else if (bMeta == 6) { - return 5 + shift; - } else if (bMeta == 7) { - return 0 + shift; - } else if (bMeta == 0) { - return 7 + shift; - } - case RotationType.SIGN: - return ++bMeta % 16; - case RotationType.PREVENT: - default: - return bMeta; + return bMeta; + case RotationType.RAIL: + if(bMeta < 2) + { + return ++bMeta % 2; + } + return bMeta; + case RotationType.PUMPKIN: + return (bMeta + 3) % 4; + case RotationType.STAIRS: + return (bMeta + 7) % 8; + case RotationType.REDSTONE: + final int upper = bMeta & 0xC; + final int lower = bMeta & 0x3; + return upper + (lower + 3) % 4; + case RotationType.LOG: + return (bMeta + 8) % 12; + case RotationType.SLAB: + return (bMeta + 8) % 16; + case RotationType.CHEST: + int coords[] = new int[3]; + for(int i = 2; i < 6; i++) + { + coords = getAdjacentCoordinatesForSide(x, y, z, i); + if(isEqual(world.getBlock(coords[0], coords[1], coords[2]), block)) + { + world.setBlockMetadataWithNotify(coords[0], coords[1], coords[2], SIDE_OPPOSITE[bMeta], 1); + return SIDE_OPPOSITE[bMeta]; + } + } + return SIDE_RIGHT[bMeta]; + case RotationType.LEVER: + int shift = 0; + if(bMeta > 7) + { + bMeta -= 8; + shift = 8; + } + if(bMeta == 5) + { + return 6 + shift; + } + else if(bMeta == 6) + { + return 5 + shift; + } + else if(bMeta == 7) + { + return 0 + shift; + } + else if(bMeta == 0) + { + return 7 + shift; + } + case RotationType.SIGN: + return ++bMeta % 16; + case RotationType.PREVENT: + default: + return bMeta; } } - public static List<ItemStack> breakBlock(World worldObj, int x, int y, int z, Block block, int fortune, boolean doBreak, boolean silkTouch) { + public static List<ItemStack> breakBlock(World worldObj, int x, int y, int z, Block block, int fortune, boolean doBreak, boolean silkTouch) + { return breakBlock(worldObj, null, x, y, z, block, fortune, doBreak, silkTouch); } - public static List<ItemStack> breakBlock(World worldObj, EntityPlayer player, int x, int y, int z, Block block, int fortune, boolean doBreak, - boolean silkTouch) { + public static List<ItemStack> breakBlock(World worldObj, EntityPlayer player, int x, int y, int z, Block block, int fortune, boolean doBreak, boolean silkTouch) + { - if (block.getBlockHardness(worldObj, x, y, z) == -1) { + if(block.getBlockHardness(worldObj, x, y, z) == -1) + { return new LinkedList<ItemStack>(); } - int meta = worldObj.getBlockMetadata(x, y, z); + final int meta = worldObj.getBlockMetadata(x, y, z); List<ItemStack> stacks = null; - if (silkTouch && block.canSilkHarvest(worldObj, player, x, y, z, meta)) { + if(silkTouch && block.canSilkHarvest(worldObj, player, x, y, z, meta)) + { stacks = new LinkedList<ItemStack>(); stacks.add(createStackedBlock(block, meta)); - } else { + } + else + { stacks = block.getDrops(worldObj, x, y, z, meta, fortune); } - if (!doBreak) { + if(!doBreak) + { return stacks; } worldObj.playAuxSFXAtEntity(player, 2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); worldObj.setBlockToAir(x, y, z); - List<EntityItem> result = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - 2, y - 2, z - 2, x + 3, y + 3, z + 3)); - for (int i = 0; i < result.size(); i++) { - EntityItem entity = result.get(i); - if (entity.isDead || entity.getEntityItem().stackSize <= 0) { + final List<EntityItem> result = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - 2, y - 2, z - 2, x + 3, y + 3, z + 3)); + for(int i = 0; i < result.size(); i++) + { + final EntityItem entity = result.get(i); + if(entity.isDead || entity.getEntityItem().stackSize <= 0) + { continue; } stacks.add(entity.getEntityItem()); @@ -555,10 +636,12 @@ public final class BlockHelper { return stacks; } - public static ItemStack createStackedBlock(Block block, int bMeta) { + public static ItemStack createStackedBlock(Block block, int bMeta) + { - Item item = Item.getItemFromBlock(block); - if (item.getHasSubtypes()) { + final Item item = Item.getItemFromBlock(block); + if(item.getHasSubtypes()) + { return new ItemStack(item, 1, bMeta); } return new ItemStack(item, 1, 0); diff --git a/src/api/java/dynamicswordskills/api/ISword.java b/src/api/java/dynamicswordskills/api/ISword.java index d8f309b..9d81357 100644 --- a/src/api/java/dynamicswordskills/api/ISword.java +++ b/src/api/java/dynamicswordskills/api/ISword.java @@ -22,6 +22,7 @@ package dynamicswordskills.api; * {@link LeapingBlow}, {@link MortalDraw}, and {@link RisingCut} * */ -public interface ISword { +public interface ISword +{ -}
\ No newline at end of file +} diff --git a/src/api/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java b/src/api/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java index 13279ef..b917269 100644 --- a/src/api/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java +++ b/src/api/java/exterminatorJeff/undergroundBiomes/api/UBAPIHook.java @@ -4,8 +4,9 @@ package exterminatorJeff.undergroundBiomes.api; * Striped down version, get the full API from here: https://github.com/Zeno410/UndergroundBiomes1.7API * @author Zeno410 */ -public class UBAPIHook { - public static final UBAPIHook ubAPIHook = new UBAPIHook(); - //public UBDimensionalStrataColumnProvider dimensionalStrataColumnProvider; // set in the main Underground Biomes - public UBOreTexturizer ubOreTexturizer; +public class UBAPIHook +{ + public static final UBAPIHook ubAPIHook = new UBAPIHook(); + //public UBDimensionalStrataColumnProvider dimensionalStrataColumnProvider; // set in the main Underground Biomes + public UBOreTexturizer ubOreTexturizer; } diff --git a/src/api/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java b/src/api/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java index 947b156..2b9b6de 100644 --- a/src/api/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java +++ b/src/api/java/exterminatorJeff/undergroundBiomes/api/UBOreTexturizer.java @@ -5,9 +5,9 @@ package exterminatorJeff.undergroundBiomes.api; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; import net.minecraft.block.Block; import net.minecraft.world.World; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; /** * Striped down version, get the full API from here: https://github.com/Zeno410/UndergroundBiomes1.7API @@ -15,56 +15,70 @@ import net.minecraft.world.World; * It creates three new blocks for each texturized ore. * @author Zeno410 */ -public interface UBOreTexturizer { - // usage: Block is the ore block. - // Overlay name is the fully qualified name, e.g. modname:overlayName - // that static vars are fully qualified names for all the textures in the UB pack, just pass as is - // the event isn't needed per se, but if this is called anytime else, the blocks will not "stick" - public void setupUBOre(Block oreBlock, String overlayName, FMLPreInitializationEvent event); - public void setupUBOre(Block oreBlock, int metadata, String overlayName, FMLPreInitializationEvent event); - public void setupUBOre(Block oreBlock, int metadata, String overlayName, String blockName, FMLPreInitializationEvent event); +public interface UBOreTexturizer +{ + // usage: Block is the ore block. + // Overlay name is the fully qualified name, e.g. modname:overlayName + // that static vars are fully qualified names for all the textures in the UB pack, just pass as is + // the event isn't needed per se, but if this is called anytime else, the blocks will not "stick" + public void setupUBOre(Block oreBlock, String overlayName, FMLPreInitializationEvent event); + + public void setupUBOre(Block oreBlock, int metadata, String overlayName, FMLPreInitializationEvent event); + + public void setupUBOre(Block oreBlock, int metadata, String overlayName, String blockName, FMLPreInitializationEvent event); + + public void requestUBOreSetup(Block oreBlock, String overlayName) throws BlocksAreAlreadySet; + + public void requestUBOreSetup(Block oreBlock, int metadata, String overlayName) throws BlocksAreAlreadySet; + + public void requestUBOreSetup(Block oreBlock, int metadata, String overlayName, String blockName) throws BlocksAreAlreadySet; + + public void redoOres(int xInBlockCoordinates, int zInBlockCoordinates, World serverSideWorld); - public void requestUBOreSetup(Block oreBlock, String overlayName) throws BlocksAreAlreadySet; - public void requestUBOreSetup(Block oreBlock, int metadata, String overlayName) throws BlocksAreAlreadySet; - public void requestUBOreSetup(Block oreBlock, int metadata, String overlayName, String blockName) throws BlocksAreAlreadySet; - public void redoOres(int xInBlockCoordinates, int zInBlockCoordinates, World serverSideWorld) ; + public static String amber_overlay = "undergroundbiomes:amber_overlay"; + public static String cinnabar_overlay = "undergroundbiomes:cinnabar_overlay"; + public static String coal_overlay = "undergroundbiomes:coal_overlay"; + public static String copper_overlay = "undergroundbiomes:copper_overlay"; + public static String diamond_overlay = "undergroundbiomes:diamond_overlay"; + public static String emerald_overlay = "undergroundbiomes:emerald_overlay"; + public static String gold_overlay = "undergroundbiomes:gold_overlay"; + public static String iron_overlay = "undergroundbiomes:iron_overlay"; + public static String lapis_overlay = "undergroundbiomes:lapis_overlay"; + public static String lead_overlay = "undergroundbiomes:lead_overlay"; + public static String olivine_peridot_overlay = "undergroundbiomes:olivine-peridot_overlay"; + public static String redstone_overlay = "undergroundbiomes:redstone_overlay"; + public static String ruby_overlay = "undergroundbiomes:ruby_overlay"; + public static String sapphire_overlay = "undergroundbiomes:sapphire_overlay"; + public static String tin_overlay = "undergroundbiomes:tin_overlay"; + public static String uranium_overlay = "undergroundbiomes:uranium_overlay"; - public static String amber_overlay = "undergroundbiomes:amber_overlay"; - public static String cinnabar_overlay = "undergroundbiomes:cinnabar_overlay"; - public static String coal_overlay = "undergroundbiomes:coal_overlay"; - public static String copper_overlay = "undergroundbiomes:copper_overlay"; - public static String diamond_overlay = "undergroundbiomes:diamond_overlay"; - public static String emerald_overlay = "undergroundbiomes:emerald_overlay"; - public static String gold_overlay = "undergroundbiomes:gold_overlay"; - public static String iron_overlay = "undergroundbiomes:iron_overlay"; - public static String lapis_overlay = "undergroundbiomes:lapis_overlay"; - public static String lead_overlay = "undergroundbiomes:lead_overlay"; - public static String olivine_peridot_overlay = "undergroundbiomes:olivine-peridot_overlay"; - public static String redstone_overlay = "undergroundbiomes:redstone_overlay"; - public static String ruby_overlay = "undergroundbiomes:ruby_overlay"; - public static String sapphire_overlay = "undergroundbiomes:sapphire_overlay"; - public static String tin_overlay = "undergroundbiomes:tin_overlay"; - public static String uranium_overlay = "undergroundbiomes:uranium_overlay"; + public class BlocksAreAlreadySet extends RuntimeException + { + // this is thrown if UB has already run its pre-initialization step and can no longer register blocks + public final Block oreBlock; + public final String overlayName; - public class BlocksAreAlreadySet extends RuntimeException { - // this is thrown if UB has already run its pre-initialization step and can no longer register blocks - public final Block oreBlock; - public final String overlayName; - - public BlocksAreAlreadySet(Block oreBlock, String overlayName) { - this.oreBlock = oreBlock; - this.overlayName = overlayName; - } + public BlocksAreAlreadySet(Block oreBlock, String overlayName) + { + this.oreBlock = oreBlock; + this.overlayName = overlayName; + } - @Override - public String toString() { - String blockDescription = "undefined block"; - String overlayDescription = "undefined overlay"; - if (oreBlock != null) blockDescription = oreBlock.getUnlocalizedName(); - if (overlayName != null) overlayDescription = overlayName; - return "Attempt to create Underground Biomes ore for "+blockDescription+" with "+overlayDescription + - " after blocks have already been defined"; - } + @Override + public String toString() + { + String blockDescription = "undefined block"; + String overlayDescription = "undefined overlay"; + if(oreBlock != null) + { + blockDescription = oreBlock.getUnlocalizedName(); + } + if(overlayName != null) + { + overlayDescription = overlayName; + } + return "Attempt to create Underground Biomes ore for " + blockDescription + " with " + overlayDescription + " after blocks have already been defined"; + } - } + } } diff --git a/src/api/java/ic2/api/Direction.java b/src/api/java/ic2/api/Direction.java index b550ca3..ce0f077 100644 --- a/src/api/java/ic2/api/Direction.java +++ b/src/api/java/ic2/api/Direction.java @@ -5,13 +5,13 @@ import java.util.Set; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; /** * Represents the 6 possible directions along the axis of a block. */ -public enum Direction { +public enum Direction +{ /** * -X */ @@ -39,21 +39,27 @@ public enum Direction { */ ZP; - private Direction() { - int side = ordinal() / 2; - int sign = getSign(); + private Direction() + { + final int side = ordinal() / 2; + final int sign = getSign(); xOffset = side == 0 ? sign : 0; yOffset = side == 1 ? sign : 0; zOffset = side == 2 ? sign : 0; } - public static Direction fromSideValue(int side) { + public static Direction fromSideValue(int side) + { return directions[(side + 2) % 6]; } - public static Direction fromForgeDirection(ForgeDirection dir) { - if (dir == ForgeDirection.UNKNOWN) return null; + public static Direction fromForgeDirection(ForgeDirection dir) + { + if(dir == ForgeDirection.UNKNOWN) + { + return null; + } return fromSideValue(dir.ordinal()); } @@ -64,7 +70,8 @@ public enum Direction { * @param tileEntity tile entity to check * @return Adjacent tile entity or null if none exists */ - public TileEntity applyToTileEntity(TileEntity te) { + public TileEntity applyToTileEntity(TileEntity te) + { return applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); } @@ -77,16 +84,22 @@ public enum Direction { * @param z Z coordinate to check from * @return Adjacent tile entity or null if none exists */ - public TileEntity applyTo(World world, int x, int y, int z) { - int coords[] = { x, y, z }; + public TileEntity applyTo(World world, int x, int y, int z) + { + final int coords[] = {x, y, z}; coords[ordinal() / 2] += getSign(); - if (world != null && world.blockExists(coords[0], coords[1], coords[2])) { - try { + if(world != null && world.blockExists(coords[0], coords[1], coords[2])) + { + try + { return world.getTileEntity(coords[0], coords[1], coords[2]); - } catch (Exception e) { - throw new RuntimeException("error getting TileEntity at dim "+world.provider.dimensionId+" "+coords[0]+"/"+coords[1]+"/"+coords[2]); + } + catch(final Exception e) + { + throw new RuntimeException( + "error getting TileEntity at dim " + world.provider.dimensionId + " " + coords[0] + "/" + coords[1] + "/" + coords[2]); } } @@ -98,7 +111,8 @@ public enum Direction { * * @return Inverse direction */ - public Direction getInverse() { + public Direction getInverse() + { return directions[ordinal() ^ 1]; } @@ -107,7 +121,8 @@ public enum Direction { * * @return Minecraft side value */ - public int toSideValue() { + public int toSideValue() + { return (ordinal() + 4) % 6; } @@ -116,20 +131,21 @@ public enum Direction { * * @return -1 if the direction is negative, +1 if the direction is positive */ - private int getSign() { + private int getSign() + { return (ordinal() % 2) * 2 - 1; } - public ForgeDirection toForgeDirection() { + public ForgeDirection toForgeDirection() + { return ForgeDirection.getOrientation(toSideValue()); } - public final int xOffset; - public final int yOffset; - public final int zOffset; + public final int xOffset; + public final int yOffset; + public final int zOffset; - public static final Direction[] directions = Direction.values(); - public static final Set<Direction> noDirections = EnumSet.noneOf(Direction.class); - public static final Set<Direction> allDirections = EnumSet.allOf(Direction.class); + public static final Direction[] directions = Direction.values(); + public static final Set<Direction> noDirections = EnumSet.noneOf(Direction.class); + public static final Set<Direction> allDirections = EnumSet.allOf(Direction.class); } - diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/api/java/ic2/api/crops/BaseSeed.java index 89e7865..a7b55f6 100644 --- a/src/api/java/ic2/api/crops/BaseSeed.java +++ b/src/api/java/ic2/api/crops/BaseSeed.java @@ -3,7 +3,8 @@ package ic2.api.crops; /** * Base agriculture seed. Used to determine the state of a plant once it is planted from an item. */ -public class BaseSeed { +public class BaseSeed +{ /** * Create a BaseSeed object. * @@ -15,10 +16,11 @@ public class BaseSeed { * @param stackSize1 for internal usage only */ @SuppressWarnings("deprecation") - public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance, int stackSize) { + public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance, int stackSize) + { super(); this.crop = crop; - this.id = Crops.instance.getIdFor(crop); + id = Crops.instance.getIdFor(crop); this.size = size; this.statGrowth = statGrowth; this.statGain = statGain; @@ -30,53 +32,57 @@ public class BaseSeed { * @deprecated Use the CropCard version. */ @Deprecated - public BaseSeed(int id, int size, int statGrowth, int statGain, int statResistance, int stackSize) { + public BaseSeed(int id, int size, int statGrowth, int statGain, int statResistance, int stackSize) + { this(getCropFromId(id), size, statGrowth, statGain, statResistance, stackSize); } @SuppressWarnings("deprecation") - private static CropCard getCropFromId(int id) { - CropCard[] crops = Crops.instance.getCropList(); + private static CropCard getCropFromId(int id) + { + final CropCard[] crops = Crops.instance.getCropList(); - if (id < 0 || id >= crops.length) return null; + if(id < 0 || id >= crops.length) + { + return null; + } return crops[id]; } - /** * Plant. */ - public final CropCard crop; + public final CropCard crop; /** * @deprecated IDs aren't used anymore. */ @Deprecated - public int id; + public int id; /** * Plant size. */ - public int size; + public int size; /** * Plant growth stat. */ - public int statGrowth; + public int statGrowth; /** * Plant gain stat. */ - public int statGain; + public int statGain; /** * Plant resistance stat. */ - public int statResistance; + public int statResistance; /** * For internal usage only. */ - public int stackSize; + public int stackSize; } diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/api/java/ic2/api/crops/CropCard.java index 1d2b640..e2a16d8 100644 --- a/src/api/java/ic2/api/crops/CropCard.java +++ b/src/api/java/ic2/api/crops/CropCard.java @@ -6,7 +6,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.relauncher.Side; @@ -17,8 +16,10 @@ import cpw.mods.fml.relauncher.SideOnly; * * Any crop extending this can be registered using registerCrop to be added into the game. */ -public abstract class CropCard { - public CropCard() { +public abstract class CropCard +{ + public CropCard() + { modId = getModId(); // initialize mod id while we should be in the real owner's init event } @@ -46,7 +47,8 @@ public abstract class CropCard { * * @return Mod id. */ - public String owner() { // TODO: make abstract + public String owner() + { // TODO: make abstract return modId; } @@ -59,7 +61,8 @@ public abstract class CropCard { * * @return Unlocalized name. */ - public String displayName() { + public String displayName() + { return name(); // return the raw name for backwards compatibility } @@ -68,7 +71,8 @@ public abstract class CropCard { * * @return Your name */ - public String discoveredBy() { + public String discoveredBy() + { return "unknown"; } @@ -79,22 +83,37 @@ public abstract class CropCard { * @param i line to get, starting from 0 * @return The line */ - public String desc(int i) { - String[] att = attributes(); + public String desc(int i) + { + final String[] att = attributes(); - if (att == null || att.length == 0) return ""; + if(att == null || att.length == 0) + { + return ""; + } - if (i == 0) { + if(i == 0) + { String s = att[0]; - if (att.length >= 2) { - s+=", "+att[1]; - if (att.length >= 3) s+=","; + if(att.length >= 2) + { + s += ", " + att[1]; + if(att.length >= 3) + { + s += ","; + } } return s; } - if (att.length < 3) return ""; + if(att.length < 3) + { + return ""; + } String s = att[2]; - if (att.length >= 4) s+=", "+att[3]; + if(att.length >= 4) + { + s += ", " + att[3]; + } return s; } @@ -103,7 +122,8 @@ public abstract class CropCard { * @param crop reference to ICropTile * @return roots lengt use in isBlockBelow */ - public int getrootslength(ICropTile crop) { // TODO: camel case + public int getrootslength(ICropTile crop) + { // TODO: camel case return 1; } @@ -155,12 +175,14 @@ public abstract class CropCard { * ic2:crop/*, which will then read assets/yourmod/textures/blocks/crop/*.png. */ @SideOnly(Side.CLIENT) - public void registerSprites(IIconRegister iconRegister) { + public void registerSprites(IIconRegister iconRegister) + { textures = new IIcon[maxSize()]; - for (int i = 1; i <= textures.length; i++) { + for(int i = 1; i <= textures.length; i++) + { // ic2:crop/blockCrop.NAME.n is the legacy name for backwards compatiblity - textures[i - 1] = iconRegister.registerIcon("ic2:crop/blockCrop."+name()+"."+i); + textures[i - 1] = iconRegister.registerIcon("ic2:crop/blockCrop." + name() + "." + i); } } @@ -171,8 +193,12 @@ public abstract class CropCard { * @return 0-255, representing the sprite index on the crop's spritesheet. */ @SideOnly(Side.CLIENT) - public IIcon getSprite(ICropTile crop) { - if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; + public IIcon getSprite(ICropTile crop) + { + if(crop.getSize() <= 0 || crop.getSize() > textures.length) + { + return null; + } return textures[crop.getSize() - 1]; } @@ -181,7 +207,8 @@ public abstract class CropCard { * Amount of growth points needed to increase the plant's size. * Default is 200 * tier. */ - public int growthDuration(ICropTile crop) { + public int growthDuration(ICropTile crop) + { return tier() * 200; } @@ -214,7 +241,8 @@ public abstract class CropCard { * @param air air quality, influences by open gardens and less crops surrounding this one * @return 0-30 */ - public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) + { return (int) (humidity + nutrients + air); } @@ -224,11 +252,11 @@ public abstract class CropCard { * * @param crop crop to crossbreed with */ - public boolean canCross(ICropTile crop) { + public boolean canCross(ICropTile crop) + { return crop.getSize() >= 3; } - /** * Called when the plant is rightclicked by a player. * Default action is harvesting. @@ -239,7 +267,8 @@ public abstract class CropCard { * @param player player rightclicking the crop * @return Whether the plant has changed */ - public boolean rightclick(ICropTile crop, EntityPlayer player) { + public boolean rightclick(ICropTile crop, EntityPlayer player) + { return crop.harvest(true); } @@ -266,7 +295,8 @@ public abstract class CropCard { * * @return Chance to drop the gains */ - public float dropGainChance() { // TODO: change to double + public float dropGainChance() + { // TODO: change to double return (float) Math.pow(0.95, tier()); } @@ -285,8 +315,10 @@ public abstract class CropCard { * @param crop reference to ICropTile * @return Plant size after harvesting */ - public byte getSizeAfterHarvest(ICropTile crop) {return 1;} // TODO: change to int - + public byte getSizeAfterHarvest(ICropTile crop) + { + return 1; + } // TODO: change to int /** * Called when the plant is left clicked by a player. @@ -298,7 +330,8 @@ public abstract class CropCard { * @param player player left clicked the crop * @return Whether the plant has changed */ - public boolean leftclick(ICropTile crop, EntityPlayer player) { // TODO: camel case + public boolean leftclick(ICropTile crop, EntityPlayer player) + { // TODO: camel case return crop.pick(true); } @@ -309,11 +342,21 @@ public abstract class CropCard { * @param crop reference to ICropTile * @return Chance to drop the seeds */ - public float dropSeedChance(ICropTile crop) { - if (crop.getSize() == 1) return 0; + public float dropSeedChance(ICropTile crop) + { + if(crop.getSize() == 1) + { + return 0; + } float base = 0.5F; - if (crop.getSize() == 2) base/=2F; - for (int i = 0; i < tier(); i++) {base*=0.8;} + if(crop.getSize() == 2) + { + base /= 2F; + } + for(int i = 0; i < tier(); i++) + { + base *= 0.8; + } return base; } @@ -325,7 +368,8 @@ public abstract class CropCard { * @param crop reference to ICropTile * @return Seeds */ - public ItemStack getSeeds(ICropTile crop) { + public ItemStack getSeeds(ICropTile crop) + { return crop.generateSeeds(crop.getCrop(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); } @@ -334,7 +378,8 @@ public abstract class CropCard { * * @param crop reference to ICropTile */ - public void onNeighbourChange(ICropTile crop) { + public void onNeighbourChange(ICropTile crop) + { // } @@ -343,14 +388,18 @@ public abstract class CropCard { * * @return Whether the crop should emit redstone */ - public int emitRedstone(ICropTile crop) {return 0;} + public int emitRedstone(ICropTile crop) + { + return 0; + } /** * Called when the crop is destroyed. * * @param crop reference to ICropTile */ - public void onBlockDestroyed(ICropTile crop) { + public void onBlockDestroyed(ICropTile crop) + { // } @@ -360,7 +409,8 @@ public abstract class CropCard { * @param crop reference to ICropTile * @return Light value emitted */ - public int getEmittedLight(ICropTile crop) { + public int getEmittedLight(ICropTile crop) + { return 0; } @@ -371,22 +421,24 @@ public abstract class CropCard { * @param entity entity colliding * @return Whether trampling calculation should happen, return false if the plant is no longer valid. */ - public boolean onEntityCollision(ICropTile crop, Entity entity) { - if (entity instanceof EntityLivingBase) { + public boolean onEntityCollision(ICropTile crop, Entity entity) + { + if(entity instanceof EntityLivingBase) + { return ((EntityLivingBase) entity).isSprinting(); } return false; } - /** * Called every time the crop ticks. * Should be called every 256 ticks or around 13 seconds. * * @param crop reference to ICropTile */ - public void tick(ICropTile crop) { + public void tick(ICropTile crop) + { // nothing by default } @@ -397,12 +449,11 @@ public abstract class CropCard { * @param crop reference to ICropTile * @return Whether the plant spreads weed */ - public boolean isWeed(ICropTile crop) { - return crop.getSize() >= 2 && - (crop.getCrop() == Crops.weed || crop.getGrowth() >= 24); + public boolean isWeed(ICropTile crop) + { + return crop.getSize() >= 2 && (crop.getCrop() == Crops.weed || crop.getGrowth() >= 24); } - /** * Get this plant's ID. * @@ -410,16 +461,21 @@ public abstract class CropCard { * @deprecated IDs aren't used anymore. */ @Deprecated - public final int getId() { + public final int getId() + { return Crops.instance.getIdFor(this); } - private static String getModId() { - ModContainer modContainer = Loader.instance().activeModContainer(); + private static String getModId() + { + final ModContainer modContainer = Loader.instance().activeModContainer(); - if (modContainer != null) { + if(modContainer != null) + { return modContainer.getModId(); - } else { + } + else + { // this is bad if you are not actually IC2 assert false; @@ -428,8 +484,8 @@ public abstract class CropCard { } @SideOnly(Side.CLIENT) - protected IIcon textures[]; + protected IIcon textures[]; - private final String modId; // TODO: make owner abstract, remove modId auto detection + private final String modId; // TODO: make owner abstract, remove modId auto detection // TODO: add a clean way to obtain world reference and position } diff --git a/src/api/java/ic2/api/crops/Crops.java b/src/api/java/ic2/api/crops/Crops.java index a11059a..c6f0745 100644 --- a/src/api/java/ic2/api/crops/Crops.java +++ b/src/api/java/ic2/api/crops/Crops.java @@ -5,19 +5,18 @@ import java.util.Collection; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; - +import net.minecraftforge.common.BiomeDictionary.Type; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.BiomeDictionary.Type; - /** * General management of the crop system. */ -public abstract class Crops { - public static Crops instance; +public abstract class Crops +{ + public static Crops instance; - public static CropCard weed; // weed has special properties, thus it's exposed here + public static CropCard weed; // weed has special properties, thus it's exposed here /** * Adds a crop nutrient biome bonus. @@ -39,7 +38,6 @@ public abstract class Crops { */ public abstract void addBiomehumidityBonus(Type type, int humidityBonus); - /** * Gets the humidity bonus for a biome. * diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/api/java/ic2/api/crops/ICropTile.java index dadf691..5ad2f6f 100644 --- a/src/api/java/ic2/api/crops/ICropTile.java +++ b/src/api/java/ic2/api/crops/ICropTile.java @@ -9,7 +9,8 @@ import net.minecraft.world.World; /** * Interface implemented by the crop tile entity. */ -public interface ICropTile { +public interface ICropTile +{ /** * Get the crop. * diff --git a/src/api/java/ic2/api/crops/package-info.java b/src/api/java/ic2/api/crops/package-info.java index 04b8253..018003a 100644 --- a/src/api/java/ic2/api/crops/package-info.java +++ b/src/api/java/ic2/api/crops/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.crops; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/EnergyNet.java b/src/api/java/ic2/api/energy/EnergyNet.java index 822bfc2..05a2b59 100644 --- a/src/api/java/ic2/api/energy/EnergyNet.java +++ b/src/api/java/ic2/api/energy/EnergyNet.java @@ -1,6 +1,5 @@ package ic2.api.energy; - /** * Provides access to the energy network. * @@ -9,10 +8,10 @@ package ic2.api.energy; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public final class EnergyNet { +public final class EnergyNet +{ /** * Instance of the global EnergyNet class. */ - public static IEnergyNet instance; + public static IEnergyNet instance; } - diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/api/java/ic2/api/energy/IEnergyNet.java index 8f656e5..e3058ea 100644 --- a/src/api/java/ic2/api/energy/IEnergyNet.java +++ b/src/api/java/ic2/api/energy/IEnergyNet.java @@ -2,7 +2,6 @@ package ic2.api.energy; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; /** @@ -10,7 +9,8 @@ import net.minecraftforge.common.util.ForgeDirection; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergyNet { +public interface IEnergyNet +{ /** * Get the EnergyNet-registered tile entity at the specified position. * diff --git a/src/api/java/ic2/api/energy/NodeStats.java b/src/api/java/ic2/api/energy/NodeStats.java index db33da7..e38b5e2 100644 --- a/src/api/java/ic2/api/energy/NodeStats.java +++ b/src/api/java/ic2/api/energy/NodeStats.java @@ -1,25 +1,30 @@ package ic2.api.energy; -public class NodeStats { - public NodeStats(double energyIn, double energyOut, double voltage) { +public class NodeStats +{ + public NodeStats(double energyIn, double energyOut, double voltage) + { this.energyIn = energyIn; this.energyOut = energyOut; this.voltage = voltage; } - public double getEnergyIn() { + public double getEnergyIn() + { return energyIn; } - public double getEnergyOut() { + public double getEnergyOut() + { return energyOut; } - public double getVoltage() { + public double getVoltage() + { return voltage; } - protected double energyIn; - protected double energyOut; - protected double voltage; + protected double energyIn; + protected double energyOut; + protected double voltage; } diff --git a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java index 86b8dc2..1fc04d3 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java @@ -1,25 +1,27 @@ package ic2.api.energy.event; +import ic2.api.energy.tile.IEnergyTile; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.event.world.WorldEvent; -import ic2.api.energy.tile.IEnergyTile; - /** * Base class for energy net events, don't use it directly. * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public class EnergyTileEvent extends WorldEvent { - public final IEnergyTile energyTile; +public class EnergyTileEvent extends WorldEvent +{ + public final IEnergyTile energyTile; - public EnergyTileEvent(IEnergyTile energyTile1) { + public EnergyTileEvent(IEnergyTile energyTile1) + { super(((TileEntity) energyTile1).getWorldObj()); - if (world == null) throw new NullPointerException("world is null"); + if(world == null) + { + throw new NullPointerException("world is null"); + } - this.energyTile = energyTile1; + energyTile = energyTile1; } } - diff --git a/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java index bf019ae..62192f7 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java @@ -18,9 +18,10 @@ import ic2.api.energy.tile.IEnergyTile; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public class EnergyTileLoadEvent extends EnergyTileEvent { - public EnergyTileLoadEvent(IEnergyTile energyTile1) { +public class EnergyTileLoadEvent extends EnergyTileEvent +{ + public EnergyTileLoadEvent(IEnergyTile energyTile1) + { super(energyTile1); } } - diff --git a/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java index 2b22ae3..cf44877 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java @@ -19,9 +19,10 @@ import ic2.api.energy.tile.IEnergyTile; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public class EnergyTileUnloadEvent extends EnergyTileEvent { - public EnergyTileUnloadEvent(IEnergyTile energyTile1) { +public class EnergyTileUnloadEvent extends EnergyTileEvent +{ + public EnergyTileUnloadEvent(IEnergyTile energyTile1) + { super(energyTile1); } } - diff --git a/src/api/java/ic2/api/energy/event/package-info.java b/src/api/java/ic2/api/energy/event/package-info.java index 40db6f8..de3bb9e 100644 --- a/src/api/java/ic2/api/energy/event/package-info.java +++ b/src/api/java/ic2/api/energy/event/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.event; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/package-info.java b/src/api/java/ic2/api/energy/package-info.java index 81d0bfe..0efa97f 100644 --- a/src/api/java/ic2/api/energy/package-info.java +++ b/src/api/java/ic2/api/energy/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.java b/src/api/java/ic2/api/energy/prefab/BasicSink.java index 48de061..4b93858 100644 --- a/src/api/java/ic2/api/energy/prefab/BasicSink.java +++ b/src/api/java/ic2/api/energy/prefab/BasicSink.java @@ -1,19 +1,16 @@ package ic2.api.energy.prefab; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - -import cpw.mods.fml.common.FMLCommonHandler; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; - import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; import ic2.api.info.Info; import ic2.api.item.ElectricItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.FMLCommonHandler; /** * BasicSink is a simple adapter to provide an ic2 energy sink. @@ -88,7 +85,8 @@ import ic2.api.item.ElectricItem; * } * @endcode */ -public class BasicSink extends TileEntity implements IEnergySink { +public class BasicSink extends TileEntity implements IEnergySink +{ // ********************************** // *** Methods for use by the mod *** // ********************************** @@ -100,10 +98,11 @@ public class BasicSink extends TileEntity implements IEnergySink { * @param capacity1 Maximum amount of eu to store. * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... */ - public BasicSink(TileEntity parent1, int capacity1, int tier1) { - this.parent = parent1; - this.capacity = capacity1; - this.tier = tier1; + public BasicSink(TileEntity parent1, int capacity1, int tier1) + { + parent = parent1; + capacity = capacity1; + tier = tier1; } // in-world te forwards >> @@ -113,18 +112,22 @@ public class BasicSink extends TileEntity implements IEnergySink { * Either updateEntity or onLoaded have to be used. */ @Override - public void updateEntity() { - if (!addedToEnet) onLoaded(); + public void updateEntity() + { + if(!addedToEnet) + { + onLoaded(); + } } /** * Notification that the base TileEntity finished loaded, for advanced uses. * Either updateEntity or onLoaded have to be used. */ - public void onLoaded() { - if (!addedToEnet && - !FMLCommonHandler.instance().getEffectiveSide().isClient() && - Info.isIc2Available()) { + public void onLoaded() + { + if(!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient() && Info.isIc2Available()) + { worldObj = parent.getWorldObj(); xCoord = parent.xCoord; yCoord = parent.yCoord; @@ -141,7 +144,8 @@ public class BasicSink extends TileEntity implements IEnergySink { * Both invalidate and onChunkUnload have to be used. */ @Override - public void invalidate() { + public void invalidate() + { super.invalidate(); onChunkUnload(); @@ -152,9 +156,10 @@ public class BasicSink extends TileEntity implements IEnergySink { * Both invalidate and onChunkUnload have to be used. */ @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { + public void onChunkUnload() + { + if(addedToEnet && Info.isIc2Available()) + { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); addedToEnet = false; @@ -167,10 +172,11 @@ public class BasicSink extends TileEntity implements IEnergySink { * @param tag Compound tag as supplied by TileEntity.readFromNBT() */ @Override - public void readFromNBT(NBTTagCompound tag) { + public void readFromNBT(NBTTagCompound tag) + { super.readFromNBT(tag); - NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); + final NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); energyStored = data.getDouble("energy"); } @@ -181,14 +187,18 @@ public class BasicSink extends TileEntity implements IEnergySink { * @param tag Compound tag as supplied by TileEntity.writeToNBT() */ @Override - public void writeToNBT(NBTTagCompound tag) { - try { + public void writeToNBT(NBTTagCompound tag) + { + try + { super.writeToNBT(tag); - } catch (RuntimeException e) { + } + catch(final RuntimeException e) + { // happens if this is a delegate, ignore } - NBTTagCompound data = new NBTTagCompound(); + final NBTTagCompound data = new NBTTagCompound(); data.setDouble("energy", energyStored); @@ -203,7 +213,8 @@ public class BasicSink extends TileEntity implements IEnergySink { * * @return Capacity in EU. */ - public int getCapacity() { + public int getCapacity() + { return capacity; } @@ -212,8 +223,9 @@ public class BasicSink extends TileEntity implements IEnergySink { * * @param capacity1 Capacity in EU. */ - public void setCapacity(int capacity1) { - this.capacity = capacity1; + public void setCapacity(int capacity1) + { + capacity = capacity1; } /** @@ -221,7 +233,8 @@ public class BasicSink extends TileEntity implements IEnergySink { * * @return IC2 Tier. */ - public int getTier() { + public int getTier() + { return tier; } @@ -230,8 +243,9 @@ public class BasicSink extends TileEntity implements IEnergySink { * * @param tier1 IC2 Tier. */ - public void setTier(int tier1) { - this.tier = tier1; + public void setTier(int tier1) + { + tier = tier1; } /** @@ -239,7 +253,8 @@ public class BasicSink extends TileEntity implements IEnergySink { * * @return amount in EU, may be above capacity */ - public double getEnergyStored() { + public double getEnergyStored() + { return energyStored; } @@ -251,7 +266,8 @@ public class BasicSink extends TileEntity implements IEnergySink { * * @param amount */ - public void setEnergyStored(double amount) { + public void setEnergyStored(double amount) + { energyStored = amount; } @@ -261,7 +277,8 @@ public class BasicSink extends TileEntity implements IEnergySink { * @param amount in EU * @return true if the amount is available */ - public boolean canUseEnergy(double amount) { + public boolean canUseEnergy(double amount) + { return energyStored >= amount; } @@ -271,8 +288,10 @@ public class BasicSink extends TileEntity implements IEnergySink { * @param amount amount to use * @return true if the amount was available */ - public boolean useEnergy(double amount) { - if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean useEnergy(double amount) + { + if(canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) + { energyStored -= amount; return true; @@ -287,13 +306,23 @@ public class BasicSink extends TileEntity implements IEnergySink { * @param limit Transfer limit, values <= 0 will use the battery's limit * @return true if energy was transferred */ - public boolean discharge(ItemStack stack, int limit) { - if (stack == null || !Info.isIc2Available()) return false; + public boolean discharge(ItemStack stack, int limit) + { + if(stack == null || !Info.isIc2Available()) + { + return false; + } double amount = capacity - energyStored; - if (amount <= 0) return false; + if(amount <= 0) + { + return false; + } - if (limit > 0 && limit < amount) amount = limit; + if(limit > 0 && limit < amount) + { + amount = limit; + } amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); @@ -307,27 +336,32 @@ public class BasicSink extends TileEntity implements IEnergySink { // backwards compatibility (ignore these) >> @Deprecated - public void onUpdateEntity() { + public void onUpdateEntity() + { updateEntity(); } @Deprecated - public void onInvalidate() { + public void onInvalidate() + { invalidate(); } @Deprecated - public void onOnChunkUnload() { + public void onOnChunkUnload() + { onChunkUnload(); } @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { + public void onReadFromNbt(NBTTagCompound tag) + { readFromNBT(tag); } @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { + public void onWriteToNbt(NBTTagCompound tag) + { writeToNBT(tag); } @@ -340,34 +374,37 @@ public class BasicSink extends TileEntity implements IEnergySink { // energy net interface >> @Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) + { return true; } @Override - public double getDemandedEnergy() { + public double getDemandedEnergy() + { return Math.max(0, capacity - energyStored); } @Override - public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) + { energyStored += amount; return 0; } @Override - public int getSinkTier() { + public int getSinkTier() + { return tier; } // << energy net interface + public final TileEntity parent; - public final TileEntity parent; - - protected int capacity; - protected int tier; - protected double energyStored; - protected boolean addedToEnet; + protected int capacity; + protected int tier; + protected double energyStored; + protected boolean addedToEnet; } diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.java b/src/api/java/ic2/api/energy/prefab/BasicSource.java index 011e8cd..5be7e1c 100644 --- a/src/api/java/ic2/api/energy/prefab/BasicSource.java +++ b/src/api/java/ic2/api/energy/prefab/BasicSource.java @@ -1,20 +1,17 @@ package ic2.api.energy.prefab; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - -import cpw.mods.fml.common.FMLCommonHandler; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; - import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySource; import ic2.api.info.Info; import ic2.api.item.ElectricItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.FMLCommonHandler; /** * BasicSource is a simple adapter to provide an ic2 energy source. @@ -87,7 +84,8 @@ import ic2.api.item.ElectricItem; * } * @endcode */ -public class BasicSource extends TileEntity implements IEnergySource { +public class BasicSource extends TileEntity implements IEnergySource +{ // ********************************** // *** Methods for use by the mod *** // ********************************** @@ -99,12 +97,13 @@ public class BasicSource extends TileEntity implements IEnergySource { * @param capacity1 Maximum amount of eu to store. * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... */ - public BasicSource(TileEntity parent1, double capacity1, int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); + public BasicSource(TileEntity parent1, double capacity1, int tier1) + { + final double power = EnergyNet.instance.getPowerFromTier(tier1); - this.parent = parent1; - this.capacity = capacity1 < power ? power : capacity1; - this.tier = tier1; + parent = parent1; + capacity = capacity1 < power ? power : capacity1; + tier = tier1; this.power = power; } @@ -115,18 +114,22 @@ public class BasicSource extends TileEntity implements IEnergySource { * Either updateEntity or onLoaded have to be used. */ @Override - public void updateEntity() { - if (!addedToEnet) onLoaded(); + public void updateEntity() + { + if(!addedToEnet) + { + onLoaded(); + } } /** * Notification that the base TileEntity finished loading, for advanced uses. * Either updateEntity or onLoaded have to be used. */ - public void onLoaded() { - if (!addedToEnet && - !FMLCommonHandler.instance().getEffectiveSide().isClient() && - Info.isIc2Available()) { + public void onLoaded() + { + if(!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient() && Info.isIc2Available()) + { worldObj = parent.getWorldObj(); xCoord = parent.xCoord; yCoord = parent.yCoord; @@ -143,7 +146,8 @@ public class BasicSource extends TileEntity implements IEnergySource { * Both invalidate and onChunkUnload have to be used. */ @Override - public void invalidate() { + public void invalidate() + { super.invalidate(); onChunkUnload(); @@ -154,9 +158,10 @@ public class BasicSource extends TileEntity implements IEnergySource { * Both invalidate and onChunkUnload have to be used. */ @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { + public void onChunkUnload() + { + if(addedToEnet && Info.isIc2Available()) + { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); addedToEnet = false; @@ -169,10 +174,11 @@ public class BasicSource extends TileEntity implements IEnergySource { * @param tag Compound tag as supplied by TileEntity.readFromNBT() */ @Override - public void readFromNBT(NBTTagCompound tag) { + public void readFromNBT(NBTTagCompound tag) + { super.readFromNBT(tag); - NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); + final NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); energyStored = data.getDouble("energy"); } @@ -183,14 +189,18 @@ public class BasicSource extends TileEntity implements IEnergySource { * @param tag Compound tag as supplied by TileEntity.writeToNBT() */ @Override - public void writeToNBT(NBTTagCompound tag) { - try { + public void writeToNBT(NBTTagCompound tag) + { + try + { super.writeToNBT(tag); - } catch (RuntimeException e) { + } + catch(final RuntimeException e) + { // happens if this is a delegate, ignore } - NBTTagCompound data = new NBTTagCompound(); + final NBTTagCompound data = new NBTTagCompound(); data.setDouble("energy", energyStored); @@ -205,7 +215,8 @@ public class BasicSource extends TileEntity implements IEnergySource { * * @return Capacity in EU. */ - public double getCapacity() { + public double getCapacity() + { return capacity; } @@ -214,10 +225,14 @@ public class BasicSource extends TileEntity implements IEnergySource { * * @param capacity1 Capacity in EU. */ - public void setCapacity(double capacity1) { - if (capacity1 < power) capacity1 = power; + public void setCapacity(double capacity1) + { + if(capacity1 < power) + { + capacity1 = power; + } - this.capacity = capacity1; + capacity = capacity1; } /** @@ -225,7 +240,8 @@ public class BasicSource extends TileEntity implements IEnergySource { * * @return IC2 Tier. */ - public int getTier() { + public int getTier() + { return tier; } @@ -234,22 +250,26 @@ public class BasicSource extends TileEntity implements IEnergySource { * * @param tier1 IC2 Tier. */ - public void setTier(int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); + public void setTier(int tier1) + { + final double power = EnergyNet.instance.getPowerFromTier(tier1); - if (capacity < power) capacity = power; + if(capacity < power) + { + capacity = power; + } - this.tier = tier1; + tier = tier1; this.power = power; } - /** * Determine the energy stored in the source's output buffer. * * @return amount in EU */ - public double getEnergyStored() { + public double getEnergyStored() + { return energyStored; } @@ -261,7 +281,8 @@ public class BasicSource extends TileEntity implements IEnergySource { * * @param amount */ - public void setEnergyStored(double amount) { + public void setEnergyStored(double amount) + { energyStored = amount; } @@ -270,7 +291,8 @@ public class BasicSource extends TileEntity implements IEnergySource { * * @return amount in EU */ - public double getFreeCapacity() { + public double getFreeCapacity() + { return capacity - energyStored; } @@ -280,9 +302,16 @@ public class BasicSource extends TileEntity implements IEnergySource { * @param amount maximum amount of energy to add * @return amount added/used, NOT remaining */ - public double addEnergy(double amount) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; - if (amount > capacity - energyStored) amount = capacity - energyStored; + public double addEnergy(double amount) + { + if(FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + return 0; + } + if(amount > capacity - energyStored) + { + amount = capacity - energyStored; + } energyStored += amount; @@ -295,10 +324,14 @@ public class BasicSource extends TileEntity implements IEnergySource { * @param stack ItemStack to charge (null is ignored) * @return true if energy was transferred */ - public boolean charge(ItemStack stack) { - if (stack == null || !Info.isIc2Available()) return false; + public boolean charge(ItemStack stack) + { + if(stack == null || !Info.isIc2Available()) + { + return false; + } - double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); + final double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); energyStored -= amount; @@ -310,27 +343,32 @@ public class BasicSource extends TileEntity implements IEnergySource { // backwards compatibility (ignore these) >> @Deprecated - public void onUpdateEntity() { + public void onUpdateEntity() + { updateEntity(); } @Deprecated - public void onInvalidate() { + public void onInvalidate() + { invalidate(); } @Deprecated - public void onOnChunkUnload() { + public void onOnChunkUnload() + { onChunkUnload(); } @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { + public void onReadFromNbt(NBTTagCompound tag) + { readFromNBT(tag); } @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { + public void onWriteToNbt(NBTTagCompound tag) + { writeToNBT(tag); } @@ -343,33 +381,36 @@ public class BasicSource extends TileEntity implements IEnergySource { // energy net interface >> @Override - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) + { return true; } @Override - public double getOfferedEnergy() { + public double getOfferedEnergy() + { return Math.min(energyStored, power); } @Override - public void drawEnergy(double amount) { + public void drawEnergy(double amount) + { energyStored -= amount; } @Override - public int getSourceTier() { + public int getSourceTier() + { return tier; } // << energy net interface + public final TileEntity parent; - public final TileEntity parent; - - protected double capacity; - protected int tier; - protected double power; - protected double energyStored; - protected boolean addedToEnet; + protected double capacity; + protected int tier; + protected double power; + protected double energyStored; + protected boolean addedToEnet; } diff --git a/src/api/java/ic2/api/energy/prefab/package-info.java b/src/api/java/ic2/api/energy/prefab/package-info.java index c38f7e0..a1ba4ee 100644 --- a/src/api/java/ic2/api/energy/prefab/package-info.java +++ b/src/api/java/ic2/api/energy/prefab/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.prefab; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java index 1735ff5..55f3e97 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java @@ -1,7 +1,6 @@ package ic2.api.energy.tile; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; /** @@ -12,7 +11,8 @@ import net.minecraftforge.common.util.ForgeDirection; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergyAcceptor extends IEnergyTile { +public interface IEnergyAcceptor extends IEnergyTile +{ /** * Determine if this acceptor can accept current from an adjacent emitter in a direction. * @@ -24,4 +24,3 @@ public interface IEnergyAcceptor extends IEnergyTile { */ boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction); } - diff --git a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java index 08dab88..e10430d 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java @@ -6,7 +6,8 @@ package ic2.api.energy.tile; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { +public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter +{ /** * Energy loss for the conductor in EU per block. * @@ -50,4 +51,3 @@ public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { */ void removeConductor(); } - diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java index 013865e..d09e849 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java @@ -1,7 +1,6 @@ package ic2.api.energy.tile; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; /** @@ -12,7 +11,8 @@ import net.minecraftforge.common.util.ForgeDirection; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergyEmitter extends IEnergyTile { +public interface IEnergyEmitter extends IEnergyTile +{ /** * Determine if this emitter can emit energy to an adjacent receiver. * @@ -25,4 +25,3 @@ public interface IEnergyEmitter extends IEnergyTile { */ boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction); } - diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.java b/src/api/java/ic2/api/energy/tile/IEnergySink.java index 4ae8e79..1c834b7 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergySink.java +++ b/src/api/java/ic2/api/energy/tile/IEnergySink.java @@ -7,7 +7,8 @@ import net.minecraftforge.common.util.ForgeDirection; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergySink extends IEnergyAcceptor { +public interface IEnergySink extends IEnergyAcceptor +{ /** * Determine how much energy the sink accepts. * @@ -42,4 +43,3 @@ public interface IEnergySink extends IEnergyAcceptor { */ double injectEnergy(ForgeDirection directionFrom, double amount, double voltage); } - diff --git a/src/api/java/ic2/api/energy/tile/IEnergySource.java b/src/api/java/ic2/api/energy/tile/IEnergySource.java index 44b952a..1d70eaa 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergySource.java +++ b/src/api/java/ic2/api/energy/tile/IEnergySource.java @@ -5,7 +5,8 @@ package ic2.api.energy.tile; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergySource extends IEnergyEmitter { +public interface IEnergySource extends IEnergyEmitter +{ /** * Energy output provided by the source this tick. * This is typically Math.min(stored energy, max output/tick). @@ -35,4 +36,3 @@ public interface IEnergySource extends IEnergyEmitter { */ int getSourceTier(); } - diff --git a/src/api/java/ic2/api/energy/tile/IEnergyTile.java b/src/api/java/ic2/api/energy/tile/IEnergyTile.java index 3938190..e619e29 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyTile.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyTile.java @@ -9,7 +9,7 @@ package ic2.api.energy.tile; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IEnergyTile { +public interface IEnergyTile +{ // } - diff --git a/src/api/java/ic2/api/energy/tile/IHeatSource.java b/src/api/java/ic2/api/energy/tile/IHeatSource.java index 2e5db41..ceebc41 100644 --- a/src/api/java/ic2/api/energy/tile/IHeatSource.java +++ b/src/api/java/ic2/api/energy/tile/IHeatSource.java @@ -2,13 +2,14 @@ package ic2.api.energy.tile; import net.minecraftforge.common.util.ForgeDirection; -public interface IHeatSource { - +public interface IHeatSource +{ + /* * Return max heat transmission peer Tick (only theoretical bandwidth not available amount) */ - int maxrequestHeatTick(ForgeDirection directionFrom); - + int maxrequestHeatTick(ForgeDirection directionFrom); + /* * @param requested amount of heat to transfer * @@ -18,6 +19,6 @@ public interface IHeatSource { * * requestHeat(100) : return 50 : so 50 units of heat remove from HeatSource */ - + int requestHeat(ForgeDirection directionFrom, int requestheat); } diff --git a/src/api/java/ic2/api/energy/tile/IKineticSource.java b/src/api/java/ic2/api/energy/tile/IKineticSource.java index a651408..4271a67 100644 --- a/src/api/java/ic2/api/energy/tile/IKineticSource.java +++ b/src/api/java/ic2/api/energy/tile/IKineticSource.java @@ -2,11 +2,12 @@ package ic2.api.energy.tile; import net.minecraftforge.common.util.ForgeDirection; -public interface IKineticSource { +public interface IKineticSource +{ /* * Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount) */ - int maxrequestkineticenergyTick(ForgeDirection directionFrom); + int maxrequestkineticenergyTick(ForgeDirection directionFrom); /* * @param requested amount of kinetic energy to transfer diff --git a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java index f7319d0..c8ecc4c 100644 --- a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java +++ b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java @@ -22,7 +22,8 @@ import net.minecraft.tileentity.TileEntity; * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ -public interface IMetaDelegate extends IEnergyTile { +public interface IMetaDelegate extends IEnergyTile +{ /** * Get the sub-TileEntities belonging to this Meta TileEntity. * diff --git a/src/api/java/ic2/api/energy/tile/package-info.java b/src/api/java/ic2/api/energy/tile/package-info.java index 3c60323..944249a 100644 --- a/src/api/java/ic2/api/energy/tile/package-info.java +++ b/src/api/java/ic2/api/energy/tile/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.tile; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/event/ExplosionEvent.java b/src/api/java/ic2/api/event/ExplosionEvent.java index c2df419..f46cb71 100644 --- a/src/api/java/ic2/api/event/ExplosionEvent.java +++ b/src/api/java/ic2/api/event/ExplosionEvent.java @@ -3,18 +3,14 @@ package ic2.api.event; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - import net.minecraftforge.event.world.WorldEvent; +import cpw.mods.fml.common.eventhandler.Cancelable; @Cancelable -public class ExplosionEvent extends WorldEvent { - public ExplosionEvent(World world, Entity entity, - double x, double y, double z, - double power, - EntityLivingBase igniter, - int radiationRange, double rangeLimit) { +public class ExplosionEvent extends WorldEvent +{ + public ExplosionEvent(World world, Entity entity, double x, double y, double z, double power, EntityLivingBase igniter, int radiationRange, double rangeLimit) + { super(world); this.entity = entity; @@ -30,15 +26,15 @@ public class ExplosionEvent extends WorldEvent { /** * Entity representing the explosive, may be null. */ - public final Entity entity; - public double x; - public double y; - public double z; - public double power; + public final Entity entity; + public double x; + public double y; + public double z; + public double power; /** * Entity causing the explosion, may be null. */ - public final EntityLivingBase igniter; - public final int radiationRange; - public final double rangeLimit; + public final EntityLivingBase igniter; + public final int radiationRange; + public final double rangeLimit; } diff --git a/src/api/java/ic2/api/event/LaserEvent.java b/src/api/java/ic2/api/event/LaserEvent.java index 6d5ea28..226a818 100644 --- a/src/api/java/ic2/api/event/LaserEvent.java +++ b/src/api/java/ic2/api/event/LaserEvent.java @@ -4,38 +4,38 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - import net.minecraftforge.event.world.WorldEvent; +import cpw.mods.fml.common.eventhandler.Cancelable; /** * A bunch of Events to handle the power of the Mining Laser. */ @Cancelable -public class LaserEvent extends WorldEvent { +public class LaserEvent extends WorldEvent +{ // the Laser Entity - public final Entity lasershot; + public final Entity lasershot; // the following variables can be changed and the Laser will adjust to them // the Player firing the Laser. If the Laser gets "reflected" the Player could change. - public EntityLivingBase owner; + public EntityLivingBase owner; // Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range. - public float range, power; - public int blockBreaks; + public float range, power; + public int blockBreaks; // Determines whether the laser will explode upon hitting something - public boolean explosive, smelt; + public boolean explosive, smelt; - public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) { + public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) + { super(world1); - this.lasershot = lasershot1; - this.owner = owner1; - this.range = range1; - this.power = power1; - this.blockBreaks = blockBreaks1; - this.explosive = explosive1; - this.smelt = smelt1; + lasershot = lasershot1; + owner = owner1; + range = range1; + power = power1; + blockBreaks = blockBreaks1; + explosive = explosive1; + smelt = smelt1; } /** @@ -43,12 +43,14 @@ public class LaserEvent extends WorldEvent { * * The Item is the Laser Gun which the "Player" has shot */ - public static class LaserShootEvent extends LaserEvent { - ItemStack laseritem; + public static class LaserShootEvent extends LaserEvent + { + ItemStack laseritem; - public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) { + public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) + { super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.laseritem = laseritem1; + laseritem = laseritem1; } } @@ -57,15 +59,18 @@ public class LaserEvent extends WorldEvent { * * The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired. */ - public static class LaserExplodesEvent extends LaserEvent { + public static class LaserExplodesEvent extends LaserEvent + { // explosion strength, even that can be changed! - public float explosionpower, explosiondroprate, explosionentitydamage; + public float explosionpower, explosiondroprate, + explosionentitydamage; - public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { + public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) + { super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.explosionpower = explosionpower1; - this.explosiondroprate = explosiondroprate1; - this.explosionentitydamage = explosionentitydamage1; + explosionpower = explosionpower1; + explosiondroprate = explosiondroprate1; + explosionentitydamage = explosionentitydamage1; } } @@ -76,23 +81,25 @@ public class LaserEvent extends WorldEvent { * Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass. * Use lasershot.setDead() to remove the Shot entirely. */ - public static class LaserHitsBlockEvent extends LaserEvent { + public static class LaserHitsBlockEvent extends LaserEvent + { // targeted block, even that can be changed! - public int x, y, z; - public int side; + public int x, y, z; + public int side; // removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something. - public boolean removeBlock, dropBlock; - public float dropChance; + public boolean removeBlock, dropBlock; + public float dropChance; - public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { + public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) + { super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.removeBlock = removeBlock1; - this.dropBlock = dropBlock1; - this.dropChance = dropChance1; + x = x1; + y = y1; + z = z1; + side = side1; + removeBlock = removeBlock1; + dropBlock = dropBlock1; + dropChance = dropChance1; } } @@ -102,13 +109,15 @@ public class LaserEvent extends WorldEvent { * Canceling this Event ignores the Entity * Use lasershot.setDead() to remove the Shot entirely. */ - public static class LaserHitsEntityEvent extends LaserEvent { + public static class LaserHitsEntityEvent extends LaserEvent + { // the Entity which the Laser has shot at, even the target can be changed! - public Entity hitentity; + public Entity hitentity; - public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) { + public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) + { super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.hitentity = hitentity1; + hitentity = hitentity1; } } } diff --git a/src/api/java/ic2/api/event/PaintEvent.java b/src/api/java/ic2/api/event/PaintEvent.java index c6565c2..4f7e743 100644 --- a/src/api/java/ic2/api/event/PaintEvent.java +++ b/src/api/java/ic2/api/event/PaintEvent.java @@ -1,32 +1,32 @@ package ic2.api.event; import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - import net.minecraftforge.event.world.WorldEvent; +import cpw.mods.fml.common.eventhandler.Cancelable; @Cancelable -public class PaintEvent extends WorldEvent { +public class PaintEvent extends WorldEvent +{ // target block - public final int x; - public final int y; - public final int z; - public final int side; + public final int x; + public final int y; + public final int z; + public final int side; // color to paint the block - public final int color; + public final int color; // set to true to confirm the operation - public boolean painted = false; + public boolean painted = false; - public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) { + public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) + { super(world1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.color = color1; + x = x1; + y = y1; + z = z1; + side = side1; + color = color1; } } diff --git a/src/api/java/ic2/api/event/RetextureEvent.java b/src/api/java/ic2/api/event/RetextureEvent.java index d530578..0dda540 100644 --- a/src/api/java/ic2/api/event/RetextureEvent.java +++ b/src/api/java/ic2/api/event/RetextureEvent.java @@ -2,36 +2,36 @@ package ic2.api.event; import net.minecraft.block.Block; import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - import net.minecraftforge.event.world.WorldEvent; +import cpw.mods.fml.common.eventhandler.Cancelable; @Cancelable -public class RetextureEvent extends WorldEvent { +public class RetextureEvent extends WorldEvent +{ // target block - public final int x; - public final int y; - public final int z; - public final int side; + public final int x; + public final int y; + public final int z; + public final int side; // referenced block (to grab the texture from) - public final Block referencedBlock; - public final int referencedMeta; - public final int referencedSide; + public final Block referencedBlock; + public final int referencedMeta; + public final int referencedSide; // set to true to confirm the operation - public boolean applied = false; + public boolean applied = false; - public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) { + public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) + { super(world1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; + x = x1; + y = y1; + z = z1; + side = side1; this.referencedBlock = referencedBlock; - this.referencedMeta = referencedMeta1; - this.referencedSide = referencedSide1; + referencedMeta = referencedMeta1; + referencedSide = referencedSide1; } } diff --git a/src/api/java/ic2/api/event/package-info.java b/src/api/java/ic2/api/event/package-info.java index d331b92..45c1338 100644 --- a/src/api/java/ic2/api/event/package-info.java +++ b/src/api/java/ic2/api/event/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.event; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java index 1e7b2cc..a66b35c 100644 --- a/src/api/java/ic2/api/info/IEnergyValueProvider.java +++ b/src/api/java/ic2/api/info/IEnergyValueProvider.java @@ -2,7 +2,8 @@ package ic2.api.info; import net.minecraft.item.ItemStack; -public interface IEnergyValueProvider { +public interface IEnergyValueProvider +{ /** * Determine the energy value for a single item in the supplied stack. * The value is used by most machines in the discharge slot. diff --git a/src/api/java/ic2/api/info/IFuelValueProvider.java b/src/api/java/ic2/api/info/IFuelValueProvider.java index 7c7fe0f..690a477 100644 --- a/src/api/java/ic2/api/info/IFuelValueProvider.java +++ b/src/api/java/ic2/api/info/IFuelValueProvider.java @@ -2,7 +2,8 @@ package ic2.api.info; import net.minecraft.item.ItemStack; -public interface IFuelValueProvider { +public interface IFuelValueProvider +{ /** * Determine the fuel value for a single item in the supplied stack. * The information currently applies to Generators and the Iron Furnace. diff --git a/src/api/java/ic2/api/info/Info.java b/src/api/java/ic2/api/info/Info.java index f8e30ad..42f8235 100644 --- a/src/api/java/ic2/api/info/Info.java +++ b/src/api/java/ic2/api/info/Info.java @@ -2,38 +2,44 @@ package ic2.api.info; import net.minecraft.potion.Potion; import net.minecraft.util.DamageSource; - import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.LoaderState; -public class Info { - public static IEnergyValueProvider itemEnergy; - public static IFuelValueProvider itemFuel; - public static Object ic2ModInstance; +public class Info +{ + public static IEnergyValueProvider itemEnergy; + public static IFuelValueProvider itemFuel; + public static Object ic2ModInstance; /** * Damage Sources used by IC2. * Getting assigned in preload. */ - public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; + public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, + DMG_RADIATION; /** * Potions used by IC2. * Getting assigned in preload. */ - public static Potion POTION_RADIATION; + public static Potion POTION_RADIATION; - public static boolean isIc2Available() { - if (ic2Available != null) return ic2Available; + public static boolean isIc2Available() + { + if(ic2Available != null) + { + return ic2Available; + } - boolean loaded = Loader.isModLoaded("IC2"); + final boolean loaded = Loader.isModLoaded("IC2"); - if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { + if(Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) + { ic2Available = loaded; } return loaded; } - private static Boolean ic2Available = null; -}
\ No newline at end of file + private static Boolean ic2Available = null; +} diff --git a/src/api/java/ic2/api/info/package-info.java b/src/api/java/ic2/api/info/package-info.java index 59936e5..126f59e 100644 --- a/src/api/java/ic2/api/info/package-info.java +++ b/src/api/java/ic2/api/info/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.info; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/item/ElectricItem.java b/src/api/java/ic2/api/item/ElectricItem.java index 19e5fc1..f4037a9 100644 --- a/src/api/java/ic2/api/item/ElectricItem.java +++ b/src/api/java/ic2/api/item/ElectricItem.java @@ -8,20 +8,21 @@ import net.minecraft.item.ItemStack; /** * Allows for charging, discharging and using electric items (IElectricItem). */ -public final class ElectricItem { +public final class ElectricItem +{ /** * IElectricItemManager to use for interacting with IElectricItem ItemStacks. * * This manager will act as a gateway and delegate the tasks to the final implementation * (rawManager or a custom one) as necessary. */ - public static IElectricItemManager manager; + public static IElectricItemManager manager; /** * Standard IElectricItemManager implementation, only call it directly from another * IElectricItemManager. Use manager instead. */ - public static IElectricItemManager rawManager; + public static IElectricItemManager rawManager; /** * Register an electric item manager for items not implementing IElectricItem. @@ -33,7 +34,8 @@ public final class ElectricItem { * * @param manager Manager to register. */ - public static void registerBackupManager(IBackupElectricItemManager manager) { + public static void registerBackupManager(IBackupElectricItemManager manager) + { backupManagers.add(manager); } @@ -45,15 +47,18 @@ public final class ElectricItem { * @param stack ItemStack to be handled. * @return First suitable electric item manager. */ - public static IBackupElectricItemManager getBackupManager(ItemStack stack) { - for (IBackupElectricItemManager manager : backupManagers) { - if (manager.handles(stack)) return manager; + public static IBackupElectricItemManager getBackupManager(ItemStack stack) + { + for(final IBackupElectricItemManager manager : backupManagers) + { + if(manager.handles(stack)) + { + return manager; + } } return null; } - - private static final List<IBackupElectricItemManager> backupManagers = new ArrayList<IBackupElectricItemManager>(); + private static final List<IBackupElectricItemManager> backupManagers = new ArrayList<IBackupElectricItemManager>(); } - diff --git a/src/api/java/ic2/api/item/IBackupElectricItemManager.java b/src/api/java/ic2/api/item/IBackupElectricItemManager.java index 2ae254a..d53b885 100644 --- a/src/api/java/ic2/api/item/IBackupElectricItemManager.java +++ b/src/api/java/ic2/api/item/IBackupElectricItemManager.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; * * The manager implementing this has to be registered with ElectricItem.registerBackupManager(). */ -public interface IBackupElectricItemManager extends IElectricItemManager { +public interface IBackupElectricItemManager extends IElectricItemManager +{ boolean handles(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IBlockCuttingBlade.java b/src/api/java/ic2/api/item/IBlockCuttingBlade.java index 24a8f00..e153117 100644 --- a/src/api/java/ic2/api/item/IBlockCuttingBlade.java +++ b/src/api/java/ic2/api/item/IBlockCuttingBlade.java @@ -1,6 +1,6 @@ package ic2.api.item; - -public interface IBlockCuttingBlade { +public interface IBlockCuttingBlade +{ int gethardness(); } diff --git a/src/api/java/ic2/api/item/IBoxable.java b/src/api/java/ic2/api/item/IBoxable.java index bca2cc0..1d86e2c 100644 --- a/src/api/java/ic2/api/item/IBoxable.java +++ b/src/api/java/ic2/api/item/IBoxable.java @@ -2,8 +2,8 @@ package ic2.api.item; import net.minecraft.item.ItemStack; - -public interface IBoxable { +public interface IBoxable +{ /** * Determine whether an item can be stored in a toolbox or not. * diff --git a/src/api/java/ic2/api/item/IC2Items.java b/src/api/java/ic2/api/item/IC2Items.java index 9b8c7df..78c680d 100644 --- a/src/api/java/ic2/api/item/IC2Items.java +++ b/src/api/java/ic2/api/item/IC2Items.java @@ -13,7 +13,8 @@ import net.minecraft.item.ItemStack; * Blocks: Block.blocksList[x.itemID] * Items: x.getItem() */ -public final class IC2Items { +public final class IC2Items +{ /** * Get an ItemStack for a specific item name, example: Items.getItem("resin") * See the list below for item names. @@ -22,18 +23,26 @@ public final class IC2Items { * @param name item name * @return The item or null if the item does not exist or an error occurred */ - public static ItemStack getItem(String name) { - try { - if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); + public static ItemStack getItem(String name) + { + try + { + if(Ic2Items == null) + { + Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); + } - Object ret = Ic2Items.getField(name).get(null); + final Object ret = Ic2Items.getField(name).get(null); - if (ret instanceof ItemStack) { + if(ret instanceof ItemStack) + { return (ItemStack) ret; } return null; - } catch (Exception e) { - System.out.println("IC2 API: Call getItem failed for "+name); + } + catch(final Exception e) + { + System.out.println("IC2 API: Call getItem failed for " + name); return null; } @@ -581,11 +590,13 @@ public final class IC2Items { * * @return IC2 package name, if unable to be determined defaults to ic2 */ - private static String getPackage() { - Package pkg = IC2Items.class.getPackage(); + private static String getPackage() + { + final Package pkg = IC2Items.class.getPackage(); - if (pkg != null) { - String packageName = pkg.getName(); + if(pkg != null) + { + final String packageName = pkg.getName(); return packageName.substring(0, packageName.length() - ".api.item".length()); } @@ -593,6 +604,5 @@ public final class IC2Items { return "ic2"; } - private static Class<?> Ic2Items; + private static Class<?> Ic2Items; } - diff --git a/src/api/java/ic2/api/item/ICustomDamageItem.java b/src/api/java/ic2/api/item/ICustomDamageItem.java index 4470fa0..56590d1 100644 --- a/src/api/java/ic2/api/item/ICustomDamageItem.java +++ b/src/api/java/ic2/api/item/ICustomDamageItem.java @@ -17,7 +17,8 @@ import net.minecraft.item.ItemStack; * * @author Player */ -public interface ICustomDamageItem { +public interface ICustomDamageItem +{ /** * Retrieve the custom damage value for the supplied item stack. * diff --git a/src/api/java/ic2/api/item/IDebuggable.java b/src/api/java/ic2/api/item/IDebuggable.java index 404c7eb..cd5159e 100644 --- a/src/api/java/ic2/api/item/IDebuggable.java +++ b/src/api/java/ic2/api/item/IDebuggable.java @@ -1,22 +1,22 @@ package ic2.api.item; - /** * Allows a tile entity to output a debug message when the debugItem is used on it. * Suggestions by Myrathi */ -public abstract interface IDebuggable { - /** - * Checks if the tile entity is in a state that can be debugged. - * - * @return True if the tile entity can be debugged - */ - public abstract boolean isDebuggable(); +public abstract interface IDebuggable +{ + /** + * Checks if the tile entity is in a state that can be debugged. + * + * @return True if the tile entity can be debugged + */ + public abstract boolean isDebuggable(); - /** - * Gets the debug text for the tile entity. - * - * @return The text that the debugItem should show - */ - public abstract String getDebugText(); + /** + * Gets the debug text for the tile entity. + * + * @return The text that the debugItem should show + */ + public abstract String getDebugText(); } diff --git a/src/api/java/ic2/api/item/IElectricItem.java b/src/api/java/ic2/api/item/IElectricItem.java index 4f546d5..14935a5 100644 --- a/src/api/java/ic2/api/item/IElectricItem.java +++ b/src/api/java/ic2/api/item/IElectricItem.java @@ -8,7 +8,8 @@ import net.minecraft.item.ItemStack; * * The item should have a maximum damage of 13. */ -public interface IElectricItem { +public interface IElectricItem +{ /** * Determine if the item can be used in a machine or as an armor part to supply energy. * @@ -54,4 +55,3 @@ public interface IElectricItem { */ double getTransferLimit(ItemStack itemStack); } - diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java index 5de43d7..315ce90 100644 --- a/src/api/java/ic2/api/item/IElectricItemManager.java +++ b/src/api/java/ic2/api/item/IElectricItemManager.java @@ -17,7 +17,8 @@ import net.minecraft.item.ItemStack; * to minimize its dependency on its own constraints/structure and delegates most work back to the * more atomic features in the gateway manager. */ -public interface IElectricItemManager { +public interface IElectricItemManager +{ /** * Charge an item with a specified amount of energy. * diff --git a/src/api/java/ic2/api/item/IItemHudInfo.java b/src/api/java/ic2/api/item/IItemHudInfo.java index da97318..77f0454 100644 --- a/src/api/java/ic2/api/item/IItemHudInfo.java +++ b/src/api/java/ic2/api/item/IItemHudInfo.java @@ -4,18 +4,19 @@ import java.util.List; import net.minecraft.item.ItemStack; -public interface IItemHudInfo { +public interface IItemHudInfo +{ /* - Add Info to Nano- and Quantum-Suit Helm Hud - for itemStack + Add Info to Nano- and Quantum-Suit Helm Hud + for itemStack - @Override - public List<String> getHudInfo(ItemStack itemStack) { - List<String> info = new LinkedList<String>(); - info.add("i am a Cool Item"); - info.add("and have Cool info"); - return info; - } + @Override + public List<String> getHudInfo(ItemStack itemStack) { + List<String> info = new LinkedList<String>(); + info.add("i am a Cool Item"); + info.add("and have Cool info"); + return info; + } */ diff --git a/src/api/java/ic2/api/item/IKineticRotor.java b/src/api/java/ic2/api/item/IKineticRotor.java index a61d162..a2547bc 100644 --- a/src/api/java/ic2/api/item/IKineticRotor.java +++ b/src/api/java/ic2/api/item/IKineticRotor.java @@ -3,7 +3,8 @@ package ic2.api.item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public interface IKineticRotor { +public interface IKineticRotor +{ int getDiameter(ItemStack stack); ResourceLocation getRotorRenderTexture(ItemStack stack); @@ -16,8 +17,8 @@ public interface IKineticRotor { boolean isAcceptedType(ItemStack stack, GearboxType type); - public static enum GearboxType { - WATER, - WIND, + public static enum GearboxType + { + WATER, WIND, } } diff --git a/src/api/java/ic2/api/item/ILatheItem.java b/src/api/java/ic2/api/item/ILatheItem.java index 45988c4..b98760e 100644 --- a/src/api/java/ic2/api/item/ILatheItem.java +++ b/src/api/java/ic2/api/item/ILatheItem.java @@ -2,14 +2,14 @@ package ic2.api.item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * Interface used for Items that can be processed in the Turning Table */ -public interface ILatheItem { +public interface ILatheItem +{ /** * Returns the radius of this Lathe Item @@ -57,7 +57,8 @@ public interface ILatheItem { /** * Interface used for Tools that can be used to modify {@link ILatheItem} */ - public static interface ILatheTool extends ICustomDamageItem { + public static interface ILatheTool extends ICustomDamageItem + { /** * This is similar to the Tool HarvestLevel. Requires a different tool for a different hardness diff --git a/src/api/java/ic2/api/item/IMetalArmor.java b/src/api/java/ic2/api/item/IMetalArmor.java index 16ffd24..c067814 100644 --- a/src/api/java/ic2/api/item/IMetalArmor.java +++ b/src/api/java/ic2/api/item/IMetalArmor.java @@ -8,7 +8,8 @@ import net.minecraft.item.ItemStack; * * Currently used for determining which boots can be used to slide up a magnetic pole. */ -public interface IMetalArmor { +public interface IMetalArmor +{ /** * Determine if the given armor piece is metal armor. * diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.java b/src/api/java/ic2/api/item/ISpecialElectricItem.java index a7302f5..b73cf1d 100644 --- a/src/api/java/ic2/api/item/ISpecialElectricItem.java +++ b/src/api/java/ic2/api/item/ISpecialElectricItem.java @@ -2,7 +2,8 @@ package ic2.api.item; import net.minecraft.item.ItemStack; -public interface ISpecialElectricItem extends IElectricItem { +public interface ISpecialElectricItem extends IElectricItem +{ /** * Supply a custom IElectricItemManager. * diff --git a/src/api/java/ic2/api/item/ITerraformingBP.java b/src/api/java/ic2/api/item/ITerraformingBP.java index 59b46ba..cbb1eba 100644 --- a/src/api/java/ic2/api/item/ITerraformingBP.java +++ b/src/api/java/ic2/api/item/ITerraformingBP.java @@ -5,14 +5,15 @@ import net.minecraft.world.World; /** * Allows an item to act as a terraformer blueprint. */ -public interface ITerraformingBP { +public interface ITerraformingBP +{ /** * Get the energy consumption per operation of the blueprint. * * @return Energy consumption in EU */ public abstract int getConsume(); - + /** * Get the maximum range of the blueprint. * Should be a divisor of 5. @@ -20,7 +21,7 @@ public interface ITerraformingBP { * @return Maximum range in blocks */ public abstract int getRange(); - + /** * Perform the terraforming operation. * diff --git a/src/api/java/ic2/api/item/ItemWrapper.java b/src/api/java/ic2/api/item/ItemWrapper.java index 58f8073..9a4e4d8 100644 --- a/src/api/java/ic2/api/item/ItemWrapper.java +++ b/src/api/java/ic2/api/item/ItemWrapper.java @@ -12,39 +12,58 @@ import com.google.common.collect.Multimap; * * @author Richard */ -public class ItemWrapper { - private static final Multimap<Item, IBoxable> boxableItems = ArrayListMultimap.create(); - private static final Multimap<Item, IMetalArmor> metalArmorItems = ArrayListMultimap.create(); - - public static void registerBoxable(Item item, IBoxable boxable) { +public class ItemWrapper +{ + private static final Multimap<Item, IBoxable> boxableItems = ArrayListMultimap.create(); + private static final Multimap<Item, IMetalArmor> metalArmorItems = ArrayListMultimap.create(); + + public static void registerBoxable(Item item, IBoxable boxable) + { boxableItems.put(item, boxable); } - - public static boolean canBeStoredInToolbox(ItemStack stack) { - Item item = stack.getItem(); + + public static boolean canBeStoredInToolbox(ItemStack stack) + { + final Item item = stack.getItem(); // use customs first to allow for overriding behavior - for (IBoxable boxable : boxableItems.get(item)) { - if (boxable.canBeStoredInToolbox(stack)) return true; + for(final IBoxable boxable : boxableItems.get(item)) + { + if(boxable.canBeStoredInToolbox(stack)) + { + return true; + } } - - if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; - + + if(item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) + { + return true; + } + return false; } - - public static void registerMetalArmor(Item item, IMetalArmor armor) { + + public static void registerMetalArmor(Item item, IMetalArmor armor) + { metalArmorItems.put(item, armor); } - - public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { - Item item = stack.getItem(); + + public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) + { + final Item item = stack.getItem(); // use customs first to allow for overriding behavior - for (IMetalArmor metalArmor : metalArmorItems.get(item)) { - if (metalArmor.isMetalArmor(stack, player)) return true; + for(final IMetalArmor metalArmor : metalArmorItems.get(item)) + { + if(metalArmor.isMetalArmor(stack, player)) + { + return true; + } } - - if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; - + + if(item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) + { + return true; + } + return false; } } diff --git a/src/api/java/ic2/api/item/package-info.java b/src/api/java/ic2/api/item/package-info.java index 44ecdce..f9d4d80 100644 --- a/src/api/java/ic2/api/item/package-info.java +++ b/src/api/java/ic2/api/item/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.item; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java index ed3ea38..000ce16 100644 --- a/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java @@ -5,7 +5,8 @@ import net.minecraft.entity.player.EntityPlayer; /** * Allows a tile entity to receive network events received from clients. */ -public interface INetworkClientTileEntityEventListener { +public interface INetworkClientTileEntityEventListener +{ /** * Called when a network event is received. * @@ -14,4 +15,3 @@ public interface INetworkClientTileEntityEventListener { */ void onNetworkEvent(EntityPlayer player, int event); } - diff --git a/src/api/java/ic2/api/network/INetworkDataProvider.java b/src/api/java/ic2/api/network/INetworkDataProvider.java index c3f283e..86e58c7 100644 --- a/src/api/java/ic2/api/network/INetworkDataProvider.java +++ b/src/api/java/ic2/api/network/INetworkDataProvider.java @@ -7,7 +7,8 @@ import java.util.List; * * The fields don't update themselves, a field update must be sent every time a synchronized field changes. */ -public interface INetworkDataProvider { +public interface INetworkDataProvider +{ /** * Get the list of synchronized fields. * @@ -15,4 +16,3 @@ public interface INetworkDataProvider { */ List<String> getNetworkedFields(); } - diff --git a/src/api/java/ic2/api/network/INetworkItemEventListener.java b/src/api/java/ic2/api/network/INetworkItemEventListener.java index 5f3228c..6ddbb4b 100644 --- a/src/api/java/ic2/api/network/INetworkItemEventListener.java +++ b/src/api/java/ic2/api/network/INetworkItemEventListener.java @@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack; /** * Allows an item to receive network events received from the server. */ -public interface INetworkItemEventListener { +public interface INetworkItemEventListener +{ /** * Called when a network event is received. * @@ -16,4 +17,3 @@ public interface INetworkItemEventListener { */ void onNetworkEvent(ItemStack stack, EntityPlayer player, int event); } - diff --git a/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java index fbb4753..e3cd5c3 100644 --- a/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java @@ -3,7 +3,8 @@ package ic2.api.network; /** * Allows a tile entity to receive network events received from the server. */ -public interface INetworkTileEntityEventListener { +public interface INetworkTileEntityEventListener +{ /** * Called when a network event is received. * @@ -11,4 +12,3 @@ public interface INetworkTileEntityEventListener { */ void onNetworkEvent(int event); } - diff --git a/src/api/java/ic2/api/network/INetworkUpdateListener.java b/src/api/java/ic2/api/network/INetworkUpdateListener.java index 09414ae..a37fcaa 100644 --- a/src/api/java/ic2/api/network/INetworkUpdateListener.java +++ b/src/api/java/ic2/api/network/INetworkUpdateListener.java @@ -3,7 +3,8 @@ package ic2.api.network; /** * Allows a tile entity to receive field sync updates received from the server. */ -public interface INetworkUpdateListener { +public interface INetworkUpdateListener +{ /** * Called when a field is synchronized. * @@ -11,4 +12,3 @@ public interface INetworkUpdateListener { */ void onNetworkUpdate(String field); } - diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/api/java/ic2/api/network/NetworkHelper.java index a91d03a..0615e35 100644 --- a/src/api/java/ic2/api/network/NetworkHelper.java +++ b/src/api/java/ic2/api/network/NetworkHelper.java @@ -18,10 +18,10 @@ import net.minecraft.tileentity.TileEntity; * producing effects. Anything which is only visible inside the GUI should be synchronized through * the Container class associated to the GUI in Container.updateProgressBar(). */ -public final class NetworkHelper { +public final class NetworkHelper +{ // server -> client - /** * Schedule a TileEntity's field to be updated to the clients in range. * @@ -53,13 +53,23 @@ public final class NetworkHelper { * @param te TileEntity to update * @param field Name of the field to update */ - public static void updateTileEntityField(TileEntity te, String field) { - try { - if (NetworkManager_updateTileEntityField == null) NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); - if (instance == null) instance = getInstance(); + public static void updateTileEntityField(TileEntity te, String field) + { + try + { + if(NetworkManager_updateTileEntityField == null) + { + NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); + } + if(instance == null) + { + instance = getInstance(); + } NetworkManager_updateTileEntityField.invoke(instance, te, field); - } catch (Exception e) { + } + catch(final Exception e) + { throw new RuntimeException(e); } } @@ -75,13 +85,23 @@ public final class NetworkHelper { * @param limitRange Limit the notification range to (currently) 20 blocks instead of the * tracking distance if true */ - public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { - try { - if (NetworkManager_initiateTileEntityEvent == null) NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); + public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) + { + try + { + if(NetworkManager_initiateTileEntityEvent == null) + { + NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); + } + if(instance == null) + { + instance = getInstance(); + } NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); - } catch (Exception e) { + } + catch(final Exception e) + { throw new RuntimeException(e); } } @@ -100,18 +120,27 @@ public final class NetworkHelper { * @param limitRange Limit the notification range to (currently) 20 blocks instead of the * tracking distance if true */ - public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { - try { - if (NetworkManager_initiateItemEvent == null) NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); + public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) + { + try + { + if(NetworkManager_initiateItemEvent == null) + { + NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); + } + if(instance == null) + { + instance = getInstance(); + } NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); - } catch (Exception e) { + } + catch(final Exception e) + { throw new RuntimeException(e); } } - // client -> server /** @@ -122,13 +151,23 @@ public final class NetworkHelper { * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener * @param event Arbitrary integer to represent the event, choosing the values is up to you */ - public static void initiateClientTileEntityEvent(TileEntity te, int event) { - try { - if (NetworkManager_initiateClientTileEntityEvent == null) NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); - if (instance == null) instance = getInstance(); + public static void initiateClientTileEntityEvent(TileEntity te, int event) + { + try + { + if(NetworkManager_initiateClientTileEntityEvent == null) + { + NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); + } + if(instance == null) + { + instance = getInstance(); + } NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); - } catch (Exception e) { + } + catch(final Exception e) + { throw new RuntimeException(e); } } @@ -143,13 +182,23 @@ public final class NetworkHelper { * @param itemStack ItemStack containing the item * @param event Arbitrary integer to represent the event, choosing the values is up to you */ - public static void initiateClientItemEvent(ItemStack itemStack, int event) { - try { - if (NetworkManager_initiateClientItemEvent == null) NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); - if (instance == null) instance = getInstance(); + public static void initiateClientItemEvent(ItemStack itemStack, int event) + { + try + { + if(NetworkManager_initiateClientItemEvent == null) + { + NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); + } + if(instance == null) + { + instance = getInstance(); + } NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); - } catch (Exception e) { + } + catch(final Exception e) + { throw new RuntimeException(e); } } @@ -159,11 +208,13 @@ public final class NetworkHelper { * * @return IC2 package name, if unable to be determined defaults to ic2 */ - private static String getPackage() { - Package pkg = NetworkHelper.class.getPackage(); + private static String getPackage() + { + final Package pkg = NetworkHelper.class.getPackage(); - if (pkg != null) { - String packageName = pkg.getName(); + if(pkg != null) + { + final String packageName = pkg.getName(); return packageName.substring(0, packageName.length() - ".api.network".length()); } @@ -176,19 +227,22 @@ public final class NetworkHelper { * * @return NetworkManager instance */ - private static Object getInstance() { - try { + private static Object getInstance() + { + try + { return Class.forName(getPackage() + ".core.util.SideGateway").getMethod("get").invoke(Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null)); - } catch (Throwable e) { + } + catch(final Throwable e) + { throw new RuntimeException(e); } } - private static Object instance; - private static Method NetworkManager_updateTileEntityField; - private static Method NetworkManager_initiateTileEntityEvent; - private static Method NetworkManager_initiateItemEvent; - private static Method NetworkManager_initiateClientTileEntityEvent; - private static Method NetworkManager_initiateClientItemEvent; + private static Object instance; + private static Method NetworkManager_updateTileEntityField; + private static Method NetworkManager_initiateTileEntityEvent; + private static Method NetworkManager_initiateItemEvent; + private static Method NetworkManager_initiateClientTileEntityEvent; + private static Method NetworkManager_initiateClientItemEvent; } - diff --git a/src/api/java/ic2/api/network/package-info.java b/src/api/java/ic2/api/network/package-info.java index 25ea29e..1b69df8 100644 --- a/src/api/java/ic2/api/network/package-info.java +++ b/src/api/java/ic2/api/network/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.network; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/package-info.java b/src/api/java/ic2/api/package-info.java index e6f1522..00ff182 100644 --- a/src/api/java/ic2/api/package-info.java +++ b/src/api/java/ic2/api/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/reactor/IReactor.java b/src/api/java/ic2/api/reactor/IReactor.java index 55191cc..5009b32 100644 --- a/src/api/java/ic2/api/reactor/IReactor.java +++ b/src/api/java/ic2/api/reactor/IReactor.java @@ -7,7 +7,8 @@ import net.minecraft.world.World; /** * Interface implemented by the tile entity of nuclear reactors. */ -public interface IReactor { +public interface IReactor +{ /** * Get the reactor's position in the world. * @@ -67,7 +68,6 @@ public interface IReactor { * no more magic heat disappear */ - public void addEmitHeat(int heat); /** diff --git a/src/api/java/ic2/api/reactor/IReactorChamber.java b/src/api/java/ic2/api/reactor/IReactorChamber.java index 4611a6a..66463b3 100644 --- a/src/api/java/ic2/api/reactor/IReactorChamber.java +++ b/src/api/java/ic2/api/reactor/IReactorChamber.java @@ -3,7 +3,8 @@ package ic2.api.reactor; /** * Interface implemented by the reactor chamber tile entity. */ -public interface IReactorChamber { +public interface IReactorChamber +{ /** * Get the chamber's reactor. * @@ -15,6 +16,6 @@ public interface IReactorChamber { * Set Redstone Signal without direct contact * */ - + public void setRedstoneSignal(boolean redstone); } diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.java b/src/api/java/ic2/api/reactor/IReactorComponent.java index 84e011c..4b4d8ad 100644 --- a/src/api/java/ic2/api/reactor/IReactorComponent.java +++ b/src/api/java/ic2/api/reactor/IReactorComponent.java @@ -10,7 +10,8 @@ import net.minecraft.item.ItemStack; * All IC2 ReactorComponents implement and use this Interface * */ -public interface IReactorComponent { +public interface IReactorComponent +{ /** * Called by reactor upon iterating through it's inventory (every cycle). * Perform all necessary calculation/interaction here diff --git a/src/api/java/ic2/api/reactor/package-info.java b/src/api/java/ic2/api/reactor/package-info.java index 5194aee..7b70911 100644 --- a/src/api/java/ic2/api/reactor/package-info.java +++ b/src/api/java/ic2/api/reactor/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.reactor; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java index 415b3c3..6f64585 100644 --- a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java @@ -4,7 +4,8 @@ import java.util.Map; import net.minecraft.item.ItemStack; -public interface ICannerBottleRecipeManager { +public interface ICannerBottleRecipeManager +{ /** * Adds a recipe to the machine. * @@ -34,18 +35,20 @@ public interface ICannerBottleRecipeManager { */ public Map<Input, RecipeOutput> getRecipes(); - - public static class Input { - public Input(IRecipeInput container1, IRecipeInput fill1) { - this.container = container1; - this.fill = fill1; + public static class Input + { + public Input(IRecipeInput container1, IRecipeInput fill1) + { + container = container1; + fill = fill1; } - public boolean matches(ItemStack container1, ItemStack fill1) { - return this.container.matches(container1) && this.fill.matches(fill1); + public boolean matches(ItemStack container1, ItemStack fill1) + { + return container.matches(container1) && fill.matches(fill1); } - public final IRecipeInput container; - public final IRecipeInput fill; + public final IRecipeInput container; + public final IRecipeInput fill; } } diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java index 5eba1b6..c4141ab 100644 --- a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java @@ -3,10 +3,10 @@ package ic2.api.recipe; import java.util.Map; import net.minecraft.item.ItemStack; - import net.minecraftforge.fluids.FluidStack; -public interface ICannerEnrichRecipeManager { +public interface ICannerEnrichRecipeManager +{ /** * Adds a recipe to the machine. * @@ -36,19 +36,20 @@ public interface ICannerEnrichRecipeManager { */ public Map<Input, FluidStack> getRecipes(); - - public static class Input { - public Input(FluidStack fluid1, IRecipeInput additive1) { - this.fluid = fluid1; - this.additive = additive1; + public static class Input + { + public Input(FluidStack fluid1, IRecipeInput additive1) + { + fluid = fluid1; + additive = additive1; } - public boolean matches(FluidStack fluid1, ItemStack additive1) { - return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) && - this.additive.matches(additive1); + public boolean matches(FluidStack fluid1, ItemStack additive1) + { + return (fluid == null || fluid.isFluidEqual(fluid1)) && additive.matches(additive1); } - public final FluidStack fluid; - public final IRecipeInput additive; + public final FluidStack fluid; + public final IRecipeInput additive; } } diff --git a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java index 756eaf6..12583a9 100644 --- a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java @@ -7,7 +7,8 @@ import net.minecraft.item.ItemStack; * * @author Richard */ -public interface ICraftingRecipeManager { +public interface ICraftingRecipeManager +{ /** * Adds a shaped crafting recipe. * @@ -15,7 +16,7 @@ public interface ICraftingRecipeManager { * @param input Recipe input format */ public void addRecipe(ItemStack output, Object... input); - + /** * Adds a shapeless crafting recipe. * diff --git a/src/api/java/ic2/api/recipe/IFluidHeatManager.java b/src/api/java/ic2/api/recipe/IFluidHeatManager.java index 7ddecdc..ee8be18 100644 --- a/src/api/java/ic2/api/recipe/IFluidHeatManager.java +++ b/src/api/java/ic2/api/recipe/IFluidHeatManager.java @@ -4,8 +4,8 @@ import java.util.Map; import net.minecraftforge.fluids.Fluid; - -public interface IFluidHeatManager extends ILiquidAcceptManager { +public interface IFluidHeatManager extends ILiquidAcceptManager +{ /** * Add a new fluid to the Fluid Heat Generator. * @@ -19,14 +19,15 @@ public interface IFluidHeatManager extends ILiquidAcceptManager { Map<String, BurnProperty> getBurnProperties(); - - public static class BurnProperty { - public BurnProperty(int amount1, int heat1) { - this.amount = amount1; - this.heat = heat1; + public static class BurnProperty + { + public BurnProperty(int amount1, int heat1) + { + amount = amount1; + heat = heat1; } - public final int amount; - public final int heat; + public final int amount; + public final int heat; } } diff --git a/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java index 4f377b9..6483c34 100644 --- a/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java +++ b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java @@ -4,7 +4,9 @@ import java.util.Set; import net.minecraftforge.fluids.Fluid; -public interface ILiquidAcceptManager { +public interface ILiquidAcceptManager +{ boolean acceptsFluid(Fluid fluid); + Set<Fluid> getAcceptedFluids(); } diff --git a/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java index 68decbb..1fc079c 100644 --- a/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java +++ b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java @@ -4,7 +4,8 @@ import java.util.Map; import net.minecraftforge.fluids.Fluid; -public interface ILiquidHeatExchangerManager extends ILiquidAcceptManager { +public interface ILiquidHeatExchangerManager extends ILiquidAcceptManager +{ /** * Add a new fluid heatup/cooldown recipe. @@ -26,14 +27,16 @@ public interface ILiquidHeatExchangerManager extends ILiquidAcceptManager { */ ILiquidAcceptManager getSingleDirectionLiquidManager(); - public static class HeatExchangeProperty { - public HeatExchangeProperty(Fluid outputFluid, int huPerMB) { + public static class HeatExchangeProperty + { + public HeatExchangeProperty(Fluid outputFluid, int huPerMB) + { this.outputFluid = outputFluid; this.huPerMB = huPerMB; } - public final Fluid outputFluid; - public final int huPerMB; + public final Fluid outputFluid; + public final int huPerMB; } } diff --git a/src/api/java/ic2/api/recipe/IListRecipeManager.java b/src/api/java/ic2/api/recipe/IListRecipeManager.java index adc2291..d488335 100644 --- a/src/api/java/ic2/api/recipe/IListRecipeManager.java +++ b/src/api/java/ic2/api/recipe/IListRecipeManager.java @@ -9,7 +9,8 @@ import net.minecraft.item.ItemStack; * * @author Richard */ -public interface IListRecipeManager extends Iterable<IRecipeInput> { +public interface IListRecipeManager extends Iterable<IRecipeInput> +{ /** * Adds a stack to the list. * diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java index d2d4382..ff391f8 100644 --- a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java +++ b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java @@ -10,7 +10,8 @@ import net.minecraft.nbt.NBTTagCompound; * * @author RichardG, Player */ -public interface IMachineRecipeManager { // TODO: merge with IMachineRecipeManagerExt +public interface IMachineRecipeManager +{ // TODO: merge with IMachineRecipeManagerExt /** * Adds a recipe to the machine. * diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java b/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java index 9c68706..6dc4715 100644 --- a/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java +++ b/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java @@ -3,7 +3,8 @@ package ic2.api.recipe; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public interface IMachineRecipeManagerExt extends IMachineRecipeManager { +public interface IMachineRecipeManagerExt extends IMachineRecipeManager +{ /** * Adds a recipe to the machine. * diff --git a/src/api/java/ic2/api/recipe/IPatternStorage.java b/src/api/java/ic2/api/recipe/IPatternStorage.java index c9dbd8d..2b646f3 100644 --- a/src/api/java/ic2/api/recipe/IPatternStorage.java +++ b/src/api/java/ic2/api/recipe/IPatternStorage.java @@ -4,7 +4,8 @@ import java.util.List; import net.minecraft.item.ItemStack; -public interface IPatternStorage { +public interface IPatternStorage +{ boolean addPattern(ItemStack itemstack); List<ItemStack> getPatterns(); diff --git a/src/api/java/ic2/api/recipe/IRecipeInput.java b/src/api/java/ic2/api/recipe/IRecipeInput.java index 0c842d6..99249bb 100644 --- a/src/api/java/ic2/api/recipe/IRecipeInput.java +++ b/src/api/java/ic2/api/recipe/IRecipeInput.java @@ -4,7 +4,8 @@ import java.util.List; import net.minecraft.item.ItemStack; -public interface IRecipeInput { +public interface IRecipeInput +{ /** * Check if subject matches this recipe input, ignoring the amount. * diff --git a/src/api/java/ic2/api/recipe/IScrapboxManager.java b/src/api/java/ic2/api/recipe/IScrapboxManager.java index 41b694d..4828591 100644 --- a/src/api/java/ic2/api/recipe/IScrapboxManager.java +++ b/src/api/java/ic2/api/recipe/IScrapboxManager.java @@ -4,7 +4,8 @@ import java.util.Map; import net.minecraft.item.ItemStack; -public interface IScrapboxManager { +public interface IScrapboxManager +{ void addDrop(ItemStack drop, float rawChance); ItemStack getDrop(ItemStack input, boolean adjustInput); diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java index 87c3427..1503a18 100644 --- a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java +++ b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java @@ -4,8 +4,8 @@ import java.util.Map; import net.minecraftforge.fluids.Fluid; - -public interface ISemiFluidFuelManager extends ILiquidAcceptManager { +public interface ISemiFluidFuelManager extends ILiquidAcceptManager +{ /** * Add a new fluid to the semi fluid generator. * @@ -19,14 +19,15 @@ public interface ISemiFluidFuelManager extends ILiquidAcceptManager { Map<String, BurnProperty> getBurnProperties(); - - public static class BurnProperty { - public BurnProperty(int amount1, double power1) { - this.amount = amount1; - this.power = power1; + public static class BurnProperty + { + public BurnProperty(int amount1, double power1) + { + amount = amount1; + power = power1; } - public final int amount; - public final double power; + public final int amount; + public final double power; } } diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java index 103d293..7f9ba8c 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java +++ b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java @@ -4,51 +4,64 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.item.ItemStack; - import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidStack; -public class RecipeInputFluidContainer implements IRecipeInput { - public RecipeInputFluidContainer(Fluid fluid) { +public class RecipeInputFluidContainer implements IRecipeInput +{ + public RecipeInputFluidContainer(Fluid fluid) + { this(fluid, FluidContainerRegistry.BUCKET_VOLUME); } - public RecipeInputFluidContainer(Fluid fluid, int amount) { + public RecipeInputFluidContainer(Fluid fluid, int amount) + { this.fluid = fluid; this.amount = amount; } @Override - public boolean matches(ItemStack subject) { - FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); - if (fs == null) return false; + public boolean matches(ItemStack subject) + { + final FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); + if(fs == null) + { + return false; + } return fs.getFluid() == fluid; } @Override - public int getAmount() { + public int getAmount() + { return amount; } @Override - public List<ItemStack> getInputs() { - List<ItemStack> ret = new ArrayList<ItemStack>(); + public List<ItemStack> getInputs() + { + final List<ItemStack> ret = new ArrayList<ItemStack>(); - for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); + for(final FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) + { + if(data.fluid.getFluid() == fluid) + { + ret.add(data.filledContainer); + } } return ret; } @Override - public String toString() { - return "RInputFluidContainer<"+amount+"x"+fluid.getName()+">"; + public String toString() + { + return "RInputFluidContainer<" + amount + "x" + fluid.getName() + ">"; } - public final Fluid fluid; - public final int amount; + public final Fluid fluid; + public final int amount; } diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java index 84f86ea..41a6012 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java +++ b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java @@ -4,44 +4,52 @@ import java.util.Arrays; import java.util.List; import net.minecraft.item.ItemStack; - import net.minecraftforge.oredict.OreDictionary; -public class RecipeInputItemStack implements IRecipeInput { - public RecipeInputItemStack(ItemStack aInput) { +public class RecipeInputItemStack implements IRecipeInput +{ + public RecipeInputItemStack(ItemStack aInput) + { this(aInput, aInput.stackSize); } - public RecipeInputItemStack(ItemStack aInput, int aAmount) { - if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); + public RecipeInputItemStack(ItemStack aInput, int aAmount) + { + if(aInput.getItem() == null) + { + throw new IllegalArgumentException("Invalid item stack specfied"); + } input = aInput.copy(); // Never forget to copy. amount = aAmount; } @Override - public boolean matches(ItemStack subject) { - return subject.getItem() == input.getItem() && - (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); + public boolean matches(ItemStack subject) + { + return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); } @Override - public int getAmount() { + public int getAmount() + { return amount; } @Override - public List<ItemStack> getInputs() { + public List<ItemStack> getInputs() + { return Arrays.asList(input); } @Override - public String toString() { - ItemStack stack = input.copy(); + public String toString() + { + final ItemStack stack = input.copy(); input.stackSize = amount; - return "RInputItemStack<"+stack+">"; + return "RInputItemStack<" + stack + ">"; } - public final ItemStack input; - public final int amount; + public final ItemStack input; + public final int amount; } diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java index e6e4695..173e6b3 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java +++ b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java @@ -6,39 +6,47 @@ import java.util.List; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; - import net.minecraftforge.oredict.OreDictionary; -public class RecipeInputOreDict implements IRecipeInput { - public RecipeInputOreDict(String input1) { +public class RecipeInputOreDict implements IRecipeInput +{ + public RecipeInputOreDict(String input1) + { this(input1, 1); } - public RecipeInputOreDict(String input1, int amount1) { + public RecipeInputOreDict(String input1, int amount1) + { this(input1, amount1, null); } - public RecipeInputOreDict(String input1, int amount1, Integer meta) { - this.input = input1; - this.amount = amount1; + public RecipeInputOreDict(String input1, int amount1, Integer meta) + { + input = input1; + amount = amount1; this.meta = meta; } @Override - public boolean matches(ItemStack subject) { - List<ItemStack> inputs = getOres(); - boolean useOreStackMeta = (meta == null); - Item subjectItem = subject.getItem(); - int subjectMeta = subject.getItemDamage(); - - for (ItemStack oreStack : inputs) { - Item oreItem = oreStack.getItem(); - if (oreItem == null) continue; // ignore invalid + public boolean matches(ItemStack subject) + { + final List<ItemStack> inputs = getOres(); + final boolean useOreStackMeta = (meta == null); + final Item subjectItem = subject.getItem(); + final int subjectMeta = subject.getItemDamage(); + + for(final ItemStack oreStack : inputs) + { + final Item oreItem = oreStack.getItem(); + if(oreItem == null) + { + continue; // ignore invalid + } - int metaRequired = useOreStackMeta ? oreStack.getItemDamage() : meta; + final int metaRequired = useOreStackMeta ? oreStack.getItemDamage() : meta; - if (subjectItem == oreItem && - (subjectMeta == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) { + if(subjectItem == oreItem && (subjectMeta == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) + { return true; } } @@ -47,58 +55,80 @@ public class RecipeInputOreDict implements IRecipeInput { } @Override - public int getAmount() { + public int getAmount() + { return amount; } @Override - public List<ItemStack> getInputs() { - List<ItemStack> ores = getOres(); + public List<ItemStack> getInputs() + { + final List<ItemStack> ores = getOres(); // check if we have to filter the list first boolean hasInvalidEntries = false; - for (ItemStack stack : ores) { - if (stack.getItem() == null) { + for(final ItemStack stack : ores) + { + if(stack.getItem() == null) + { hasInvalidEntries = true; break; } } - if (!hasInvalidEntries) return ores; + if(!hasInvalidEntries) + { + return ores; + } - List<ItemStack> ret = new ArrayList<ItemStack>(ores.size()); + final List<ItemStack> ret = new ArrayList<ItemStack>(ores.size()); - for (ItemStack stack : ores) { - if (stack.getItem() != null) ret.add(stack); // ignore invalid + for(final ItemStack stack : ores) + { + if(stack.getItem() != null) + { + ret.add(stack); // ignore invalid + } } return Collections.unmodifiableList(ret); } @Override - public String toString() { - if (meta == null) { - return "RInputOreDict<"+amount+"x"+input+">"; - } else { - return "RInputOreDict<"+amount+"x"+input+"@"+meta+">"; + public String toString() + { + if(meta == null) + { + return "RInputOreDict<" + amount + "x" + input + ">"; + } + else + { + return "RInputOreDict<" + amount + "x" + input + "@" + meta + ">"; } } - private List<ItemStack> getOres() { - if (ores != null) return ores; + private List<ItemStack> getOres() + { + if(ores != null) + { + return ores; + } // cache the ore list by making use of the fact that forge always uses the same list, // unless it's EMPTY_LIST, which should never happen. - List<ItemStack> ret = OreDictionary.getOres(input); + final List<ItemStack> ret = OreDictionary.getOres(input); - if (ret != OreDictionary.EMPTY_LIST) ores = ret; + if(ret != OreDictionary.EMPTY_LIST) + { + ores = ret; + } return ret; } - public final String input; - public final int amount; - public final Integer meta; - private List<ItemStack> ores; + public final String input; + public final int amount; + public final Integer meta; + private List<ItemStack> ores; } diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java index 80ad5fb..aa7839d 100644 --- a/src/api/java/ic2/api/recipe/RecipeOutput.java +++ b/src/api/java/ic2/api/recipe/RecipeOutput.java @@ -7,33 +7,42 @@ import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public final class RecipeOutput { - public RecipeOutput(NBTTagCompound metadata1, List<ItemStack> items1) { +public final class RecipeOutput +{ + public RecipeOutput(NBTTagCompound metadata1, List<ItemStack> items1) + { assert !items1.contains(null); - this.metadata = metadata1; - this.items = items1; + metadata = metadata1; + items = items1; } - public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) { + public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) + { this(metadata1, Arrays.asList(items1)); } @Override - public boolean equals(Object obj) { - if (obj instanceof RecipeOutput) { - RecipeOutput ro = (RecipeOutput) obj; - - if (items.size() == ro.items.size() && - (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) { - Iterator<ItemStack> itA = items.iterator(); - Iterator<ItemStack> itB = ro.items.iterator(); - - while (itA.hasNext() && itB.hasNext()) { - ItemStack stackA = itA.next(); - ItemStack stackB = itB.next(); - - if (ItemStack.areItemStacksEqual(stackA, stackB)) return false; + public boolean equals(Object obj) + { + if(obj instanceof RecipeOutput) + { + final RecipeOutput ro = (RecipeOutput) obj; + + if(items.size() == ro.items.size() && (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) + { + final Iterator<ItemStack> itA = items.iterator(); + final Iterator<ItemStack> itB = ro.items.iterator(); + + while(itA.hasNext() && itB.hasNext()) + { + final ItemStack stackA = itA.next(); + final ItemStack stackB = itB.next(); + + if(ItemStack.areItemStacksEqual(stackA, stackB)) + { + return false; + } } return true; @@ -44,10 +53,11 @@ public final class RecipeOutput { } @Override - public String toString() { - return "ROutput<"+items+","+metadata+">"; + public String toString() + { + return "ROutput<" + items + "," + metadata + ">"; } - public final List<ItemStack> items; - public final NBTTagCompound metadata; + public final List<ItemStack> items; + public final NBTTagCompound metadata; } diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java index 0aa0b75..0bcc71b 100644 --- a/src/api/java/ic2/api/recipe/Recipes.java +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -1,25 +1,25 @@ package ic2.api.recipe; - /** * General recipe registry. * * @author Richard */ -public class Recipes { - public static IMachineRecipeManager macerator; - public static IMachineRecipeManager extractor; - public static IMachineRecipeManager compressor; - public static IMachineRecipeManager centrifuge; - public static IMachineRecipeManager blockcutter; - public static IMachineRecipeManager blastfurance; - public static IMachineRecipeManager recycler; - public static IMachineRecipeManager metalformerExtruding; - public static IMachineRecipeManager metalformerCutting; - public static IMachineRecipeManager metalformerRolling; - public static IMachineRecipeManager oreWashing; - public static ICannerBottleRecipeManager cannerBottle; - public static ICannerEnrichRecipeManager cannerEnrich; +public class Recipes +{ + public static IMachineRecipeManager macerator; + public static IMachineRecipeManager extractor; + public static IMachineRecipeManager compressor; + public static IMachineRecipeManager centrifuge; + public static IMachineRecipeManager blockcutter; + public static IMachineRecipeManager blastfurance; + public static IMachineRecipeManager recycler; + public static IMachineRecipeManager metalformerExtruding; + public static IMachineRecipeManager metalformerCutting; + public static IMachineRecipeManager metalformerRolling; + public static IMachineRecipeManager oreWashing; + public static ICannerBottleRecipeManager cannerBottle; + public static ICannerEnrichRecipeManager cannerEnrich; /** * Reference amplifier values: @@ -33,7 +33,7 @@ public class Recipes { * nbt.setInteger("amplification", aValue); * matterAmplifier.addRecipe(yourStack, nbt); */ - public static IMachineRecipeManager matterAmplifier; + public static IMachineRecipeManager matterAmplifier; /** * Reference scrap box chance values: * @@ -46,23 +46,23 @@ public class Recipes { * 4.0: Stick * 5.0: Dirt, Wooden Hoe */ - public static IScrapboxManager scrapboxDrops; - public static IListRecipeManager recyclerBlacklist; + public static IScrapboxManager scrapboxDrops; + public static IListRecipeManager recyclerBlacklist; /** * Do not add anything to this Whitelist. This is for Configuration only. * You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List */ - public static IListRecipeManager recyclerWhitelist; - public static ICraftingRecipeManager advRecipes; + public static IListRecipeManager recyclerWhitelist; + public static ICraftingRecipeManager advRecipes; - public static ISemiFluidFuelManager semiFluidGenerator; - public static IFluidHeatManager FluidHeatGenerator; + public static ISemiFluidFuelManager semiFluidGenerator; + public static IFluidHeatManager FluidHeatGenerator; /** * Used by the Liquid Heat Exchanger to cool down liquids and determine the amount of hu generated for every mb. */ - public static ILiquidHeatExchangerManager liquidCooldownManager; + public static ILiquidHeatExchangerManager liquidCooldownManager; /** * Opposite of {@link #liquidCooldownManager}. This is for Liquids that can be heated up again. */ - public static ILiquidHeatExchangerManager liquidHeatupManager; + public static ILiquidHeatExchangerManager liquidHeatupManager; } diff --git a/src/api/java/ic2/api/recipe/package-info.java b/src/api/java/ic2/api/recipe/package-info.java index 44e70e7..4974eb1 100644 --- a/src/api/java/ic2/api/recipe/package-info.java +++ b/src/api/java/ic2/api/recipe/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.recipe; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.java b/src/api/java/ic2/api/tile/ExplosionWhitelist.java index fa4a474..ea3217b 100644 --- a/src/api/java/ic2/api/tile/ExplosionWhitelist.java +++ b/src/api/java/ic2/api/tile/ExplosionWhitelist.java @@ -13,35 +13,38 @@ import net.minecraft.block.Block; * invulnerable reactor chambers. Said blocks will not shield the explosion and won't get * destroyed. */ -public final class ExplosionWhitelist { +public final class ExplosionWhitelist +{ /** * Add a block to the whitelist. * * @param block block to add */ - public static void addWhitelistedBlock(Block block) { + public static void addWhitelistedBlock(Block block) + { whitelist.add(block); } - + /** * Remove a block from the whitelist. * * @param block block to remove */ - public static void removeWhitelistedBlock(Block block) { + public static void removeWhitelistedBlock(Block block) + { whitelist.remove(block); } - + /** * Check if a block is on the whitelist. * * @param block block to check if whitelisted * @return Whether the block is whitelisted */ - public static boolean isBlockWhitelisted(Block block) { + public static boolean isBlockWhitelisted(Block block) + { return whitelist.contains(block); } - private static Set<Block> whitelist = new HashSet<Block>(); + private static Set<Block> whitelist = new HashSet<Block>(); } - diff --git a/src/api/java/ic2/api/tile/IEnergyStorage.java b/src/api/java/ic2/api/tile/IEnergyStorage.java index 68f4270..c2ee2e4 100644 --- a/src/api/java/ic2/api/tile/IEnergyStorage.java +++ b/src/api/java/ic2/api/tile/IEnergyStorage.java @@ -5,7 +5,8 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Interface implemented by the tile entity of energy storage blocks. */ -public interface IEnergyStorage { +public interface IEnergyStorage +{ /** * Get the amount of energy currently stored in the block. * diff --git a/src/api/java/ic2/api/tile/IWrenchable.java b/src/api/java/ic2/api/tile/IWrenchable.java index 8fcbea5..bd2f3f5 100644 --- a/src/api/java/ic2/api/tile/IWrenchable.java +++ b/src/api/java/ic2/api/tile/IWrenchable.java @@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack; /** * Allows a tile entity to make use of the wrench's removal and rotation functions. */ -public interface IWrenchable { +public interface IWrenchable +{ /** * Determine if the wrench can be used to set the block's facing. * Called before wrenchCanRemove(). @@ -58,4 +59,3 @@ public interface IWrenchable { */ ItemStack getWrenchDrop(EntityPlayer entityPlayer); } - diff --git a/src/api/java/ic2/api/tile/package-info.java b/src/api/java/ic2/api/tile/package-info.java index 5ebc76e..26c013a 100644 --- a/src/api/java/ic2/api/tile/package-info.java +++ b/src/api/java/ic2/api/tile/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.tile; + import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/util/IKeyboard.java b/src/api/java/ic2/api/util/IKeyboard.java index ff6eaea..b71a5e4 100644 --- a/src/api/java/ic2/api/util/IKeyboard.java +++ b/src/api/java/ic2/api/util/IKeyboard.java @@ -2,13 +2,21 @@ package ic2.api.util; import net.minecraft.entity.player.EntityPlayer; -public interface IKeyboard { +public interface IKeyboard +{ boolean isAltKeyDown(EntityPlayer player); + boolean isBoostKeyDown(EntityPlayer player); + boolean isForwardKeyDown(EntityPlayer player); + boolean isJumpKeyDown(EntityPlayer player); + boolean isModeSwitchKeyDown(EntityPlayer player); + boolean isSideinventoryKeyDown(EntityPlayer player); + boolean isHudModeKeyDown(EntityPlayer player); + boolean isSneakKeyDown(EntityPlayer player); } diff --git a/src/api/java/ic2/api/util/Keys.java b/src/api/java/ic2/api/util/Keys.java index 84d1756..7493868 100644 --- a/src/api/java/ic2/api/util/Keys.java +++ b/src/api/java/ic2/api/util/Keys.java @@ -1,6 +1,6 @@ package ic2.api.util; - -public class Keys { - public static IKeyboard instance; -}
\ No newline at end of file +public class Keys +{ + public static IKeyboard instance; +} diff --git a/src/api/java/ic2/api/util/package-info.java b/src/api/java/ic2/api/util/package-info.java index 4dd2d93..3207c5b 100644 --- a/src/api/java/ic2/api/util/package-info.java +++ b/src/api/java/ic2/api/util/package-info.java @@ -1,4 +1,5 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.util; + import cpw.mods.fml.common.API; diff --git a/src/api/java/invtweaks/api/container/ChestContainer.java b/src/api/java/invtweaks/api/container/ChestContainer.java index dc27377..7a921fd 100644 --- a/src/api/java/invtweaks/api/container/ChestContainer.java +++ b/src/api/java/invtweaks/api/container/ChestContainer.java @@ -11,28 +11,31 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -public @interface ChestContainer { - // Set to true if the Inventory Tweaks sorting buttons should be shown for this container. - boolean showButtons() default true; +public @interface ChestContainer +{ + // Set to true if the Inventory Tweaks sorting buttons should be shown for this container. + boolean showButtons() default true; - // Size of a chest row - int rowSize() default 9; + // Size of a chest row + int rowSize() default 9; - // Uses 'large chest' mode for sorting buttons - // (Renders buttons vertically down the right side of the GUI) - boolean isLargeChest() default false; + // Uses 'large chest' mode for sorting buttons + // (Renders buttons vertically down the right side of the GUI) + boolean isLargeChest() default false; - // Annotation for method to get size of a chest row if it is not a fixed size for this container class - // Signature int func() - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface RowSizeCallback { - } + // Annotation for method to get size of a chest row if it is not a fixed size for this container class + // Signature int func() + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface RowSizeCallback + { + } - // Annotation for method to get size of a chest row if it is not a fixed size for this container class - // Signature int func() - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface IsLargeCallback { - } -}
\ No newline at end of file + // Annotation for method to get size of a chest row if it is not a fixed size for this container class + // Signature int func() + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface IsLargeCallback + { + } +} diff --git a/src/api/java/mcp/mobius/waila/api/IWailaBlock.java b/src/api/java/mcp/mobius/waila/api/IWailaBlock.java index 8b4dd13..181f938 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaBlock.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaBlock.java @@ -5,18 +5,19 @@ import java.util.List; import net.minecraft.item.ItemStack; @Deprecated -public interface IWailaBlock { +public interface IWailaBlock +{ /* * Use this method to return an item stack in case the default lookup system fails. * Return null if you want to use the default lookup system. * You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities */ - ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); - + ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); + /* Waila HUD is divided into 3 zones. The head corresponds to the item name, * body to where you mostly want to put informations, and I reserve the tail for modname display - */ - + */ + /* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD. * You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack(). * ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info. @@ -27,8 +28,10 @@ public interface IWailaBlock { * * Always return the currenttip is you don't want to modify the current zone. */ - + List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); + List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); + List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaBlockDecorator.java b/src/api/java/mcp/mobius/waila/api/IWailaBlockDecorator.java index 935d475..093d044 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaBlockDecorator.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaBlockDecorator.java @@ -2,8 +2,9 @@ package mcp.mobius.waila.api; import net.minecraft.item.ItemStack; -public interface IWailaBlockDecorator { +public interface IWailaBlockDecorator +{ + + void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config); - void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config); - } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaConfigHandler.java b/src/api/java/mcp/mobius/waila/api/IWailaConfigHandler.java index faede63..94e08d6 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaConfigHandler.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaConfigHandler.java @@ -3,13 +3,14 @@ package mcp.mobius.waila.api; import java.util.HashMap; import java.util.Set; -public interface IWailaConfigHandler { +public interface IWailaConfigHandler +{ /* Returns a set of all the currently loaded modules in the config handler */ public Set<String> getModuleNames(); - + /* Returns all the currently available options for a given module */ public HashMap<String, String> getConfigKeys(String modName); - + /* Add a new option to a given module * * modName is the name of the module to add the option to (ie : Buildcraft, IndustrialCraft2, etc) @@ -17,12 +18,12 @@ public interface IWailaConfigHandler { * name is the human readable name of the option (ie : "Tank content", "Max EU Input") * */ //public void addConfig(String modName, String key, String name); - + /* Returns the current value of an option (true/false) with a default value defvalue if not set*/ public boolean getConfig(String key, boolean defvalue); - - /* Returns the current value of an option (true/false) with a default value true if not set*/ - public boolean getConfig(String key); - + + /* Returns the current value of an option (true/false) with a default value true if not set*/ + public boolean getConfig(String key); + //public void setConfig(String key, boolean value); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaDataAccessor.java b/src/api/java/mcp/mobius/waila/api/IWailaDataAccessor.java index 0288624..9d0a6fb 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaDataAccessor.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaDataAccessor.java @@ -15,19 +15,32 @@ import net.minecraftforge.common.util.ForgeDirection; * It will also return things that are unmodified by the overriding systems (like getWailaStack). */ -public interface IWailaDataAccessor { - - World getWorld(); - EntityPlayer getPlayer(); - Block getBlock(); - int getBlockID(); - int getMetadata(); - TileEntity getTileEntity(); +public interface IWailaDataAccessor +{ + + World getWorld(); + + EntityPlayer getPlayer(); + + Block getBlock(); + + int getBlockID(); + + int getMetadata(); + + TileEntity getTileEntity(); + MovingObjectPosition getPosition(); - Vec3 getRenderingPosition(); - NBTTagCompound getNBTData(); - int getNBTInteger(NBTTagCompound tag, String keyname); - double getPartialFrame(); - ForgeDirection getSide(); - ItemStack getStack(); + + Vec3 getRenderingPosition(); + + NBTTagCompound getNBTData(); + + int getNBTInteger(NBTTagCompound tag, String keyname); + + double getPartialFrame(); + + ForgeDirection getSide(); + + ItemStack getStack(); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaDataProvider.java b/src/api/java/mcp/mobius/waila/api/IWailaDataProvider.java index 4859d9c..f0c886b 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaDataProvider.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaDataProvider.java @@ -4,18 +4,19 @@ import java.util.List; import net.minecraft.item.ItemStack; -public interface IWailaDataProvider{ +public interface IWailaDataProvider +{ /* * Use this method to return an item stack in case the default lookup system fails. * Return null if you want to use the default lookup system. * You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities */ - ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); - + ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); + /* Waila HUD is divided into 3 zones. The head corresponds to the item name, * body to where you mostly want to put informations, and I reserve the tail for modname display - */ - + */ + /* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD. * You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack(). * ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info. @@ -26,8 +27,10 @@ public interface IWailaDataProvider{ * * Always return the currenttip is you don't want to modify the current zone. */ - + List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); + List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); + List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaEntityAccessor.java b/src/api/java/mcp/mobius/waila/api/IWailaEntityAccessor.java index 788067a..62e3352 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaEntityAccessor.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaEntityAccessor.java @@ -12,13 +12,21 @@ import net.minecraft.world.World; * It will also return things that are unmodified by the overriding systems (like getWailaStack). */ -public interface IWailaEntityAccessor { - World getWorld(); - EntityPlayer getPlayer(); - Entity getEntity(); +public interface IWailaEntityAccessor +{ + World getWorld(); + + EntityPlayer getPlayer(); + + Entity getEntity(); + MovingObjectPosition getPosition(); - Vec3 getRenderingPosition(); - NBTTagCompound getNBTData(); - int getNBTInteger(NBTTagCompound tag, String keyname); - double getPartialFrame(); + + Vec3 getRenderingPosition(); + + NBTTagCompound getNBTData(); + + int getNBTInteger(NBTTagCompound tag, String keyname); + + double getPartialFrame(); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaEntityProvider.java b/src/api/java/mcp/mobius/waila/api/IWailaEntityProvider.java index 9548289..a7fe7a2 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaEntityProvider.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaEntityProvider.java @@ -4,13 +4,16 @@ import java.util.List; import net.minecraft.entity.Entity; -public interface IWailaEntityProvider { - +public interface IWailaEntityProvider +{ + /* A way to get an override on the entity returned by the raytracing */ Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config); - + /* The classical HEAD/BODY/TAIL text getters */ List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config); + List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config); + List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaFMPAccessor.java b/src/api/java/mcp/mobius/waila/api/IWailaFMPAccessor.java index 19e01fa..a885ea7 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaFMPAccessor.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaFMPAccessor.java @@ -1,7 +1,6 @@ package mcp.mobius.waila.api; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; @@ -13,15 +12,25 @@ import net.minecraft.world.World; * It will also return things that are unmodified by the overriding systems (like getWailaStack). */ -public interface IWailaFMPAccessor { - World getWorld(); - EntityPlayer getPlayer(); - TileEntity getTileEntity(); +public interface IWailaFMPAccessor +{ + World getWorld(); + + EntityPlayer getPlayer(); + + TileEntity getTileEntity(); + MovingObjectPosition getPosition(); - NBTTagCompound getNBTData(); - NBTTagCompound getFullNBTData(); - int getNBTInteger(NBTTagCompound tag, String keyname); - double getPartialFrame(); - Vec3 getRenderingPosition(); - String getID(); + + NBTTagCompound getNBTData(); + + NBTTagCompound getFullNBTData(); + + int getNBTInteger(NBTTagCompound tag, String keyname); + + double getPartialFrame(); + + Vec3 getRenderingPosition(); + + String getID(); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaFMPDecorator.java b/src/api/java/mcp/mobius/waila/api/IWailaFMPDecorator.java index 839af31..64d6e30 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaFMPDecorator.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaFMPDecorator.java @@ -2,6 +2,7 @@ package mcp.mobius.waila.api; import net.minecraft.item.ItemStack; -public interface IWailaFMPDecorator { - void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config); +public interface IWailaFMPDecorator +{ + void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaFMPProvider.java b/src/api/java/mcp/mobius/waila/api/IWailaFMPProvider.java index 232c83e..08f0ca3 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaFMPProvider.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaFMPProvider.java @@ -4,9 +4,12 @@ import java.util.List; import net.minecraft.item.ItemStack; -public interface IWailaFMPProvider { +public interface IWailaFMPProvider +{ /* The classical HEAD/BODY/TAIL text getters */ List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config); + List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config); + List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaRegistrar.java b/src/api/java/mcp/mobius/waila/api/IWailaRegistrar.java index 162aeb6..8414a81 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaRegistrar.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaRegistrar.java @@ -1,35 +1,47 @@ package mcp.mobius.waila.api; -public interface IWailaRegistrar { +public interface IWailaRegistrar +{ /* Add a config option in the section modname with displayed text configtext and access key keyname */ public void addConfig(String modname, String keyname, String configtext); - public void addConfigRemote(String modname, String keyname, String configtext); + + public void addConfigRemote(String modname, String keyname, String configtext); + public void addConfig(String modname, String keyname); - public void addConfigRemote(String modname, String keyname); - + + public void addConfigRemote(String modname, String keyname); + /* Register a stack overrider for the given blockID */ - public void registerStackProvider(IWailaDataProvider dataProvider, Class block); - + public void registerStackProvider(IWailaDataProvider dataProvider, Class block); + /* Same thing, but works on a class hierarchy instead */ - public void registerHeadProvider (IWailaDataProvider dataProvider, Class block); - public void registerBodyProvider (IWailaDataProvider dataProvider, Class block); - public void registerTailProvider (IWailaDataProvider dataProvider, Class block); + public void registerHeadProvider(IWailaDataProvider dataProvider, Class block); + + public void registerBodyProvider(IWailaDataProvider dataProvider, Class block); + + public void registerTailProvider(IWailaDataProvider dataProvider, Class block); /* Entity text registration methods */ - public void registerHeadProvider (IWailaEntityProvider dataProvider, Class entity); - public void registerBodyProvider (IWailaEntityProvider dataProvider, Class entity); - public void registerTailProvider (IWailaEntityProvider dataProvider, Class entity); - public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity); - + public void registerHeadProvider(IWailaEntityProvider dataProvider, Class entity); + + public void registerBodyProvider(IWailaEntityProvider dataProvider, Class entity); + + public void registerTailProvider(IWailaEntityProvider dataProvider, Class entity); + + public void registerOverrideEntityProvider(IWailaEntityProvider dataProvider, Class entity); + /* FMP Providers */ public void registerHeadProvider(IWailaFMPProvider dataProvider, String name); + public void registerBodyProvider(IWailaFMPProvider dataProvider, String name); + public void registerTailProvider(IWailaFMPProvider dataProvider, String name); - + /* The block decorators */ - public void registerDecorator (IWailaBlockDecorator decorator, Class block); - public void registerDecorator (IWailaFMPDecorator decorator, String name); - + public void registerDecorator(IWailaBlockDecorator decorator, Class block); + + public void registerDecorator(IWailaFMPDecorator decorator, String name); + /* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent). * Accept * as a ending wildcard * registerNBTKey("bob.*", MyBlock.class) @@ -39,6 +51,7 @@ public interface IWailaRegistrar { public void registerSyncedNBTKey(String key, Class target); /* UNUSED FOR NOW (Will be used for the ingame wiki */ - public void registerDocTextFile (String filename); - public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item); + public void registerDocTextFile(String filename); + + public void registerShortDataProvider(IWailaSummaryProvider dataProvider, Class item); } diff --git a/src/api/java/mcp/mobius/waila/api/IWailaSummaryProvider.java b/src/api/java/mcp/mobius/waila/api/IWailaSummaryProvider.java index f790649..3d7a349 100644 --- a/src/api/java/mcp/mobius/waila/api/IWailaSummaryProvider.java +++ b/src/api/java/mcp/mobius/waila/api/IWailaSummaryProvider.java @@ -4,9 +4,10 @@ import java.util.LinkedHashMap; import net.minecraft.item.ItemStack; -public interface IWailaSummaryProvider { +public interface IWailaSummaryProvider +{ /* This interface is used to control the display data in the description screen */ - + /* BASIC TOOLS & ITEMS DATA */ //EnumToolMaterial getMaterial(ItemStack stack); //String getMaterialName(ItemStack stack); @@ -16,6 +17,6 @@ public interface IWailaSummaryProvider { //int getEnchantability(ItemStack stack); //int getDamageVsEntity(ItemStack stack); //int getDurability(ItemStack stack); - + LinkedHashMap<String, String> getSummary(ItemStack stack, LinkedHashMap<String, String> currentSummary, IWailaConfigHandler config); } diff --git a/src/api/java/mcp/mobius/waila/api/SpecialChars.java b/src/api/java/mcp/mobius/waila/api/SpecialChars.java index 5bd92a8..a987a15 100644 --- a/src/api/java/mcp/mobius/waila/api/SpecialChars.java +++ b/src/api/java/mcp/mobius/waila/api/SpecialChars.java @@ -1,40 +1,41 @@ package mcp.mobius.waila.api; -public class SpecialChars { +public class SpecialChars +{ - public static String MCStyle = "\u00A7"; - - public static String BLACK = MCStyle + "0"; - public static String DBLUE = MCStyle + "1"; - public static String DGREEN = MCStyle + "2"; - public static String DAQUA = MCStyle + "3"; - public static String DRED = MCStyle + "4"; - public static String DPURPLE = MCStyle + "5"; - public static String GOLD = MCStyle + "6"; - public static String GRAY = MCStyle + "7"; - public static String DGRAY = MCStyle + "8"; - public static String BLUE = MCStyle + "9"; - public static String GREEN = MCStyle + "a"; - public static String AQUA = MCStyle + "b"; - public static String RED = MCStyle + "c"; - public static String LPURPLE = MCStyle + "d"; - public static String YELLOW = MCStyle + "e"; - public static String WHITE = MCStyle + "f"; - - public static String OBF = MCStyle + "k"; - public static String BOLD = MCStyle + "l"; - public static String STRIKE = MCStyle + "m"; - public static String UNDER = MCStyle + "n"; - public static String ITALIC = MCStyle + "o"; - public static String RESET = MCStyle + "r"; + public static String MCStyle = "\u00A7"; + + public static String BLACK = MCStyle + "0"; + public static String DBLUE = MCStyle + "1"; + public static String DGREEN = MCStyle + "2"; + public static String DAQUA = MCStyle + "3"; + public static String DRED = MCStyle + "4"; + public static String DPURPLE = MCStyle + "5"; + public static String GOLD = MCStyle + "6"; + public static String GRAY = MCStyle + "7"; + public static String DGRAY = MCStyle + "8"; + public static String BLUE = MCStyle + "9"; + public static String GREEN = MCStyle + "a"; + public static String AQUA = MCStyle + "b"; + public static String RED = MCStyle + "c"; + public static String LPURPLE = MCStyle + "d"; + public static String YELLOW = MCStyle + "e"; + public static String WHITE = MCStyle + "f"; + + public static String OBF = MCStyle + "k"; + public static String BOLD = MCStyle + "l"; + public static String STRIKE = MCStyle + "m"; + public static String UNDER = MCStyle + "n"; + public static String ITALIC = MCStyle + "o"; + public static String RESET = MCStyle + "r"; + + public static String WailaStyle = "\u00A4"; + public static String WailaIcon = "\u00A5"; + public static String TAB = WailaStyle + WailaStyle + "a"; + public static String ALIGNRIGHT = WailaStyle + WailaStyle + "b"; + public static String ALIGNCENTER = WailaStyle + WailaStyle + "c"; + public static String HEART = WailaStyle + WailaIcon + "a"; + public static String HHEART = WailaStyle + WailaIcon + "b"; + public static String EHEART = WailaStyle + WailaIcon + "c"; - public static String WailaStyle = "\u00A4"; - public static String WailaIcon = "\u00A5"; - public static String TAB = WailaStyle + WailaStyle +"a"; - public static String ALIGNRIGHT = WailaStyle + WailaStyle +"b"; - public static String ALIGNCENTER = WailaStyle + WailaStyle +"c"; - public static String HEART = WailaStyle + WailaIcon +"a"; - public static String HHEART = WailaStyle + WailaIcon +"b"; - public static String EHEART = WailaStyle + WailaIcon +"c"; - } diff --git a/src/api/java/mcp/mobius/waila/api/package-info.java b/src/api/java/mcp/mobius/waila/api/package-info.java index 9b5e663..82cf044 100644 --- a/src/api/java/mcp/mobius/waila/api/package-info.java +++ b/src/api/java/mcp/mobius/waila/api/package-info.java @@ -1,3 +1,5 @@ -@API(apiVersion="1.0",owner="Waila",provides="WailaAPI") +@API(apiVersion = "1.0", owner = "Waila", provides = "WailaAPI") package mcp.mobius.waila.api; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/Chunk3D.java b/src/api/java/mekanism/api/Chunk3D.java index f469d5d..11c758f 100644 --- a/src/api/java/mekanism/api/Chunk3D.java +++ b/src/api/java/mekanism/api/Chunk3D.java @@ -13,11 +13,11 @@ import net.minecraft.world.chunk.Chunk; */ public class Chunk3D { - public int dimensionId; - - public int xCoord; - public int zCoord; - + public int dimensionId; + + public int xCoord; + public int zCoord; + /** * Creates a Chunk3D object from the given x and z coordinates, as well as a dimension. * @param x - chunk x location @@ -28,22 +28,22 @@ public class Chunk3D { xCoord = x; zCoord = z; - + dimensionId = dimension; } - + /** * Creates a Chunk3D from an entity based on it's location and dimension. * @param entity - the entity to get the Chunk3D object from */ public Chunk3D(Entity entity) { - xCoord = ((int)entity.posX) >> 4; - zCoord = ((int)entity.posZ) >> 4; - + xCoord = ((int) entity.posX) >> 4; + zCoord = ((int) entity.posZ) >> 4; + dimensionId = entity.dimension; } - + /** * Creates a Chunk3D from a Coord4D based on it's coordinates and dimension. * @param coord - the Coord4D object to get this Chunk3D from @@ -52,10 +52,10 @@ public class Chunk3D { xCoord = coord.xCoord >> 4; zCoord = coord.zCoord >> 4; - + dimensionId = coord.dimensionId; } - + /** * Whether or not this chunk exists in the given world. * @param world - the world to check in @@ -65,7 +65,7 @@ public class Chunk3D { return world.getChunkProvider().chunkExists(xCoord, zCoord); } - + /** * Gets a Chunk object corresponding to this Chunk3D's coordinates. * @param world - the world to get the Chunk object from @@ -75,7 +75,7 @@ public class Chunk3D { return world.getChunkFromChunkCoords(xCoord, zCoord); } - + /** * Returns this Chunk3D in the Minecraft-based ChunkCoordIntPair format. * @return this Chunk3D as a ChunkCoordIntPair @@ -84,7 +84,7 @@ public class Chunk3D { return new ChunkCoordIntPair(xCoord, zCoord); } - + @Override public Coord4D clone() { @@ -100,10 +100,7 @@ public class Chunk3D @Override public boolean equals(Object obj) { - return obj instanceof Chunk3D && - ((Chunk3D)obj).xCoord == xCoord && - ((Chunk3D)obj).zCoord == zCoord && - ((Chunk3D)obj).dimensionId == dimensionId; + return obj instanceof Chunk3D && ((Chunk3D) obj).xCoord == xCoord && ((Chunk3D) obj).zCoord == zCoord && ((Chunk3D) obj).dimensionId == dimensionId; } @Override diff --git a/src/api/java/mekanism/api/Coord4D.java b/src/api/java/mekanism/api/Coord4D.java index 1a0f7e4..57f82ca 100644 --- a/src/api/java/mekanism/api/Coord4D.java +++ b/src/api/java/mekanism/api/Coord4D.java @@ -1,7 +1,9 @@ package mekanism.api; -import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; @@ -15,8 +17,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.util.ForgeDirection; - -import java.util.ArrayList; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; /** * Coord4D - an integer-based way to keep track of and perform operations on blocks in a Minecraft-based environment. This also takes @@ -26,11 +27,11 @@ import java.util.ArrayList; */ public class Coord4D { - public int xCoord; - public int yCoord; - public int zCoord; + public int xCoord; + public int yCoord; + public int zCoord; - public int dimensionId; + public int dimensionId; /** * Creates a Coord4D WITHOUT a dimensionId. Don't use unless absolutely necessary. @@ -46,17 +47,17 @@ public class Coord4D dimensionId = 0; } - + /** * Creates a Coord4D from an entity's position, rounded down. * @param entity - entity to create the Coord4D from */ public Coord4D(Entity entity) { - xCoord = (int)entity.posX; - yCoord = (int)entity.posY; - zCoord = (int)entity.posZ; - + xCoord = (int) entity.posX; + yCoord = (int) entity.posY; + zCoord = (int) entity.posZ; + dimensionId = entity.worldObj.provider.dimensionId; } @@ -100,7 +101,7 @@ public class Coord4D */ public TileEntity getTileEntity(IBlockAccess world) { - if(world instanceof World && !exists((World)world)) + if(world instanceof World && !exists((World) world)) { return null; } @@ -115,11 +116,11 @@ public class Coord4D */ public Block getBlock(IBlockAccess world) { - if(world instanceof World && !exists((World)world)) + if(world instanceof World && !exists((World) world)) { return null; } - + return world.getBlock(xCoord, yCoord, zCoord); } @@ -149,7 +150,7 @@ public class Coord4D data.add(zCoord); data.add(dimensionId); } - + /** * Writes this Coord4D's data to a ByteBuf for packet transfer. * @param dataStream - the ByteBuf to add the data to @@ -177,7 +178,7 @@ public class Coord4D return this; } - + /** * Translates this Coord4D by the defined Coord4D's coordinates, regardless of dimension. * @param coord - coordinates to translate by @@ -186,7 +187,7 @@ public class Coord4D public Coord4D translate(Coord4D coord) { translate(coord.xCoord, coord.yCoord, coord.zCoord); - + return this; } @@ -208,18 +209,20 @@ public class Coord4D */ public Coord4D getFromSide(ForgeDirection side, int amount) { - return new Coord4D(xCoord+(side.offsetX*amount), yCoord+(side.offsetY*amount), zCoord+(side.offsetZ*amount), dimensionId); + return new Coord4D(xCoord + (side.offsetX * amount), + yCoord + (side.offsetY * amount), + zCoord + (side.offsetZ * amount), dimensionId); } - + public ItemStack getStack(IBlockAccess world) { - Block block = getBlock(world); - + final Block block = getBlock(world); + if(block == null || block == Blocks.air) { return null; } - + return new ItemStack(block, 1, getMetadata(world)); } @@ -230,7 +233,9 @@ public class Coord4D */ public static Coord4D get(TileEntity tileEntity) { - return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.getWorldObj().provider.dimensionId); + return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, + tileEntity.zCoord, + tileEntity.getWorldObj().provider.dimensionId); } /** @@ -238,10 +243,11 @@ public class Coord4D * @param tag - tag compound to read from * @return the Coord4D from the tag compound */ - public static Coord4D read(NBTTagCompound tag) - { - return new Coord4D(tag.getInteger("x"), tag.getInteger("y"), tag.getInteger("z"), tag.getInteger("id")); - } + public static Coord4D read(NBTTagCompound tag) + { + return new Coord4D(tag.getInteger("x"), tag.getInteger("y"), + tag.getInteger("z"), tag.getInteger("id")); + } /** * Returns a new Coord4D from a ByteBuf. @@ -250,7 +256,8 @@ public class Coord4D */ public static Coord4D read(ByteBuf dataStream) { - return new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); + return new Coord4D(dataStream.readInt(), dataStream.readInt(), + dataStream.readInt(), dataStream.readInt()); } /** @@ -260,7 +267,8 @@ public class Coord4D */ public Coord4D difference(Coord4D other) { - return new Coord4D(xCoord-other.xCoord, yCoord-other.yCoord, zCoord-other.zCoord, dimensionId); + return new Coord4D(xCoord - other.xCoord, yCoord - other.yCoord, + zCoord - other.zCoord, dimensionId); } /** @@ -271,9 +279,9 @@ public class Coord4D */ public ForgeDirection sideDifference(Coord4D other) { - Coord4D diff = difference(other); + final Coord4D diff = difference(other); - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + for(final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if(side.offsetX == diff.xCoord && side.offsetY == diff.yCoord && side.offsetZ == diff.zCoord) { @@ -291,10 +299,10 @@ public class Coord4D */ public int distanceTo(Coord4D obj) { - int subX = xCoord - obj.xCoord; - int subY = yCoord - obj.yCoord; - int subZ = zCoord - obj.zCoord; - return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); + final int subX = xCoord - obj.xCoord; + final int subY = yCoord - obj.yCoord; + final int subZ = zCoord - obj.zCoord; + return (int) MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); } /** @@ -305,9 +313,9 @@ public class Coord4D */ public boolean sideVisible(ForgeDirection side, IBlockAccess world) { - return world.isAirBlock(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ); + return world.isAirBlock(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ); } - + /** * Gets a TargetPoint with the defined range from this Coord4D with the appropriate coordinates and dimension ID. * @param range - the range the packet can be sent in of this Coord4D @@ -347,7 +355,7 @@ public class Coord4D { return world.getChunkFromBlockCoords(xCoord, zCoord); } - + /** * Gets the Chunk3D object with chunk coordinates correlating to this Coord4D's location * @return Chunk3D with correlating chunk coordinates. @@ -366,7 +374,7 @@ public class Coord4D { return world.isAirBlock(xCoord, yCoord, zCoord); } - + /** * Whether or not this block this Coord4D represents is replaceable. * @param world - world this Coord4D is in @@ -376,14 +384,14 @@ public class Coord4D { return getBlock(world).isReplaceable(world, xCoord, yCoord, zCoord); } - + /** * Gets a bounding box that contains the area this Coord4D would take up in a world. * @return this Coord4D's bounding box */ public AxisAlignedBB getBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+1, zCoord+1); + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); } @Override @@ -401,11 +409,7 @@ public class Coord4D @Override public boolean equals(Object obj) { - return obj instanceof Coord4D && - ((Coord4D)obj).xCoord == xCoord && - ((Coord4D)obj).yCoord == yCoord && - ((Coord4D)obj).zCoord == zCoord && - ((Coord4D)obj).dimensionId == dimensionId; + return obj instanceof Coord4D && ((Coord4D) obj).xCoord == xCoord && ((Coord4D) obj).yCoord == yCoord && ((Coord4D) obj).zCoord == zCoord && ((Coord4D) obj).dimensionId == dimensionId; } @Override @@ -418,4 +422,4 @@ public class Coord4D code = 31 * code + dimensionId; return code; } -}
\ No newline at end of file +} diff --git a/src/api/java/mekanism/api/EnumColor.java b/src/api/java/mekanism/api/EnumColor.java index df9ba74..73d8b61 100644 --- a/src/api/java/mekanism/api/EnumColor.java +++ b/src/api/java/mekanism/api/EnumColor.java @@ -9,39 +9,23 @@ import net.minecraft.util.StatCollector; */ public enum EnumColor { - BLACK("\u00a70", "black", "Black", new int[] {0, 0, 0}, 0), - DARK_BLUE("\u00a71", "darkBlue", "Blue", new int[] {0, 0, 170}, 4), - DARK_GREEN("\u00a72", "darkGreen", "Green", new int[] {0, 170, 0}, 2), - DARK_AQUA("\u00a73", "darkAqua", "Cyan", new int[] {0, 255, 255}, 6), - DARK_RED("\u00a74", "darkRed", null, new int[] {170, 0, 0}, -1), - PURPLE("\u00a75", "purple", "Purple", new int[] {170, 0, 170}, 5), - ORANGE("\u00a76", "orange", "Orange", new int[] {255, 170, 0}, 14), - GREY("\u00a77", "grey", "LightGray", new int[] {170, 170, 170}, 7), - DARK_GREY("\u00a78", "darkGrey", "Gray", new int[] {85, 85, 85}, 8), - INDIGO("\u00a79", "indigo", "LightBlue", new int[] {85, 85, 255}, 12), - BRIGHT_GREEN("\u00a7a", "brightGreen", "Lime", new int[] {85, 255, 85}, 10), - AQUA("\u00a7b", "aqua", null, new int[] {85, 255, 255}, -1), - RED("\u00a7c", "red", "Red", new int[] {255, 0, 0}, 1), - PINK("\u00a7d", "pink", "Magenta", new int[] {255, 85, 255}, 13), - YELLOW("\u00a7e", "yellow", "Yellow", new int[] {255, 255, 85}, 11), - WHITE("\u00a7f", "white", "White", new int[] {255, 255, 255}, 15), + BLACK("\u00a70", "black", "Black", new int[] {0, 0, 0}, 0), DARK_BLUE("\u00a71", "darkBlue", "Blue", new int[] {0, 0, 170}, 4), DARK_GREEN("\u00a72", "darkGreen", "Green", new int[] {0, 170, 0}, 2), DARK_AQUA("\u00a73", "darkAqua", "Cyan", new int[] {0, 255, 255}, 6), DARK_RED("\u00a74", "darkRed", null, new int[] {170, 0, 0}, -1), PURPLE("\u00a75", "purple", "Purple", new int[] {170, 0, 170}, 5), ORANGE("\u00a76", "orange", "Orange", new int[] {255, 170, 0}, 14), GREY("\u00a77", "grey", "LightGray", new int[] {170, 170, 170}, 7), DARK_GREY("\u00a78", "darkGrey", "Gray", new int[] {85, 85, 85}, 8), INDIGO("\u00a79", "indigo", "LightBlue", new int[] {85, 85, 255}, 12), BRIGHT_GREEN("\u00a7a", "brightGreen", "Lime", new int[] {85, 255, 85}, 10), AQUA("\u00a7b", "aqua", null, new int[] {85, 255, 255}, -1), RED("\u00a7c", "red", "Red", new int[] {255, 0, 0}, 1), PINK("\u00a7d", "pink", "Magenta", new int[] {255, 85, 255}, 13), YELLOW("\u00a7e", "yellow", "Yellow", new int[] {255, 255, 85}, 11), WHITE("\u00a7f", "white", "White", new int[] {255, 255, 255}, 15), //Extras for dye-completeness - BROWN("\u00a76", "brown", "Brown", new int[] {150, 75, 0}, 3), - BRIGHT_PINK("\u00a7d", "brightPink", "Pink", new int[] {255, 192, 203}, 9); + BROWN("\u00a76", "brown", "Brown", new int[] {150, 75, 0}, 3), BRIGHT_PINK("\u00a7d", "brightPink", "Pink", new int[] {255, 192, 203}, 9); - public static EnumColor[] DYES = new EnumColor[] {BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, INDIGO, PINK, ORANGE, WHITE}; + public static EnumColor[] DYES = new EnumColor[] {BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, INDIGO, PINK, ORANGE, WHITE}; /** The color code that will be displayed */ - public final String code; + public final String code; - public final int[] rgbCode; + public final int[] rgbCode; - public final int mcMeta; + public final int mcMeta; /** A friendly name of the color. */ - public String unlocalizedName; - - public String dyeName; + public String unlocalizedName; + + public String dyeName; private EnumColor(String s, String n, String dye, int[] rgb, int meta) { @@ -65,7 +49,7 @@ public enum EnumColor { return StatCollector.translateToLocal("dye." + unlocalizedName); } - + public String getOreDictName() { return dyeName; @@ -92,7 +76,7 @@ public enum EnumColor */ public float getColor(int index) { - return (float)rgbCode[index]/255F; + return rgbCode[index] / 255F; } /** diff --git a/src/api/java/mekanism/api/IFilterAccess.java b/src/api/java/mekanism/api/IFilterAccess.java index abdcf29..7bb2ee3 100644 --- a/src/api/java/mekanism/api/IFilterAccess.java +++ b/src/api/java/mekanism/api/IFilterAccess.java @@ -16,13 +16,13 @@ public interface IFilterAccess * @return the NBTTagCompound that now contains the TileEntity's filter card data */ public NBTTagCompound getFilterData(NBTTagCompound nbtTags); - + /** * Retrieves the TileEntity's data contained in the filter card based on the given NBTTagCompopund. * @param nbtTags - the NBTTagCompound of the filter card ItemStack */ public void setFilterData(NBTTagCompound nbtTags); - + /** * A String name of this TileEntity that will be displayed as the type of data on the filter card. * @return the String name of this TileEntity diff --git a/src/api/java/mekanism/api/IHeatTransfer.java b/src/api/java/mekanism/api/IHeatTransfer.java index da682e1..17393f7 100644 --- a/src/api/java/mekanism/api/IHeatTransfer.java +++ b/src/api/java/mekanism/api/IHeatTransfer.java @@ -5,10 +5,10 @@ import net.minecraftforge.common.util.ForgeDirection; public interface IHeatTransfer { /**The value of the zero point of our temperature scale in kelvin*/ - public static final double AMBIENT_TEMP = 300; + public static final double AMBIENT_TEMP = 300; /**The heat transfer coefficient for air*/ - public static final double AIR_INVERSE_COEFFICIENT = 10000; + public static final double AIR_INVERSE_COEFFICIENT = 10000; public double getTemp(); diff --git a/src/api/java/mekanism/api/ItemRetriever.java b/src/api/java/mekanism/api/ItemRetriever.java index c2820f0..1b6f4bd 100644 --- a/src/api/java/mekanism/api/ItemRetriever.java +++ b/src/api/java/mekanism/api/ItemRetriever.java @@ -13,10 +13,10 @@ import net.minecraft.item.ItemStack; public final class ItemRetriever { /** The 'MekanismItems' class that items are retrieved from. */ - private static Class MekanismItems; - + private static Class MekanismItems; + /** The 'MekanismBlocks' class that blocks are retrieved from. */ - private static Class MekanismBlocks; + private static Class MekanismBlocks; /** * Attempts to retrieve an ItemStack of an item with the declared identifier. @@ -43,27 +43,31 @@ public final class ItemRetriever */ public static ItemStack getItem(String identifier) { - try { + try + { if(MekanismItems == null) { MekanismItems = Class.forName("mekanism.common.MekanismItems"); } - Object ret = MekanismItems.getField(identifier).get(null); + final Object ret = MekanismItems.getField(identifier).get(null); if(ret instanceof Item) { - return new ItemStack((Item)ret, 1); + return new ItemStack((Item) ret, 1); } - else { + else + { return null; } - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error retrieving item with identifier '" + identifier + "': " + e.getMessage()); return null; } } - + /** * Attempts to retrieve an ItemStack of a block with the declared identifier. * @@ -89,22 +93,26 @@ public final class ItemRetriever */ public static ItemStack getBlock(String identifier) { - try { + try + { if(MekanismBlocks == null) { MekanismBlocks = Class.forName("mekanism.common.MekanismBlocks"); } - Object ret = MekanismBlocks.getField(identifier).get(null); + final Object ret = MekanismBlocks.getField(identifier).get(null); if(ret instanceof Block) { - return new ItemStack((Block)ret, 1); + return new ItemStack((Block) ret, 1); } - else { + else + { return null; } - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error retrieving block with identifier '" + identifier + "': " + e.getMessage()); return null; } diff --git a/src/api/java/mekanism/api/MekanismAPI.java b/src/api/java/mekanism/api/MekanismAPI.java index abdd6da..cfbdb68 100644 --- a/src/api/java/mekanism/api/MekanismAPI.java +++ b/src/api/java/mekanism/api/MekanismAPI.java @@ -4,7 +4,6 @@ import java.util.HashSet; import java.util.Set; import mekanism.api.util.BlockInfo; - import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.oredict.OreDictionary; @@ -13,14 +12,14 @@ import cpw.mods.fml.common.eventhandler.Event; public class MekanismAPI { //Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes - private static Set<BlockInfo> cardboardBoxIgnore = new HashSet<BlockInfo>(); - + private static Set<BlockInfo> cardboardBoxIgnore = new HashSet<BlockInfo>(); + /** Mekanism debug mode */ - public static boolean debug = false; + public static boolean debug = false; public static boolean isBlockCompatible(Item item, int meta) { - for(BlockInfo i : cardboardBoxIgnore) + for(final BlockInfo i : cardboardBoxIgnore) { if(i.block == Block.getBlockFromItem(item) && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta)) { @@ -46,5 +45,7 @@ public class MekanismAPI return cardboardBoxIgnore; } - public static class BoxBlacklistEvent extends Event {} + public static class BoxBlacklistEvent extends Event + { + } } diff --git a/src/api/java/mekanism/api/MekanismConfig.java b/src/api/java/mekanism/api/MekanismConfig.java index 2f9ea68..81772b1 100644 --- a/src/api/java/mekanism/api/MekanismConfig.java +++ b/src/api/java/mekanism/api/MekanismConfig.java @@ -10,76 +10,76 @@ public class MekanismConfig { public static class general { - public static boolean updateNotifications = true; - public static boolean controlCircuitOreDict = true; - public static boolean logPackets = false; - public static boolean dynamicTankEasterEgg = false; - public static boolean voiceServerEnabled = true; - public static boolean cardboardSpawners = true; - public static boolean enableWorldRegeneration = true; - public static boolean creativeOverrideElectricChest = true; - public static boolean spawnBabySkeletons = true; - public static int obsidianTNTBlastRadius = 12; - public static int osmiumPerChunk = 12; - public static int copperPerChunk = 16; - public static int tinPerChunk = 14; - public static int saltPerChunk = 2; - public static int obsidianTNTDelay = 100; - public static int UPDATE_DELAY = 10; - public static int VOICE_PORT = 36123; - public static int maxUpgradeMultiplier = 10; - public static int userWorldGenVersion = 0; - public static double ENERGY_PER_REDSTONE = 10000; - public static int ETHENE_BURN_TIME = 40; - public static double DISASSEMBLER_USAGE = 10; - public static EnergyType activeType = EnergyType.J; - public static TempType tempUnit = TempType.K; - public static double TO_IC2; - public static double TO_TE; - public static double FROM_H2; - public static double FROM_IC2; - public static double FROM_TE; - public static int laserRange; - public static double laserEnergyNeededPerHardness; - public static double minerSilkMultiplier = 6; - public static boolean blacklistIC2; - public static boolean blacklistRF; - public static boolean destroyDisabledBlocks; - public static boolean enableAmbientLighting; - public static int ambientLightingLevel; - public static boolean prefilledPortableTanks; - public static double armoredJetpackDamageRatio; - public static int armoredJetpackDamageMax; - public static boolean aestheticWorldDamage; - public static boolean opsBypassRestrictions; - public static double solarEvaporationSpeed; - public static int maxJetpackGas; - public static int maxScubaGas; - public static int maxFlamethrowerGas; + public static boolean updateNotifications = true; + public static boolean controlCircuitOreDict = true; + public static boolean logPackets = false; + public static boolean dynamicTankEasterEgg = false; + public static boolean voiceServerEnabled = true; + public static boolean cardboardSpawners = true; + public static boolean enableWorldRegeneration = true; + public static boolean creativeOverrideElectricChest = true; + public static boolean spawnBabySkeletons = true; + public static int obsidianTNTBlastRadius = 12; + public static int osmiumPerChunk = 12; + public static int copperPerChunk = 16; + public static int tinPerChunk = 14; + public static int saltPerChunk = 2; + public static int obsidianTNTDelay = 100; + public static int UPDATE_DELAY = 10; + public static int VOICE_PORT = 36123; + public static int maxUpgradeMultiplier = 10; + public static int userWorldGenVersion = 0; + public static double ENERGY_PER_REDSTONE = 10000; + public static int ETHENE_BURN_TIME = 40; + public static double DISASSEMBLER_USAGE = 10; + public static EnergyType activeType = EnergyType.J; + public static TempType tempUnit = TempType.K; + public static double TO_IC2; + public static double TO_TE; + public static double FROM_H2; + public static double FROM_IC2; + public static double FROM_TE; + public static int laserRange; + public static double laserEnergyNeededPerHardness; + public static double minerSilkMultiplier = 6; + public static boolean blacklistIC2; + public static boolean blacklistRF; + public static boolean destroyDisabledBlocks; + public static boolean enableAmbientLighting; + public static int ambientLightingLevel; + public static boolean prefilledPortableTanks; + public static double armoredJetpackDamageRatio; + public static int armoredJetpackDamageMax; + public static boolean aestheticWorldDamage; + public static boolean opsBypassRestrictions; + public static double solarEvaporationSpeed; + public static int maxJetpackGas; + public static int maxScubaGas; + public static int maxFlamethrowerGas; } public static class client { - public static boolean enablePlayerSounds = true; - public static boolean enableMachineSounds = true; - public static boolean fancyUniversalCableRender = true; - public static boolean holidays = true; - public static float baseSoundVolume = 1F; - public static boolean machineEffects = true; - public static boolean oldTransmitterRender = false; - public static boolean replaceSoundsWhenResuming = true; - public static boolean renderCTM = true; + public static boolean enablePlayerSounds = true; + public static boolean enableMachineSounds = true; + public static boolean fancyUniversalCableRender = true; + public static boolean holidays = true; + public static float baseSoundVolume = 1F; + public static boolean machineEffects = true; + public static boolean oldTransmitterRender = false; + public static boolean replaceSoundsWhenResuming = true; + public static boolean renderCTM = true; } - + public static class machines { - private static Map<String, Boolean> config = new HashMap<String, Boolean>(); - + private static Map<String, Boolean> config = new HashMap<String, Boolean>(); + public static boolean isEnabled(String type) { return config.get(type) != null && config.get(type); } - + public static void setEntry(String type, boolean enabled) { config.put(type, enabled); @@ -88,50 +88,50 @@ public class MekanismConfig public static class usage { - public static double enrichmentChamberUsage; - public static double osmiumCompressorUsage; - public static double combinerUsage; - public static double crusherUsage; - public static double factoryUsage; - public static double metallurgicInfuserUsage; - public static double purificationChamberUsage; - public static double energizedSmelterUsage; - public static double digitalMinerUsage; - public static double electricPumpUsage; - public static double rotaryCondensentratorUsage; - public static double oxidationChamberUsage; - public static double chemicalInfuserUsage; - public static double chemicalInjectionChamberUsage; - public static double precisionSawmillUsage; - public static double chemicalDissolutionChamberUsage; - public static double chemicalWasherUsage; - public static double chemicalCrystallizerUsage; - public static double seismicVibratorUsage; - public static double pressurizedReactionBaseUsage; - public static double fluidicPlenisherUsage; - public static double laserUsage; - public static double gasCentrifugeUsage; - public static double heavyWaterElectrolysisUsage; + public static double enrichmentChamberUsage; + public static double osmiumCompressorUsage; + public static double combinerUsage; + public static double crusherUsage; + public static double factoryUsage; + public static double metallurgicInfuserUsage; + public static double purificationChamberUsage; + public static double energizedSmelterUsage; + public static double digitalMinerUsage; + public static double electricPumpUsage; + public static double rotaryCondensentratorUsage; + public static double oxidationChamberUsage; + public static double chemicalInfuserUsage; + public static double chemicalInjectionChamberUsage; + public static double precisionSawmillUsage; + public static double chemicalDissolutionChamberUsage; + public static double chemicalWasherUsage; + public static double chemicalCrystallizerUsage; + public static double seismicVibratorUsage; + public static double pressurizedReactionBaseUsage; + public static double fluidicPlenisherUsage; + public static double laserUsage; + public static double gasCentrifugeUsage; + public static double heavyWaterElectrolysisUsage; } public static class generators { - public static double advancedSolarGeneration; - public static double bioGeneration; - public static double heatGeneration; - public static double heatGenerationLava; - public static double heatGenerationNether; - public static double solarGeneration; + public static double advancedSolarGeneration; + public static double bioGeneration; + public static double heatGeneration; + public static double heatGenerationLava; + public static double heatGenerationNether; + public static double solarGeneration; - public static double windGenerationMin; - public static double windGenerationMax; + public static double windGenerationMin; + public static double windGenerationMax; - public static int windGenerationMinY; - public static int windGenerationMaxY; + public static int windGenerationMinY; + public static int windGenerationMaxY; } public static class tools { - public static double armorSpawnRate; + public static double armorSpawnRate; } } diff --git a/src/api/java/mekanism/api/Pos3D.java b/src/api/java/mekanism/api/Pos3D.java index 75f83a0..03c5892 100644 --- a/src/api/java/mekanism/api/Pos3D.java +++ b/src/api/java/mekanism/api/Pos3D.java @@ -16,22 +16,22 @@ import net.minecraftforge.common.util.ForgeDirection; */ public class Pos3D { - public double xPos; - public double yPos; - public double zPos; + public double xPos; + public double yPos; + public double zPos; public Pos3D() { this(0, 0, 0); } - + public Pos3D(Vec3 vec) { xPos = vec.xCoord; yPos = vec.yCoord; zPos = vec.zCoord; } - + public Pos3D(MovingObjectPosition mop) { xPos = mop.blockX; @@ -45,7 +45,7 @@ public class Pos3D yPos = y; zPos = z; } - + public Pos3D(Coord4D coord) { xPos = coord.xCoord; @@ -70,18 +70,19 @@ public class Pos3D { this(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); } - + /** * Returns a new Pos3D from a tag compound. * @param tag - tag compound to read from * @return the Pos3D from the tag compound */ - public static Pos3D read(NBTTagCompound tag) - { - return new Pos3D(tag.getDouble("x"), tag.getDouble("y"), tag.getDouble("z")); - } - - /** + public static Pos3D read(NBTTagCompound tag) + { + return new Pos3D(tag.getDouble("x"), tag.getDouble("y"), + tag.getDouble("z")); + } + + /** * Writes this Pos3D's data to an NBTTagCompound. * @param nbtTags - tag compound to write to * @return the tag compound with this Pos3D's data @@ -102,7 +103,7 @@ public class Pos3D */ public Pos3D diff(Pos3D pos) { - return new Pos3D(xPos-pos.xPos, yPos-pos.yPos, zPos-pos.zPos); + return new Pos3D(xPos - pos.xPos, yPos - pos.yPos, zPos - pos.zPos); } /** @@ -115,15 +116,15 @@ public class Pos3D return new Pos3D(entity.motionX, entity.motionY, entity.motionZ); } - /** - * Creates a new Coord4D representing this Pos3D in the provided dimension. - * @param dimensionId - the dimension this Pos3D is in - * @return Coord4D representing this Pos3D - */ - public Coord4D getCoord(int dimensionId) - { - return new Coord4D((int)xPos, (int)yPos, (int)zPos, dimensionId); - } + /** + * Creates a new Coord4D representing this Pos3D in the provided dimension. + * @param dimensionId - the dimension this Pos3D is in + * @return Coord4D representing this Pos3D + */ + public Coord4D getCoord(int dimensionId) + { + return new Coord4D((int) xPos, (int) yPos, (int) zPos, dimensionId); + } /** * Centres a block-derived Pos3D @@ -172,9 +173,18 @@ public class Pos3D */ public Pos3D translateExcludingSide(ForgeDirection direction, double amount) { - if(direction.offsetX == 0) xPos += amount; - if(direction.offsetY == 0) yPos += amount; - if(direction.offsetZ == 0) zPos += amount; + if(direction.offsetX == 0) + { + xPos += amount; + } + if(direction.offsetY == 0) + { + yPos += amount; + } + if(direction.offsetZ == 0) + { + zPos += amount; + } return this; } @@ -186,9 +196,9 @@ public class Pos3D */ public double distance(Pos3D pos) { - double subX = xPos - pos.xPos; - double subY = yPos - pos.yPos; - double subZ = zPos - pos.zPos; + final double subX = xPos - pos.xPos; + final double subY = yPos - pos.yPos; + final double subZ = zPos - pos.zPos; return MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); } @@ -199,10 +209,10 @@ public class Pos3D */ public Pos3D rotateYaw(double yaw) { - double yawRadians = Math.toRadians(yaw); + final double yawRadians = Math.toRadians(yaw); - double x = xPos; - double z = zPos; + final double x = xPos; + final double z = zPos; if(yaw != 0) { @@ -212,51 +222,51 @@ public class Pos3D return this; } - + public Pos3D rotatePitch(double pitch) { - double pitchRadians = Math.toRadians(pitch); - - double y = yPos; - double z = zPos; - + final double pitchRadians = Math.toRadians(pitch); + + final double y = yPos; + final double z = zPos; + if(pitch != 0) { yPos = y * Math.cos(pitchRadians) - z * Math.sin(pitchRadians); zPos = z * Math.cos(pitchRadians) + y * Math.sin(pitchRadians); } - + return this; } - + public Pos3D rotate(double yaw, double pitch) { return rotate(yaw, pitch, 0); } - public Pos3D rotate(double yaw, double pitch, double roll) - { - double yawRadians = Math.toRadians(yaw); - double pitchRadians = Math.toRadians(pitch); - double rollRadians = Math.toRadians(roll); + public Pos3D rotate(double yaw, double pitch, double roll) + { + final double yawRadians = Math.toRadians(yaw); + final double pitchRadians = Math.toRadians(pitch); + final double rollRadians = Math.toRadians(roll); + + final double x = xPos; + final double y = yPos; + final double z = zPos; + + xPos = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + z * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math.cos(rollRadians)) + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + Math.sin(yawRadians) * Math.sin(rollRadians)); + zPos = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + z * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math.cos(rollRadians)) + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - Math.cos(yawRadians) * Math.sin(rollRadians)); + yPos = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math.cos(pitchRadians) * Math.cos(rollRadians); - double x = xPos; - double y = yPos; - double z = zPos; + return this; + } - xPos = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + z * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math.cos(rollRadians)) + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + Math.sin(yawRadians) * Math.sin(rollRadians)); - zPos = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + z * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math.cos(rollRadians)) + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - Math.cos(yawRadians) * Math.sin(rollRadians)); - yPos = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math.cos(pitchRadians) * Math.cos(rollRadians); - - return this; - } - public Pos3D multiply(Pos3D pos) { xPos *= pos.xPos; yPos *= pos.yPos; zPos *= pos.zPos; - + return this; } @@ -285,7 +295,7 @@ public class Pos3D { return scale(scale, scale, scale); } - + public Pos3D rotate(float angle, Pos3D axis) { return translateMatrix(getRotationMatrix(angle, axis), this); @@ -293,19 +303,19 @@ public class Pos3D public double[] getRotationMatrix(float angle) { - double[] matrix = new double[16]; - Pos3D axis = clone().normalize(); - - double x = axis.xPos; - double y = axis.yPos; - double z = axis.zPos; - + final double[] matrix = new double[16]; + final Pos3D axis = clone().normalize(); + + final double x = axis.xPos; + final double y = axis.yPos; + final double z = axis.zPos; + angle *= 0.0174532925D; - - float cos = (float)Math.cos(angle); - float ocos = 1.0F - cos; - float sin = (float)Math.sin(angle); - + + final float cos = (float) Math.cos(angle); + final float ocos = 1.0F - cos; + final float sin = (float) Math.sin(angle); + matrix[0] = (x * x * ocos + cos); matrix[1] = (y * x * ocos + z * sin); matrix[2] = (x * z * ocos - y * sin); @@ -316,20 +326,20 @@ public class Pos3D matrix[9] = (y * z * ocos - x * sin); matrix[10] = (z * z * ocos + cos); matrix[15] = 1.0F; - + return matrix; } public static Pos3D translateMatrix(double[] matrix, Pos3D translation) { - double x = translation.xPos * matrix[0] + translation.yPos * matrix[1] + translation.zPos * matrix[2] + matrix[3]; - double y = translation.xPos * matrix[4] + translation.yPos * matrix[5] + translation.zPos * matrix[6] + matrix[7]; - double z = translation.xPos * matrix[8] + translation.yPos * matrix[9] + translation.zPos * matrix[10] + matrix[11]; - + final double x = translation.xPos * matrix[0] + translation.yPos * matrix[1] + translation.zPos * matrix[2] + matrix[3]; + final double y = translation.xPos * matrix[4] + translation.yPos * matrix[5] + translation.zPos * matrix[6] + matrix[7]; + final double z = translation.xPos * matrix[8] + translation.yPos * matrix[9] + translation.zPos * matrix[10] + matrix[11]; + translation.xPos = x; translation.yPos = y; translation.zPos = z; - + return translation; } @@ -337,7 +347,7 @@ public class Pos3D { return axis.getRotationMatrix(angle); } - + public double anglePreNorm(Pos3D pos2) { return Math.acos(dotProduct(pos2)); @@ -347,27 +357,27 @@ public class Pos3D { return Math.acos(pos1.clone().dotProduct(pos2)); } - + public double dotProduct(Pos3D pos) { return xPos * pos.xPos + yPos * pos.yPos + zPos * pos.zPos; } - + public Pos3D crossProduct(Pos3D compare) { return clone().toCrossProduct(compare); } - + public Pos3D toCrossProduct(Pos3D compare) { - double newX = yPos * compare.zPos - zPos * compare.yPos; - double newY = zPos * compare.xPos - xPos * compare.zPos; - double newZ = xPos * compare.yPos - yPos * compare.xPos; - + final double newX = yPos * compare.zPos - zPos * compare.yPos; + final double newY = zPos * compare.xPos - xPos * compare.zPos; + final double newZ = xPos * compare.yPos - yPos * compare.xPos; + xPos = newX; yPos = newY; zPos = newZ; - + return this; } @@ -380,7 +390,7 @@ public class Pos3D { return new Pos3D(-yPos, xPos, 0.0D); } - + public Pos3D getPerpendicular() { if(zPos == 0) @@ -390,39 +400,32 @@ public class Pos3D return xCrossProduct(); } - + public Pos3D floor() { return new Pos3D(Math.floor(xPos), Math.floor(yPos), Math.floor(zPos)); } - public double getMagnitude() - { - return Math.sqrt(xPos * xPos + yPos * yPos + zPos * zPos); - } + public double getMagnitude() + { + return Math.sqrt(xPos * xPos + yPos * yPos + zPos * zPos); + } - public Pos3D normalize() - { - double d = getMagnitude(); + public Pos3D normalize() + { + final double d = getMagnitude(); - if (d != 0) - { - this.scale(1 / d); - } + if(d != 0) + { + this.scale(1 / d); + } - return this; - } + return this; + } public static AxisAlignedBB getAABB(Pos3D pos1, Pos3D pos2) { - return AxisAlignedBB.getBoundingBox( - Math.min(pos1.xPos, pos2.xPos), - Math.min(pos1.yPos, pos2.yPos), - Math.min(pos1.zPos, pos2.zPos), - Math.max(pos1.xPos, pos2.xPos), - Math.max(pos1.yPos, pos2.yPos), - Math.max(pos1.zPos, pos2.zPos) - ); + return AxisAlignedBB.getBoundingBox(Math.min(pos1.xPos, pos2.xPos), Math.min(pos1.yPos, pos2.yPos), Math.min(pos1.zPos, pos2.zPos), Math.max(pos1.xPos, pos2.xPos), Math.max(pos1.yPos, pos2.yPos), Math.max(pos1.zPos, pos2.zPos)); } @Override @@ -440,10 +443,7 @@ public class Pos3D @Override public boolean equals(Object obj) { - return obj instanceof Pos3D && - ((Pos3D)obj).xPos == xPos && - ((Pos3D)obj).yPos == yPos && - ((Pos3D)obj).zPos == zPos; + return obj instanceof Pos3D && ((Pos3D) obj).xPos == xPos && ((Pos3D) obj).yPos == yPos && ((Pos3D) obj).zPos == zPos; } @Override diff --git a/src/api/java/mekanism/api/Range4D.java b/src/api/java/mekanism/api/Range4D.java index 40905a6..7e4f6ae 100644 --- a/src/api/java/mekanism/api/Range4D.java +++ b/src/api/java/mekanism/api/Range4D.java @@ -3,17 +3,17 @@ package mekanism.api; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.FMLCommonHandler; -public class Range4D +public class Range4D { - public int dimensionId; - - public int xMin; - public int yMin; - public int zMin; - public int xMax; - public int yMax; - public int zMax; - + public int dimensionId; + + public int xMin; + public int yMin; + public int zMin; + public int xMax; + public int yMax; + public int zMax; + public Range4D(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dimension) { xMin = minX; @@ -22,57 +22,57 @@ public class Range4D xMax = maxX; yMax = maxY; zMax = maxZ; - + dimensionId = dimension; } - + public Range4D(Chunk3D chunk) { - xMin = chunk.xCoord*16; + xMin = chunk.xCoord * 16; yMin = 0; - zMin = chunk.zCoord*16; - xMax = xMin+16; + zMin = chunk.zCoord * 16; + xMax = xMin + 16; yMax = 255; - zMax = zMin+16; - + zMax = zMin + 16; + dimensionId = chunk.dimensionId; } - + public Range4D(Coord4D coord) { xMin = coord.xCoord; yMin = coord.yCoord; zMin = coord.zCoord; - - xMax = coord.xCoord+1; - yMax = coord.yCoord+1; - zMax = coord.zCoord+1; - + + xMax = coord.xCoord + 1; + yMax = coord.yCoord + 1; + zMax = coord.zCoord + 1; + dimensionId = coord.dimensionId; } - + public static Range4D getChunkRange(EntityPlayer player) { - int radius = FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().getViewDistance(); - + final int radius = FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().getViewDistance(); + return new Range4D(new Chunk3D(player)).expandChunks(radius); } - + public Range4D expandChunks(int chunks) { - xMin -= chunks*16; - xMax += chunks*16; - zMin -= chunks*16; - zMax += chunks*16; - + xMin -= chunks * 16; + xMax += chunks * 16; + zMin -= chunks * 16; + zMax += chunks * 16; + return this; } - + public boolean intersects(Range4D range) { - return (xMax+1 - 1.E-05D > range.xMin) && (range.xMax+1 - 1.E-05D > xMin) && (yMax+1 - 1.E-05D > range.yMin) && (range.yMax+1 - 1.E-05D > yMin) && (zMax+1 - 1.E-05D > range.zMin) && (range.zMax+1 - 1.E-05D > zMin); + return (xMax + 1 - 1.E-05D > range.xMin) && (range.xMax + 1 - 1.E-05D > xMin) && (yMax + 1 - 1.E-05D > range.yMin) && (range.yMax + 1 - 1.E-05D > yMin) && (zMax + 1 - 1.E-05D > range.zMin) && (range.zMax + 1 - 1.E-05D > zMin); } - + @Override public Range4D clone() { @@ -88,14 +88,7 @@ public class Range4D @Override public boolean equals(Object obj) { - return obj instanceof Range4D && - ((Range4D)obj).xMin == xMin && - ((Range4D)obj).yMin == yMin && - ((Range4D)obj).zMin == zMin && - ((Range4D)obj).xMax == xMax && - ((Range4D)obj).yMax == yMax && - ((Range4D)obj).zMax == zMax && - ((Range4D)obj).dimensionId == dimensionId; + return obj instanceof Range4D && ((Range4D) obj).xMin == xMin && ((Range4D) obj).yMin == yMin && ((Range4D) obj).zMin == zMin && ((Range4D) obj).xMax == xMax && ((Range4D) obj).yMax == yMax && ((Range4D) obj).zMax == zMax && ((Range4D) obj).dimensionId == dimensionId; } @Override diff --git a/src/api/java/mekanism/api/TabProxy.java b/src/api/java/mekanism/api/TabProxy.java index c562c02..a96813c 100644 --- a/src/api/java/mekanism/api/TabProxy.java +++ b/src/api/java/mekanism/api/TabProxy.java @@ -10,7 +10,7 @@ import net.minecraft.creativetab.CreativeTabs; public final class TabProxy { /** The 'Mekanism' class where the tab instance is stored. */ - public static Class Mekanism; + public static Class Mekanism; /** * Attempts to get the Mekanism creative tab instance from the 'Mekanism' class. Will return @@ -20,21 +20,24 @@ public final class TabProxy */ public static CreativeTabs tabMekanism(CreativeTabs preferred) { - try { + try + { if(Mekanism == null) { Mekanism = Class.forName("mekanism.common.Mekanism"); } - Object ret = Mekanism.getField("tabMekanism").get(null); + final Object ret = Mekanism.getField("tabMekanism").get(null); if(ret instanceof CreativeTabs) { - return (CreativeTabs)ret; + return (CreativeTabs) ret; } return preferred; - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error retrieving Mekanism creative tab."); return preferred; } diff --git a/src/api/java/mekanism/api/energy/EnergizedItemManager.java b/src/api/java/mekanism/api/energy/EnergizedItemManager.java index 165bdf6..458c480 100644 --- a/src/api/java/mekanism/api/energy/EnergizedItemManager.java +++ b/src/api/java/mekanism/api/energy/EnergizedItemManager.java @@ -16,11 +16,11 @@ public class EnergizedItemManager { if(itemStack.getItem() instanceof IEnergizedItem) { - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); + final IEnergizedItem energizedItem = (IEnergizedItem) itemStack.getItem(); if(energizedItem.canSend(itemStack)) { - double energyToUse = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getEnergy(itemStack), amount)); + final double energyToUse = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getEnergy(itemStack), amount)); energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToUse); return energyToUse; @@ -43,11 +43,11 @@ public class EnergizedItemManager { if(itemStack.getItem() instanceof IEnergizedItem) { - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); + final IEnergizedItem energizedItem = (IEnergizedItem) itemStack.getItem(); if(energizedItem.canReceive(itemStack)) { - double energyToSend = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getMaxEnergy(itemStack) - energizedItem.getEnergy(itemStack), amount)); + final double energyToSend = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getMaxEnergy(itemStack) - energizedItem.getEnergy(itemStack), amount)); energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToSend); return energyToSend; diff --git a/src/api/java/mekanism/api/energy/EnergyStack.java b/src/api/java/mekanism/api/energy/EnergyStack.java index 3f57621..807262d 100644 --- a/src/api/java/mekanism/api/energy/EnergyStack.java +++ b/src/api/java/mekanism/api/energy/EnergyStack.java @@ -5,7 +5,7 @@ package mekanism.api.energy; */ public class EnergyStack { - public double amount; + public double amount; public EnergyStack(double newAmount) { diff --git a/src/api/java/mekanism/api/energy/package-info.java b/src/api/java/mekanism/api/energy/package-info.java index 8f3d371..d16dddf 100644 --- a/src/api/java/mekanism/api/energy/package-info.java +++ b/src/api/java/mekanism/api/energy/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|energy") package mekanism.api.energy; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/gas/Gas.java b/src/api/java/mekanism/api/gas/Gas.java index f05be52..b65353e 100644 --- a/src/api/java/mekanism/api/gas/Gas.java +++ b/src/api/java/mekanism/api/gas/Gas.java @@ -13,17 +13,17 @@ import net.minecraftforge.fluids.FluidRegistry; */ public class Gas { - private String name; + private String name; - private String unlocalizedName; + private String unlocalizedName; - private Fluid fluid; + private Fluid fluid; - private IIcon icon; + private IIcon icon; - private boolean visible = true; + private boolean visible = true; - private boolean from_fluid = false; + private boolean from_fluid = false; /** * Creates a new Gas object with a defined name or key value. @@ -113,9 +113,9 @@ public class Gas { if(from_fluid) { - return this.getFluid().getIcon(); + return getFluid().getIcon(); } - + return icon; } @@ -132,9 +132,9 @@ public class Gas { fluid.setIcons(getIcon()); } - + from_fluid = false; - + return this; } @@ -205,7 +205,8 @@ public class Gas fluid = new Fluid(getName()).setGaseous(true); FluidRegistry.registerFluid(fluid); } - else { + else + { fluid = FluidRegistry.getFluid(getName()); } } diff --git a/src/api/java/mekanism/api/gas/GasNetwork.java b/src/api/java/mekanism/api/gas/GasNetwork.java index ea81d12..05e18be 100644 --- a/src/api/java/mekanism/api/gas/GasNetwork.java +++ b/src/api/java/mekanism/api/gas/GasNetwork.java @@ -1,8 +1,12 @@ package mekanism.api.gas; -import com.google.common.collect.Lists; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.Event; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import mekanism.api.Coord4D; import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.IGridTransmitter; @@ -10,7 +14,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -import java.util.*; +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event; /** * A DynamicNetwork extension created specifically for the transfer of Gasses. By default this is server-only, but if ticked on @@ -20,25 +27,27 @@ import java.util.*; */ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> { - public int transferDelay = 0; + public int transferDelay = 0; - public boolean didTransfer; - public boolean prevTransfer; + public boolean didTransfer; + public boolean prevTransfer; - public float gasScale; + public float gasScale; - public Gas refGas; + public Gas refGas; - public GasStack buffer; - public int prevStored; + public GasStack buffer; + public int prevStored; - public int prevTransferAmount = 0; + public int prevTransferAmount = 0; - public GasNetwork() {} + public GasNetwork() + { + } public GasNetwork(Collection<GasNetwork> networks) { - for(GasNetwork net : networks) + for(final GasNetwork net : networks) { if(net != null) { @@ -54,14 +63,16 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> net.refGas = null; net.buffer = null; } - } else + } + else { if(net.buffer != null) { if(buffer == null) { buffer = net.buffer.copy(); - } else + } + else { if(buffer.isGasEqual(net.buffer)) { @@ -91,19 +102,19 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> @Override public void absorbBuffer(IGridTransmitter<IGasHandler, GasNetwork> transmitter) { - Object b = transmitter.getBuffer(); - - if(!(b instanceof GasStack) || ((GasStack)b).getGas() == null || ((GasStack)b).amount == 0) + final Object b = transmitter.getBuffer(); + + if(!(b instanceof GasStack) || ((GasStack) b).getGas() == null || ((GasStack) b).amount == 0) { return; } - GasStack gas = (GasStack)b; + final GasStack gas = (GasStack) b; if(buffer == null || buffer.getGas() == null || buffer.amount == 0) { buffer = gas.copy(); - gas.amount = 0; + gas.amount = 0; return; } @@ -112,7 +123,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> { buffer.amount += gas.amount; } - + gas.amount = 0; } @@ -127,30 +138,30 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> public int getGasNeeded() { - return getCapacity()-(buffer != null ? buffer.amount : 0); + return getCapacity() - (buffer != null ? buffer.amount : 0); } public int tickEmit(GasStack stack) { - List<IGasHandler> availableAcceptors = Lists.newArrayList(); + final List<IGasHandler> availableAcceptors = Lists.newArrayList(); availableAcceptors.addAll(getAcceptors(stack.getGas())); Collections.shuffle(availableAcceptors); int toSend = stack.amount; - int prevSending = toSend; + final int prevSending = toSend; if(!availableAcceptors.isEmpty()) { - int divider = availableAcceptors.size(); + final int divider = availableAcceptors.size(); int remaining = toSend % divider; - int sending = (toSend-remaining)/divider; + final int sending = (toSend - remaining) / divider; - for(IGasHandler acceptor : availableAcceptors) + for(final IGasHandler acceptor : availableAcceptors) { int currentSending = sending; - EnumSet<ForgeDirection> sides = acceptorDirections.get(Coord4D.get((TileEntity)acceptor)); + final EnumSet<ForgeDirection> sides = acceptorDirections.get(Coord4D.get((TileEntity) acceptor)); if(remaining > 0) { @@ -158,11 +169,12 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> remaining--; } - for(ForgeDirection side : sides) + for(final ForgeDirection side : sides) { - int prev = toSend; + final int prev = toSend; - toSend -= acceptor.receiveGas(side, new GasStack(stack.getGas(), currentSending), true); + toSend -= acceptor.receiveGas(side, new GasStack( + stack.getGas(), currentSending), true); if(toSend < prev) { @@ -172,7 +184,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> } } - int sent = prevSending-toSend; + final int sent = prevSending - toSend; if(sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) { @@ -190,7 +202,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> return 0; } - int toUse = Math.min(getGasNeeded(), stack.amount); + final int toUse = Math.min(getGasNeeded(), stack.amount); if(doTransfer) { @@ -199,7 +211,8 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> buffer = stack.copy(); buffer.amount = toUse; } - else { + else + { buffer.amount += toUse; } } @@ -220,11 +233,12 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> { didTransfer = false; } - else { + else + { transferDelay--; } - int stored = buffer != null ? buffer.amount : 0; + final int stored = buffer != null ? buffer.amount : 0; if(stored != prevStored) { @@ -235,7 +249,8 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> if(didTransfer != prevTransfer || needsUpdate) { - MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, buffer, didTransfer)); + MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, + buffer, didTransfer)); needsUpdate = false; } @@ -263,11 +278,11 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> if(didTransfer && gasScale < 1) { - gasScale = Math.max(getScale(), Math.min(1, gasScale+0.02F)); + gasScale = Math.max(getScale(), Math.min(1, gasScale + 0.02F)); } else if(!didTransfer && gasScale > 0) { - gasScale = Math.max(getScale(), Math.max(0, gasScale-0.02F)); + gasScale = Math.max(getScale(), Math.max(0, gasScale - 0.02F)); if(gasScale == 0) { @@ -279,27 +294,27 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> @Override public Set<IGasHandler> getAcceptors(Object data) { - Gas type = (Gas)data; - Set<IGasHandler> toReturn = new HashSet<IGasHandler>(); - + final Gas type = (Gas) data; + final Set<IGasHandler> toReturn = new HashSet<IGasHandler>(); + if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { return toReturn; } - for(Coord4D coord : possibleAcceptors.keySet()) + for(final Coord4D coord : possibleAcceptors.keySet()) { - EnumSet<ForgeDirection> sides = acceptorDirections.get(coord); - TileEntity tile = coord.getTileEntity(getWorld()); - + final EnumSet<ForgeDirection> sides = acceptorDirections.get(coord); + final TileEntity tile = coord.getTileEntity(getWorld()); + if(!(tile instanceof IGasHandler) || sides == null || sides.isEmpty()) { continue; } - - IGasHandler acceptor = (IGasHandler)tile; - for(ForgeDirection side : sides) + final IGasHandler acceptor = (IGasHandler) tile; + + for(final ForgeDirection side : sides) { if(acceptor != null && acceptor.canReceiveGas(side, type)) { @@ -314,10 +329,10 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> public static class GasTransferEvent extends Event { - public final GasNetwork gasNetwork; + public final GasNetwork gasNetwork; - public final GasStack transferType; - public final boolean didTransfer; + public final GasStack transferType; + public final boolean didTransfer; public GasTransferEvent(GasNetwork network, GasStack type, boolean did) { @@ -329,7 +344,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> public float getScale() { - return Math.min(1, (buffer == null || getCapacity() == 0 ? 0 : (float)buffer.amount/getCapacity())); + return Math.min(1, (buffer == null || getCapacity() == 0 ? 0 : (float) buffer.amount / getCapacity())); } @Override diff --git a/src/api/java/mekanism/api/gas/GasRegistry.java b/src/api/java/mekanism/api/gas/GasRegistry.java index 25db966..37a6363 100644 --- a/src/api/java/mekanism/api/gas/GasRegistry.java +++ b/src/api/java/mekanism/api/gas/GasRegistry.java @@ -7,7 +7,7 @@ import net.minecraftforge.fluids.Fluid; public class GasRegistry { - private static ArrayList<Gas> registeredGasses = new ArrayList<Gas>(); + private static ArrayList<Gas> registeredGasses = new ArrayList<Gas>(); /** * Register a new gas into GasRegistry. @@ -48,7 +48,7 @@ public class GasRegistry */ public static Gas getGas(Fluid f) { - for(Gas gas : getRegisteredGasses()) + for(final Gas gas : getRegisteredGasses()) { if(gas.hasFluid() && gas.getFluid() == f) { @@ -75,7 +75,7 @@ public class GasRegistry */ public static List<Gas> getRegisteredGasses() { - return (List<Gas>)registeredGasses.clone(); + return (List<Gas>) registeredGasses.clone(); } /** @@ -85,7 +85,7 @@ public class GasRegistry */ public static Gas getGas(String name) { - for(Gas gas : registeredGasses) + for(final Gas gas : registeredGasses) { if(gas.getName().toLowerCase().equals(name.toLowerCase())) { diff --git a/src/api/java/mekanism/api/gas/GasStack.java b/src/api/java/mekanism/api/gas/GasStack.java index 05e5ae6..6d04a53 100644 --- a/src/api/java/mekanism/api/gas/GasStack.java +++ b/src/api/java/mekanism/api/gas/GasStack.java @@ -9,9 +9,9 @@ import net.minecraft.nbt.NBTTagCompound; */ public class GasStack { - private Gas type; + private Gas type; - public int amount; + public int amount; /** * Creates a new GasStack with a defined gas ID and quantity. @@ -35,7 +35,9 @@ public class GasStack amount = quantity; } - private GasStack() {} + private GasStack() + { + } /** * Gets the Gas type of this GasStack. @@ -45,11 +47,11 @@ public class GasStack { return type; } - + public GasStack withAmount(int newAmount) { amount = newAmount; - + return this; } @@ -88,7 +90,7 @@ public class GasStack return null; } - GasStack stack = new GasStack(); + final GasStack stack = new GasStack(); stack.read(nbtTags); if(stack.getGas() == null || stack.amount <= 0) diff --git a/src/api/java/mekanism/api/gas/GasTank.java b/src/api/java/mekanism/api/gas/GasTank.java index a5d4c20..69b7a3c 100644 --- a/src/api/java/mekanism/api/gas/GasTank.java +++ b/src/api/java/mekanism/api/gas/GasTank.java @@ -9,11 +9,13 @@ import net.minecraft.nbt.NBTTagCompound; */ public class GasTank { - public GasStack stored; + public GasStack stored; - private int maxGas; + private int maxGas; - private GasTank() {} + private GasTank() + { + } /** * Creates a tank with a defined capacity. @@ -51,7 +53,8 @@ public class GasTank return null; } - GasStack ret = new GasStack(getGas().getGas(), Math.min(getStored(), amount)); + final GasStack ret = new GasStack(getGas().getGas(), + Math.min(getStored(), amount)); if(ret.amount > 0) { @@ -84,16 +87,17 @@ public class GasTank return 0; } - int toFill = Math.min(getMaxGas()-getStored(), amount.amount); + final int toFill = Math.min(getMaxGas() - getStored(), amount.amount); if(doReceive) { if(stored == null) { - stored = amount.copy().withAmount(getStored()+toFill); + stored = amount.copy().withAmount(getStored() + toFill); } - else { - stored.amount = Math.min(getMaxGas(), getStored()+amount.amount); + else + { + stored.amount = Math.min(getMaxGas(), getStored() + amount.amount); } } @@ -151,7 +155,7 @@ public class GasTank */ public int getNeeded() { - return getMaxGas()-getStored(); + return getMaxGas() - getStored(); } /** @@ -179,7 +183,7 @@ public class GasTank { return stored; } - + /** * Gets the type of gas currently stored in this GasTank. * @return gas type contained @@ -244,7 +248,7 @@ public class GasTank return null; } - GasTank tank = new GasTank(); + final GasTank tank = new GasTank(); tank.read(nbtTags); return tank; diff --git a/src/api/java/mekanism/api/gas/GasTransmission.java b/src/api/java/mekanism/api/gas/GasTransmission.java index c043eb8..a714af0 100644 --- a/src/api/java/mekanism/api/gas/GasTransmission.java +++ b/src/api/java/mekanism/api/gas/GasTransmission.java @@ -8,7 +8,6 @@ import java.util.List; import mekanism.api.Coord4D; import mekanism.api.transmitters.ITransmitterTile; import mekanism.api.transmitters.TransmissionType; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -27,15 +26,15 @@ public final class GasTransmission */ public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity) { - IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null}; + final IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null}; - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + for(final ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { - TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); + final TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); if(acceptor instanceof IGasHandler) { - acceptors[orientation.ordinal()] = (IGasHandler)acceptor; + acceptors[orientation.ordinal()] = (IGasHandler) acceptor; } } @@ -49,15 +48,15 @@ public final class GasTransmission */ public static ITubeConnection[] getConnections(TileEntity tileEntity) { - ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; + final ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + for(final ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { - TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); + final TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); if(canConnect(connection, orientation)) { - connections[orientation.ordinal()] = (ITubeConnection)connection; + connections[orientation.ordinal()] = (ITubeConnection) connection; } } @@ -72,9 +71,9 @@ public final class GasTransmission */ public static boolean canConnect(TileEntity tileEntity, ForgeDirection side) { - if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof ITransmitterTile) || TransmissionType.checkTransmissionType(((ITransmitterTile)tileEntity).getTransmitter(), TransmissionType.GAS))) + if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof ITransmitterTile) || TransmissionType.checkTransmissionType(((ITransmitterTile) tileEntity).getTransmitter(), TransmissionType.GAS))) { - if(((ITubeConnection)tileEntity).canTubeConnect(side.getOpposite())) + if(((ITubeConnection) tileEntity).canTubeConnect(side.getOpposite())) { return true; } @@ -94,7 +93,7 @@ public final class GasTransmission { if(itemStack != null && itemStack.getItem() instanceof IGasItem) { - IGasItem item = (IGasItem)itemStack.getItem(); + final IGasItem item = (IGasItem) itemStack.getItem(); if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type)) { @@ -115,14 +114,14 @@ public final class GasTransmission */ public static int addGas(ItemStack itemStack, GasStack stack) { - if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas())) + if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem) itemStack.getItem()).canReceiveGas(itemStack, stack.getGas())) { - return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy()); + return ((IGasItem) itemStack.getItem()).addGas(itemStack, stack.copy()); } return 0; } - + /** * Emits gas from a central block by splitting the received stack among the sides given. * @param sides - the list of sides to output from @@ -136,14 +135,14 @@ public final class GasTransmission { return 0; } - - List<IGasHandler> availableAcceptors = new ArrayList<IGasHandler>(); - IGasHandler[] possibleAcceptors = getConnectedAcceptors(from); - + + final List<IGasHandler> availableAcceptors = new ArrayList<IGasHandler>(); + final IGasHandler[] possibleAcceptors = getConnectedAcceptors(from); + for(int i = 0; i < possibleAcceptors.length; i++) { - IGasHandler handler = possibleAcceptors[i]; - + final IGasHandler handler = possibleAcceptors[i]; + if(handler != null && handler.canReceiveGas(ForgeDirection.getOrientation(i).getOpposite(), stack.getGas())) { availableAcceptors.add(handler); @@ -153,15 +152,15 @@ public final class GasTransmission Collections.shuffle(availableAcceptors); int toSend = stack.amount; - int prevSending = toSend; + final int prevSending = toSend; if(!availableAcceptors.isEmpty()) { - int divider = availableAcceptors.size(); + final int divider = availableAcceptors.size(); int remaining = toSend % divider; - int sending = (toSend-remaining)/divider; + final int sending = (toSend - remaining) / divider; - for(IGasHandler acceptor : availableAcceptors) + for(final IGasHandler acceptor : availableAcceptors) { int currentSending = sending; @@ -170,12 +169,13 @@ public final class GasTransmission currentSending++; remaining--; } - - ForgeDirection dir = ForgeDirection.getOrientation(Arrays.asList(possibleAcceptors).indexOf(acceptor)).getOpposite(); - toSend -= acceptor.receiveGas(dir, new GasStack(stack.getGas(), currentSending), true); + + final ForgeDirection dir = ForgeDirection.getOrientation(Arrays.asList(possibleAcceptors).indexOf(acceptor)).getOpposite(); + toSend -= acceptor.receiveGas(dir, new GasStack(stack.getGas(), + currentSending), true); } } - return prevSending-toSend; + return prevSending - toSend; } } diff --git a/src/api/java/mekanism/api/gas/IGasItem.java b/src/api/java/mekanism/api/gas/IGasItem.java index 9c7d332..f95baa3 100644 --- a/src/api/java/mekanism/api/gas/IGasItem.java +++ b/src/api/java/mekanism/api/gas/IGasItem.java @@ -72,7 +72,7 @@ public interface IGasItem * @return maximum gas */ public int getMaxGas(ItemStack itemstack); - + /** * Returns whether or not this item contains metadata-specific subtypes instead of using metadata for damage display. * @return if the item contains metadata-specific subtypes diff --git a/src/api/java/mekanism/api/gas/IGasTransmitter.java b/src/api/java/mekanism/api/gas/IGasTransmitter.java index 57ec4c1..2785ac1 100644 --- a/src/api/java/mekanism/api/gas/IGasTransmitter.java +++ b/src/api/java/mekanism/api/gas/IGasTransmitter.java @@ -1,7 +1,6 @@ package mekanism.api.gas; import mekanism.api.transmitters.IGridTransmitter; - import net.minecraft.tileentity.TileEntity; public interface IGasTransmitter extends IGridTransmitter<IGasHandler, GasNetwork> diff --git a/src/api/java/mekanism/api/gas/OreGas.java b/src/api/java/mekanism/api/gas/OreGas.java index 316169c..c9d7ad8 100644 --- a/src/api/java/mekanism/api/gas/OreGas.java +++ b/src/api/java/mekanism/api/gas/OreGas.java @@ -4,8 +4,8 @@ import net.minecraft.util.StatCollector; public class OreGas extends Gas { - private String oreName; - private OreGas cleanGas; + private final String oreName; + private OreGas cleanGas; public OreGas(String s, String name) { diff --git a/src/api/java/mekanism/api/gas/package-info.java b/src/api/java/mekanism/api/gas/package-info.java index 4418451..2a6464c 100644 --- a/src/api/java/mekanism/api/gas/package-info.java +++ b/src/api/java/mekanism/api/gas/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|gas") package mekanism.api.gas; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/infuse/InfuseObject.java b/src/api/java/mekanism/api/infuse/InfuseObject.java index a86c02f..de9005e 100644 --- a/src/api/java/mekanism/api/infuse/InfuseObject.java +++ b/src/api/java/mekanism/api/infuse/InfuseObject.java @@ -8,10 +8,10 @@ package mekanism.api.infuse; public class InfuseObject { /** The type of infuse this item stores */ - public InfuseType type; + public InfuseType type; /** How much infuse this item stores */ - public int stored; + public int stored; public InfuseObject(InfuseType infusion, int i) { diff --git a/src/api/java/mekanism/api/infuse/InfuseRegistry.java b/src/api/java/mekanism/api/infuse/InfuseRegistry.java index 308b9c5..6916878 100644 --- a/src/api/java/mekanism/api/infuse/InfuseRegistry.java +++ b/src/api/java/mekanism/api/infuse/InfuseRegistry.java @@ -13,10 +13,10 @@ import net.minecraft.item.ItemStack; public class InfuseRegistry { /** The (private) map of ItemStacks and their related InfuseObjects. */ - private static Map<ItemStack, InfuseObject> infuseObjects = new HashMap<ItemStack, InfuseObject>(); + private static Map<ItemStack, InfuseObject> infuseObjects = new HashMap<ItemStack, InfuseObject>(); /** The (private) map of infuse names and their corresponding InfuseTypes. */ - private static Map<String, InfuseType> infuseTypes = new HashMap<String, InfuseType>(); + private static Map<String, InfuseType> infuseTypes = new HashMap<String, InfuseType>(); /** * Registers an InfuseType into the registry. Call this in PreInit! @@ -82,7 +82,7 @@ public class InfuseRegistry */ public static InfuseObject getObject(ItemStack itemStack) { - for(Map.Entry<ItemStack, InfuseObject> obj : infuseObjects.entrySet()) + for(final Map.Entry<ItemStack, InfuseObject> obj : infuseObjects.entrySet()) { if(itemStack.isItemEqual(obj.getKey())) { diff --git a/src/api/java/mekanism/api/infuse/InfuseType.java b/src/api/java/mekanism/api/infuse/InfuseType.java index 1f5215c..76820a8 100644 --- a/src/api/java/mekanism/api/infuse/InfuseType.java +++ b/src/api/java/mekanism/api/infuse/InfuseType.java @@ -11,19 +11,19 @@ import net.minecraft.util.StatCollector; public final class InfuseType { /** The name of this infusion */ - public String name; + public String name; /** The location of this infuse's GUI texture */ - public ResourceLocation texture; + public ResourceLocation texture; /** The infuse's GUI texture X offset. */ - public int texX; + public int texX; /** The infuse's GUI texture Y offset. */ - public int texY; + public int texY; /** The unlocalized name of this type. */ - public String unlocalizedName; + public String unlocalizedName; public InfuseType(String s, ResourceLocation location, int x, int y) { diff --git a/src/api/java/mekanism/api/infuse/package-info.java b/src/api/java/mekanism/api/infuse/package-info.java index 8718996..a826ca2 100644 --- a/src/api/java/mekanism/api/infuse/package-info.java +++ b/src/api/java/mekanism/api/infuse/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|infuse") package mekanism.api.infuse; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/lasers/package-info.java b/src/api/java/mekanism/api/lasers/package-info.java index b456937..957b64f 100644 --- a/src/api/java/mekanism/api/lasers/package-info.java +++ b/src/api/java/mekanism/api/lasers/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|laser") package mekanism.api.lasers; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/package-info.java b/src/api/java/mekanism/api/package-info.java index 2b9fcab..f515694 100644 --- a/src/api/java/mekanism/api/package-info.java +++ b/src/api/java/mekanism/api/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|core") package mekanism.api; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/reactor/IFusionReactor.java b/src/api/java/mekanism/api/reactor/IFusionReactor.java index 9d9d96d..33d474c 100644 --- a/src/api/java/mekanism/api/reactor/IFusionReactor.java +++ b/src/api/java/mekanism/api/reactor/IFusionReactor.java @@ -2,7 +2,6 @@ package mekanism.api.reactor; import mekanism.api.IHeatTransfer; import mekanism.api.gas.GasTank; - import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidTank; @@ -61,6 +60,6 @@ public interface IFusionReactor extends IHeatTransfer public int getSteamPerTick(boolean current); public void updateTemperatures(); - + public ItemStack[] getInventory(); } diff --git a/src/api/java/mekanism/api/reactor/IReactorBlock.java b/src/api/java/mekanism/api/reactor/IReactorBlock.java index b3b8518..96d161b 100644 --- a/src/api/java/mekanism/api/reactor/IReactorBlock.java +++ b/src/api/java/mekanism/api/reactor/IReactorBlock.java @@ -1,6 +1,5 @@ package mekanism.api.reactor; - public interface IReactorBlock { public boolean isFrame(); diff --git a/src/api/java/mekanism/api/reactor/package-info.java b/src/api/java/mekanism/api/reactor/package-info.java index 6a00fc6..6f11811 100644 --- a/src/api/java/mekanism/api/reactor/package-info.java +++ b/src/api/java/mekanism/api/reactor/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|reactor") package mekanism.api.reactor; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/recipe/RecipeHelper.java b/src/api/java/mekanism/api/recipe/RecipeHelper.java index 1040aa2..8884d44 100644 --- a/src/api/java/mekanism/api/recipe/RecipeHelper.java +++ b/src/api/java/mekanism/api/recipe/RecipeHelper.java @@ -4,7 +4,6 @@ import java.lang.reflect.Method; import mekanism.api.gas.GasStack; import mekanism.api.infuse.InfuseType; - import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -24,11 +23,14 @@ public final class RecipeHelper */ public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addEnrichmentChamberRecipe", ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addEnrichmentChamberRecipe", ItemStack.class, ItemStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -40,11 +42,14 @@ public final class RecipeHelper */ public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addOsmiumCompressorRecipe", ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addOsmiumCompressorRecipe", ItemStack.class, ItemStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -56,11 +61,14 @@ public final class RecipeHelper */ public static void addCombinerRecipe(ItemStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addCombinerRecipe", ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addCombinerRecipe", ItemStack.class, ItemStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -72,11 +80,14 @@ public final class RecipeHelper */ public static void addCrusherRecipe(ItemStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addCrusherRecipe", ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addCrusherRecipe", ItemStack.class, ItemStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -88,11 +99,14 @@ public final class RecipeHelper */ public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPurificationChamberRecipe", ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addPurificationChamberRecipe", ItemStack.class, ItemStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -104,11 +118,14 @@ public final class RecipeHelper */ public static void addChemicalOxidizerRecipe(ItemStack input, GasStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalOxidizerRecipe", ItemStack.class, GasStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addChemicalOxidizerRecipe", ItemStack.class, GasStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -121,11 +138,14 @@ public final class RecipeHelper */ public static void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInfuserRecipe", GasStack.class, GasStack.class, GasStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addChemicalInfuserRecipe", GasStack.class, GasStack.class, GasStack.class); m.invoke(null, leftInput, rightInput, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -139,11 +159,14 @@ public final class RecipeHelper */ public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class, ItemStack.class, Double.TYPE); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class, ItemStack.class, Double.TYPE); m.invoke(null, input, primaryOutput, secondaryOutput, chance); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -155,11 +178,14 @@ public final class RecipeHelper */ public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class); m.invoke(null, input, primaryOutput); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -171,11 +197,14 @@ public final class RecipeHelper */ public static void addChemicalInjectionChamberRecipe(ItemStack input, String gasName, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInjectionChamberRecipe", ItemStack.class, String.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addChemicalInjectionChamberRecipe", ItemStack.class, String.class, ItemStack.class); m.invoke(null, input, gasName, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -189,11 +218,14 @@ public final class RecipeHelper */ public static void addElectrolyticSeparatorRecipe(FluidStack input, double energy, GasStack leftOutput, GasStack rightOutput) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addElectrolyticSeparatorRecipe", FluidStack.class, Double.TYPE, GasStack.class, GasStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addElectrolyticSeparatorRecipe", FluidStack.class, Double.TYPE, GasStack.class, GasStack.class); m.invoke(null, input, energy, leftOutput, rightOutput); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -205,11 +237,14 @@ public final class RecipeHelper */ public static void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalDissolutionChamberRecipe", ItemStack.class, GasStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addChemicalDissolutionChamberRecipe", ItemStack.class, GasStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -221,11 +256,14 @@ public final class RecipeHelper */ public static void addChemicalWasherRecipe(GasStack input, GasStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalWasherRecipe", GasStack.class, GasStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addChemicalWasherRecipe", GasStack.class, GasStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -237,11 +275,14 @@ public final class RecipeHelper */ public static void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalCrystallizerRecipe", GasStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addChemicalCrystallizerRecipe", GasStack.class, ItemStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -255,11 +296,14 @@ public final class RecipeHelper */ public static void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfuseType.class, Integer.TYPE, ItemStack.class, ItemStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfuseType.class, Integer.TYPE, ItemStack.class, ItemStack.class); m.invoke(null, infuse, amount, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } @@ -276,15 +320,18 @@ public final class RecipeHelper */ public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPRCRecipe", ItemStack.class, FluidStack.class, GasStack.class, ItemStack.class, GasStack.class, Double.TYPE, Integer.TYPE); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addPRCRecipe", ItemStack.class, FluidStack.class, GasStack.class, ItemStack.class, GasStack.class, Double.TYPE, Integer.TYPE); m.invoke(null, inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Solar Evaporation Plant recipe. * @param input - input GasStack @@ -292,15 +339,18 @@ public final class RecipeHelper */ public static void addSolarEvaporationRecipe(FluidStack input, FluidStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addSolarEvaporationRecipe", FluidStack.class, FluidStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addSolarEvaporationRecipe", FluidStack.class, FluidStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Solar Neutron Activator recipe. * @param input - input GasStack @@ -308,11 +358,14 @@ public final class RecipeHelper */ public static void addSolarNeutronRecipe(GasStack input, GasStack output) { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addSolarEvaporationRecipe", GasStack.class, GasStack.class); + try + { + final Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + final Method m = recipeClass.getMethod("addSolarEvaporationRecipe", GasStack.class, GasStack.class); m.invoke(null, input, output); - } catch(Exception e) { + } + catch(final Exception e) + { System.err.println("Error while adding recipe: " + e.getMessage()); } } diff --git a/src/api/java/mekanism/api/recipe/package-info.java b/src/api/java/mekanism/api/recipe/package-info.java index f166da4..060e5ab 100644 --- a/src/api/java/mekanism/api/recipe/package-info.java +++ b/src/api/java/mekanism/api/recipe/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|recipe") package mekanism.api.recipe; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/transmitters/DynamicNetwork.java b/src/api/java/mekanism/api/transmitters/DynamicNetwork.java index ee4e8a2..39932c7 100644 --- a/src/api/java/mekanism/api/transmitters/DynamicNetwork.java +++ b/src/api/java/mekanism/api/transmitters/DynamicNetwork.java @@ -1,10 +1,13 @@ package mekanism.api.transmitters; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.Event; +import java.util.Collection; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Map.Entry; +import java.util.Set; + import mekanism.api.Coord4D; import mekanism.api.IClientTicker; import mekanism.api.Range4D; @@ -14,31 +17,35 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -import java.util.*; -import java.util.Map.Entry; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event; public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implements IClientTicker, INetworkDataHandler { - public LinkedHashSet<IGridTransmitter<A, N>> transmitters = Sets.newLinkedHashSet(); - public LinkedHashSet<IGridTransmitter<A, N>> transmittersToAdd = Sets.newLinkedHashSet(); - public LinkedHashSet<IGridTransmitter<A, N>> transmittersAdded = Sets.newLinkedHashSet(); + public LinkedHashSet<IGridTransmitter<A, N>> transmitters = Sets.newLinkedHashSet(); + public LinkedHashSet<IGridTransmitter<A, N>> transmittersToAdd = Sets.newLinkedHashSet(); + public LinkedHashSet<IGridTransmitter<A, N>> transmittersAdded = Sets.newLinkedHashSet(); - public HashMap<Coord4D, A> possibleAcceptors = new HashMap<Coord4D, A>(); - public HashMap<Coord4D, EnumSet<ForgeDirection>> acceptorDirections = new HashMap<Coord4D, EnumSet<ForgeDirection>>(); - public HashMap<IGridTransmitter<A, N>, EnumSet<ForgeDirection>> changedAcceptors = Maps.newHashMap(); + public HashMap<Coord4D, A> possibleAcceptors = new HashMap<Coord4D, A>(); + public HashMap<Coord4D, EnumSet<ForgeDirection>> acceptorDirections = new HashMap<Coord4D, EnumSet<ForgeDirection>>(); + public HashMap<IGridTransmitter<A, N>, EnumSet<ForgeDirection>> changedAcceptors = Maps.newHashMap(); - private Set<DelayQueue> updateQueue = new LinkedHashSet<DelayQueue>(); + private final Set<DelayQueue> updateQueue = new LinkedHashSet<DelayQueue>(); - protected Range4D packetRange = null; + protected Range4D packetRange = null; - protected int capacity = 0; - protected double meanCapacity = 0; + protected int capacity = 0; + protected double meanCapacity = 0; - protected boolean needsUpdate = false; - protected int updateDelay = 0; + protected boolean needsUpdate = false; + protected int updateDelay = 0; - protected boolean firstUpdate = true; - protected World worldObj = null; + protected boolean firstUpdate = true; + protected World worldObj = null; public void addNewTransmitters(Collection<IGridTransmitter<A, N>> newTransmitters) { @@ -49,7 +56,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen { if(!transmittersToAdd.isEmpty()) { - for(IGridTransmitter<A, N> transmitter : transmittersToAdd) + for(final IGridTransmitter<A, N> transmitter : transmittersToAdd) { if(transmitter.isValid()) { @@ -58,17 +65,17 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen worldObj = transmitter.world(); } - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + for(final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { updateTransmitterOnSide(transmitter, side); } - - transmitter.setTransmitterNetwork((N)this); + + transmitter.setTransmitterNetwork((N) this); absorbBuffer(transmitter); transmitters.add(transmitter); } } - + updateCapacity(); clampBuffer(); queueClientUpdate(Lists.newArrayList(transmittersToAdd)); @@ -77,30 +84,30 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen if(!changedAcceptors.isEmpty()) { - for(Entry<IGridTransmitter<A, N>, EnumSet<ForgeDirection>> entry : changedAcceptors.entrySet()) + for(final Entry<IGridTransmitter<A, N>, EnumSet<ForgeDirection>> entry : changedAcceptors.entrySet()) { - IGridTransmitter<A, N> transmitter = entry.getKey(); - + final IGridTransmitter<A, N> transmitter = entry.getKey(); + if(transmitter.isValid()) { - EnumSet<ForgeDirection> directionsChanged = entry.getValue(); + final EnumSet<ForgeDirection> directionsChanged = entry.getValue(); - for(ForgeDirection side : directionsChanged) + for(final ForgeDirection side : directionsChanged) { updateTransmitterOnSide(transmitter, side); } } } - + changedAcceptors.clear(); } } public void updateTransmitterOnSide(IGridTransmitter<A, N> transmitter, ForgeDirection side) { - A acceptor = transmitter.getAcceptor(side); - Coord4D acceptorCoord = transmitter.coord().getFromSide(side); - EnumSet<ForgeDirection> directions = acceptorDirections.get(acceptorCoord); + final A acceptor = transmitter.getAcceptor(side); + final Coord4D acceptorCoord = transmitter.coord().getFromSide(side); + final EnumSet<ForgeDirection> directions = acceptorDirections.get(acceptorCoord); if(acceptor != null) { @@ -110,11 +117,13 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen { directions.add(side.getOpposite()); } - else { + else + { acceptorDirections.put(acceptorCoord, EnumSet.of(side.getOpposite())); } } - else { + else + { if(directions != null) { directions.remove(side.getOpposite()); @@ -125,7 +134,8 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen acceptorDirections.remove(acceptorCoord); } } - else { + else + { possibleAcceptors.remove(acceptorCoord); acceptorDirections.remove(acceptorCoord); } @@ -139,33 +149,33 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen public void invalidate() { - //Remove invalid transmitters first for share calculations - for(Iterator<IGridTransmitter<A, N>> iter = transmitters.iterator(); iter.hasNext();) - { - IGridTransmitter<A, N> transmitter = iter.next(); - - if(!transmitter.isValid()) - { - iter.remove(); - continue; - } - } - - //Clamp the new buffer - clampBuffer(); - - //Update all shares - for(IGridTransmitter<A, N> transmitter : transmitters) - { - transmitter.updateShare(); - } - - //Now invalidate the transmitters - for(IGridTransmitter<A, N> transmitter : transmitters) + //Remove invalid transmitters first for share calculations + for(final Iterator<IGridTransmitter<A, N>> iter = transmitters.iterator(); iter.hasNext();) + { + final IGridTransmitter<A, N> transmitter = iter.next(); + + if(!transmitter.isValid()) + { + iter.remove(); + continue; + } + } + + //Clamp the new buffer + clampBuffer(); + + //Update all shares + for(final IGridTransmitter<A, N> transmitter : transmitters) + { + transmitter.updateShare(); + } + + //Now invalidate the transmitters + for(final IGridTransmitter<A, N> transmitter : transmitters) { invalidateTransmitter(transmitter); } - + transmitters.clear(); deregister(); } @@ -182,39 +192,41 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen public void acceptorChanged(IGridTransmitter<A, N> transmitter, ForgeDirection side) { - EnumSet<ForgeDirection> directions = changedAcceptors.get(transmitter); - + final EnumSet<ForgeDirection> directions = changedAcceptors.get(transmitter); + if(directions != null) { directions.add(side); - } - else { + } + else + { changedAcceptors.put(transmitter, EnumSet.of(side)); } - + TransmitterNetworkRegistry.registerChangedNetwork(this); } public void adoptTransmittersAndAcceptorsFrom(N net) { - for(IGridTransmitter<A, N> transmitter : net.transmitters) + for(final IGridTransmitter<A, N> transmitter : net.transmitters) { - transmitter.setTransmitterNetwork((N)this); + transmitter.setTransmitterNetwork((N) this); transmitters.add(transmitter); transmittersAdded.add(transmitter); } - + possibleAcceptors.putAll(net.possibleAcceptors); - - for(Entry<Coord4D, EnumSet<ForgeDirection>> entry : net.acceptorDirections.entrySet()) + + for(final Entry<Coord4D, EnumSet<ForgeDirection>> entry : net.acceptorDirections.entrySet()) { - Coord4D coord = entry.getKey(); - + final Coord4D coord = entry.getKey(); + if(acceptorDirections.containsKey(coord)) { acceptorDirections.get(coord).addAll(entry.getValue()); } - else { + else + { acceptorDirections.put(coord, entry.getValue()); } } @@ -227,10 +239,10 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen { return genPacketRange(); } - + return packetRange; } - + protected Range4D genPacketRange() { if(getSize() == 0) @@ -239,29 +251,48 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen return null; } - IGridTransmitter<A, N> initTransmitter = transmitters.iterator().next(); - Coord4D initCoord = initTransmitter.coord(); - + final IGridTransmitter<A, N> initTransmitter = transmitters.iterator().next(); + final Coord4D initCoord = initTransmitter.coord(); + int minX = initCoord.xCoord; int minY = initCoord.yCoord; int minZ = initCoord.zCoord; int maxX = initCoord.xCoord; int maxY = initCoord.yCoord; int maxZ = initCoord.zCoord; - - for(IGridTransmitter transmitter : transmitters) + + for(final IGridTransmitter transmitter : transmitters) { - Coord4D coord = transmitter.coord(); - - if(coord.xCoord < minX) minX = coord.xCoord; - if(coord.yCoord < minY) minY = coord.yCoord; - if(coord.zCoord < minZ) minZ = coord.zCoord; - if(coord.xCoord > maxX) maxX = coord.xCoord; - if(coord.yCoord > maxY) maxY = coord.yCoord; - if(coord.zCoord > maxZ) maxZ = coord.zCoord; + final Coord4D coord = transmitter.coord(); + + if(coord.xCoord < minX) + { + minX = coord.xCoord; + } + if(coord.yCoord < minY) + { + minY = coord.yCoord; + } + if(coord.zCoord < minZ) + { + minZ = coord.zCoord; + } + if(coord.xCoord > maxX) + { + maxX = coord.xCoord; + } + if(coord.yCoord > maxY) + { + maxY = coord.yCoord; + } + if(coord.zCoord > maxZ) + { + maxZ = coord.zCoord; + } } - - return new Range4D(minX, minY, minZ, maxX, maxY, maxZ, initTransmitter.world().provider.dimensionId); + + return new Range4D(minX, minY, minZ, maxX, maxY, maxZ, + initTransmitter.world().provider.dimensionId); } public void register() @@ -270,8 +301,9 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen { TransmitterNetworkRegistry.getInstance().registerNetwork(this); } - else { - MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)1)); + else + { + MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte) 1)); } } @@ -283,8 +315,9 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen { TransmitterNetworkRegistry.getInstance().removeNetwork(this); } - else { - MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)0)); + else + { + MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte) 0)); } } @@ -298,31 +331,32 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen return possibleAcceptors.size(); } - public synchronized void updateCapacity() + public synchronized void updateCapacity() { updateMeanCapacity(); - capacity = (int)meanCapacity * transmitters.size(); + capacity = (int) meanCapacity * transmitters.size(); } - /** - * Override this if things can have variable capacity along the network. - * @return An 'average' value of capacity. Calculate it how you will. - */ - protected synchronized void updateMeanCapacity() + /** + * Override this if things can have variable capacity along the network. + * @return An 'average' value of capacity. Calculate it how you will. + */ + protected synchronized void updateMeanCapacity() { - if(transmitters.size() > 0) + if(transmitters.size() > 0) { meanCapacity = transmitters.iterator().next().getCapacity(); - } - else { + } + else + { meanCapacity = 0; } } - - public int getCapacity() - { - return capacity; - } + + public int getCapacity() + { + return capacity; + } public World getWorld() { @@ -340,24 +374,29 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen { if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { - Iterator<DelayQueue> i = updateQueue.iterator(); + final Iterator<DelayQueue> i = updateQueue.iterator(); - try { + try + { while(i.hasNext()) { - DelayQueue q = i.next(); + final DelayQueue q = i.next(); if(q.delay > 0) { q.delay--; - } - else { + } + else + { transmittersAdded.addAll(transmitters); updateDelay = 1; i.remove(); } } - } catch(Exception e) {} + } + catch(final Exception e) + { + } if(updateDelay > 0) { @@ -365,7 +404,8 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen if(updateDelay == 0) { - MinecraftForge.EVENT_BUS.post(new TransmittersAddedEvent(this, firstUpdate, (Collection)transmittersAdded)); + MinecraftForge.EVENT_BUS.post(new TransmittersAddedEvent( + this, firstUpdate, (Collection) transmittersAdded)); firstUpdate = false; transmittersAdded.clear(); needsUpdate = true; @@ -381,7 +421,9 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen } @Override - public void clientTick() {} + public void clientTick() + { + } public void queueClientUpdate(Collection<IGridTransmitter<A, N>> newTransmitters) { @@ -391,9 +433,9 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen public static class TransmittersAddedEvent extends Event { - public DynamicNetwork<?, ?> network; - public boolean newNetwork; - public Collection<IGridTransmitter> newTransmitters; + public DynamicNetwork<?, ?> network; + public boolean newNetwork; + public Collection<IGridTransmitter> newTransmitters; public TransmittersAddedEvent(DynamicNetwork net, boolean newNet, Collection<IGridTransmitter> added) { @@ -405,8 +447,8 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen public static class ClientTickUpdate extends Event { - public DynamicNetwork network; - public byte operation; /*0 remove, 1 add*/ + public DynamicNetwork network; + public byte operation; /*0 remove, 1 add*/ public ClientTickUpdate(DynamicNetwork net, byte b) { @@ -417,7 +459,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen public static class NetworkClientRequest extends Event { - public TileEntity tileEntity; + public TileEntity tileEntity; public NetworkClientRequest(TileEntity tile) { @@ -432,8 +474,8 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen public static class DelayQueue { - public EntityPlayer player; - public int delay; + public EntityPlayer player; + public int delay; public DelayQueue(EntityPlayer p) { @@ -450,7 +492,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen @Override public boolean equals(Object o) { - return o instanceof DelayQueue && ((DelayQueue)o).player.equals(this.player); + return o instanceof DelayQueue && ((DelayQueue) o).player.equals(this.player); } } } diff --git a/src/api/java/mekanism/api/transmitters/IBlockableConnection.java b/src/api/java/mekanism/api/transmitters/IBlockableConnection.java index f6811fb..1183975 100644 --- a/src/api/java/mekanism/api/transmitters/IBlockableConnection.java +++ b/src/api/java/mekanism/api/transmitters/IBlockableConnection.java @@ -5,6 +5,6 @@ import net.minecraftforge.common.util.ForgeDirection; public interface IBlockableConnection { public boolean canConnectMutual(ForgeDirection side); - + public boolean canConnect(ForgeDirection side); } diff --git a/src/api/java/mekanism/api/transmitters/IGridTransmitter.java b/src/api/java/mekanism/api/transmitters/IGridTransmitter.java index 9d82d48..a184377 100644 --- a/src/api/java/mekanism/api/transmitters/IGridTransmitter.java +++ b/src/api/java/mekanism/api/transmitters/IGridTransmitter.java @@ -1,11 +1,11 @@ package mekanism.api.transmitters; +import java.util.Collection; + import mekanism.api.Coord4D; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; - public interface IGridTransmitter<A, N extends DynamicNetwork<A, N>> extends ITransmitter { public boolean hasTransmitterNetwork(); @@ -37,7 +37,7 @@ public interface IGridTransmitter<A, N extends DynamicNetwork<A, N>> extends ITr public int getCapacity(); public World world(); - + public Coord4D coord(); public Coord4D getAdjacentConnectableTransmitterCoord(ForgeDirection side); @@ -58,7 +58,7 @@ public interface IGridTransmitter<A, N extends DynamicNetwork<A, N>> extends ITr public void takeShare(); - public void updateShare(); + public void updateShare(); public Object getBuffer(); } diff --git a/src/api/java/mekanism/api/transmitters/TransmissionType.java b/src/api/java/mekanism/api/transmitters/TransmissionType.java index 7b54e9c..34aed37 100644 --- a/src/api/java/mekanism/api/transmitters/TransmissionType.java +++ b/src/api/java/mekanism/api/transmitters/TransmissionType.java @@ -1,37 +1,32 @@ package mekanism.api.transmitters; import mekanism.api.gas.IGasTransmitter; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; public enum TransmissionType { - ENERGY("EnergyNetwork", "Energy"), - FLUID("FluidNetwork", "Fluids"), - GAS("GasNetwork", "Gases"), - ITEM("InventoryNetwork", "Items"), - HEAT("HeatNetwork", "Heat"); - - private String name; - private String transmission; - + ENERGY("EnergyNetwork", "Energy"), FLUID("FluidNetwork", "Fluids"), GAS("GasNetwork", "Gases"), ITEM("InventoryNetwork", "Items"), HEAT("HeatNetwork", "Heat"); + + private String name; + private String transmission; + private TransmissionType(String n, String t) { name = n; transmission = t; } - + public String getName() { return name; } - + public String getTransmission() { return transmission; } - + public String localize() { return StatCollector.translateToLocal("transmission." + getTransmission()); @@ -61,7 +56,7 @@ public enum TransmissionType { if(sideTile instanceof ITransmitter) { - if(((ITransmitter)sideTile).getTransmissionType() == this) + if(((ITransmitter) sideTile).getTransmissionType() == this) { return true; } @@ -69,7 +64,7 @@ public enum TransmissionType if(this == GAS && currentTile instanceof IGasTransmitter) { - if(((IGasTransmitter)currentTile).canTransferGasToTube(sideTile)) + if(((IGasTransmitter) currentTile).canTransferGasToTube(sideTile)) { return true; } @@ -77,4 +72,4 @@ public enum TransmissionType return false; } -}
\ No newline at end of file +} diff --git a/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java b/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java index 0f9c1c5..4bf6a22 100644 --- a/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java +++ b/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java @@ -21,16 +21,16 @@ import cpw.mods.fml.relauncher.Side; public class TransmitterNetworkRegistry { - private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry(); - private static boolean loaderRegistered = false; + private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry(); + private static boolean loaderRegistered = false; - private HashSet<DynamicNetwork> networks = Sets.newHashSet(); - private HashSet<DynamicNetwork> networksToChange = Sets.newHashSet(); + private final HashSet<DynamicNetwork> networks = Sets.newHashSet(); + private final HashSet<DynamicNetwork> networksToChange = Sets.newHashSet(); - private HashSet<IGridTransmitter> invalidTransmitters = Sets.newHashSet(); - private HashMap<Coord4D, IGridTransmitter> orphanTransmitters = Maps.newHashMap(); + private final HashSet<IGridTransmitter> invalidTransmitters = Sets.newHashSet(); + private final HashMap<Coord4D, IGridTransmitter> orphanTransmitters = Maps.newHashMap(); - private Logger logger = LogManager.getLogger("MekanismTransmitters"); + private final Logger logger = LogManager.getLogger("MekanismTransmitters"); public static void initiate() { @@ -100,7 +100,7 @@ public class TransmitterNetworkRegistry commitChanges(); - for(DynamicNetwork net : networks) + for(final DynamicNetwork net : networks) { net.tick(); } @@ -112,20 +112,20 @@ public class TransmitterNetworkRegistry { logger.info("Dealing with " + invalidTransmitters.size() + " invalid Transmitters"); } - - for(IGridTransmitter invalid : invalidTransmitters) + + for(final IGridTransmitter invalid : invalidTransmitters) { if(!(invalid.isOrphan() && invalid.isValid())) { - DynamicNetwork n = invalid.getTransmitterNetwork(); - + final DynamicNetwork n = invalid.getTransmitterNetwork(); + if(n != null) { n.invalidate(); } } } - + invalidTransmitters.clear(); } @@ -135,18 +135,18 @@ public class TransmitterNetworkRegistry { logger.info("Dealing with " + orphanTransmitters.size() + " orphan Transmitters"); } - - for(IGridTransmitter orphanTransmitter : orphanTransmitters.values()) + + for(final IGridTransmitter orphanTransmitter : orphanTransmitters.values()) { - DynamicNetwork network = getNetworkFromOrphan(orphanTransmitter); - + final DynamicNetwork network = getNetworkFromOrphan(orphanTransmitter); + if(network != null) { networksToChange.add(network); network.register(); } } - + orphanTransmitters.clear(); } @@ -154,10 +154,11 @@ public class TransmitterNetworkRegistry { if(startOrphan.isValid() && startOrphan.isOrphan()) { - OrphanPathFinder<A, N> finder = new OrphanPathFinder<A, N>(startOrphan); + final OrphanPathFinder<A, N> finder = new OrphanPathFinder<A, N>( + startOrphan); finder.start(); N network; - + switch(finder.networksFound.size()) { case 0: @@ -165,43 +166,43 @@ public class TransmitterNetworkRegistry { logger.info("No networks found. Creating new network for " + finder.connectedTransmitters.size() + " transmitters"); } - + network = startOrphan.createEmptyNetwork(); - + break; case 1: if(MekanismAPI.debug) { logger.info("Adding " + finder.connectedTransmitters.size() + " transmitters to single found network"); } - + network = finder.networksFound.iterator().next(); - + break; default: if(MekanismAPI.debug) { logger.info("Merging " + finder.networksFound.size() + " networks with " + finder.connectedTransmitters.size() + " new transmitters"); } - + network = startOrphan.mergeNetworks(finder.networksFound); } - + network.addNewTransmitters(finder.connectedTransmitters); - + return network; } - + return null; } public void commitChanges() { - for(DynamicNetwork network : networksToChange) + for(final DynamicNetwork network : networksToChange) { network.commit(); } - + networksToChange.clear(); } @@ -213,10 +214,10 @@ public class TransmitterNetworkRegistry public String[] toStrings() { - String[] strings = new String[networks.size()]; + final String[] strings = new String[networks.size()]; int i = 0; - for(DynamicNetwork network : networks) + for(final DynamicNetwork network : networks) { strings[i++] = network.toString(); } @@ -226,12 +227,12 @@ public class TransmitterNetworkRegistry public class OrphanPathFinder<A, N extends DynamicNetwork<A, N>> { - public IGridTransmitter<A, N> startPoint; + public IGridTransmitter<A, N> startPoint; - public HashSet<Coord4D> iterated = Sets.newHashSet(); + public HashSet<Coord4D> iterated = Sets.newHashSet(); - public HashSet<IGridTransmitter<A, N>> connectedTransmitters = Sets.newHashSet(); - public HashSet<N> networksFound = Sets.newHashSet(); + public HashSet<IGridTransmitter<A, N>> connectedTransmitters = Sets.newHashSet(); + public HashSet<N> networksFound = Sets.newHashSet(); public OrphanPathFinder(IGridTransmitter<A, N> start) { @@ -251,22 +252,22 @@ public class TransmitterNetworkRegistry } iterated.add(from); - + if(orphanTransmitters.containsKey(from)) { - IGridTransmitter<A, N> transmitter = orphanTransmitters.get(from); - + final IGridTransmitter<A, N> transmitter = orphanTransmitters.get(from); + if(transmitter.isValid() && transmitter.isOrphan()) { connectedTransmitters.add(transmitter); transmitter.setOrphan(false); - - for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) + + for(final ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if(direction != fromDirection) { - Coord4D directionCoord = transmitter.getAdjacentConnectableTransmitterCoord(direction); - + final Coord4D directionCoord = transmitter.getAdjacentConnectableTransmitterCoord(direction); + if(!(directionCoord == null || iterated.contains(directionCoord))) { iterate(directionCoord, direction.getOpposite()); @@ -274,16 +275,20 @@ public class TransmitterNetworkRegistry } } } - } - else { + } + else + { addNetworkToIterated(from); } } public void addNetworkToIterated(Coord4D from) { - N net = startPoint.getExternalNetwork(from); - if(net != null) networksFound.add(net); + final N net = startPoint.getExternalNetwork(from); + if(net != null) + { + networksFound.add(net); + } } } } diff --git a/src/api/java/mekanism/api/transmitters/package-info.java b/src/api/java/mekanism/api/transmitters/package-info.java index 06819e7..e959a85 100644 --- a/src/api/java/mekanism/api/transmitters/package-info.java +++ b/src/api/java/mekanism/api/transmitters/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|transmitter") package mekanism.api.transmitters; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mekanism/api/util/BlockInfo.java b/src/api/java/mekanism/api/util/BlockInfo.java index 2cb40d7..a0e349d 100644 --- a/src/api/java/mekanism/api/util/BlockInfo.java +++ b/src/api/java/mekanism/api/util/BlockInfo.java @@ -5,8 +5,8 @@ import net.minecraft.item.ItemStack; public class BlockInfo { - public Block block; - public int meta; + public Block block; + public int meta; public BlockInfo(Block b, int j) { @@ -16,15 +16,14 @@ public class BlockInfo public static BlockInfo get(ItemStack stack) { - return new BlockInfo(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); + return new BlockInfo(Block.getBlockFromItem(stack.getItem()), + stack.getItemDamage()); } @Override public boolean equals(Object obj) { - return obj instanceof BlockInfo && - ((BlockInfo)obj).block == block && - ((BlockInfo)obj).meta == meta; + return obj instanceof BlockInfo && ((BlockInfo) obj).block == block && ((BlockInfo) obj).meta == meta; } @Override @@ -35,4 +34,4 @@ public class BlockInfo code = 31 * code + meta; return code; } -}
\ No newline at end of file +} diff --git a/src/api/java/mekanism/api/util/ItemInfo.java b/src/api/java/mekanism/api/util/ItemInfo.java index f27065b..9a810b7 100644 --- a/src/api/java/mekanism/api/util/ItemInfo.java +++ b/src/api/java/mekanism/api/util/ItemInfo.java @@ -5,8 +5,8 @@ import net.minecraft.item.ItemStack; public class ItemInfo { - public Item item; - public int meta; + public Item item; + public int meta; public ItemInfo(Item i, int j) { @@ -22,9 +22,7 @@ public class ItemInfo @Override public boolean equals(Object obj) { - return obj instanceof ItemInfo && - ((ItemInfo)obj).item == item && - ((ItemInfo)obj).meta == meta; + return obj instanceof ItemInfo && ((ItemInfo) obj).item == item && ((ItemInfo) obj).meta == meta; } @Override diff --git a/src/api/java/mekanism/api/util/ListUtils.java b/src/api/java/mekanism/api/util/ListUtils.java index e20807c..4637ae3 100644 --- a/src/api/java/mekanism/api/util/ListUtils.java +++ b/src/api/java/mekanism/api/util/ListUtils.java @@ -9,7 +9,7 @@ public class ListUtils { public static <V> List<V> inverse(List<V> list) { - List<V> toReturn = new ArrayList<V>(); + final List<V> toReturn = new ArrayList<V>(); for(int i = list.size() - 1; i >= 0; i--) { @@ -27,10 +27,11 @@ public class ListUtils { toReturn = copy(list); } - else { + else + { int count = 0; - for(V obj : list) + for(final V obj : list) { count++; @@ -48,9 +49,9 @@ public class ListUtils public static <V> List<V> copy(List<V> list) { - List<V> toReturn = new ArrayList<V>(); + final List<V> toReturn = new ArrayList<V>(); - for(V obj : list) + for(final V obj : list) { toReturn.add(obj); } @@ -60,14 +61,14 @@ public class ListUtils public static <V> List<V> merge(List<V> listOne, List<V> listTwo) { - List<V> newList = new ArrayList<V>(); + final List<V> newList = new ArrayList<V>(); - for(V obj : listOne) + for(final V obj : listOne) { newList.add(obj); } - for(V obj : listTwo) + for(final V obj : listTwo) { newList.add(obj); } @@ -77,19 +78,20 @@ public class ListUtils public static <V> List<V> capRemains(List<V> list, int cap) { - List<V> toReturn = new ArrayList<V>(); + final List<V> toReturn = new ArrayList<V>(); if(list.size() <= cap) { return toReturn; } - else { - List<V> inverse = inverse(list); + else + { + inverse(list); - int iterNeeded = list.size() - cap; + final int iterNeeded = list.size() - cap; int count = 0; - for(V obj : list) + for(final V obj : list) { count++; @@ -108,18 +110,18 @@ public class ListUtils public static <V> ArrayList<List<V>> split(List<V> list, int divide) { int remain = list.size() % divide; - int size = (list.size() - remain) / divide; + final int size = (list.size() - remain) / divide; - ArrayList<List<V>> toReturn = new ArrayList<List<V>>(); + final ArrayList<List<V>> toReturn = new ArrayList<List<V>>(); for(int i = 0; i < divide; i++) { toReturn.add(i, new ArrayList<V>()); } - for(List<V> iterSet : toReturn) + for(final List<V> iterSet : toReturn) { - List<V> removed = new ArrayList<V>(); + final List<V> removed = new ArrayList<V>(); int toAdd = size; @@ -129,7 +131,7 @@ public class ListUtils toAdd++; } - for(V obj : list) + for(final V obj : list) { if(toAdd == 0) { @@ -141,7 +143,7 @@ public class ListUtils toAdd--; } - for(V obj : removed) + for(final V obj : removed) { list.remove(obj); } @@ -152,7 +154,7 @@ public class ListUtils public static <V> V getTop(List<V> list) { - for(V obj : list) + for(final V obj : list) { return obj; } @@ -162,22 +164,22 @@ public class ListUtils public static <V> List<V> asList(Set<V> set) { - return (List<V>)Arrays.asList(set.toArray()); + return (List<V>) Arrays.asList(set.toArray()); } public static <V> List<V> asList(V... values) { - return (List<V>)Arrays.asList(values); + return Arrays.asList(values); } public static double[] splitDouble(int size, double num) { - double[] split = new double[size]; + final double[] split = new double[size]; for(int i = 0; i < size; i++) { - double remain = num%size; - double ret = (num-remain)/size; + final double remain = num % size; + double ret = (num - remain) / size; ret += remain; split[i] = ret; @@ -189,14 +191,17 @@ public class ListUtils public static double[] percent(double[] values) { - double[] ret = new double[values.length]; + final double[] ret = new double[values.length]; double total = 0; - for(double d : values) total += d; + for(final double d : values) + { + total += d; + } for(int i = 0; i < values.length; i++) { - ret[i] = values[i]/total; + ret[i] = values[i] / total; } return ret; @@ -204,23 +209,26 @@ public class ListUtils public static int[] calcPercentInt(double[] percent, int val) { - int[] ret = new int[percent.length]; + final int[] ret = new int[percent.length]; for(int i = 0; i < percent.length; i++) { - ret[i] = (int)Math.round(val*percent[i]); + ret[i] = (int) Math.round(val * percent[i]); } int newTotal = 0; - for(int i : ret) newTotal += i; + for(final int i : ret) + { + newTotal += i; + } - int diff = val-newTotal; + int diff = val - newTotal; if(diff != val) { for(int i = 0; i < ret.length; i++) { - int num = ret[i]; + final int num = ret[i]; if(diff < 0 && num == 0) { @@ -250,12 +258,12 @@ public class ListUtils public static int[] splitInt(int size, int num) { - int[] split = new int[size]; + final int[] split = new int[size]; for(int i = 0; i < size; i++) { - int remain = num%size; - int ret = (num-remain)/size; + final int remain = num % size; + int ret = (num - remain) / size; ret += remain; split[i] = ret; @@ -267,14 +275,17 @@ public class ListUtils public static double[] percent(int[] values) { - double[] ret = new double[values.length]; + final double[] ret = new double[values.length]; double total = 0; - for(double d : values) total += d; + for(final double d : values) + { + total += d; + } for(int i = 0; i < values.length; i++) { - ret[i] = values[i]/total; + ret[i] = values[i] / total; } return ret; diff --git a/src/api/java/mekanism/api/util/StackUtils.java b/src/api/java/mekanism/api/util/StackUtils.java index 7363c75..17cfe3e 100644 --- a/src/api/java/mekanism/api/util/StackUtils.java +++ b/src/api/java/mekanism/api/util/StackUtils.java @@ -16,7 +16,7 @@ public final class StackUtils return null; } - List<ItemStack> ret = new ArrayList<ItemStack>(); + final List<ItemStack> ret = new ArrayList<ItemStack>(); if(stack.stackSize == 1) { @@ -24,10 +24,10 @@ public final class StackUtils return ret; } - int remain = stack.stackSize % 2; - int split = (int)((float)(stack.stackSize)/2F); + final int remain = stack.stackSize % 2; + final int split = (int) ((stack.stackSize) / 2F); - ret.add(size(stack, split+remain)); + ret.add(size(stack, split + remain)); ret.add(size(stack, split)); return ret; @@ -59,7 +59,7 @@ public final class StackUtils { return check == wild; } - + return wild.getItem() == check.getItem() && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check.getItemDamage()); } @@ -70,9 +70,9 @@ public final class StackUtils public static List<ItemStack> even(ItemStack stack1, ItemStack stack2) { - ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); + final ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); - if(getSize(stack1) == getSize(stack2) || Math.abs(getSize(stack1)-getSize(stack2)) == 1) + if(getSize(stack1) == getSize(stack2) || Math.abs(getSize(stack1) - getSize(stack2)) == 1) { ret.add(stack1); ret.add(stack2); @@ -82,18 +82,18 @@ public final class StackUtils if(getSize(stack1) > getSize(stack2)) { - int diff = getSize(stack1)-getSize(stack2); + final int diff = getSize(stack1) - getSize(stack2); - List<ItemStack> split = split(size(stack1, diff)); + final List<ItemStack> split = split(size(stack1, diff)); ret.add(subtract(stack1, split.get(0))); ret.add(add(stack2, split.get(0))); } else if(getSize(stack2) > getSize(stack1)) { - int diff = getSize(stack2)-getSize(stack1); + final int diff = getSize(stack2) - getSize(stack1); - List<ItemStack> split = split(size(stack2, diff)); + final List<ItemStack> split = split(size(stack2, diff)); ret.add(subtract(stack2, split.get(0))); ret.add(add(stack1, split.get(0))); @@ -113,7 +113,7 @@ public final class StackUtils return stack1; } - return size(stack1, getSize(stack1)+getSize(stack2)); + return size(stack1, getSize(stack1) + getSize(stack2)); } public static ItemStack subtract(ItemStack stack1, ItemStack stack2) @@ -127,7 +127,7 @@ public final class StackUtils return stack1; } - return size(stack1, getSize(stack1)-getSize(stack2)); + return size(stack1, getSize(stack1) - getSize(stack2)); } public static ItemStack size(ItemStack stack, int size) @@ -137,7 +137,7 @@ public final class StackUtils return null; } - ItemStack ret = stack.copy(); + final ItemStack ret = stack.copy(); ret.stackSize = size; return ret; } @@ -156,27 +156,27 @@ public final class StackUtils { return stack != null ? stack.stackSize : 0; } - + public static List<ItemStack> getMergeRejects(ItemStack[] orig, ItemStack[] toAdd) { - List<ItemStack> ret = new ArrayList<ItemStack>(); - + final List<ItemStack> ret = new ArrayList<ItemStack>(); + for(int i = 0; i < toAdd.length; i++) { if(toAdd[i] != null) { - ItemStack reject = getMergeReject(orig[i], toAdd[i]); - + final ItemStack reject = getMergeReject(orig[i], toAdd[i]); + if(reject != null) { ret.add(reject); } } } - + return ret; } - + public static void merge(ItemStack[] orig, ItemStack[] toAdd) { for(int i = 0; i < toAdd.length; i++) @@ -187,51 +187,52 @@ public final class StackUtils } } } - + public static ItemStack merge(ItemStack orig, ItemStack toAdd) { if(orig == null) { return toAdd; } - + if(toAdd == null) { return orig; } - + if(!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) { return orig; } - - return StackUtils.size(orig, Math.min(orig.getMaxStackSize(), orig.stackSize+toAdd.stackSize)); + + return StackUtils.size(orig, Math.min(orig.getMaxStackSize(), orig.stackSize + toAdd.stackSize)); } - + public static ItemStack getMergeReject(ItemStack orig, ItemStack toAdd) { if(orig == null) { return null; } - + if(toAdd == null) { return orig; } - + if(!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) { return orig; } - - int newSize = orig.stackSize+toAdd.stackSize; - + + final int newSize = orig.stackSize + toAdd.stackSize; + if(newSize > orig.getMaxStackSize()) { - return StackUtils.size(orig, newSize-orig.getMaxStackSize()); + return StackUtils.size(orig, newSize - orig.getMaxStackSize()); } - else { + else + { return StackUtils.size(orig, newSize); } } @@ -247,8 +248,8 @@ public final class StackUtils { return -1; } - - String name = stack.getItemDamage() == OreDictionary.WILDCARD_VALUE ? stack.getItem().getUnlocalizedName() : stack.getItem().getUnlocalizedName(stack); + + final String name = stack.getItemDamage() == OreDictionary.WILDCARD_VALUE ? stack.getItem().getUnlocalizedName() : stack.getItem().getUnlocalizedName(stack); return name.hashCode() << 8 | stack.getItemDamage(); } } diff --git a/src/api/java/mekanism/api/util/UnitDisplayUtils.java b/src/api/java/mekanism/api/util/UnitDisplayUtils.java index 9dd3e28..30eace1 100644 --- a/src/api/java/mekanism/api/util/UnitDisplayUtils.java +++ b/src/api/java/mekanism/api/util/UnitDisplayUtils.java @@ -7,13 +7,10 @@ public class UnitDisplayUtils { public static enum ElectricUnit { - JOULES("Joule", "J"), - REDSTONE_FLUX("Redstone Flux", "RF"), - MINECRAFT_JOULES("Minecraft Joule", "MJ"), - ELECTRICAL_UNITS("Electrical Unit", "EU"); + JOULES("Joule", "J"), REDSTONE_FLUX("Redstone Flux", "RF"), MINECRAFT_JOULES("Minecraft Joule", "MJ"), ELECTRICAL_UNITS("Electrical Unit", "EU"); - public String name; - public String symbol; + public String name; + public String symbol; private ElectricUnit(String s, String s1) { @@ -29,16 +26,12 @@ public class UnitDisplayUtils public static enum TemperatureUnit { - KELVIN("Kelvin", "K", 0, 1), - CELSIUS("Celsius", "°C", 273.15, 1), - RANKINE("Rankine", "R", 0, 9D/5D), - FAHRENHEIT("Fahrenheit", "°F", 459.67, 9D/5D), - AMBIENT("Ambient", "+STP", 300, 1); + KELVIN("Kelvin", "K", 0, 1), CELSIUS("Celsius", "°C", 273.15, 1), RANKINE("Rankine", "R", 0, 9D / 5D), FAHRENHEIT("Fahrenheit", "°F", 459.67, 9D / 5D), AMBIENT("Ambient", "+STP", 300, 1); - public String name; - public String symbol; - double zeroOffset; - double intervalSize; + public String name; + public String symbol; + double zeroOffset; + double intervalSize; private TemperatureUnit(String s, String s1, double offset, double size) { @@ -62,29 +55,16 @@ public class UnitDisplayUtils /** Metric system of measurement. */ public static enum MeasurementUnit { - FEMTO("Femto", "f", 0.000000000000001D), - PICO("Pico", "p", 0.000000000001D), - NANO("Nano", "n", 0.000000001D), - MICRO("Micro", "u", 0.000001D), - MILLI("Milli", "m", 0.001D), - BASE("", "", 1), - KILO("Kilo", "k", 1000D), - MEGA("Mega", "M", 1000000D), - GIGA("Giga", "G", 1000000000D), - TERA("Tera", "T", 1000000000000D), - PETA("Peta", "P", 1000000000000000D), - EXA("Exa", "E", 1000000000000000000D), - ZETTA("Zetta", "Z", 1000000000000000000000D), - YOTTA("Yotta", "Y", 1000000000000000000000000D); + FEMTO("Femto", "f", 0.000000000000001D), PICO("Pico", "p", 0.000000000001D), NANO("Nano", "n", 0.000000001D), MICRO("Micro", "u", 0.000001D), MILLI("Milli", "m", 0.001D), BASE("", "", 1), KILO("Kilo", "k", 1000D), MEGA("Mega", "M", 1000000D), GIGA("Giga", "G", 1000000000D), TERA("Tera", "T", 1000000000000D), PETA("Peta", "P", 1000000000000000D), EXA("Exa", "E", 1000000000000000000D), ZETTA("Zetta", "Z", 1000000000000000000000D), YOTTA("Yotta", "Y", 1000000000000000000000000D); /** long name for the unit */ - public String name; + public String name; /** short unit version of the unit */ - public String symbol; + public String symbol; /** Point by which a number is consider to be of this unit */ - public double value; + public double value; private MeasurementUnit(String s, String s1, double v) { @@ -99,7 +79,8 @@ public class UnitDisplayUtils { return symbol; } - else { + else + { return name; } } @@ -149,10 +130,11 @@ public class UnitDisplayUtils { return value + " " + unitName; } - else { + else + { for(int i = 0; i < MeasurementUnit.values().length; i++) { - MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; + final MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) { @@ -164,7 +146,7 @@ public class UnitDisplayUtils return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; } - MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; + final MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value) { @@ -192,7 +174,7 @@ public class UnitDisplayUtils { if(decimalPlaces < 1) { - return (int)value + " " + unit.getPlural(); + return (int) value + " " + unit.getPlural(); } return roundDecimals(value, decimalPlaces) + " " + unit.getPlural(); @@ -200,7 +182,7 @@ public class UnitDisplayUtils if(decimalPlaces < 1) { - return (int)value + " " + unit.name; + return (int) value + " " + unit.name; } return roundDecimals(value, decimalPlaces) + " " + unit.name; @@ -228,10 +210,11 @@ public class UnitDisplayUtils { return value + (isShort ? "" : " ") + unitName; } - else { + else + { for(int i = 0; i < MeasurementUnit.values().length; i++) { - MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; + final MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) { @@ -243,7 +226,7 @@ public class UnitDisplayUtils return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; } - MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; + final MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value) { @@ -267,8 +250,8 @@ public class UnitDisplayUtils public static double roundDecimals(double d, int decimalPlaces) { - int j = (int)(d*Math.pow(10, decimalPlaces)); - return j/Math.pow(10, decimalPlaces); + final int j = (int) (d * Math.pow(10, decimalPlaces)); + return j / Math.pow(10, decimalPlaces); } public static double roundDecimals(double d) @@ -278,18 +261,11 @@ public class UnitDisplayUtils public static enum EnergyType { - J, - RF, - EU, - MJ + J, RF, EU, MJ } public static enum TempType { - K, - C, - R, - F, - STP + K, C, R, F, STP } } diff --git a/src/api/java/mekanism/api/util/package-info.java b/src/api/java/mekanism/api/util/package-info.java index e5253bc..78fd35b 100644 --- a/src/api/java/mekanism/api/util/package-info.java +++ b/src/api/java/mekanism/api/util/package-info.java @@ -1,3 +1,5 @@ @API(apiVersion = "8.0.0", owner = "Mekanism", provides = "MekanismAPI|util") package mekanism.api.util; -import cpw.mods.fml.common.API;
\ No newline at end of file + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mods/battlegear2/api/IAllowItem.java b/src/api/java/mods/battlegear2/api/IAllowItem.java index 78e9ffa..2610f74 100644 --- a/src/api/java/mods/battlegear2/api/IAllowItem.java +++ b/src/api/java/mods/battlegear2/api/IAllowItem.java @@ -2,10 +2,11 @@ package mods.battlegear2.api; import net.minecraft.item.ItemStack; -public interface IAllowItem { +public interface IAllowItem +{ /** - * Returns true if the mainhand {@link ItemStack} allows the offhand {@link ItemStack} to be placed in the partner offhand slot - */ + * Returns true if the mainhand {@link ItemStack} allows the offhand {@link ItemStack} to be placed in the partner offhand slot + */ public boolean allowOffhand(ItemStack mainhand, ItemStack offhand); } diff --git a/src/api/java/mods/battlegear2/api/IOffhandDual.java b/src/api/java/mods/battlegear2/api/IOffhandDual.java index 4e93dd5..91f1293 100644 --- a/src/api/java/mods/battlegear2/api/IOffhandDual.java +++ b/src/api/java/mods/battlegear2/api/IOffhandDual.java @@ -1,62 +1,63 @@ package mods.battlegear2.api; -import cpw.mods.fml.relauncher.Side; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import cpw.mods.fml.relauncher.Side; -public interface IOffhandDual { +public interface IOffhandDual +{ /** - * Returns true if this item can be dual wielded in the offhand slot - * @param off The {@link ItemStack} holding this item - */ - public boolean isOffhandHandDual(ItemStack off); - - /** - * Perform any function when this item is held in the offhand and the user right clicks an entity. - * This is generally used to attack an entity with the offhand item. - * If this is the case the {@link PlayerEventChild.OffhandAttackEvent#parent} field should - * be canceled (or {@link PlayerEventChild.OffhandAttackEvent#cancelParent} field left at true, to prevent any default right clicking events (Eg Villager Trading) - * - * @param event the OffhandAttackEvent that was generated - * @param mainhandItem the {@link ItemStack} currently being held in the right hand - * @param offhandItem the {@link ItemStack} currently being held in the left hand, holding this item - * @return true if the off hand swing animation should be performed - */ - public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem); + * Returns true if this item can be dual wielded in the offhand slot + * @param off The {@link ItemStack} holding this item + */ + public boolean isOffhandHandDual(ItemStack off); - /** - * Perform any function when this item is held in the offhand and the user right clicks "Air". - * Note: Called first on client-side, then on server side if {@link PlayerInteractEvent} is not cancelled and mainhandItem is not null, - * following Forge rules for PlayerInteractEvent with Action==RIGHT_CLICK_AIR - * Note: PlayerInteractEvent is already cancelled beforehand, and will be cancelled after if this method returns false - * Note: Above issues will be fixed in next Minecraft versions by replacing first arg with a shallow copy - * @param event the PlayerInteractEvent that was generated - * @param mainhandItem the {@link ItemStack} currently being held in the right hand - * @param offhandItem the {@link ItemStack} currently being held in the left hand, holding this item - * @return true if the off hand swing animation should be performed - */ - public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + /** + * Perform any function when this item is held in the offhand and the user right clicks an entity. + * This is generally used to attack an entity with the offhand item. + * If this is the case the {@link PlayerEventChild.OffhandAttackEvent#parent} field should + * be canceled (or {@link PlayerEventChild.OffhandAttackEvent#cancelParent} field left at true, to prevent any default right clicking events (Eg Villager Trading) + * + * @param event the OffhandAttackEvent that was generated + * @param mainhandItem the {@link ItemStack} currently being held in the right hand + * @param offhandItem the {@link ItemStack} currently being held in the left hand, holding this item + * @return true if the off hand swing animation should be performed + */ + public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem); - /** - * Perform any function when this item is held in the offhand and the user right clicks a block. - * Note: this will happen prior to the activation of any activation functions of blocks - * Note: Called first on client-side, then on server side if {@link PlayerInteractEvent} is not cancelled - * Note: {@link PlayerInteractEvent#useItem} is already set on {@link Event.Result#DENY} before reaching this method, in order to avoid mainhandItem usage - * - * @param event the PlayerInteractEvent that was generated - * @param mainhandItem the {@link ItemStack} currently being held in the right hand - * @param offhandItem the {@link ItemStack} currently being held in the left hand, holding this item - * @return true if the off hand swing animation should be performed - */ - public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + /** + * Perform any function when this item is held in the offhand and the user right clicks "Air". + * Note: Called first on client-side, then on server side if {@link PlayerInteractEvent} is not cancelled and mainhandItem is not null, + * following Forge rules for PlayerInteractEvent with Action==RIGHT_CLICK_AIR + * Note: PlayerInteractEvent is already cancelled beforehand, and will be cancelled after if this method returns false + * Note: Above issues will be fixed in next Minecraft versions by replacing first arg with a shallow copy + * @param event the PlayerInteractEvent that was generated + * @param mainhandItem the {@link ItemStack} currently being held in the right hand + * @param offhandItem the {@link ItemStack} currently being held in the left hand, holding this item + * @return true if the off hand swing animation should be performed + */ + public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); - @SuppressWarnings("unused") - /** - * Perform any passive effects on each game tick when this item is held in the offhand - * @deprecated See {@link Item#onUpdate(ItemStack, World, Entity, int, boolean)} - * @param effectiveSide the effective side the method was called from - * @param mainhandItem the {@link ItemStack} currently being held in the right hand - * @param offhandItem the {@link ItemStack} currently being held in the left hand - */ - public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem); + /** + * Perform any function when this item is held in the offhand and the user right clicks a block. + * Note: this will happen prior to the activation of any activation functions of blocks + * Note: Called first on client-side, then on server side if {@link PlayerInteractEvent} is not cancelled + * Note: {@link PlayerInteractEvent#useItem} is already set on {@link Event.Result#DENY} before reaching this method, in order to avoid mainhandItem usage + * + * @param event the PlayerInteractEvent that was generated + * @param mainhandItem the {@link ItemStack} currently being held in the right hand + * @param offhandItem the {@link ItemStack} currently being held in the left hand, holding this item + * @return true if the off hand swing animation should be performed + */ + public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + @SuppressWarnings("unused") + /** + * Perform any passive effects on each game tick when this item is held in the offhand + * @deprecated See {@link Item#onUpdate(ItemStack, World, Entity, int, boolean)} + * @param effectiveSide the effective side the method was called from + * @param mainhandItem the {@link ItemStack} currently being held in the right hand + * @param offhandItem the {@link ItemStack} currently being held in the left hand + */ + public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem); } diff --git a/src/api/java/mods/battlegear2/api/ISheathed.java b/src/api/java/mods/battlegear2/api/ISheathed.java index 411c639..5a96625 100644 --- a/src/api/java/mods/battlegear2/api/ISheathed.java +++ b/src/api/java/mods/battlegear2/api/ISheathed.java @@ -10,11 +10,12 @@ import net.minecraft.item.ItemStack; * See {@link mods.battlegear2.api.RenderPlayerEventChild.PreRenderSheathed} and {@link mods.battlegear2.api.RenderPlayerEventChild.PostRenderSheathed} * for more flexibility over the rendering */ -public interface ISheathed { +public interface ISheathed +{ - /** - * Returns true if this item should always be sheathed on the back, false if it should be sheathed on the hip - * @param item the {@link ItemStack} to be sheathed - */ - public boolean sheatheOnBack(ItemStack item); + /** + * Returns true if this item should always be sheathed on the back, false if it should be sheathed on the hip + * @param item the {@link ItemStack} to be sheathed + */ + public boolean sheatheOnBack(ItemStack item); } diff --git a/src/api/java/mods/battlegear2/api/PlayerEventChild.java b/src/api/java/mods/battlegear2/api/PlayerEventChild.java index 95ea329..d6a04f4 100644 --- a/src/api/java/mods/battlegear2/api/PlayerEventChild.java +++ b/src/api/java/mods/battlegear2/api/PlayerEventChild.java @@ -1,271 +1,306 @@ package mods.battlegear2.api; -import cpw.mods.fml.common.eventhandler.Cancelable; +import mods.battlegear2.api.quiver.IArrowContainer2; +import mods.battlegear2.api.shield.IShield; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import cpw.mods.fml.common.eventhandler.Cancelable; -public abstract class PlayerEventChild extends PlayerEvent{ +public abstract class PlayerEventChild extends PlayerEvent +{ - /** - * The event that this event is a child of - */ - public final PlayerEvent parent; + /** + * The event that this event is a child of + */ + public final PlayerEvent parent; - public PlayerEventChild(PlayerEvent parent) { + public PlayerEventChild(PlayerEvent parent) + { super(parent.entityPlayer); this.parent = parent; } - public void setCancelParentEvent(boolean cancel) { - parent.setCanceled(cancel); - } + public void setCancelParentEvent(boolean cancel) + { + parent.setCanceled(cancel); + } - @Override - public void setCanceled(boolean cancel) { - super.setCanceled(cancel); - parent.setCanceled(cancel); - } + @Override + public void setCanceled(boolean cancel) + { + super.setCanceled(cancel); + parent.setCanceled(cancel); + } - @Override - public void setResult(Result value) { - super.setResult(value); - parent.setResult(value); - } + @Override + public void setResult(Result value) + { + super.setResult(value); + parent.setResult(value); + } + + public EntityPlayer getPlayer() + { + return parent.entityPlayer; + } - public EntityPlayer getPlayer(){ - return parent.entityPlayer; - } - /** * Event fired when a shield successfully blocks an attack (in {@link LivingHurtEvent}) */ - public static class ShieldBlockEvent extends PlayerEventChild { - public final ItemStack shield; - public final DamageSource source; - public final float ammount; // use same name as other Forge events - public float ammountRemaining = 0.0F; // damage remaining after shield block event, if any - /** - * If the {@link IShield#blockAnimation(EntityPlayer, float)} should be called - */ - public boolean performAnimation = true; - /** - * If the shield should be damaged based on the ammount and the result of {@link IShield#getDamageReduction(ItemStack, DamageSource)} - */ - public boolean damageShield = true; - public ShieldBlockEvent(PlayerEvent parent, ItemStack shield, DamageSource source, float ammount) { - super(parent); - this.shield = shield; - this.source = source; - this.ammount = ammount; - } - } + public static class ShieldBlockEvent extends PlayerEventChild + { + public final ItemStack shield; + public final DamageSource source; + public final float ammount; // use same name as other Forge events + public float ammountRemaining = 0.0F; // damage remaining after shield block event, if any + /** + * If the {@link IShield#blockAnimation(EntityPlayer, float)} should be called + */ + public boolean performAnimation = true; + /** + * If the shield should be damaged based on the ammount and the result of {@link IShield#getDamageReduction(ItemStack, DamageSource)} + */ + public boolean damageShield = true; - /** - * Called when a player right clicks in battlemode - * The parent event can be either {@link PlayerInteractEvent} or {@link EntityInteractEvent} if the OffhandAttackEvent allowed swinging - * Both {@link ItemStack} can be null - * If cancelled, no offhand swinging will be performed - */ - @Cancelable - public static class OffhandSwingEvent extends PlayerEventChild { - public final ItemStack mainHand; - public final ItemStack offHand; - public OffhandSwingEvent(PlayerEvent parent, ItemStack mainHand, ItemStack offHand){ - super(parent); - this.mainHand = mainHand; - this.offHand = offHand; - } - } + public ShieldBlockEvent(PlayerEvent parent, ItemStack shield, DamageSource source, float ammount) + { + super(parent); + this.shield = shield; + this.source = source; + this.ammount = ammount; + } + } - /** - * Called when a player right clicks an entity in battlemode - * Both {@link ItemStack} can be null - * Cancelling will prevent any further processing and prevails over the boolean fields - */ - @Cancelable - public static class OffhandAttackEvent extends PlayerEventChild { + /** + * Called when a player right clicks in battlemode + * The parent event can be either {@link PlayerInteractEvent} or {@link EntityInteractEvent} if the OffhandAttackEvent allowed swinging + * Both {@link ItemStack} can be null + * If cancelled, no offhand swinging will be performed + */ + @Cancelable + public static class OffhandSwingEvent extends PlayerEventChild + { + public final ItemStack mainHand; + public final ItemStack offHand; - /** - * If we should call the OffhandSwingEvent and perform swinging - */ - public boolean swingOffhand = true; - /** - * If we should perform an attack on the entity with the offhand item - * Note: Will post {@link AttackEntityEvent} and {@link Item#onLeftClickEntity(ItemStack, EntityPlayer, Entity)} - * with {@link InventoryPlayer#currentItem} offset to the offhand - */ - public boolean shouldAttack = true; - /** - * If we should cancel the base entity interaction event - */ - public boolean cancelParent = true; - /** - * The base entity interaction event - */ - public final EntityInteractEvent event; - /** - * Content of the main hand slot - */ - public final ItemStack mainHand; - /** - * Content of the off hand slot - */ - public final ItemStack offHand; + public OffhandSwingEvent(PlayerEvent parent, ItemStack mainHand, ItemStack offHand) + { + super(parent); + this.mainHand = mainHand; + this.offHand = offHand; + } + } - public OffhandAttackEvent(EntityInteractEvent parent, ItemStack mainHand, ItemStack offHand) { - super(parent); - this.event = parent; - this.mainHand = mainHand; - this.offHand = offHand; - } + /** + * Called when a player right clicks an entity in battlemode + * Both {@link ItemStack} can be null + * Cancelling will prevent any further processing and prevails over the boolean fields + */ + @Cancelable + public static class OffhandAttackEvent extends PlayerEventChild + { + + /** + * If we should call the OffhandSwingEvent and perform swinging + */ + public boolean swingOffhand = true; + /** + * If we should perform an attack on the entity with the offhand item + * Note: Will post {@link AttackEntityEvent} and {@link Item#onLeftClickEntity(ItemStack, EntityPlayer, Entity)} + * with {@link InventoryPlayer#currentItem} offset to the offhand + */ + public boolean shouldAttack = true; + /** + * If we should cancel the base entity interaction event + */ + public boolean cancelParent = true; + /** + * The base entity interaction event + */ + public final EntityInteractEvent event; + /** + * Content of the main hand slot + */ + public final ItemStack mainHand; + /** + * Content of the off hand slot + */ + public final ItemStack offHand; + + public OffhandAttackEvent(EntityInteractEvent parent, ItemStack mainHand, ItemStack offHand) + { + super(parent); + event = parent; + this.mainHand = mainHand; + this.offHand = offHand; + } + + public Entity getTarget() + { + return ((EntityInteractEvent) parent).target; + } + } - public Entity getTarget() { - return ((EntityInteractEvent)parent).target; - } - } + /** + * This event replicates the event usage of {@link PlayerInteractEvent} for the item in left hand on right click, + * allowing support for other mods that use such event to customize item usage + * {@link Item#onItemUseFirst}, {@link Item#onItemRightClick} and {@link Item#onItemUse} will then get called the same way as with the item in the player right hand for PlayerInteractEvent + */ + @Cancelable + public static class UseOffhandItemEvent extends PlayerEventChild + { + /** + * The {@link ItemStack} held in left hand + */ + public final ItemStack offhand; + /** + * The equivalent {@link PlayerInteractEvent} that would have been triggered if the offhand item was held in right hand and right click was pressed + */ + public final PlayerInteractEvent event; + + public UseOffhandItemEvent(PlayerInteractEvent event, ItemStack offhand) + { + super(event); + this.event = event; + this.offhand = offhand; + } + } + + public static class QuiverArrowEvent extends PlayerEventChild + { + /** + * The event from which this occurred + */ + protected final ArrowLooseEvent event; - /** - * This event replicates the event usage of {@link PlayerInteractEvent} for the item in left hand on right click, - * allowing support for other mods that use such event to customize item usage - * {@link Item#onItemUseFirst}, {@link Item#onItemRightClick} and {@link Item#onItemUse} will then get called the same way as with the item in the player right hand for PlayerInteractEvent - */ - @Cancelable - public static class UseOffhandItemEvent extends PlayerEventChild{ - /** - * The {@link ItemStack} held in left hand - */ - public final ItemStack offhand; - /** - * The equivalent {@link PlayerInteractEvent} that would have been triggered if the offhand item was held in right hand and right click was pressed - */ - public final PlayerInteractEvent event; - public UseOffhandItemEvent(PlayerInteractEvent event, ItemStack offhand){ - super(event); - this.event = event; - this.offhand = offhand; - } - } + public QuiverArrowEvent(ArrowLooseEvent event) + { + super(event); + this.event = event; + } - public static class QuiverArrowEvent extends PlayerEventChild{ - /** - * The event from which this occurred - */ - protected final ArrowLooseEvent event; - public QuiverArrowEvent(ArrowLooseEvent event){ - super(event); - this.event = event; - } + /** + * @return the player using the bow + */ + public EntityPlayer getArcher() + { + return getPlayer(); + } - /** - * @return the player using the bow - */ - public EntityPlayer getArcher(){ - return getPlayer(); - } + /** + * @return the bow trying to fire + */ + public ItemStack getBow() + { + return event.bow; + } - /** - * @return the bow trying to fire - */ - public ItemStack getBow() - { - return event.bow; - } + /** + * @return the amount of charge in the bow + */ + public float getCharge() + { + return event.charge; + } - /** - * @return the amount of charge in the bow - */ - public float getCharge() - { - return event.charge; - } + /** + * Event fired after an arrow has been selected and taken from a {@link IArrowContainer2}, before it is actually spawned + */ + @Cancelable + public static class Firing extends QuiverArrowEvent + { + /** + * Damage done to the bow after arrow is fired + */ + public int bowDamage = 1; + /** + * The volume of the sound emitted from the bow after arrow is fired + */ + public float bowSoundVolume = 1.0F; + /** + * Decides if standard enchantments can be added to the arrow + */ + public boolean addEnchantments = true; + /** + * Decides if critical state should be forced into the arrow + */ + public boolean isCritical = false; + /** + * The quiver from which the arrow was pulled from + */ + public final ItemStack quiver; + /** + * The arrow to be fired, can't be null + */ + public final EntityArrow arrow; - /** - * Event fired after an arrow has been selected and taken from a {@link IArrowContainer2}, before it is actually spawned - */ - @Cancelable - public static class Firing extends QuiverArrowEvent { - /** - * Damage done to the bow after arrow is fired - */ - public int bowDamage = 1; - /** - * The volume of the sound emitted from the bow after arrow is fired - */ - public float bowSoundVolume = 1.0F; - /** - * Decides if standard enchantments can be added to the arrow - */ - public boolean addEnchantments = true; - /** - * Decides if critical state should be forced into the arrow - */ - public boolean isCritical = false; - /** - * The quiver from which the arrow was pulled from - */ - public final ItemStack quiver; - /** - * The arrow to be fired, can't be null - */ - public final EntityArrow arrow; + public Firing(ArrowLooseEvent parent, ItemStack quiver, EntityArrow arrow) + { + super(parent); + this.quiver = quiver; + this.arrow = arrow; + } - public Firing(ArrowLooseEvent parent, ItemStack quiver, EntityArrow arrow) { - super(parent); - this.quiver = quiver; - this.arrow = arrow; - } + } - } + /** + * The DEFAULT result for this event is the vanilla charge calculated value + * Use setNewCharge to override the value with the one provided + * Change the event result to DENY to prevent further processing + */ + @HasResult + public static class ChargeCalculations extends QuiverArrowEvent + { + /** + * Returned value if the result is set to allow + */ + protected float charge; - /** - * The DEFAULT result for this event is the vanilla charge calculated value - * Use setNewCharge to override the value with the one provided - * Change the event result to DENY to prevent further processing - */ - @HasResult - public static class ChargeCalculations extends QuiverArrowEvent { - /** - * Returned value if the result is set to allow - */ - protected float charge; - public ChargeCalculations(ArrowLooseEvent event){ - super(event); - } + public ChargeCalculations(ArrowLooseEvent event) + { + super(event); + } - @Override - public float getCharge(){ - MinecraftForge.EVENT_BUS.post(this); - switch (this.getResult()){ - case ALLOW: - return charge; - case DENY: - return 0; - } - float f = super.getCharge()/20.0F; - f = (f * f + f * 2.0F) / 3.0F; - if ((double)f < 0.1D) - { - return 0; - } - if (f > 1.0F) - { - f = 1.0F; - } - return f; - } + @Override + public float getCharge() + { + MinecraftForge.EVENT_BUS.post(this); + switch(getResult()) + { + case ALLOW: + return charge; + case DENY: + return 0; + } + float f = super.getCharge() / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; + if(f < 0.1D) + { + return 0; + } + if(f > 1.0F) + { + f = 1.0F; + } + return f; + } - public void setNewCharge(float charge){ - this.setResult(Result.ALLOW); - this.charge = charge; - } - } - } + public void setNewCharge(float charge) + { + setResult(Result.ALLOW); + this.charge = charge; + } + } + } } diff --git a/src/api/java/mods/battlegear2/api/package-info.java b/src/api/java/mods/battlegear2/api/package-info.java index 49f47ea..81dbfe8 100644 --- a/src/api/java/mods/battlegear2/api/package-info.java +++ b/src/api/java/mods/battlegear2/api/package-info.java @@ -1,4 +1,5 @@ @API(owner = "battlegear2", provides = "DualWield", apiVersion = "0.1") package mods.battlegear2.api; -import cpw.mods.fml.common.API;
\ No newline at end of file +import cpw.mods.fml.common.API; + diff --git a/src/api/java/mods/battlegear2/api/weapons/IBattlegearWeapon.java b/src/api/java/mods/battlegear2/api/weapons/IBattlegearWeapon.java index 8442153..61ca8cc 100644 --- a/src/api/java/mods/battlegear2/api/weapons/IBattlegearWeapon.java +++ b/src/api/java/mods/battlegear2/api/weapons/IBattlegearWeapon.java @@ -8,6 +8,7 @@ import mods.battlegear2.api.ISheathed; * A generic flag for weapon * <strong>Not</strong> necessary for an item to be wielded in battlegear slots */ -public interface IBattlegearWeapon extends ISheathed,IOffhandDual,IAllowItem{ +public interface IBattlegearWeapon extends ISheathed, IOffhandDual, IAllowItem +{ -}
\ No newline at end of file +} diff --git a/src/api/java/mods/battlegear2/api/weapons/package-info.java b/src/api/java/mods/battlegear2/api/weapons/package-info.java index 2e3232b..152cc47 100644 --- a/src/api/java/mods/battlegear2/api/weapons/package-info.java +++ b/src/api/java/mods/battlegear2/api/weapons/package-info.java @@ -1,4 +1,5 @@ @API(owner = "battlegear2", provides = "Weapons", apiVersion = "0.1") package mods.battlegear2.api.weapons; -import cpw.mods.fml.common.API;
\ No newline at end of file +import cpw.mods.fml.common.API; + diff --git a/src/api/java/modwarriors/notenoughkeys/api/Api.java b/src/api/java/modwarriors/notenoughkeys/api/Api.java index 390d28a..5da1ae8 100644 --- a/src/api/java/modwarriors/notenoughkeys/api/Api.java +++ b/src/api/java/modwarriors/notenoughkeys/api/Api.java @@ -10,14 +10,16 @@ import cpw.mods.fml.relauncher.SideOnly; * @author TheTemportalist */ @SideOnly(Side.CLIENT) -public class Api { +public class Api +{ /** * Checks if NotEnoughKeys is loaded in the current environment * * @return 'true' if loaded */ - public static boolean isLoaded() { + public static boolean isLoaded() + { return Loader.isModLoaded("notenoughkeys"); } @@ -27,12 +29,14 @@ public class Api { * @param modname The NAME of the mod registering the key * @param keyDecriptions A String[] (Array[String]) of the key descriptions. i.e. new String[]{"key.hotbar1"} */ - public static void registerMod(String modname, String[] keyDecriptions) { - try { - Class.forName("modwarriors.notenoughkeys.keys.KeyHelper").getMethod( - "registerMod", String.class, String[].class - ).invoke(null, modname, keyDecriptions); - } catch (Exception e) { + public static void registerMod(String modname, String[] keyDecriptions) + { + try + { + Class.forName("modwarriors.notenoughkeys.keys.KeyHelper").getMethod("registerMod", String.class, String[].class).invoke(null, modname, keyDecriptions); + } + catch(final Exception e) + { e.printStackTrace(); } } diff --git a/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java b/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java index d17b808..850ec6a 100644 --- a/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java +++ b/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java @@ -1,10 +1,10 @@ package modwarriors.notenoughkeys.api; +import net.minecraft.client.settings.KeyBinding; import cpw.mods.fml.common.eventhandler.Cancelable; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.settings.KeyBinding; /** * Called when a keybinding is triggered with the passed with valid modifiers @@ -13,16 +13,18 @@ import net.minecraft.client.settings.KeyBinding; */ @SideOnly(Side.CLIENT) @Cancelable -public class KeyBindingPressedEvent extends Event { +public class KeyBindingPressedEvent extends Event +{ /** * The KeyBinding being triggered */ - public KeyBinding keyBinding = null; + public KeyBinding keyBinding = null; /** * Tells whether a modifier was required AND was down when triggered */ - public boolean shiftRequired = false, ctrlRequired = false, altRequired = false; + public boolean shiftRequired = false, ctrlRequired = false, + altRequired = false; /** * Called with the passed keyBinding and modifiers. @@ -31,12 +33,13 @@ public class KeyBindingPressedEvent extends Event { * @param keyBinding The KeyBinding being triggered. Stores the key's description and keycode * @param modifiers The modifiers (SHIFT, CTRL, ALT) that determine when a compatible key is pressed */ - public KeyBindingPressedEvent(KeyBinding keyBinding, boolean[] modifiers) { + public KeyBindingPressedEvent(KeyBinding keyBinding, boolean[] modifiers) + { super(); this.keyBinding = keyBinding; - this.shiftRequired = modifiers[0]; - this.ctrlRequired = modifiers[1]; - this.altRequired = modifiers[2]; + shiftRequired = modifiers[0]; + ctrlRequired = modifiers[1]; + altRequired = modifiers[2]; } diff --git a/src/api/java/modwarriors/notenoughkeys/api/package-info.java b/src/api/java/modwarriors/notenoughkeys/api/package-info.java index d53b000..913ae44 100644 --- a/src/api/java/modwarriors/notenoughkeys/api/package-info.java +++ b/src/api/java/modwarriors/notenoughkeys/api/package-info.java @@ -1,5 +1,5 @@ - -@API(owner = "Not Enough Keys", provides = "API_NEK", - apiVersion = "1.0.0") package modwarriors.notenoughkeys.api; +@API(owner = "Not Enough Keys", provides = "API_NEK", apiVersion = "1.0.0") +package modwarriors.notenoughkeys.api; import cpw.mods.fml.common.API; + diff --git a/src/api/java/morph/api/Ability.java b/src/api/java/morph/api/Ability.java index 36a75e9..266855b 100644 --- a/src/api/java/morph/api/Ability.java +++ b/src/api/java/morph/api/Ability.java @@ -15,18 +15,18 @@ import cpw.mods.fml.relauncher.SideOnly; * @author iChun * */ -public abstract class Ability +public abstract class Ability { /** * Ability parent field. Will be null for instances used in registration. Ability is then cloned and parent assigned later on. */ - private EntityLivingBase parent; + private EntityLivingBase parent; + + /** + * Flag for Ability activity. If true, tick/postRender/kill will notbe called. + */ + public boolean inactive; - /** - * Flag for Ability activity. If true, tick/postRender/kill will notbe called. - */ - public boolean inactive; - /** * Basic constructor (but you didn't really need me to tell you that ;D ) */ @@ -34,12 +34,15 @@ public abstract class Ability { parent = null; } - + /** * Function for mod mob support, with args. */ - public Ability parse(String[] args) { return this; } - + public Ability parse(String[] args) + { + return this; + } + /** * Since parent is private it needs a setter. * @param newParent @@ -48,7 +51,7 @@ public abstract class Ability { parent = ent; } - + /** * Get's the parent entity for this ability * @return Entity the ability takes effect on @@ -57,7 +60,7 @@ public abstract class Ability { return parent; } - + /** * Each ability has to return a String type. * This is used for comparison, saving, as well as construction/loading of Ability. @@ -65,60 +68,61 @@ public abstract class Ability * @return Ability type */ public abstract String getType(); - + /** * Ticks every world tick, basically an ability onUpdate, similar to Entity's onUpdate. * Will only tick if getParent() is not null. * Please remember that getParent is not necessarily a player. */ public abstract void tick(); - + /** * Called when the ability is finally removed when the parent demorphs or morphs into a state that does not have this ability type. * This will NOT be called if the parent morphs into another morph that has this type of ability. */ public abstract void kill(); - + /** * Creates a copy of this ability for use with parents. * As previously stated before the ability instance used during registration is a base so it needs to be cloned for use with parents. */ + @Override public abstract Ability clone(); - /** - * Return true for this if you need an inactive copy of this morph in-between morph states (abilities of the next morph are only swapped over when morph is complete) - * Currently used for AbilitySwim to adjust the fog render. - * @return requiresInactiveClone - */ - public boolean requiresInactiveClone() - { - return false; - } - + /** + * Return true for this if you need an inactive copy of this morph in-between morph states (abilities of the next morph are only swapped over when morph is complete) + * Currently used for AbilitySwim to adjust the fog render. + * @return requiresInactiveClone + */ + public boolean requiresInactiveClone() + { + return false; + } + /** * Saving of ability to NBTTagCompound. * Mainly used for synching Abilities between the client-server for mod mobs which do not use the API to add abilities. * The ability type (getType()) is appended to nbt before function is called. - * Not actually used. + * Not actually used. * @param NBTTagCompound saveData */ public abstract void save(NBTTagCompound tag); - + /** * Loading of ability from NBTTagCompound. * Mainly used to load custom fields from NBT. - * Not actually used. + * Not actually used. * @param NBTTagCompound saveData */ public abstract void load(NBTTagCompound tag); - + /** * Rendering to be done post-render. * EG: Used by AbilitySwim to render air bubbles whilst on land. */ @SideOnly(Side.CLIENT) public abstract void postRender(); - + /** * Icon location for ability. Can be null. * Mod's default icons are 32x32. Can be any resolution though. @@ -126,13 +130,13 @@ public abstract class Ability */ @SideOnly(Side.CLIENT) public abstract ResourceLocation getIcon(); - + @SideOnly(Side.CLIENT) public boolean entityHasAbility(EntityLivingBase living) { return true; } - + /** * Registers the ability so the mod can look up the class when attempting to load Ability save data. * Call this no later than PostInit. @@ -141,9 +145,12 @@ public abstract class Ability */ public static void registerAbility(String name, Class<? extends Ability> clz) { - try { + try + { Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("registerAbility", String.class, Class.class).invoke(null, name, clz); - } catch (Exception e) { + } + catch(final Exception e) + { } } @@ -156,14 +163,17 @@ public abstract class Ability * @param entClass * @param abilities */ - public static void mapAbilities(Class<? extends EntityLivingBase> entClass, Ability...abilities) + public static void mapAbilities(Class<? extends EntityLivingBase> entClass, Ability... abilities) { - try { + try + { Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("mapAbilities", Class.class, Ability[].class).invoke(null, entClass, abilities); - } catch (Exception e) { + } + catch(final Exception e) + { } } - + /** * Superman's kryptonite. * @param Entity class to remove ability from @@ -171,12 +181,15 @@ public abstract class Ability */ public static void removeAbility(Class<? extends EntityLivingBase> entClass, String type) { - try { + try + { Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("removeAbility", Class.class, String.class).invoke(null, entClass, type); - } catch (Exception e) { + } + catch(final Exception e) + { } } - + /** * Checks to see if the entity class has a mapped ability type. * @param entClass @@ -185,24 +198,30 @@ public abstract class Ability */ public static boolean hasAbility(Class<? extends EntityLivingBase> entClass, String type) { - try { - return (Boolean)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("hasAbility", Class.class, String.class).invoke(null, entClass, type); - } catch (Exception e) { + try + { + return (Boolean) Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("hasAbility", Class.class, String.class).invoke(null, entClass, type); + } + catch(final Exception e) + { return false; } } - + /** * Creates an ability by type. - * Check out AbilityHandler to see each Ability type and the parse function in their respective classes for the arguments. + * Check out AbilityHandler to see each Ability type and the parse function in their respective classes for the arguments. * @return */ - public static Ability createNewAbilityByType(String type, String[] arguments) - { - try { - return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("createNewAbilityByType", String.class, String[].class).invoke(null, type, arguments); - } catch (Exception e) { - return null; - } - } + public static Ability createNewAbilityByType(String type, String[] arguments) + { + try + { + return (Ability) Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("createNewAbilityByType", String.class, String[].class).invoke(null, type, arguments); + } + catch(final Exception e) + { + return null; + } + } } diff --git a/src/api/java/morph/api/Api.java b/src/api/java/morph/api/Api.java index 1cfb49d..a02c62f 100644 --- a/src/api/java/morph/api/Api.java +++ b/src/api/java/morph/api/Api.java @@ -9,7 +9,7 @@ import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public final class Api +public final class Api { /** * Returns if a player is has a morph. If morph progress < 1.0F, player is mid-morphing. @@ -19,13 +19,16 @@ public final class Api */ public static boolean hasMorph(String playerName, boolean isClient) { - try { - return (Boolean)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("hasMorph", String.class, boolean.class).invoke(null, playerName, isClient); - } catch (Exception e) { + try + { + return (Boolean) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("hasMorph", String.class, boolean.class).invoke(null, playerName, isClient); + } + catch(final Exception e) + { return false; } } - + /** * Returns morph progression of a player. Time per morph is 80 ticks. * If player does not have a morph, 1.0F will be returned. @@ -34,13 +37,16 @@ public final class Api */ public static float morphProgress(String playerName, boolean isClient) { - try { - return (Float)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("morphProgress", String.class, boolean.class).invoke(null, playerName, isClient); - } catch (Exception e) { + try + { + return (Float) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("morphProgress", String.class, boolean.class).invoke(null, playerName, isClient); + } + catch(final Exception e) + { return 1.0F; } } - + /** * Returns previous entity instance used to render the morph. * If player does not have a previous morph state, null will be returned. @@ -49,9 +55,12 @@ public final class Api */ public static EntityLivingBase getPrevMorphEntity(String playerName, boolean isClient) { - try { - return (EntityLivingBase)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("getPrevMorphEntity", String.class, boolean.class).invoke(null, playerName, isClient); - } catch (Exception e) { + try + { + return (EntityLivingBase) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("getPrevMorphEntity", String.class, boolean.class).invoke(null, playerName, isClient); + } + catch(final Exception e) + { return null; } } @@ -64,13 +73,16 @@ public final class Api */ public static EntityLivingBase getMorphEntity(String playerName, boolean isClient) { - try { - return (EntityLivingBase)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("getMorphEntity", String.class, boolean.class).invoke(null, playerName, isClient); - } catch (Exception e) { + try + { + return (EntityLivingBase) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("getMorphEntity", String.class, boolean.class).invoke(null, playerName, isClient); + } + catch(final Exception e) + { return null; } } - + /** * Blacklists an entity from being morphed into. * Previously saved morphs of the classtype will not be removed. @@ -78,12 +90,15 @@ public final class Api */ public static void blacklistEntity(Class<? extends EntityLivingBase> clz) { - try { + try + { Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("blacklistEntity", Class.class).invoke(null, clz); - } catch (Exception e) { + } + catch(final Exception e) + { } } - + /** * Forces a player to morph into an EntityLivingBase, also adds said entity to the morph list. * Called Serverside only. @@ -93,13 +108,16 @@ public final class Api */ public static boolean forceMorph(EntityPlayerMP player, EntityLivingBase living) { - try { - return (Boolean)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("forceMorph", EntityPlayerMP.class, EntityLivingBase.class).invoke(null, player, living); - } catch (Exception e) { + try + { + return (Boolean) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("forceMorph", EntityPlayerMP.class, EntityLivingBase.class).invoke(null, player, living); + } + catch(final Exception e) + { return false; } } - + /** * Forces a player to demorph. * Called Serverside only. @@ -107,12 +125,15 @@ public final class Api */ public static void forceDemorph(EntityPlayerMP player) { - try { + try + { Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("forceDemorph", EntityPlayerMP.class).invoke(null, player); - } catch (Exception e) { + } + catch(final Exception e) + { } } - + /** * Checks if the entity passed on is a Morph. * If it is, the player name will be passed, else null. @@ -121,25 +142,31 @@ public final class Api */ public static String isEntityAMorph(EntityLivingBase living, boolean isClient) { - try { - return (String)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("isEntityAMorph", EntityLivingBase.class, boolean.class).invoke(null, living, isClient); - } catch (Exception e) { + try + { + return (String) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("isEntityAMorph", EntityLivingBase.class, boolean.class).invoke(null, living, isClient); + } + catch(final Exception e) + { return null; } } - + /** * Allows the rendering of the next player rendered. * Prevents Morph from cancelling the player render event to render the morphed entity. */ public static void allowNextPlayerRender() { - try { + try + { Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("allowNextPlayerRender").invoke(null); - } catch (Exception e) { + } + catch(final Exception e) + { } } - + /** * Returns the black grainy morph skin that overlays the player when the player is morphing * @return Morph Skin Resource Location @@ -147,24 +174,30 @@ public final class Api @SideOnly(Side.CLIENT) public static ResourceLocation getMorphSkinTexture() { - try { - return (ResourceLocation)Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("getMorphSkinTexture").invoke(null); - } catch (Exception e) { + try + { + return (ResourceLocation) Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("getMorphSkinTexture").invoke(null); + } + catch(final Exception e) + { return AbstractClientPlayer.locationStevePng; } } - /** - * Assign a specific arm to a model for rendering in First Person. - * @param model Model which arm you are registering for - * @param arm The arm in a ModelRenderer form. - */ - @SideOnly(Side.CLIENT) - public static void registerArmForModel(ModelBase model, ModelRenderer arm) - { - try { - Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("registerArmForModel", ModelBase.class, ModelRenderer.class).invoke(null, model, arm); - } catch (Exception e) { - } - } + /** + * Assign a specific arm to a model for rendering in First Person. + * @param model Model which arm you are registering for + * @param arm The arm in a ModelRenderer form. + */ + @SideOnly(Side.CLIENT) + public static void registerArmForModel(ModelBase model, ModelRenderer arm) + { + try + { + Class.forName("morph.common.core.ApiHandler").getDeclaredMethod("registerArmForModel", ModelBase.class, ModelRenderer.class).invoke(null, model, arm); + } + catch(final Exception e) + { + } + } } diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java b/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java index 8eff88d..d83db32 100644 --- a/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java +++ b/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java @@ -1,12 +1,12 @@ package powercrystals.minefactoryreloaded.api; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - /** * @author PowerCrystals * @@ -94,18 +94,19 @@ public class FactoryRegistry */ public static void sendMessage(String message, Object value) { - if (!Loader.isModLoaded("MineFactoryReloaded") || - Loader.instance().activeModContainer() == null) + if(!Loader.isModLoaded("MineFactoryReloaded") || Loader.instance().activeModContainer() == null) + { return; + } try { - Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class); + final Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class); m.setAccessible(true); - Constructor<IMCMessage> c = IMCMessage.class.getDeclaredConstructor(String.class, Object.class); + final Constructor<IMCMessage> c = IMCMessage.class.getDeclaredConstructor(String.class, Object.class); c.setAccessible(true); m.invoke(null, Loader.instance().activeModContainer(), "MineFactoryReloaded", c.newInstance(message, value)); } - catch(Exception e) + catch(final Exception e) { e.printStackTrace(); } diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java index d4e620a..1191149 100644 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java +++ b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java @@ -19,17 +19,17 @@ public interface IFactoryHarvestable * @return The block this harvestable instance is managing. */ public Block getPlant(); - + /** * @return The type of harvest the Harvester should perform on this block. */ public HarvestType getHarvestType(); - + /** * @return Whether or not the Harvester should break the block when harvesting. If false, no changes will be performed by the Harvester itself. */ public boolean breakBlock(); - + /** * @param world The world this block is in. * @param harvesterSettings The harvester's current settings. Do not modify these. @@ -39,7 +39,7 @@ public interface IFactoryHarvestable * @return True if this block can be harvested. */ public boolean canBeHarvested(World world, Map<String, Boolean> harvesterSettings, int x, int y, int z); - + /** * @param world The world this block is in. * @param rand A Random instance to use when generating drops. @@ -50,7 +50,7 @@ public interface IFactoryHarvestable * @return The drops generated by breaking this block. For a default implementation, calling Block.getBlockDropped() is usually sufficient. */ public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> harvesterSettings, int x, int y, int z); - + /** * Called before the block is going to be harvested. Usually empty. * @param world The world this block is in. @@ -59,7 +59,7 @@ public interface IFactoryHarvestable * @param z The Z coordinate of the block being harvested. */ public void preHarvest(World world, int x, int y, int z); - + /** * Called after the block is going to be harvested. Used to re-till soil, for example. * @param world The world this block is in. diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java b/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java index 7f5dd7c..84a34a5 100644 --- a/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java +++ b/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java @@ -5,17 +5,20 @@ import net.minecraft.util.WeightedRandom; public class MobDrop extends WeightedRandom.Item { - private ItemStack _stack; - + private final ItemStack _stack; + public MobDrop(int weight, ItemStack stack) { super(weight); _stack = stack; } - + public ItemStack getStack() { - if(_stack == null) return null; + if(_stack == null) + { + return null; + } return _stack.copy(); } } diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java b/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java index 3d075fa..d9b1b55 100644 --- a/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java +++ b/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java @@ -4,11 +4,11 @@ import net.minecraft.item.ItemStack; public class ValuedItem { - public final int value; - public final ItemStack item; - public final String key; - public final Object object; - + public final int value; + public final ItemStack item; + public final String key; + public final Object object; + public ValuedItem(int v, ItemStack i) { value = v; @@ -16,7 +16,7 @@ public class ValuedItem key = null; object = null; } - + public ValuedItem(String v, Object i) { value = -1; @@ -24,12 +24,12 @@ public class ValuedItem key = v; object = i; } - + /** * Presently unused but included so that if they do get used in the future, * people including this in their jar and loading before MFR don't destroy everyone */ - + public ValuedItem(int v, Object i) { value = v; @@ -37,7 +37,7 @@ public class ValuedItem key = null; object = i; } - + public ValuedItem(String v, ItemStack i) { value = -1; @@ -45,7 +45,7 @@ public class ValuedItem key = v; object = null; } - + public ValuedItem(int v, String k, ItemStack i) { value = v; @@ -53,7 +53,7 @@ public class ValuedItem key = k; object = null; } - + public ValuedItem(int v, String k, Object i) { value = v; @@ -61,7 +61,7 @@ public class ValuedItem key = k; object = i; } - + public ValuedItem(int v, String k, ItemStack i, Object o) { value = v; diff --git a/src/api/java/thaumcraft/api/BlockCoordinates.java b/src/api/java/thaumcraft/api/BlockCoordinates.java index 27a28f8..9fb5dd8 100644 --- a/src/api/java/thaumcraft/api/BlockCoordinates.java +++ b/src/api/java/thaumcraft/api/BlockCoordinates.java @@ -5,104 +5,111 @@ import net.minecraft.tileentity.TileEntity; public class BlockCoordinates implements Comparable { - public int x; - - /** the y coordinate */ - public int y; - - /** the z coordinate */ - public int z; - - public BlockCoordinates() {} - - public BlockCoordinates(int par1, int par2, int par3) - { - this.x = par1; - this.y = par2; - this.z = par3; - } - - public BlockCoordinates(TileEntity tile) - { - this.x = tile.xCoord; - this.y = tile.yCoord; - this.z = tile.zCoord; - } - - public BlockCoordinates(BlockCoordinates par1ChunkCoordinates) - { - this.x = par1ChunkCoordinates.x; - this.y = par1ChunkCoordinates.y; - this.z = par1ChunkCoordinates.z; - } - - public boolean equals(Object par1Obj) - { - if (!(par1Obj instanceof BlockCoordinates)) - { - return false; - } - else - { - BlockCoordinates coordinates = (BlockCoordinates)par1Obj; - return this.x == coordinates.x && this.y == coordinates.y && this.z == coordinates.z ; - } - } - - public int hashCode() - { - return this.x + this.y << 8 + this.z << 16; - } - - /** - * Compare the coordinate with another coordinate - */ - public int compareWorldCoordinate(BlockCoordinates par1) - { - return this.y == par1.y ? (this.z == par1.z ? this.x - par1.x : this.z - par1.z) : this.y - par1.y; - } - - public void set(int par1, int par2, int par3, int d) - { - this.x = par1; - this.y = par2; - this.z = par3; - } - - /** - * Returns the squared distance between this coordinates and the coordinates given as argument. - */ - public float getDistanceSquared(int par1, int par2, int par3) - { - float f = (float)(this.x - par1); - float f1 = (float)(this.y - par2); - float f2 = (float)(this.z - par3); - return f * f + f1 * f1 + f2 * f2; - } - - /** - * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. - */ - public float getDistanceSquaredToWorldCoordinates(BlockCoordinates par1ChunkCoordinates) - { - return this.getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); - } - - public int compareTo(Object par1Obj) - { - return this.compareWorldCoordinate((BlockCoordinates)par1Obj); - } - - public void readNBT(NBTTagCompound nbt) { - this.x = nbt.getInteger("b_x"); - this.y = nbt.getInteger("b_y"); - this.z = nbt.getInteger("b_z"); - } - - public void writeNBT(NBTTagCompound nbt) { - nbt.setInteger("b_x",x); - nbt.setInteger("b_y",y); - nbt.setInteger("b_z",z); - } - + public int x; + + /** the y coordinate */ + public int y; + + /** the z coordinate */ + public int z; + + public BlockCoordinates() + { + } + + public BlockCoordinates(int par1, int par2, int par3) + { + x = par1; + y = par2; + z = par3; + } + + public BlockCoordinates(TileEntity tile) + { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + } + + public BlockCoordinates(BlockCoordinates par1ChunkCoordinates) + { + x = par1ChunkCoordinates.x; + y = par1ChunkCoordinates.y; + z = par1ChunkCoordinates.z; + } + + @Override + public boolean equals(Object par1Obj) + { + if(!(par1Obj instanceof BlockCoordinates)) + { + return false; + } + else + { + final BlockCoordinates coordinates = (BlockCoordinates) par1Obj; + return x == coordinates.x && y == coordinates.y && z == coordinates.z; + } + } + + @Override + public int hashCode() + { + return x + y << 8 + z << 16; + } + + /** + * Compare the coordinate with another coordinate + */ + public int compareWorldCoordinate(BlockCoordinates par1) + { + return y == par1.y ? (z == par1.z ? x - par1.x : z - par1.z) : y - par1.y; + } + + public void set(int par1, int par2, int par3, int d) + { + x = par1; + y = par2; + z = par3; + } + + /** + * Returns the squared distance between this coordinates and the coordinates given as argument. + */ + public float getDistanceSquared(int par1, int par2, int par3) + { + final float f = x - par1; + final float f1 = y - par2; + final float f2 = z - par3; + return f * f + f1 * f1 + f2 * f2; + } + + /** + * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. + */ + public float getDistanceSquaredToWorldCoordinates(BlockCoordinates par1ChunkCoordinates) + { + return getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); + } + + @Override + public int compareTo(Object par1Obj) + { + return compareWorldCoordinate((BlockCoordinates) par1Obj); + } + + public void readNBT(NBTTagCompound nbt) + { + x = nbt.getInteger("b_x"); + y = nbt.getInteger("b_y"); + z = nbt.getInteger("b_z"); + } + + public void writeNBT(NBTTagCompound nbt) + { + nbt.setInteger("b_x", x); + nbt.setInteger("b_y", y); + nbt.setInteger("b_z", z); + } + } diff --git a/src/api/java/thaumcraft/api/IArchitect.java b/src/api/java/thaumcraft/api/IArchitect.java index c733af5..ba25d98 100644 --- a/src/api/java/thaumcraft/api/IArchitect.java +++ b/src/api/java/thaumcraft/api/IArchitect.java @@ -6,20 +6,21 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IArchitect { +public interface IArchitect +{ /** * Returns a list of blocks that should be highlighted in world. */ - public ArrayList<BlockCoordinates> getArchitectBlocks(ItemStack stack, World world, - int x, int y, int z, int side, EntityPlayer player); - + public ArrayList<BlockCoordinates> getArchitectBlocks(ItemStack stack, World world, int x, int y, int z, int side, EntityPlayer player); + /** * which axis should be displayed. */ public boolean showAxis(ItemStack stack, World world, EntityPlayer player, int side, EnumAxis axis); - - public enum EnumAxis { + + public enum EnumAxis + { X, // east / west Y, // up / down Z; // north / south diff --git a/src/api/java/thaumcraft/api/IGoggles.java b/src/api/java/thaumcraft/api/IGoggles.java index 2f53d81..743e0e9 100644 --- a/src/api/java/thaumcraft/api/IGoggles.java +++ b/src/api/java/thaumcraft/api/IGoggles.java @@ -12,8 +12,9 @@ import net.minecraft.item.ItemStack; * */ -public interface IGoggles { - +public interface IGoggles +{ + /* * If this method returns true things like block essentia contents will be shown. */ diff --git a/src/api/java/thaumcraft/api/IRepairable.java b/src/api/java/thaumcraft/api/IRepairable.java index 48c6dff..a742f2b 100644 --- a/src/api/java/thaumcraft/api/IRepairable.java +++ b/src/api/java/thaumcraft/api/IRepairable.java @@ -1,13 +1,11 @@ package thaumcraft.api; - - /** * @author Azanor * Items, armor and tools with this interface can receive the Repair enchantment. * Repairs 1 point of durability every 10 seconds (2 for repair II) */ -public interface IRepairable { - +public interface IRepairable +{ } diff --git a/src/api/java/thaumcraft/api/IRepairableExtended.java b/src/api/java/thaumcraft/api/IRepairableExtended.java index 3382712..87e4479 100644 --- a/src/api/java/thaumcraft/api/IRepairableExtended.java +++ b/src/api/java/thaumcraft/api/IRepairableExtended.java @@ -3,15 +3,14 @@ package thaumcraft.api; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - - /** * @author Azanor * Items, armor and tools with this interface can receive the Repair enchantment. * Repairs 1 point of durability every 10 seconds (2 for repair II) */ -public interface IRepairableExtended extends IRepairable { - +public interface IRepairableExtended extends IRepairable +{ + public boolean doRepair(ItemStack stack, EntityPlayer player, int enchantlevel); } diff --git a/src/api/java/thaumcraft/api/IRunicArmor.java b/src/api/java/thaumcraft/api/IRunicArmor.java index 5dd3110..d9ed818 100644 --- a/src/api/java/thaumcraft/api/IRunicArmor.java +++ b/src/api/java/thaumcraft/api/IRunicArmor.java @@ -11,12 +11,12 @@ import net.minecraft.item.ItemStack; * */ -public interface IRunicArmor { - +public interface IRunicArmor +{ + /** * returns how much charge this item can provide. This is the base shielding value - any hardening is stored and calculated internally. */ public int getRunicCharge(ItemStack itemstack); - } diff --git a/src/api/java/thaumcraft/api/IScribeTools.java b/src/api/java/thaumcraft/api/IScribeTools.java index 8800fa5..d6dbb8d 100644 --- a/src/api/java/thaumcraft/api/IScribeTools.java +++ b/src/api/java/thaumcraft/api/IScribeTools.java @@ -1,6 +1,5 @@ package thaumcraft.api; - /** * * @author Azanor @@ -9,6 +8,7 @@ package thaumcraft.api; * */ -public interface IScribeTools { - +public interface IScribeTools +{ + } diff --git a/src/api/java/thaumcraft/api/IVisDiscountGear.java b/src/api/java/thaumcraft/api/IVisDiscountGear.java index 3793ea3..6032b07 100644 --- a/src/api/java/thaumcraft/api/IVisDiscountGear.java +++ b/src/api/java/thaumcraft/api/IVisDiscountGear.java @@ -4,17 +4,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.Aspect; - - - /** * @author Azanor * ItemArmor with this interface will grant a discount to the vis cost of actions the wearer performs with casting wands. * The amount returned is the percentage by which the cost is discounted. There is a built-int max discount of 50%, but * individual items really shouldn't have a discount more than 5% */ -public interface IVisDiscountGear { - +public interface IVisDiscountGear +{ + int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect); } diff --git a/src/api/java/thaumcraft/api/IWarpingGear.java b/src/api/java/thaumcraft/api/IWarpingGear.java index e7415ab..674054f 100644 --- a/src/api/java/thaumcraft/api/IWarpingGear.java +++ b/src/api/java/thaumcraft/api/IWarpingGear.java @@ -11,12 +11,12 @@ import net.minecraft.item.ItemStack; * */ -public interface IWarpingGear { - +public interface IWarpingGear +{ + /** * returns how much warp this item adds while worn or held. */ public int getWarp(ItemStack itemstack, EntityPlayer player); - } diff --git a/src/api/java/thaumcraft/api/ItemApi.java b/src/api/java/thaumcraft/api/ItemApi.java index 25dda28..3aea4f1 100644 --- a/src/api/java/thaumcraft/api/ItemApi.java +++ b/src/api/java/thaumcraft/api/ItemApi.java @@ -13,38 +13,53 @@ import cpw.mods.fml.common.FMLLog; * require a bit of work for you to get hold of everything you need. * */ -public class ItemApi { - - public static ItemStack getItem(String itemString, int meta) { +public class ItemApi +{ + + public static ItemStack getItem(String itemString, int meta) + { ItemStack item = null; - try { - String itemClass = "thaumcraft.common.config.ConfigItems"; - Object obj = Class.forName(itemClass).getField(itemString).get(null); - if (obj instanceof Item) { - item = new ItemStack((Item) obj,1,meta); - } else if (obj instanceof ItemStack) { + try + { + final String itemClass = "thaumcraft.common.config.ConfigItems"; + final Object obj = Class.forName(itemClass).getField(itemString).get(null); + if(obj instanceof Item) + { + item = new ItemStack((Item) obj, 1, meta); + } + else if(obj instanceof ItemStack) + { item = (ItemStack) obj; } - } catch (Exception ex) { + } + catch(final Exception ex) + { FMLLog.warning("[Thaumcraft] Could not retrieve item identified by: " + itemString); } return item; } - - public static ItemStack getBlock(String itemString, int meta) { + + public static ItemStack getBlock(String itemString, int meta) + { ItemStack item = null; - try { - String itemClass = "thaumcraft.common.config.ConfigBlocks"; - Object obj = Class.forName(itemClass).getField(itemString).get(null); - if (obj instanceof Block) { - item = new ItemStack((Block) obj,1,meta); - } else if (obj instanceof ItemStack) { + try + { + final String itemClass = "thaumcraft.common.config.ConfigBlocks"; + final Object obj = Class.forName(itemClass).getField(itemString).get(null); + if(obj instanceof Block) + { + item = new ItemStack((Block) obj, 1, meta); + } + else if(obj instanceof ItemStack) + { item = (ItemStack) obj; } - } catch (Exception ex) { + } + catch(final Exception ex) + { FMLLog.warning("[Thaumcraft] Could not retrieve block identified by: " + itemString); } diff --git a/src/api/java/thaumcraft/api/ItemRunic.java b/src/api/java/thaumcraft/api/ItemRunic.java index 80251f5..3517558 100644 --- a/src/api/java/thaumcraft/api/ItemRunic.java +++ b/src/api/java/thaumcraft/api/ItemRunic.java @@ -3,19 +3,21 @@ package thaumcraft.api; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemRunic extends Item implements IRunicArmor { - - int charge; - - public ItemRunic (int charge) - { - super(); - this.charge = charge; - } - +public class ItemRunic extends Item implements IRunicArmor +{ + + int charge; + + public ItemRunic(int charge) + { + super(); + this.charge = charge; + } + @Override - public int getRunicCharge(ItemStack itemstack) { + public int getRunicCharge(ItemStack itemstack) + { return charge; } - + } diff --git a/src/api/java/thaumcraft/api/ThaumcraftApi.java b/src/api/java/thaumcraft/api/ThaumcraftApi.java index fbf7880..c01d521 100644 --- a/src/api/java/thaumcraft/api/ThaumcraftApi.java +++ b/src/api/java/thaumcraft/api/ThaumcraftApi.java @@ -31,7 +31,6 @@ import thaumcraft.api.research.ResearchCategoryList; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; - /** * @author Azanor * @@ -39,66 +38,76 @@ import thaumcraft.api.research.ResearchPage; * IMPORTANT: If you are adding your own aspects to items it is a good idea to do it AFTER Thaumcraft adds its aspects, otherwise odd things may happen. * */ -public class ThaumcraftApi { - +public class ThaumcraftApi +{ + //Materials - public static ToolMaterial toolMatThaumium = EnumHelper.addToolMaterial("THAUMIUM", 3, 400, 7F, 2, 22); - public static ToolMaterial toolMatVoid = EnumHelper.addToolMaterial("VOID", 4, 150, 8F, 3, 10); - public static ToolMaterial toolMatElemental = EnumHelper.addToolMaterial("THAUMIUM_ELEMENTAL", 3, 1500, 10F, 3, 18); - public static ArmorMaterial armorMatThaumium = EnumHelper.addArmorMaterial("THAUMIUM", 25, new int[] { 2, 6, 5, 2 }, 25); - public static ArmorMaterial armorMatSpecial = EnumHelper.addArmorMaterial("SPECIAL", 25, new int[] { 1, 3, 2, 1 }, 25); - public static ArmorMaterial armorMatThaumiumFortress = EnumHelper.addArmorMaterial("FORTRESS", 40, new int[] { 3, 7, 6, 3 }, 25); - public static ArmorMaterial armorMatVoid = EnumHelper.addArmorMaterial("VOID", 10, new int[] { 3, 7, 6, 3 }, 10); - public static ArmorMaterial armorMatVoidFortress = EnumHelper.addArmorMaterial("VOIDFORTRESS", 18, new int[] { 4, 8, 7, 4 }, 10); - + public static ToolMaterial toolMatThaumium = EnumHelper.addToolMaterial("THAUMIUM", 3, 400, 7F, 2, 22); + public static ToolMaterial toolMatVoid = EnumHelper.addToolMaterial("VOID", 4, 150, 8F, 3, 10); + public static ToolMaterial toolMatElemental = EnumHelper.addToolMaterial("THAUMIUM_ELEMENTAL", 3, 1500, 10F, 3, 18); + public static ArmorMaterial armorMatThaumium = EnumHelper.addArmorMaterial("THAUMIUM", 25, new int[] {2, 6, 5, 2}, 25); + public static ArmorMaterial armorMatSpecial = EnumHelper.addArmorMaterial("SPECIAL", 25, new int[] {1, 3, 2, 1}, 25); + public static ArmorMaterial armorMatThaumiumFortress = EnumHelper.addArmorMaterial("FORTRESS", 40, new int[] {3, 7, 6, 3}, 25); + public static ArmorMaterial armorMatVoid = EnumHelper.addArmorMaterial("VOID", 10, new int[] {3, 7, 6, 3}, 10); + public static ArmorMaterial armorMatVoidFortress = EnumHelper.addArmorMaterial("VOIDFORTRESS", 18, new int[] {4, 8, 7, 4}, 10); + //Enchantment references - public static int enchantFrugal; - public static int enchantPotency; - public static int enchantWandFortune; - public static int enchantHaste; - public static int enchantRepair; - + public static int enchantFrugal; + public static int enchantPotency; + public static int enchantWandFortune; + public static int enchantHaste; + public static int enchantRepair; + //Miscellaneous /** * Portable Hole Block-id Blacklist. * Simply add the block-id's of blocks you don't want the portable hole to go through. */ - public static ArrayList<Block> portableHoleBlackList = new ArrayList<Block>(); - + public static ArrayList<Block> portableHoleBlackList = new ArrayList<Block>(); + //Internal (Do not alter this unless you like pretty explosions) //Calling methods from this will only work properly once Thaumcraft is past the FMLPreInitializationEvent phase. - public static IInternalMethodHandler internalMethods = new DummyInternalMethodHandler(); - + public static IInternalMethodHandler internalMethods = new DummyInternalMethodHandler(); + //RESEARCH///////////////////////////////////////// - public static ArrayList<IScanEventHandler> scanEventhandlers = new ArrayList<IScanEventHandler>(); - public static ArrayList<EntityTags> scanEntities = new ArrayList<EntityTags>(); - public static class EntityTagsNBT { - public EntityTagsNBT(String name, Object value) { + public static ArrayList<IScanEventHandler> scanEventhandlers = new ArrayList<IScanEventHandler>(); + public static ArrayList<EntityTags> scanEntities = new ArrayList<EntityTags>(); + + public static class EntityTagsNBT + { + public EntityTagsNBT(String name, Object value) + { this.name = name; this.value = value; } - public String name; - public Object value; + + public String name; + public Object value; } - public static class EntityTags { - public EntityTags(String entityName, AspectList aspects, EntityTagsNBT... nbts) { + + public static class EntityTags + { + public EntityTags(String entityName, AspectList aspects, EntityTagsNBT... nbts) + { this.entityName = entityName; this.nbts = nbts; this.aspects = aspects; } - public String entityName; - public EntityTagsNBT[] nbts; - public AspectList aspects; + + public String entityName; + public EntityTagsNBT[] nbts; + public AspectList aspects; } - + /** * not really working atm, so ignore it for now * @param scanEventHandler */ - public static void registerScanEventhandler(IScanEventHandler scanEventHandler) { + public static void registerScanEventhandler(IScanEventHandler scanEventHandler) + { scanEventhandlers.add(scanEventHandler); } - + /** * This is used to add aspects to entities which you can then scan using a thaumometer. * Also used to calculate vis drops from mobs. @@ -109,83 +118,92 @@ public class ThaumcraftApi { * <br>ThaumcraftApi.registerEntityTag("Skeleton", (new AspectList()).add(Aspect.DEATH, 5)); * <br>ThaumcraftApi.registerEntityTag("Skeleton", (new AspectList()).add(Aspect.DEATH, 8), new NBTTagByte("SkeletonType",(byte) 1)); */ - public static void registerEntityTag(String entityName, AspectList aspects, EntityTagsNBT... nbt ) { - scanEntities.add(new EntityTags(entityName,aspects,nbt)); + public static void registerEntityTag(String entityName, AspectList aspects, EntityTagsNBT... nbt) + { + scanEntities.add(new EntityTags(entityName, aspects, nbt)); } - + //RECIPES///////////////////////////////////////// - private static ArrayList craftingRecipes = new ArrayList(); - private static HashMap<Object,ItemStack> smeltingBonus = new HashMap<Object,ItemStack>(); - + private static ArrayList craftingRecipes = new ArrayList(); + private static HashMap<Object, ItemStack> smeltingBonus = new HashMap<Object, ItemStack>(); + /** * This method is used to determine what bonus items are generated when the infernal furnace smelts items * @param in The input of the smelting operation. e.g. new ItemStack(Block.oreGold) * @param out The bonus item that can be produced from the smelting operation e.g. new ItemStack(nuggetGold,0,0). * Stacksize should be 0 unless you want to guarantee that at least 1 item is always produced. */ - public static void addSmeltingBonus(ItemStack in, ItemStack out) { - smeltingBonus.put( - Arrays.asList(in.getItem(),in.getItemDamage()), - new ItemStack(out.getItem(),0,out.getItemDamage())); + public static void addSmeltingBonus(ItemStack in, ItemStack out) + { + smeltingBonus.put(Arrays.asList(in.getItem(), in.getItemDamage()), new ItemStack( + out.getItem(), 0, out.getItemDamage())); } - + /** * This method is used to determine what bonus items are generated when the infernal furnace smelts items * @param in The ore dictionary input of the smelting operation. e.g. "oreGold" * @param out The bonus item that can be produced from the smelting operation e.g. new ItemStack(nuggetGold,0,0). * Stacksize should be 0 unless you want to guarantee that at least 1 item is always produced. */ - public static void addSmeltingBonus(String in, ItemStack out) { - smeltingBonus.put( in, new ItemStack(out.getItem(),0,out.getItemDamage())); + public static void addSmeltingBonus(String in, ItemStack out) + { + smeltingBonus.put(in, new ItemStack(out.getItem(), 0, + out.getItemDamage())); } - + /** * Returns the bonus item produced from a smelting operation in the infernal furnace * @param in The input of the smelting operation. e.g. new ItemStack(oreGold) * @return the The bonus item that can be produced */ - public static ItemStack getSmeltingBonus(ItemStack in) { - ItemStack out = smeltingBonus.get(Arrays.asList(in.getItem(),in.getItemDamage())); - if (out==null) { - out = smeltingBonus.get(Arrays.asList(in.getItem(),OreDictionary.WILDCARD_VALUE)); + public static ItemStack getSmeltingBonus(ItemStack in) + { + ItemStack out = smeltingBonus.get(Arrays.asList(in.getItem(), in.getItemDamage())); + if(out == null) + { + out = smeltingBonus.get(Arrays.asList(in.getItem(), OreDictionary.WILDCARD_VALUE)); } - if (out==null) { - String od = OreDictionary.getOreName( OreDictionary.getOreID(in)); + if(out == null) + { + final String od = OreDictionary.getOreName(OreDictionary.getOreID(in)); out = smeltingBonus.get(od); } return out; } - - public static List getCraftingRecipes() { + + public static List getCraftingRecipes() + { return craftingRecipes; } - + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param result the recipe output * @param aspects the vis cost per aspect. * @param recipe The recipe. Format is exactly the same as vanilla recipes. Input itemstacks are NBT sensitive. */ - public static ShapedArcaneRecipe addArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object ... recipe) - { - ShapedArcaneRecipe r= new ShapedArcaneRecipe(research, result, aspects, recipe); - craftingRecipes.add(r); + public static ShapedArcaneRecipe addArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + final ShapedArcaneRecipe r = new ShapedArcaneRecipe(research, result, + aspects, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param result the recipe output * @param aspects the vis cost per aspect * @param recipe The recipe. Format is exactly the same as vanilla shapeless recipes. Input itemstacks are NBT sensitive. */ - public static ShapelessArcaneRecipe addShapelessArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object ... recipe) - { - ShapelessArcaneRecipe r = new ShapelessArcaneRecipe(research, result, aspects, recipe); - craftingRecipes.add(r); + public static ShapelessArcaneRecipe addShapelessArcaneCraftingRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + final ShapelessArcaneRecipe r = new ShapelessArcaneRecipe(research, result, + aspects, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param result the recipe output. It can either be an itemstack or an nbt compound tag that will be added to the central item @@ -197,14 +215,18 @@ public class ThaumcraftApi { * Infusion crafting components are automatically "fuzzy" and the oredict will be checked for possible matches. * */ - public static InfusionRecipe addInfusionCraftingRecipe(String research, Object result, int instability, AspectList aspects, ItemStack input,ItemStack[] recipe) - { - if (!(result instanceof ItemStack || result instanceof Object[])) return null; - InfusionRecipe r= new InfusionRecipe(research, result, instability, aspects, input, recipe); - craftingRecipes.add(r); + public static InfusionRecipe addInfusionCraftingRecipe(String research, Object result, int instability, AspectList aspects, ItemStack input, ItemStack[] recipe) + { + if(!(result instanceof ItemStack || result instanceof Object[])) + { + return null; + } + final InfusionRecipe r = new InfusionRecipe(research, result, instability, + aspects, input, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param research the research key required for this recipe to work. Leave blank if it will work without research * @param enchantment the enchantment that will be applied to the item @@ -216,158 +238,214 @@ public class ThaumcraftApi { * */ public static InfusionEnchantmentRecipe addInfusionEnchantmentRecipe(String research, Enchantment enchantment, int instability, AspectList aspects, ItemStack[] recipe) - { - InfusionEnchantmentRecipe r= new InfusionEnchantmentRecipe(research, enchantment, instability, aspects, recipe); - craftingRecipes.add(r); + { + final InfusionEnchantmentRecipe r = new InfusionEnchantmentRecipe(research, + enchantment, instability, aspects, recipe); + craftingRecipes.add(r); return r; - } - + } + /** * @param stack the recipe result * @return the recipe */ - public static InfusionRecipe getInfusionRecipe(ItemStack res) { - for (Object r:getCraftingRecipes()) { - if (r instanceof InfusionRecipe) { - if (((InfusionRecipe)r).getRecipeOutput() instanceof ItemStack) { - if (((ItemStack) ((InfusionRecipe)r).getRecipeOutput()).isItemEqual(res)) - return (InfusionRecipe)r; - } + public static InfusionRecipe getInfusionRecipe(ItemStack res) + { + for(final Object r : getCraftingRecipes()) + { + if(r instanceof InfusionRecipe) + { + if(((InfusionRecipe) r).getRecipeOutput() instanceof ItemStack) + { + if(((ItemStack) ((InfusionRecipe) r).getRecipeOutput()).isItemEqual(res)) + { + return (InfusionRecipe) r; + } + } } } return null; } - - /** - * @param key the research key required for this recipe to work. - * @param result the output result - * @param catalyst an itemstack of the catalyst or a string if it is an ore dictionary item - * @param cost the vis cost - * @param tags the aspects required to craft this - */ - public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) { - CrucibleRecipe rc = new CrucibleRecipe(key, result, catalyst, tags); - getCraftingRecipes().add(rc); + /** + * @param key the research key required for this recipe to work. + * @param result the output result + * @param catalyst an itemstack of the catalyst or a string if it is an ore dictionary item + * @param cost the vis cost + * @param tags the aspects required to craft this + */ + public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) + { + final CrucibleRecipe rc = new CrucibleRecipe(key, result, catalyst, tags); + getCraftingRecipes().add(rc); return rc; } - - + /** * @param stack the recipe result * @return the recipe */ - public static CrucibleRecipe getCrucibleRecipe(ItemStack stack) { - for (Object r:getCraftingRecipes()) { - if (r instanceof CrucibleRecipe) { - if (((CrucibleRecipe)r).getRecipeOutput().isItemEqual(stack)) - return (CrucibleRecipe)r; + public static CrucibleRecipe getCrucibleRecipe(ItemStack stack) + { + for(final Object r : getCraftingRecipes()) + { + if(r instanceof CrucibleRecipe) + { + if(((CrucibleRecipe) r).getRecipeOutput().isItemEqual(stack)) + { + return (CrucibleRecipe) r; + } } } return null; } - + /** * @param hash the unique recipe code * @return the recipe */ - public static CrucibleRecipe getCrucibleRecipeFromHash(int hash) { - for (Object r:getCraftingRecipes()) { - if (r instanceof CrucibleRecipe) { - if (((CrucibleRecipe)r).hash==hash) - return (CrucibleRecipe)r; + public static CrucibleRecipe getCrucibleRecipeFromHash(int hash) + { + for(final Object r : getCraftingRecipes()) + { + if(r instanceof CrucibleRecipe) + { + if(((CrucibleRecipe) r).hash == hash) + { + return (CrucibleRecipe) r; + } } } return null; } - + /** * Used by the thaumonomicon drilldown feature. * @param stack the item * @return the thaumcraft recipe key that produces that item. */ - private static HashMap<int[],Object[]> keyCache = new HashMap<int[],Object[]>(); - - public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) { - int[] key = new int[] {Item.getIdFromItem(stack.getItem()),stack.getItemDamage()}; - if (keyCache.containsKey(key)) { - if (keyCache.get(key)==null) return null; - if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String)(keyCache.get(key))[0])) + private static HashMap<int[], Object[]> keyCache = new HashMap<int[], Object[]>(); + + public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) + { + final int[] key = new int[] {Item.getIdFromItem(stack.getItem()), stack.getItemDamage()}; + if(keyCache.containsKey(key)) + { + if(keyCache.get(key) == null) + { + return null; + } + if(ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String) (keyCache.get(key))[0])) + { return keyCache.get(key); - else + } + else + { return null; + } } - for (ResearchCategoryList rcl:ResearchCategories.researchCategories.values()) { - for (ResearchItem ri:rcl.research.values()) { - if (ri.getPages()==null) continue; - for (int a=0;a<ri.getPages().length;a++) { - ResearchPage page = ri.getPages()[a]; - if (page.recipe!=null && page.recipe instanceof CrucibleRecipe[]) { - CrucibleRecipe[] crs = (CrucibleRecipe[]) page.recipe; - for (CrucibleRecipe cr:crs) { - if (cr.getRecipeOutput().isItemEqual(stack)) { - keyCache.put(key,new Object[] {ri.key,a}); - if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) - return new Object[] {ri.key,a}; + for(final ResearchCategoryList rcl : ResearchCategories.researchCategories.values()) + { + for(final ResearchItem ri : rcl.research.values()) + { + if(ri.getPages() == null) + { + continue; + } + for(int a = 0; a < ri.getPages().length; a++) + { + final ResearchPage page = ri.getPages()[a]; + if(page.recipe != null && page.recipe instanceof CrucibleRecipe[]) + { + final CrucibleRecipe[] crs = (CrucibleRecipe[]) page.recipe; + for(final CrucibleRecipe cr : crs) + { + if(cr.getRecipeOutput().isItemEqual(stack)) + { + keyCache.put(key, new Object[] {ri.key, a}); + if(ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) + { + return new Object[] {ri.key, a}; + } } } - } else - if (page.recipeOutput!=null && stack !=null && page.recipeOutput.isItemEqual(stack)) { - keyCache.put(key,new Object[] {ri.key,a}); - if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) - return new Object[] {ri.key,a}; - else + } + else if(page.recipeOutput != null && stack != null && page.recipeOutput.isItemEqual(stack)) + { + keyCache.put(key, new Object[] {ri.key, a}); + if(ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) + { + return new Object[] {ri.key, a}; + } + else + { return null; + } } } } } - keyCache.put(key,null); + keyCache.put(key, null); return null; } - + //ASPECTS//////////////////////////////////////// - - public static ConcurrentHashMap<List,AspectList> objectTags = new ConcurrentHashMap<List,AspectList>(); - public static ConcurrentHashMap<List,int[]> groupedObjectTags = new ConcurrentHashMap<List,int[]>(); - + + public static ConcurrentHashMap<List, AspectList> objectTags = new ConcurrentHashMap<List, AspectList>(); + public static ConcurrentHashMap<List, int[]> groupedObjectTags = new ConcurrentHashMap<List, int[]>(); + /** * Checks to see if the passed item/block already has aspects associated with it. * @param id * @param meta * @return */ - public static boolean exists(Item item, int meta) { - AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,meta)); - if (tmp==null) { - tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,OreDictionary.WILDCARD_VALUE)); - if (meta==OreDictionary.WILDCARD_VALUE && tmp==null) { - int index=0; - do { - tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,index)); + public static boolean exists(Item item, int meta) + { + AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item, meta)); + if(tmp == null) + { + tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item, OreDictionary.WILDCARD_VALUE)); + if(meta == OreDictionary.WILDCARD_VALUE && tmp == null) + { + int index = 0; + do + { + tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item, index)); index++; - } while (index<16 && tmp==null); + } + while(index < 16 && tmp == null); + } + if(tmp == null) + { + return false; } - if (tmp==null) return false; } - + return true; } - + /** * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:<p> * <i>ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));</i> * @param item the item passed. Pass OreDictionary.WILDCARD_VALUE if all damage values of this item/block should have the same aspects * @param aspects A ObjectTags object of the associated aspects */ - public static void registerObjectTag(ItemStack item, AspectList aspects) { - if (aspects==null) aspects=new AspectList(); - try { - objectTags.put(Arrays.asList(item.getItem(),item.getItemDamage()), aspects); - } catch (Exception e) {} - } - - + public static void registerObjectTag(ItemStack item, AspectList aspects) + { + if(aspects == null) + { + aspects = new AspectList(); + } + try + { + objectTags.put(Arrays.asList(item.getItem(), item.getItemDamage()), aspects); + } + catch(final Exception e) + { + } + } + /** * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:<p> * <i>ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), new int[]{0,1}, (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));</i> @@ -375,34 +453,53 @@ public class ThaumcraftApi { * @param meta A range of meta values if you wish to lump several item meta's together as being the "same" item (i.e. stair orientations) * @param aspects A ObjectTags object of the associated aspects */ - public static void registerObjectTag(ItemStack item, int[] meta, AspectList aspects) { - if (aspects==null) aspects=new AspectList(); - try { - objectTags.put(Arrays.asList(item.getItem(),meta[0]), aspects); - for (int m:meta) { - groupedObjectTags.put(Arrays.asList(item.getItem(),m), meta); + public static void registerObjectTag(ItemStack item, int[] meta, AspectList aspects) + { + if(aspects == null) + { + aspects = new AspectList(); + } + try + { + objectTags.put(Arrays.asList(item.getItem(), meta[0]), aspects); + for(final int m : meta) + { + groupedObjectTags.put(Arrays.asList(item.getItem(), m), meta); } - - } catch (Exception e) {} + + } + catch(final Exception e) + { + } } - + /** * Used to assign apsects to the given ore dictionary item. * @param oreDict the ore dictionary name * @param aspects A ObjectTags object of the associated aspects */ - public static void registerObjectTag(String oreDict, AspectList aspects) { - if (aspects==null) aspects=new AspectList(); - ArrayList<ItemStack> ores = OreDictionary.getOres(oreDict); - if (ores!=null && ores.size()>0) { - for (ItemStack ore:ores) { - try { - objectTags.put(Arrays.asList(ore.getItem(), ore.getItemDamage()), aspects); - } catch (Exception e) {} + public static void registerObjectTag(String oreDict, AspectList aspects) + { + if(aspects == null) + { + aspects = new AspectList(); + } + final ArrayList<ItemStack> ores = OreDictionary.getOres(oreDict); + if(ores != null && ores.size() > 0) + { + for(final ItemStack ore : ores) + { + try + { + objectTags.put(Arrays.asList(ore.getItem(), ore.getItemDamage()), aspects); + } + catch(final Exception e) + { + } } } } - + /** * Used to assign aspects to the given item/block. * Attempts to automatically generate aspect tags by checking registered recipes. @@ -412,90 +509,121 @@ public class ThaumcraftApi { * @param item, pass OreDictionary.WILDCARD_VALUE to meta if all damage values of this item/block should have the same aspects * @param aspects A ObjectTags object of the associated aspects */ - public static void registerComplexObjectTag(ItemStack item, AspectList aspects ) { - if (!exists(item.getItem(),item.getItemDamage())) { - AspectList tmp = ThaumcraftApiHelper.generateTags(item.getItem(), item.getItemDamage()); - if (tmp != null && tmp.size()>0) { - for(Aspect tag:tmp.getAspects()) { + public static void registerComplexObjectTag(ItemStack item, AspectList aspects) + { + if(!exists(item.getItem(), item.getItemDamage())) + { + final AspectList tmp = ThaumcraftApiHelper.generateTags(item.getItem(), item.getItemDamage()); + if(tmp != null && tmp.size() > 0) + { + for(final Aspect tag : tmp.getAspects()) + { aspects.add(tag, tmp.getAmount(tag)); } } - registerObjectTag(item,aspects); - } else { - AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item); - for(Aspect tag:aspects.getAspects()) { + registerObjectTag(item, aspects); + } + else + { + final AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item); + for(final Aspect tag : aspects.getAspects()) + { tmp.merge(tag, tmp.getAmount(tag)); } - registerObjectTag(item,tmp); + registerObjectTag(item, tmp); } } - + //WARP /////////////////////////////////////////////////////////////////////////////////////// - private static HashMap<Object,Integer> warpMap = new HashMap<Object,Integer>(); - - /** - * This method is used to determine how much warp is gained if the item is crafted. The warp - * added is "sticky" warp - * @param craftresult The item crafted - * @param amount how much warp is gained - */ - public static void addWarpToItem(ItemStack craftresult, int amount) { - warpMap.put(Arrays.asList(craftresult.getItem(),craftresult.getItemDamage()),amount); + private static HashMap<Object, Integer> warpMap = new HashMap<Object, Integer>(); + + /** + * This method is used to determine how much warp is gained if the item is crafted. The warp + * added is "sticky" warp + * @param craftresult The item crafted + * @param amount how much warp is gained + */ + public static void addWarpToItem(ItemStack craftresult, int amount) + { + warpMap.put(Arrays.asList(craftresult.getItem(), craftresult.getItemDamage()), amount); + } + + /** + * This method is used to determine how much permanent warp is gained if the research is completed + * @param in The item crafted + * @param amount how much warp is gained + */ + public static void addWarpToResearch(String research, int amount) + { + warpMap.put(research, amount); + } + + /** + * Returns how much warp is gained from the item or research passed in + * @param in itemstack or string + * @return how much warp it will give + */ + public static int getWarp(Object in) + { + if(in == null) + { + return 0; } - - /** - * This method is used to determine how much permanent warp is gained if the research is completed - * @param in The item crafted - * @param amount how much warp is gained - */ - public static void addWarpToResearch(String research, int amount) { - warpMap.put(research, amount); + if(in instanceof ItemStack && warpMap.containsKey(Arrays.asList(((ItemStack) in).getItem(), ((ItemStack) in).getItemDamage()))) + { + return warpMap.get(Arrays.asList(((ItemStack) in).getItem(), ((ItemStack) in).getItemDamage())); } - - /** - * Returns how much warp is gained from the item or research passed in - * @param in itemstack or string - * @return how much warp it will give - */ - public static int getWarp(Object in) { - if (in==null) return 0; - if (in instanceof ItemStack && warpMap.containsKey(Arrays.asList(((ItemStack)in).getItem(),((ItemStack)in).getItemDamage()))) { - return warpMap.get(Arrays.asList(((ItemStack)in).getItem(),((ItemStack)in).getItemDamage())); - } else - if (in instanceof String && warpMap.containsKey((String)in)) { - return warpMap.get((String)in); - } - return 0; + else if(in instanceof String && warpMap.containsKey(in)) + { + return warpMap.get(in); } - + return 0; + } + //LOOT BAGS ////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Used to add possible loot to treasure bags. As a reference, the weight of gold coins are 2000 - * and a diamond is 50. - * The weights are the same for all loot bag types - the only difference is how many items the bag - * contains. - * @param item - * @param weight - * @param bagTypes array of which type of bag to add this loot to. Multiple types can be specified - * 0 = common, 1 = uncommon, 2 = rare - */ - public static void addLootBagItem(ItemStack item, int weight, int... bagTypes) { - if (bagTypes==null || bagTypes.length==0) - WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot(item,weight)); - else { - for (int rarity:bagTypes) { - switch(rarity) { - case 0: WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot(item,weight)); break; - case 1: WeightedRandomLoot.lootBagUncommon.add(new WeightedRandomLoot(item,weight)); break; - case 2: WeightedRandomLoot.lootBagRare.add(new WeightedRandomLoot(item,weight)); break; - } + + /** + * Used to add possible loot to treasure bags. As a reference, the weight of gold coins are 2000 + * and a diamond is 50. + * The weights are the same for all loot bag types - the only difference is how many items the bag + * contains. + * @param item + * @param weight + * @param bagTypes array of which type of bag to add this loot to. Multiple types can be specified + * 0 = common, 1 = uncommon, 2 = rare + */ + public static void addLootBagItem(ItemStack item, int weight, int... bagTypes) + { + if(bagTypes == null || bagTypes.length == 0) + { + WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot(item, + weight)); + } + else + { + for(final int rarity : bagTypes) + { + switch(rarity) + { + case 0: + WeightedRandomLoot.lootBagCommon.add(new WeightedRandomLoot( + item, weight)); + break; + case 1: + WeightedRandomLoot.lootBagUncommon.add(new WeightedRandomLoot( + item, weight)); + break; + case 2: + WeightedRandomLoot.lootBagRare.add(new WeightedRandomLoot( + item, weight)); + break; } } } - + } + //CROPS ////////////////////////////////////////////////////////////////////////////////////////// - + /** * To define mod crops you need to use FMLInterModComms in your @Mod.Init method. * There are two 'types' of crops you can add. Standard crops and clickable crops. @@ -522,9 +650,9 @@ public class ThaumcraftApi { * Example: * FMLInterModComms.sendMessage("Thaumcraft", "harvestStackedCrop", new ItemStack(Block.reed,1,7)); */ - + //NATIVE CLUSTERS ////////////////////////////////////////////////////////////////////////////////// - + /** * You can define certain ores that will have a chance to produce native clusters via FMLInterModComms * in your @Mod.Init method using the "nativeCluster" string message. @@ -536,7 +664,7 @@ public class ThaumcraftApi { * Example for vanilla iron ore to produce one of my own native iron clusters (assuming default id's) at double the default chance: * FMLInterModComms.sendMessage("Thaumcraft", "nativeCluster","15,0,25016,16,2.0"); */ - + //LAMP OF GROWTH BLACKLIST /////////////////////////////////////////////////////////////////////////// /** * You can blacklist crops that should not be effected by the Lamp of Growth via FMLInterModComms @@ -545,7 +673,7 @@ public class ThaumcraftApi { * Example for vanilla wheat: * FMLInterModComms.sendMessage("Thaumcraft", "lampBlacklist", new ItemStack(Block.crops,1,OreDictionary.WILDCARD_VALUE)); */ - + //DIMENSION BLACKLIST /////////////////////////////////////////////////////////////////////////// /** * You can blacklist a dimension to not spawn certain thaumcraft features @@ -558,7 +686,7 @@ public class ThaumcraftApi { * Example: * FMLInterModComms.sendMessage("Thaumcraft", "dimensionBlacklist", "15:1"); */ - + //BIOME BLACKLIST /////////////////////////////////////////////////////////////////////////// /** * You can blacklist a biome to not spawn certain thaumcraft features @@ -571,7 +699,7 @@ public class ThaumcraftApi { * Example: * FMLInterModComms.sendMessage("Thaumcraft", "biomeBlacklist", "180:2"); */ - + //CHAMPION MOB WHITELIST /////////////////////////////////////////////////////////////////////////// /** * You can whitelist an entity class so it can rarely spawn champion versions in your @Mod.Init method using diff --git a/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java b/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java index 77d5588..83ac4d2 100644 --- a/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java +++ b/src/api/java/thaumcraft/api/ThaumcraftApiHelper.java @@ -19,181 +19,236 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.IEssentiaTransport; -public class ThaumcraftApiHelper { - - public static AspectList cullTags(AspectList temp) { - AspectList temp2 = new AspectList(); - for (Aspect tag:temp.getAspects()) { - if (tag!=null) +public class ThaumcraftApiHelper +{ + + public static AspectList cullTags(AspectList temp) + { + final AspectList temp2 = new AspectList(); + for(final Aspect tag : temp.getAspects()) + { + if(tag != null) + { temp2.add(tag, temp.getAmount(tag)); + } } - while (temp2!=null && temp2.size()>6) { + while(temp2 != null && temp2.size() > 6) + { Aspect lowest = null; float low = Short.MAX_VALUE; - for (Aspect tag:temp2.getAspects()) { - if (tag==null) continue; - float ta=temp2.getAmount(tag); - if (tag.isPrimal()) { + for(final Aspect tag : temp2.getAspects()) + { + if(tag == null) + { + continue; + } + float ta = temp2.getAmount(tag); + if(tag.isPrimal()) + { ta *= .9f; - } else { - if (!tag.getComponents()[0].isPrimal()) { + } + else + { + if(!tag.getComponents()[0].isPrimal()) + { ta *= 1.1f; - if (!tag.getComponents()[0].getComponents()[0].isPrimal()) { + if(!tag.getComponents()[0].getComponents()[0].isPrimal()) + { ta *= 1.05f; } - if (!tag.getComponents()[0].getComponents()[1].isPrimal()) { + if(!tag.getComponents()[0].getComponents()[1].isPrimal()) + { ta *= 1.05f; } } - if (!tag.getComponents()[1].isPrimal()) { + if(!tag.getComponents()[1].isPrimal()) + { ta *= 1.1f; - if (!tag.getComponents()[1].getComponents()[0].isPrimal()) { + if(!tag.getComponents()[1].getComponents()[0].isPrimal()) + { ta *= 1.05f; } - if (!tag.getComponents()[1].getComponents()[1].isPrimal()) { + if(!tag.getComponents()[1].getComponents()[1].isPrimal()) + { ta *= 1.05f; } } } - - if (ta<low) { - low = ta; + + if(ta < low) + { + low = ta; lowest = tag; } } temp2.aspects.remove(lowest); } - return temp2; + return temp2; } - - public static boolean areItemsEqual(ItemStack s1,ItemStack s2) - { - if (s1.isItemStackDamageable() && s2.isItemStackDamageable()) + + public static boolean areItemsEqual(ItemStack s1, ItemStack s2) + { + if(s1.isItemStackDamageable() && s2.isItemStackDamageable()) { return s1.getItem() == s2.getItem(); - } else + } + else + { return s1.getItem() == s2.getItem() && s1.getItemDamage() == s2.getItemDamage(); - } + } + } - public static boolean isResearchComplete(String username, String researchkey) { + public static boolean isResearchComplete(String username, String researchkey) + { return ThaumcraftApi.internalMethods.isResearchComplete(username, researchkey); } - - public static boolean hasDiscoveredAspect(String username, Aspect aspect) { + + public static boolean hasDiscoveredAspect(String username, Aspect aspect) + { return ThaumcraftApi.internalMethods.hasDiscoveredAspect(username, aspect); } - - public static AspectList getDiscoveredAspects(String username) { + + public static AspectList getDiscoveredAspects(String username) + { return ThaumcraftApi.internalMethods.getDiscoveredAspects(username); } - public static ItemStack getStackInRowAndColumn(Object instance, int row, int column) { + public static ItemStack getStackInRowAndColumn(Object instance, int row, int column) + { return ThaumcraftApi.internalMethods.getStackInRowAndColumn(instance, row, column); } - public static AspectList getObjectAspects(ItemStack is) { + public static AspectList getObjectAspects(ItemStack is) + { return ThaumcraftApi.internalMethods.getObjectAspects(is); } - public static AspectList getBonusObjectTags(ItemStack is,AspectList ot) { + public static AspectList getBonusObjectTags(ItemStack is, AspectList ot) + { return ThaumcraftApi.internalMethods.getBonusObjectTags(is, ot); } - public static AspectList generateTags(Item item, int meta) { + public static AspectList generateTags(Item item, int meta) + { return ThaumcraftApi.internalMethods.generateTags(item, meta); } - + public static boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets) - { - for (ItemStack input : inputs) - { - for (ItemStack target : targets) - { - if (itemMatches(target, input, strict)) - { - return true; - } - } - } - return false; - } - - public static boolean areItemStackTagsEqualForCrafting(ItemStack slotItem,ItemStack recipeItem) - { - if (recipeItem == null || slotItem == null) return false; - if (recipeItem.stackTagCompound!=null && slotItem.stackTagCompound==null ) return false; - if (recipeItem.stackTagCompound==null ) return true; - - Iterator iterator = recipeItem.stackTagCompound.func_150296_c().iterator(); - while (iterator.hasNext()) - { - String s = (String)iterator.next(); - if (slotItem.stackTagCompound.hasKey(s)) { - if (!slotItem.stackTagCompound.getTag(s).toString().equals( - recipeItem.stackTagCompound.getTag(s).toString())) { - return false; - } - } else { - return false; - } - - } - return true; - } - - public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict) - { - if (input == null && target != null || input != null && target == null) - { - return false; - } - return (target.getItem() == input.getItem() && - ((target.getItemDamage() == OreDictionary.WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); - } - - - public static TileEntity getConnectableTile(World world, int x, int y, int z, ForgeDirection face) { - TileEntity te = world.getTileEntity(x+face.offsetX, y+face.offsetY, z+face.offsetZ); - if (te instanceof IEssentiaTransport && ((IEssentiaTransport)te).isConnectable(face.getOpposite())) + { + for(final ItemStack input : inputs) + { + for(final ItemStack target : targets) + { + if(itemMatches(target, input, strict)) + { + return true; + } + } + } + return false; + } + + public static boolean areItemStackTagsEqualForCrafting(ItemStack slotItem, ItemStack recipeItem) + { + if(recipeItem == null || slotItem == null) + { + return false; + } + if(recipeItem.stackTagCompound != null && slotItem.stackTagCompound == null) + { + return false; + } + if(recipeItem.stackTagCompound == null) + { + return true; + } + + final Iterator iterator = recipeItem.stackTagCompound.func_150296_c().iterator(); + while(iterator.hasNext()) + { + final String s = (String) iterator.next(); + if(slotItem.stackTagCompound.hasKey(s)) + { + if(!slotItem.stackTagCompound.getTag(s).toString().equals(recipeItem.stackTagCompound.getTag(s).toString())) + { + return false; + } + } + else + { + return false; + } + + } + return true; + } + + public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict) + { + if(input == null && target != null || input != null && target == null) + { + return false; + } + return(target.getItem() == input.getItem() && ((target.getItemDamage() == OreDictionary.WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); + } + + public static TileEntity getConnectableTile(World world, int x, int y, int z, ForgeDirection face) + { + final TileEntity te = world.getTileEntity(x + face.offsetX, y + face.offsetY, z + face.offsetZ); + if(te instanceof IEssentiaTransport && ((IEssentiaTransport) te).isConnectable(face.getOpposite())) + { return te; + } else + { return null; + } } - - public static TileEntity getConnectableTile(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - TileEntity te = world.getTileEntity(x+face.offsetX, y+face.offsetY, z+face.offsetZ); - if (te instanceof IEssentiaTransport && ((IEssentiaTransport)te).isConnectable(face.getOpposite())) + + public static TileEntity getConnectableTile(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + final TileEntity te = world.getTileEntity(x + face.offsetX, y + face.offsetY, z + face.offsetZ); + if(te instanceof IEssentiaTransport && ((IEssentiaTransport) te).isConnectable(face.getOpposite())) + { return te; + } else + { return null; + } } - - private static HashMap<Integer, AspectList> allAspects= new HashMap<Integer, AspectList>(); - private static HashMap<Integer, AspectList> allCompoundAspects= new HashMap<Integer, AspectList>(); - - public static AspectList getAllAspects(int amount) { - if (allAspects.get(amount)==null) { - AspectList al = new AspectList(); - for (Aspect aspect:Aspect.aspects.values()) { - al.add(aspect, amount); - } - allAspects.put(amount, al); - } - return allAspects.get(amount); - } - - public static AspectList getAllCompoundAspects(int amount) { - if (allCompoundAspects.get(amount)==null) { - AspectList al = new AspectList(); - for (Aspect aspect:Aspect.getCompoundAspects()) { - al.add(aspect, amount); - } - allCompoundAspects.put(amount, al); - } - return allCompoundAspects.get(amount); - } - - + + private static HashMap<Integer, AspectList> allAspects = new HashMap<Integer, AspectList>(); + private static HashMap<Integer, AspectList> allCompoundAspects = new HashMap<Integer, AspectList>(); + + public static AspectList getAllAspects(int amount) + { + if(allAspects.get(amount) == null) + { + final AspectList al = new AspectList(); + for(final Aspect aspect : Aspect.aspects.values()) + { + al.add(aspect, amount); + } + allAspects.put(amount, al); + } + return allAspects.get(amount); + } + + public static AspectList getAllCompoundAspects(int amount) + { + if(allCompoundAspects.get(amount) == null) + { + final AspectList al = new AspectList(); + for(final Aspect aspect : Aspect.getCompoundAspects()) + { + al.add(aspect, amount); + } + allCompoundAspects.put(amount, al); + } + return allCompoundAspects.get(amount); + } + /** * Use to subtract vis from a wand for most operations * Wands store vis differently so "real" vis costs need to be multiplied by 100 before calling this method @@ -205,11 +260,11 @@ public class ThaumcraftApiHelper { * false then things like frugal and potency will apply to the costs * @return was the vis successfully subtracted */ - public static boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, - AspectList cost, boolean doit, boolean crafting) { + public static boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit, boolean crafting) + { return ThaumcraftApi.internalMethods.consumeVisFromWand(wand, player, cost, doit, crafting); } - + /** * Subtract vis for use by a crafting mechanic. Costs are calculated slightly * differently and things like the frugal enchant is ignored @@ -220,11 +275,11 @@ public class ThaumcraftApiHelper { * @param doit actually subtract the vis from the wand if true - if false just simulate the result * @return was the vis successfully subtracted */ - public static boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, - AspectList cost, boolean doit) { + public static boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit) + { return ThaumcraftApi.internalMethods.consumeVisFromWandCrafting(wand, player, cost, doit); } - + /** * Subtract vis from a wand the player is carrying. Works like consumeVisFromWand in that actual vis * costs should be multiplied by 100. The costs are handled like crafting however and things like @@ -233,235 +288,236 @@ public class ThaumcraftApiHelper { * @param cost the cost of the operation. * @return was the vis successfully subtracted */ - public static boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) { + public static boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) + { return ThaumcraftApi.internalMethods.consumeVisFromInventory(player, cost); } - - + /** * This adds permanents or temporary warp to a player. It will automatically be synced clientside * @param player the player using the wand * @param amount how much warp to add. Negative amounts are only valid for temporary warp * @param temporary add temporary warp instead of permanent */ - public static void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) { + public static void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) + { ThaumcraftApi.internalMethods.addWarpToPlayer(player, amount, temporary); } - + /** * This "sticky" warp to a player. Sticky warp is permanent warp that can be removed. * It will automatically be synced clientside * @param player the player using the wand * @param amount how much warp to add. Can have negative amounts. */ - public static void addStickyWarpToPlayer(EntityPlayer player, int amount) { + public static void addStickyWarpToPlayer(EntityPlayer player, int amount) + { ThaumcraftApi.internalMethods.addStickyWarpToPlayer(player, amount); } - public static MovingObjectPosition rayTraceIgnoringSource(World world, Vec3 v1, Vec3 v2, - boolean bool1, boolean bool2, boolean bool3) + public static MovingObjectPosition rayTraceIgnoringSource(World world, Vec3 v1, Vec3 v2, boolean bool1, boolean bool2, boolean bool3) { - if (!Double.isNaN(v1.xCoord) && !Double.isNaN(v1.yCoord) && !Double.isNaN(v1.zCoord)) - { - if (!Double.isNaN(v2.xCoord) && !Double.isNaN(v2.yCoord) && !Double.isNaN(v2.zCoord)) - { - int i = MathHelper.floor_double(v2.xCoord); - int j = MathHelper.floor_double(v2.yCoord); - int k = MathHelper.floor_double(v2.zCoord); - int l = MathHelper.floor_double(v1.xCoord); - int i1 = MathHelper.floor_double(v1.yCoord); - int j1 = MathHelper.floor_double(v1.zCoord); - Block block = world.getBlock(l, i1, j1); - int k1 = world.getBlockMetadata(l, i1, j1); - - MovingObjectPosition movingobjectposition2 = null; - k1 = 200; - - while (k1-- >= 0) - { - if (Double.isNaN(v1.xCoord) || Double.isNaN(v1.yCoord) || Double.isNaN(v1.zCoord)) - { - return null; - } - - if (l == i && i1 == j && j1 == k) - { - continue; - } - - boolean flag6 = true; - boolean flag3 = true; - boolean flag4 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (i > l) - { - d0 = (double)l + 1.0D; - } - else if (i < l) - { - d0 = (double)l + 0.0D; - } - else - { - flag6 = false; - } - - if (j > i1) - { - d1 = (double)i1 + 1.0D; - } - else if (j < i1) - { - d1 = (double)i1 + 0.0D; - } - else - { - flag3 = false; - } - - if (k > j1) - { - d2 = (double)j1 + 1.0D; - } - else if (k < j1) - { - d2 = (double)j1 + 0.0D; - } - else - { - flag4 = false; - } - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = v2.xCoord - v1.xCoord; - double d7 = v2.yCoord - v1.yCoord; - double d8 = v2.zCoord - v1.zCoord; - - if (flag6) - { - d3 = (d0 - v1.xCoord) / d6; - } - - if (flag3) - { - d4 = (d1 - v1.yCoord) / d7; - } - - if (flag4) - { - d5 = (d2 - v1.zCoord) / d8; - } - - boolean flag5 = false; - byte b0; - - if (d3 < d4 && d3 < d5) - { - if (i > l) - { - b0 = 4; - } - else - { - b0 = 5; - } - - v1.xCoord = d0; - v1.yCoord += d7 * d3; - v1.zCoord += d8 * d3; - } - else if (d4 < d5) - { - if (j > i1) - { - b0 = 0; - } - else - { - b0 = 1; - } - - v1.xCoord += d6 * d4; - v1.yCoord = d1; - v1.zCoord += d8 * d4; - } - else - { - if (k > j1) - { - b0 = 2; - } - else - { - b0 = 3; - } - - v1.xCoord += d6 * d5; - v1.yCoord += d7 * d5; - v1.zCoord = d2; - } - - Vec3 vec32 = Vec3.createVectorHelper(v1.xCoord, v1.yCoord, v1.zCoord); - l = (int)(vec32.xCoord = (double)MathHelper.floor_double(v1.xCoord)); - - if (b0 == 5) - { - --l; - ++vec32.xCoord; - } - - i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(v1.yCoord)); - - if (b0 == 1) - { - --i1; - ++vec32.yCoord; - } - - j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(v1.zCoord)); - - if (b0 == 3) - { - --j1; - ++vec32.zCoord; - } - - Block block1 = world.getBlock(l, i1, j1); - int l1 = world.getBlockMetadata(l, i1, j1); - - if (!bool2 || block1.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) - { - if (block1.canCollideCheck(l1, bool1)) - { - MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(world, l, i1, j1, v1, v2); - - if (movingobjectposition1 != null) - { - return movingobjectposition1; - } - } - else - { - movingobjectposition2 = new MovingObjectPosition(l, i1, j1, b0, v1, false); - } - } - } - - return bool3 ? movingobjectposition2 : null; - } - else - { - return null; - } - } - else - { - return null; - } + if(!Double.isNaN(v1.xCoord) && !Double.isNaN(v1.yCoord) && !Double.isNaN(v1.zCoord)) + { + if(!Double.isNaN(v2.xCoord) && !Double.isNaN(v2.yCoord) && !Double.isNaN(v2.zCoord)) + { + final int i = MathHelper.floor_double(v2.xCoord); + final int j = MathHelper.floor_double(v2.yCoord); + final int k = MathHelper.floor_double(v2.zCoord); + int l = MathHelper.floor_double(v1.xCoord); + int i1 = MathHelper.floor_double(v1.yCoord); + int j1 = MathHelper.floor_double(v1.zCoord); + world.getBlock(l, i1, j1); + int k1 = world.getBlockMetadata(l, i1, j1); + + MovingObjectPosition movingobjectposition2 = null; + k1 = 200; + + while(k1-- >= 0) + { + if(Double.isNaN(v1.xCoord) || Double.isNaN(v1.yCoord) || Double.isNaN(v1.zCoord)) + { + return null; + } + + if(l == i && i1 == j && j1 == k) + { + continue; + } + + boolean flag6 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if(i > l) + { + d0 = l + 1.0D; + } + else if(i < l) + { + d0 = l + 0.0D; + } + else + { + flag6 = false; + } + + if(j > i1) + { + d1 = i1 + 1.0D; + } + else if(j < i1) + { + d1 = i1 + 0.0D; + } + else + { + flag3 = false; + } + + if(k > j1) + { + d2 = j1 + 1.0D; + } + else if(k < j1) + { + d2 = j1 + 0.0D; + } + else + { + flag4 = false; + } + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + final double d6 = v2.xCoord - v1.xCoord; + final double d7 = v2.yCoord - v1.yCoord; + final double d8 = v2.zCoord - v1.zCoord; + + if(flag6) + { + d3 = (d0 - v1.xCoord) / d6; + } + + if(flag3) + { + d4 = (d1 - v1.yCoord) / d7; + } + + if(flag4) + { + d5 = (d2 - v1.zCoord) / d8; + } + + byte b0; + + if(d3 < d4 && d3 < d5) + { + if(i > l) + { + b0 = 4; + } + else + { + b0 = 5; + } + + v1.xCoord = d0; + v1.yCoord += d7 * d3; + v1.zCoord += d8 * d3; + } + else if(d4 < d5) + { + if(j > i1) + { + b0 = 0; + } + else + { + b0 = 1; + } + + v1.xCoord += d6 * d4; + v1.yCoord = d1; + v1.zCoord += d8 * d4; + } + else + { + if(k > j1) + { + b0 = 2; + } + else + { + b0 = 3; + } + + v1.xCoord += d6 * d5; + v1.yCoord += d7 * d5; + v1.zCoord = d2; + } + + final Vec3 vec32 = Vec3.createVectorHelper(v1.xCoord, v1.yCoord, v1.zCoord); + l = (int) (vec32.xCoord = MathHelper.floor_double(v1.xCoord)); + + if(b0 == 5) + { + --l; + ++vec32.xCoord; + } + + i1 = (int) (vec32.yCoord = MathHelper.floor_double(v1.yCoord)); + + if(b0 == 1) + { + --i1; + ++vec32.yCoord; + } + + j1 = (int) (vec32.zCoord = MathHelper.floor_double(v1.zCoord)); + + if(b0 == 3) + { + --j1; + ++vec32.zCoord; + } + + final Block block1 = world.getBlock(l, i1, j1); + final int l1 = world.getBlockMetadata(l, i1, j1); + + if(!bool2 || block1.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) + { + if(block1.canCollideCheck(l1, bool1)) + { + final MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(world, l, i1, j1, v1, v2); + + if(movingobjectposition1 != null) + { + return movingobjectposition1; + } + } + else + { + movingobjectposition2 = new MovingObjectPosition(l, + i1, j1, b0, v1, false); + } + } + } + + return bool3 ? movingobjectposition2 : null; + } + else + { + return null; + } + } + else + { + return null; + } } } diff --git a/src/api/java/thaumcraft/api/TileThaumcraft.java b/src/api/java/thaumcraft/api/TileThaumcraft.java index 56ccae8..8bcb4c7 100644 --- a/src/api/java/thaumcraft/api/TileThaumcraft.java +++ b/src/api/java/thaumcraft/api/TileThaumcraft.java @@ -15,49 +15,50 @@ import net.minecraft.tileentity.TileEntity; * updates. Apart from all the normal TE data that gets sent that is. * */ -public class TileThaumcraft extends TileEntity { - +public class TileThaumcraft extends TileEntity +{ + //NBT stuff - + @Override public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - readCustomNBT(nbttagcompound); - } - + { + super.readFromNBT(nbttagcompound); + readCustomNBT(nbttagcompound); + } + public void readCustomNBT(NBTTagCompound nbttagcompound) - { - //TODO - } + { + //TODO + } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - writeCustomNBT(nbttagcompound); - } - + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + writeCustomNBT(nbttagcompound); + } + public void writeCustomNBT(NBTTagCompound nbttagcompound) - { + { //TODO - } - + } + //Client Packet stuff @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - this.writeCustomNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, nbttagcompound); + public Packet getDescriptionPacket() + { + final NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, + zCoord, -999, nbttagcompound); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - super.onDataPacket(net, pkt); - this.readCustomNBT(pkt.func_148857_g()); + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) + { + super.onDataPacket(net, pkt); + readCustomNBT(pkt.func_148857_g()); } - - - } diff --git a/src/api/java/thaumcraft/api/WorldCoordinates.java b/src/api/java/thaumcraft/api/WorldCoordinates.java index 6c620af..cab4082 100644 --- a/src/api/java/thaumcraft/api/WorldCoordinates.java +++ b/src/api/java/thaumcraft/api/WorldCoordinates.java @@ -5,113 +5,119 @@ import net.minecraft.tileentity.TileEntity; public class WorldCoordinates implements Comparable { - public int x; - - /** the y coordinate */ - public int y; - - /** the z coordinate */ - public int z; - - public int dim; - - public WorldCoordinates() {} - - public WorldCoordinates(int par1, int par2, int par3, int d) - { - this.x = par1; - this.y = par2; - this.z = par3; - this.dim = d; - } - - public WorldCoordinates(TileEntity tile) - { - this.x = tile.xCoord; - this.y = tile.yCoord; - this.z = tile.zCoord; - this.dim = tile.getWorldObj().provider.dimensionId; - } - - public WorldCoordinates(WorldCoordinates par1ChunkCoordinates) - { - this.x = par1ChunkCoordinates.x; - this.y = par1ChunkCoordinates.y; - this.z = par1ChunkCoordinates.z; - this.dim = par1ChunkCoordinates.dim; - } - - public boolean equals(Object par1Obj) - { - if (!(par1Obj instanceof WorldCoordinates)) - { - return false; - } - else - { - WorldCoordinates coordinates = (WorldCoordinates)par1Obj; - return this.x == coordinates.x && this.y == coordinates.y && this.z == coordinates.z && this.dim == coordinates.dim ; - } - } - - public int hashCode() - { - return this.x + this.y << 8 + this.z << 16 + this.dim << 24; - } - - /** - * Compare the coordinate with another coordinate - */ - public int compareWorldCoordinate(WorldCoordinates par1) - { - return this.dim == par1.dim ? ( - this.y == par1.y ? (this.z == par1.z ? this.x - par1.x : this.z - par1.z) : this.y - par1.y) : -1; - } - - public void set(int par1, int par2, int par3, int d) - { - this.x = par1; - this.y = par2; - this.z = par3; - this.dim = d; - } - - /** - * Returns the squared distance between this coordinates and the coordinates given as argument. - */ - public float getDistanceSquared(int par1, int par2, int par3) - { - float f = (float)(this.x - par1); - float f1 = (float)(this.y - par2); - float f2 = (float)(this.z - par3); - return f * f + f1 * f1 + f2 * f2; - } - - /** - * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. - */ - public float getDistanceSquaredToWorldCoordinates(WorldCoordinates par1ChunkCoordinates) - { - return this.getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); - } - - public int compareTo(Object par1Obj) - { - return this.compareWorldCoordinate((WorldCoordinates)par1Obj); - } - - public void readNBT(NBTTagCompound nbt) { - this.x = nbt.getInteger("w_x"); - this.y = nbt.getInteger("w_y"); - this.z = nbt.getInteger("w_z"); - this.dim = nbt.getInteger("w_d"); - } - - public void writeNBT(NBTTagCompound nbt) { - nbt.setInteger("w_x",x); - nbt.setInteger("w_y",y); - nbt.setInteger("w_z",z); - nbt.setInteger("w_d",dim); - } - + public int x; + + /** the y coordinate */ + public int y; + + /** the z coordinate */ + public int z; + + public int dim; + + public WorldCoordinates() + { + } + + public WorldCoordinates(int par1, int par2, int par3, int d) + { + x = par1; + y = par2; + z = par3; + dim = d; + } + + public WorldCoordinates(TileEntity tile) + { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + dim = tile.getWorldObj().provider.dimensionId; + } + + public WorldCoordinates(WorldCoordinates par1ChunkCoordinates) + { + x = par1ChunkCoordinates.x; + y = par1ChunkCoordinates.y; + z = par1ChunkCoordinates.z; + dim = par1ChunkCoordinates.dim; + } + + @Override + public boolean equals(Object par1Obj) + { + if(!(par1Obj instanceof WorldCoordinates)) + { + return false; + } + else + { + final WorldCoordinates coordinates = (WorldCoordinates) par1Obj; + return x == coordinates.x && y == coordinates.y && z == coordinates.z && dim == coordinates.dim; + } + } + + @Override + public int hashCode() + { + return x + y << 8 + z << 16 + dim << 24; + } + + /** + * Compare the coordinate with another coordinate + */ + public int compareWorldCoordinate(WorldCoordinates par1) + { + return dim == par1.dim ? (y == par1.y ? (z == par1.z ? x - par1.x : z - par1.z) : y - par1.y) : -1; + } + + public void set(int par1, int par2, int par3, int d) + { + x = par1; + y = par2; + z = par3; + dim = d; + } + + /** + * Returns the squared distance between this coordinates and the coordinates given as argument. + */ + public float getDistanceSquared(int par1, int par2, int par3) + { + final float f = x - par1; + final float f1 = y - par2; + final float f2 = z - par3; + return f * f + f1 * f1 + f2 * f2; + } + + /** + * Return the squared distance between this coordinates and the ChunkCoordinates given as argument. + */ + public float getDistanceSquaredToWorldCoordinates(WorldCoordinates par1ChunkCoordinates) + { + return getDistanceSquared(par1ChunkCoordinates.x, par1ChunkCoordinates.y, par1ChunkCoordinates.z); + } + + @Override + public int compareTo(Object par1Obj) + { + return compareWorldCoordinate((WorldCoordinates) par1Obj); + } + + public void readNBT(NBTTagCompound nbt) + { + x = nbt.getInteger("w_x"); + y = nbt.getInteger("w_y"); + z = nbt.getInteger("w_z"); + dim = nbt.getInteger("w_d"); + } + + public void writeNBT(NBTTagCompound nbt) + { + nbt.setInteger("w_x", x); + nbt.setInteger("w_y", y); + nbt.setInteger("w_z", z); + nbt.setInteger("w_d", dim); + } + } diff --git a/src/api/java/thaumcraft/api/aspects/Aspect.java b/src/api/java/thaumcraft/api/aspects/Aspect.java index 0ea13f5..c6c548e 100644 --- a/src/api/java/thaumcraft/api/aspects/Aspect.java +++ b/src/api/java/thaumcraft/api/aspects/Aspect.java @@ -9,14 +9,15 @@ import net.minecraft.util.StatCollector; import org.apache.commons.lang3.text.WordUtils; -public class Aspect { - - String tag; - Aspect[] components; - int color; - private String chatcolor; - ResourceLocation image; - int blend; +public class Aspect +{ + + String tag; + Aspect[] components; + int color; + private String chatcolor; + ResourceLocation image; + int blend; /** * Use this constructor to register your own aspects. @@ -26,8 +27,12 @@ public class Aspect { * @param image ResourceLocation pointing to a 32x32 icon of the aspect * @param blend GL11 blendmode (1 or 771). Used for rendering nodes. Default is 1 */ - public Aspect(String tag, int color, Aspect[] components, ResourceLocation image, int blend) { - if (aspects.containsKey(tag)) throw new IllegalArgumentException(tag+" already registered!"); + public Aspect(String tag, int color, Aspect[] components, ResourceLocation image, int blend) + { + if(aspects.containsKey(tag)) + { + throw new IllegalArgumentException(tag + " already registered!"); + } this.tag = tag; this.components = components; this.color = color; @@ -35,167 +40,338 @@ public class Aspect { this.blend = blend; aspects.put(tag, this); } - + /** * Shortcut constructor I use for the default aspects - you shouldn't be using this. */ - public Aspect(String tag, int color, Aspect[] components) { - this(tag,color,components,new ResourceLocation("thaumcraft","textures/aspects/"+tag.toLowerCase()+".png"),1); + public Aspect(String tag, int color, Aspect[] components) + { + this(tag, color, components, new ResourceLocation("thaumcraft", + "textures/aspects/" + tag.toLowerCase() + ".png"), 1); } - + /** * Shortcut constructor I use for the default aspects - you shouldn't be using this. */ - public Aspect(String tag, int color, Aspect[] components, int blend) { - this(tag,color,components,new ResourceLocation("thaumcraft","textures/aspects/"+tag.toLowerCase()+".png"),blend); + public Aspect(String tag, int color, Aspect[] components, int blend) + { + this(tag, color, components, new ResourceLocation("thaumcraft", + "textures/aspects/" + tag.toLowerCase() + ".png"), blend); } /** * Shortcut constructor I use for the primal aspects - * you shouldn't use this as making your own primal aspects will break all the things. */ - public Aspect(String tag, int color, String chatcolor, int blend) { - this(tag,color,(Aspect[])null, blend); - this.setChatcolor(chatcolor); + public Aspect(String tag, int color, String chatcolor, int blend) + { + this(tag, color, (Aspect[]) null, blend); + setChatcolor(chatcolor); } - - public int getColor() { + + public int getColor() + { return color; } - - public String getName() { + + public String getName() + { return WordUtils.capitalizeFully(tag); } - - public String getLocalizedDescription() { - return StatCollector.translateToLocal("tc.aspect."+tag); + + public String getLocalizedDescription() + { + return StatCollector.translateToLocal("tc.aspect." + tag); } - - public String getTag() { + + public String getTag() + { return tag; } - public void setTag(String tag) { + public void setTag(String tag) + { this.tag = tag; } - public Aspect[] getComponents() { + public Aspect[] getComponents() + { return components; } - public void setComponents(Aspect[] components) { + public void setComponents(Aspect[] components) + { this.components = components; } - - public ResourceLocation getImage() { + + public ResourceLocation getImage() + { return image; } - - public static Aspect getAspect(String tag) { + + public static Aspect getAspect(String tag) + { return aspects.get(tag); } - - public int getBlend() { + + public int getBlend() + { return blend; } - public void setBlend(int blend) { + public void setBlend(int blend) + { this.blend = blend; } - - public boolean isPrimal() { - return getComponents()==null || getComponents().length!=2; + + public boolean isPrimal() + { + return getComponents() == null || getComponents().length != 2; } - + /////////////////////////////// - public static ArrayList<Aspect> getPrimalAspects() { - ArrayList<Aspect> primals = new ArrayList<Aspect>(); - Collection<Aspect> pa = aspects.values(); - for (Aspect aspect:pa) { - if (aspect.isPrimal()) primals.add(aspect); + public static ArrayList<Aspect> getPrimalAspects() + { + final ArrayList<Aspect> primals = new ArrayList<Aspect>(); + final Collection<Aspect> pa = aspects.values(); + for(final Aspect aspect : pa) + { + if(aspect.isPrimal()) + { + primals.add(aspect); + } } return primals; } - - public static ArrayList<Aspect> getCompoundAspects() { - ArrayList<Aspect> compounds = new ArrayList<Aspect>(); - Collection<Aspect> pa = aspects.values(); - for (Aspect aspect:pa) { - if (!aspect.isPrimal()) compounds.add(aspect); + + public static ArrayList<Aspect> getCompoundAspects() + { + final ArrayList<Aspect> compounds = new ArrayList<Aspect>(); + final Collection<Aspect> pa = aspects.values(); + for(final Aspect aspect : pa) + { + if(!aspect.isPrimal()) + { + compounds.add(aspect); + } } return compounds; } - public String getChatcolor() { + public String getChatcolor() + { return chatcolor; } - public void setChatcolor(String chatcolor) { + public void setChatcolor(String chatcolor) + { this.chatcolor = chatcolor; } - /////////////////////////////// - public static LinkedHashMap<String,Aspect> aspects = new LinkedHashMap<String,Aspect>(); - + public static LinkedHashMap<String, Aspect> aspects = new LinkedHashMap<String, Aspect>(); + //PRIMAL - public static final Aspect AIR = new Aspect("aer",0xffff7e,"e",1); - public static final Aspect EARTH = new Aspect("terra",0x56c000,"2",1); - public static final Aspect FIRE = new Aspect("ignis",0xff5a01,"c",1); - public static final Aspect WATER = new Aspect("aqua",0x3cd4fc,"3",1); - public static final Aspect ORDER = new Aspect("ordo",0xd5d4ec,"7",1); - public static final Aspect ENTROPY = new Aspect("perditio",0x404040,"8",771); - + public static final Aspect AIR = new Aspect("aer", + 0xffff7e, + "e", 1); + public static final Aspect EARTH = new Aspect( + "terra", + 0x56c000, + "2", 1); + public static final Aspect FIRE = new Aspect( + "ignis", + 0xff5a01, + "c", 1); + public static final Aspect WATER = new Aspect( + "aqua", + 0x3cd4fc, + "3", 1); + public static final Aspect ORDER = new Aspect( + "ordo", + 0xd5d4ec, + "7", 1); + public static final Aspect ENTROPY = new Aspect( + "perditio", + 0x404040, + "8", 771); + //SECONDARY - public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {AIR, ENTROPY},771); - public static final Aspect LIGHT = new Aspect("lux",0xfff663, new Aspect[] {AIR, FIRE}); - public static final Aspect WEATHER = new Aspect("tempestas",0xFFFFFF, new Aspect[] {AIR, WATER}); - public static final Aspect MOTION = new Aspect("motus",0xcdccf4, new Aspect[] {AIR, ORDER}); - public static final Aspect COLD = new Aspect("gelum",0xe1ffff, new Aspect[] {FIRE, ENTROPY}); - public static final Aspect CRYSTAL = new Aspect("vitreus",0x80ffff, new Aspect[] {EARTH, ORDER}); - public static final Aspect LIFE = new Aspect("victus",0xde0005, new Aspect[] {WATER, EARTH}); - public static final Aspect POISON = new Aspect("venenum",0x89f000, new Aspect[] {WATER, ENTROPY}); - public static final Aspect ENERGY = new Aspect("potentia",0xc0ffff, new Aspect[] {ORDER, FIRE}); - public static final Aspect EXCHANGE = new Aspect("permutatio",0x578357, new Aspect[] {ENTROPY, ORDER}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {AIR, EARTH}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, EARTH}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, WATER}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {ORDER, WATER}); -// public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {EARTH, ENTROPY}); - + public static final Aspect VOID = new Aspect( + "vacuos", + 0x888888, + new Aspect[] {AIR, ENTROPY}, + 771); + public static final Aspect LIGHT = new Aspect( + "lux", + 0xfff663, + new Aspect[] {AIR, FIRE}); + public static final Aspect WEATHER = new Aspect( + "tempestas", + 0xFFFFFF, + new Aspect[] {AIR, WATER}); + public static final Aspect MOTION = new Aspect( + "motus", + 0xcdccf4, + new Aspect[] {AIR, ORDER}); + public static final Aspect COLD = new Aspect( + "gelum", + 0xe1ffff, + new Aspect[] {FIRE, ENTROPY}); + public static final Aspect CRYSTAL = new Aspect( + "vitreus", + 0x80ffff, + new Aspect[] {EARTH, ORDER}); + public static final Aspect LIFE = new Aspect( + "victus", + 0xde0005, + new Aspect[] {WATER, EARTH}); + public static final Aspect POISON = new Aspect( + "venenum", + 0x89f000, + new Aspect[] {WATER, ENTROPY}); + public static final Aspect ENERGY = new Aspect( + "potentia", + 0xc0ffff, + new Aspect[] {ORDER, FIRE}); + public static final Aspect EXCHANGE = new Aspect( + "permutatio", + 0x578357, + new Aspect[] {ENTROPY, ORDER}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {AIR, EARTH}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, EARTH}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {FIRE, WATER}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {ORDER, WATER}); + // public static final Aspect ?? = new Aspect("??",0xcdccf4, new Aspect[] {EARTH, ENTROPY}); + //TERTIARY - public static final Aspect METAL = new Aspect("metallum",0xb5b5cd, new Aspect[] {EARTH, CRYSTAL}); - public static final Aspect DEATH = new Aspect("mortuus",0x887788, new Aspect[] {LIFE, ENTROPY}); - public static final Aspect FLIGHT = new Aspect("volatus",0xe7e7d7, new Aspect[] {AIR, MOTION}); - public static final Aspect DARKNESS = new Aspect("tenebrae",0x222222, new Aspect[] {VOID, LIGHT}); - public static final Aspect SOUL = new Aspect("spiritus",0xebebfb, new Aspect[] {LIFE, DEATH}); - public static final Aspect HEAL = new Aspect("sano",0xff2f34, new Aspect[] {LIFE, ORDER}); - public static final Aspect TRAVEL = new Aspect("iter",0xe0585b, new Aspect[] {MOTION, EARTH}); - public static final Aspect ELDRITCH = new Aspect("alienis",0x805080, new Aspect[] {VOID, DARKNESS}); - public static final Aspect MAGIC = new Aspect("praecantatio",0x9700c0, new Aspect[] {VOID, ENERGY}); - public static final Aspect AURA = new Aspect("auram",0xffc0ff, new Aspect[] {MAGIC, AIR}); - public static final Aspect TAINT = new Aspect("vitium",0x800080, new Aspect[] {MAGIC, ENTROPY}); - public static final Aspect SLIME = new Aspect("limus",0x01f800, new Aspect[] {LIFE, WATER}); - public static final Aspect PLANT = new Aspect("herba",0x01ac00, new Aspect[] {LIFE, EARTH}); - public static final Aspect TREE = new Aspect("arbor",0x876531, new Aspect[] {AIR, PLANT}); - public static final Aspect BEAST = new Aspect("bestia",0x9f6409, new Aspect[] {MOTION, LIFE}); - public static final Aspect FLESH = new Aspect("corpus",0xee478d, new Aspect[] {DEATH, BEAST}); - public static final Aspect UNDEAD = new Aspect("exanimis",0x3a4000, new Aspect[] {MOTION, DEATH}); - public static final Aspect MIND = new Aspect("cognitio",0xffc2b3, new Aspect[] {FIRE, SOUL}); - public static final Aspect SENSES = new Aspect("sensus",0x0fd9ff, new Aspect[] {AIR, SOUL}); - public static final Aspect MAN = new Aspect("humanus",0xffd7c0, new Aspect[] {BEAST, MIND}); - public static final Aspect CROP = new Aspect("messis",0xe1b371, new Aspect[] {PLANT, MAN}); - public static final Aspect MINE = new Aspect("perfodio",0xdcd2d8, new Aspect[] {MAN, EARTH}); - public static final Aspect TOOL = new Aspect("instrumentum",0x4040ee, new Aspect[] {MAN, ORDER}); - public static final Aspect HARVEST = new Aspect("meto",0xeead82, new Aspect[] {CROP, TOOL}); - public static final Aspect WEAPON = new Aspect("telum",0xc05050, new Aspect[] {TOOL, FIRE}); - public static final Aspect ARMOR = new Aspect("tutamen",0x00c0c0, new Aspect[] {TOOL, EARTH}); - public static final Aspect HUNGER = new Aspect("fames",0x9a0305, new Aspect[] {LIFE, VOID}); - public static final Aspect GREED = new Aspect("lucrum",0xe6be44, new Aspect[] {MAN, HUNGER}); - public static final Aspect CRAFT = new Aspect("fabrico",0x809d80, new Aspect[] {MAN, TOOL}); - public static final Aspect CLOTH = new Aspect("pannus",0xeaeac2, new Aspect[] {TOOL, BEAST}); - public static final Aspect MECHANISM = new Aspect("machina",0x8080a0, new Aspect[] {MOTION, TOOL}); - public static final Aspect TRAP = new Aspect("vinculum",0x9a8080, new Aspect[] {MOTION, ENTROPY}); - - + public static final Aspect METAL = new Aspect( + "metallum", + 0xb5b5cd, + new Aspect[] {EARTH, CRYSTAL}); + public static final Aspect DEATH = new Aspect( + "mortuus", + 0x887788, + new Aspect[] {LIFE, ENTROPY}); + public static final Aspect FLIGHT = new Aspect( + "volatus", + 0xe7e7d7, + new Aspect[] {AIR, MOTION}); + public static final Aspect DARKNESS = new Aspect( + "tenebrae", + 0x222222, + new Aspect[] {VOID, LIGHT}); + public static final Aspect SOUL = new Aspect( + "spiritus", + 0xebebfb, + new Aspect[] {LIFE, DEATH}); + public static final Aspect HEAL = new Aspect( + "sano", + 0xff2f34, + new Aspect[] {LIFE, ORDER}); + public static final Aspect TRAVEL = new Aspect( + "iter", + 0xe0585b, + new Aspect[] {MOTION, EARTH}); + public static final Aspect ELDRITCH = new Aspect( + "alienis", + 0x805080, + new Aspect[] {VOID, DARKNESS}); + public static final Aspect MAGIC = new Aspect( + "praecantatio", + 0x9700c0, + new Aspect[] {VOID, ENERGY}); + public static final Aspect AURA = new Aspect( + "auram", + 0xffc0ff, + new Aspect[] {MAGIC, AIR}); + public static final Aspect TAINT = new Aspect( + "vitium", + 0x800080, + new Aspect[] {MAGIC, ENTROPY}); + public static final Aspect SLIME = new Aspect( + "limus", + 0x01f800, + new Aspect[] {LIFE, WATER}); + public static final Aspect PLANT = new Aspect( + "herba", + 0x01ac00, + new Aspect[] {LIFE, EARTH}); + public static final Aspect TREE = new Aspect( + "arbor", + 0x876531, + new Aspect[] {AIR, PLANT}); + public static final Aspect BEAST = new Aspect( + "bestia", + 0x9f6409, + new Aspect[] {MOTION, LIFE}); + public static final Aspect FLESH = new Aspect( + "corpus", + 0xee478d, + new Aspect[] {DEATH, BEAST}); + public static final Aspect UNDEAD = new Aspect( + "exanimis", + 0x3a4000, + new Aspect[] {MOTION, DEATH}); + public static final Aspect MIND = new Aspect( + "cognitio", + 0xffc2b3, + new Aspect[] {FIRE, SOUL}); + public static final Aspect SENSES = new Aspect( + "sensus", + 0x0fd9ff, + new Aspect[] {AIR, SOUL}); + public static final Aspect MAN = new Aspect( + "humanus", + 0xffd7c0, + new Aspect[] {BEAST, MIND}); + public static final Aspect CROP = new Aspect( + "messis", + 0xe1b371, + new Aspect[] {PLANT, MAN}); + public static final Aspect MINE = new Aspect( + "perfodio", + 0xdcd2d8, + new Aspect[] {MAN, EARTH}); + public static final Aspect TOOL = new Aspect( + "instrumentum", + 0x4040ee, + new Aspect[] {MAN, ORDER}); + public static final Aspect HARVEST = new Aspect( + "meto", + 0xeead82, + new Aspect[] {CROP, TOOL}); + public static final Aspect WEAPON = new Aspect( + "telum", + 0xc05050, + new Aspect[] {TOOL, FIRE}); + public static final Aspect ARMOR = new Aspect( + "tutamen", + 0x00c0c0, + new Aspect[] {TOOL, EARTH}); + public static final Aspect HUNGER = new Aspect( + "fames", + 0x9a0305, + new Aspect[] {LIFE, VOID}); + public static final Aspect GREED = new Aspect( + "lucrum", + 0xe6be44, + new Aspect[] {MAN, HUNGER}); + public static final Aspect CRAFT = new Aspect( + "fabrico", + 0x809d80, + new Aspect[] {MAN, TOOL}); + public static final Aspect CLOTH = new Aspect( + "pannus", + 0xeaeac2, + new Aspect[] {TOOL, BEAST}); + public static final Aspect MECHANISM = new Aspect( + "machina", + 0x8080a0, + new Aspect[] {MOTION, TOOL}); + public static final Aspect TRAP = new Aspect( + "vinculum", + 0x9a8080, + new Aspect[] {MOTION, ENTROPY}); + } diff --git a/src/api/java/thaumcraft/api/aspects/AspectList.java b/src/api/java/thaumcraft/api/aspects/AspectList.java index b578141..fb80b48 100644 --- a/src/api/java/thaumcraft/api/aspects/AspectList.java +++ b/src/api/java/thaumcraft/api/aspects/AspectList.java @@ -8,154 +8,192 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import thaumcraft.api.ThaumcraftApiHelper; -public class AspectList implements Serializable { - - public LinkedHashMap<Aspect,Integer> aspects = new LinkedHashMap<Aspect,Integer>();//aspects associated with this object +public class AspectList implements Serializable +{ + + public LinkedHashMap<Aspect, Integer> aspects = new LinkedHashMap<Aspect, Integer>(); //aspects associated with this object - /** * this creates a new aspect list with preloaded values based off the aspects of the given item. * @param the itemstack of the given item */ - public AspectList(ItemStack stack) { - try { - AspectList temp = ThaumcraftApiHelper.getObjectAspects(stack); - if (temp!=null) - for (Aspect tag:temp.getAspects()) { - add(tag,temp.getAmount(tag)); + public AspectList(ItemStack stack) + { + try + { + final AspectList temp = ThaumcraftApiHelper.getObjectAspects(stack); + if(temp != null) + { + for(final Aspect tag : temp.getAspects()) + { + add(tag, temp.getAmount(tag)); + } } - } catch (Exception e) {} + } + catch(final Exception e) + { + } } - - public AspectList() { + + public AspectList() + { } - - public AspectList copy() { - AspectList out = new AspectList(); - for (Aspect a:this.getAspects()) - out.add(a, this.getAmount(a)); + + public AspectList copy() + { + final AspectList out = new AspectList(); + for(final Aspect a : getAspects()) + { + out.add(a, getAmount(a)); + } return out; } - + /** * @return the amount of different aspects in this collection */ - public int size() { + public int size() + { return aspects.size(); } - + /** * @return the amount of total vis in this collection */ - public int visSize() { + public int visSize() + { int q = 0; - - for (Aspect as:aspects.keySet()) { - q+=this.getAmount(as); + + for(final Aspect as : aspects.keySet()) + { + q += getAmount(as); } - + return q; } - + /** * @return an array of all the aspects in this collection */ - public Aspect[] getAspects() { - Aspect[] q = new Aspect[1]; + public Aspect[] getAspects() + { + final Aspect[] q = new Aspect[1]; return aspects.keySet().toArray(q); } - + /** * @return an array of all the aspects in this collection */ - public Aspect[] getPrimalAspects() { - AspectList t = new AspectList(); - for (Aspect as:aspects.keySet()) { - if (as.isPrimal()) { - t.add(as,1); + public Aspect[] getPrimalAspects() + { + final AspectList t = new AspectList(); + for(final Aspect as : aspects.keySet()) + { + if(as.isPrimal()) + { + t.add(as, 1); } } - Aspect[] q = new Aspect[1]; + final Aspect[] q = new Aspect[1]; return t.aspects.keySet().toArray(q); } - + /** * @return an array of all the aspects in this collection sorted by name */ - public Aspect[] getAspectsSorted() { - try { - Aspect[] out = aspects.keySet().toArray(new Aspect[]{}); - boolean change=false; - do { - change=false; - for(int a=0;a<out.length-1;a++) { - Aspect e1 = out[a]; - Aspect e2 = out[a+1]; - if (e1!=null && e2!=null && e1.getTag().compareTo(e2.getTag())>0) { + public Aspect[] getAspectsSorted() + { + try + { + final Aspect[] out = aspects.keySet().toArray(new Aspect[] {}); + boolean change = false; + do + { + change = false; + for(int a = 0; a < out.length - 1; a++) + { + final Aspect e1 = out[a]; + final Aspect e2 = out[a + 1]; + if(e1 != null && e2 != null && e1.getTag().compareTo(e2.getTag()) > 0) + { out[a] = e2; - out[a+1] = e1; + out[a + 1] = e1; change = true; break; } } - } while (change==true); + } + while(change == true); return out; - } catch (Exception e) { - return this.getAspects(); + } + catch(final Exception e) + { + return getAspects(); } } - + /** * @return an array of all the aspects in this collection sorted by amount */ - public Aspect[] getAspectsSortedAmount() { - try { - Aspect[] out = aspects.keySet().toArray(new Aspect[1]); - boolean change=false; - do { - change=false; - for(int a=0;a<out.length-1;a++) { - int e1 = getAmount(out[a]); - int e2 = getAmount(out[a+1]); - if (e1>0 && e2>0 && e2>e1) { - Aspect ea = out[a]; - Aspect eb = out[a+1]; + public Aspect[] getAspectsSortedAmount() + { + try + { + final Aspect[] out = aspects.keySet().toArray(new Aspect[1]); + boolean change = false; + do + { + change = false; + for(int a = 0; a < out.length - 1; a++) + { + final int e1 = getAmount(out[a]); + final int e2 = getAmount(out[a + 1]); + if(e1 > 0 && e2 > 0 && e2 > e1) + { + final Aspect ea = out[a]; + final Aspect eb = out[a + 1]; out[a] = eb; - out[a+1] = ea; + out[a + 1] = ea; change = true; break; } } - } while (change==true); + } + while(change == true); return out; - } catch (Exception e) { - return this.getAspects(); + } + catch(final Exception e) + { + return getAspects(); } } - + /** * @param key * @return the amount associated with the given aspect in this collection */ - public int getAmount(Aspect key) { - return aspects.get(key)==null?0:aspects.get(key); + public int getAmount(Aspect key) + { + return aspects.get(key) == null ? 0 : aspects.get(key); } - + /** * Reduces the amount of an aspect in this collection by the given amount. * @param key * @param amount * @return */ - public boolean reduce(Aspect key, int amount) { - if (getAmount(key)>=amount) { - int am = getAmount(key)-amount; + public boolean reduce(Aspect key, int amount) + { + if(getAmount(key) >= amount) + { + final int am = getAmount(key) - amount; aspects.put(key, am); return true; } return false; } - + /** * Reduces the amount of an aspect in this collection by the given amount. * If reduced to 0 or less the aspect will be removed completely. @@ -163,24 +201,32 @@ public class AspectList implements Serializable { * @param amount * @return */ - public AspectList remove(Aspect key, int amount) { - int am = getAmount(key)-amount; - if (am<=0) aspects.remove(key); else - this.aspects.put(key, am); + public AspectList remove(Aspect key, int amount) + { + final int am = getAmount(key) - amount; + if(am <= 0) + { + aspects.remove(key); + } + else + { + aspects.put(key, am); + } return this; } - + /** * Simply removes the aspect from the list * @param key * @param amount * @return */ - public AspectList remove(Aspect key) { - aspects.remove(key); + public AspectList remove(Aspect key) + { + aspects.remove(key); return this; } - + /** * Adds this aspect and amount to the collection. * If the aspect exists then its value will be increased by the given amount. @@ -188,16 +234,17 @@ public class AspectList implements Serializable { * @param amount * @return */ - public AspectList add(Aspect aspect, int amount) { - if (this.aspects.containsKey(aspect)) { - int oldamount = this.aspects.get(aspect); - amount+=oldamount; + public AspectList add(Aspect aspect, int amount) + { + if(aspects.containsKey(aspect)) + { + final int oldamount = aspects.get(aspect); + amount += oldamount; } - this.aspects.put( aspect, amount ); + aspects.put(aspect, amount); return this; } - /** * Adds this aspect and amount to the collection. * If the aspect exists then only the highest of the old or new amount will be used. @@ -205,88 +252,107 @@ public class AspectList implements Serializable { * @param amount * @return */ - public AspectList merge(Aspect aspect, int amount) { - if (this.aspects.containsKey(aspect)) { - int oldamount = this.aspects.get(aspect); - if (amount<oldamount) amount=oldamount; - + public AspectList merge(Aspect aspect, int amount) + { + if(aspects.containsKey(aspect)) + { + final int oldamount = aspects.get(aspect); + if(amount < oldamount) + { + amount = oldamount; + } + } - this.aspects.put( aspect, amount ); + aspects.put(aspect, amount); return this; } - - public AspectList add(AspectList in) { - for (Aspect a:in.getAspects()) + + public AspectList add(AspectList in) + { + for(final Aspect a : in.getAspects()) + { this.add(a, in.getAmount(a)); + } return this; } - - public AspectList merge(AspectList in) { - for (Aspect a:in.getAspects()) + + public AspectList merge(AspectList in) + { + for(final Aspect a : in.getAspects()) + { this.merge(a, in.getAmount(a)); + } return this; } - + /** * Reads the list of aspects from nbt * @param nbttagcompound * @return */ public void readFromNBT(NBTTagCompound nbttagcompound) - { - aspects.clear(); - NBTTagList tlist = nbttagcompound.getTagList("Aspects",(byte)10); - for (int j = 0; j < tlist.tagCount(); j++) { - NBTTagCompound rs = (NBTTagCompound) tlist.getCompoundTagAt(j); - if (rs.hasKey("key")) { - add( Aspect.getAspect(rs.getString("key")), - rs.getInteger("amount")); + { + aspects.clear(); + final NBTTagList tlist = nbttagcompound.getTagList("Aspects", (byte) 10); + for(int j = 0; j < tlist.tagCount(); j++) + { + final NBTTagCompound rs = tlist.getCompoundTagAt(j); + if(rs.hasKey("key")) + { + add(Aspect.getAspect(rs.getString("key")), rs.getInteger("amount")); } } - } - + } + public void readFromNBT(NBTTagCompound nbttagcompound, String label) - { - aspects.clear(); - NBTTagList tlist = nbttagcompound.getTagList(label,(byte)10); - for (int j = 0; j < tlist.tagCount(); j++) { - NBTTagCompound rs = (NBTTagCompound) tlist.getCompoundTagAt(j); - if (rs.hasKey("key")) { - add( Aspect.getAspect(rs.getString("key")), - rs.getInteger("amount")); + { + aspects.clear(); + final NBTTagList tlist = nbttagcompound.getTagList(label, (byte) 10); + for(int j = 0; j < tlist.tagCount(); j++) + { + final NBTTagCompound rs = tlist.getCompoundTagAt(j); + if(rs.hasKey("key")) + { + add(Aspect.getAspect(rs.getString("key")), rs.getInteger("amount")); } } - } - + } + /** * Writes the list of aspects to nbt * @param nbttagcompound * @return */ public void writeToNBT(NBTTagCompound nbttagcompound) - { - NBTTagList tlist = new NBTTagList(); + { + final NBTTagList tlist = new NBTTagList(); nbttagcompound.setTag("Aspects", tlist); - for (Aspect aspect : getAspects()) - if (aspect != null) { - NBTTagCompound f = new NBTTagCompound(); + for(final Aspect aspect : getAspects()) + { + if(aspect != null) + { + final NBTTagCompound f = new NBTTagCompound(); f.setString("key", aspect.getTag()); f.setInteger("amount", getAmount(aspect)); tlist.appendTag(f); } - } - + } + } + public void writeToNBT(NBTTagCompound nbttagcompound, String label) - { - NBTTagList tlist = new NBTTagList(); + { + final NBTTagList tlist = new NBTTagList(); nbttagcompound.setTag(label, tlist); - for (Aspect aspect : getAspects()) - if (aspect != null) { - NBTTagCompound f = new NBTTagCompound(); + for(final Aspect aspect : getAspects()) + { + if(aspect != null) + { + final NBTTagCompound f = new NBTTagCompound(); f.setString("key", aspect.getTag()); f.setInteger("amount", getAmount(aspect)); tlist.appendTag(f); } - } - + } + } + } diff --git a/src/api/java/thaumcraft/api/aspects/AspectSourceHelper.java b/src/api/java/thaumcraft/api/aspects/AspectSourceHelper.java index f22d8ce..03abe6c 100644 --- a/src/api/java/thaumcraft/api/aspects/AspectSourceHelper.java +++ b/src/api/java/thaumcraft/api/aspects/AspectSourceHelper.java @@ -6,10 +6,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.FMLLog; -public class AspectSourceHelper { +public class AspectSourceHelper +{ + + static Method drainEssentia; + static Method findEssentia; - static Method drainEssentia; - static Method findEssentia; /** * This method is what is used to drain essentia from jars and other sources for things like * infusion crafting or powering the arcane furnace. A record of possible sources are kept track of @@ -21,19 +23,24 @@ public class AspectSourceHelper { * @param range how many blocks you wish to search for essentia sources. * @return boolean returns true if essentia was found and removed from a source. */ - public static boolean drainEssentia(TileEntity tile, Aspect aspect, ForgeDirection direction, int range) { - try { - if(drainEssentia == null) { - Class fake = Class.forName("thaumcraft.common.lib.events.EssentiaHandler"); - drainEssentia = fake.getMethod("drainEssentia", TileEntity.class, Aspect.class, ForgeDirection.class, int.class); - } - return (Boolean) drainEssentia.invoke(null, tile, aspect, direction, range); - } catch(Exception ex) { - FMLLog.warning("[Thaumcraft API] Could not invoke thaumcraft.common.lib.events.EssentiaHandler method drainEssentia"); - } + public static boolean drainEssentia(TileEntity tile, Aspect aspect, ForgeDirection direction, int range) + { + try + { + if(drainEssentia == null) + { + final Class fake = Class.forName("thaumcraft.common.lib.events.EssentiaHandler"); + drainEssentia = fake.getMethod("drainEssentia", TileEntity.class, Aspect.class, ForgeDirection.class, int.class); + } + return (Boolean) drainEssentia.invoke(null, tile, aspect, direction, range); + } + catch(final Exception ex) + { + FMLLog.warning("[Thaumcraft API] Could not invoke thaumcraft.common.lib.events.EssentiaHandler method drainEssentia"); + } return false; } - + /** * This method returns if there is any essentia of the passed type that can be drained. It in no way checks how * much there is, only if an essentia container nearby contains at least 1 point worth. @@ -43,16 +50,21 @@ public class AspectSourceHelper { * @param range how many blocks you wish to search for essentia sources. * @return boolean returns true if essentia was found and removed from a source. */ - public static boolean findEssentia(TileEntity tile, Aspect aspect, ForgeDirection direction, int range) { - try { - if(findEssentia == null) { - Class fake = Class.forName("thaumcraft.common.lib.events.EssentiaHandler"); - findEssentia = fake.getMethod("findEssentia", TileEntity.class, Aspect.class, ForgeDirection.class, int.class); - } - return (Boolean) findEssentia.invoke(null, tile, aspect, direction, range); - } catch(Exception ex) { - FMLLog.warning("[Thaumcraft API] Could not invoke thaumcraft.common.lib.events.EssentiaHandler method findEssentia"); - } + public static boolean findEssentia(TileEntity tile, Aspect aspect, ForgeDirection direction, int range) + { + try + { + if(findEssentia == null) + { + final Class fake = Class.forName("thaumcraft.common.lib.events.EssentiaHandler"); + findEssentia = fake.getMethod("findEssentia", TileEntity.class, Aspect.class, ForgeDirection.class, int.class); + } + return (Boolean) findEssentia.invoke(null, tile, aspect, direction, range); + } + catch(final Exception ex) + { + FMLLog.warning("[Thaumcraft API] Could not invoke thaumcraft.common.lib.events.EssentiaHandler method findEssentia"); + } return false; } } diff --git a/src/api/java/thaumcraft/api/aspects/IAspectContainer.java b/src/api/java/thaumcraft/api/aspects/IAspectContainer.java index bb34ae8..6b34db3 100644 --- a/src/api/java/thaumcraft/api/aspects/IAspectContainer.java +++ b/src/api/java/thaumcraft/api/aspects/IAspectContainer.java @@ -1,6 +1,5 @@ package thaumcraft.api.aspects; - /** * * @author azanor @@ -9,20 +8,19 @@ package thaumcraft.api.aspects; * Tiles extending this interface will have their aspects show up when viewed by goggles of revealing * */ -public interface IAspectContainer { +public interface IAspectContainer +{ public AspectList getAspects(); - - + public void setAspects(AspectList aspects); - - + /** * This method is used to determine of a specific aspect can be added to this container. * @param tag * @return true or false */ public boolean doesContainerAccept(Aspect tag); - + /** * This method is used to add a certain amount of an aspect to the tile entity. * @param tag @@ -38,7 +36,7 @@ public interface IAspectContainer { * @return true if that amount of aspect was available and was removed */ public boolean takeFromContainer(Aspect tag, int amount); - + /** * removes a bunch of different aspects and amounts from the tile entity. * @param ot the ObjectTags object that contains the aspects and their amounts. @@ -48,15 +46,15 @@ public interface IAspectContainer { */ @Deprecated public boolean takeFromContainer(AspectList ot); - + /** * Checks if the tile entity contains the listed amount (or more) of the aspect * @param tag * @param amount * @return */ - public boolean doesContainerContainAmount(Aspect tag,int amount); - + public boolean doesContainerContainAmount(Aspect tag, int amount); + /** * Checks if the tile entity contains all the listed aspects and their amounts * @param ot the ObjectTags object that contains the aspects and their amounts. @@ -66,15 +64,12 @@ public interface IAspectContainer { */ @Deprecated public boolean doesContainerContain(AspectList ot); - + /** * Returns how much of the aspect this tile entity contains * @param tag * @return the amount of that aspect found */ public int containerContains(Aspect tag); - -} - - +} diff --git a/src/api/java/thaumcraft/api/aspects/IAspectSource.java b/src/api/java/thaumcraft/api/aspects/IAspectSource.java index c01f569..a24ffdd 100644 --- a/src/api/java/thaumcraft/api/aspects/IAspectSource.java +++ b/src/api/java/thaumcraft/api/aspects/IAspectSource.java @@ -1,7 +1,5 @@ package thaumcraft.api.aspects; - - /** * @author Azanor * @@ -9,8 +7,7 @@ package thaumcraft.api.aspects; * so that they can act as an essentia source for blocks like the infusion altar. * */ -public interface IAspectSource extends IAspectContainer { - - - +public interface IAspectSource extends IAspectContainer +{ + } diff --git a/src/api/java/thaumcraft/api/aspects/IEssentiaContainerItem.java b/src/api/java/thaumcraft/api/aspects/IEssentiaContainerItem.java index 6a82c0e..fba289a 100644 --- a/src/api/java/thaumcraft/api/aspects/IEssentiaContainerItem.java +++ b/src/api/java/thaumcraft/api/aspects/IEssentiaContainerItem.java @@ -1,7 +1,6 @@ package thaumcraft.api.aspects; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; /** * @@ -12,8 +11,10 @@ import net.minecraft.nbt.NBTTagCompound; * automatically picks up the aspects they contain * */ -public interface IEssentiaContainerItem { +public interface IEssentiaContainerItem +{ public AspectList getAspects(ItemStack itemstack); + public void setAspects(ItemStack itemstack, AspectList aspects); } @@ -28,10 +29,10 @@ public interface IEssentiaContainerItem { } 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 index fecbc16..5e69de5 100644 --- a/src/api/java/thaumcraft/api/aspects/IEssentiaTransport.java +++ b/src/api/java/thaumcraft/api/aspects/IEssentiaTransport.java @@ -2,40 +2,40 @@ 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 { +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 @@ -44,7 +44,7 @@ public interface IEssentiaTransport { * 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 @@ -52,34 +52,32 @@ public interface IEssentiaTransport { * @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. @@ -94,7 +92,4 @@ public interface IEssentiaTransport { */ boolean renderExtendedTube(); - - } - diff --git a/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java b/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java index 595b6e5..725e21a 100644 --- a/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/CrucibleRecipe.java @@ -8,84 +8,109 @@ import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class CrucibleRecipe { +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) { + private final 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); + aspects = tags; + key = researchKey; + catalyst = cat; + if(cat instanceof String) + { + catalyst = OreDictionary.getOres((String) cat); } String hc = researchKey + result.toString(); - for (Aspect tag:tags.getAspects()) { - hc += tag.getTag()+tags.getAmount(tag); + for(final Aspect tag : tags.getAspects()) + { + hc += tag.getTag() + tags.getAmount(tag); } - if (cat instanceof ItemStack) { - hc += ((ItemStack)cat).toString(); - } else - if (cat instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) { - for (ItemStack is :(ArrayList<ItemStack>)catalyst) { + if(cat instanceof ItemStack) + { + hc += ((ItemStack) cat).toString(); + } + else if(cat instanceof ArrayList && ((ArrayList<ItemStack>) catalyst).size() > 0) + { + for(final ItemStack is : (ArrayList<ItemStack>) catalyst) + { hc += is.toString(); } } - + hash = hc.hashCode(); } - - - public boolean matches(AspectList itags, ItemStack cat) { - if (catalyst instanceof ItemStack && - !ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) { + public boolean matches(AspectList itags, ItemStack cat) + { + if(catalyst instanceof ItemStack && !ThaumcraftApiHelper.itemMatches((ItemStack) catalyst, cat, false)) + { return false; - } else - if (catalyst instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) { - ItemStack[] ores = ((ArrayList<ItemStack>)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)<aspects.getAmount(tag)) return false; + else if(catalyst instanceof ArrayList && ((ArrayList<ItemStack>) catalyst).size() > 0) + { + final ItemStack[] ores = ((ArrayList<ItemStack>) catalyst).toArray(new ItemStack[] {}); + if(!ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {cat}, ores)) + { + return false; + } + } + if(itags == null) + { + return false; + } + for(final Aspect tag : aspects.getAspects()) + { + if(itags.getAmount(tag) < aspects.getAmount(tag)) + { + return false; + } } return true; } - - public boolean catalystMatches(ItemStack cat) { - if (catalyst instanceof ItemStack && ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) { + + public boolean catalystMatches(ItemStack cat) + { + if(catalyst instanceof ItemStack && ThaumcraftApiHelper.itemMatches((ItemStack) catalyst, cat, false)) + { return true; - } else - if (catalyst instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) { - ItemStack[] ores = ((ArrayList<ItemStack>)catalyst).toArray(new ItemStack[]{}); - if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{cat},ores)) return true; + } + else if(catalyst instanceof ArrayList && ((ArrayList<ItemStack>) catalyst).size() > 0) + { + final ItemStack[] ores = ((ArrayList<ItemStack>) catalyst).toArray(new ItemStack[] {}); + if(ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {cat}, ores)) + { + return true; + } } return false; } - - public AspectList removeMatching(AspectList itags) { - AspectList temptags = new AspectList(); + + public AspectList removeMatching(AspectList itags) + { + final AspectList temptags = new AspectList(); temptags.aspects.putAll(itags.aspects); - - for (Aspect tag:aspects.getAspects()) { + + for(final Aspect tag : aspects.getAspects()) + { temptags.remove(tag, aspects.getAmount(tag)); } - + itags = temptags; return itags; } - - public ItemStack getRecipeOutput() { + + public ItemStack getRecipeOutput() + { return recipeOutput; } - } diff --git a/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java b/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java index bb5036d..1b0a933 100644 --- a/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/IArcaneRecipe.java @@ -8,28 +8,29 @@ import thaumcraft.api.aspects.AspectList; public interface IArcaneRecipe { - - - /** - * Used to check if a recipe matches current crafting inventory - * @param player - */ - boolean matches(IInventory var1, World world, EntityPlayer player); - - /** - * Returns an Item that is the result of this recipe - */ - ItemStack getCraftingResult(IInventory var1); - - /** - * Returns the size of the recipe area - */ - int getRecipeSize(); - - ItemStack getRecipeOutput(); - AspectList getAspects(); - AspectList getAspects(IInventory var1); - String getResearch(); - - + + /** + * Used to check if a recipe matches current crafting inventory + * @param player + */ + boolean matches(IInventory var1, World world, EntityPlayer player); + + /** + * Returns an Item that is the result of this recipe + */ + ItemStack getCraftingResult(IInventory var1); + + /** + * Returns the size of the recipe area + */ + int getRecipeSize(); + + ItemStack getRecipeOutput(); + + AspectList getAspects(); + + AspectList getAspects(IInventory var1); + + String getResearch(); + } diff --git a/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java b/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java index d137ff2..f0a1226 100644 --- a/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java +++ b/src/api/java/thaumcraft/api/crafting/IInfusionStabiliser.java @@ -9,8 +9,9 @@ import net.minecraft.world.World; * Blocks that implement this interface act as infusion crafting stabilisers like candles and skulls * */ -public interface IInfusionStabiliser { - +public interface IInfusionStabiliser +{ + /** * returns true if the block can stabilise things */ diff --git a/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java b/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java index bdc5f50..60ed52e 100644 --- a/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/InfusionEnchantmentRecipe.java @@ -15,139 +15,173 @@ import thaumcraft.api.aspects.AspectList; public class InfusionEnchantmentRecipe { - - public AspectList aspects; - public String research; - public ItemStack[] components; - public Enchantment enchantment; - public int recipeXP; - public int instability; - - public InfusionEnchantmentRecipe(String research, Enchantment input, int inst, - AspectList aspects2, ItemStack[] recipe) { + + public AspectList aspects; + public String research; + public ItemStack[] components; + public Enchantment enchantment; + public int recipeXP; + public int instability; + + public InfusionEnchantmentRecipe(String research, Enchantment input, int inst, AspectList aspects2, ItemStack[] recipe) + { this.research = research; - this.enchantment = input; - this.aspects = aspects2; - this.components = recipe; - this.instability = inst; - this.recipeXP = Math.max(1, input.getMinEnchantability(1)/3); + enchantment = input; + aspects = aspects2; + components = recipe; + instability = inst; + recipeXP = Math.max(1, input.getMinEnchantability(1) / 3); } /** - * Used to check if a recipe matches current crafting inventory - * @param player - */ - public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) { - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - - if (!enchantment.canApply(central) || !central.getItem().isItemTool(central)) { + * Used to check if a recipe matches current crafting inventory + * @param player + */ + public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) + { + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + + if(!enchantment.canApply(central) || !central.getItem().isItemTool(central)) + { return false; } - - Map map1 = EnchantmentHelper.getEnchantments(central); - Iterator iterator = map1.keySet().iterator(); - while (iterator.hasNext()) - { - int j1 = ((Integer)iterator.next()).intValue(); - Enchantment ench = Enchantment.enchantmentsList[j1]; - if (j1 == enchantment.effectId && - EnchantmentHelper.getEnchantmentLevel(j1, central)>=ench.getMaxLevel()) - return false; - if (enchantment.effectId != ench.effectId && - (!enchantment.canApplyTogether(ench) || - !ench.canApplyTogether(enchantment))) { - return false; - } - } - + + final Map map1 = EnchantmentHelper.getEnchantments(central); + final Iterator iterator = map1.keySet().iterator(); + while(iterator.hasNext()) + { + final int j1 = ((Integer) iterator.next()).intValue(); + final Enchantment ench = Enchantment.enchantmentsList[j1]; + if(j1 == enchantment.effectId && EnchantmentHelper.getEnchantmentLevel(j1, central) >= ench.getMaxLevel()) + { + return false; + } + if(enchantment.effectId != ench.effectId && (!enchantment.canApplyTogether(ench) || !ench.canApplyTogether(enchantment))) + { + return false; + } + } + ItemStack i2 = null; - - ArrayList<ItemStack> ii = new ArrayList<ItemStack>(); - for (ItemStack is:input) { + + final ArrayList<ItemStack> ii = new ArrayList<ItemStack>(); + for(final ItemStack is : input) + { ii.add(is.copy()); } - - for (ItemStack comp:components) { - boolean b=false; - for (int a=0;a<ii.size();a++) { - i2 = ii.get(a).copy(); - if (comp.getItemDamage()==OreDictionary.WILDCARD_VALUE) { + + for(final ItemStack comp : components) + { + boolean b = false; + for(int a = 0; a < ii.size(); a++) + { + i2 = ii.get(a).copy(); + if(comp.getItemDamage() == OreDictionary.WILDCARD_VALUE) + { i2.setItemDamage(OreDictionary.WILDCARD_VALUE); } - if (areItemStacksEqual(i2, comp,true)) { + if(areItemStacksEqual(i2, comp, true)) + { ii.remove(a); - b=true; + b = true; break; } } - if (!b) return false; + if(!b) + { + return false; + } } -// System.out.println(ii.size()); - return ii.size()==0?true:false; - } - + // System.out.println(ii.size()); + return ii.size() == 0 ? true : false; + } + protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy) - { - if (stack0==null && stack1!=null) return false; - if (stack0!=null && stack1==null) return false; - if (stack0==null && stack1==null) return true; - boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1); - if (!t1) return false; - if (fuzzy) { - Integer od = OreDictionary.getOreID(stack0); - if (od!=-1) { - ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{}); - if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores)) + { + if(stack0 == null && stack1 != null) + { + return false; + } + if(stack0 != null && stack1 == null) + { + return false; + } + if(stack0 == null && stack1 == null) + { + return true; + } + final boolean t1 = ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1); + if(!t1) + { + return false; + } + if(fuzzy) + { + final Integer od = OreDictionary.getOreID(stack0); + if(od != -1) + { + final ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[] {}); + if(ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {stack1}, ores)) + { return true; + } } } - return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() ); - } - - - public Enchantment getEnchantment() { + return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize()); + } + + public Enchantment getEnchantment() + { return enchantment; - - } - - public AspectList getAspects() { + + } + + public AspectList getAspects() + { return aspects; - - } - - public String getResearch() { + + } + + public String getResearch() + { return research; - - } - public int calcInstability(ItemStack recipeInput) { + } + + public int calcInstability(ItemStack recipeInput) + { int i = 0; - Map map1 = EnchantmentHelper.getEnchantments(recipeInput); - Iterator iterator = map1.keySet().iterator(); - while (iterator.hasNext()) - { - int j1 = ((Integer)iterator.next()).intValue(); - i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); - } - return (i/2) + instability; + final Map map1 = EnchantmentHelper.getEnchantments(recipeInput); + final Iterator iterator = map1.keySet().iterator(); + while(iterator.hasNext()) + { + final int j1 = ((Integer) iterator.next()).intValue(); + i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); + } + return (i / 2) + instability; } - public int calcXP(ItemStack recipeInput) { - return recipeXP * (1+EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput)); + public int calcXP(ItemStack recipeInput) + { + return recipeXP * (1 + EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput)); } - public float getEssentiaMod(ItemStack recipeInput) { + public float getEssentiaMod(ItemStack recipeInput) + { float mod = EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput); - Map map1 = EnchantmentHelper.getEnchantments(recipeInput); - Iterator iterator = map1.keySet().iterator(); - while (iterator.hasNext()) - { - int j1 = ((Integer)iterator.next()).intValue(); - if (j1 != enchantment.effectId) - mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; - } + final Map map1 = EnchantmentHelper.getEnchantments(recipeInput); + final Iterator iterator = map1.keySet().iterator(); + while(iterator.hasNext()) + { + final int j1 = ((Integer) iterator.next()).intValue(); + if(j1 != enchantment.effectId) + { + mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; + } + } return mod; } diff --git a/src/api/java/thaumcraft/api/crafting/InfusionRecipe.java b/src/api/java/thaumcraft/api/crafting/InfusionRecipe.java index d786b81..93d1121 100644 --- a/src/api/java/thaumcraft/api/crafting/InfusionRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/InfusionRecipe.java @@ -11,123 +11,164 @@ import thaumcraft.api.aspects.AspectList; public class InfusionRecipe { - protected AspectList aspects; - protected String research; - private ItemStack[] components; - private ItemStack recipeInput; - protected Object recipeOutput; - protected int instability; - - public InfusionRecipe(String research, Object output, int inst, - AspectList aspects2, ItemStack input, ItemStack[] recipe) { + protected AspectList aspects; + protected String research; + private final ItemStack[] components; + private final ItemStack recipeInput; + protected Object recipeOutput; + protected int instability; + + public InfusionRecipe(String research, Object output, int inst, AspectList aspects2, ItemStack input, ItemStack[] recipe) + { this.research = research; - this.recipeOutput = output; - this.recipeInput = input; - this.aspects = aspects2; - this.components = recipe; - this.instability = inst; + recipeOutput = output; + recipeInput = input; + aspects = aspects2; + components = recipe; + instability = inst; } /** - * Used to check if a recipe matches current crafting inventory - * @param player - */ - public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) { - if (getRecipeInput()==null) return false; - - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - + * Used to check if a recipe matches current crafting inventory + * @param player + */ + public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) + { + if(getRecipeInput() == null) + { + return false; + } + + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + ItemStack i2 = central.copy(); - if (getRecipeInput().getItemDamage()==OreDictionary.WILDCARD_VALUE) { + if(getRecipeInput().getItemDamage() == OreDictionary.WILDCARD_VALUE) + { i2.setItemDamage(OreDictionary.WILDCARD_VALUE); } - - if (!areItemStacksEqual(i2, getRecipeInput(), true)) return false; - - ArrayList<ItemStack> ii = new ArrayList<ItemStack>(); - for (ItemStack is:input) { + + if(!areItemStacksEqual(i2, getRecipeInput(), true)) + { + return false; + } + + final ArrayList<ItemStack> ii = new ArrayList<ItemStack>(); + for(final ItemStack is : input) + { ii.add(is.copy()); } - - for (ItemStack comp:getComponents()) { - boolean b=false; - for (int a=0;a<ii.size();a++) { - i2 = ii.get(a).copy(); - if (comp.getItemDamage()==OreDictionary.WILDCARD_VALUE) { + + for(final ItemStack comp : getComponents()) + { + boolean b = false; + for(int a = 0; a < ii.size(); a++) + { + i2 = ii.get(a).copy(); + if(comp.getItemDamage() == OreDictionary.WILDCARD_VALUE) + { i2.setItemDamage(OreDictionary.WILDCARD_VALUE); } - if (areItemStacksEqual(i2, comp,true)) { + if(areItemStacksEqual(i2, comp, true)) + { ii.remove(a); - b=true; + b = true; break; } } - if (!b) return false; + if(!b) + { + return false; + } } - return ii.size()==0?true:false; - } - + return ii.size() == 0 ? true : false; + } + public static boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy) - { - if (stack0==null && stack1!=null) return false; - if (stack0!=null && stack1==null) return false; - if (stack0==null && stack1==null) return true; - + { + if(stack0 == null && stack1 != null) + { + return false; + } + if(stack0 != null && stack1 == null) + { + return false; + } + if(stack0 == null && stack1 == null) + { + return true; + } + //nbt - boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1); - if (!t1) return false; - - if (fuzzy) { - Integer od = OreDictionary.getOreID(stack0); - if (od!=-1) { - ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{}); - if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores)) + final boolean t1 = ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1); + if(!t1) + { + return false; + } + + if(fuzzy) + { + final Integer od = OreDictionary.getOreID(stack0); + if(od != -1) + { + final ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[] {}); + if(ThaumcraftApiHelper.containsMatch(false, new ItemStack[] {stack1}, ores)) + { return true; + } } } - + //damage - boolean damage = stack0.getItemDamage() == stack1.getItemDamage() || - stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE; - - return stack0.getItem() != stack1.getItem() ? false : (!damage ? false : stack0.stackSize <= stack0.getMaxStackSize() ); - } - - public Object getRecipeOutput() { - return getRecipeOutput(this.getRecipeInput()); - } - - public AspectList getAspects() { - return getAspects(this.getRecipeInput()); - } - - public int getInstability() { - return getInstability(this.getRecipeInput()); - } - - public String getResearch() { + final boolean damage = stack0.getItemDamage() == stack1.getItemDamage() || stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE; + + return stack0.getItem() != stack1.getItem() ? false : (!damage ? false : stack0.stackSize <= stack0.getMaxStackSize()); + } + + public Object getRecipeOutput() + { + return getRecipeOutput(getRecipeInput()); + } + + public AspectList getAspects() + { + return getAspects(getRecipeInput()); + } + + public int getInstability() + { + return getInstability(getRecipeInput()); + } + + public String getResearch() + { return research; - } - - public ItemStack getRecipeInput() { + } + + public ItemStack getRecipeInput() + { return recipeInput; } - public ItemStack[] getComponents() { + public ItemStack[] getComponents() + { return components; } - - public Object getRecipeOutput(ItemStack input) { + + public Object getRecipeOutput(ItemStack input) + { return recipeOutput; - } - - public AspectList getAspects(ItemStack input) { + } + + public AspectList getAspects(ItemStack input) + { return aspects; - } - - public int getInstability(ItemStack input) { + } + + public int getInstability(ItemStack input) + { return instability; - } + } } diff --git a/src/api/java/thaumcraft/api/crafting/ShapedArcaneRecipe.java b/src/api/java/thaumcraft/api/crafting/ShapedArcaneRecipe.java index 1490110..a76eed0 100644 --- a/src/api/java/thaumcraft/api/crafting/ShapedArcaneRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/ShapedArcaneRecipe.java @@ -15,247 +15,267 @@ import thaumcraft.api.aspects.AspectList; public class ShapedArcaneRecipe implements IArcaneRecipe { - //Added in for future ease of change, but hard coded for now. - private static final int MAX_CRAFT_GRID_WIDTH = 3; - private static final int MAX_CRAFT_GRID_HEIGHT = 3; - - public ItemStack output = null; - public Object[] input = null; - public AspectList aspects = null; - public String research; - public int width = 0; - public int height = 0; - private boolean mirrored = true; - - public ShapedArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe){ this(research, new ItemStack(result), aspects, recipe); } - public ShapedArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe){ this(research, new ItemStack(result), aspects, recipe); } - public ShapedArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) - { - output = result.copy(); - this.research = research; - this.aspects = aspects; - String shape = ""; - - int idx = 0; - - if (recipe[idx] instanceof Boolean) - { - mirrored = (Boolean)recipe[idx]; - if (recipe[idx+1] instanceof Object[]) - { - recipe = (Object[])recipe[idx+1]; - } - else - { - idx = 1; - } - } - - if (recipe[idx] instanceof String[]) - { - String[] parts = ((String[])recipe[idx++]); - - for (String s : parts) - { - width = s.length(); - shape += s; - } - - height = parts.length; - } - else - { - while (recipe[idx] instanceof String) - { - String s = (String)recipe[idx++]; - shape += s; - width = s.length(); - height++; - } - } - - if (width * height != shape.length()) - { - String ret = "Invalid shaped ore recipe: "; - for (Object tmp : recipe) - { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } - - HashMap<Character, Object> itemMap = new HashMap<Character, Object>(); - - 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<ItemStack>)target) - { - matched = matched || checkItemEquals(item, slot); - } - - if (!matched) - { - return false; - } - } - else if (target == null && slot != null) - { - return false; - } - } - } - - return true; - } - - private boolean checkItemEquals(ItemStack target, ItemStack input) - { - if (input == null && target != null || input != null && target == null) - { - return false; - } - return (target.getItem() == input.getItem() && - (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) && - (target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage())); - } - - public ShapedArcaneRecipe setMirrored(boolean mirror) - { - mirrored = mirror; - return this; - } - - /** - * Returns the input for this recipe, any mod accessing this value should never - * manipulate the values in this array as it will effect the recipe itself. - * @return The recipes input vales. - */ - public Object[] getInput() - { - return this.input; - } - - @Override - public AspectList getAspects() { + //Added in for future ease of change, but hard coded for now. + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; + + public ItemStack output = null; + public Object[] input = null; + public AspectList aspects = null; + public String research; + public int width = 0; + public int height = 0; + private boolean mirrored = true; + + public ShapedArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapedArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapedArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + output = result.copy(); + this.research = research; + this.aspects = aspects; + String shape = ""; + + int idx = 0; + + if(recipe[idx] instanceof Boolean) + { + mirrored = (Boolean) recipe[idx]; + if(recipe[idx + 1] instanceof Object[]) + { + recipe = (Object[]) recipe[idx + 1]; + } + else + { + idx = 1; + } + } + + if(recipe[idx] instanceof String[]) + { + final String[] parts = ((String[]) recipe[idx++]); + + for(final String s : parts) + { + width = s.length(); + shape += s; + } + + height = parts.length; + } + else + { + while(recipe[idx] instanceof String) + { + final String s = (String) recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } + + if(width * height != shape.length()) + { + String ret = "Invalid shaped ore recipe: "; + for(final Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + + final HashMap<Character, Object> itemMap = new HashMap<Character, Object>(); + + for(; idx < recipe.length; idx += 2) + { + final Character chr = (Character) recipe[idx]; + final Object in = recipe[idx + 1]; + + if(in instanceof ItemStack) + { + itemMap.put(chr, ((ItemStack) in).copy()); + } + else if(in instanceof Item) + { + itemMap.put(chr, new ItemStack((Item) in)); + } + else if(in instanceof Block) + { + itemMap.put(chr, new ItemStack((Block) in, 1, + OreDictionary.WILDCARD_VALUE)); + } + else if(in instanceof String) + { + itemMap.put(chr, OreDictionary.getOres((String) in)); + } + else + { + String ret = "Invalid shaped ore recipe: "; + for(final Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + + input = new Object[width * height]; + int x = 0; + for(final char chr : shape.toCharArray()) + { + input[x++] = itemMap.get(chr); + } + } + + @Override + public ItemStack getCraftingResult(IInventory var1) + { + return output.copy(); + } + + @Override + public int getRecipeSize() + { + return input.length; + } + + @Override + public ItemStack getRecipeOutput() + { + return output; + } + + @Override + public boolean matches(IInventory inv, World world, EntityPlayer player) + { + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + for(int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) + { + for(int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) + { + if(checkMatch(inv, x, y, false)) + { + return true; + } + + if(mirrored && checkMatch(inv, x, y, true)) + { + return true; + } + } + } + + return false; + } + + private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror) + { + for(int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) + { + for(int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) + { + final int subX = x - startX; + final int subY = y - startY; + Object target = null; + + if(subX >= 0 && subY >= 0 && subX < width && subY < height) + { + if(mirror) + { + target = input[width - subX - 1 + subY * width]; + } + else + { + target = input[subX + subY * width]; + } + } + + final ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y); + + if(target instanceof ItemStack) + { + if(!checkItemEquals((ItemStack) target, slot)) + { + return false; + } + } + else if(target instanceof ArrayList) + { + boolean matched = false; + + for(final ItemStack item : (ArrayList<ItemStack>) target) + { + matched = matched || checkItemEquals(item, slot); + } + + if(!matched) + { + return false; + } + } + else if(target == null && slot != null) + { + return false; + } + } + } + + return true; + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + if(input == null && target != null || input != null && target == null) + { + return false; + } + return(target.getItem() == input.getItem() && (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input, target)) && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage())); + } + + public ShapedArcaneRecipe setMirrored(boolean mirror) + { + mirrored = mirror; + return this; + } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public Object[] getInput() + { + return input; + } + + @Override + public AspectList getAspects() + { return aspects; } - - @Override - public AspectList getAspects(IInventory inv) { + + @Override + public AspectList getAspects(IInventory inv) + { return aspects; } - + @Override - public String getResearch() { + public String getResearch() + { return research; } } diff --git a/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java b/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java index 3b1eaeb..d6890c1 100644 --- a/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java +++ b/src/api/java/thaumcraft/api/crafting/ShapelessArcaneRecipe.java @@ -15,147 +15,165 @@ import thaumcraft.api.aspects.AspectList; public class ShapelessArcaneRecipe implements IArcaneRecipe { - private ItemStack output = null; - private ArrayList input = new ArrayList(); - - public AspectList aspects = null; - public String research; - - public ShapelessArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe){ this(research,new ItemStack(result),aspects, recipe); } - public ShapelessArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe){ this(research,new ItemStack(result),aspects, recipe); } - - public ShapelessArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) - { - output = result.copy(); - this.research = research; - this.aspects = aspects; - for (Object in : recipe) - { - if (in instanceof ItemStack) - { - input.add(((ItemStack)in).copy()); - } - else if (in instanceof Item) - { - input.add(new ItemStack((Item)in)); - } - else if (in instanceof Block) - { - input.add(new ItemStack((Block)in)); - } - else if (in instanceof String) - { - input.add(OreDictionary.getOres((String)in)); - } - else - { - String ret = "Invalid shapeless ore recipe: "; - for (Object tmp : recipe) - { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } - } - } - - @Override - public int getRecipeSize(){ return input.size(); } - - @Override - public ItemStack getRecipeOutput(){ return output; } - - @Override - public ItemStack getCraftingResult(IInventory var1){ return output.copy(); } - - @Override - public boolean matches(IInventory var1, World world, EntityPlayer player) - { - if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { - return false; - } - - ArrayList required = new ArrayList(input); - - for (int x = 0; x < 9; x++) - { - ItemStack slot = var1.getStackInSlot(x); - - if (slot != null) - { - boolean inRecipe = false; - Iterator req = required.iterator(); - - while (req.hasNext()) - { - boolean match = false; - - Object next = req.next(); - - if (next instanceof ItemStack) - { - match = checkItemEquals((ItemStack)next, slot); - } - else if (next instanceof ArrayList) - { - for (ItemStack item : (ArrayList<ItemStack>)next) - { - match = match || checkItemEquals(item, slot); - } - } - - if (match) - { - inRecipe = true; - required.remove(next); - break; - } - } - - if (!inRecipe) - { - return false; - } - } - } - - return required.isEmpty(); - } - - private boolean checkItemEquals(ItemStack target, ItemStack input) - { - if (input == null && target != null || input != null && target == null) - { - return false; - } - return (target.getItem() == input.getItem() && - (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) && - (target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage())); - } - - /** - * Returns the input for this recipe, any mod accessing this value should never - * manipulate the values in this array as it will effect the recipe itself. - * @return The recipes input vales. - */ - public ArrayList getInput() - { - return this.input; - } - - @Override - public AspectList getAspects() { + private ItemStack output = null; + private final ArrayList input = new ArrayList(); + + public AspectList aspects = null; + public String research; + + public ShapelessArcaneRecipe(String research, Block result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapelessArcaneRecipe(String research, Item result, AspectList aspects, Object... recipe) + { + this(research, new ItemStack(result), aspects, recipe); + } + + public ShapelessArcaneRecipe(String research, ItemStack result, AspectList aspects, Object... recipe) + { + output = result.copy(); + this.research = research; + this.aspects = aspects; + for(final Object in : recipe) + { + if(in instanceof ItemStack) + { + input.add(((ItemStack) in).copy()); + } + else if(in instanceof Item) + { + input.add(new ItemStack((Item) in)); + } + else if(in instanceof Block) + { + input.add(new ItemStack((Block) in)); + } + else if(in instanceof String) + { + input.add(OreDictionary.getOres((String) in)); + } + else + { + String ret = "Invalid shapeless ore recipe: "; + for(final Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + } + + @Override + public int getRecipeSize() + { + return input.size(); + } + + @Override + public ItemStack getRecipeOutput() + { + return output; + } + + @Override + public ItemStack getCraftingResult(IInventory var1) + { + return output.copy(); + } + + @Override + public boolean matches(IInventory var1, World world, EntityPlayer player) + { + if(research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) + { + return false; + } + + final ArrayList required = new ArrayList(input); + + for(int x = 0; x < 9; x++) + { + final ItemStack slot = var1.getStackInSlot(x); + + if(slot != null) + { + boolean inRecipe = false; + final Iterator req = required.iterator(); + + while(req.hasNext()) + { + boolean match = false; + + final Object next = req.next(); + + if(next instanceof ItemStack) + { + match = checkItemEquals((ItemStack) next, slot); + } + else if(next instanceof ArrayList) + { + for(final ItemStack item : (ArrayList<ItemStack>) next) + { + match = match || checkItemEquals(item, slot); + } + } + + if(match) + { + inRecipe = true; + required.remove(next); + break; + } + } + + if(!inRecipe) + { + return false; + } + } + } + + return required.isEmpty(); + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + if(input == null && target != null || input != null && target == null) + { + return false; + } + return(target.getItem() == input.getItem() && (!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input, target)) && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage())); + } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public ArrayList getInput() + { + return input; + } + + @Override + public AspectList getAspects() + { return aspects; } - - @Override - public AspectList getAspects(IInventory inv) { + + @Override + public AspectList getAspects(IInventory inv) + { return aspects; } - + @Override - public String getResearch() { + public String getResearch() + { return research; } } diff --git a/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java b/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java index 1562d05..52fc3c3 100644 --- a/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java +++ b/src/api/java/thaumcraft/api/damagesource/DamageSourceIndirectThaumcraftEntity.java @@ -4,29 +4,23 @@ import net.minecraft.entity.Entity; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSourceIndirect; -public class DamageSourceIndirectThaumcraftEntity extends EntityDamageSourceIndirect { +public class DamageSourceIndirectThaumcraftEntity extends EntityDamageSourceIndirect +{ - private boolean fireDamage; - private float hungerDamage; - private boolean isUnblockable; - - - public DamageSourceIndirectThaumcraftEntity(String par1Str, - Entity par2Entity, Entity par3Entity) { + public DamageSourceIndirectThaumcraftEntity(String par1Str, Entity par2Entity, Entity par3Entity) + { super(par1Str, par2Entity, par3Entity); } - + @Override public DamageSource setFireDamage() - { - this.fireDamage = true; - return this; - } - + { + return this; + } + + @Override public DamageSource setDamageBypassesArmor() - { - this.isUnblockable = true; - this.hungerDamage = 0.0F; - return this; - } + { + return this; + } } diff --git a/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java b/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java index bb55672..a05f5c5 100644 --- a/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java +++ b/src/api/java/thaumcraft/api/damagesource/DamageSourceThaumcraft.java @@ -6,42 +6,29 @@ import net.minecraft.util.EntityDamageSource; public class DamageSourceThaumcraft extends DamageSource { - - public static DamageSource taint = new DamageSourceThaumcraft("taint").setDamageBypassesArmor().setMagicDamage(); - public static DamageSource tentacle = new DamageSourceThaumcraft("tentacle"); - public static DamageSource swarm = new DamageSourceThaumcraft("swarm"); - public static DamageSource dissolve = new DamageSourceThaumcraft("dissolve").setDamageBypassesArmor(); - - protected DamageSourceThaumcraft(String par1Str) { + + public static DamageSource taint = new DamageSourceThaumcraft( + "taint").setDamageBypassesArmor().setMagicDamage(); + public static DamageSource tentacle = new DamageSourceThaumcraft( + "tentacle"); + public static DamageSource swarm = new DamageSourceThaumcraft( + "swarm"); + public static DamageSource dissolve = new DamageSourceThaumcraft( + "dissolve").setDamageBypassesArmor(); + + protected DamageSourceThaumcraft(String par1Str) + { super(par1Str); } - - /** This kind of damage can be blocked or not. */ - private boolean isUnblockable = false; - private boolean isDamageAllowedInCreativeMode = false; - private float hungerDamage = 0.3F; - - /** This kind of damage is based on fire or not. */ - private boolean fireDamage; - /** This kind of damage is based on a projectile or not. */ - private boolean projectile; + public static DamageSource causeSwarmDamage(EntityLivingBase par0EntityLiving) + { + return new EntityDamageSource("swarm", par0EntityLiving); + } - /** - * Whether this damage source will have its damage amount scaled based on the current difficulty. - */ - private boolean difficultyScaled; - private boolean magicDamage = false; - private boolean explosion = false; - - public static DamageSource causeSwarmDamage(EntityLivingBase par0EntityLiving) - { - return new EntityDamageSource("swarm", par0EntityLiving); - } + public static DamageSource causeTentacleDamage(EntityLivingBase par0EntityLiving) + { + return new EntityDamageSource("tentacle", par0EntityLiving); + } - public static DamageSource causeTentacleDamage(EntityLivingBase par0EntityLiving) - { - return new EntityDamageSource("tentacle", par0EntityLiving); - } - } diff --git a/src/api/java/thaumcraft/api/entities/IEldritchMob.java b/src/api/java/thaumcraft/api/entities/IEldritchMob.java index 79fc75b..a23d228 100644 --- a/src/api/java/thaumcraft/api/entities/IEldritchMob.java +++ b/src/api/java/thaumcraft/api/entities/IEldritchMob.java @@ -1,5 +1,6 @@ package thaumcraft.api.entities; -public interface IEldritchMob { +public interface IEldritchMob +{ } diff --git a/src/api/java/thaumcraft/api/entities/ITaintedMob.java b/src/api/java/thaumcraft/api/entities/ITaintedMob.java index 83fb1fc..1b1b793 100644 --- a/src/api/java/thaumcraft/api/entities/ITaintedMob.java +++ b/src/api/java/thaumcraft/api/entities/ITaintedMob.java @@ -1,5 +1,6 @@ package thaumcraft.api.entities; -public interface ITaintedMob { +public interface ITaintedMob +{ } diff --git a/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java b/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java index 9af8c30..fcf31de 100644 --- a/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java +++ b/src/api/java/thaumcraft/api/internal/DummyInternalMethodHandler.java @@ -6,73 +6,83 @@ import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class DummyInternalMethodHandler implements IInternalMethodHandler { +public class DummyInternalMethodHandler implements IInternalMethodHandler +{ @Override - public void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) { - + public void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) + { + } @Override - public boolean isResearchComplete(String username, String researchkey) { + public boolean isResearchComplete(String username, String researchkey) + { return false; } - + @Override - public boolean hasDiscoveredAspect(String username, Aspect aspect) { + public boolean hasDiscoveredAspect(String username, Aspect aspect) + { return false; } - + @Override - public AspectList getDiscoveredAspects(String username) { + public AspectList getDiscoveredAspects(String username) + { return null; } @Override - public ItemStack getStackInRowAndColumn(Object instance, int row, int column) { + public ItemStack getStackInRowAndColumn(Object instance, int row, int column) + { return null; } @Override - public AspectList getObjectAspects(ItemStack is) { + public AspectList getObjectAspects(ItemStack is) + { return null; } @Override - public AspectList getBonusObjectTags(ItemStack is, AspectList ot) { + public AspectList getBonusObjectTags(ItemStack is, AspectList ot) + { return null; } @Override - public AspectList generateTags(Item item, int meta) { + public AspectList generateTags(Item item, int meta) + { return null; } @Override - public boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, - AspectList cost, boolean doit, boolean crafting) { + public boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit, boolean crafting) + { return false; } @Override - public boolean consumeVisFromWandCrafting(ItemStack wand, - EntityPlayer player, AspectList cost, boolean doit) { + public boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit) + { return false; } @Override - public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) { + public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost) + { return false; } @Override - public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) { + public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) + { } @Override - public void addStickyWarpToPlayer(EntityPlayer player, int amount) { + public void addStickyWarpToPlayer(EntityPlayer player, int amount) + { } - - } diff --git a/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java b/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java index 73fce66..749c954 100644 --- a/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java +++ b/src/api/java/thaumcraft/api/internal/IInternalMethodHandler.java @@ -6,20 +6,33 @@ import net.minecraft.item.ItemStack; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public interface IInternalMethodHandler { +public interface IInternalMethodHandler +{ public void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color); + public boolean isResearchComplete(String username, String researchkey); + public ItemStack getStackInRowAndColumn(Object instance, int row, int column); + public AspectList getObjectAspects(ItemStack is); - public AspectList getBonusObjectTags(ItemStack is,AspectList ot); + + public AspectList getBonusObjectTags(ItemStack is, AspectList ot); + public AspectList generateTags(Item item, int meta); + public boolean consumeVisFromWand(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit, boolean crafting); - public boolean consumeVisFromWandCrafting(ItemStack wand,EntityPlayer player, AspectList cost, boolean doit); + + public boolean consumeVisFromWandCrafting(ItemStack wand, EntityPlayer player, AspectList cost, boolean doit); + public boolean consumeVisFromInventory(EntityPlayer player, AspectList cost); - public void addWarpToPlayer(EntityPlayer player, int amount,boolean temporary); + + public void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary); + public void addStickyWarpToPlayer(EntityPlayer player, int amount); + public boolean hasDiscoveredAspect(String username, Aspect aspect); + public AspectList getDiscoveredAspects(String username); - + } diff --git a/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java b/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java index 4ac6ee7..9ea95dd 100644 --- a/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java +++ b/src/api/java/thaumcraft/api/internal/WeightedRandomLoot.java @@ -5,20 +5,20 @@ import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandom; +public class WeightedRandomLoot extends WeightedRandom.Item +{ -public class WeightedRandomLoot extends WeightedRandom.Item { - /** The Item/Block ID to generate in the bag. */ - public ItemStack item; + public ItemStack item; + + public WeightedRandomLoot(ItemStack stack, int weight) + { + super(weight); + item = stack; + } + + public static ArrayList<WeightedRandomLoot> lootBagCommon = new ArrayList<WeightedRandomLoot>(); + public static ArrayList<WeightedRandomLoot> lootBagUncommon = new ArrayList<WeightedRandomLoot>(); + public static ArrayList<WeightedRandomLoot> lootBagRare = new ArrayList<WeightedRandomLoot>(); - public WeightedRandomLoot(ItemStack stack, int weight) - { - super(weight); - this.item = stack; - } - - public static ArrayList<WeightedRandomLoot> lootBagCommon = new ArrayList<WeightedRandomLoot>(); - public static ArrayList<WeightedRandomLoot> lootBagUncommon = new ArrayList<WeightedRandomLoot>(); - public static ArrayList<WeightedRandomLoot> lootBagRare = new ArrayList<WeightedRandomLoot>(); - } diff --git a/src/api/java/thaumcraft/api/nodes/INode.java b/src/api/java/thaumcraft/api/nodes/INode.java index 61da1f7..4ef8fee 100644 --- a/src/api/java/thaumcraft/api/nodes/INode.java +++ b/src/api/java/thaumcraft/api/nodes/INode.java @@ -4,16 +4,17 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.IAspectContainer; -public interface INode extends IAspectContainer { +public interface INode extends IAspectContainer +{ /** * Unique identifier to distinguish nodes. Normal node id's are based on world id and coordinates * @return */ public String getId(); - + public AspectList getAspectsBase(); - + /** * Return the type of node * @return @@ -31,13 +32,13 @@ public interface INode extends IAspectContainer { * @return */ public void setNodeModifier(NodeModifier nodeModifier); - + /** * Return the node modifier * @return */ public NodeModifier getNodeModifier(); - + /** * Return the maximum capacity of each aspect the node can hold * @return @@ -49,5 +50,5 @@ public interface INode extends IAspectContainer { * @return */ public void setNodeVisBase(Aspect aspect, short nodeVisBase); - + } diff --git a/src/api/java/thaumcraft/api/nodes/IRevealer.java b/src/api/java/thaumcraft/api/nodes/IRevealer.java index 14a19b5..0f241e1 100644 --- a/src/api/java/thaumcraft/api/nodes/IRevealer.java +++ b/src/api/java/thaumcraft/api/nodes/IRevealer.java @@ -11,12 +11,12 @@ import net.minecraft.item.ItemStack; * */ -public interface IRevealer { - +public interface IRevealer +{ + /* * If this method returns true the nodes will be visible. */ public boolean showNodes(ItemStack itemstack, EntityLivingBase player); - } diff --git a/src/api/java/thaumcraft/api/nodes/NodeModifier.java b/src/api/java/thaumcraft/api/nodes/NodeModifier.java index 885b867..2e0e95e 100644 --- a/src/api/java/thaumcraft/api/nodes/NodeModifier.java +++ b/src/api/java/thaumcraft/api/nodes/NodeModifier.java @@ -2,5 +2,5 @@ package thaumcraft.api.nodes; public enum NodeModifier { - BRIGHT, PALE, FADING -}
\ No newline at end of file + BRIGHT, PALE, FADING +} diff --git a/src/api/java/thaumcraft/api/nodes/NodeType.java b/src/api/java/thaumcraft/api/nodes/NodeType.java index 355324b..4fc26c3 100644 --- a/src/api/java/thaumcraft/api/nodes/NodeType.java +++ b/src/api/java/thaumcraft/api/nodes/NodeType.java @@ -2,5 +2,5 @@ package thaumcraft.api.nodes; public enum NodeType { - NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE -}
\ No newline at end of file + NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE +} diff --git a/src/api/java/thaumcraft/api/package-info.java b/src/api/java/thaumcraft/api/package-info.java index cceaf89..4de2404 100644 --- a/src/api/java/thaumcraft/api/package-info.java +++ b/src/api/java/thaumcraft/api/package-info.java @@ -2,3 +2,4 @@ package thaumcraft.api; import cpw.mods.fml.common.API; + diff --git a/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java b/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java index b950de0..facc2cc 100644 --- a/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java +++ b/src/api/java/thaumcraft/api/potions/PotionFluxTaint.java @@ -12,56 +12,59 @@ import cpw.mods.fml.relauncher.SideOnly; public class PotionFluxTaint extends Potion { - public static PotionFluxTaint instance = null; // will be instantiated at runtime - private int statusIconIndex = -1; - - public PotionFluxTaint(int par1, boolean par2, int par3) - { - super(par1,par2,par3); - setIconIndex(0, 0); - } - - public static void init() - { - instance.setPotionName("potion.fluxtaint"); - instance.setIconIndex(3, 1); - instance.setEffectiveness(0.25D); - } - + public static PotionFluxTaint instance = null; // will be instantiated at runtime + public PotionFluxTaint(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + setIconIndex(0, 0); + } + + public static void init() + { + instance.setPotionName("potion.fluxtaint"); + instance.setIconIndex(3, 1); + instance.setEffectiveness(0.25D); + } + @Override - public boolean isBadEffect() { + public boolean isBadEffect() + { return true; } @Override @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { + public int getStatusIconIndex() + { Minecraft.getMinecraft().renderEngine.bindTexture(rl); return super.getStatusIconIndex(); } - - static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png"); - + + static final ResourceLocation rl = new ResourceLocation("thaumcraft", + "textures/misc/potions.png"); + @Override - public void performEffect(EntityLivingBase target, int par2) { - if (target instanceof ITaintedMob) { + public void performEffect(EntityLivingBase target, int par2) + { + if(target instanceof ITaintedMob) + { target.heal(1); - } else - if (!target.isEntityUndead() && !(target instanceof EntityPlayer)) - { + } + else if(!target.isEntityUndead() && !(target instanceof EntityPlayer)) + { target.attackEntityFrom(DamageSourceThaumcraft.taint, 1); - } - else - if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer))) - { + } + else if(!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer))) + { target.attackEntityFrom(DamageSourceThaumcraft.taint, 1); - } + } } - + + @Override public boolean isReady(int par1, int par2) - { - int k = 40 >> par2; - return k > 0 ? par1 % k == 0 : true; - } - + { + final int k = 40 >> par2; + return k > 0 ? par1 % k == 0 : true; + } + } diff --git a/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java b/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java index cd7fc18..baa0f9c 100644 --- a/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java +++ b/src/api/java/thaumcraft/api/potions/PotionVisExhaust.java @@ -9,40 +9,41 @@ import cpw.mods.fml.relauncher.SideOnly; public class PotionVisExhaust extends Potion { - public static PotionVisExhaust instance = null; // will be instantiated at runtime - private int statusIconIndex = -1; - - public PotionVisExhaust(int par1, boolean par2, int par3) - { - super(par1,par2,par3); - setIconIndex(0, 0); - } - - public static void init() - { - instance.setPotionName("potion.visexhaust"); - instance.setIconIndex(5, 1); - instance.setEffectiveness(0.25D); - } - + public static PotionVisExhaust instance = null; // will be instantiated at runtime + public PotionVisExhaust(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + setIconIndex(0, 0); + } + + public static void init() + { + instance.setPotionName("potion.visexhaust"); + instance.setIconIndex(5, 1); + instance.setEffectiveness(0.25D); + } + @Override - public boolean isBadEffect() { + public boolean isBadEffect() + { return true; } @Override @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { + public int getStatusIconIndex() + { Minecraft.getMinecraft().renderEngine.bindTexture(rl); return super.getStatusIconIndex(); } - - static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png"); - + + static final ResourceLocation rl = new ResourceLocation("thaumcraft", + "textures/misc/potions.png"); + @Override - public void performEffect(EntityLivingBase target, int par2) { - + public void performEffect(EntityLivingBase target, int par2) + { + } - - + } diff --git a/src/api/java/thaumcraft/api/research/IScanEventHandler.java b/src/api/java/thaumcraft/api/research/IScanEventHandler.java index d0efac5..219cb5d 100644 --- a/src/api/java/thaumcraft/api/research/IScanEventHandler.java +++ b/src/api/java/thaumcraft/api/research/IScanEventHandler.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IScanEventHandler { +public interface IScanEventHandler +{ ScanResult scanPhenomena(ItemStack stack, World world, EntityPlayer player); } diff --git a/src/api/java/thaumcraft/api/research/ResearchCategories.java b/src/api/java/thaumcraft/api/research/ResearchCategories.java index 82309b3..01c648b 100644 --- a/src/api/java/thaumcraft/api/research/ResearchCategories.java +++ b/src/api/java/thaumcraft/api/research/ResearchCategories.java @@ -10,43 +10,52 @@ import org.apache.logging.log4j.Level; import cpw.mods.fml.common.FMLLog; -public class ResearchCategories { - +public class ResearchCategories +{ + //Research - public static LinkedHashMap <String, ResearchCategoryList> researchCategories = new LinkedHashMap <String,ResearchCategoryList>(); - + public static LinkedHashMap<String, ResearchCategoryList> researchCategories = new LinkedHashMap<String, ResearchCategoryList>(); + /** * @param key * @return the research item linked to this key */ - public static ResearchCategoryList getResearchList(String key) { + public static ResearchCategoryList getResearchList(String key) + { return researchCategories.get(key); } - + /** * @param key * @return the name of the research category linked to this key. * Must be stored as localization information in the LanguageRegistry. */ - public static String getCategoryName(String key) { - return StatCollector.translateToLocal("tc.research_category."+key); + public static String getCategoryName(String key) + { + return StatCollector.translateToLocal("tc.research_category." + key); } - + /** * @param key the research key * @return the ResearchItem object. */ - public static ResearchItem getResearch(String key) { - Collection rc = researchCategories.values(); - for (Object cat:rc) { - Collection rl = ((ResearchCategoryList)cat).research.values(); - for (Object ri:rl) { - if ((((ResearchItem)ri).key).equals(key)) return (ResearchItem)ri; + public static ResearchItem getResearch(String key) + { + final Collection rc = researchCategories.values(); + for(final Object cat : rc) + { + final Collection rl = ((ResearchCategoryList) cat).research.values(); + for(final Object ri : rl) + { + if((((ResearchItem) ri).key).equals(key)) + { + return (ResearchItem) ri; + } } } return null; } - + /** * This should only be done at the PostInit stage * @param key the key used for this category @@ -54,48 +63,54 @@ public class ResearchCategories { * @param background the resource location of the background image to use for this category * @return the name of the research linked to this key */ - public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { - if (getResearchList(key)==null) { - ResearchCategoryList rl = new ResearchCategoryList(icon, background); + public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) + { + if(getResearchList(key) == null) + { + final ResearchCategoryList rl = new ResearchCategoryList(icon, background); researchCategories.put(key, rl); } } - - public static void addResearch(ResearchItem ri) { - ResearchCategoryList rl = getResearchList(ri.category); - if (rl!=null && !rl.research.containsKey(ri.key)) { - - if (!ri.isVirtual()) { - for (ResearchItem rr:rl.research.values()) { - if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { - FMLLog.log(Level.FATAL, "[Thaumcraft] Research ["+ri.getName()+"] not added as it overlaps with existing research ["+rr.getName()+"]"); + + public static void addResearch(ResearchItem ri) + { + final ResearchCategoryList rl = getResearchList(ri.category); + if(rl != null && !rl.research.containsKey(ri.key)) + { + + if(!ri.isVirtual()) + { + for(final ResearchItem rr : rl.research.values()) + { + if(rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) + { + FMLLog.log(Level.FATAL, "[Thaumcraft] Research [" + ri.getName() + "] not added as it overlaps with existing research [" + rr.getName() + "]"); return; } } } - - + rl.research.put(ri.key, ri); - - if (ri.displayColumn < rl.minDisplayColumn) - { - rl.minDisplayColumn = ri.displayColumn; - } - - if (ri.displayRow < rl.minDisplayRow) - { - rl.minDisplayRow = ri.displayRow; - } - - if (ri.displayColumn > rl.maxDisplayColumn) - { - rl.maxDisplayColumn = ri.displayColumn; - } - - if (ri.displayRow > rl.maxDisplayRow) - { - rl.maxDisplayRow = ri.displayRow; - } - } + + if(ri.displayColumn < rl.minDisplayColumn) + { + rl.minDisplayColumn = ri.displayColumn; + } + + if(ri.displayRow < rl.minDisplayRow) + { + rl.minDisplayRow = ri.displayRow; + } + + if(ri.displayColumn > rl.maxDisplayColumn) + { + rl.maxDisplayColumn = ri.displayColumn; + } + + if(ri.displayRow > rl.maxDisplayRow) + { + rl.maxDisplayRow = ri.displayRow; + } + } } } diff --git a/src/api/java/thaumcraft/api/research/ResearchCategoryList.java b/src/api/java/thaumcraft/api/research/ResearchCategoryList.java index 7eed010..289604d 100644 --- a/src/api/java/thaumcraft/api/research/ResearchCategoryList.java +++ b/src/api/java/thaumcraft/api/research/ResearchCategoryList.java @@ -5,33 +5,32 @@ import java.util.Map; import net.minecraft.util.ResourceLocation; -public class ResearchCategoryList { - +public class ResearchCategoryList +{ + /** Is the smallest column used on the GUI. */ - public int minDisplayColumn; - - /** Is the smallest row used on the GUI. */ - public int minDisplayRow; - - /** Is the biggest column used on the GUI. */ - public int maxDisplayColumn; - - /** Is the biggest row used on the GUI. */ - public int maxDisplayRow; - - /** display variables **/ - public ResourceLocation icon; - public ResourceLocation background; - - public ResearchCategoryList(ResourceLocation icon, ResourceLocation background) { + public int minDisplayColumn; + + /** Is the smallest row used on the GUI. */ + public int minDisplayRow; + + /** Is the biggest column used on the GUI. */ + public int maxDisplayColumn; + + /** Is the biggest row used on the GUI. */ + public int maxDisplayRow; + + /** display variables **/ + public ResourceLocation icon; + public ResourceLocation background; + + public ResearchCategoryList(ResourceLocation icon, ResourceLocation background) + { this.icon = icon; this.background = background; } //Research - public Map<String, ResearchItem> research = new HashMap<String,ResearchItem>(); - - - - + public Map<String, ResearchItem> research = new HashMap<String, ResearchItem>(); + } diff --git a/src/api/java/thaumcraft/api/research/ResearchItem.java b/src/api/java/thaumcraft/api/research/ResearchItem.java index 1d5fd8b..b8b9e88 100644 --- a/src/api/java/thaumcraft/api/research/ResearchItem.java +++ b/src/api/java/thaumcraft/api/research/ResearchItem.java @@ -6,346 +6,365 @@ import net.minecraft.util.StatCollector; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class ResearchItem +public class ResearchItem { /** * A short string used as a key for this research. Must be unique */ - public final String key; - + public final String key; + /** * A short string used as a reference to the research category to which this must be added. */ - public final String category; + public final String category; /** * The aspect tags and their values required to complete this research */ - public final AspectList tags; - - /** - * This links to any research that needs to be completed before this research can be discovered or learnt. - */ - public String[] parents = null; - - /** - * Like parent above, but a line will not be displayed in the thaumonomicon linking them. Just used to prevent clutter. - */ - public String[] parentsHidden = null; - /** - * any research linked to this that will be unlocked automatically when this research is complete - */ - public String[] siblings = null; - - /** - * the horizontal position of the research icon - */ - public final int displayColumn; - - /** - * the vertical position of the research icon - */ - public final int displayRow; - - /** - * the icon to be used for this research - */ - public final ItemStack icon_item; - - /** - * the icon to be used for this research - */ - public final ResourceLocation icon_resource; - - /** - * How large the research grid is. Valid values are 1 to 3. - */ - private int complexity; - - /** - * Special research has a spiky border. Used for important research milestones. - */ - private boolean isSpecial; - - /** - * Research that can be directly purchased with RP in normal research difficulty. - */ - private boolean isSecondary; - + public final AspectList tags; + + /** + * This links to any research that needs to be completed before this research can be discovered or learnt. + */ + public String[] parents = null; + + /** + * Like parent above, but a line will not be displayed in the thaumonomicon linking them. Just used to prevent clutter. + */ + public String[] parentsHidden = null; + /** + * any research linked to this that will be unlocked automatically when this research is complete + */ + public String[] siblings = null; + /** - * This indicates if the research should use a circular icon border. Usually used for "passive" research - * that doesn't have recipes and grants passive effects, or that unlock automatically. - */ - private boolean isRound; - - /** - * Stub research cannot be discovered by normal means, but can be unlocked via the sibling system. - */ - private boolean isStub; - - /** - * This indicated that the research is completely hidden and cannot be discovered by any - * player-controlled means. The recipes will never show up in the thaumonomicon. - * Usually used to unlock "hidden" recipes via sibling unlocking, like - * the various cap and rod combos for wands. - */ - private boolean isVirtual; - - - - /** - * Concealed research does not display in the thaumonomicon until parent researches are discovered. - */ - private boolean isConcealed; - - /** - * Hidden research can only be discovered via scanning or knowledge fragments - */ - private boolean isHidden; - - /** - * This is the same as isHidden, except it cannot be discovered with knowledge fragments, only scanning. - */ - private boolean isLost; - - /** - * These research items will automatically unlock for all players on game start - */ - private boolean isAutoUnlock; - - /** - * Scanning these items will have a chance of revealing hidden knowledge in the thaumonomicon - */ - private ItemStack[] itemTriggers; - - /** - * Scanning these entities will have a chance of revealing hidden knowledge in the thaumonomicon - */ - private String[] entityTriggers; - - /** - * Scanning things with these aspects will have a chance of revealing hidden knowledge in the thaumonomicon - */ - private Aspect[] aspectTriggers; - - private ResearchPage[] pages = null; - + * the horizontal position of the research icon + */ + public final int displayColumn; + + /** + * the vertical position of the research icon + */ + public final int displayRow; + + /** + * the icon to be used for this research + */ + public final ItemStack icon_item; + + /** + * the icon to be used for this research + */ + public final ResourceLocation icon_resource; + + /** + * How large the research grid is. Valid values are 1 to 3. + */ + private int complexity; + + /** + * Special research has a spiky border. Used for important research milestones. + */ + private boolean isSpecial; + + /** + * Research that can be directly purchased with RP in normal research difficulty. + */ + private boolean isSecondary; + + /** + * This indicates if the research should use a circular icon border. Usually used for "passive" research + * that doesn't have recipes and grants passive effects, or that unlock automatically. + */ + private boolean isRound; + + /** + * Stub research cannot be discovered by normal means, but can be unlocked via the sibling system. + */ + private boolean isStub; + + /** + * This indicated that the research is completely hidden and cannot be discovered by any + * player-controlled means. The recipes will never show up in the thaumonomicon. + * Usually used to unlock "hidden" recipes via sibling unlocking, like + * the various cap and rod combos for wands. + */ + private boolean isVirtual; + + /** + * Concealed research does not display in the thaumonomicon until parent researches are discovered. + */ + private boolean isConcealed; + + /** + * Hidden research can only be discovered via scanning or knowledge fragments + */ + private boolean isHidden; + + /** + * This is the same as isHidden, except it cannot be discovered with knowledge fragments, only scanning. + */ + private boolean isLost; + + /** + * These research items will automatically unlock for all players on game start + */ + private boolean isAutoUnlock; + + /** + * Scanning these items will have a chance of revealing hidden knowledge in the thaumonomicon + */ + private ItemStack[] itemTriggers; + + /** + * Scanning these entities will have a chance of revealing hidden knowledge in the thaumonomicon + */ + private String[] entityTriggers; + + /** + * Scanning things with these aspects will have a chance of revealing hidden knowledge in the thaumonomicon + */ + private Aspect[] aspectTriggers; + + private ResearchPage[] pages = null; + public ResearchItem(String key, String category) - { - this.key = key; - this.category = category; - this.tags = new AspectList(); - this.icon_resource = null; - this.icon_item = null; - this.displayColumn = 0; - this.displayRow = 0; - this.setVirtual(); - - } - - public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ResourceLocation icon) - { - this.key = key; - this.category = category; - this.tags = tags; - this.icon_resource = icon; - this.icon_item = null; - this.displayColumn = col; - this.displayRow = row; - this.complexity = complex; - if (complexity < 1) this.complexity = 1; - if (complexity > 3) this.complexity = 3; - } - - public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ItemStack icon) - { - this.key = key; - this.category = category; - this.tags = tags; - this.icon_item = icon; - this.icon_resource = null; - this.displayColumn = col; - this.displayRow = row; - this.complexity = complex; - if (complexity < 1) this.complexity = 1; - if (complexity > 3) this.complexity = 3; - } - - public ResearchItem setSpecial() - { - this.isSpecial = true; - return this; - } - - public ResearchItem setStub() - { - this.isStub = true; - return this; - } - - public ResearchItem setLost() - { - this.isLost = true; - return this; - } - - public ResearchItem setConcealed() - { - this.isConcealed = true; - return this; - } - - public ResearchItem setHidden() - { - this.isHidden = true; - return this; - } - - public ResearchItem setVirtual() - { - this.isVirtual = true; - return this; - } - - public ResearchItem setParents(String... par) - { - this.parents = par; - return this; - } - - + { + this.key = key; + this.category = category; + tags = new AspectList(); + icon_resource = null; + icon_item = null; + displayColumn = 0; + displayRow = 0; + setVirtual(); + + } + + public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ResourceLocation icon) + { + this.key = key; + this.category = category; + this.tags = tags; + icon_resource = icon; + icon_item = null; + displayColumn = col; + displayRow = row; + complexity = complex; + if(complexity < 1) + { + complexity = 1; + } + if(complexity > 3) + { + complexity = 3; + } + } + + public ResearchItem(String key, String category, AspectList tags, int col, int row, int complex, ItemStack icon) + { + this.key = key; + this.category = category; + this.tags = tags; + icon_item = icon; + icon_resource = null; + displayColumn = col; + displayRow = row; + complexity = complex; + if(complexity < 1) + { + complexity = 1; + } + if(complexity > 3) + { + complexity = 3; + } + } + + public ResearchItem setSpecial() + { + isSpecial = true; + return this; + } + + public ResearchItem setStub() + { + isStub = true; + return this; + } + + public ResearchItem setLost() + { + isLost = true; + return this; + } + + public ResearchItem setConcealed() + { + isConcealed = true; + return this; + } + + public ResearchItem setHidden() + { + isHidden = true; + return this; + } + + public ResearchItem setVirtual() + { + isVirtual = true; + return this; + } + + public ResearchItem setParents(String... par) + { + parents = par; + return this; + } public ResearchItem setParentsHidden(String... par) - { - this.parentsHidden = par; - return this; - } - - public ResearchItem setSiblings(String... sib) - { - this.siblings = sib; - return this; - } - - public ResearchItem setPages(ResearchPage... par) - { - this.pages = par; - return this; - } - - public ResearchPage[] getPages() { + { + parentsHidden = par; + return this; + } + + public ResearchItem setSiblings(String... sib) + { + siblings = sib; + return this; + } + + public ResearchItem setPages(ResearchPage... par) + { + pages = par; + return this; + } + + public ResearchPage[] getPages() + { return pages; } - - public ResearchItem setItemTriggers(ItemStack... par) - { - this.itemTriggers = par; - return this; - } - - public ResearchItem setEntityTriggers(String... par) - { - this.entityTriggers = par; - return this; - } - - public ResearchItem setAspectTriggers(Aspect... par) - { - this.aspectTriggers = par; - return this; - } - - public ItemStack[] getItemTriggers() { + + public ResearchItem setItemTriggers(ItemStack... par) + { + itemTriggers = par; + return this; + } + + public ResearchItem setEntityTriggers(String... par) + { + entityTriggers = par; + return this; + } + + public ResearchItem setAspectTriggers(Aspect... par) + { + aspectTriggers = par; + return this; + } + + public ItemStack[] getItemTriggers() + { return itemTriggers; } - public String[] getEntityTriggers() { + public String[] getEntityTriggers() + { return entityTriggers; } - - public Aspect[] getAspectTriggers() { + + public Aspect[] getAspectTriggers() + { return aspectTriggers; } public ResearchItem registerResearchItem() - { - ResearchCategories.addResearch(this); - return this; - } - - public String getName() - { - return StatCollector.translateToLocal("tc.research_name."+key); - } - - public String getText() - { - return StatCollector.translateToLocal("tc.research_text."+key); - } - - public boolean isSpecial() - { - return this.isSpecial; - } - - public boolean isStub() - { - return this.isStub; - } - - public boolean isLost() - { - return this.isLost; - } - - public boolean isConcealed() - { - return this.isConcealed; - } - - public boolean isHidden() - { - return this.isHidden; - } - - public boolean isVirtual() - { - return this.isVirtual; - } - - public boolean isAutoUnlock() { + { + ResearchCategories.addResearch(this); + return this; + } + + public String getName() + { + return StatCollector.translateToLocal("tc.research_name." + key); + } + + public String getText() + { + return StatCollector.translateToLocal("tc.research_text." + key); + } + + public boolean isSpecial() + { + return isSpecial; + } + + public boolean isStub() + { + return isStub; + } + + public boolean isLost() + { + return isLost; + } + + public boolean isConcealed() + { + return isConcealed; + } + + public boolean isHidden() + { + return isHidden; + } + + public boolean isVirtual() + { + return isVirtual; + } + + public boolean isAutoUnlock() + { return isAutoUnlock; } - + public ResearchItem setAutoUnlock() - { - this.isAutoUnlock = true; - return this; - } - - public boolean isRound() { + { + isAutoUnlock = true; + return this; + } + + public boolean isRound() + { return isRound; } - public ResearchItem setRound() { - this.isRound = true; + public ResearchItem setRound() + { + isRound = true; return this; } - - public boolean isSecondary() { + + public boolean isSecondary() + { return isSecondary; } - public ResearchItem setSecondary() { - this.isSecondary = true; + public ResearchItem setSecondary() + { + isSecondary = true; return this; } - public int getComplexity() { + public int getComplexity() + { return complexity; } - public ResearchItem setComplexity(int complexity) { + public ResearchItem setComplexity(int complexity) + { this.complexity = complexity; return this; } @@ -353,17 +372,23 @@ public class ResearchItem /** * @return the aspect aspects ordinal with the highest value. Used to determine scroll color and similar things */ - public Aspect getResearchPrimaryTag() { - Aspect aspect=null; - int highest=0; - if (tags!=null) - for (Aspect tag:tags.getAspects()) { - if (tags.getAmount(tag)>highest) { - aspect=tag; - highest=tags.getAmount(tag); - }; + public Aspect getResearchPrimaryTag() + { + Aspect aspect = null; + int highest = 0; + if(tags != null) + { + for(final Aspect tag : tags.getAspects()) + { + if(tags.getAmount(tag) > highest) + { + aspect = tag; + highest = tags.getAmount(tag); + } + ; + } } return aspect; } - + } diff --git a/src/api/java/thaumcraft/api/research/ResearchPage.java b/src/api/java/thaumcraft/api/research/ResearchPage.java index fdada84..415350a 100644 --- a/src/api/java/thaumcraft/api/research/ResearchPage.java +++ b/src/api/java/thaumcraft/api/research/ResearchPage.java @@ -13,181 +13,194 @@ import thaumcraft.api.crafting.IArcaneRecipe; import thaumcraft.api.crafting.InfusionEnchantmentRecipe; import thaumcraft.api.crafting.InfusionRecipe; -public class ResearchPage { +public class ResearchPage +{ public static enum PageType - { - TEXT, - TEXT_CONCEALED, - IMAGE, - CRUCIBLE_CRAFTING, - ARCANE_CRAFTING, - ASPECTS, - NORMAL_CRAFTING, - INFUSION_CRAFTING, - COMPOUND_CRAFTING, - INFUSION_ENCHANTMENT, - SMELTING - } - - public PageType type = PageType.TEXT; - - public String text=null; - public String research=null; - public ResourceLocation image=null; - public AspectList aspects=null; - public Object recipe=null; - public ItemStack recipeOutput=null; - + { + TEXT, TEXT_CONCEALED, IMAGE, CRUCIBLE_CRAFTING, ARCANE_CRAFTING, ASPECTS, NORMAL_CRAFTING, INFUSION_CRAFTING, COMPOUND_CRAFTING, INFUSION_ENCHANTMENT, SMELTING + } + + public PageType type = PageType.TEXT; + + public String text = null; + public String research = null; + public ResourceLocation image = null; + public AspectList aspects = null; + public Object recipe = null; + public ItemStack recipeOutput = null; + /** * @param text this can (but does not have to) be a reference to a localization variable, not the actual text. */ - public ResearchPage(String text) { - this.type = PageType.TEXT; + public ResearchPage(String text) + { + type = PageType.TEXT; this.text = text; } - + /** * @param research this page will only be displayed if the player has discovered this research * @param text this can (but does not have to) be a reference to a localization variable, not the actual text. */ - public ResearchPage(String research, String text) { - this.type = PageType.TEXT_CONCEALED; + public ResearchPage(String research, String text) + { + type = PageType.TEXT_CONCEALED; this.research = research; this.text = text; } - + /** * @param recipe a vanilla crafting recipe. */ - public ResearchPage(IRecipe recipe) { - this.type = PageType.NORMAL_CRAFTING; + public ResearchPage(IRecipe recipe) + { + type = PageType.NORMAL_CRAFTING; this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); + recipeOutput = recipe.getRecipeOutput(); } - + /** * @param recipe a collection of vanilla crafting recipes. */ - public ResearchPage(IRecipe[] recipe) { - this.type = PageType.NORMAL_CRAFTING; + public ResearchPage(IRecipe[] recipe) + { + type = PageType.NORMAL_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a collection of arcane crafting recipes. */ - public ResearchPage(IArcaneRecipe[] recipe) { - this.type = PageType.ARCANE_CRAFTING; + public ResearchPage(IArcaneRecipe[] recipe) + { + type = PageType.ARCANE_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a collection of arcane crafting recipes. */ - public ResearchPage(CrucibleRecipe[] recipe) { - this.type = PageType.CRUCIBLE_CRAFTING; + public ResearchPage(CrucibleRecipe[] recipe) + { + type = PageType.CRUCIBLE_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a collection of infusion crafting recipes. */ - public ResearchPage(InfusionRecipe[] recipe) { - this.type = PageType.INFUSION_CRAFTING; + public ResearchPage(InfusionRecipe[] recipe) + { + type = PageType.INFUSION_CRAFTING; this.recipe = recipe; } - + /** * @param recipe a compound crafting recipe. */ - public ResearchPage(List recipe) { - this.type = PageType.COMPOUND_CRAFTING; + public ResearchPage(List recipe) + { + type = PageType.COMPOUND_CRAFTING; this.recipe = recipe; } - + /** * @param recipe an arcane worktable crafting recipe. */ - public ResearchPage(IArcaneRecipe recipe) { - this.type = PageType.ARCANE_CRAFTING; + public ResearchPage(IArcaneRecipe recipe) + { + type = PageType.ARCANE_CRAFTING; this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); + recipeOutput = recipe.getRecipeOutput(); } - + /** * @param recipe an alchemy crafting recipe. */ - public ResearchPage(CrucibleRecipe recipe) { - this.type = PageType.CRUCIBLE_CRAFTING; + public ResearchPage(CrucibleRecipe recipe) + { + type = PageType.CRUCIBLE_CRAFTING; this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); + recipeOutput = recipe.getRecipeOutput(); } - + /** * @param recipe a furnace smelting crafting recipe. */ - public ResearchPage(ItemStack input) { - this.type = PageType.SMELTING; - this.recipe = input; - this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); + public ResearchPage(ItemStack input) + { + type = PageType.SMELTING; + recipe = input; + recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); } - + /** * @param recipe an infusion crafting recipe. */ - public ResearchPage(InfusionRecipe recipe) { - this.type = PageType.INFUSION_CRAFTING; + public ResearchPage(InfusionRecipe recipe) + { + type = PageType.INFUSION_CRAFTING; this.recipe = recipe; - if (recipe.getRecipeOutput() instanceof ItemStack) { - this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); - } else { - this.recipeOutput = recipe.getRecipeInput(); + if(recipe.getRecipeOutput() instanceof ItemStack) + { + recipeOutput = (ItemStack) recipe.getRecipeOutput(); + } + else + { + recipeOutput = recipe.getRecipeInput(); } } - + /** * @param recipe an infusion crafting recipe. */ - public ResearchPage(InfusionEnchantmentRecipe recipe) { - this.type = PageType.INFUSION_ENCHANTMENT; + public ResearchPage(InfusionEnchantmentRecipe recipe) + { + type = PageType.INFUSION_ENCHANTMENT; this.recipe = recipe; -// if (recipe.recipeOutput instanceof ItemStack) { -// this.recipeOutput = (ItemStack) recipe.recipeOutput; -// } else { -// this.recipeOutput = recipe.recipeInput; -// } + // if (recipe.recipeOutput instanceof ItemStack) { + // this.recipeOutput = (ItemStack) recipe.recipeOutput; + // } else { + // this.recipeOutput = recipe.recipeInput; + // } } - + /** * @param image * @param caption this can (but does not have to) be a reference to a localization variable, not the actual text. */ - public ResearchPage(ResourceLocation image, String caption) { - this.type = PageType.IMAGE; + public ResearchPage(ResourceLocation image, String caption) + { + type = PageType.IMAGE; this.image = image; - this.text = caption; + text = caption; } - + /** * This function should really not be called directly - used internally */ - public ResearchPage(AspectList as) { - this.type = PageType.ASPECTS; - this.aspects = as; + public ResearchPage(AspectList as) + { + type = PageType.ASPECTS; + aspects = as; } - + /** * returns a localized text of the text field (if one exists). Returns the text field itself otherwise. * @return */ - public String getTranslatedText() { - String ret=""; - if (text != null) { + public String getTranslatedText() + { + String ret = ""; + if(text != null) + { ret = StatCollector.translateToLocal(text); - if (ret.isEmpty()) ret = text; + if(ret.isEmpty()) + { + ret = text; + } } return ret; } - - + } diff --git a/src/api/java/thaumcraft/api/research/ScanResult.java b/src/api/java/thaumcraft/api/research/ScanResult.java index e1498f3..8c04c69 100644 --- a/src/api/java/thaumcraft/api/research/ScanResult.java +++ b/src/api/java/thaumcraft/api/research/ScanResult.java @@ -2,36 +2,46 @@ package thaumcraft.api.research; import net.minecraft.entity.Entity; -public class ScanResult { - public byte type = 0; //1=blocks,2=entities,3=phenomena - public int id; - public int meta; - public Entity entity; - public String phenomena; +public class ScanResult +{ + public byte type = 0; //1=blocks,2=entities,3=phenomena + public int id; + public int meta; + public Entity entity; + public String phenomena; - public ScanResult(byte type, int blockId, int blockMeta, Entity entity, - String phenomena) { + public ScanResult(byte type, int blockId, int blockMeta, Entity entity, String phenomena) + { super(); this.type = type; - this.id = blockId; - this.meta = blockMeta; + id = blockId; + meta = blockMeta; this.entity = entity; this.phenomena = phenomena; } @Override - public boolean equals(Object obj) { - if (obj instanceof ScanResult) { - ScanResult sr = (ScanResult) obj; - if (type != sr.type) + public boolean equals(Object obj) + { + if(obj instanceof ScanResult) + { + final ScanResult sr = (ScanResult) obj; + if(type != sr.type) + { return false; - if (type == 1 - && (id != sr.id || meta != sr.meta)) + } + if(type == 1 && (id != sr.id || meta != sr.meta)) + { return false; - if (type == 2 && entity.getEntityId() != sr.entity.getEntityId()) + } + if(type == 2 && entity.getEntityId() != sr.entity.getEntityId()) + { return false; - if (type == 3 && !phenomena.equals(sr.phenomena)) + } + if(type == 3 && !phenomena.equals(sr.phenomena)) + { return false; + } } return true; } diff --git a/src/api/java/thaumcraft/api/visnet/TileVisNode.java b/src/api/java/thaumcraft/api/visnet/TileVisNode.java index 204879e..56dbafe 100644 --- a/src/api/java/thaumcraft/api/visnet/TileVisNode.java +++ b/src/api/java/thaumcraft/api/visnet/TileVisNode.java @@ -15,174 +15,203 @@ import thaumcraft.api.aspects.Aspect; * a transport relay or vis receiver (like the infernal furnace). * */ -public abstract class TileVisNode extends TileThaumcraft { - - WeakReference<TileVisNode> parent = null; - ArrayList<WeakReference<TileVisNode>> children = new ArrayList<WeakReference<TileVisNode>>(); - +public abstract class TileVisNode extends TileThaumcraft +{ + + WeakReference<TileVisNode> parent = null; + ArrayList<WeakReference<TileVisNode>> children = new ArrayList<WeakReference<TileVisNode>>(); + /** * @return the WorldCoordinates location of where this node is located */ - public WorldCoordinates getLocation() { + public WorldCoordinates getLocation() + { return new WorldCoordinates(this); } - + /** * @return the number of blocks away this node will check for parent nodes to connect to. */ public abstract int getRange(); - + /** * @return true if this is the source or root node of the vis network. */ public abstract boolean isSource(); - + /** * This method should never be called directly. Use VisNetHandler.drainVis() instead * @param aspect what aspect to drain * @param vis how much to drain * @return how much was actually drained */ - public int consumeVis(Aspect aspect, int vis) { - if (VisNetHandler.isNodeValid(getParent())) { - int out = getParent().get().consumeVis(aspect, vis); - if (out>0) { + public int consumeVis(Aspect aspect, int vis) + { + if(VisNetHandler.isNodeValid(getParent())) + { + final int out = getParent().get().consumeVis(aspect, vis); + if(out > 0) + { triggerConsumeEffect(aspect); } return out; } return 0; } - - public void removeThisNode() { - for (WeakReference<TileVisNode> n:getChildren()) { - if (n!=null && n.get()!=null) { + + public void removeThisNode() + { + for(final WeakReference<TileVisNode> n : getChildren()) + { + if(n != null && n.get() != null) + { n.get().removeThisNode(); } - } - + } + children = new ArrayList<WeakReference<TileVisNode>>(); - if (VisNetHandler.isNodeValid(this.getParent())) { - this.getParent().get().nodeRefresh=true; + if(VisNetHandler.isNodeValid(getParent())) + { + getParent().get().nodeRefresh = true; } - this.setParent(null); - this.parentChanged(); - - if (this.isSource()) { + setParent(null); + parentChanged(); + + if(isSource()) + { HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId); - if (sourcelist==null) { + if(sourcelist == null) + { sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>(); } sourcelist.remove(getLocation()); - VisNetHandler.sources.put( worldObj.provider.dimensionId, sourcelist ); + VisNetHandler.sources.put(worldObj.provider.dimensionId, sourcelist); } - + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } - - @Override - public void invalidate() { + public void invalidate() + { removeThisNode(); super.invalidate(); } - public void triggerConsumeEffect(Aspect aspect) { } + public void triggerConsumeEffect(Aspect aspect) + { + } /** * @return */ - public WeakReference<TileVisNode> getParent() { + public WeakReference<TileVisNode> getParent() + { return parent; } - + /** * @return */ - public WeakReference<TileVisNode> getRootSource() { - return VisNetHandler.isNodeValid(getParent()) ? - getParent().get().getRootSource() : this.isSource() ? - new WeakReference(this) : null; + public WeakReference<TileVisNode> getRootSource() + { + return VisNetHandler.isNodeValid(getParent()) ? getParent().get().getRootSource() : isSource() ? new WeakReference( + this) : null; } - + /** * @param parent */ - public void setParent(WeakReference<TileVisNode> parent) { + public void setParent(WeakReference<TileVisNode> parent) + { this.parent = parent; } - + /** * @return */ - public ArrayList<WeakReference<TileVisNode>> getChildren() { + public ArrayList<WeakReference<TileVisNode>> getChildren() + { return children; } - + @Override - public boolean canUpdate() { + public boolean canUpdate() + { return true; } - - protected int nodeCounter = 0; - private boolean nodeRegged = false; - public boolean nodeRefresh = false; + + protected int nodeCounter = 0; + private boolean nodeRegged = false; + public boolean nodeRefresh = false; @Override - public void updateEntity() { - - if (!worldObj.isRemote && ((nodeCounter++) % 40==0 || nodeRefresh)) { + public void updateEntity() + { + + if(!worldObj.isRemote && ((nodeCounter++) % 40 == 0 || nodeRefresh)) + { //check for changes - if (!nodeRefresh && children.size()>0) { - for (WeakReference<TileVisNode> n:children) { - if (n==null || n.get()==null || !VisNetHandler.canNodeBeSeen(this, n.get())) { - nodeRefresh=true; + if(!nodeRefresh && children.size() > 0) + { + for(final WeakReference<TileVisNode> n : children) + { + if(n == null || n.get() == null || !VisNetHandler.canNodeBeSeen(this, n.get())) + { + nodeRefresh = true; break; } - } + } } - + //refresh linked nodes - if (nodeRefresh) { - for (WeakReference<TileVisNode> n:children) { - if (n.get()!=null) { - n.get().nodeRefresh=true; + if(nodeRefresh) + { + for(final WeakReference<TileVisNode> n : children) + { + if(n.get() != null) + { + n.get().nodeRefresh = true; } } children.clear(); - parent=null; + parent = null; } - + //redo stuff - if (isSource() && !nodeRegged) { + if(isSource() && !nodeRegged) + { VisNetHandler.addSource(getWorldObj(), this); nodeRegged = true; - } else - if (!isSource() && !VisNetHandler.isNodeValid(getParent())) { - setParent(VisNetHandler.addNode(getWorldObj(), this)); - nodeRefresh=true; } - - if (nodeRefresh) { + else if(!isSource() && !VisNetHandler.isNodeValid(getParent())) + { + setParent(VisNetHandler.addNode(getWorldObj(), this)); + nodeRefresh = true; + } + + if(nodeRefresh) + { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); parentChanged(); } - nodeRefresh=false; + nodeRefresh = false; } - + + } + + public void parentChanged() + { } - - public void parentChanged() { } - + /** * @return the type of shard this is attuned to: * none -1, air 0, fire 1, water 2, earth 3, order 4, entropy 5 * Should return -1 for most implementations */ - public byte getAttunement() { + public byte getAttunement() + { return -1; } - - + } diff --git a/src/api/java/thaumcraft/api/visnet/VisNetHandler.java b/src/api/java/thaumcraft/api/visnet/VisNetHandler.java index 7ac4c69..c8a4826 100644 --- a/src/api/java/thaumcraft/api/visnet/VisNetHandler.java +++ b/src/api/java/thaumcraft/api/visnet/VisNetHandler.java @@ -13,7 +13,8 @@ import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.WorldCoordinates; import thaumcraft.api.aspects.Aspect; -public class VisNetHandler { +public class VisNetHandler +{ // NODE DRAINING /** @@ -29,49 +30,61 @@ public class VisNetHandler { * @param amount how much to drain * @return how much was actually drained */ - public static int drainVis(World world, int x, int y, int z, Aspect aspect, int amount) { + public static int drainVis(World world, int x, int y, int z, Aspect aspect, int amount) + { int drainedAmount = 0; - WorldCoordinates drainer = new WorldCoordinates(x, y, z, + final WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId); - if (!nearbyNodes.containsKey(drainer)) { + if(!nearbyNodes.containsKey(drainer)) + { calculateNearbyNodes(world, x, y, z); } - ArrayList<WeakReference<TileVisNode>> nodes = nearbyNodes.get(drainer); - if (nodes!=null && nodes.size()>0) - for (WeakReference<TileVisNode> noderef : nodes) { - - TileVisNode node = noderef.get(); - - if (node == null) continue; - - int a = node.consumeVis(aspect, amount); - drainedAmount += a; - amount -= a; - if (a>0) { - int color = Aspect.getPrimalAspects().indexOf(aspect); - generateVisEffect(world.provider.dimensionId, x, y, z, node.xCoord, node.yCoord, node.zCoord, color); - } - if (amount <= 0) { - break; + final ArrayList<WeakReference<TileVisNode>> nodes = nearbyNodes.get(drainer); + if(nodes != null && nodes.size() > 0) + { + for(final WeakReference<TileVisNode> noderef : nodes) + { + + final TileVisNode node = noderef.get(); + + if(node == null) + { + continue; + } + + final int a = node.consumeVis(aspect, amount); + drainedAmount += a; + amount -= a; + if(a > 0) + { + final int color = Aspect.getPrimalAspects().indexOf(aspect); + generateVisEffect(world.provider.dimensionId, x, y, z, node.xCoord, node.yCoord, node.zCoord, color); + } + if(amount <= 0) + { + break; + } } } - + return drainedAmount; } - - public static void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) { + + public static void generateVisEffect(int dim, int x, int y, int z, int x2, int y2, int z2, int color) + { ThaumcraftApi.internalMethods.generateVisEffect(dim, x, y, z, x2, y2, z2, color); } - public static HashMap<Integer, HashMap<WorldCoordinates, WeakReference<TileVisNode>>> sources = new HashMap<Integer, HashMap<WorldCoordinates, WeakReference<TileVisNode>>>(); + public static HashMap<Integer, HashMap<WorldCoordinates, WeakReference<TileVisNode>>> sources = new HashMap<Integer, HashMap<WorldCoordinates, WeakReference<TileVisNode>>>(); - public static void addSource(World world, TileVisNode vs) { - HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources - .get(world.provider.dimensionId); - if (sourcelist == null) { + public static void addSource(World world, TileVisNode vs) + { + HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources.get(world.provider.dimensionId); + if(sourcelist == null) + { sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>(); } sourcelist.put(vs.getLocation(), new WeakReference(vs)); @@ -79,54 +92,63 @@ public class VisNetHandler { nearbyNodes.clear(); } - public static boolean isNodeValid(WeakReference<TileVisNode> node) { - if (node == null || node.get() == null || node.get().isInvalid()) + public static boolean isNodeValid(WeakReference<TileVisNode> node) + { + if(node == null || node.get() == null || node.get().isInvalid()) + { return false; + } return true; } - public static WeakReference<TileVisNode> addNode(World world, TileVisNode vn) { - WeakReference ref = new WeakReference(vn); + public static WeakReference<TileVisNode> addNode(World world, TileVisNode vn) + { + final WeakReference ref = new WeakReference(vn); - HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources - .get(world.provider.dimensionId); - if (sourcelist == null) { + HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources.get(world.provider.dimensionId); + if(sourcelist == null) + { sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>(); return null; } ArrayList<Object[]> nearby = new ArrayList<Object[]>(); - for (WeakReference<TileVisNode> root : sourcelist.values()) { - if (!isNodeValid(root)) + for(final WeakReference<TileVisNode> root : sourcelist.values()) + { + if(!isNodeValid(root)) + { continue; + } - TileVisNode source = root.get(); + final TileVisNode source = root.get(); - float r = inRange(world, vn.getLocation(), source.getLocation(), - vn.getRange()); - if (r > 0) { - nearby.add(new Object[] { source, r - vn.getRange() * 2 }); + final float r = inRange(world, vn.getLocation(), source.getLocation(), vn.getRange()); + if(r > 0) + { + nearby.add(new Object[] {source, r - vn.getRange() * 2}); } - + nearby = findClosestNodes(vn, source, nearby); cache.clear(); } float dist = Float.MAX_VALUE; TileVisNode closest = null; - if (nearby.size() > 0) { - for (Object[] o : nearby) { - if ((Float) o[1] < dist && - (vn.getAttunement() == -1 || ((TileVisNode) o[0]).getAttunement() == -1 || - vn.getAttunement() == ((TileVisNode) o[0]).getAttunement())//) { - && canNodeBeSeen(vn,(TileVisNode)o[0])) { + if(nearby.size() > 0) + { + for(final Object[] o : nearby) + { + if((Float) o[1] < dist && (vn.getAttunement() == -1 || ((TileVisNode) o[0]).getAttunement() == -1 || vn.getAttunement() == ((TileVisNode) o[0]).getAttunement())//) { + && canNodeBeSeen(vn, (TileVisNode) o[0])) + { dist = (Float) o[1]; - closest = (TileVisNode) o[0]; + closest = (TileVisNode) o[0]; } } } - if (closest != null) { + if(closest != null) + { closest.getChildren().add(ref); nearbyNodes.clear(); return new WeakReference(closest); @@ -135,121 +157,134 @@ public class VisNetHandler { return null; } - static ArrayList<WorldCoordinates> cache = new ArrayList<WorldCoordinates>(); - public static ArrayList<Object[]> findClosestNodes(TileVisNode target, - TileVisNode parent, ArrayList<Object[]> in) { - - if (cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) return in; + static ArrayList<WorldCoordinates> cache = new ArrayList<WorldCoordinates>(); + + public static ArrayList<Object[]> findClosestNodes(TileVisNode target, TileVisNode parent, ArrayList<Object[]> in) + { + + if(cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) + { + return in; + } cache.add(new WorldCoordinates(parent)); - - for (WeakReference<TileVisNode> childWR : parent.getChildren()) { - TileVisNode child = childWR.get(); - - if (child != null && !child.equals(target) && !child.equals(parent)) { - float r2 = inRange(child.getWorldObj(), child.getLocation(), - target.getLocation(), target.getRange()); - if (r2 > 0) { - in.add(new Object[] { child, r2 }); + + for(final WeakReference<TileVisNode> childWR : parent.getChildren()) + { + final TileVisNode child = childWR.get(); + + if(child != null && !child.equals(target) && !child.equals(parent)) + { + final float r2 = inRange(child.getWorldObj(), child.getLocation(), target.getLocation(), target.getRange()); + if(r2 > 0) + { + in.add(new Object[] {child, r2}); } - + in = findClosestNodes(target, child, in); } } return in; } - private static float inRange(World world, WorldCoordinates cc1, - WorldCoordinates cc2, int range) { - float distance = cc1.getDistanceSquaredToWorldCoordinates(cc2); + private static float inRange(World world, WorldCoordinates cc1, WorldCoordinates cc2, int range) + { + final float distance = cc1.getDistanceSquaredToWorldCoordinates(cc2); return distance > range * range ? -1 : distance; } - private static HashMap<WorldCoordinates, ArrayList<WeakReference<TileVisNode>>> nearbyNodes = new HashMap<WorldCoordinates, ArrayList<WeakReference<TileVisNode>>>(); + private static HashMap<WorldCoordinates, ArrayList<WeakReference<TileVisNode>>> nearbyNodes = new HashMap<WorldCoordinates, ArrayList<WeakReference<TileVisNode>>>(); - private static void calculateNearbyNodes(World world, int x, int y, int z) { + private static void calculateNearbyNodes(World world, int x, int y, int z) + { - HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources - .get(world.provider.dimensionId); - if (sourcelist == null) { + HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources.get(world.provider.dimensionId); + if(sourcelist == null) + { sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>(); return; } - ArrayList<WeakReference<TileVisNode>> cn = new ArrayList<WeakReference<TileVisNode>>(); - WorldCoordinates drainer = new WorldCoordinates(x, y, z, + final ArrayList<WeakReference<TileVisNode>> cn = new ArrayList<WeakReference<TileVisNode>>(); + final WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId); - ArrayList<Object[]> nearby = new ArrayList<Object[]>(); + new ArrayList<Object[]>(); - for (WeakReference<TileVisNode> root : sourcelist.values()) { - - if (!isNodeValid(root)) + for(final WeakReference<TileVisNode> root : sourcelist.values()) + { + + if(!isNodeValid(root)) + { continue; + } + + final TileVisNode source = root.get(); - TileVisNode source = root.get(); - TileVisNode closest = null; float range = Float.MAX_VALUE; - float r = inRange(world, drainer, source.getLocation(), - source.getRange()); - if (r > 0) { + final float r = inRange(world, drainer, source.getLocation(), source.getRange()); + if(r > 0) + { range = r; closest = source; } - + ArrayList<WeakReference<TileVisNode>> children = new ArrayList<WeakReference<TileVisNode>>(); - children = getAllChildren(source,children); - - for (WeakReference<TileVisNode> child : children) { - TileVisNode n = child.get(); - if (n != null && !n.equals(root)) { - - float r2 = inRange(n.getWorldObj(), n.getLocation(), - drainer, n.getRange()); - if (r2 > 0 && r2 < range) { + children = getAllChildren(source, children); + + for(final WeakReference<TileVisNode> child : children) + { + final TileVisNode n = child.get(); + if(n != null && !n.equals(root)) + { + + final float r2 = inRange(n.getWorldObj(), n.getLocation(), drainer, n.getRange()); + if(r2 > 0 && r2 < range) + { range = r2; closest = n; } } } - if (closest != null) { - + if(closest != null) + { + cn.add(new WeakReference(closest)); } } nearbyNodes.put(drainer, cn); } - - private static ArrayList<WeakReference<TileVisNode>> getAllChildren(TileVisNode source, ArrayList<WeakReference<TileVisNode>> list) { - for (WeakReference<TileVisNode> child : source.getChildren()) { - TileVisNode n = child.get(); - - if (n != null && n.getWorldObj()!=null && isChunkLoaded(n.getWorldObj(), n.xCoord, n.zCoord)) { + + private static ArrayList<WeakReference<TileVisNode>> getAllChildren(TileVisNode source, ArrayList<WeakReference<TileVisNode>> list) + { + for(final WeakReference<TileVisNode> child : source.getChildren()) + { + final TileVisNode n = child.get(); + + if(n != null && n.getWorldObj() != null && isChunkLoaded(n.getWorldObj(), n.xCoord, n.zCoord)) + { list.add(child); - list = getAllChildren(n,list); + list = getAllChildren(n, list); } } return list; } - - public static boolean isChunkLoaded(World world, int x, int z) { - int xx = x >> 4; - int zz = z >> 4; - return world.getChunkProvider().chunkExists(xx, zz); + + public static boolean isChunkLoaded(World world, int x, int z) + { + final int xx = x >> 4; + final int zz = z >> 4; + return world.getChunkProvider().chunkExists(xx, zz); } - public static boolean canNodeBeSeen(TileVisNode source,TileVisNode target) - { - MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(source.getWorldObj(), - Vec3.createVectorHelper(source.xCoord+.5, source.yCoord+.5,source.zCoord+.5), - Vec3.createVectorHelper(target.xCoord+.5, target.yCoord+.5,target.zCoord+.5), - false, true, false); - return mop == null || (mop.typeOfHit==MovingObjectType.BLOCK && - mop.blockX==target.xCoord && mop.blockY==target.yCoord && mop.blockZ==target.zCoord); - } + public static boolean canNodeBeSeen(TileVisNode source, TileVisNode target) + { + final MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(source.getWorldObj(), Vec3.createVectorHelper(source.xCoord + .5, source.yCoord + .5, source.zCoord + .5), Vec3.createVectorHelper(target.xCoord + .5, target.yCoord + .5, target.zCoord + .5), false, true, false); + return mop == null || (mop.typeOfHit == MovingObjectType.BLOCK && mop.blockX == target.xCoord && mop.blockY == target.yCoord && mop.blockZ == target.zCoord); + } // public static HashMap<WorldCoordinates,WeakReference<TileVisNode>> // noderef = new HashMap<WorldCoordinates,WeakReference<TileVisNode>>(); diff --git a/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java b/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java index 5c4269e..32ee1ef 100644 --- a/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java +++ b/src/api/java/thaumcraft/api/wands/FocusUpgradeType.java @@ -8,107 +8,152 @@ import org.apache.logging.log4j.LogManager; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -public class FocusUpgradeType { - - public static FocusUpgradeType[] types = new FocusUpgradeType[20]; - - public short id; - - public ResourceLocation icon; - - public String name; - - public String text; - +public class FocusUpgradeType +{ + + public static FocusUpgradeType[] types = new FocusUpgradeType[20]; + + public short id; + + public ResourceLocation icon; + + public String name; + + public String text; + /** * What aspects are used to calculate the cost of this upgrade. The amounts given is ignored, just the type is used for the calculation. */ - public AspectList aspects; - - + public AspectList aspects; - public FocusUpgradeType(int id, ResourceLocation icon, String name, String text, AspectList aspects) { - this.id = (short) id; + public FocusUpgradeType(int id, ResourceLocation icon, String name, String text, AspectList aspects) + { + this.id = (short) id; this.icon = icon; this.name = name; this.text = text; this.aspects = aspects; - - if (id<types.length && types[id]!=null) { - LogManager.getLogger("THAUMCRAFT").fatal("Focus Upgrade id "+id+" already occupied. Ignoring."); + + if(id < types.length && types[id] != null) + { + LogManager.getLogger("THAUMCRAFT").fatal("Focus Upgrade id " + id + " already occupied. Ignoring."); return; } - + // allocate space - if (id>=types.length) { - FocusUpgradeType[] temp = new FocusUpgradeType[id+1]; + if(id >= types.length) + { + final FocusUpgradeType[] temp = new FocusUpgradeType[id + 1]; System.arraycopy(types, 0, temp, 0, types.length); types = temp; } - + types[id] = this; - } - - public String getLocalizedName() { + } + + public String getLocalizedName() + { return StatCollector.translateToLocal(name); } - - public String getLocalizedText() { + + public String getLocalizedText() + { return StatCollector.translateToLocal(text); } - + @Override - public boolean equals(Object obj) { - if (obj instanceof FocusUpgradeType) { - return this.id == ((FocusUpgradeType)obj).id; - } else return false; + public boolean equals(Object obj) + { + if(obj instanceof FocusUpgradeType) + { + return id == ((FocusUpgradeType) obj).id; + } + else + { + return false; + } } // basic upgrade types - public static FocusUpgradeType potency = new FocusUpgradeType( 0, - new ResourceLocation("thaumcraft", "textures/foci/potency.png"), - "focus.upgrade.potency.name","focus.upgrade.potency.text", - new AspectList().add(Aspect.WEAPON,1)); - - public static FocusUpgradeType frugal = new FocusUpgradeType( 1, - new ResourceLocation("thaumcraft", "textures/foci/frugal.png"), - "focus.upgrade.frugal.name","focus.upgrade.frugal.text", - new AspectList().add(Aspect.HUNGER,1)); - - public static FocusUpgradeType treasure = new FocusUpgradeType( 2, - new ResourceLocation("thaumcraft", "textures/foci/treasure.png"), - "focus.upgrade.treasure.name","focus.upgrade.treasure.text", - new AspectList().add(Aspect.GREED,1)); - - public static FocusUpgradeType enlarge = new FocusUpgradeType( 3, - new ResourceLocation("thaumcraft", "textures/foci/enlarge.png"), - "focus.upgrade.enlarge.name","focus.upgrade.enlarge.text", - new AspectList().add(Aspect.TRAVEL,1)); - - public static FocusUpgradeType alchemistsfire = new FocusUpgradeType( 4, - new ResourceLocation("thaumcraft", "textures/foci/alchemistsfire.png"), - "focus.upgrade.alchemistsfire.name","focus.upgrade.alchemistsfire.text", - new AspectList().add(Aspect.ENERGY,1).add(Aspect.SLIME,1)); - - public static FocusUpgradeType alchemistsfrost = new FocusUpgradeType( 5, - new ResourceLocation("thaumcraft", "textures/foci/alchemistsfrost.png"), - "focus.upgrade.alchemistsfrost.name","focus.upgrade.alchemistsfrost.text", - new AspectList().add(Aspect.COLD,1).add(Aspect.TRAP,1)); - - public static FocusUpgradeType architect = new FocusUpgradeType( 6, - new ResourceLocation("thaumcraft", "textures/foci/architect.png"), - "focus.upgrade.architect.name","focus.upgrade.architect.text", - new AspectList().add(Aspect.CRAFT,1)); - - public static FocusUpgradeType extend = new FocusUpgradeType( 7, - new ResourceLocation("thaumcraft", "textures/foci/extend.png"), - "focus.upgrade.extend.name","focus.upgrade.extend.text", - new AspectList().add(Aspect.EXCHANGE,1)); - - public static FocusUpgradeType silktouch = new FocusUpgradeType( 8, - new ResourceLocation("thaumcraft", "textures/foci/silktouch.png"), - "focus.upgrade.silktouch.name","focus.upgrade.silktouch.text", - new AspectList().add(Aspect.GREED,1)); - - + public static FocusUpgradeType potency = new FocusUpgradeType( + 0, + new ResourceLocation( + "thaumcraft", + "textures/foci/potency.png"), + "focus.upgrade.potency.name", + "focus.upgrade.potency.text", + new AspectList().add(Aspect.WEAPON, 1)); + + public static FocusUpgradeType frugal = new FocusUpgradeType( + 1, + new ResourceLocation( + "thaumcraft", + "textures/foci/frugal.png"), + "focus.upgrade.frugal.name", + "focus.upgrade.frugal.text", + new AspectList().add(Aspect.HUNGER, 1)); + + public static FocusUpgradeType treasure = new FocusUpgradeType( + 2, + new ResourceLocation( + "thaumcraft", + "textures/foci/treasure.png"), + "focus.upgrade.treasure.name", + "focus.upgrade.treasure.text", + new AspectList().add(Aspect.GREED, 1)); + + public static FocusUpgradeType enlarge = new FocusUpgradeType( + 3, + new ResourceLocation( + "thaumcraft", + "textures/foci/enlarge.png"), + "focus.upgrade.enlarge.name", + "focus.upgrade.enlarge.text", + new AspectList().add(Aspect.TRAVEL, 1)); + + public static FocusUpgradeType alchemistsfire = new FocusUpgradeType( + 4, + new ResourceLocation( + "thaumcraft", + "textures/foci/alchemistsfire.png"), + "focus.upgrade.alchemistsfire.name", + "focus.upgrade.alchemistsfire.text", + new AspectList().add(Aspect.ENERGY, 1).add(Aspect.SLIME, 1)); + + public static FocusUpgradeType alchemistsfrost = new FocusUpgradeType( + 5, + new ResourceLocation( + "thaumcraft", + "textures/foci/alchemistsfrost.png"), + "focus.upgrade.alchemistsfrost.name", + "focus.upgrade.alchemistsfrost.text", + new AspectList().add(Aspect.COLD, 1).add(Aspect.TRAP, 1)); + + public static FocusUpgradeType architect = new FocusUpgradeType( + 6, + new ResourceLocation( + "thaumcraft", + "textures/foci/architect.png"), + "focus.upgrade.architect.name", + "focus.upgrade.architect.text", + new AspectList().add(Aspect.CRAFT, 1)); + + public static FocusUpgradeType extend = new FocusUpgradeType( + 7, + new ResourceLocation( + "thaumcraft", + "textures/foci/extend.png"), + "focus.upgrade.extend.name", + "focus.upgrade.extend.text", + new AspectList().add(Aspect.EXCHANGE, 1)); + + public static FocusUpgradeType silktouch = new FocusUpgradeType( + 8, + new ResourceLocation( + "thaumcraft", + "textures/foci/silktouch.png"), + "focus.upgrade.silktouch.name", + "focus.upgrade.silktouch.text", + new AspectList().add(Aspect.GREED, 1)); + } diff --git a/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java b/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java index 4ef8c84..dbceaa5 100644 --- a/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java +++ b/src/api/java/thaumcraft/api/wands/IWandRodOnUpdate.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack; * update tick. * */ -public interface IWandRodOnUpdate { +public interface IWandRodOnUpdate +{ void onUpdate(ItemStack itemstack, EntityPlayer player); } diff --git a/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java b/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java index 7c299de..ae47992 100644 --- a/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java +++ b/src/api/java/thaumcraft/api/wands/IWandTriggerManager.java @@ -4,12 +4,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IWandTriggerManager { +public interface IWandTriggerManager +{ /** * This class will be called by wands with the proper parameters. It is up to you to decide what to do with them. */ - public boolean performTrigger(World world, ItemStack wand, EntityPlayer player, - int x, int y, int z, int side, int event); - + public boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, int event); + } diff --git a/src/api/java/thaumcraft/api/wands/IWandable.java b/src/api/java/thaumcraft/api/wands/IWandable.java index aeb9bac..7cc0362 100644 --- a/src/api/java/thaumcraft/api/wands/IWandable.java +++ b/src/api/java/thaumcraft/api/wands/IWandable.java @@ -12,14 +12,15 @@ import net.minecraft.world.World; * */ -public interface IWandable { +public interface IWandable +{ public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, int md); - + public ItemStack onWandRightClick(World world, ItemStack wandstack, EntityPlayer player); - + public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count); - + public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count); - + } diff --git a/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java b/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java index e8938e9..70d0dba 100644 --- a/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java +++ b/src/api/java/thaumcraft/api/wands/ItemFocusBasic.java @@ -21,256 +21,294 @@ import thaumcraft.api.aspects.AspectList; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemFocusBasic extends Item { - - public ItemFocusBasic () - { - super(); - maxStackSize = 1; - canRepair=false; - this.setMaxDamage(0); - } - - public IIcon icon; - +public class ItemFocusBasic extends Item +{ + + public ItemFocusBasic() + { + super(); + maxStackSize = 1; + canRepair = false; + setMaxDamage(0); + } + + public IIcon icon; + @SideOnly(Side.CLIENT) @Override - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int par1) + { return icon; } - + @Override - public boolean isDamageable() { + public boolean isDamageable() + { return false; } @Override - public void addInformation(ItemStack stack,EntityPlayer player, List list, boolean par4) { - AspectList al = this.getVisCost(stack); - if (al!=null && al.size()>0) { - list.add(StatCollector.translateToLocal(isVisCostPerTick(stack)?"item.Focus.cost2":"item.Focus.cost1")); - for (Aspect aspect:al.getAspectsSorted()) { - DecimalFormat myFormatter = new DecimalFormat("#####.##"); - String amount = myFormatter.format(al.getAmount(aspect)/100f); - list.add(" \u00A7"+aspect.getChatcolor()+aspect.getName()+"\u00A7r x "+ amount); + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + final AspectList al = getVisCost(stack); + if(al != null && al.size() > 0) + { + list.add(StatCollector.translateToLocal(isVisCostPerTick(stack) ? "item.Focus.cost2" : "item.Focus.cost1")); + for(final Aspect aspect : al.getAspectsSorted()) + { + final DecimalFormat myFormatter = new DecimalFormat("#####.##"); + final String amount = myFormatter.format(al.getAmount(aspect) / 100f); + list.add(" \u00A7" + aspect.getChatcolor() + aspect.getName() + "\u00A7r x " + amount); } } - addFocusInformation(stack,player,list,par4); + addFocusInformation(stack, player, list, par4); } - - public void addFocusInformation(ItemStack focusstack,EntityPlayer player, List list, boolean par4) { - LinkedHashMap<Short, Integer> map = new LinkedHashMap<Short, Integer>(); - for (short id:this.getAppliedUpgrades(focusstack)) { - if (id>=0) { + + public void addFocusInformation(ItemStack focusstack, EntityPlayer player, List list, boolean par4) + { + final LinkedHashMap<Short, Integer> map = new LinkedHashMap<Short, Integer>(); + for(final short id : getAppliedUpgrades(focusstack)) + { + if(id >= 0) + { int amt = 1; - if (map.containsKey(id)) { - amt = map.get(id) + 1; + if(map.containsKey(id)) + { + amt = map.get(id) + 1; } map.put(id, amt); } } - for (Short id:map.keySet()) { - list.add(EnumChatFormatting.DARK_PURPLE +FocusUpgradeType.types[id].getLocalizedName()+ - (map.get(id)>1?" "+StatCollector.translateToLocal("enchantment.level." + map.get(id)):"")); + for(final Short id : map.keySet()) + { + list.add(EnumChatFormatting.DARK_PURPLE + FocusUpgradeType.types[id].getLocalizedName() + (map.get(id) > 1 ? " " + StatCollector.translateToLocal("enchantment.level." + map.get(id)) : "")); } } - + /** * Purely for display on the focus tooltip (see addInformation method above) */ - public boolean isVisCostPerTick(ItemStack focusstack) { + public boolean isVisCostPerTick(ItemStack focusstack) + { return false; } - + @Override public EnumRarity getRarity(ItemStack focusstack) - { - return EnumRarity.rare; - } - + { + return EnumRarity.rare; + } + /** * What color will the focus orb be rendered on the held wand */ - public int getFocusColor(ItemStack focusstack) { + public int getFocusColor(ItemStack focusstack) + { return 0; } - /** * Does the focus have ornamentation like the focus of the nine hells. Ornamentation is a standard icon rendered in a cross around the focus - */ - public IIcon getOrnament(ItemStack focusstack) { + */ + public IIcon getOrnament(ItemStack focusstack) + { // TODO Auto-generated method stub return null; } - + /** * An icon to be rendered inside the focus itself */ - public IIcon getFocusDepthLayerIcon(ItemStack focusstack) { + public IIcon getFocusDepthLayerIcon(ItemStack focusstack) + { // TODO Auto-generated method stub return null; } - - public enum WandFocusAnimation { + + public enum WandFocusAnimation + { WAVE, CHARGE; } - public WandFocusAnimation getAnimation(ItemStack focusstack) { + public WandFocusAnimation getAnimation(ItemStack focusstack) + { return WandFocusAnimation.WAVE; } - + /** * Just insert two alphanumeric characters before this string in your focus item class */ - public String getSortingHelper(ItemStack focusstack) { - String out=""; - for (short id:this.getAppliedUpgrades(focusstack)) { + public String getSortingHelper(ItemStack focusstack) + { + String out = ""; + for(final short id : getAppliedUpgrades(focusstack)) + { out = out + id; } return out; } - - + /** * How much vis does this focus consume per activation. */ - public AspectList getVisCost(ItemStack focusstack) { + public AspectList getVisCost(ItemStack focusstack) + { return null; } - + /** * This returns how many milliseconds must pass before the focus can be activated again. - */ - public int getActivationCooldown(ItemStack focusstack) { + */ + public int getActivationCooldown(ItemStack focusstack) + { return 0; - } - + } + /** * Used by foci like equal trade to determine their area in artchitect mode */ - public int getMaxAreaSize(ItemStack focusstack) { + public int getMaxAreaSize(ItemStack focusstack) + { return 1; } - + /** * What upgrades can be applied to this focus for ranks 1 to 5 */ - public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) { + public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) + { return null; } - + /** * What upgrades does the focus currently have */ - public short[] getAppliedUpgrades(ItemStack focusstack) { - short[] l = new short[] {-1,-1,-1,-1,-1}; - NBTTagList nbttaglist = getFocusUpgradeTagList(focusstack); - if (nbttaglist == null) - { - return l; - } - else - { - for (int j = 0; j < nbttaglist.tagCount(); ++j) - { - if (j>=5) break; - l[j] = nbttaglist.getCompoundTagAt(j).getShort("id"); - } - - return l; - } + public short[] getAppliedUpgrades(ItemStack focusstack) + { + final short[] l = new short[] {-1, -1, -1, -1, -1}; + final NBTTagList nbttaglist = getFocusUpgradeTagList(focusstack); + if(nbttaglist == null) + { + return l; + } + else + { + for(int j = 0; j < nbttaglist.tagCount(); ++j) + { + if(j >= 5) + { + break; + } + l[j] = nbttaglist.getCompoundTagAt(j).getShort("id"); + } + + return l; + } } - - public boolean applyUpgrade(ItemStack focusstack, FocusUpgradeType type, int rank) { - short[] upgrades = getAppliedUpgrades(focusstack); - if (upgrades[rank-1]!=-1 || rank<1 || rank>5) { + + public boolean applyUpgrade(ItemStack focusstack, FocusUpgradeType type, int rank) + { + final short[] upgrades = getAppliedUpgrades(focusstack); + if(upgrades[rank - 1] != -1 || rank < 1 || rank > 5) + { return false; } - upgrades[rank-1] = type.id; + upgrades[rank - 1] = type.id; setFocusUpgradeTagList(focusstack, upgrades); return true; } - + /** * Use this method to define custom logic about which upgrades can be applied. This can be used to set up upgrade "trees" * that make certain upgrades available only when others are unlocked first, when certain research is completed, or similar logic. * */ - public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) { + public boolean canApplyUpgrade(ItemStack focusstack, EntityPlayer player, FocusUpgradeType type, int rank) + { return true; } /** * Does this focus have the passed upgrade type */ - public boolean isUpgradedWith(ItemStack focusstack, FocusUpgradeType focusUpgradetype) { - return getUpgradeLevel(focusstack,focusUpgradetype)>0; + public boolean isUpgradedWith(ItemStack focusstack, FocusUpgradeType focusUpgradetype) + { + return getUpgradeLevel(focusstack, focusUpgradetype) > 0; } /** * What level is the passed upgrade type on the focus. If it is not present it returns 0 */ - public int getUpgradeLevel(ItemStack focusstack, FocusUpgradeType focusUpgradetype) { - short[] list = getAppliedUpgrades(focusstack); - int level=0; - for (short id:list) { - if (id == focusUpgradetype.id) - { - level++; - } + public int getUpgradeLevel(ItemStack focusstack, FocusUpgradeType focusUpgradetype) + { + final short[] list = getAppliedUpgrades(focusstack); + int level = 0; + for(final short id : list) + { + if(id == focusUpgradetype.id) + { + level++; + } } - return level; - } - - public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) { + return level; + } + + public ItemStack onFocusRightClick(ItemStack wandstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) + { // TODO Auto-generated method stub return null; } - - public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player,int count) { + + public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player, int count) + { // TODO Auto-generated method stub } - - public void onPlayerStoppedUsingFocus(ItemStack wandstack, World world, EntityPlayer player, int count) { + + public void onPlayerStoppedUsingFocus(ItemStack wandstack, World world, EntityPlayer player, int count) + { // TODO Auto-generated method stub - + } - - public boolean onFocusBlockStartBreak(ItemStack wandstack, int x, int y,int z, EntityPlayer player) { + + public boolean onFocusBlockStartBreak(ItemStack wandstack, int x, int y, int z, EntityPlayer player) + { // TODO Auto-generated method stub return false; } - + /** * Internal helper methods */ private NBTTagList getFocusUpgradeTagList(ItemStack focusstack) - { - return focusstack.stackTagCompound == null ? null : focusstack.stackTagCompound.getTagList("upgrade", 10); - } - - private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) { - if (!focusstack.hasTagCompound()) + { + return focusstack.stackTagCompound == null ? null : focusstack.stackTagCompound.getTagList("upgrade", 10); + } + + private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) + { + if(!focusstack.hasTagCompound()) + { focusstack.setTagCompound(new NBTTagCompound()); - NBTTagCompound nbttagcompound = focusstack.getTagCompound(); - NBTTagList tlist = new NBTTagList(); + } + final NBTTagCompound nbttagcompound = focusstack.getTagCompound(); + final NBTTagList tlist = new NBTTagList(); nbttagcompound.setTag("upgrade", tlist); - for (short id : upgrades) { - NBTTagCompound f = new NBTTagCompound(); + for(final short id : upgrades) + { + final NBTTagCompound f = new NBTTagCompound(); f.setShort("id", id); tlist.appendTag(f); } } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { - if (stack.stackTagCompound !=null && stack.stackTagCompound.hasKey("ench")) { + public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) + { + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("ench")) + { stack.stackTagCompound.removeTag("ench"); } super.onUpdate(stack, world, entity, p_77663_4_, p_77663_5_); } - - } diff --git a/src/api/java/thaumcraft/api/wands/StaffRod.java b/src/api/java/thaumcraft/api/wands/StaffRod.java index e7ae90f..1dc474c 100644 --- a/src/api/java/thaumcraft/api/wands/StaffRod.java +++ b/src/api/java/thaumcraft/api/wands/StaffRod.java @@ -11,38 +11,43 @@ import net.minecraft.util.ResourceLocation; * It is also used to generate the wand recipes ingame. * */ -public class StaffRod extends WandRod { - - boolean runes=false; +public class StaffRod extends WandRod +{ - public StaffRod(String tag, int capacity, ItemStack item, int craftCost) { - super(tag+"_staff", capacity, item, craftCost); - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+tag+".png"); + boolean runes = false; + + public StaffRod(String tag, int capacity, ItemStack item, int craftCost) + { + super(tag + "_staff", capacity, item, craftCost); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + tag + ".png"); } - public StaffRod(String tag, int capacity, ItemStack item, int craftCost, - IWandRodOnUpdate onUpdate, ResourceLocation texture) { - super(tag+"_staff", capacity, item, craftCost, onUpdate, texture); + public StaffRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) + { + super(tag + "_staff", capacity, item, craftCost, onUpdate, texture); } - public StaffRod(String tag, int capacity, ItemStack item, int craftCost, - IWandRodOnUpdate onUpdate) { - super(tag+"_staff", capacity, item, craftCost, onUpdate); - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+tag+".png"); + public StaffRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) + { + super(tag + "_staff", capacity, item, craftCost, onUpdate); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + tag + ".png"); } - public StaffRod(String tag, int capacity, ItemStack item, int craftCost, - ResourceLocation texture) { - super(tag+"_staff", capacity, item, craftCost, texture); + public StaffRod(String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) + { + super(tag + "_staff", capacity, item, craftCost, texture); } - public boolean hasRunes() { + public boolean hasRunes() + { return runes; } - public void setRunes(boolean hasRunes) { - this.runes = hasRunes; + public void setRunes(boolean hasRunes) + { + runes = hasRunes; } - } diff --git a/src/api/java/thaumcraft/api/wands/WandCap.java b/src/api/java/thaumcraft/api/wands/WandCap.java index 17b4581..e5726ef 100644 --- a/src/api/java/thaumcraft/api/wands/WandCap.java +++ b/src/api/java/thaumcraft/api/wands/WandCap.java @@ -13,117 +13,133 @@ import thaumcraft.api.aspects.Aspect; * @author Azanor * */ -public class WandCap { +public class WandCap +{ + + private String tag; - private String tag; - /** * Cost to craft this wand. Combined with the rod cost. */ - private int craftCost; - + private int craftCost; + /** * the amount by which all aspect costs are multiplied */ - float baseCostModifier; - + float baseCostModifier; + /** * specifies a list of primal aspects that use the special discount figure instead of the normal discount. */ - List<Aspect> specialCostModifierAspects; - + List<Aspect> specialCostModifierAspects; + /** * the amount by which the specified aspect costs are multiplied */ - float specialCostModifier; - + float specialCostModifier; + /** * The texture that will be used for the ingame wand cap */ - ResourceLocation texture; - + ResourceLocation texture; + /** * the actual item that makes up this cap and will be used to generate the wand recipes */ - ItemStack item; - - public static LinkedHashMap<String,WandCap> caps = new LinkedHashMap<String,WandCap>(); - - public WandCap (String tag, float discount, ItemStack item, int craftCost) { - this.setTag(tag); - this.baseCostModifier = discount; - this.specialCostModifierAspects = null; - texture = new ResourceLocation("thaumcraft","textures/models/wand_cap_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + ItemStack item; + + public static LinkedHashMap<String, WandCap> caps = new LinkedHashMap<String, WandCap>(); + + public WandCap(String tag, float discount, ItemStack item, int craftCost) + { + setTag(tag); + baseCostModifier = discount; + specialCostModifierAspects = null; + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_cap_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); caps.put(tag, this); } - - public WandCap (String tag, float discount, List<Aspect> specialAspects, float discountSpecial, ItemStack item, int craftCost) { - this.setTag(tag); - this.baseCostModifier = discount; - this.specialCostModifierAspects = specialAspects; - this.specialCostModifier = discountSpecial; - texture = new ResourceLocation("thaumcraft","textures/models/wand_cap_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + + public WandCap(String tag, float discount, List<Aspect> specialAspects, float discountSpecial, ItemStack item, int craftCost) + { + setTag(tag); + baseCostModifier = discount; + specialCostModifierAspects = specialAspects; + specialCostModifier = discountSpecial; + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_cap_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); caps.put(tag, this); } - - public float getBaseCostModifier() { + + public float getBaseCostModifier() + { return baseCostModifier; } - public List<Aspect> getSpecialCostModifierAspects() { + public List<Aspect> getSpecialCostModifierAspects() + { return specialCostModifierAspects; } - public float getSpecialCostModifier() { + public float getSpecialCostModifier() + { return specialCostModifier; } - public ResourceLocation getTexture() { + public ResourceLocation getTexture() + { return texture; } - public void setTexture(ResourceLocation texture) { + public void setTexture(ResourceLocation texture) + { this.texture = texture; } - public String getTag() { + public String getTag() + { return tag; } - public void setTag(String tag) { + public void setTag(String tag) + { this.tag = tag; } - - public ItemStack getItem() { + public ItemStack getItem() + { return item; } - public void setItem(ItemStack item) { + public void setItem(ItemStack item) + { this.item = item; } - public int getCraftCost() { + public int getCraftCost() + { return craftCost; } - public void setCraftCost(int craftCost) { + public void setCraftCost(int craftCost) + { this.craftCost = craftCost; } - + /** * The research a player needs to have finished to be able to craft a wand with this cap. */ - public String getResearch() { - return "CAP_"+getTag(); + public String getResearch() + { + return "CAP_" + getTag(); } - + // Some examples: // WandCap WAND_CAP_IRON = new WandCap("iron", 1.1f, Arrays.asList(Aspect.ORDER),1, new ItemStack(ConfigItems.itemWandCap,1,0),1); // WandCap WAND_CAP_GOLD = new WandCap("gold", 1f, new ItemStack(ConfigItems.itemWandCap,1,1),3); - + } diff --git a/src/api/java/thaumcraft/api/wands/WandRod.java b/src/api/java/thaumcraft/api/wands/WandRod.java index 85954e4..9b6907d 100644 --- a/src/api/java/thaumcraft/api/wands/WandRod.java +++ b/src/api/java/thaumcraft/api/wands/WandRod.java @@ -13,143 +13,164 @@ import net.minecraft.util.ResourceLocation; * It is also used to generate the wand recipes ingame. * */ -public class WandRod { +public class WandRod +{ + + private String tag; - - private String tag; - /** * Cost to craft this wand. Combined with the rod cost. */ - private int craftCost; - + private int craftCost; + /** * The amount of vis that can be stored - this number is actually multiplied * by 100 for use by the wands internals */ - int capacity; + int capacity; /** * The texture that will be used for the ingame wand rod */ - protected ResourceLocation texture; - + protected ResourceLocation texture; + /** * the actual item that makes up this rod and will be used to generate the wand recipes */ - ItemStack item; - + ItemStack item; + /** * A class that will be called whenever the wand onUpdate tick is run */ - IWandRodOnUpdate onUpdate; - + IWandRodOnUpdate onUpdate; + /** * Does the rod glow in the dark? */ - boolean glow; + boolean glow; + + public static LinkedHashMap<String, WandRod> rods = new LinkedHashMap<String, WandRod>(); - public static LinkedHashMap<String,WandRod> rods = new LinkedHashMap<String,WandRod>(); - - public WandRod (String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) { - this.setTag(tag); + public WandRod(String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture) + { + setTag(tag); this.capacity = capacity; this.texture = texture; - this.item=item; - this.setCraftCost(craftCost); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); } - - public WandRod (String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) { - this.setTag(tag); + + public WandRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture) + { + setTag(tag); this.capacity = capacity; this.texture = texture; - this.item=item; - this.setCraftCost(craftCost); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); this.onUpdate = onUpdate; } - public WandRod (String tag, int capacity, ItemStack item, int craftCost) { - this.setTag(tag); + public WandRod(String tag, int capacity, ItemStack item, int craftCost) + { + setTag(tag); this.capacity = capacity; - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); } - - public WandRod (String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) { - this.setTag(tag); + + public WandRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate) + { + setTag(tag); this.capacity = capacity; - this.texture = new ResourceLocation("thaumcraft","textures/models/wand_rod_"+getTag()+".png"); - this.item=item; - this.setCraftCost(craftCost); + texture = new ResourceLocation("thaumcraft", + "textures/models/wand_rod_" + getTag() + ".png"); + this.item = item; + setCraftCost(craftCost); rods.put(tag, this); this.onUpdate = onUpdate; } - - public String getTag() { + + public String getTag() + { return tag; } - - public void setTag(String tag) { + + public void setTag(String tag) + { this.tag = tag; } - public int getCapacity() { + public int getCapacity() + { return capacity; } - public void setCapacity(int capacity) { + public void setCapacity(int capacity) + { this.capacity = capacity; } - public ResourceLocation getTexture() { + public ResourceLocation getTexture() + { return texture; } - public void setTexture(ResourceLocation texture) { + public void setTexture(ResourceLocation texture) + { this.texture = texture; } - public ItemStack getItem() { + public ItemStack getItem() + { return item; } - public void setItem(ItemStack item) { + public void setItem(ItemStack item) + { this.item = item; } - - public int getCraftCost() { + + public int getCraftCost() + { return craftCost; } - public void setCraftCost(int craftCost) { + public void setCraftCost(int craftCost) + { this.craftCost = craftCost; } - public IWandRodOnUpdate getOnUpdate() { + public IWandRodOnUpdate getOnUpdate() + { return onUpdate; } - public void setOnUpdate(IWandRodOnUpdate onUpdate) { + public void setOnUpdate(IWandRodOnUpdate onUpdate) + { this.onUpdate = onUpdate; } - public boolean isGlowing() { + public boolean isGlowing() + { return glow; } - public void setGlowing(boolean hasGlow) { - this.glow = hasGlow; + public void setGlowing(boolean hasGlow) + { + glow = hasGlow; } - + /** * The research a player needs to have finished to be able to craft a wand with this rod. */ - public String getResearch() { - return "ROD_"+getTag(); + public String getResearch() + { + return "ROD_" + getTag(); } // Some examples: diff --git a/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java b/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java index 7224e12..c9c24f2 100644 --- a/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java +++ b/src/api/java/thaumcraft/api/wands/WandTriggerRegistry.java @@ -19,10 +19,11 @@ import net.minecraft.world.World; * @author azanor * */ -public class WandTriggerRegistry { - - private static HashMap<String,HashMap<List,List>> triggers = new HashMap<String,HashMap<List,List>>(); - private static final String DEFAULT = "default"; +public class WandTriggerRegistry +{ + + private static HashMap<String, HashMap<List, List>> triggers = new HashMap<String, HashMap<List, List>>(); + private static final String DEFAULT = "default"; /** * Registers an action to perform when a casting wand right clicks on a specific block. @@ -33,49 +34,61 @@ public class WandTriggerRegistry { * @param meta send -1 as a wildcard value for all possible meta values * @param modid a unique identifier. It is best to register your own triggers using your mod id to avoid conflicts with mods that register triggers for the same block */ - public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta, String modid) { - if (!triggers.containsKey(modid)) { - triggers.put(modid, new HashMap<List,List>()); + public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta, String modid) + { + if(!triggers.containsKey(modid)) + { + triggers.put(modid, new HashMap<List, List>()); } - HashMap<List,List> temp = triggers.get(modid); - temp.put(Arrays.asList(block,meta),Arrays.asList(manager,event)); + final HashMap<List, List> temp = triggers.get(modid); + temp.put(Arrays.asList(block, meta), Arrays.asList(manager, event)); triggers.put(modid, temp); } - + /** * for legacy support */ - public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta) { + public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, Block block, int meta) + { registerWandBlockTrigger(manager, event, block, meta, DEFAULT); } - + /** * Checks all trigger registries if one exists for the given block and meta * @param block * @param meta * @return */ - public static boolean hasTrigger(Block block, int meta) { - for (String modid:triggers.keySet()) { - HashMap<List,List> temp = triggers.get(modid); - if (temp.containsKey(Arrays.asList(block,meta)) || - temp.containsKey(Arrays.asList(block,-1))) return true; + public static boolean hasTrigger(Block block, int meta) + { + for(final String modid : triggers.keySet()) + { + final HashMap<List, List> 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<List,List> temp = triggers.get(modid); - if (temp.containsKey(Arrays.asList(block,meta)) || - temp.containsKey(Arrays.asList(block,-1))) return true; + public static boolean hasTrigger(Block block, int meta, String modid) + { + if(!triggers.containsKey(modid)) + { + return false; + } + final HashMap<List, List> temp = triggers.get(modid); + if(temp.containsKey(Arrays.asList(block, meta)) || temp.containsKey(Arrays.asList(block, -1))) + { + return true; + } return false; } - - + /** * This is called by the onItemUseFirst function in wands. * Parameters and return value functions like you would expect for that function. @@ -90,37 +103,56 @@ public class WandTriggerRegistry { * @param meta * @return */ - public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, - int x, int y, int z, int side, Block block, int meta) { - - for (String modid:triggers.keySet()) { - HashMap<List,List> temp = triggers.get(modid); - List l = temp.get(Arrays.asList(block,meta)); - if (l==null) l = temp.get(Arrays.asList(block,-1)); - if (l==null) continue; - - IWandTriggerManager manager = (IWandTriggerManager) l.get(0); - int event = (Integer) l.get(1); - boolean result = manager.performTrigger(world, wand, player, x, y, z, side, event); - if (result) return true; + public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, Block block, int meta) + { + + for(final String modid : triggers.keySet()) + { + final HashMap<List, List> temp = triggers.get(modid); + List l = temp.get(Arrays.asList(block, meta)); + if(l == null) + { + l = temp.get(Arrays.asList(block, -1)); + } + if(l == null) + { + continue; + } + + final IWandTriggerManager manager = (IWandTriggerManager) l.get(0); + final int event = (Integer) l.get(1); + final boolean result = manager.performTrigger(world, wand, player, x, y, z, side, event); + if(result) + { + return true; + } } return false; } - + /** * modid sensitive version */ - public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, - int x, int y, int z, int side, Block block, int meta, String modid) { - if (!triggers.containsKey(modid)) return false; - HashMap<List,List> temp = triggers.get(modid); - List l = temp.get(Arrays.asList(block,meta)); - if (l==null) l = temp.get(Arrays.asList(block,-1)); - if (l==null) return false; - - IWandTriggerManager manager = (IWandTriggerManager) l.get(0); - int event = (Integer) l.get(1); + public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, Block block, int meta, String modid) + { + if(!triggers.containsKey(modid)) + { + return false; + } + final HashMap<List, List> temp = triggers.get(modid); + List l = temp.get(Arrays.asList(block, meta)); + if(l == null) + { + l = temp.get(Arrays.asList(block, -1)); + } + if(l == null) + { + return false; + } + + final IWandTriggerManager manager = (IWandTriggerManager) l.get(0); + final int event = (Integer) l.get(1); return manager.performTrigger(world, wand, player, x, y, z, side, event); } - + } diff --git a/src/api/java/zeldaswordskills/api/item/ISword.java b/src/api/java/zeldaswordskills/api/item/ISword.java index 793c97d..5a996fe 100644 --- a/src/api/java/zeldaswordskills/api/item/ISword.java +++ b/src/api/java/zeldaswordskills/api/item/ISword.java @@ -25,6 +25,7 @@ package zeldaswordskills.api.item; * {@link LeapingBlow}, {@link MortalDraw}, {@link RisingCut}, and {@link SwordBeam} * */ -public interface ISword { +public interface ISword +{ } diff --git a/src/api/java/zeldaswordskills/api/item/package-info.java b/src/api/java/zeldaswordskills/api/item/package-info.java index ee7ca09..3719df9 100644 --- a/src/api/java/zeldaswordskills/api/item/package-info.java +++ b/src/api/java/zeldaswordskills/api/item/package-info.java @@ -2,3 +2,4 @@ package zeldaswordskills.api.item; import cpw.mods.fml.common.API; + diff --git a/src/api/java/zeldaswordskills/api/package-info.java b/src/api/java/zeldaswordskills/api/package-info.java index c253cb4..89fe947 100644 --- a/src/api/java/zeldaswordskills/api/package-info.java +++ b/src/api/java/zeldaswordskills/api/package-info.java @@ -2,3 +2,4 @@ package zeldaswordskills.api; import cpw.mods.fml.common.API; + |
