ERADICATE V1

This commit is contained in:
Daniel Mills
2020-11-10 01:07:28 -05:00
parent 4fc8a5ad0c
commit 9ba47c1b6a
57 changed files with 85 additions and 9837 deletions

View File

@@ -1,22 +0,0 @@
package com.volmit.iris.util;
import com.volmit.iris.generator.legacy.TopographicTerrainProvider;
public abstract class GenLayer
{
protected final RNG rng;
protected final TopographicTerrainProvider iris;
public GenLayer(TopographicTerrainProvider iris, RNG rng)
{
this.iris = iris;
this.rng = rng;
}
public GenLayer()
{
this(null, null);
}
public abstract double generate(double x, double z);
}

View File

@@ -1,135 +0,0 @@
package com.volmit.iris.util;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Levelled;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Slab;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.generator.legacy.PostBlockTerrainProvider;
import lombok.Data;
@Data
public abstract class IrisPostBlockFilter implements IPostBlockAccess
{
public PostBlockTerrainProvider gen;
private int phase;
@DontObfuscate
public IrisPostBlockFilter(PostBlockTerrainProvider gen, int phase)
{
this.gen = gen;
this.phase = phase;
}
@DontObfuscate
public IrisPostBlockFilter(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
public abstract void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData, KList<Runnable> q);
@Override
public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
return gen.getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
}
@Override
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData)
{
gen.setPostBlock(x, y, z, d, currentPostX, currentPostZ, currentData);
}
@Override
public int highestTerrainOrFluidBlock(int x, int z)
{
return gen.highestTerrainOrFluidBlock(x, z);
}
@Override
public int highestTerrainBlock(int x, int z)
{
return gen.highestTerrainBlock(x, z);
}
public int highestTerrainOrCarvingBlock(int x, int z)
{
return gen.getCarvedHeight(x, z, true);
}
public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
}
public boolean hasGravity(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER);
}
public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid();
}
public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid() && !(d instanceof Slab);
}
public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
}
public boolean isSlab(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Slab;
}
public boolean isSnowLayer(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.SNOW);
}
public boolean isWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER);
}
public boolean isWaterOrWaterlogged(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged());
}
public boolean isLiquid(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Levelled;
}
@Override
public KList<CaveResult> caveFloors(int x, int z)
{
return gen.caveFloors(x, z);
}
@Override
public void updateHeight(int x, int z, int h)
{
gen.updateHeight(x, z, h);
}
}

View File

@@ -1,157 +0,0 @@
package com.volmit.iris.util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.Iris;
import com.volmit.iris.generator.legacy.atomics.AtomicSliver;
public class ParallaxChunk implements Writable
{
private static final ParallaxSection EMPTY = new ParallaxSection();
private final ParallaxSection[] sections;
private boolean parallaxGenerated;
private boolean worldGenerated;
public ParallaxChunk(DataInputStream in) throws IOException
{
this();
read(in);
}
public ParallaxChunk()
{
parallaxGenerated = false;
worldGenerated = false;
sections = new ParallaxSection[16];
}
public boolean isParallaxGenerated()
{
return parallaxGenerated;
}
public void setParallaxGenerated(boolean parallaxGenerated)
{
this.parallaxGenerated = parallaxGenerated;
}
public boolean isWorldGenerated()
{
return worldGenerated;
}
public void setWorldGenerated(boolean worldGenerated)
{
this.worldGenerated = worldGenerated;
}
public void export(ChunkData d)
{
for(ParallaxSection i : sections)
{
if(i != null)
{
for(int x = 0; x < 16; x++)
{
for(int y = 0; y < 16; y++)
{
for(int z = 0; z < 16; z++)
{
BlockData b = get(x, y, z);
if(b == null || b.getMaterial().equals(Material.AIR))
{
continue;
}
d.setBlock(x, y, z, b);
}
}
}
}
}
}
public void injectUpdates(AtomicSliver sliver, int x, int z)
{
for(Byte b : sliver.getUpdatables())
{
byte i = (byte) (b - Byte.MIN_VALUE);
if(i > 255 || i < 0)
{
Iris.warn("Block Update out of bounds: " + i);
}
getSection(i >> 4, true).update(x, i, z);
}
}
@Override
public void write(DataOutputStream o) throws IOException
{
o.writeBoolean(isParallaxGenerated());
o.writeBoolean(isWorldGenerated());
for(int i = 15; i > 0; i--)
{
ParallaxSection c = sections[i];
if(c != null)
{
o.writeBoolean(true);
c.write(o);
}
else
{
o.writeBoolean(false);
}
}
}
@Override
public void read(DataInputStream i) throws IOException
{
setParallaxGenerated(i.readBoolean());
setWorldGenerated(i.readBoolean());
for(int iv = 15; iv > 0; iv--)
{
if(i.readBoolean())
{
sections[iv] = new ParallaxSection(i);
}
}
}
public BlockData get(int x, int y, int z)
{
return getSection(y >> 4, false).getBlock(x, y & 15, z);
}
public void set(int x, int y, int z, BlockData d)
{
getSection(y >> 4, true).setBlock(x, y & 15, z, d);
}
private final ParallaxSection getSection(int y, boolean create)
{
if(sections[y] == null)
{
if(create)
{
sections[y] = new ParallaxSection();
}
return EMPTY;
}
return sections[y];
}
}

View File

@@ -1,125 +0,0 @@
package com.volmit.iris.util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.IrisSettings;
public class ParallaxRegion implements Writable
{
private static final ParallaxChunk EMPTY = new ParallaxChunk();
private ParallaxChunk[] chunks;
private transient long last;
public ParallaxRegion(File i) throws IOException
{
this();
if(i.exists())
{
FileInputStream in = new FileInputStream(i);
GZIPInputStream vin = new GZIPInputStream(in);
DataInputStream min = new DataInputStream(vin);
read(min);
min.close();
}
}
public ParallaxRegion(DataInputStream i) throws IOException
{
this();
read(i);
}
public ParallaxRegion()
{
last = M.ms();
chunks = new ParallaxChunk[1024];
}
@Override
public void write(DataOutputStream o) throws IOException
{
int c = 0;
for(ParallaxChunk i : chunks)
{
if(i != null)
{
c++;
}
}
o.writeShort(c);
for(int i = 0; i < 1024; i++)
{
ParallaxChunk ch = chunks[i];
if(ch != null)
{
ch.write(o);
}
}
}
public void write(File file) throws IOException
{
file.getParentFile().mkdirs();
FileOutputStream o = new FileOutputStream(file);
CustomOutputStream g = new CustomOutputStream(o, IrisSettings.get().parallaxCompressionLevel);
DataOutputStream d = new DataOutputStream(g);
write(d);
d.close();
}
@Override
public void read(DataInputStream i) throws IOException
{
int v = i.readShort();
for(int b = 0; b < v; b++)
{
chunks[b] = new ParallaxChunk(i);
}
}
public boolean isOlderThan(long time)
{
return M.ms() - time > last;
}
public void set(int x, int y, int z, BlockData d)
{
getChunk(x >> 4, z >> 4, true).set(x & 15, y, z & 15, d);
}
public BlockData get(int x, int y, int z)
{
return getChunk(x >> 4, z >> 4, false).get(x & 15, y, z & 15);
}
private final ParallaxChunk getChunk(int x, int z, boolean create)
{
last = M.ms();
int v = (z << 5) | x;
if(chunks[v] == null)
{
if(create)
{
chunks[v] = new ParallaxChunk();
}
return EMPTY;
}
return chunks[v];
}
}

View File

@@ -1,98 +0,0 @@
package com.volmit.iris.util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.bukkit.block.data.BlockData;
public class ParallaxSection implements Writable
{
private final DataPalette<BlockData> block;
private final KSet<Short> updates;
public ParallaxSection(DataInputStream in) throws IOException
{
this();
read(in);
}
public ParallaxSection()
{
updates = new KSet<Short>();
this.block = new DataPalette<BlockData>(B.get("AIR"))
{
@Override
public void writeType(BlockData t, DataOutputStream o) throws IOException
{
o.writeUTF(t.getAsString(true));
}
@Override
public BlockData readType(DataInputStream i) throws IOException
{
return B.get(i.readUTF());
}
};
}
public void clearUpdates()
{
updates.clear();
}
public void update(int x, int y, int z)
{
updates.add((short) (y << 8 | z << 4 | x));
}
public void dontUpdate(int x, int y, int z)
{
updates.remove((short) (y << 8 | z << 4 | x));
}
public void setBlock(int x, int y, int z, BlockData d)
{
block.set(x, y, z, d);
if(B.isUpdatable(d))
{
update(x, y, z);
}
else
{
dontUpdate(x, y, z);
}
}
public BlockData getBlock(int x, int y, int z)
{
return block.get(x, y, z);
}
@Override
public void write(DataOutputStream o) throws IOException
{
block.write(o);
o.writeShort(updates.size());
for(Short i : updates)
{
o.writeShort(i);
}
}
@Override
public void read(DataInputStream i) throws IOException
{
block.read(i);
updates.clear();
int m = i.readShort();
for(int v = 0; v < m; v++)
{
updates.add(i.readShort());
}
}
}

View File

@@ -1,120 +0,0 @@
package com.volmit.iris.util;
import java.io.File;
import java.io.IOException;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.Iris;
public class ParallaxWorld
{
private final KMap<Long, ParallaxRegion> loadedRegions;
private final File dataFolder;
public ParallaxWorld(File dataFolder)
{
loadedRegions = new KMap<>();
this.dataFolder = dataFolder;
}
public void unloadAll()
{
for(long i : loadedRegions.k())
{
try
{
unload(i);
}
catch(IOException e)
{
Iris.error("Failed to save region " + i);
e.printStackTrace();
}
}
}
public void clean(long time)
{
for(long i : loadedRegions.k())
{
ParallaxRegion r = loadedRegions.get(i);
if(r.isOlderThan(time))
{
try
{
unload(i);
}
catch(IOException e)
{
Iris.error("Failed to save region " + i);
e.printStackTrace();
}
break;
}
}
}
private void unload(long i) throws IOException
{
ParallaxRegion r = loadedRegions.get(i);
r.write(new File(dataFolder, i + ".plx"));
loadedRegions.remove(i);
}
public BlockData getBlock(int x, int y, int z)
{
if(y > 255 || y < 0)
{
throw new IllegalArgumentException(y + " exceeds 0-255");
}
return getRegion(x >> 5, z >> 5).get(x & 511, y, z & 511);
}
public void setBlock(int x, int y, int z, BlockData d)
{
if(d == null)
{
throw new IllegalArgumentException("Block data cannot be null");
}
if(y > 255 || y < 0)
{
throw new IllegalArgumentException(y + " exceeds 0-255");
}
getRegion(x >> 5, z >> 5).set(x & 511, y, z & 511, d);
}
public ParallaxRegion getRegion(int x, int z)
{
Long vb = (((long) x) << 32) | (z & 0xffffffffL);
File ff = new File(dataFolder, vb + ".plx");
return loadedRegions.compute(vb, (k, v) ->
{
if(k == null || v == null)
{
try
{
return new ParallaxRegion(ff);
}
catch(IOException e)
{
Iris.error("Failed to load parallax file: " + ff.getAbsolutePath() + " Assuming empty region!");
ff.deleteOnExit();
ff.delete();
return new ParallaxRegion();
}
}
return v;
});
}
}

View File

@@ -1,16 +0,0 @@
package com.volmit.iris.util;
import org.bukkit.Chunk;
import org.bukkit.World;
import com.volmit.iris.generator.legacy.TopographicTerrainProvider;
public abstract class WorldGenLayer
{
public WorldGenLayer()
{
}
public abstract void gen(TopographicTerrainProvider g, Chunk c, int x, int z, World w, RNG r);
}