aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/api/objects/minecraft
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2024-05-24 19:50:35 +0100
committerRaven Szewczyk <git@eigenraven.me>2024-05-24 19:50:35 +0100
commit6d1b2216464d4dad449ac6fcfec476832224a55e (patch)
tree526a0c15f7056313c80e6c0386e025e9b3f61781 /src/main/java/gtPlusPlus/api/objects/minecraft
parentb5d35f40afa606ed1b07061dad82e0521a59c186 (diff)
downloadGT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.tar.gz
GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.tar.bz2
GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.zip
Merge addon sources
Diffstat (limited to 'src/main/java/gtPlusPlus/api/objects/minecraft')
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java67
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java185
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java231
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java245
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java56
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java33
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java57
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java34
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java65
-rw-r--r--src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java251
10 files changed, 1224 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java b/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java
new file mode 100644
index 0000000000..e516f12ddd
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java
@@ -0,0 +1,67 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.World;
+
+import gtPlusPlus.core.util.minecraft.EntityUtils;
+
+/**
+ * Generates an AABB around an entity.
+ *
+ * @author Alkalus
+ *
+ */
+public class AABB {
+
+ private final AxisAlignedBB mAabb;
+ private final World mWorld;
+
+ /**
+ * Creates a AxisAlignedBB based around an Entity.
+ *
+ * @param aEntity - The Entity to work with.
+ * @param x - Maximum X from origin.
+ * @param y - Maximum Y from origin.
+ * @param z - Maximum Z from origin.
+ */
+ public AABB(Entity aEntity, int x, int y, int z) {
+ if (aEntity == null) {
+ mAabb = null;
+ mWorld = null;
+ } else {
+ mWorld = aEntity.worldObj;
+ BlockPos aEntityLocation = EntityUtils.findBlockPosUnderEntity(aEntity);
+ int xMin, xMax, yMin, yMax, zMin, zMax;
+ xMin = aEntityLocation.xPos;
+ yMin = aEntityLocation.yPos;
+ zMin = aEntityLocation.zPos;
+ xMax = aEntityLocation.xPos + x;
+ yMax = aEntityLocation.yPos + y;
+ zMax = aEntityLocation.zPos + z;
+ mAabb = AxisAlignedBB.getBoundingBox(xMin, yMin, zMin, xMax, yMax, zMax);
+ }
+ }
+
+ /**
+ * Used to get the AxisAlignedBB from this class.
+ *
+ * @return
+ */
+ public AxisAlignedBB get() {
+ return mAabb;
+ }
+
+ /**
+ * Used to determine if this object is valid or not.
+ *
+ * @return
+ */
+ public boolean valid() {
+ return mAabb != null && mWorld != null;
+ }
+
+ public World world() {
+ return mWorld;
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java
new file mode 100644
index 0000000000..13f12503f0
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java
@@ -0,0 +1,185 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTank;
+import net.minecraftforge.fluids.FluidTankInfo;
+
+public class BTF_FluidTank extends FluidTank {
+
+ public FluidStack mFluid;
+
+ public BTF_FluidTank(int capacity) {
+ super(capacity);
+ }
+
+ /**
+ * Let's replace the Default handling with GT's own handling code, because it's probably better, right?
+ *
+ * @author Alkalus/GregoriusT
+ */
+ @Override
+ public FluidStack getFluid() {
+ return this.getDrainableStack();
+ }
+
+ @Override
+ public int getFluidAmount() {
+ return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0;
+ }
+
+ @Override
+ public NBTTagCompound writeToNBT(NBTTagCompound aNBT) {
+ super.writeToNBT(aNBT);
+ if (this.mFluid != null) {
+ aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound()));
+ }
+ return aNBT;
+ }
+
+ @Override
+ public FluidTank readFromNBT(NBTTagCompound aNBT) {
+ this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
+ return this;
+ }
+
+ /*
+ * public abstract boolean isLiquidInput(byte arg0); public abstract boolean isLiquidOutput(byte arg0); public
+ * abstract boolean doesFillContainers(); public abstract boolean doesEmptyContainers();
+ */
+
+ public boolean canTankBeFilled() {
+ return true;
+ }
+
+ public boolean canTankBeEmptied() {
+ return true;
+ }
+
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return true;
+ }
+
+ public FluidStack getFillableStack() {
+ return this.mFluid;
+ }
+
+ public FluidStack setFillableStack(FluidStack aFluid) {
+ this.mFluid = aFluid;
+ return this.mFluid;
+ }
+
+ public FluidStack getDrainableStack() {
+ return this.mFluid;
+ }
+
+ public FluidStack setDrainableStack(FluidStack aFluid) {
+ this.mFluid = aFluid;
+ return this.mFluid;
+ }
+
+ public boolean isFluidChangingAllowed() {
+ return true;
+ }
+
+ @Override
+ public int fill(FluidStack aFluid, boolean doFill) {
+ if (aFluid != null && aFluid.getFluid()
+ .getID() > 0 && aFluid.amount > 0 && this.canTankBeFilled() && this.isFluidInputAllowed(aFluid)) {
+ if (this.getFillableStack() != null && this.getFillableStack()
+ .getFluid()
+ .getID() > 0) {
+ if (!this.getFillableStack()
+ .isFluidEqual(aFluid)) {
+ return 0;
+ } else {
+ int space = this.getCapacity() - this.getFillableStack().amount;
+ if (aFluid.amount <= space) {
+ if (doFill) {
+ FluidStack arg9999 = this.getFillableStack();
+ arg9999.amount += aFluid.amount;
+ }
+
+ return aFluid.amount;
+ } else {
+ if (doFill) {
+ this.getFillableStack().amount = this.getCapacity();
+ }
+
+ return space;
+ }
+ }
+ } else if (aFluid.amount <= this.getCapacity()) {
+ if (doFill) {
+ this.setFillableStack(aFluid.copy());
+ }
+
+ return aFluid.amount;
+ } else {
+ if (doFill) {
+ this.setFillableStack(aFluid.copy());
+ this.getFillableStack().amount = this.getCapacity();
+ }
+
+ return this.getCapacity();
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ if (this.getDrainableStack() != null && this.canTankBeEmptied()) {
+ if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) {
+ this.setDrainableStack((FluidStack) null);
+ return null;
+ } else {
+ int used = maxDrain;
+ if (this.getDrainableStack().amount < maxDrain) {
+ used = this.getDrainableStack().amount;
+ }
+
+ if (doDrain) {
+ FluidStack arg9999 = this.getDrainableStack();
+ arg9999.amount -= used;
+ }
+
+ FluidStack drained = this.getDrainableStack()
+ .copy();
+ drained.amount = used;
+ if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) {
+ this.setDrainableStack((FluidStack) null);
+ }
+
+ return drained;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public int getCapacity() {
+ return super.getCapacity();
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ return new FluidTankInfo(this);
+ }
+
+ @Override
+ public void setFluid(FluidStack fluid) {
+ setFillableStack(fluid);
+ }
+
+ @Override
+ public void setCapacity(int capacity) {
+ super.setCapacity(capacity);
+ }
+
+ public FluidStack drain(FluidStack aFluid, boolean doDrain) {
+ return drain(aFluid.amount, doDrain);
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java
new file mode 100644
index 0000000000..fc71869d9e
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java
@@ -0,0 +1,231 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import java.util.ArrayList;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.util.ForgeDirection;
+
+import gregtech.api.util.GT_Utility;
+import gregtech.common.covers.CoverInfo;
+import gtPlusPlus.core.tileentities.base.TileEntityBase;
+import gtPlusPlus.core.util.data.ArrayUtils;
+
+public class BTF_Inventory implements ISidedInventory {
+
+ public final ItemStack[] mInventory;
+ public final TileEntityBase mTile;
+
+ public BTF_Inventory(int aSlots, TileEntityBase tile) {
+ this.mInventory = new ItemStack[aSlots];
+ this.mTile = tile;
+ }
+
+ public ItemStack[] getRealInventory() {
+ purgeNulls();
+ return this.mInventory;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return this.mInventory.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ return aIndex >= 0 && aIndex < this.mInventory.length ? this.mInventory[aIndex] : null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int aIndex, ItemStack aStack) {
+ if (aIndex >= 0 && aIndex < this.mInventory.length) {
+ this.mInventory[aIndex] = aStack;
+ }
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ public boolean setStackToZeroInsteadOfNull(int aIndex) {
+ return false;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {
+ return isValidSlot(aIndex);
+ }
+
+ @Override
+ public ItemStack decrStackSize(int aIndex, int aAmount) {
+ ItemStack tStack = this.getStackInSlot(aIndex);
+ ItemStack rStack = GT_Utility.copy(new Object[] { tStack });
+ if (tStack != null) {
+ if (tStack.stackSize <= aAmount) {
+ if (this.setStackToZeroInsteadOfNull(aIndex)) {
+ tStack.stackSize = 0;
+ } else {
+ this.setInventorySlotContents(aIndex, (ItemStack) null);
+ }
+ } else {
+ rStack = tStack.splitStack(aAmount);
+ if (tStack.stackSize == 0 && !this.setStackToZeroInsteadOfNull(aIndex)) {
+ this.setInventorySlotContents(aIndex, (ItemStack) null);
+ }
+ }
+ }
+
+ return rStack;
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int ordinalSide) {
+ final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide);
+ ArrayList<Integer> tList = new ArrayList<>();
+ CoverInfo coverInfo = this.mTile.getCoverInfoAtSide(side);
+ boolean tSkip = coverInfo.letsItemsIn(-2) || coverInfo.letsItemsIn(-2);
+
+ for (int rArray = 0; rArray < this.getSizeInventory(); ++rArray) {
+ if (this.isValidSlot(rArray)
+ && (tSkip || coverInfo.letsItemsOut(rArray) || coverInfo.letsItemsIn(rArray))) {
+ tList.add(rArray);
+ }
+ }
+
+ int[] arg6 = new int[tList.size()];
+
+ for (int i = 0; i < arg6.length; ++i) {
+ arg6[i] = tList.get(i);
+ }
+
+ return arg6;
+ }
+
+ @Override
+ public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) {
+ return this.isValidSlot(aIndex) && aStack != null
+ && aIndex < this.mInventory.length
+ && (this.mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, this.mInventory[aIndex]))
+ && this.allowPutStack(this.mTile, aIndex, ForgeDirection.getOrientation(ordinalSide), aStack);
+ }
+
+ @Override
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int ordinalSide) {
+ return this.isValidSlot(aIndex) && aStack != null
+ && aIndex < this.mInventory.length
+ && this.allowPullStack(this.mTile, aIndex, ForgeDirection.getOrientation(ordinalSide), aStack);
+ }
+
+ public boolean allowPullStack(TileEntityBase mTile2, int aIndex, ForgeDirection side, ItemStack aStack) {
+ return aIndex >= 0 && aIndex < this.getSizeInventory();
+ }
+
+ public boolean allowPutStack(TileEntityBase aBaseMetaTileEntity, int aIndex, ForgeDirection side,
+ ItemStack aStack) {
+ return (aIndex >= 0 && aIndex < this.getSizeInventory())
+ && (this.mInventory[aIndex] == null || GT_Utility.areStacksEqual(this.mInventory[aIndex], aStack));
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return null;
+ }
+
+ @Override
+ public final boolean hasCustomInventoryName() {
+ return mTile != null ? mTile.hasCustomInventoryName() : false;
+ }
+
+ @Override
+ public void markDirty() {
+ if (mTile != null) {
+ purgeNulls();
+ mTile.markDirty();
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return true;
+ }
+
+ @Override
+ public void openInventory() {}
+
+ @Override
+ public void closeInventory() {}
+
+ @Override
+ public final String getInventoryName() {
+ return this.mTile != null ? mTile.getInventoryName() : "";
+ }
+
+ public boolean isFull() {
+ for (int s = 0; s < this.getSizeInventory(); s++) {
+ ItemStack slot = mInventory[s];
+ if (slot == null || slot.stackSize != slot.getMaxStackSize()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean isEmpty() {
+ for (int s = 0; s < this.getSizeInventory(); s++) {
+ ItemStack slot = mInventory[s];
+ if (slot == null) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean addItemStack(ItemStack aInput) {
+ if (aInput != null & (isEmpty() || !isFull())) {
+ for (int s = 0; s < this.getSizeInventory(); s++) {
+ if (mInventory != null && mInventory[s] != null) {
+ ItemStack slot = mInventory[s];
+ if (slot == null || (slot != null && GT_Utility.areStacksEqual(aInput, slot)
+ && slot.stackSize != slot.getItem()
+ .getItemStackLimit(slot))) {
+ if (slot == null) {
+ slot = aInput.copy();
+ } else {
+ slot.stackSize++;
+ }
+ this.setInventorySlotContents(s, slot);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public final void purgeNulls() {
+ ItemStack[] aTemp = ArrayUtils.removeNulls(this.mInventory);
+ for (int g = 0; g < this.getSizeInventory(); g++) {
+ if (aTemp.length < this.getSizeInventory()) {
+ if (g <= aTemp.length - 1) {
+ this.mInventory[g] = aTemp[g];
+ } else {
+ this.mInventory[g] = null;
+ }
+ } else {
+ this.mInventory[g] = aTemp[g];
+ }
+ }
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java
new file mode 100644
index 0000000000..3853f61793
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java
@@ -0,0 +1,245 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.minecraft.block.Block;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gtPlusPlus.api.objects.data.AutoMap;
+
+public class BlockPos implements Serializable {
+
+ private static final long serialVersionUID = -7271947491316682006L;
+ public final int xPos;
+ public final int yPos;
+ public final int zPos;
+ public final int dim;
+ public final transient World world;
+
+ public static BlockPos generateBlockPos(String sUUID) {
+ String[] s2 = sUUID.split("@");
+ return new BlockPos(s2);
+ }
+
+ public BlockPos(String[] s) {
+ this(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), Integer.parseInt(s[0]));
+ }
+
+ public BlockPos(int x, int y, int z) {
+ this(x, y, z, 0);
+ }
+
+ public BlockPos(int x, int y, int z, int dim) {
+ this(x, y, z, DimensionManager.getWorld(dim));
+ }
+
+ public BlockPos(int x, int y, int z, World dim) {
+ this.xPos = x;
+ this.yPos = y;
+ this.zPos = z;
+
+ if (dim != null) {
+ this.dim = dim.provider.dimensionId;
+ this.world = dim;
+ } else {
+ this.dim = 0;
+ this.world = null;
+ }
+ }
+
+ public BlockPos(IGregTechTileEntity b) {
+ this(b.getXCoord(), b.getYCoord(), b.getZCoord(), b.getWorld());
+ }
+
+ public BlockPos(TileEntity b) {
+ this(b.xCoord, b.yCoord, b.zCoord, b.getWorldObj());
+ }
+
+ public String getLocationString() {
+ return "[X: " + this.xPos + "][Y: " + this.yPos + "][Z: " + this.zPos + "][Dim: " + this.dim + "]";
+ }
+
+ public String getUniqueIdentifier() {
+ String S = "" + this.dim + "@" + this.xPos + "@" + this.yPos + "@" + this.zPos;
+ return S;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash += (13 * this.xPos);
+ hash += (19 * this.yPos);
+ hash += (31 * this.zPos);
+ hash += (17 * this.dim);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (other == this) {
+ return true;
+ }
+ if (!(other instanceof BlockPos otherPoint)) {
+ return false;
+ }
+ return this.xPos == otherPoint.xPos && this.yPos == otherPoint.yPos
+ && this.zPos == otherPoint.zPos
+ && this.dim == otherPoint.dim;
+ }
+
+ public int distanceFrom(BlockPos target) {
+ if (target.dim != this.dim) {
+ return Short.MIN_VALUE;
+ }
+ return distanceFrom(target.xPos, target.yPos, target.zPos);
+ }
+
+ /**
+ *
+ * @param x X coordinate of target.
+ * @param y Y coordinate of target.
+ * @param z Z coordinate of target.
+ * @return square of distance
+ */
+ public int distanceFrom(int x, int y, int z) {
+ int distanceX = this.xPos - x;
+ int distanceY = this.yPos - y;
+ int distanceZ = this.zPos - z;
+ return distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ;
+ }
+
+ public boolean isWithinRange(BlockPos target, int range) {
+ if (target.dim != this.dim) {
+ return false;
+ }
+ return isWithinRange(target.xPos, target.yPos, target.zPos, range);
+ }
+
+ public boolean isWithinRange(int x, int y, int z, int range) {
+ return distanceFrom(x, y, z) <= (range * range);
+ }
+
+ public BlockPos getUp() {
+ return new BlockPos(this.xPos, this.yPos + 1, this.zPos, this.dim);
+ }
+
+ public BlockPos getDown() {
+ return new BlockPos(this.xPos, this.yPos - 1, this.zPos, this.dim);
+ }
+
+ public BlockPos getXPos() {
+ return new BlockPos(this.xPos + 1, this.yPos, this.zPos, this.dim);
+ }
+
+ public BlockPos getXNeg() {
+ return new BlockPos(this.xPos - 1, this.yPos, this.zPos, this.dim);
+ }
+
+ public BlockPos getZPos() {
+ return new BlockPos(this.xPos, this.yPos, this.zPos + 1, this.dim);
+ }
+
+ public BlockPos getZNeg() {
+ return new BlockPos(this.xPos, this.yPos, this.zPos - 1, this.dim);
+ }
+
+ public AutoMap<BlockPos> getSurroundingBlocks() {
+ AutoMap<BlockPos> sides = new AutoMap<>();
+ sides.put(getUp());
+ sides.put(getDown());
+ sides.put(getXPos());
+ sides.put(getXNeg());
+ sides.put(getZPos());
+ sides.put(getZNeg());
+ return sides;
+ }
+
+ public Block getBlockAtPos() {
+ return getBlockAtPos(this);
+ }
+
+ public Block getBlockAtPos(BlockPos pos) {
+ return getBlockAtPos(world, pos);
+ }
+
+ public Block getBlockAtPos(World world, BlockPos pos) {
+ return world.getBlock(pos.xPos, pos.yPos, pos.zPos);
+ }
+
+ public int getMetaAtPos() {
+ return getMetaAtPos(this);
+ }
+
+ public int getMetaAtPos(BlockPos pos) {
+ return getMetaAtPos(world, pos);
+ }
+
+ public int getMetaAtPos(World world, BlockPos pos) {
+ return world.getBlockMetadata(pos.xPos, pos.yPos, pos.zPos);
+ }
+
+ public boolean hasSimilarNeighbour() {
+ return hasSimilarNeighbour(false);
+ }
+
+ /**
+ * @param strict - Does this check Meta Data?
+ * @return - Does this block have a neighbour that is the same?
+ */
+ public boolean hasSimilarNeighbour(boolean strict) {
+ for (BlockPos g : getSurroundingBlocks().values()) {
+ if (getBlockAtPos(g) == getBlockAtPos()) {
+ if (!strict) {
+ return true;
+ } else {
+ if (getMetaAtPos() == getMetaAtPos(g)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public AutoMap<BlockPos> getSimilarNeighbour() {
+ return getSimilarNeighbour(false);
+ }
+
+ /**
+ * @param strict - Does this check Meta Data?
+ * @return - Does this block have a neighbour that is the same?
+ */
+ public AutoMap<BlockPos> getSimilarNeighbour(boolean strict) {
+ AutoMap<BlockPos> sides = new AutoMap<>();
+ for (BlockPos g : getSurroundingBlocks().values()) {
+ if (getBlockAtPos(g) == getBlockAtPos()) {
+ if (!strict) {
+ sides.put(g);
+ } else {
+ if (getMetaAtPos() == getMetaAtPos(g)) {
+ sides.put(g);
+ }
+ }
+ }
+ }
+ return sides;
+ }
+
+ public Set<BlockPos> getValidNeighboursAndSelf() {
+ AutoMap<BlockPos> h = getSimilarNeighbour(true);
+ h.put(this);
+ Set<BlockPos> result = new HashSet<>();
+ for (BlockPos f : h.values()) {
+ result.add(f);
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java b/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java
new file mode 100644
index 0000000000..5620b76895
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java
@@ -0,0 +1,56 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import net.minecraftforge.common.util.ForgeDirection;
+
+import gtPlusPlus.api.objects.data.AutoMap;
+
+public class CubicObject<T> {
+
+ public final T NORTH;
+ public final T SOUTH;
+
+ public final T WEST;
+ public final T EAST;
+
+ public final T UP;
+ public final T DOWN;
+
+ public CubicObject(AutoMap<T> aDataSet) {
+ this(aDataSet.get(0), aDataSet.get(1), aDataSet.get(2), aDataSet.get(3), aDataSet.get(4), aDataSet.get(5));
+ }
+
+ public CubicObject(T[] aDataSet) {
+ this(aDataSet[0], aDataSet[1], aDataSet[2], aDataSet[3], aDataSet[4], aDataSet[5]);
+ }
+
+ public CubicObject(T aDOWN, T aUP, T aNORTH, T aSOUTH, T aWEST, T aEAST) {
+ DOWN = aDOWN;
+ UP = aUP;
+ NORTH = aNORTH;
+ SOUTH = aSOUTH;
+ WEST = aWEST;
+ EAST = aEAST;
+ }
+
+ public T get(int ordinalSide) {
+ return get(ForgeDirection.getOrientation(ordinalSide));
+ }
+
+ public T get(ForgeDirection side) {
+ if (side == ForgeDirection.DOWN) {
+ return DOWN;
+ } else if (side == ForgeDirection.UP) {
+ return UP;
+ } else if (side == ForgeDirection.NORTH) {
+ return NORTH;
+ } else if (side == ForgeDirection.SOUTH) {
+ return SOUTH;
+ } else if (side == ForgeDirection.WEST) {
+ return WEST;
+ } else if (side == ForgeDirection.EAST) {
+ return EAST;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java
new file mode 100644
index 0000000000..c5c903cd1f
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java
@@ -0,0 +1,33 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import static gregtech.api.enums.Mods.GTPlusPlus;
+
+import net.minecraftforge.fluids.Fluid;
+
+import gregtech.api.GregTech_API;
+
+public class FluidGT6 extends Fluid implements Runnable {
+
+ private final short[] mRGBa;
+ public final String mTextureName;
+
+ public FluidGT6(final String aName, final String aTextureName, final short[] aRGBa) {
+ super(aName);
+ this.mRGBa = aRGBa;
+ this.mTextureName = aTextureName;
+ if (GregTech_API.sGTBlockIconload != null) {
+ GregTech_API.sGTBlockIconload.add(this);
+ }
+ }
+
+ @Override
+ public int getColor() {
+ return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8)
+ | Math.max(0, Math.min(255, this.mRGBa[2]));
+ }
+
+ @Override
+ public void run() {
+ this.setIcons(GregTech_API.sBlockIcons.registerIcon(GTPlusPlus.ID + ":" + "fluids/fluid." + this.mTextureName));
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java
new file mode 100644
index 0000000000..d68ef1a93f
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java
@@ -0,0 +1,57 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
+import gtPlusPlus.api.interfaces.RunnableWithInfo;
+import gtPlusPlus.core.handler.COMPAT_HANDLER;
+
+public abstract class ItemPackage implements RunnableWithInfo<String> {
+
+ public ItemPackage() {
+ this(false);
+ }
+
+ public ItemPackage(boolean hasExtraLateRun) {
+ // Register for late run
+ COMPAT_HANDLER.mObjectsToRunInPostInit.put(this);
+ if (hasExtraLateRun) {
+ COMPAT_HANDLER.mObjectsToRunInOnLoadComplete.put(this);
+ }
+ init();
+ }
+
+ @Override
+ public final void run() {
+ generateRecipes();
+ }
+
+ @Override
+ public final String getInfoData() {
+ return errorMessage();
+ }
+
+ public abstract String errorMessage();
+
+ public abstract boolean generateRecipes();
+
+ private void init() {
+ items();
+ blocks();
+ fluids();
+ }
+
+ public abstract void items();
+
+ public abstract void blocks();
+
+ public abstract void fluids();
+
+ /**
+ * Override this to handle GT Recipe map manipulation after they're Baked.
+ *
+ * @param event - the {@link FMLLoadCompleteEvent}.
+ * @return - Did we do anything?
+ */
+ public boolean onLoadComplete(FMLLoadCompleteEvent event) {
+ return false;
+ };
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java
new file mode 100644
index 0000000000..f5e483b91c
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java
@@ -0,0 +1,34 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+
+public class ItemStackData {
+
+ protected final Item mItem;
+ protected final int mDamage;
+ protected final int mStackSize;
+ protected final NBTTagCompound mNBT;
+ protected final String mUniqueDataTag;
+
+ public ItemStackData(ItemStack aStack) {
+ mItem = aStack.getItem();
+ mDamage = aStack.getItemDamage();
+ mStackSize = aStack.stackSize;
+ mNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound());
+ mUniqueDataTag = "" + Item.getIdFromItem(mItem) + "" + mDamage + "" + mStackSize + "" + mNBT.getId();
+ }
+
+ public String getUniqueDataIdentifier() {
+ return this.mUniqueDataTag;
+ }
+
+ public ItemStack getStack() {
+ ItemStack aTemp = ItemUtils.simpleMetaStack(mItem, mDamage, mStackSize);
+ aTemp.setTagCompound(mNBT);
+ return aTemp;
+ }
+}
diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java b/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java
new file mode 100644
index 0000000000..58a7affa90
--- /dev/null
+++ b/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java
@@ -0,0 +1,65 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import java.util.HashMap;
+
+import net.minecraft.util.IIcon;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gtPlusPlus.core.util.Utils;