mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Even more modularization
This commit is contained in:
1 parent
b2f20185e4
commit
f64ea42e43
14 files changed
+176
-340
No files matched your search
@@ -4,6 +4,10 @@ import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
@@ -12,6 +16,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
public class TransmitterNetworkRegistry implements ITickHandler
|
||||
{
|
||||
private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry();
|
||||
private static boolean loaderRegistered = false;
|
||||
|
||||
private HashSet<ITransmitterNetwork> networks = new HashSet<ITransmitterNetwork>();
|
||||
|
||||
public TransmitterNetworkRegistry()
|
||||
@@ -19,6 +25,16 @@ public class TransmitterNetworkRegistry implements ITickHandler
|
||||
TickRegistry.registerTickHandler(this, Side.SERVER);
|
||||
}
|
||||
|
||||
public static void initiate()
|
||||
{
|
||||
if(!loaderRegistered)
|
||||
{
|
||||
loaderRegistered = true;
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static TransmitterNetworkRegistry getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
@@ -85,4 +101,27 @@ public class TransmitterNetworkRegistry implements ITickHandler
|
||||
{
|
||||
return "Network Registry:\n" + networks;
|
||||
}
|
||||
|
||||
public static class NetworkLoader
|
||||
{
|
||||
@ForgeSubscribe
|
||||
public void onChunkLoad(ChunkEvent.Load event)
|
||||
{
|
||||
if(event.getChunk() != null)
|
||||
{
|
||||
for(Object obj : event.getChunk().chunkTileEntityMap.values())
|
||||
{
|
||||
if(obj instanceof TileEntity)
|
||||
{
|
||||
TileEntity tileEntity = (TileEntity)obj;
|
||||
|
||||
if(tileEntity instanceof ITransmitter)
|
||||
{
|
||||
((ITransmitter)tileEntity).refreshNetwork();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user