aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/core/chunkloading
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gtPlusPlus/core/chunkloading')
-rw-r--r--src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java147
1 files changed, 74 insertions, 73 deletions
diff --git a/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java b/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java
index b403646a2a..3322f3924c 100644
--- a/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java
+++ b/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java
@@ -1,11 +1,11 @@
package gtPlusPlus.core.chunkloading;
import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.ListMultimap;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gtPlusPlus.GTplusplus;
-
-import com.google.common.collect.ListMultimap;
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader;
+import java.util.*;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkCoordIntPair;
@@ -14,91 +14,92 @@ import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.MinecraftForge;
-import java.util.*;
-
/**
- *
+ *
* This class handles re-initializing chunks after a server restart
* Credits to Repo-Alt for the original implementation.
* @author Repo-Alt, Alkalus
*
*/
-public class GTPP_ChunkManager implements ForgeChunkManager.LoadingCallback, ForgeChunkManager.OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback {
- private static GTPP_ChunkManager instance;
+public class GTPP_ChunkManager
+ implements ForgeChunkManager.LoadingCallback,
+ ForgeChunkManager.OrderedLoadingCallback,
+ ForgeChunkManager.PlayerOrderedLoadingCallback {
+ private static GTPP_ChunkManager instance;
- public static boolean enableChunkloaders = true;
- public static boolean alwaysReloadChunkloaders = false;
- public static boolean debugChunkloaders = false;
+ public static boolean enableChunkloaders = true;
+ public static boolean alwaysReloadChunkloaders = false;
+ public static boolean debugChunkloaders = false;
- public static GTPP_ChunkManager getInstance() {
- if (instance == null) {
- instance = new GTPP_ChunkManager();
- }
- return instance;
- }
+ public static GTPP_ChunkManager getInstance() {
+ if (instance == null) {
+ instance = new GTPP_ChunkManager();
+ }
+ return instance;
+ }
- public static void init() {
- if (enableChunkloaders) {
- ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, getInstance());
- MinecraftForge.EVENT_BUS.register(getInstance());
- }
- }
+ public static void init() {
+ if (enableChunkloaders) {
+ ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, getInstance());
+ MinecraftForge.EVENT_BUS.register(getInstance());
+ }
+ }
- @Override
- public void ticketsLoaded(List<Ticket> tickets, World world) {
- 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");
+ @Override
+ public void ticketsLoaded(List<Ticket> tickets, World world) {
+ 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) {
- TileEntity tile = world.getTileEntity(x, y, z);
- if (((IGregTechTileEntity)tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) {
- ((GregtechMetaTileEntityChunkLoader)((IGregTechTileEntity)tile).getMetaTileEntity()).forceChunkLoading(ticket);
- }
- }
- }
- }
- }
+ if (y >= 0) {
+ TileEntity tile = world.getTileEntity(x, y, z);
+ if (((IGregTechTileEntity) tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) {
+ ((GregtechMetaTileEntityChunkLoader) ((IGregTechTileEntity) tile).getMetaTileEntity())
+ .forceChunkLoading(ticket);
+ }
+ }
+ }
+ }
+ }
- @Override
- public List<Ticket> ticketsLoaded(List<Ticket> tickets, World world, int maxTicketCount) {
- Set<Ticket> validTickets = new HashSet<>();
- 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");
+ @Override
+ public List<Ticket> ticketsLoaded(List<Ticket> tickets, World world, int maxTicketCount) {
+ Set<Ticket> validTickets = new HashSet<>();
+ 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) {
- TileEntity tile = world.getTileEntity(x, y, z);
- if (((IGregTechTileEntity)tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) {
- validTickets.add(ticket);
- }
- }
- }
- }
+ if (y >= 0) {
+ TileEntity tile = world.getTileEntity(x, y, z);
+ if (((IGregTechTileEntity) tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) {
+ validTickets.add(ticket);
+ }
+ }
+ }
+ }
- return new LinkedList<>(validTickets);
- }
+ return new LinkedList<>(validTickets);
+ }
- @Override
- public ListMultimap<String, Ticket> playerTicketsLoaded(ListMultimap<String, Ticket> tickets, World world) {
- return LinkedListMultimap.create();
- }
+ @Override
+ public ListMultimap<String, Ticket> playerTicketsLoaded(ListMultimap<String, Ticket> tickets, World world) {
+ return LinkedListMultimap.create();
+ }
- public static Set<ChunkCoordIntPair> getChunksAround(int xChunk, int zChunk, int radius) {
- Set<ChunkCoordIntPair> chunkList = new HashSet<>();
- 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;
- }
+ public static Set<ChunkCoordIntPair> getChunksAround(int xChunk, int zChunk, int radius) {
+ Set<ChunkCoordIntPair> chunkList = new HashSet<>();
+ 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;
+ }
}