diff options
| author | Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> | 2023-10-18 17:03:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-18 18:03:23 +0200 |
| commit | fbdbb388c369fae549cfde3eed38b536f7461d90 (patch) | |
| tree | b46f7fc949d7e4c6e3be910b81ed725e6dc1648e /src/main/java/gtPlusPlus/core/tileentities | |
| parent | b670446fdf49991093b485f0aa14050039632775 (diff) | |
| download | GT5-Unofficial-fbdbb388c369fae549cfde3eed38b536f7461d90.tar.gz GT5-Unofficial-fbdbb388c369fae549cfde3eed38b536f7461d90.tar.bz2 GT5-Unofficial-fbdbb388c369fae549cfde3eed38b536f7461d90.zip | |
Cleaning up (#767)
* Kill playerAPI
* Gut more events and compat that is now obsolete
* Remove commented out code
* Remove final modifier from methods
* Make more stuff final
* Remove slow building ring
* Protected -> private in final classes
* More cleaning
* More cleaning v2
* Purging
* Clean DevHelper
* Clean DevHelper 2
* delete DevHelper
* remove useless IFMLLoadingPlugin.MCVersion annotation from @Mod files
* check for obfuscation only once in the IFMLloadingPlugin.injectData
* don't instantiate the static class ASMConfig
* delete unused and empty implementation of IFMLCallHook
* delete empty class
* delete ClassesToTransform class that just holds the class names constants
* delete unused methods and unsless logging in dummymod container
* delete unused transformer ClassTransformer_TT_ThaumicRestorer
* spotless
* Clean
* Clean utils
* Build checkpoint
* Purge
* Stage 2
* Stage 3
* Stage 4
* Stage 5
* Stage 6
* Spotless
* Imports
* Stage idk
* Stage 1
* Fix issue
* Spotless
* Format numbers
---------
Co-authored-by: GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>
Co-authored-by: Alexdoru <57050655+Alexdoru@users.noreply.github.com>
Co-authored-by: Connor Colenso <colen@CONNORSPC>
Diffstat (limited to 'src/main/java/gtPlusPlus/core/tileentities')
11 files changed, 36 insertions, 1015 deletions
diff --git a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java index 1cb6e5699c..56cf2fdbab 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -8,13 +8,11 @@ import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; -import gtPlusPlus.core.tileentities.general.TileEntityPlayerDoorBase; import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; -import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; public class ModTileEntities { @@ -26,12 +24,10 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); - GameRegistry.registerTileEntity(TileEntityPlayerDoorBase.class, "TilePlayerDoorBase"); GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); - GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 762d5a4d61..56197098c6 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -473,7 +473,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT public boolean ignoreUnloadedChunks = true; public boolean isDead = false; - private final void clearNullMarkersFromTileEntityBuffer() { + private void clearNullMarkersFromTileEntityBuffer() { for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { if (this.mBufferedTileEntities[i] == this) { this.mBufferedTileEntities[i] = null; diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java index a170f71af3..895c68029d 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -65,7 +65,7 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv if (aInputs[25] != null) { hasOutput = true; } - AutoMap<Integer> aValidSlots = new AutoMap<Integer>(); + AutoMap<Integer> aValidSlots = new AutoMap<>(); int aSlotCount = 0; for (ItemStack i : aInputs) { if (i != null) { diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java index 5da2560cde..36df996eb0 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java @@ -68,8 +68,7 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven if (inv == null) { continue; } - if (inv.getItem() instanceof DustDecayable) { - DustDecayable D = (DustDecayable) inv.getItem(); + if (inv.getItem() instanceof DustDecayable D) { tryUpdateDecayable(D, inv, this.worldObj); } } @@ -353,7 +352,7 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven this.checkForAdjacentChests(); } - private final int updateSlots() { + private int updateSlots() { // Have slots changed? if (cachedChestType == 0) { return 0; diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java deleted file mode 100644 index 86e5454b80..0000000000 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java +++ /dev/null @@ -1,281 +0,0 @@ -package gtPlusPlus.core.tileentities.general; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDoor; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; - -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.util.minecraft.EntityUtils; - -public class TileEntityPlayerDoorBase extends TileEntity { - - public boolean mIsOpen = false; - private short mMeta = 0; - private long mTickCounter = 0; - private final Block mBlockType; - private BlockPos mNeighbourDoor; - - public TileEntityPlayerDoorBase(Block aBlock, int meta) { - mBlockType = aBlock; - } - - @Override - public void readFromNBT(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - this.mIsOpen = aNBT.getBoolean("mIsOpen"); - } - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - super.writeToNBT(aNBT); - aNBT.setBoolean("mIsOpen", mIsOpen); - } - - public int getNeighbourState() { - - if (mNeighbourDoor != null) { - World aWorld = this.worldObj; - if (aWorld != null) { - TileEntity t = aWorld.getTileEntity(mNeighbourDoor.xPos, mNeighbourDoor.yPos, mNeighbourDoor.zPos); - // Custom Door - if (t != null) { - if (t instanceof TileEntityPlayerDoorBase) { - TileEntityPlayerDoorBase d = (TileEntityPlayerDoorBase) t; - if (d.mIsOpen) { - return 100; - } else { - return -100; - } - } else return -100; - } - // Vanilla Door - else { - Block aBlock = mNeighbourDoor.getBlockAtPos(); - BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); - if (aDoor != null) { - int i1 = aDoor.func_150012_g( - mNeighbourDoor.world, - mNeighbourDoor.xPos, - mNeighbourDoor.yPos, - mNeighbourDoor.zPos); - if ((i1 & 4) != 0) { - return 100; - } else { - return -100; - } - } - } - } - } - return 0; - } - - AutoMap<Entity> mNearbyEntityCache = new AutoMap<Entity>(); - - @Override - public void updateEntity() { - - if (this.getWorldObj().isRemote) { - return; - } - - // Look For Neighbours - if (mTickCounter % 100 == 0 || mTickCounter == 0) { - World aWorld = this.getWorldObj(); - BlockPos aThisPos = new BlockPos(xCoord, yCoord, zCoord, aWorld); - BlockPos[] aNeighbors = new BlockPos[4]; - aNeighbors[0] = aThisPos.getXNeg(); - aNeighbors[1] = aThisPos.getXPos(); - aNeighbors[2] = aThisPos.getZNeg(); - aNeighbors[3] = aThisPos.getZPos(); - boolean aFoundDoor = false; - for (BlockPos b : aNeighbors) { - Block aBlock = aWorld.getBlock(b.xPos, b.yPos, b.zPos); - BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); - if (aDoor != null) { - mNeighbourDoor = b; - aFoundDoor = true; - if (mMeta == 0) { - TileEntity t = aWorld.getTileEntity(b.xPos, b.yPos, b.zPos); - if (t != null) { - if (t instanceof TileEntityPlayerDoorBase) { - TileEntityPlayerDoorBase d = (TileEntityPlayerDoorBase) t; - if (d.mMeta != 0) { - // Logger.INFO("Found Door with Mode set other than 0, assuming slave role."); - mMeta = -1; - } else { - // Logger.INFO("Found door with no mode set, assuming we are master."); - mMeta = 1; - } - } else { - // Logger.INFO("Custom door from another mod, assuming slave role."); - mMeta = -1; - } - } else { - // Logger.INFO("No Tile Entity found, Door is probably vanilla, assuming slave role."); - mMeta = -1; - } - } - break; - } - } - if (mMeta < 1 && !aFoundDoor) { - // Logger.INFO("Found No Valid Doors around, setting this one to master mode."); - mMeta = 1; - } - } - - World aWorld = this.getWorldObj(); - Block aBlock = aWorld.getBlock(xCoord, yCoord, zCoord); - BlockPos aThisPos = new BlockPos(xCoord, yCoord, zCoord, this.worldObj); - - if (mTickCounter % 20 == 0) { - int x = 0, y = 0, z = 0; - x = this.xCoord; - y = this.yCoord; - z = this.zCoord; - // List aEntityList = aWorld.loadedEntityList; - List<Entity> aEntityList = new ArrayList<Entity>(); - Chunk aThisChunk = aWorld.getChunkFromBlockCoords(x, z); - for (List l : aThisChunk.entityLists) { - aEntityList.addAll(l); - } - for (Object o : aEntityList) { - if (o != null) { - if (o instanceof Entity) { - if (o instanceof EntityPlayer) { - continue; - } else { - Entity e = (Entity) o; - BlockPos p = EntityUtils.findBlockPosUnderEntity(e); - if (p != null) { - int newY = p.yPos + 1; - if (e.getDistance(xCoord, yCoord, zCoord) <= 2) { - mNearbyEntityCache.put(e); - } else if (aThisPos.distanceFrom(p.xPos, newY, p.zPos) <= 2) { - mNearbyEntityCache.put(e); - } - } - } - } - } - } - } - - if (mTickCounter % 4 == 0) { - for (Entity y : mNearbyEntityCache) { - if (y.getDistance(xCoord, yCoord, zCoord) > 2) { - mNearbyEntityCache.remove(y); - } - } - - boolean foundMonster = mNearbyEntityCache.size() > 0; - int aNeighbourDoorState = 0; - if (mNeighbourDoor != null) { - aNeighbourDoorState = getNeighbourState(); - } - BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); - boolean aPlayers = checkForPlayers(this.getWorldObj()); - - if (aDoor != null) { - // If neighbour state != 0 and we are in slave mode - if (aNeighbourDoorState != 0 && mMeta == -1) { - if (aNeighbourDoorState == 100) { - if (!mIsOpen && !foundMonster) { - // Logger.INFO("Opening Door (Slave)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, true); - mIsOpen = true; - } - } else if (aNeighbourDoorState == -100 || foundMonster) { - if (mIsOpen) { - // Logger.INFO("Closing Door (Slave)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, false); - mIsOpen = false; - } - } - // We are master, proceed - } else { - // No redstone found, allow automatic handling - if (aDoor != null && !hasRedstone()) { - // Found a nearby player - if (aPlayers) { - // If we are closed and there are no monsters nearby, open - if (!mIsOpen && !foundMonster) { - // Logger.INFO("Opening Door (Mstr)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, true); - mIsOpen = true; - } else { - // Logger.INFO("Doing Nothing, Door is in correct state."); - } - // Did not find nearby player - } else { - // If we are open or there is a monster nearby, close. - if (mIsOpen || foundMonster) { - // Logger.INFO("Closing Door (Mstr)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, false); - mIsOpen = false; - } else { - // Logger.INFO("Doing Nothing, Door is in correct state."); - } - } - } - } - } - } - super.updateEntity(); - mTickCounter++; - } - - @Override - public int getBlockMetadata() { - return this.mMeta; - } - - public boolean hasRedstone() { - World aWorld = this.worldObj; - if (aWorld != null && !aWorld.isRemote) { - return aWorld.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) - || aWorld.isBlockIndirectlyGettingPowered(xCoord, yCoord + 1, zCoord); - } - return false; - } - - @Override - public Block getBlockType() { - return mBlockType; - } - - @Override - public boolean canUpdate() { - return true; - } - - private boolean checkForPlayers(World aWorld) { - int x = 0, y = 0, z = 0; - x = this.xCoord; - y = this.yCoord; - z = this.zCoord; - EntityPlayer aPlayer = aWorld.getClosestPlayer(x, y, z, 3.5D); - if (aPlayer != null) { - return true; - } - return false; - } - - private short getClosedMeta() { - return 0; - } - - private short getOpenMeta() { - return 1; - } -} diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index 9e829e0c16..a7fb226411 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -87,25 +87,25 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide } private int getCapacityForSlot(int aSlot) { - switch (aSlot) { - case 0: // 16 - return 16; - case 1: // 36 - return 36; - case 2: // 144 - return 144; - case 3: // 432 - return 432; - case 4: // 576 - return 576; - case 5: // 720 - return 720; - case 6: // 864 - return 864; - case 7: // Custom - return getCustomValue(); - } - return 1000; + return switch (aSlot) { + case 0 -> // 16 + 16; + case 1 -> // 36 + 36; + case 2 -> // 144 + 144; + case 3 -> // 432 + 432; + case 4 -> // 576 + 576; + case 5 -> // 720 + 720; + case 6 -> // 864 + 864; + case 7 -> // Custom + getCustomValue(); + default -> 1000; + }; } public boolean addOutput() { @@ -126,7 +126,7 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide return false; } } - AutoMap<Integer> aValidSlots = new AutoMap<Integer>(); + AutoMap<Integer> aValidSlots = new AutoMap<>(); int aSlotCount = 0; for (ItemStack i : aInputs) { if (i != null) { diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java index c256f73b4c..d3add73de7 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -63,7 +63,7 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { return false; } - private static AutoMap<Class> aEntityToDrain = new AutoMap<Class>(); + private static AutoMap<Class> aEntityToDrain = new AutoMap<>(); @Override public AutoMap<Class> aThingsToLookFor() { diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java index 54014103cd..ac78658403 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java @@ -52,7 +52,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory, private boolean mNeedsUpdate = false; private String mCustomName; - private static final AutoMap<Class<?>> mEntityMap = new AutoMap<Class<?>>(); + private static final AutoMap<Class<?>> mEntityMap = new AutoMap<>(); static { mEntityMap.put(EntityBat.class); @@ -74,7 +74,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory, return mTank; } - private final void setup() { + private void setup() { World w = this.worldObj; if (w != null) { Chunk c = w.getChunkFromBlockCoords(this.xCoord, this.zCoord); @@ -91,19 +91,19 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory, int min = 0; int max = 0; switch (getTier()) { - case 1: + case 1 -> { min = -2; max = 3; - break; - case 2: + } + case 2 -> { min = -4; max = 5; - break; - default: - // code block + } + default -> {} + // code block } int aChunkCount = 0; - AutoMap<Entity> entities = new AutoMap<Entity>(); + AutoMap<Entity> entities = new AutoMap<>(); if (min != 0 && max != 0) { for (int x = min; x < max; x++) { for (int z = min; z < max; z++) { @@ -491,7 +491,7 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory, this.mNeedsUpdate = true; } - private final void updateTick() { + private void updateTick() { if (mNeedsUpdate) { if (mUpdateTick == 0) { mUpdateTick = 4; // every 4 ticks it will send an update diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java index ceff9d8528..d0d4ee3661 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -67,7 +67,7 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { return false; } - private static AutoMap<Class> aEntityToDrain = new AutoMap<Class>(); + private static AutoMap<Class> aEntityToDrain = new AutoMap<>(); @Override public AutoMap<Class> aThingsToLookFor() { diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java index 0229f89402..a287d8c33a 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.Vector; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -30,10 +28,6 @@ public class TileEntityProjectTable extends TileEntity public InventoryProjectMain inventoryGrid; public InventoryProjectOutput inventoryOutputs; - /** The crafting matrix inventory (3x3). */ - public InventoryCrafting craftMatrix; - - public IInventory craftResult; private Container_ProjectTable container; public TileEntityProjectTable() { diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java deleted file mode 100644 index 366251941b..0000000000 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java +++ /dev/null @@ -1,687 +0,0 @@ -package gtPlusPlus.core.tileentities.machines; - -import java.util.EnumSet; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockChest; -import net.minecraft.command.IEntitySelector; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S35PacketUpdateTileEntity; -import net.minecraft.tileentity.IHopper; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.handler.GuiHandler; -import gtPlusPlus.core.inventories.Inventory_RoundRobinator; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; - -public class TileEntityRoundRobinator extends TileEntity implements ISidedInventory, IHopper { - - private int tickCount = 0; - private final Inventory_RoundRobinator inventoryContents; - private String customName; - public int locationX; - public int locationY; - public int locationZ; - private int aData = 1111; - private int aTier = 1; - private int aTickRate = 100; - - public TileEntityRoundRobinator() { - this.inventoryContents = new Inventory_RoundRobinator(); - this.setTileLocation(); - } - - public boolean setTileLocation() { - if (this.hasWorldObj()) { - if (!this.getWorldObj().isRemote) { - this.locationX = this.xCoord; - this.locationY = this.yCoord; - this.locationZ = this.zCoord; - this.aTier = this.getWorldObj().getBlockMetadata(locationX, locationY, locationZ) + 1; - return true; - } - } - return false; - } - - // Rename to hasCircuitToConfigure - public final boolean hasInventoryContents() { - for (ItemStack i : this.aHopperInventory) { - if (i == null) { - continue; - } else { - return true; - } - } - return false; - } - - public Inventory_RoundRobinator getInventory() { - return this.inventoryContents; - } - - public int getTier() { - return this.aTier; - } - - public int getTickRate() { - return this.aTickRate; - } - - @Override - public void updateEntity() { - try { - // TODO - if (this.worldObj != null && !this.worldObj.isRemote) { - setTileLocation(); - aTickRate = (60 - (aTier * 10)); - if (this.getTier() == 1) { - // 20 s - aTickRate = 400; - } else if (this.getTier() == 2) { - // 5 - aTickRate = 100; - } else if (this.getTier() == 3) { - // 1 - aTickRate = 20; - } else if (this.getTier() == 4) { - // 1/5 - aTickRate = 10; - } else if (this.getTier() == 5) { - // 1/20 - aTickRate = 1; - } else { - aTickRate = 999999; - } - - if (tickCount % getTickRate() == 0) { - if (hasInventoryContents()) { - Logger.WARNING("Trying to move items. " + aTickRate); - this.tryProcessItems(); - } - } - this.tickCount++; - } - } catch (final Throwable t) { - t.printStackTrace(); - } - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - nbt.setInteger("aCurrentMode", aData); - this.writeToNBT2(nbt); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - aData = nbt.getInteger("aCurrentMode"); - this.readFromNBT2(nbt); - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - // this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - // this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - return new int[] { 0, 1, 2, 3, 4 }; - } - - @Override - public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int aSide) { - return aSide < 2; - } - - @Override - public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int aSide) { - return false; - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(final String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customN |
