Compare commits

...

12 Commits

Author SHA1 Message Date
DanMB
fcee61a703 fg 2022-06-04 23:32:01 -07:00
DanMB
ce8cc2cf37 Allow paper multicore to call without locking 2022-06-04 22:19:36 -07:00
DanMB
3b5bdcfb51 Merge remote-tracking branch 'origin/master' 2022-06-04 21:50:27 -07:00
DanMB
4d67e97973 Revert "Revert "No cng thing ""
This reverts commit da09f4d6d8.
2022-06-04 21:50:24 -07:00
DanMB
da09f4d6d8 Revert "No cng thing "
This reverts commit dbc7e2e0bf.
2022-06-04 21:49:21 -07:00
DanMB
dbc7e2e0bf No cng thing 2022-06-04 21:48:37 -07:00
DanMB
dd804b6665 It compiles 2022-06-04 21:42:15 -07:00
DanMB
33eb878834 Test imp 1 2022-06-04 21:08:49 -07:00
DanMB
2a2c456011 More prec 2022-06-04 21:06:38 -07:00
DanMB
05a12f3899 Bench 2022-06-04 21:04:37 -07:00
DanMB
eb04710f71 Merge remote-tracking branch 'origin/master' 2022-06-04 20:53:37 -07:00
DanMB
257760453e . 2022-06-04 20:53:28 -07:00
10 changed files with 105 additions and 77 deletions

4
.gitignore vendored
View File

@@ -6,3 +6,7 @@ build/
.idea/
.DS_Store
collection/
src/main/java/com/volmit/iris/util/uniques/

View File

@@ -129,7 +129,6 @@ dependencies {
implementation 'io.th0rgal:oraxen:1.94.0'
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.9'
// Shaded
implementation 'com.dfsek:Paralithic:0.4.0'

View File

@@ -74,6 +74,7 @@ public class IrisSettings {
public double targetSpawnEntitiesPerChunk = 0.95;
public boolean markerEntitySpawningSystem = true;
public boolean effectSystem = true;
public boolean worldEditWandCUI = true;
}
@Data

View File

@@ -229,7 +229,7 @@ public class CommandObject implements DecreeExecutor {
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2);
@@ -253,10 +253,8 @@ public class CommandObject implements DecreeExecutor {
return;
}
ItemStack wand = player().getInventory().getItemInMainHand();
if(WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
if(WandSVC.isHoldingWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if(!here) {
// TODO: WARNING HEIGHT
@@ -278,10 +276,8 @@ public class CommandObject implements DecreeExecutor {
return;
}
ItemStack wand = player().getInventory().getItemInMainHand();
if(WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
if(WandSVC.isHoldingIrisWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if(!here) {
// TODO: WARNING HEIGHT
@@ -364,7 +360,7 @@ public class CommandObject implements DecreeExecutor {
@Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force")
boolean overwrite
) {
IrisObject o = WandSVC.createSchematic(player().getInventory().getItemInMainHand());
IrisObject o = WandSVC.createSchematic(player());
if(o == null) {
sender().sendMessage(C.YELLOW + "You need to hold your wand!");
@@ -398,7 +394,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
@@ -430,15 +426,16 @@ public class CommandObject implements DecreeExecutor {
return;
}
Pair<Location, Location> locs = WorldEditLink.getSelection(sender().player());
if(locs.getFirst() == null)
sender().sendMessage(C.RED + "You don't have a WorldEdit selection!");
else if(locs.getSecond() == null)
sender().sendMessage(C.RED + "You need a valid WorldRegion selection in the current world!");
else {
sender().player().getInventory().addItem(WandSVC.createWand(locs.getFirst(), locs.getSecond()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
Cuboid locs = WorldEditLink.getSelection(sender().player());
if(locs == null)
{
sender().sendMessage(C.RED + "You don't have a WorldEdit selection in this world.");
return;
}
sender().player().getInventory().addItem(WandSVC.createWand(locs.getLowerNE(), locs.getUpperSW()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
}
@Decree(description = "Get an object wand", sync = true)
@@ -455,7 +452,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Location a1x = b[0].clone();
@@ -502,7 +499,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
b[0].add(new Vector(0, 1, 0));
b[1].add(new Vector(0, 1, 0));
Location a1 = b[0].clone();

View File

@@ -1,32 +1,37 @@
package com.volmit.iris.core.link;
import com.mojang.datafixers.util.Pair;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.MissingSessionException;
import org.bukkit.Location;
import com.volmit.iris.util.data.Cuboid;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class WorldEditLink {
public static Pair<Location, Location> getSelection(Player p) {
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(BukkitAdapter.adapt(p));
try {
if(session == null)
throw new MissingSessionException();
Region r = session.getSelection(BukkitAdapter.adapt(p.getWorld()));
BlockVector3 p1 = r.getMinimumPoint();
BlockVector3 p2 = r.getMaximumPoint();
return new Pair<>(new Location(p.getWorld(), p1.getX(), p1.getY(), p1.getZ()), new Location(p.getWorld(), p2.getX(), p2.getY(), p2.getZ()));
} catch(MissingSessionException e) {
return new Pair<>(null, new Location(null, 0, 0, 0));
} catch(IncompleteRegionException e) {
return new Pair<>(new Location(null, 0, 0, 0), null);
public static Cuboid getSelection(Player p)
{
try
{
Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null);
Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance);
Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p);
Object localSession = sessionManager.getClass().getDeclaredMethod("getIfPresent", Class.forName("com.sk89q.worldedit.session.SessionOwner")).invoke(sessionManager, player);
Object world = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", World.class).invoke(null, p.getWorld());
Object region = localSession.getClass().getDeclaredMethod("getSelection", world.getClass()).invoke(localSession, world);
Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region);
Object max = region.getClass().getDeclaredMethod("getMaximumPoint").invoke(region);
return new Cuboid(p.getWorld(),
(int)min.getClass().getDeclaredMethod("getX").invoke(min),
(int)min.getClass().getDeclaredMethod("getY").invoke(min),
(int)min.getClass().getDeclaredMethod("getZ").invoke(min),
(int)min.getClass().getDeclaredMethod("getX").invoke(max),
(int)min.getClass().getDeclaredMethod("getY").invoke(max),
(int)min.getClass().getDeclaredMethod("getZ").invoke(max)
);
}
catch(Throwable e)
{
}
return null;
}
}

View File

@@ -19,7 +19,9 @@
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.edit.DustRevealer;
import com.volmit.iris.core.link.WorldEditLink;
import com.volmit.iris.core.wand.WandSelection;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.util.collection.KList;
@@ -64,17 +66,17 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand
* The wand itemstack
* @param p
* The wand player
* @return The new object
*/
public static IrisObject createSchematic(ItemStack wand) {
if(!isWand(wand)) {
public static IrisObject createSchematic(Player p) {
if(!isHoldingWand(p)) {
return null;
}
try {
Location[] f = getCuboid(wand);
Location[] f = getCuboid(p);
Cuboid c = new Cuboid(f[0], f[1]);
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
for(Block b : c) {
@@ -98,17 +100,15 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand
* The wand itemstack
* @return The new object
*/
public static Matter createMatterSchem(Player p, ItemStack wand) {
if(!isWand(wand)) {
public static Matter createMatterSchem(Player p) {
if(!isHoldingWand(p)) {
return null;
}
try {
Location[] f = getCuboid(wand);
Location[] f = getCuboid(p);
return WorldMatter.createMatter(p.getName(), f[0], f[1]);
} catch(Throwable e) {
@@ -226,26 +226,32 @@ public class WandSVC implements IrisService {
return is;
}
/**
* Get a pair of locations that are selected in an Iris wand
*
* @param is
* The wand item
* @return An array with the 2 locations
*/
public static Location[] getCuboid(ItemStack is) {
public static Location[] getCuboidFromItem(ItemStack is) {
ItemMeta im = is.getItemMeta();
return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
}
/**
* Is a player holding an Iris wand
*
* @param p
* The player
* @return True if they are
*/
public static Location[] getCuboid(Player p) {
if(isHoldingIrisWand(p))
{
return getCuboidFromItem(p.getInventory().getItemInMainHand());
}
Cuboid c = WorldEditLink.getSelection(p);
if(c != null)
{
return new Location[] {c.getLowerNE(), c.getUpperSW()};
}
return null;
}
public static boolean isHoldingWand(Player p) {
return isHoldingIrisWand(p) || WorldEditLink.getSelection(p) != null;
}
public static boolean isHoldingIrisWand(Player p) {
ItemStack is = p.getInventory().getItemInMainHand();
return is != null && isWand(is);
}
@@ -286,8 +292,8 @@ public class WandSVC implements IrisService {
public void tick(Player p) {
try {
try {
if(isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
if((IrisSettings.get().getWorld().worldEditWandCUI && isHoldingWand(p)) || isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p);
new WandSelection(new Cuboid(d[0], d[1]), p).draw();
}
} catch(Throwable e) {
@@ -457,7 +463,7 @@ public class WandSVC implements IrisService {
return item;
}
Location[] f = getCuboid(item);
Location[] f = getCuboidFromItem(item);
Location other = left ? f[1] : f[0];
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) {

View File

@@ -80,7 +80,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
try {
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
Object biomeBase = INMS.get().getCustomBiomeBaseHolderFor(getDimension().getLoadKey() + ":" + custom.getId());
//
if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
throw new RuntimeException("Cant inject biome!");
}

View File

@@ -156,7 +156,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
} else {
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
}
}
}
}

View File

@@ -64,7 +64,7 @@ import java.util.function.Consumer;
@EqualsAndHashCode(callSuper = true)
@Data
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator {
private static final int LOAD_LOCKS = 1_000_000;
private static final int LOAD_LOCKS = Runtime.getRuntime().availableProcessors() * 4;
private final Semaphore loadLock;
private final IrisWorld world;
private final File dataLocation;

View File

@@ -21,10 +21,13 @@ package com.volmit.iris.util.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.IRare;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.NoiseInjector;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.arithmetic.FittedStream;
import com.volmit.iris.util.stream.sources.CNGStream;
@@ -120,7 +123,7 @@ public class CNG {
@Override
public double noise(double x, double z) {
return (cellularFilter.GetCellular((float) x, (float) z, str, 1) / 2D) + 0.5D;
return (cellularFilter.GetCellular((float) x, (float) z, str, 1) * 0.5) + 0.5D;
}
@Override
@@ -466,4 +469,18 @@ public class CNG {
public boolean isStatic() {
return generator != null && generator.isStatic();
}
public static void main(String[] a)
{
CNG cng = NoiseStyle.SIMPLEX.create(new RNG(1234));
PrecisionStopwatch p = PrecisionStopwatch.start();
double r = 0;
for(int i = 0; i < 30000000 * 10; i++)
{
r += cng.fit(-1000, 1000, i, i);
}
System.out.println(Form.duration(p.getMilliseconds(), 10) + " merged = " + r);
}
}