diff options
| author | miozune <miozune@gmail.com> | 2023-09-10 16:34:53 +0900 |
|---|---|---|
| committer | miozune <miozune@gmail.com> | 2023-09-10 16:35:17 +0900 |
| commit | 84b4d11e693439e87687c5d636497ed61de9402c (patch) | |
| tree | 1c25b7e29773194b6a5d9a9389c46af04a319119 /src/main/java/common/tileentities | |
| parent | 3dfd657c27f0efe2e20841a3e93a92c7881e8f6f (diff) | |
| download | GT5-Unofficial-84b4d11e693439e87687c5d636497ed61de9402c.tar.gz GT5-Unofficial-84b4d11e693439e87687c5d636497ed61de9402c.tar.bz2 GT5-Unofficial-84b4d11e693439e87687c5d636497ed61de9402c.zip | |
Remove Item Proxy things
Diffstat (limited to 'src/main/java/common/tileentities')
3 files changed, 0 insertions, 435 deletions
diff --git a/src/main/java/common/tileentities/TE_ItemProxyCable.java b/src/main/java/common/tileentities/TE_ItemProxyCable.java deleted file mode 100644 index 1dc539c89e..0000000000 --- a/src/main/java/common/tileentities/TE_ItemProxyCable.java +++ /dev/null @@ -1,155 +0,0 @@ -package common.tileentities; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -public class TE_ItemProxyCable extends TileEntity { - - private static final float THICKNESS = 0.5F; - private byte connections = 0; - private byte connectionAllowed = 63; - private String idCache = null; - - public TE_ItemProxyCable() {} - - @Override - public void updateEntity() { - // Check all 6 sides and connect the conduit if it is allowed to - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - final TileEntity te = super.getWorldObj().getTileEntity( - super.xCoord + side.offsetX, - super.yCoord + side.offsetY, - super.zCoord + side.offsetZ); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - setConnection(side, cable.isConnectionAllowed(side.getOpposite())); - } else { - setConnection(side, false); - } - } - } - - public static float getThickness() { - return THICKNESS; - } - - /** - * Builds a simple unique identifier for this TileEntity by appending the x, y, and z coordinates in a string. - * - * @return unique identifier for this TileEntity - */ - public String getIdentifier() { - if (idCache == null) { - idCache = "" + super.xCoord + super.yCoord + super.zCoord; - return idCache; - } else { - return idCache; - } - } - - /** - * 0 0 0 0 0 0 0 0 = 0 -> no connection </br> - * 0 0 0 0 0 0 0 1 = 1 -> down </br> - * 0 0 0 0 0 0 1 0 = 2 -> up </br> - * 0 0 0 0 0 1 0 0 = 4 -> north </br> - * 0 0 0 0 1 0 0 0 = 8 -> south </br> - * 0 0 0 1 0 0 0 0 = 16 -> west </br> - * 0 0 1 0 0 0 0 0 = 32 -> east </br> - * - * @param side The side for which to set the connection status. - * @param connected Whether this side should be connected or not - * @return True if the connection was allowed - */ - public boolean setConnection(ForgeDirection side, boolean connected) { - if (isConnectionAllowed(side)) { - switch (side) { - case DOWN: - connections = (byte) ((connected) ? connections | 1 : connections ^ 1); - break; - case UP: - connections = (byte) ((connected) ? connections | 2 : connections ^ 2); - break; - case NORTH: - connections = (byte) ((connected) ? connections | 4 : connections ^ 4); - break; - case SOUTH: - connections = (byte) ((connected) ? connections | 8 : connections ^ 8); - break; - case WEST: - connections = (byte) ((connected) ? connections | 16 : connections ^ 16); - break; - case EAST: - connections = (byte) ((connected) ? connections | 32 : connections ^ 32); - break; - default: - return false; - } - return true; - } else { - return false; - } - } - - public boolean isConnected(ForgeDirection side) { - switch (side) { - case DOWN: - return (connections & 1) == 1; - case UP: - return (connections & 2) == 2; - case NORTH: - return (connections & 4) == 4; - case SOUTH: - return (connections & 8) == 8; - case WEST: - return (connections & 16) == 16; - case EAST: - return (connections & 32) == 32; - default: - return false; - } - } - - public void setConnectionAllowed(ForgeDirection side, boolean allowed) { - switch (side) { - case DOWN: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 1 : connectionAllowed ^ 1); - break; - case UP: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 2 : connectionAllowed ^ 2); - break; - case NORTH: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 4 : connectionAllowed ^ 4); - break; - case SOUTH: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 8 : connectionAllowed ^ 8); - break; - case WEST: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 16 : connectionAllowed ^ 16); - break; - case EAST: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 32 : connectionAllowed ^ 32); - break; - default: - break; - } - } - - public boolean isConnectionAllowed(ForgeDirection side) { - switch (side) { - case DOWN: - return (connectionAllowed & 1) == 1; - case UP: - return (connectionAllowed & 2) == 2; - case NORTH: - return (connectionAllowed & 4) == 4; - case SOUTH: - return (connectionAllowed & 8) == 8; - case WEST: - return (connectionAllowed & 16) == 16; - case EAST: - return (connectionAllowed & 32) == 32; - default: - return false; - } - } -} diff --git a/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java b/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java deleted file mode 100644 index 7d58a21c61..0000000000 --- a/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java +++ /dev/null @@ -1,175 +0,0 @@ -package common.tileentities; - -import java.util.HashSet; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -public class TE_ItemProxyEndpoint extends TileEntity implements ISidedInventory { - - private byte channel = -1; - private IInventory proxyInventory = null; - private int tickCounter = 0; - - public TE_ItemProxyEndpoint() { - channel = 0; - } - - public void setChannel(byte channel) { - this.channel = channel; - } - - public int getChannel() { - return channel; - } - - @Override - public void updateEntity() { - if (tickCounter == 20) { - if (channel != -1) { - proxyInventory = searchSource(); - } - tickCounter = 0; - } - tickCounter++; - } - - private TE_ItemProxySource searchSource() { - - final HashSet<TE_ItemProxySource> sources = new HashSet<>(); - final HashSet<String> visited = new HashSet<>(); - - for (ForgeDirection next : ForgeDirection.VALID_DIRECTIONS) { - final TileEntity te = super.getWorldObj().getTileEntity( - super.xCoord + next.offsetX, - super.yCoord + next.offsetY, - super.zCoord + next.offsetZ); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - if (cable.isConnected(next.getOpposite())) { - searchSourceRecursive(sources, visited, next.getOpposite(), cable); - } - } - } - - if (sources.isEmpty()) { - return null; - } else { - return sources.iterator().next(); - } - } - - private void searchSourceRecursive(HashSet<TE_ItemProxySource> sources, HashSet<String> visited, - ForgeDirection from, TE_ItemProxyCable nextTarget) { - - if (!visited.contains(nextTarget.getIdentifier())) { - visited.add(nextTarget.getIdentifier()); - - for (ForgeDirection next : ForgeDirection.VALID_DIRECTIONS) { - if (next != from) { - final TileEntity te = super.getWorldObj().getTileEntity( - nextTarget.xCoord + next.offsetX, - nextTarget.yCoord + next.offsetY, - nextTarget.zCoord + next.offsetZ); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - if (cable.isConnected(next.getOpposite())) { - searchSourceRecursive(sources, visited, next.getOpposite(), cable); - } - } else if (te instanceof TE_ItemProxySource) { - sources.add((TE_ItemProxySource) te); - } - } - } - } - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public ItemStack getStackInSlot(int slot) { - if (proxyInventory != null && slot == 0) { - return proxyInventory.getStackInSlot(channel); - } else { - return null; - } - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - if (proxyInventory != null && slot == 0) { - return proxyInventory.decrStackSize(channel, amount); - } else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return (proxyInventory != null) ? proxyInventory.getStackInSlotOnClosing(channel) : null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) { - if (proxyInventory != null && slot == 0) { - proxyInventory.setInventorySlotContents(channel, itemStack); - } - } - - @Override - public String getInventoryName() { - return (proxyInventory != null) ? "Connected: " + proxyInventory.getInventoryName() : "Untethered Proxy"; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public int getInventoryStackLimit() { - return (proxyInventory != null) ? proxyInventory.getInventoryStackLimit() : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemStack) { - if (proxyInventory != null && slot == 0) { - return proxyInventory.isItemValidForSlot(channel, itemStack); - } else { - return false; - } - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return new int[] { 0 }; - } - - @Override - public boolean canInsertItem(int slot, ItemStack itemStack, int side) { - return isItemValidForSlot(slot, itemStack); - } - - @Override - public boolean canExtractItem(int slot, ItemStack itemStack, int side) { - return slot == 0; - } -} diff --git a/src/main/java/common/tileentities/TE_ItemProxySource.java b/src/main/java/common/tileentities/TE_ItemProxySource.java deleted file mode 100644 index 31403f5352..0000000000 --- a/src/main/java/common/tileentities/TE_ItemProxySource.java +++ /dev/null @@ -1,105 +0,0 @@ -package common.tileentities; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -public class TE_ItemProxySource extends TileEntity implements IInventory { - - private final ItemStack[] slots = new ItemStack[16]; - private String idCache = null; - - /** - * Builds a simple unique identifier for this TileEntity by appending the x, y, and z coordinates in a string. - * - * @return unique identifier for this TileEntity - */ - public String getIdentifier() { - if (idCache == null) { - idCache = "" + super.xCoord + super.yCoord + super.zCoord; - return idCache; - } else { - return idCache; - } - } - - @Override - public int getSizeInventory() { - return slots.length; - } - - @Override - public ItemStack getStackInSlot(int slot) { - return slots[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - if (slots[slot] != null) { - - ItemStack copy; - - if (slots[slot].stackSize == amount) { - copy = slots[slot]; - slots[slot] = null; - super.markDirty(); - return copy; - } else { - copy = slots[slot].splitStack(amount); - if (slots[slot].stackSize == 0) { - slots[slot] = null; - } - return copy; - } - - } else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) { - slots[slot] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { - itemStack.stackSize = getInventoryStackLimit(); - } - super.markDirty(); - } - - @Override - public String getInventoryName() { - return "Item Proxy Source"; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemStack) { - return true; - } -} |
