mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-22 20:25:56 +00:00
Fixes
This commit is contained in:
parent
af22751210
commit
8a7bc3c17d
55
src/main/java/com/volmit/iris/command/CommandIrisTC.java
Normal file
55
src/main/java/com/volmit/iris/command/CommandIrisTC.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisTC extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisTC()
|
||||||
|
{
|
||||||
|
super("ctc");
|
||||||
|
setDescription("Change generator thread count");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setCategory("World");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(sender.isPlayer())
|
||||||
|
{
|
||||||
|
Player p = sender.player();
|
||||||
|
World world = p.getWorld();
|
||||||
|
|
||||||
|
if(!(world.getGenerator() instanceof IrisChunkGenerator))
|
||||||
|
{
|
||||||
|
sender.sendMessage("You must be in an iris world.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisChunkGenerator g = (IrisChunkGenerator) world.getGenerator();
|
||||||
|
int m = Math.min(Math.max(Integer.valueOf(args[0]), 2), 256);
|
||||||
|
g.changeThreadCount(m);
|
||||||
|
sender.sendMessage("Thread count changed to " + m);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Players only.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "[thread-count]";
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,9 @@ public class CommandIrisWorld extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisHotload hotload;
|
private CommandIrisHotload hotload;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisTC tc;
|
||||||
|
|
||||||
public CommandIrisWorld()
|
public CommandIrisWorld()
|
||||||
{
|
{
|
||||||
super("world", "wrld", "w");
|
super("world", "wrld", "w");
|
||||||
|
@ -21,7 +21,6 @@ import com.volmit.iris.object.IrisRegion;
|
|||||||
import com.volmit.iris.util.BiomeResult;
|
import com.volmit.iris.util.BiomeResult;
|
||||||
import com.volmit.iris.util.Form;
|
import com.volmit.iris.util.Form;
|
||||||
import com.volmit.iris.util.Function2;
|
import com.volmit.iris.util.Function2;
|
||||||
import com.volmit.iris.util.IrisLock;
|
|
||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisContext
|
public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisContext
|
||||||
{
|
{
|
||||||
private Method initLighting;
|
private Method initLighting;
|
||||||
private IrisLock lock;
|
|
||||||
private IrisBiome hb = null;
|
private IrisBiome hb = null;
|
||||||
private IrisRegion hr = null;
|
private IrisRegion hr = null;
|
||||||
private KMap<Player, IrisBiome> b = new KMap<>();
|
private KMap<Player, IrisBiome> b = new KMap<>();
|
||||||
@ -41,19 +39,16 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
|||||||
public IrisChunkGenerator(String dimensionName, int threads)
|
public IrisChunkGenerator(String dimensionName, int threads)
|
||||||
{
|
{
|
||||||
super(dimensionName, threads);
|
super(dimensionName, threads);
|
||||||
lock = new IrisLock("IrisChunkGenerator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisChunkGenerator(String dimensionName)
|
public IrisChunkGenerator(String dimensionName)
|
||||||
{
|
{
|
||||||
super(dimensionName, 16);
|
super(dimensionName, 16);
|
||||||
lock = new IrisLock("IrisChunkGenerator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisChunkGenerator(int tc)
|
public IrisChunkGenerator(int tc)
|
||||||
{
|
{
|
||||||
super("", tc);
|
super("", tc);
|
||||||
lock = new IrisLock("IrisChunkGenerator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hotload()
|
public void hotload()
|
||||||
@ -73,9 +68,7 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
|||||||
@Override
|
@Override
|
||||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||||
{
|
{
|
||||||
lock.lock();
|
|
||||||
super.onGenerate(random, x, z, data, grid);
|
super.onGenerate(random, x, z, data, grid);
|
||||||
lock.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInit(World world, RNG rng)
|
public void onInit(World world, RNG rng)
|
||||||
|
@ -697,7 +697,6 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
|||||||
return i.getMax();
|
return i.getMax();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
|
@ -16,9 +16,6 @@ public class AtomicMulticache
|
|||||||
private final KMap<Long, BiomeResult> biome;
|
private final KMap<Long, BiomeResult> biome;
|
||||||
private final KMap<Long, BiomeResult> rawBiome;
|
private final KMap<Long, BiomeResult> rawBiome;
|
||||||
private final KMap<Long, IrisRegion> region;
|
private final KMap<Long, IrisRegion> region;
|
||||||
private int r = 0;
|
|
||||||
private int w = 0;
|
|
||||||
private int m = 0;
|
|
||||||
|
|
||||||
public AtomicMulticache()
|
public AtomicMulticache()
|
||||||
{
|
{
|
||||||
@ -34,9 +31,6 @@ public class AtomicMulticache
|
|||||||
{
|
{
|
||||||
this.x.set(x);
|
this.x.set(x);
|
||||||
this.z.set(z);
|
this.z.set(z);
|
||||||
r = 0;
|
|
||||||
w = 0;
|
|
||||||
m = 0;
|
|
||||||
|
|
||||||
if(!IrisSettings.get().sharedCaching || getSize() > 42000)
|
if(!IrisSettings.get().sharedCaching || getSize() > 42000)
|
||||||
{
|
{
|
||||||
@ -46,70 +40,58 @@ public class AtomicMulticache
|
|||||||
|
|
||||||
public double getHeight(int x, int z, Supplier<Double> g)
|
public double getHeight(int x, int z, Supplier<Double> g)
|
||||||
{
|
{
|
||||||
return height.compute(pos(x, z), (k, v) ->
|
Long pos = pos(x, z);
|
||||||
|
Double r = height.get(pos);
|
||||||
|
|
||||||
|
if(r == null)
|
||||||
{
|
{
|
||||||
if(v == null)
|
r = g.get();
|
||||||
{
|
height.put(pos, r);
|
||||||
m++;
|
}
|
||||||
w++;
|
|
||||||
return g.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
r++;
|
return r;
|
||||||
|
|
||||||
return v;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g)
|
public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g)
|
||||||
{
|
{
|
||||||
return region.compute(pos(x, z), (k, v) ->
|
Long pos = pos(x, z);
|
||||||
|
IrisRegion r = region.get(pos);
|
||||||
|
|
||||||
|
if(r == null)
|
||||||
{
|
{
|
||||||
if(v == null)
|
r = g.get();
|
||||||
{
|
region.put(pos, r);
|
||||||
m++;
|
}
|
||||||
w++;
|
|
||||||
return g.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
r++;
|
return r;
|
||||||
|
|
||||||
return v;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g)
|
public BiomeResult getBiome(int x, int z, Supplier<BiomeResult> g)
|
||||||
{
|
{
|
||||||
return biome.compute(pos(x, z), (k, v) ->
|
Long pos = pos(x, z);
|
||||||
|
BiomeResult r = biome.get(pos);
|
||||||
|
|
||||||
|
if(r == null)
|
||||||
{
|
{
|
||||||
if(v == null)
|
r = g.get();
|
||||||
{
|
biome.put(pos, r);
|
||||||
m++;
|
}
|
||||||
w++;
|
|
||||||
return g.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
r++;
|
return r;
|
||||||
|
|
||||||
return v;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult getRawBiome(int x, int z, Supplier<BiomeResult> g)
|
public BiomeResult getRawBiome(int x, int z, Supplier<BiomeResult> g)
|
||||||
{
|
{
|
||||||
return rawBiome.compute(pos(x, z), (k, v) ->
|
Long pos = pos(x, z);
|
||||||
|
BiomeResult r = rawBiome.get(pos);
|
||||||
|
|
||||||
|
if(r == null)
|
||||||
{
|
{
|
||||||
if(v == null)
|
r = g.get();
|
||||||
{
|
rawBiome.put(pos, r);
|
||||||
m++;
|
}
|
||||||
w++;
|
|
||||||
return g.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
r++;
|
return r;
|
||||||
|
|
||||||
return v;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long pos(int x, int z)
|
private long pos(int x, int z)
|
||||||
|
@ -178,7 +178,7 @@ public class GenLayerCave extends GenLayer
|
|||||||
|
|
||||||
public boolean canAir(Material m)
|
public boolean canAir(Material m)
|
||||||
{
|
{
|
||||||
return (m.isSolid() || (B.isDecorant(m)) || m.equals(Material.AIR) || m.equals(B.mat("CAVE_AIR"))) && !m.equals(Material.BEDROCK);
|
return (B.isSolid(m) || (B.isDecorant(m)) || m.equals(Material.AIR) || m.equals(B.mat("CAVE_AIR"))) && !m.equals(Material.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canWater(Material m)
|
public boolean canWater(Material m)
|
||||||
@ -188,7 +188,7 @@ public class GenLayerCave extends GenLayer
|
|||||||
|
|
||||||
public boolean can(Material m)
|
public boolean can(Material m)
|
||||||
{
|
{
|
||||||
return m.isSolid() && !m.equals(Material.BEDROCK);
|
return B.isSolid(m) && !m.equals(Material.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,13 +12,11 @@ public class GroupedExecutor
|
|||||||
{
|
{
|
||||||
private int xc;
|
private int xc;
|
||||||
private ExecutorService service;
|
private ExecutorService service;
|
||||||
private IrisLock lock;
|
|
||||||
private KMap<String, Integer> mirror;
|
private KMap<String, Integer> mirror;
|
||||||
|
|
||||||
public GroupedExecutor(int threadLimit, int priority, String name)
|
public GroupedExecutor(int threadLimit, int priority, String name)
|
||||||
{
|
{
|
||||||
xc = 1;
|
xc = 1;
|
||||||
lock = new IrisLock("GX");
|
|
||||||
mirror = new KMap<String, Integer>();
|
mirror = new KMap<String, Integer>();
|
||||||
|
|
||||||
if(threadLimit == 1)
|
if(threadLimit == 1)
|
||||||
@ -79,8 +77,6 @@ public class GroupedExecutor
|
|||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
J.sleep(0);
|
|
||||||
|
|
||||||
if(mirror.get(g) == 0)
|
if(mirror.get(g) == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -97,13 +93,8 @@ public class GroupedExecutor
|
|||||||
|
|
||||||
public void queue(String q, NastyRunnable r)
|
public void queue(String q, NastyRunnable r)
|
||||||
{
|
{
|
||||||
lock.lock();
|
mirror.compute(q, (k, v) -> k == null || v == null ? 1 : v + 1);
|
||||||
if(!mirror.containsKey(q))
|
|
||||||
{
|
|
||||||
mirror.put(q, 0);
|
|
||||||
}
|
|
||||||
mirror.put(q, mirror.get(q) + 1);
|
|
||||||
lock.unlock();
|
|
||||||
service.execute(() ->
|
service.execute(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -116,9 +107,7 @@ public class GroupedExecutor
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.lock();
|
mirror.compute(q, (k, v) -> v - 1);
|
||||||
mirror.put(q, mirror.get(q) - 1);
|
|
||||||
lock.unlock();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +115,7 @@ public class GroupedExecutor
|
|||||||
{
|
{
|
||||||
J.a(() ->
|
J.a(() ->
|
||||||
{
|
{
|
||||||
J.sleep(10000);
|
J.sleep(100);
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,13 @@ public class IrisInterpolation
|
|||||||
return cubic(cubic(p00, p01, p02, p03, muy), cubic(p10, p11, p12, p13, muy), cubic(p20, p21, p22, p23, muy), cubic(p30, p31, p32, p33, muy), mux);
|
return cubic(cubic(p00, p01, p02, p03, muy), cubic(p10, p11, p12, p13, muy), cubic(p20, p21, p22, p23, muy), cubic(p30, p31, p32, p33, muy), mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double trilerp(double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double x, double y, double z)
|
||||||
|
{
|
||||||
|
double s = blerp(v1, v2, v3, v4, x, y);
|
||||||
|
double t = blerp(v5, v6, v7, v8, x, y);
|
||||||
|
return lerp(s, t, z);
|
||||||
|
}
|
||||||
|
|
||||||
public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n)
|
public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n)
|
||||||
{
|
{
|
||||||
int fx = (int) Math.floor(x / rad);
|
int fx = (int) Math.floor(x / rad);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user