mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-18 19:39:10 +00:00
Client can request a chunk status update (Packet0x02) OverlayLoadedchunk is now a singleton and will send a request packet when activated. Player status is saved in the server proxy. ChunkData is a "static" class to gather chunk related data (loaded chunks for now).
51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package mcp.mobius.opis.server;
|
|
|
|
import java.util.EnumSet;
|
|
import java.util.logging.Level;
|
|
|
|
import mcp.mobius.opis.modOpis;
|
|
import mcp.mobius.opis.constants.OverlayStatus;
|
|
import mcp.mobius.opis.data.ChunkData;
|
|
import mcp.mobius.opis.network.Packet0x01ChunkStatus;
|
|
import cpw.mods.fml.common.ITickHandler;
|
|
import cpw.mods.fml.common.TickType;
|
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
import cpw.mods.fml.common.network.Player;
|
|
|
|
public class OpisServerTickHandler implements ITickHandler {
|
|
|
|
int tickCounter = 0;
|
|
|
|
@Override
|
|
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
|
}
|
|
|
|
@Override
|
|
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
|
if(type.contains(TickType.WORLD)){
|
|
tickCounter += 1;
|
|
if (tickCounter % 100 == 0){
|
|
updatePlayers();
|
|
tickCounter = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public EnumSet<TickType> ticks() {
|
|
return EnumSet.of(TickType.WORLD);
|
|
}
|
|
|
|
@Override
|
|
public String getLabel() {
|
|
return "opis.server.tickhandler";
|
|
}
|
|
|
|
private void updatePlayers(){
|
|
for (Player player : modOpis.proxy.playerOverlayStatus.keySet())
|
|
if (modOpis.proxy.playerOverlayStatus.get(player) == OverlayStatus.CHUNKSTATUS)
|
|
PacketDispatcher.sendPacketToPlayer( Packet0x01ChunkStatus.create(ChunkData.getLoadedChunks(modOpis.proxy.playerDimension.get(player))), player);
|
|
}
|
|
|
|
}
|