diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-05-01 02:45:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 11:45:56 +0200 |
commit | b2c8cfb4ec8b82337a95f51364277964ec968b52 (patch) | |
tree | d4cf94acc93249cd649b33ec13c5b0d75f1f75db /src/main/java/gtPlusPlus/api/objects | |
parent | d2eda84e457d549ad9a51f40e9dd159147a141f8 (diff) | |
download | GT5-Unofficial-b2c8cfb4ec8b82337a95f51364277964ec968b52.tar.gz GT5-Unofficial-b2c8cfb4ec8b82337a95f51364277964ec968b52.tar.bz2 GT5-Unofficial-b2c8cfb4ec8b82337a95f51364277964ec968b52.zip |
ForgeDirection (#608)
* ForgeDirection WIP
* Fix GTPP_Render_MachineBlock
Fix handling of getTexture with facing mask for pipes
Kill a bunch of magic numbers
* spotlessApply (#612)
Co-authored-by: GitHub GTNH Actions <>
* Bump bw/tt deps
---------
Co-authored-by: Léa Gris <lea.gris@noiraude.net>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gtPlusPlus/api/objects')
9 files changed, 86 insertions, 32 deletions
diff --git a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java index 9e26ea9174..f4b2550b5a 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java @@ -118,6 +118,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect return set(object); } + @Override public synchronized boolean add(V object) { return set(object) != null; } @@ -130,6 +131,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect return mInternalMap.put(mInternalID++, object); } + @Override public synchronized V get(int id) { return mInternalMap.get(id); } @@ -138,6 +140,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect return mInternalMap.values(); } + @Override public synchronized int size() { return mInternalMap.size(); } @@ -154,10 +157,12 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect return mInternalMap.containsValue(value); } + @Override public synchronized boolean isEmpty() { return mInternalMap.isEmpty(); } + @Override public synchronized void clear() { this.mInternalID = 0; this.mInternalMap.clear(); @@ -165,6 +170,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect return; } + @Override @SuppressWarnings("unchecked") public V[] toArray() { V[] toR = (V[]) java.lang.reflect.Array.newInstance(mInternalMap.get(0).getClass(), mInternalMap.size()); @@ -178,6 +184,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect return mInternalID; } + @Override public final synchronized boolean remove(Object value) { value.getClass(); if (this.mInternalMap.containsValue(value)) { diff --git a/src/main/java/gtPlusPlus/api/objects/data/ReverseAutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/ReverseAutoMap.java index da6fc7d181..275dad9d42 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/ReverseAutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/ReverseAutoMap.java @@ -24,6 +24,7 @@ public class ReverseAutoMap<N> extends AutoMap<N> { return values().iterator(); } + @Override public synchronized boolean setValue(N object) { int mOriginalID = this.mInternalID; put(object); diff --git a/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java b/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java index c282ce1eb3..e4b4e0db88 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java +++ b/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java @@ -46,6 +46,7 @@ public class TypeCounter<V> implements Set<V> { } } + @Override public boolean add(V arg0) { return add(arg0, null); } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java index 56a134716b..ac061c44fd 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java @@ -18,14 +18,17 @@ public class BTF_FluidTank extends FluidTank { * * @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) { @@ -34,6 +37,7 @@ public class BTF_FluidTank extends FluidTank { return aNBT; } + @Override public FluidTank readFromNBT(NBTTagCompound aNBT) { this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); return this; @@ -82,6 +86,7 @@ public class BTF_FluidTank extends FluidTank { return true; } + @Override public int fill(FluidStack aFluid, boolean doFill) { if (aFluid != null && aFluid.getFluid().getID() > 0 && aFluid.amount > 0 @@ -126,6 +131,7 @@ public class BTF_FluidTank extends FluidTank { } } + @Override public FluidStack drain(int maxDrain, boolean doDrain) { if (this.getDrainableStack() != null && this.canTankBeEmptied()) { if (this.getDrainableStack().amount <= 0 && this.isFluidChangingAllowed()) { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index 6dac3a7acd..cc3c2cd36e 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -5,6 +5,7 @@ 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 gtPlusPlus.core.tileentities.base.TileEntityBase; @@ -25,14 +26,17 @@ public class BTF_Inventory implements ISidedInventory { 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; @@ -47,6 +51,7 @@ public class BTF_Inventory implements ISidedInventory { return true; } + @Override public int getInventoryStackLimit() { return 64; } @@ -55,10 +60,12 @@ public class BTF_Inventory implements ISidedInventory { 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 }); @@ -80,34 +87,36 @@ public class BTF_Inventory implements ISidedInventory { return rStack; } - public int[] getAccessibleSlotsFromSide(int aSide) { + @Override + public int[] getAccessibleSlotsFromSide(int ordinalSide) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); ArrayList<Integer> tList = new ArrayList<Integer>(); TileEntityBase tTileEntity = this.mTile; - boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), + boolean tSkip = tTileEntity.getCoverBehaviorAtSide(side).letsItemsIn( + side, + tTileEntity.getCoverIDAtSide(side), + tTileEntity.getCoverDataAtSide(side), -2, tTileEntity) - || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), + || tTileEntity.getCoverBehaviorAtSide(side).letsItemsOut( + side, + tTileEntity.getCoverIDAtSide(side), + tTileEntity.getCoverDataAtSide(side), -2, tTileEntity); for (int rArray = 0; rArray < this.getSizeInventory(); ++rArray) { if (this.isValidSlot(rArray) && (tSkip - || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), + || tTileEntity.getCoverBehaviorAtSide(side).letsItemsOut( + side, + tTileEntity.getCoverIDAtSide(side), + tTileEntity.getCoverDataAtSide(side), rArray, tTileEntity) - || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), + || tTileEntity.getCoverBehaviorAtSide(side).letsItemsIn( + side, + tTileEntity.getCoverIDAtSide(side), + tTileEntity.getCoverDataAtSide(side), rArray, tTileEntity))) { tList.add(Integer.valueOf(rArray)); @@ -123,36 +132,42 @@ public class BTF_Inventory implements ISidedInventory { return arg6; } - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + @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, (byte) aSide, aStack); + && this.allowPutStack(this.mTile, aIndex, ForgeDirection.getOrientation(ordinalSide), aStack); } - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + @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, (byte) aSide, aStack); + && this.allowPullStack(this.mTile, aIndex, ForgeDirection.getOrientation(ordinalSide), aStack); } - public boolean allowPullStack(TileEntityBase mTile2, int aIndex, byte aSide, ItemStack 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, byte aSide, ItemStack aStack) { + 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(); @@ -160,12 +175,15 @@ public class BTF_Inventory implements ISidedInventory { } } + @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } + @Override public void openInventory() {} + @Override public void closeInventory() {} @Override diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java b/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java index 5799a12822..5620b76895 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java @@ -32,22 +32,22 @@ public class CubicObject<T> { EAST = aEAST; } - public T get(int aSide) { - return get(ForgeDirection.getOrientation(aSide)); + public T get(int ordinalSide) { + return get(ForgeDirection.getOrientation(ordinalSide)); } - public T get(ForgeDirection aSide) { - if (aSide == ForgeDirection.DOWN) { + public T get(ForgeDirection side) { + if (side == ForgeDirection.DOWN) { return DOWN; - } else if (aSide == ForgeDirection.UP) { + } else if (side == ForgeDirection.UP) { return UP; - } else if (aSide == ForgeDirection.NORTH) { + } else if (side == ForgeDirection.NORTH) { return NORTH; - } else if (aSide == ForgeDirection.SOUTH) { + } else if (side == ForgeDirection.SOUTH) { return SOUTH; - } else if (aSide == ForgeDirection.WEST) { + } else if (side == ForgeDirection.WEST) { return WEST; - } else if (aSide == ForgeDirection.EAST) { + } else if (side == ForgeDirection.EAST) { return EAST; } else { return null; diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java index d627d47349..4af3df18ba 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java @@ -39,11 +39,13 @@ public class FakeBlockPos extends BlockPos { super(x, y, z, null); } + @Override public String getLocationString() { String S = "" + this.xPos + "@" + this.yPos + "@" + this.zPos; return S; } + @Override public String getUniqueIdentifier() { String S = "" + this.xPos + "@" @@ -95,6 +97,7 @@ public class FakeBlockPos extends BlockPos { * @param z Z coordinate of target. * @return square of distance */ + @Override public int distanceFrom(int x, int y, int z) { int distanceX = this.xPos - x; int distanceY = this.yPos - y; @@ -109,34 +112,42 @@ public class FakeBlockPos extends BlockPos { return isWithinRange(target.xPos, target.yPos, target.zPos, range); } + @Override public boolean isWithinRange(int x, int y, int z, int range) { return distanceFrom(x, y, z) <= (range * range); } + @Override public FakeBlockPos getUp() { return new FakeBlockPos(this.xPos, this.yPos + 1, this.zPos, this.dim); } + @Override public FakeBlockPos getDown() { return new FakeBlockPos(this.xPos, this.yPos - 1, this.zPos, this.dim); } + @Override public FakeBlockPos getXPos() { return new FakeBlockPos(this.xPos + 1, this.yPos, this.zPos, this.dim); } + @Override public FakeBlockPos getXNeg() { return new FakeBlockPos(this.xPos - 1, this.yPos, this.zPos, this.dim); } + @Override public FakeBlockPos getZPos() { return new FakeBlockPos(this.xPos, this.yPos, this.zPos + 1, this.dim); } + @Override public FakeBlockPos getZNeg() { return new FakeBlockPos(this.xPos, this.yPos, this.zPos - 1, this.dim); } + @Override public AutoMap<BlockPos> getSurroundingBlocks() { AutoMap<BlockPos> sides = new AutoMap<BlockPos>(); sides.put(getUp()); @@ -148,6 +159,7 @@ public class FakeBlockPos extends BlockPos { return sides; } + @Override public Block getBlockAtPos() { return getBlockAtPos(this); } @@ -160,6 +172,7 @@ public class FakeBlockPos extends BlockPos { return aBlockAtPos; } + @Override public int getMetaAtPos() { return getMetaAtPos(this); } @@ -172,6 +185,7 @@ public class FakeBlockPos extends BlockPos { return aBlockMetaAtPos; } + @Override public boolean hasSimilarNeighbour() { return hasSimilarNeighbour(false); } @@ -180,6 +194,7 @@ public class FakeBlockPos extends BlockPos { * @param strict - Does this check Meta Data? * @return - Does this block have a neighbour that is the same? */ + @Override public boolean hasSimilarNeighbour(boolean strict) { for (BlockPos g : getSurroundingBlocks().values()) { if (getBlockAtPos(g) == getBlockAtPos()) { @@ -195,6 +210,7 @@ public class FakeBlockPos extends BlockPos { return false; } + @Override public AutoMap<BlockPos> getSimilarNeighbour() { return getSimilarNeighbour(false); } @@ -203,6 +219,7 @@ public class FakeBlockPos extends BlockPos { * @param strict - Does this check Meta Data? * @return - Does this block have a neighbour that is the same? */ + @Override public AutoMap<BlockPos> getSimilarNeighbour(boolean strict) { AutoMap<BlockPos> sides = new AutoMap<BlockPos>(); for (BlockPos g : getSurroundingBlocks().values()) { @@ -219,6 +236,7 @@ public class FakeBlockPos extends BlockPos { return sides; } + @Override public Set<BlockPos> getValidNeighboursAndSelf() { AutoMap<BlockPos> h = getSimilarNeighbour(true); h.put(this); diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java index d294326ff3..be158a38cd 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java @@ -97,11 +97,13 @@ public class FakeWorld implements IBlockAccess { return aOutput; } + @Override public Block getBlock(int x, int y, int z) { FakeBlockPos aPos = getBlockAtCoords(x, y, z); return aPos.getBlockAtPos(); } + @Override public boolean isAirBlock(int x, int y, int z) { Block aBlock = getBlock(x, y, z); return aBlock == Blocks.air || aBlock.getMaterial() == Material.air; diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java b/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java index e8b4a19031..df48c24c06 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java @@ -24,6 +24,7 @@ public class NoConflictGTRecipeMap implements Collection<GT_Recipe> { return add(recipe); } + @Override public boolean add(GT_Recipe recipe) { return mRecipeCache.setValue(recipe); } |