This commit is contained in:
Daniel Mills 2020-08-23 03:25:12 -04:00
parent 69218b6710
commit 308395aa86
9 changed files with 58 additions and 35 deletions

View File

@ -104,14 +104,8 @@ public class Iris extends MortarPlugin implements BoardProvider
public void onDisable() public void onDisable()
{ {
lock.unlock();
proj.close(); proj.close();
for(GroupedExecutor i : executors)
{
i.close();
}
for(World i : Bukkit.getWorlds()) for(World i : Bukkit.getWorlds())
{ {
if(i.getGenerator() instanceof IrisChunkGenerator) if(i.getGenerator() instanceof IrisChunkGenerator)
@ -119,6 +113,10 @@ public class Iris extends MortarPlugin implements BoardProvider
((IrisChunkGenerator) i).close(); ((IrisChunkGenerator) i).close();
} }
} }
for(GroupedExecutor i : executors)
{
i.close();
}
executors.clear(); executors.clear();
manager.onDisable(); manager.onDisable();

View File

@ -301,4 +301,16 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
hr = region; hr = region;
return biome.getName() + " (" + Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in " + region.getName() + "\nY: " + (int) height); return biome.getName() + " (" + Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in " + region.getName() + "\nY: " + (int) height);
} }
public void saveAllParallax()
{
try
{
getParallaxMap().saveAll();
}
catch(IOException e)
{
e.printStackTrace();
}
}
} }

View File

@ -40,6 +40,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
protected KMap<ChunkPosition, AtomicSliver> sliverCache; protected KMap<ChunkPosition, AtomicSliver> sliverCache;
protected AtomicWorldData parallaxMap; protected AtomicWorldData parallaxMap;
private MasterLock masterLock; private MasterLock masterLock;
private IrisLock flock = new IrisLock("ParallaxLock");
private IrisLock lock = new IrisLock("ParallaxLock"); private IrisLock lock = new IrisLock("ParallaxLock");
private IrisLock lockq = new IrisLock("ParallaxQueueLock"); private IrisLock lockq = new IrisLock("ParallaxQueueLock");
private GenLayerUpdate glUpdate; private GenLayerUpdate glUpdate;
@ -112,9 +113,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
@Override @Override
public void set(int x, int y, int z, BlockData d) public void set(int x, int y, int z, BlockData d)
{ {
getMasterLock().lock((x >> 4) + "." + (z >> 4));
getParallaxSliver(x, z).set(y, d); getParallaxSliver(x, z).set(y, d);
getMasterLock().unlock((x >> 4) + "." + (z >> 4));
} }
@Override @Override
@ -189,6 +188,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
@Override @Override
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map) protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
{ {
// flock.lock();
if(getSliverCache().size() > 20000) if(getSliverCache().size() > 20000)
{ {
getSliverCache().clear(); getSliverCache().clear();
@ -213,6 +213,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap, map); super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap, map);
getParallaxMap().clean(ticks); getParallaxMap().clean(ticks);
getData().getObjectLoader().clean(); getData().getObjectLoader().clean();
// flock.unlock();
} }
public IrisStructureResult getStructure(int x, int y, int z) public IrisStructureResult getStructure(int x, int y, int z)
@ -349,7 +350,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
} }
getAccelerant().waitFor(key); getAccelerant().waitFor(key);
lockq.lock(); lockq.lock();
for(NastyRunnable i : q) for(NastyRunnable i : q)
{ {

View File

@ -9,6 +9,7 @@ import java.util.zip.GZIPInputStream;
import org.bukkit.World; import org.bukkit.World;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings; import com.volmit.iris.IrisSettings;
import com.volmit.iris.util.ByteArrayTag; import com.volmit.iris.util.ByteArrayTag;
import com.volmit.iris.util.CompoundTag; import com.volmit.iris.util.CompoundTag;
@ -100,7 +101,8 @@ public class AtomicRegionData
data.write(out); data.write(out);
out.flush(); out.flush();
out.close(); out.close();
tag[(rz << 5) | rx] = new ByteArrayTag(rx + "." + rz, boas.toByteArray()); byte[] b = boas.toByteArray();
tag[(rz << 5) | rx] = new ByteArrayTag(rx + "." + rz, b);
} }
public AtomicSliverMap get(int rx, int rz) throws IOException public AtomicSliverMap get(int rx, int rz) throws IOException
@ -112,9 +114,15 @@ public class AtomicRegionData
return data; return data;
} }
ByteArrayTag btag = (ByteArrayTag) tag[(rz << 5) | rx];
try try
{ {
ByteArrayTag btag = (ByteArrayTag) tag[(rz << 5) | rx]; if(btag.getValue().length == 0)
{
Iris.warn("EMPTY BYTE TAG " + rx + " " + rz);
return data;
}
InputStream in; InputStream in;
@ -129,11 +137,12 @@ public class AtomicRegionData
} }
data.read(in); data.read(in);
in.close();
} }
catch(Throwable e) catch(Throwable e)
{ {
Iris.warn("Failed to load " + rx + "." + rz + " with " + btag.getValue().length);
} }
return data; return data;

View File

@ -30,8 +30,8 @@ public class AtomicSliver
private transient IrisLock lock = new IrisLock("Sliver"); private transient IrisLock lock = new IrisLock("Sliver");
private transient int highestBiome = 0; private transient int highestBiome = 0;
private transient long last = M.ms(); private transient long last = M.ms();
private transient int x; private transient final int x;
private transient int z; private transient final int z;
private transient boolean modified = false; private transient boolean modified = false;
private KMap<Integer, BlockData> block; private KMap<Integer, BlockData> block;
private KSet<Integer> blockUpdates; private KSet<Integer> blockUpdates;
@ -39,7 +39,6 @@ public class AtomicSliver
public AtomicSliver(int x, int z) public AtomicSliver(int x, int z)
{ {
lock.setDisabled(true);
this.x = x; this.x = x;
this.z = z; this.z = z;
blockUpdates = new KSet<>(); blockUpdates = new KSet<>();
@ -204,12 +203,12 @@ public class AtomicSliver
lock.lock(); lock.lock();
this.block = new KMap<Integer, BlockData>(); this.block = new KMap<Integer, BlockData>();
getUpdatables().clear();
// Block Palette // Block Palette
int h = din.readByte() - Byte.MIN_VALUE;
int p = din.readByte() - Byte.MIN_VALUE; int p = din.readByte() - Byte.MIN_VALUE;
int h = din.readByte() - Byte.MIN_VALUE;
int u = din.readByte() - Byte.MIN_VALUE; int u = din.readByte() - Byte.MIN_VALUE;
KList<BlockData> palette = new KList<BlockData>(); KList<BlockData> palette = new KList<BlockData>();
getUpdatables().clear();
highestBlock = h; highestBlock = h;
for(int i = 0; i < p; i++) for(int i = 0; i < p; i++)
@ -224,7 +223,7 @@ public class AtomicSliver
} }
// Updates // Updates
for(int i = 0; i <= u; i++) for(int i = 0; i < u; i++)
{ {
update(din.readByte() - Byte.MIN_VALUE); update(din.readByte() - Byte.MIN_VALUE);
} }
@ -236,7 +235,6 @@ public class AtomicSliver
public void write(DataOutputStream dos) throws IOException public void write(DataOutputStream dos) throws IOException
{ {
lock.lock(); lock.lock();
dos.writeByte(highestBlock + Byte.MIN_VALUE);
// Block Palette // Block Palette
KList<String> palette = new KList<>(); KList<String> palette = new KList<>();
@ -253,6 +251,7 @@ public class AtomicSliver
} }
dos.writeByte(palette.size() + Byte.MIN_VALUE); dos.writeByte(palette.size() + Byte.MIN_VALUE);
dos.writeByte(highestBlock + Byte.MIN_VALUE);
dos.writeByte(blockUpdates.size() + Byte.MIN_VALUE); dos.writeByte(blockUpdates.size() + Byte.MIN_VALUE);
for(String i : palette) for(String i : palette)

View File

@ -82,9 +82,18 @@ public class AtomicSliverMap
DataOutputStream dos = new DataOutputStream(out); DataOutputStream dos = new DataOutputStream(out);
dos.writeBoolean(isParallaxGenerated()); dos.writeBoolean(isParallaxGenerated());
dos.writeBoolean(isWorldGenerated()); dos.writeBoolean(isWorldGenerated());
for(int i = 0; i < 256; i++) for(int i = 0; i < 256; i++)
{ {
slivers[i].write(dos); try
{
slivers[i].write(dos);
}
catch(Throwable e)
{
e.printStackTrace();
}
} }
KList<String> structurePalette = new KList<>(); KList<String> structurePalette = new KList<>();
@ -132,7 +141,7 @@ public class AtomicSliverMap
catch(Throwable e) catch(Throwable e)
{ {
e.printStackTrace();
} }
} }

View File

@ -313,7 +313,7 @@ public class AtomicWorldData
break; break;
} }
if(M.ms() - lastChunk.get(i) > 15000) if(M.ms() - lastChunk.get(i) > 60000)
{ {
m++; m++;
unloadChunks.add(i); unloadChunks.add(i);

View File

@ -19,7 +19,6 @@ import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.Form; import com.volmit.iris.util.Form;
import com.volmit.iris.util.IrisLock; import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.IrisPostBlockFilter; import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.J;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.KSet; import com.volmit.iris.util.KSet;
import com.volmit.iris.util.MaxNumber; import com.volmit.iris.util.MaxNumber;
@ -619,8 +618,10 @@ public class IrisDimension extends IrisRegistrant
{ {
Iris.info("Calculating the Parallax Size in Parallel"); Iris.info("Calculating the Parallax Size in Parallel");
O<Integer> xg = new O<>(); O<Integer> xg = new O<>();
O<Integer> yg = new O<>();
O<Integer> zg = new O<>(); O<Integer> zg = new O<>();
xg.set(0); xg.set(0);
yg.set(0);
zg.set(0); zg.set(0);
KSet<String> objects = new KSet<>(); KSet<String> objects = new KSet<>();
@ -649,6 +650,7 @@ public class IrisDimension extends IrisRegistrant
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i)); BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
t.lock(); t.lock();
xg.set(bv.getBlockX() > xg.get() ? bv.getBlockX() : xg.get()); xg.set(bv.getBlockX() > xg.get() ? bv.getBlockX() : xg.get());
yg.set(bv.getBlockY() > yg.get() ? bv.getBlockY() : yg.get());
zg.set(bv.getBlockZ() > zg.get() ? bv.getBlockZ() : zg.get()); zg.set(bv.getBlockZ() > zg.get() ? bv.getBlockZ() : zg.get());
t.unlock(); t.unlock();
} }
@ -662,8 +664,8 @@ public class IrisDimension extends IrisRegistrant
g.getAccelerant().waitFor("tx-psize"); g.getAccelerant().waitFor("tx-psize");
g.changeThreadCount(tc); g.changeThreadCount(tc);
int x = xg.get(); int x = Math.max(xg.get(), Math.max(yg.get(), zg.get()));
int z = zg.get(); int z = x;
for(IrisDepositGenerator i : getDeposits()) for(IrisDepositGenerator i : getDeposits())
{ {
@ -696,6 +698,8 @@ public class IrisDimension extends IrisRegistrant
z = (Math.max(z, 16) + 16) >> 4; z = (Math.max(z, 16) + 16) >> 4;
x = x % 2 == 0 ? x + 1 : x; x = x % 2 == 0 ? x + 1 : x;
z = z % 2 == 0 ? z + 1 : z; z = z % 2 == 0 ? z + 1 : z;
z = Math.max(x, z);
x = z;
Iris.info("Done! Parallax Size: " + x + ", " + z); Iris.info("Done! Parallax Size: " + x + ", " + z);
return new ChunkPosition(x, z); return new ChunkPosition(x, z);
}); });

View File

@ -147,18 +147,10 @@ public class IrisObject extends IrisRegistrant
{ {
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT_RIGID)) if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT_RIGID))
{ {
if(config.isTranslateCenter()) y = placer.getHighest(x, z, config.isUnderwater()) + rty;
{
y = placer.getHighest(x, z, config.isUnderwater()) + rty;
}
else
{
y = placer.getHighest(x, z, config.isUnderwater()) + rty;
}
} }
if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT_RIGID_ACCURATE)) else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT_RIGID_ACCURATE))
{ {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();