Made thread pause during main menu
This commit is contained in:
parent
a7c0e8c502
commit
1cef920e62
4 changed files with 59 additions and 41 deletions
|
@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.grid.Grid;
|
||||
import resonantinduction.core.grid.TickingGrid;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
@ -68,6 +69,7 @@ public class MechanicalNode extends EnergyNode
|
|||
{
|
||||
prevAngularVelocity = angularVelocity;
|
||||
|
||||
if (!ResonantInduction.proxy.isPaused())
|
||||
angle += angularVelocity * deltaTime;
|
||||
|
||||
if (angle % (Math.PI * 2) != angle)
|
||||
|
|
|
@ -14,12 +14,6 @@ import calclavia.lib.prefab.ProxyBase;
|
|||
*/
|
||||
public class CommonProxy extends ProxyBase
|
||||
{
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
ThreadedGridTicker.INSTANCE.start();
|
||||
}
|
||||
|
||||
public boolean isPaused()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraftforge.fluids.BlockFluidFinite;
|
|||
import org.modstats.ModstatInfo;
|
||||
import org.modstats.Modstats;
|
||||
|
||||
import resonantinduction.core.grid.ThreadedGridTicker;
|
||||
import resonantinduction.core.handler.TextureHookHandler;
|
||||
import resonantinduction.core.prefab.part.PacketMultiPart;
|
||||
import resonantinduction.core.resource.BlockDust;
|
||||
|
@ -35,6 +36,8 @@ import cpw.mods.fml.common.SidedProxy;
|
|||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
@ -139,4 +142,18 @@ public class ResonantInduction
|
|||
ResourceGenerator.generateOreResources();
|
||||
proxy.postInit();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
if (!ThreadedGridTicker.INSTANCE.isAlive())
|
||||
ThreadedGridTicker.INSTANCE.start();
|
||||
ThreadedGridTicker.INSTANCE.pause = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerStopping(FMLServerStoppingEvent evt)
|
||||
{
|
||||
ThreadedGridTicker.INSTANCE.pause = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@ public class ThreadedGridTicker extends Thread
|
|||
/** For queuing Forge events to be invoked the next tick. */
|
||||
private final Queue<Event> queuedEvents = new ConcurrentLinkedQueue<Event>();
|
||||
|
||||
private ThreadedGridTicker()
|
||||
public boolean pause = false;
|
||||
|
||||
public ThreadedGridTicker()
|
||||
{
|
||||
setName("Universal Electricity");
|
||||
setPriority(MIN_PRIORITY);
|
||||
|
@ -55,6 +57,8 @@ public class ThreadedGridTicker extends Thread
|
|||
long last = System.currentTimeMillis();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (!pause)
|
||||
{
|
||||
long current = System.currentTimeMillis();
|
||||
long delta = current - last;
|
||||
|
@ -101,6 +105,7 @@ public class ThreadedGridTicker extends Thread
|
|||
MinecraftForge.EVENT_BUS.post(queuedEvents.poll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Thread.sleep(50L);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue