summaryrefslogtreecommitdiff
path: root/src/api/java/cofh
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/java/cofh')
-rw-r--r--src/api/java/cofh/api/block/IDismantleable.java3
-rw-r--r--src/api/java/cofh/api/energy/EnergyStorage.java97
-rw-r--r--src/api/java/cofh/api/energy/IEnergyConnection.java3
-rw-r--r--src/api/java/cofh/api/energy/IEnergyContainerItem.java3
-rw-r--r--src/api/java/cofh/api/energy/IEnergyHandler.java3
-rw-r--r--src/api/java/cofh/api/energy/IEnergyProvider.java3
-rw-r--r--src/api/java/cofh/api/energy/IEnergyReceiver.java3
-rw-r--r--src/api/java/cofh/api/energy/IEnergyStorage.java3
-rw-r--r--src/api/java/cofh/api/energy/ItemEnergyContainer.java64
-rw-r--r--src/api/java/cofh/api/energy/TileEnergyHandler.java26
-rw-r--r--src/api/java/cofh/api/item/IToolHammer.java3
-rw-r--r--src/api/java/cofh/core/item/IEqualityOverrideItem.java5
-rw-r--r--src/api/java/cofh/lib/util/helpers/BlockHelper.java605
13 files changed, 484 insertions, 337 deletions
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);