Some network tweaks
This commit is contained in:
parent
1cef920e62
commit
d811141896
4 changed files with 13 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package resonantinduction.core;
|
package resonantinduction.core;
|
||||||
|
|
||||||
import resonantinduction.core.grid.ThreadedGridTicker;
|
import resonantinduction.core.grid.UpdateTicker;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.prefab.ProxyBase;
|
import calclavia.lib.prefab.ProxyBase;
|
||||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraftforge.fluids.BlockFluidFinite;
|
||||||
import org.modstats.ModstatInfo;
|
import org.modstats.ModstatInfo;
|
||||||
import org.modstats.Modstats;
|
import org.modstats.Modstats;
|
||||||
|
|
||||||
import resonantinduction.core.grid.ThreadedGridTicker;
|
import resonantinduction.core.grid.UpdateTicker;
|
||||||
import resonantinduction.core.handler.TextureHookHandler;
|
import resonantinduction.core.handler.TextureHookHandler;
|
||||||
import resonantinduction.core.prefab.part.PacketMultiPart;
|
import resonantinduction.core.prefab.part.PacketMultiPart;
|
||||||
import resonantinduction.core.resource.BlockDust;
|
import resonantinduction.core.resource.BlockDust;
|
||||||
|
@ -146,14 +146,14 @@ public class ResonantInduction
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void serverStarting(FMLServerStartingEvent event)
|
public void serverStarting(FMLServerStartingEvent event)
|
||||||
{
|
{
|
||||||
if (!ThreadedGridTicker.INSTANCE.isAlive())
|
if (!UpdateTicker.INSTANCE.isAlive())
|
||||||
ThreadedGridTicker.INSTANCE.start();
|
UpdateTicker.INSTANCE.start();
|
||||||
ThreadedGridTicker.INSTANCE.pause = false;
|
UpdateTicker.INSTANCE.pause = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerStopping(FMLServerStoppingEvent evt)
|
public void onServerStopping(FMLServerStoppingEvent evt)
|
||||||
{
|
{
|
||||||
ThreadedGridTicker.INSTANCE.pause = true;
|
UpdateTicker.INSTANCE.pause = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class TickingGrid<N extends Node> extends NodeGrid<N> implements IUpdate
|
||||||
{
|
{
|
||||||
super(type);
|
super(type);
|
||||||
add(node);
|
add(node);
|
||||||
ThreadedGridTicker.addNetwork(this);
|
UpdateTicker.addNetwork(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,7 @@ public class TickingGrid<N extends Node> extends NodeGrid<N> implements IUpdate
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
synchronized (nodes)
|
//synchronized (nodes)
|
||||||
{
|
{
|
||||||
for (Node node : nodes)
|
for (Node node : nodes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,9 +15,9 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
public class ThreadedGridTicker extends Thread
|
public class UpdateTicker extends Thread
|
||||||
{
|
{
|
||||||
public static final ThreadedGridTicker INSTANCE = new ThreadedGridTicker();
|
public static final UpdateTicker INSTANCE = new UpdateTicker();
|
||||||
|
|
||||||
/** For updaters to be ticked. */
|
/** For updaters to be ticked. */
|
||||||
private final Set<IUpdate> updaters = Collections.newSetFromMap(new WeakHashMap<IUpdate, Boolean>());
|
private final Set<IUpdate> updaters = Collections.newSetFromMap(new WeakHashMap<IUpdate, Boolean>());
|
||||||
|
@ -27,7 +27,7 @@ public class ThreadedGridTicker extends Thread
|
||||||
|
|
||||||
public boolean pause = false;
|
public boolean pause = false;
|
||||||
|
|
||||||
public ThreadedGridTicker()
|
public UpdateTicker()
|
||||||
{
|
{
|
||||||
setName("Universal Electricity");
|
setName("Universal Electricity");
|
||||||
setPriority(MIN_PRIORITY);
|
setPriority(MIN_PRIORITY);
|
||||||
|
@ -105,6 +105,8 @@ public class ThreadedGridTicker extends Thread
|
||||||
MinecraftForge.EVENT_BUS.post(queuedEvents.poll());
|
MinecraftForge.EVENT_BUS.post(queuedEvents.poll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(50L);
|
Thread.sleep(50L);
|
Loading…
Add table
Reference in a new issue