mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-23 04:32:31 +00:00
Better Rates
This commit is contained in:
parent
bdbc94e54a
commit
8c4a74179d
@ -60,6 +60,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
private final ChronoLatch ecl;
|
private final ChronoLatch ecl;
|
||||||
private int actuallySpawned = 0;
|
private int actuallySpawned = 0;
|
||||||
private int cooldown = 0;
|
private int cooldown = 0;
|
||||||
|
private List<Entity> precount = new KList<>();
|
||||||
|
|
||||||
public IrisWorldManager() {
|
public IrisWorldManager() {
|
||||||
super(null);
|
super(null);
|
||||||
@ -71,13 +72,30 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
public IrisWorldManager(Engine engine) {
|
public IrisWorldManager(Engine engine) {
|
||||||
super(engine);
|
super(engine);
|
||||||
cl = new ChronoLatch(1000);
|
cl = new ChronoLatch(3000);
|
||||||
ecl = new ChronoLatch(250);
|
ecl = new ChronoLatch(250);
|
||||||
chunkCooldowns = new KMap<>();
|
chunkCooldowns = new KMap<>();
|
||||||
energy = 25;
|
energy = 25;
|
||||||
looper = new Looper() {
|
looper = new Looper() {
|
||||||
@Override
|
@Override
|
||||||
protected long loop() {
|
protected long loop() {
|
||||||
|
if(precount != null)
|
||||||
|
{
|
||||||
|
entityCount = 0;
|
||||||
|
for(Entity i : precount)
|
||||||
|
{
|
||||||
|
if(i instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
if(!i.isDead())
|
||||||
|
{
|
||||||
|
entityCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
precount = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(energy < 650)
|
if(energy < 650)
|
||||||
{
|
{
|
||||||
if(ecl.flip())
|
if(ecl.flip())
|
||||||
@ -120,7 +138,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cl.flip()) {
|
if (cl.flip()) {
|
||||||
J.s(() -> entityCount = getEngine().getWorld().realWorld().getEntities().size());
|
J.s(() -> precount = getEngine().getWorld().realWorld().getEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxGroups = 1;
|
int maxGroups = 1;
|
||||||
@ -346,6 +364,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getEntitySaturation() {
|
public double getEntitySaturation() {
|
||||||
return (double) entityCount / (getEngine().getWorld().realWorld().getLoadedChunks().length + 1) * 1.665;
|
if(!getEngine().getWorld().hasRealWorld())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (double) entityCount / (getEngine().getWorld().realWorld().getLoadedChunks().length + 1) * 1.28;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class IrisEntity extends IrisRegistrant {
|
|||||||
private boolean pickupItems = false;
|
private boolean pickupItems = false;
|
||||||
|
|
||||||
@Desc("Should this entity be removed when far away")
|
@Desc("Should this entity be removed when far away")
|
||||||
private boolean removable = true;
|
private boolean removable = false;
|
||||||
|
|
||||||
@Desc("Entity helmet equipment")
|
@Desc("Entity helmet equipment")
|
||||||
private IrisLoot helmet = null;
|
private IrisLoot helmet = null;
|
||||||
@ -266,11 +266,25 @@ public class IrisEntity extends IrisRegistrant {
|
|||||||
// Someone called spawn (worldedit maybe?) on a non server thread
|
// Someone called spawn (worldedit maybe?) on a non server thread
|
||||||
// Due to the structure of iris, we will call it sync and busy wait until it's done.
|
// Due to the structure of iris, we will call it sync and busy wait until it's done.
|
||||||
AtomicReference<Entity> ae = new AtomicReference<>();
|
AtomicReference<Entity> ae = new AtomicReference<>();
|
||||||
J.s(() -> ae.set(doSpawn(at)));
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
J.s(() -> ae.set(doSpawn(at)));
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
|
|
||||||
while (ae.get() == null) {
|
while (ae.get() == null) {
|
||||||
J.sleep(3);
|
J.sleep(25);
|
||||||
|
|
||||||
|
if(p.getMilliseconds() > 500)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae.get();
|
return ae.get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user