Dumb stuff

This commit is contained in:
cyberpwn 2022-04-17 04:11:50 -04:00
parent e9eeb8335d
commit 60a7f4bc35
8 changed files with 195 additions and 3 deletions

View File

@ -32,11 +32,13 @@ import com.volmit.iris.engine.EnginePanic;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCompat;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.engine.platform.DummyChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
@ -47,6 +49,8 @@ import com.volmit.iris.util.io.InstanceState;
import com.volmit.iris.util.io.JarScanner;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.Metrics;
@ -62,13 +66,16 @@ import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

View File

@ -25,6 +25,7 @@ import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.noise.ExpressionNoise;
@ -50,7 +51,6 @@ public class IrisGeneratorStyle {
@Desc("Cell zooms")
private double cellularZoom = 1;
@MinNumber(0.00001)
@Desc("The zoom of this style")
private double zoom = 1;

View File

@ -18,6 +18,7 @@
package com.volmit.iris.util.hunk;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.function.Consumer2;
@ -1254,6 +1255,12 @@ public interface Hunk<T> {
* the value
*/
default void set(int x, int y, int z, T t) {
if(!contains(x, y, z))
{
Iris.warn("OUT OF BOUNDS " + x + " " + y + " "+ z + " in bounds " + getWidth() + " " + getHeight() + " " + getDepth() );
return;
}
setRaw(x, y, z, t);
}
@ -1561,4 +1568,9 @@ public interface Hunk<T> {
default boolean contains(int x, int y, int z) {
return x < getWidth() && x >= 0 && y < getHeight() && y >= 0 && z < getDepth() && z >= 0;
}
default int volume()
{
return getWidth() * getDepth() * getHeight();
}
}

View File

@ -19,6 +19,7 @@
package com.volmit.iris.util.interpolation;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.Consumer2;
@ -1027,7 +1028,6 @@ public class IrisInterpolation {
return n.noise(x, z);
}
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) {
return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));
}

View File

@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
@ -59,11 +60,42 @@ import java.util.function.Function;
public interface Matter {
int VERSION = 1;
static long convert(File folder)
{
if(folder.isDirectory())
{
long v = 0;
for(File i : folder.listFiles())
{
v += convert(i);
}
return v;
}
else
{
IrisObject object = new IrisObject(1,1,1);
try {
long fs = folder.length();
object.read(folder);
Matter.from(object).write(folder);
Iris.info("Converted " + folder.getPath() + " Saved " + (fs - folder.length()));
} catch(Throwable e) {
Iris.error("Failed to convert " + folder.getPath());
e.printStackTrace();
}
}
return 0;
}
static Matter from(IrisObject object) {
object.clean();
object.shrinkwrap();
BlockVector min = new BlockVector();
Matter m = new IrisMatter(object.getW(), object.getH(), object.getD());
Matter m = new IrisMatter(Math.max(object.getW(), 1)+1, Math.max( object.getH(), 1)+1, Math.max( object.getD(), 1)+1);
for(BlockVector i : object.getBlocks().keySet()) {
min.setX(Math.min(min.getX(), i.getX()));

View File

@ -19,6 +19,7 @@
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.util.collection.KList;
import com.volmit.iris.util.function.NoiseInjector;
@ -129,6 +130,17 @@ public class CNG {
}, 1D, 1);
}
public CNG cached(int size)
{
if(size <= 0)
{
return this;
}
generator = new CachedNoise(generator, size);
return this;
}
public static CNG signature(RNG rng) {
return signature(rng, NoiseType.SIMPLEX);
}

View File

@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.noise;
import com.volmit.iris.util.math.RNG;
public class CachedNoise implements NoiseGenerator {
private final CachedNoiseMap n;
public CachedNoise(NoiseGenerator generator, int size) {
n = new CachedNoiseMap(size, generator);
}
@Override
public double noise(double x) {
return n.get((int)Math.round(x), 0);
}
@Override
public double noise(double x, double z) {
return n.get((int)Math.round(x),(int)Math.round(z));
}
@Override
public double noise(double x, double y, double z) {
return n.get((int)Math.round(x),(int)Math.round(z));
}
}

View File

@ -0,0 +1,85 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.noise;
import com.volmit.iris.util.hunk.bits.Writable;
import com.volmit.iris.util.interpolation.InterpolationMethod;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.MatterSlice;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
public class CachedNoiseMap implements Writable<Integer> {
private final Matter noise;
private final MatterSlice<Integer> slice;
public CachedNoiseMap(int size, NoiseGenerator cng)
{
noise = new IrisMatter(size, size, 1);
slice = noise.slice(Integer.class);
for(int i = 0; i < slice.getWidth(); i++)
{
for(int j = 0; j < slice.getHeight(); j++)
{
set(i, j, cng.noise(i, j));
}
}
}
public CachedNoiseMap(File file) throws IOException, ClassNotFoundException {
noise = Matter.read(file);
slice = noise.slice(Integer.class);
}
void write(File file) throws IOException {
noise.write(file);
}
void set(int x, int y, double value)
{
slice.set(x%slice.getWidth(), y%slice.getHeight(), 0, Float.floatToIntBits((float)value));
}
double get(int x, int y)
{
Integer i = slice.get(x%slice.getWidth(), y%slice.getHeight(), 0);
if(i == null)
{
return 0;
}
return Float.intBitsToFloat(i);
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return din.readInt();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeInt(integer);
}
}