mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Prg
This commit is contained in:
parent
1993639bf6
commit
bdb86808a5
@ -31,7 +31,9 @@ import com.volmit.iris.util.IrisLock;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarPlugin;
|
||||
import com.volmit.iris.util.NastyRunnable;
|
||||
import com.volmit.iris.util.Permission;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class Iris extends MortarPlugin
|
||||
{
|
||||
@ -394,4 +396,21 @@ public class Iris extends MortarPlugin
|
||||
{
|
||||
return nmsTag;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void later(NastyRunnable object)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
object.run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, RNG.r.i(100, 1200));
|
||||
}
|
||||
}
|
||||
|
@ -113,27 +113,6 @@ public class GenLayerCave extends GenLayer
|
||||
{
|
||||
ceiling = pu > ceiling ? pu : ceiling;
|
||||
floor = pu < floor ? pu : floor;
|
||||
|
||||
if(pu > surface - 2)
|
||||
{
|
||||
if(dig(x, pu + 1, z, data))
|
||||
{
|
||||
ceiling = pu + 1 > ceiling ? pu + 1 : ceiling;
|
||||
floor = pu + 1 < floor ? pu + 1 : floor;
|
||||
|
||||
if(dig(x, pu + 2, z, data))
|
||||
{
|
||||
ceiling = pu + 2 > ceiling ? pu + 2 : ceiling;
|
||||
floor = pu + 2 < floor ? pu + 2 : floor;
|
||||
|
||||
if(dig(x, pu + 3, z, data))
|
||||
{
|
||||
ceiling = pu + 3 > ceiling ? pu + 3 : ceiling;
|
||||
floor = pu + 3 < floor ? pu + 3 : floor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dig(x, pd, z, data))
|
||||
|
@ -6,9 +6,11 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
@ -30,9 +32,17 @@ import net.minecraft.server.v1_14_R1.WorldNBTStorage;
|
||||
import net.minecraft.server.v1_14_R1.WorldProvider;
|
||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||
import net.minecraft.server.v1_14_R1.WorldSettings;
|
||||
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_14_R1.TicketType;
|
||||
import net.minecraft.server.v1_14_R1.Unit;
|
||||
|
||||
public class NMSCreator141
|
||||
{
|
||||
public static void addStartTicket(Location center, int size)
|
||||
{
|
||||
((CraftWorld) center.getWorld()).getHandle().getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(center.getBlockX() >> 4, center.getBlockZ() >> 4), size, Unit.INSTANCE);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"resource", "deprecation"})
|
||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||
{
|
||||
|
@ -6,9 +6,11 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
@ -30,9 +32,17 @@ import net.minecraft.server.v1_15_R1.WorldNBTStorage;
|
||||
import net.minecraft.server.v1_15_R1.WorldProvider;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
import net.minecraft.server.v1_15_R1.WorldSettings;
|
||||
import net.minecraft.server.v1_15_R1.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_15_R1.TicketType;
|
||||
import net.minecraft.server.v1_15_R1.Unit;
|
||||
|
||||
public class NMSCreator151
|
||||
{
|
||||
public static void addStartTicket(Location center, int size)
|
||||
{
|
||||
((CraftWorld) center.getWorld()).getHandle().getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(center.getBlockX() >> 4, center.getBlockZ() >> 4), size, Unit.INSTANCE);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"resource", "deprecation"})
|
||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||
{
|
||||
|
@ -11,9 +11,11 @@ import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
@ -52,9 +54,17 @@ import net.minecraft.server.v1_16_R1.WorldDataServer;
|
||||
import net.minecraft.server.v1_16_R1.WorldDimension;
|
||||
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||
import net.minecraft.server.v1_16_R1.WorldSettings;
|
||||
import net.minecraft.server.v1_16_R1.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_16_R1.TicketType;
|
||||
import net.minecraft.server.v1_16_R1.Unit;
|
||||
|
||||
public class NMSCreator161
|
||||
{
|
||||
public static void addStartTicket(Location center, int size)
|
||||
{
|
||||
((CraftWorld) center.getWorld()).getHandle().getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(center.getBlockX() >> 4, center.getBlockZ() >> 4), size, Unit.INSTANCE);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "resource"})
|
||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||
{
|
||||
|
@ -270,6 +270,57 @@ public class PostMasterPatcher extends IrisPostBlockFilter
|
||||
int cc = nearestCaveCeiling(c, x - 1, z, currentPostX, currentPostZ, currentData);
|
||||
int cd = nearestCaveCeiling(c, x, z - 1, currentPostX, currentPostZ, currentData);
|
||||
|
||||
// Cave Nibs
|
||||
g = 0;
|
||||
g += fa == f - 1 ? 1 : 0;
|
||||
g += fb == f - 1 ? 1 : 0;
|
||||
g += fc == f - 1 ? 1 : 0;
|
||||
g += fd == f - 1 ? 1 : 0;
|
||||
|
||||
if(g >= 3)
|
||||
{
|
||||
BlockData bc = getPostBlock(x, f, z, currentPostX, currentPostZ, currentData);
|
||||
b = getPostBlock(x, f + 1, z, currentPostX, currentPostZ, currentData);
|
||||
Material m = bc.getMaterial();
|
||||
|
||||
if(m.isSolid())
|
||||
{
|
||||
setPostBlock(x, f, z, b, currentPostX, currentPostZ, currentData);
|
||||
updateHeight(x, z, f - 1);
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Cave Potholes
|
||||
g = 0;
|
||||
g += fa == f + 1 ? 1 : 0;
|
||||
g += fb == f + 1 ? 1 : 0;
|
||||
g += fc == f + 1 ? 1 : 0;
|
||||
g += fd == f + 1 ? 1 : 0;
|
||||
|
||||
if(g >= 3)
|
||||
{
|
||||
BlockData ba = getPostBlock(x, fa, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bb = getPostBlock(x, fb, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bc = getPostBlock(x, fc, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bd = getPostBlock(x, fd, z, currentPostX, currentPostZ, currentData);
|
||||
g = 0;
|
||||
g = B.isSolid(ba) ? g + 1 : g;
|
||||
g = B.isSolid(bb) ? g + 1 : g;
|
||||
g = B.isSolid(bc) ? g + 1 : g;
|
||||
g = B.isSolid(bd) ? g + 1 : g;
|
||||
|
||||
if(g >= 3)
|
||||
{
|
||||
setPostBlock(x, f + 1, z, getPostBlock(x, f, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
|
||||
updateHeight(x, z, f + 1);
|
||||
h++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gen.getDimension().isPostProcessingSlabs())
|
||||
{
|
||||
//@builder
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.volmit.iris.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
@ -16,7 +17,7 @@ import javax.swing.JPanel;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.ChunkPosition;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.PregenJob;
|
||||
|
||||
@ -24,8 +25,11 @@ public class PregenGui extends JPanel
|
||||
{
|
||||
private PregenJob job;
|
||||
private static final long serialVersionUID = 2094606939770332040L;
|
||||
private KMap<ChunkPosition, Color> queue = new KMap<>();
|
||||
private int res = 8192;
|
||||
private KList<Runnable> order = new KList<>();
|
||||
private int res = 512;
|
||||
Graphics2D bg;
|
||||
double minC;
|
||||
double maxC;
|
||||
private BufferedImage image = new BufferedImage(res, res, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
public PregenGui()
|
||||
@ -36,19 +40,16 @@ public class PregenGui extends JPanel
|
||||
@Override
|
||||
public void paint(Graphics gx)
|
||||
{
|
||||
double minC = Math.floorDiv(job.min(), 16) - 4;
|
||||
double maxC = Math.floorDiv(job.max(), 16) + 4;
|
||||
|
||||
minC = Math.floorDiv(job.min(), 16) - 4;
|
||||
maxC = Math.floorDiv(job.max(), 16) + 4;
|
||||
Graphics2D g = (Graphics2D) gx;
|
||||
Graphics2D bg = (Graphics2D) image.getGraphics();
|
||||
|
||||
for(ChunkPosition i : queue.k())
|
||||
bg = (Graphics2D) image.getGraphics();
|
||||
|
||||
while(order.isNotEmpty())
|
||||
{
|
||||
draw(i, queue.get(i), minC, maxC, bg);
|
||||
order.pop().run();
|
||||
}
|
||||
|
||||
queue.clear();
|
||||
|
||||
g.drawImage(image, 0, 0, getParent().getWidth(), getParent().getHeight(), new ImageObserver()
|
||||
{
|
||||
@Override
|
||||
@ -58,6 +59,16 @@ public class PregenGui extends JPanel
|
||||
}
|
||||
});
|
||||
|
||||
g.setColor(Color.WHITE);
|
||||
g.setFont(new Font("Hevetica", Font.BOLD, 28));
|
||||
String[] prog = job.getProgress();
|
||||
int h = g.getFontMetrics().getHeight() + 5;
|
||||
int hh = 20;
|
||||
for(String i : prog)
|
||||
{
|
||||
g.drawString(i, 20, hh += h);
|
||||
}
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
J.sleep((long) 500);
|
||||
@ -84,9 +95,12 @@ public class PregenGui extends JPanel
|
||||
JFrame frame = new JFrame("Pregen View");
|
||||
PregenGui nv = new PregenGui();
|
||||
nv.job = j;
|
||||
j.subscribe((c, b) -> nv.queue.put(c, b));
|
||||
j.subscribe((c, b) ->
|
||||
{
|
||||
nv.order.add(() -> nv.draw(c, b, nv.minC, nv.maxC, nv.bg));
|
||||
});
|
||||
frame.add(nv);
|
||||
frame.setSize(1440, 820);
|
||||
frame.setSize(1000, 1000);
|
||||
frame.setVisible(true);
|
||||
File file = Iris.getCached("Iris Icon", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/icon.png");
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class IrisDimension extends IrisRegistrant
|
||||
@DontObfuscate
|
||||
@Desc("Add slabs in post processing")
|
||||
private boolean postProcessingSlabs = true;
|
||||
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Add painted walls in post processing")
|
||||
private boolean postProcessingWalls = true;
|
||||
@ -600,10 +600,8 @@ public class IrisDimension extends IrisRegistrant
|
||||
{
|
||||
Iris.info("Calculating the Parallax Size in Parallel");
|
||||
O<Integer> xg = new O<>();
|
||||
O<Integer> yg = new O<>();
|
||||
O<Integer> zg = new O<>();
|
||||
xg.set(0);
|
||||
yg.set(0);
|
||||
zg.set(0);
|
||||
|
||||
KSet<String> objects = new KSet<>();
|
||||
@ -630,7 +628,6 @@ public class IrisDimension extends IrisRegistrant
|
||||
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
|
||||
t.lock();
|
||||
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());
|
||||
t.unlock();
|
||||
}
|
||||
@ -643,8 +640,8 @@ public class IrisDimension extends IrisRegistrant
|
||||
}
|
||||
|
||||
g.getAccelerant().waitFor("tx-psize");
|
||||
int x = Math.max(xg.get(), Math.max(yg.get(), zg.get()));
|
||||
int z = x;
|
||||
int x = xg.get();
|
||||
int z = zg.get();
|
||||
|
||||
for(IrisDepositGenerator i : getDeposits())
|
||||
{
|
||||
@ -698,8 +695,8 @@ public class IrisDimension extends IrisRegistrant
|
||||
z = (Math.max(z, 16) + 16) >> 4;
|
||||
x = x % 2 == 0 ? x + 1 : x;
|
||||
z = z % 2 == 0 ? z + 1 : z;
|
||||
z = Math.max(x, z);
|
||||
x = z;
|
||||
x = Math.max(x, z);
|
||||
z = x;
|
||||
Iris.info("Done! Parallax Size: " + x + ", " + z);
|
||||
return new ChunkPosition(x, z);
|
||||
});
|
||||
|
@ -204,12 +204,13 @@ public class IrisObject extends IrisRegistrant
|
||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static BlockVector sampleSize(File file) throws IOException
|
||||
{
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
DataInputStream din = new DataInputStream(in);
|
||||
BlockVector bv = new BlockVector(din.readInt(), din.readInt(), din.readInt());
|
||||
din.close();
|
||||
Iris.later(() -> din.close());
|
||||
return bv;
|
||||
}
|
||||
|
||||
|
@ -515,6 +515,11 @@ public class B
|
||||
{
|
||||
return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.LAVA);
|
||||
}
|
||||
|
||||
public static boolean isAirOrFluid(BlockData d)
|
||||
{
|
||||
return isAir(d) || isFluid(d);
|
||||
}
|
||||
|
||||
public static boolean isAir(BlockData d)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ public class PregenJob implements Listener
|
||||
private Spiraler chunkSpiraler;
|
||||
private boolean first;
|
||||
private Consumer2<ChunkPosition, Color> consumer;
|
||||
private int cubeSize = 7;
|
||||
|
||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||
{
|
||||
@ -52,7 +53,7 @@ public class PregenJob implements Listener
|
||||
clf = new ChronoLatch(30000);
|
||||
total = (size / 16) * (size / 16);
|
||||
genned = 0;
|
||||
mcaWidth = Math.floorDiv(size >> 4, 8) + 8;
|
||||
mcaWidth = Math.floorDiv(size >> 4, cubeSize) + cubeSize;
|
||||
this.mcaX = 0;
|
||||
this.mcaZ = 0;
|
||||
this.chunkX = 0;
|
||||
@ -60,20 +61,20 @@ public class PregenJob implements Listener
|
||||
completed = false;
|
||||
first = true;
|
||||
|
||||
chunkSpiraler = new Spiraler(8, 8, (x, z) ->
|
||||
chunkSpiraler = new Spiraler(cubeSize, cubeSize, (x, z) ->
|
||||
{
|
||||
chunkX = (mcaX * 8) + x;
|
||||
chunkZ = (mcaZ * 8) + z;
|
||||
chunkX = (mcaX * cubeSize) + x;
|
||||
chunkZ = (mcaZ * cubeSize) + z;
|
||||
});
|
||||
|
||||
spiraler = new Spiraler(mcaWidth, mcaWidth, (x, z) ->
|
||||
{
|
||||
mcaX = x;
|
||||
mcaZ = z;
|
||||
chunkSpiraler.retarget(8, 8);
|
||||
chunkSpiraler.retarget(cubeSize, cubeSize);
|
||||
});
|
||||
|
||||
chunkSpiraler.setOffset(3, 3);
|
||||
chunkSpiraler.setOffset(Math.floorDiv(cubeSize, 2), Math.floorDiv(cubeSize, 2));
|
||||
|
||||
if(task != -1)
|
||||
{
|
||||
@ -151,26 +152,22 @@ public class PregenJob implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
chunkSpiraler.retarget(8, 8);
|
||||
chunkSpiraler.retarget(cubeSize, cubeSize);
|
||||
}
|
||||
|
||||
if(chunkSpiraler.hasNext())
|
||||
{
|
||||
chunkSpiraler.next();
|
||||
|
||||
try
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.YELLOW);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(isChunkWithin(chunkX, chunkZ))
|
||||
{
|
||||
if(consumer != null)
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.YELLOW);
|
||||
}
|
||||
|
||||
world.loadChunk(chunkX, chunkZ);
|
||||
genned++;
|
||||
|
||||
if(consumer != null)
|
||||
{
|
||||
@ -178,23 +175,31 @@ public class PregenJob implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
genned++;
|
||||
else
|
||||
{
|
||||
total--;
|
||||
if(consumer != null)
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.GREEN.darker());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(spiraler.hasNext())
|
||||
{
|
||||
saveAllRequest();
|
||||
spiraler.next();
|
||||
|
||||
while(chunkSpiraler.hasNext())
|
||||
{
|
||||
chunkSpiraler.next();
|
||||
|
||||
if(isChunkWithin(chunkX, chunkZ))
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.DARK_GRAY);
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.BLUE.darker().darker());
|
||||
}
|
||||
}
|
||||
chunkSpiraler.retarget(8, 8);
|
||||
chunkSpiraler.retarget(cubeSize, cubeSize);
|
||||
}
|
||||
|
||||
else
|
||||
@ -267,4 +272,12 @@ public class PregenJob implements Listener
|
||||
{
|
||||
consumer = s;
|
||||
}
|
||||
|
||||
public String[] getProgress()
|
||||
{
|
||||
long eta = (long) ((total - genned) * (s.getMilliseconds() / (double) genned));
|
||||
|
||||
return new String[] {"Progress: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0), "Generated: " + Form.f(genned) + " Chunks", "Remaining: " + Form.f(total - genned) + " Chunks", "Elapsed: " + Form.duration((long) s.getMilliseconds(), 2), "Estimate: " + ((genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta, 2))), "ChunksMS: " + Form.duration((s.getMilliseconds() / (double) genned), 2), "Chunks/s: " + Form.f(1000D / (s.getMilliseconds() / genned), 1),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user