diff options
Diffstat (limited to 'src/main/java/gregtech/api/graphs/Lock.java')
-rw-r--r-- | src/main/java/gregtech/api/graphs/Lock.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/graphs/Lock.java b/src/main/java/gregtech/api/graphs/Lock.java new file mode 100644 index 0000000000..d3c8c49169 --- /dev/null +++ b/src/main/java/gregtech/api/graphs/Lock.java @@ -0,0 +1,38 @@ +package gregtech.api.graphs; + +import java.util.ArrayList; + +import net.minecraft.tileentity.TileEntity; + +public class Lock { + + protected ArrayList<TileEntity> tiles = new ArrayList<>(); + + public void addTileEntity(TileEntity tileEntity) { + int i = contains(tileEntity); + if (i == -1) { + tiles.add(tileEntity); + } + } + + public void removeTileEntity(TileEntity tileEntity) { + int i = contains(tileEntity); + if (i > -1) { + tiles.remove(i); + } + } + + public boolean isLocked() { + return !tiles.isEmpty(); + } + + // i want to check for the exact object not equals + protected int contains(TileEntity tileEntity) { + for (int i = 0; i < tiles.size(); i++) { + if (tiles.get(i) == tileEntity) { + return i; + } + } + return -1; + } +} |