aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2018-02-07 22:28:35 +1000
committerJordan Byrne <draknyte1@hotmail.com>2018-02-07 22:28:35 +1000
commitf4ac62247a54c38466fb7544aae63e6d97fb2740 (patch)
treef422cccbd6b944bd163189fe094e9ca4d941b7ae
parent54cb60e2ba5a9feef685ac369d7eb4b51fc847c0 (diff)
downloadGT5-Unofficial-f4ac62247a54c38466fb7544aae63e6d97fb2740.tar.gz
GT5-Unofficial-f4ac62247a54c38466fb7544aae63e6d97fb2740.tar.bz2
GT5-Unofficial-f4ac62247a54c38466fb7544aae63e6d97fb2740.zip
$ Work on GT Chunkloader.
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java9
-rw-r--r--src/Java/gtPlusPlus/api/objects/ChunkManager.java202
-rw-r--r--src/Java/gtPlusPlus/core/common/CommonProxy.java8
-rw-r--r--src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java1
-rw-r--r--src/Java/gtPlusPlus/core/util/array/BlockPos.java6
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java5
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java290
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java25
8 files changed, 532 insertions, 14 deletions
diff --git a/src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java b/src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java
new file mode 100644
index 0000000000..e6aaabbba0
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java
@@ -0,0 +1,9 @@
+package gtPlusPlus.api.interfaces;
+
+import net.minecraft.inventory.IInventory;
+
+public interface IChunkLoader extends IInventory, net.minecraft.world.chunk.storage.IChunkLoader{
+
+ long getTicksRemaining();
+
+}
diff --git a/src/Java/gtPlusPlus/api/objects/ChunkManager.java b/src/Java/gtPlusPlus/api/objects/ChunkManager.java
new file mode 100644
index 0000000000..8805e3bbe4
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/ChunkManager.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) CovertJaguar, 2014 http://railcraft.info
+ *
+ * This code is the property of CovertJaguar
+ * and may only be used with explicit written
+ * permission unless otherwise specified on the
+ * license page at http://railcraft.info/wiki/info:license.
+ */
+package gtPlusPlus.api.objects;
+
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.ListMultimap;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import gtPlusPlus.core.util.array.BlockPos;
+import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.minecraft.world.ChunkCoordIntPair;
+import net.minecraft.entity.Entity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeChunkManager;
+import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
+import net.minecraftforge.common.ForgeChunkManager.OrderedLoadingCallback;
+import net.minecraftforge.common.ForgeChunkManager.Ticket;
+import net.minecraftforge.event.entity.EntityEvent;
+
+/**
+ * @author CovertJaguar <http://www.railcraft.info>
+ */
+public class ChunkManager implements LoadingCallback, OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback {
+
+ private static ChunkManager instance;
+
+ public static Map<BlockPos, GregtechMetaTileEntityChunkLoader> mChunkLoaders = new HashMap<BlockPos, GregtechMetaTileEntityChunkLoader>();
+
+ public static ChunkManager getInstance() {
+ if (instance == null) {
+ instance = new ChunkManager();
+ }
+ return instance;
+ }
+
+ @SubscribeEvent
+ public void entityEnteredChunk(EntityEvent.EnteringChunk event) {
+
+ }
+
+ /**
+ * Returns a Set of ChunkCoordIntPair containing the chunks between the
+ * start and end chunks.
+ * <p/>
+ * One of the pairs of start/end coords need to be equal.
+ * <p/>
+ * Coordinates are in chunk coordinates, not world coordinates.
+ *
+ * @param xChunkA Start Chunk x-Coord
+ * @param zChunkA Start Chunk z-Coord
+ * @param xChunkB End Chunk x-Coord
+ * @param zChunkB End Chunk z-Coord
+ * @param max Max number of chunks to return
+ * @return A set of chunks.
+ */
+ public Set<ChunkCoordIntPair> getChunksBetween(int xChunkA, int zChunkA, int xChunkB, int zChunkB, int max) {
+ Set<ChunkCoordIntPair> chunkList = new HashSet<ChunkCoordIntPair>();
+
+ if (xChunkA != xChunkB && zChunkA != zChunkB) {
+ return chunkList;
+ }
+
+ int xStart = Math.min(xChunkA, xChunkB);
+ int xEnd = Math.max(xChunkA, xChunkB);
+
+ int zStart = Math.min(zChunkA, zChunkB);
+ int zEnd = Math.max(zChunkA, zChunkB);
+
+ for (int xx = xStart; xx <= xEnd; xx++) {
+ for (int zz = zStart; zz <= zEnd; zz++) {
+ chunkList.add(new ChunkCoordIntPair(xx, zz));
+ if (chunkList.size() >= max) {
+ return chunkList;
+ }
+ }
+ }
+ return chunkList;
+ }
+
+ /**
+ * Returns a Set of ChunkCoordIntPair containing the chunks around point [x,
+ * z]. Coordinates are in chunk coordinates, not world coordinates.
+ *
+ * @param xChunk Chunk x-Coord
+ * @param zChunk Chunk z-Coord
+ * @param radius Distance from [x, z] to include, in number of chunks.
+ * @return A set of chunks.
+ */
+ public Set<ChunkCoordIntPair> getChunksAround(int xChunk, int zChunk, int radius) {
+ Set<ChunkCoordIntPair> chunkList = new HashSet<ChunkCoordIntPair>();
+ for (int xx = xChunk - radius; xx <= xChunk + radius; xx++) {
+ for (int zz = zChunk - radius; zz <= zChunk + radius; zz++) {
+ chunkList.add(new ChunkCoordIntPair(xx, zz));
+ }
+ }
+ return chunkList;
+ }
+
+ /**
+ * Returns a Set of ChunkCoordIntPair containing the chunks around point [x,
+ * z]. Coordinates are in world coordinates, not chunk coordinates.
+ *
+ * @param xWorld World x-Coord
+ * @param zWorld World z-Coord
+ * @param radius Distance from [x, z] to include, in blocks.
+ * @return A set of chunks.
+ */
+ public Set<ChunkCoordIntPair> getBufferAround(int xWorld, int zWorld, int radius) {
+ int minX = (xWorld - radius) >> 4;
+ int maxX = (xWorld + radius) >> 4;
+ int minZ = (zWorld - radius) >> 4;
+ int maxZ = (zWorld + radius) >> 4;
+
+ Set<ChunkCoordIntPair> chunkList = new HashSet<ChunkCoordIntPair>();
+ for (int xx = minX; xx <= maxX; xx++) {
+ for (int zz = minZ; zz <= maxZ; zz++) {
+ chunkList.add(new ChunkCoordIntPair(xx, zz));
+ }
+ }
+ return chunkList;
+ }
+
+ private void printAnchor(String type, int x, int y, int z) {
+ Logger.INFO("[Chunk Loader] "+type+" @ [x: "+x+"][y: "+y+"][z: "+z+"]");
+ }
+
+ @Override
+ public void ticketsLoaded(List<Ticket> tickets, World world) {
+ // System.out.println("Callback 2");
+ for (Ticket ticket : tickets) {
+ if (ticket.isPlayerTicket())
+ continue;
+ Entity entity = ticket.getEntity();
+ if (entity == null) {
+ int x = ticket.getModData().getInteger("xCoord");
+ int y = ticket.getModData().getInteger("yCoord");
+ int z = ticket.getModData().getInteger("zCoord");
+
+ if (y >= 0) {
+ BlockPos tile = new BlockPos(x, y, z);
+
+ if (!mChunkLoaders.isEmpty()) {
+ GregtechMetaTileEntityChunkLoader f = mChunkLoaders.get(tile);
+ f.forceChunkLoading(ticket);
+ printAnchor("Force Chunk Loading. Chunk Loader has ID of "+f.getLoaderID()+". ",x,y,z);
+ }
+
+ /*if (tile instanceof IGregTechTileEntity) {
+ final IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tile;
+ IGregTechTileEntity anchor = (IGregTechTileEntity) tile;
+ GregtechMetaTileEntityChunkLoader jun = (GregtechMetaTileEntityChunkLoader) anchor;
+ jun.forceChunkLoading(ticket);
+ //printAnchor(anchor.getName(), x, y, z);
+ }*/
+ }
+ }
+ }
+ }
+
+ @Override
+ public List<Ticket> ticketsLoaded(List<Ticket> tickets, World world, int maxTicketCount) {
+ // System.out.println("Callback 1");
+ Set<Ticket> adminTickets = new HashSet<Ticket>();
+ Set<Ticket> worldTickets = new HashSet<Ticket>();
+ Set<Ticket> cartTickets = new HashSet<Ticket>();
+ for (Ticket ticket : tickets) {
+ Entity entity = ticket.getEntity();
+ if (entity == null) {
+ int x = ticket.getModData().getInteger("xCoord");
+ int y = ticket.getModData().getInteger("yCoord");
+ int z = ticket.getModData().getInteger("zCoord");
+ if (y >= 0) {
+ worldTickets.add(ticket);
+ }
+ }
+ }
+
+ List<Ticket> claimedTickets = new LinkedList<Ticket>();
+ claimedTickets.addAll(cartTickets);
+ claimedTickets.addAll(adminTickets);
+ claimedTickets.addAll(worldTickets);
+ return claimedTickets;
+ }
+
+ @Override
+ public ListMultimap<String, Ticket> playerTicketsLoaded(ListMultimap<String, Ticket> tickets, World world) {
+ return LinkedListMultimap.create();
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java
index 6acdf9b0c3..d5f4d95aef 100644
--- a/src/Java/gtPlusPlus/core/common/CommonProxy.java
+++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java
@@ -4,6 +4,8 @@ import static gtPlusPlus.core.lib.CORE.DEBUG;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.registry.GameRegistry;
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.api.objects.ChunkManager;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.creative.AddToCreativeTab;
@@ -25,6 +27,8 @@ import gtPlusPlus.core.util.player.PlayerCache;
import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO;
import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy;
import net.minecraft.entity.Entity;
+import net.minecraftforge.common.ForgeChunkManager;
+import net.minecraftforge.common.MinecraftForge;
public class CommonProxy {
@@ -101,6 +105,10 @@ public class CommonProxy {
Utils.registerEvent(new BlockEventHandler());
//Handles Custom tooltips for EIO.
Utils.registerEvent(new HandlerTooltip_EIO());
+
+ //Register Chunkloader
+ ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance());
+ Utils.registerEvent(ChunkManager.getInstance());
if (ConfigSwitches.disableZombieReinforcement){
//Make Zombie reinforcements fuck off.
diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
index 953d32f138..42d8021899 100644
--- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
+++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
@@ -99,6 +99,7 @@ public class COMPAT_HANDLER {
GregtechTeslaTower.run();
GregtechSuperTanks.run();
GregtechIndustrialFishPond.run();
+ GregtechTieredChunkloaders.run();
//New Horizons Content
NewHorizonsAccelerator.run();
diff --git a/src/Java/gtPlusPlus/core/util/array/BlockPos.java b/src/Java/gtPlusPlus/core/util/array/BlockPos.java
index 32f74ff514..b4f6f65086 100644
--- a/src/Java/gtPlusPlus/core/util/array/BlockPos.java
+++ b/src/Java/gtPlusPlus/core/util/array/BlockPos.java
@@ -5,11 +5,17 @@ public class BlockPos {
public final int xPos;
public final int yPos;
public final int zPos;
+ public final int dim;
public BlockPos(int x, int y, int z){
+ this(x, y, z, 0);
+ }
+
+ public BlockPos(int x, int y, int z, int dim){
this.xPos = x;
this.yPos = y;
this.zPos = z;
+ this.dim = dim;
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
index da2b24e38f..bcf4777acd 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
@@ -284,7 +284,10 @@ public enum GregtechItemList implements GregtechItemContainer {
Super_Chest_LV, Super_Chest_MV, Super_Chest_HV, Super_Chest_EV, Super_Chest_IV,
//Fish Pond
- Casing_FishPond, Industrial_FishingPond,
+ Casing_FishPond, Industrial_FishingPond,
+
+ //Chunkloader
+ GT_Chunkloader_HV,
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
index b68c49c48c..d8304aaa77 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
@@ -1,6 +1,14 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic;
import static gregtech.api.enums.GT_Values.V;
+import static gtPlusPlus.api.objects.ChunkManager.mChunkLoaders;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import com.google.common.collect.MapMaker;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
@@ -9,15 +17,29 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_SpawnEventHandler;
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.api.interfaces.IChunkLoader;
+import gtPlusPlus.api.objects.ChunkManager;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.util.array.BlockPos;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.ChunkCoordIntPair;
+import net.minecraft.world.MinecraftException;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraftforge.common.ForgeChunkManager;
+import net.minecraftforge.common.ForgeChunkManager.Ticket;
+import net.minecraftforge.common.ForgeChunkManager.Type;
-public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredMachineBlock {
+public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredMachineBlock implements IChunkLoader {
public int mRange = 16;
+ private long mTicksLeft = 0;
+ private UUID mUUID = UUID.randomUUID();
public GregtechMetaTileEntityChunkLoader(final int aID, final String aName, final String aNameRegional, final int aTier) {
- super(aID, aName, aNameRegional, aTier, 0, "Reprells nasty Creatures. Range: " + (4 + (12 * aTier)) + " unpowered / " + (16 + (48 * aTier)) + " powered");
+ super(aID, aName, aNameRegional, aTier, 0, "Loads chunks: " + (16 + (48 * aTier)) + " powered");
}
public GregtechMetaTileEntityChunkLoader(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) {
@@ -34,31 +56,69 @@ public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredM
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], (aSide != 1) ? null : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER)};
}
+ private int xCoord, yCoord, zCoord;
+ private int prevX, prevY, prevZ;
@Override
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
+ if (!aBaseMetaTileEntity.isServerSide()) {
+ return;
+ }
+
if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()) {
- final int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), aBaseMetaTileEntity.getWorld().provider.dimensionId};
- if (((aTimer % 600) == 0) && !GT_SpawnEventHandler.mobReps.contains(tCoords)) {
- GT_SpawnEventHandler.mobReps.add(tCoords);
+
+
+
+ if (this.mTicksLeft > 0) {
+ this.mTicksLeft--;
}
- if (aBaseMetaTileEntity.isUniversalEnergyStored(this.getMinimumStoredEU()) && aBaseMetaTileEntity.decreaseStoredEnergyUnits(1 << (this.mTier * 2), false)) {
- this.mRange = 16 + (48 * this.mTier);
- } else {
- this.mRange = 4 + (12 * this.mTier);
+ else if (this.mTicksLeft < 0) {
+ this.mTicksLeft = 0;
+ }
+ if (mTicksLeft < 10) {
+ long h = this.getEUVar();
+ if (h > 0) {
+ if (h >(this.maxEUInput()+this.getMinimumStoredEU())) {
+ this.setEUVar((this.getEUVar()-this.maxEUInput()));
+ this.mTicksLeft += 10;
+ }
+ }
+ }
+
+ xCoord = aBaseMetaTileEntity.getXCoord();
+ yCoord = aBaseMetaTileEntity.getYCoord();
+ zCoord = aBaseMetaTileEntity.getZCoord();
+
+ if (xCoord != prevX || yCoord != prevY || zCoord != prevZ) {
+ releaseTicket();
+ prevX = xCoord;
+ prevY = yCoord;
+ prevZ = zCoord;
}
+
+ if (hasActiveTicket() && (getTicket().world != aBaseMetaTileEntity.getWorld() || refreshTicket || !aBaseMetaTileEntity.isAllowedToWork())) {
+ releaseTicket();
+ }
+
+ if (!hasActiveTicket() && this.mTicksLeft > 0) {
+ requestTicket();
+ }
+
+
}
+
+
+
+
}
@Override
public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
- final int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), aBaseMetaTileEntity.getWorld().provider.dimensionId};
- GT_SpawnEventHandler.mobReps.add(tCoords);
+ registerLoader();
}
@Override
public void onRemoval() {
- final int[] tCoords = new int[]{this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId};
- GT_SpawnEventHandler.mobReps.remove(tCoords);
+ ChunkManager.mChunkLoaders.remove(new BlockPos(this.xCoord, this.yCoord, this.zCoord, this.getBaseMetaTileEntity().getWorld().provider.dimensionId));
}
@Override
@@ -123,9 +183,213 @@ public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredM
@Override
public void saveNBTData(final NBTTagCompound aNBT) {
+ aNBT.setLong("mTicksLeft", getTicksRemaining());
}
@Override
public void loadNBTData(final NBTTagCompound aNBT) {
+ this.mTicksLeft = aNBT.getLong("mTicksLeft");
+ }
+
+
+
+
+
+ /**
+ * Chunk Handling
+ */
+ private static final Map<UUID, Ticket> tickets = new MapMaker().makeMap();
+ private static final byte ANCHOR_RADIUS = 1;
+ private boolean hasTicket;
+ private boolean refreshTicket;
+ private Set<ChunkCoordIntPair> chunks;
+ private short mChunkLoaderMapID = -1;
+
+ public void registerLoader() {
+ short mSize = (short) ChunkManager.mChunkLoaders.size();
+ this.mChunkLoaderMapID = mSize;
+ if (!mChunkLoaders.containsValue(this)) {
+ mChunkLoaders.put(new BlockPos(this.xCoord, this.yCoord, this.zCoord, this.getBaseMetaTileEntity().getWorld().provider.dimensionId),this);
+ }
+ }
+
+ public short getLoaderID() {
+ return this.mChunkLoaderMapID;
+ }
+
+ public void onBlockRemoval() {
+ releaseTicket();
+ }
+
+ public void invalidate() {
+ refreshTicket = true;
+ }
+
+ public void validate() {
+ refreshTicket = true;
+ }
+
+ protected void releaseTicket() {
+ refreshTicket = false;
+ setTicket(null);
+ }
+
+ protected void requestTicket() {
+ Ticket chunkTicket = getTicketFromForge();
+ if (chunkTicket != null) {
+ setTicketData(chunkTicket);
+ forceChunkLoading(chunkTicket);
+ }
+ }
+
+ protected Ticket getTicketFromForge() {
+ return ForgeChunkManager.requestTicket(GTplusplus.instance, this.getBaseMetaTileEntity().getWorld(), Type.NORMAL);
+ }
+
+ protected void setTicketData(Ticket chunkTicket) {
+ chunkTicket.getModData().setInteger("xCoord", this.getBaseMetaTileEntity().getXCoord());
+ chunkTicket.getModData().setInteger("yCoord", this.getBaseMetaTileEntity().getYCoord());
+ chunkTicket.getModData().setInteger("zCoord", this.getBaseMetaTileEntity().getZCoord());
+ //chunkTicket.getModData().setString("type", getMachineType().getTag());
+ }
+
+ public boolean hasActiveTicket() {
+ return getTicket() != null;
+ }
+
+ public Ticket getTicket() {
+ //Logger.INFO("[Chunk Loader] "+"Getting Ticking. ["+this.getLoaderID()+"] @ [x: "+this.xCoord+"][y: "+this.yCoord+"][z: "+this.zCoord+"]");
+ return tickets.get(this.mUUID);
+ }
+
+ public void setTicket(Ticket t) {
+ boolean changed = false;
+ Ticket ticket = getTicket();
+ if (ticket != t) {
+ if (ticket != null) {
+ if (ticket.world == this.getBaseMetaTileEntity().getWorld()) {
+ for (ChunkCoordIntPair chunk : ticket.getChunkList()) {
+ if (ForgeChunkManager.getPersistentChunksFor(this.getBaseMetaTileEntity().getWorld()).keys().contains(chunk))
+ ForgeChunkManager.unforceChunk(ticket, chunk);
+ }
+ ForgeChunkManager.releaseTicket(ticket);
+ }
+ Logger.INFO("[Chunk Loader] "+"Removing Ticking. ["+this.getLoaderID()+"] @ [x: "+this.xCoord+"][y: "+this.yCoord+"][z: "+this.zCoord+"]");
+ tickets.remove(mUUID);
+ }
+ changed = true;
+ }
+ hasTicket = t != null;
+ if (hasTicket) {
+ Logger.INFO("[Chunk Loader] "+"Putting Ticking. ["+this.getLoaderID()+"] @ [x: "+this.xCoord+"][y: "+this.yCoord+"][z: "+this.zCoord+"]");
+ tickets.put(mUUID, t);
+ }
+ //if (changed)
+ //sendUpdateToClient();
+ }
+
+ public void forceChunkLoading(Ticket ticket) {
+ setTicket(ticket);
+
+ setupChunks();
+
+ if (chunks != null)
+ for (ChunkCoordIntPair chunk : chunks) {
+ ForgeChunkManager.forceChunk(ticket, chunk);
+ }
+ }
+
+ public void setupChunks() {
+ if (!hasTicket)
+ chunks = null;
+ else
+ chunks = ChunkManager.getInstance().getChunksAround(this.getBaseMetaTileEntity().getXCoord() >> 4, this.getBaseMetaTileEntity().getZCoord() >> 4, ANCHOR_RADIUS);
+ }
+
+
+ @Override
+ public Chunk loadChunk(World p_75815_1_, int p_75815_2_, int p_75815_3_) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void saveChunk(World p_75816_1_, Chunk p_75816_2_) throws MinecraftException, IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void saveExtraChunkData(World p_75819_1_, Chunk p_75819_2_) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void chunkTick() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void saveExtraData() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public long getTicksRemaining() {
+ return this.mTicksLeft;
+ }
+
+ @Override
+ public String[] getDescription() {
+ // TODO Auto-generated method stub
+ return super.getDescription();
+ }
+
+ @Override
+ public void onExplosion() {
+ this.releaseTicket();
+ super.onExplosion();
}
+
+ @Override
+ public void inValidate() {
+ invalidate();
+ super.inValidate();
+ }
+
+ @Override
+ public void onMachineBlockUpdate() {
+ validate();
+ super.onMachineBlockUpdate();
+ }
+
+ @Override
+ public void markDirty() {
+ validate();
+ super.markDirty();
+ }
+
+ @Override
+ public void doExplosion(long aExplosionPower) {
+ this.releaseTicket();
+ super.doExplosion(aExplosionPower);
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[] {
+ this.getLocalName(),
+ "Ticks Left: "+this.mTicksLeft,
+ "mRange: "+this.mRange,
+ "chunks: "+this.chunks.size()};
+ }
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java
new file mode 100644
index 0000000000..6e5274536f
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java
@@ -0,0 +1,25 @@
+package gtPlusPlus.xmod.gregtech.registration.gregtech;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
+import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader;
+import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank;
+
+public class GregtechTieredChunkloaders {
+ public static void run() {
+ if (LoadedMods.Gregtech) {
+ Logger.INFO("Gregtech5u Content | Registering Portable Fluid Tanks.");
+ run1();
+ }
+
+ }
+
+ private static void run1() {
+ int ID = 945;
+ GregtechItemList.GT_Chunkloader_HV
+ .set(new GregtechMetaTileEntityChunkLoader(ID++, "chunkloader.tier.00", "Chunkloader MK I", 4)
+ .getStackForm(1L));
+ }
+}