9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-25 18:19:14 +00:00
This commit is contained in:
Brian Fopiano
2022-12-19 20:36:36 -05:00
parent 4ce790082d
commit 9731feff7f
15 changed files with 174 additions and 246 deletions

View File

@@ -48,7 +48,6 @@ import java.io.File;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.*;
import java.util.stream.Collectors;
@Decree(name = "object", aliases = "o", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris object manipulation")
public class CommandObject implements DecreeExecutor {
@@ -167,7 +166,7 @@ public class CommandObject implements DecreeExecutor {
}
List<Material> sortedMatsList = amounts.keySet().stream().map(BlockData::getMaterial)
.sorted().collect(Collectors.toList());
.sorted().toList();
Set<Material> sortedMats = new TreeSet<>(Comparator.comparingInt(materials::get).reversed());
sortedMats.addAll(sortedMatsList);
sender().sendMessage("== Blocks in object ==");
@@ -216,6 +215,9 @@ public class CommandObject implements DecreeExecutor {
Location[] b = WandSVC.getCuboid(player());
if (b == null) {
return;
}
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2);
@@ -242,6 +244,9 @@ public class CommandObject implements DecreeExecutor {
if (WandSVC.isHoldingWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if (g == null) {
return;
}
if (!here) {
// TODO: WARNING HEIGHT
g[1] = player().getTargetBlock(null, 256).getLocation().clone();
@@ -265,6 +270,10 @@ public class CommandObject implements DecreeExecutor {
if (WandSVC.isHoldingIrisWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if (g == null) {
return;
}
if (!here) {
// TODO: WARNING HEIGHT
g[0] = player().getTargetBlock(null, 256).getLocation().clone();
@@ -383,6 +392,9 @@ public class CommandObject implements DecreeExecutor {
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
if (d == null) {
return; // HOW DID THIS HAPPEN
}
a1.add(d.toVector().multiply(amount));
a2.add(d.toVector().multiply(amount));
Cuboid cursor = new Cuboid(a1, a2);

View File

@@ -162,11 +162,11 @@ public class JigsawEditor implements Listener {
removeKey(o.getJSONObject(path[0]), s.toArray(new String[0]));
}
private List<JSONObject> getObjectsInArray(JSONObject a, String key) {
private List<JSONObject> getObjectsInArray(JSONObject a) { // This gets all the objects in an array that are connectors
KList<JSONObject> o = new KList<>();
for (int i = 0; i < a.getJSONArray(key).length(); i++) {
o.add(a.getJSONArray(key).getJSONObject(i));
for (int i = 0; i < a.getJSONArray("connectors").length(); i++) {
o.add(a.getJSONArray("connectors").getJSONObject(i));
}
return o;
@@ -185,7 +185,7 @@ public class JigsawEditor implements Listener {
j.remove("placementOptions"); // otherwise
// Remove key in all objects in array
for (JSONObject i : getObjectsInArray(j, "connectors")) {
for (JSONObject i : getObjectsInArray(j)) {
removeKey(i, "rotateConnector");
}

View File

@@ -277,8 +277,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List
Color color = colorMode ? Color.getHSBColor((float) (n), 1f - (float) (n * n * n * n * n * n), 1f - (float) n) : Color.getHSBColor(0f, 0f, (float) n);
int rgb = color.getRGB();
img.setRGB(xx, z, rgb);
} catch (Throwable xxx) {
} catch (Throwable ignored) {
}
}
});

View File

@@ -154,12 +154,10 @@ public class PregeneratorJob implements PregenListener {
}
public void drawRegion(int x, int z, Color color) {
J.a(() -> {
PregenTask.iterateRegion(x, z, (xx, zz) -> {
draw(xx, zz, color);
J.sleep(3);
});
});
J.a(() -> PregenTask.iterateRegion(x, z, (xx, zz) -> {
draw(xx, zz, color);
J.sleep(3);
}));
}
public void draw(int x, int z, Color color) {
@@ -168,7 +166,7 @@ public class PregeneratorJob implements PregenListener {
renderer.func.accept(new Position2(x, z), color);
}
} catch (Throwable ignored) {
Iris.error("Failed to draw pregen");
}
}
@@ -186,8 +184,8 @@ public class PregeneratorJob implements PregenListener {
monitor.close();
J.sleep(3000);
frame.setVisible(false);
} catch (Throwable e) {
} catch (Throwable ignored) {
Iris.error("Error closing pregen gui");
}
});
}
@@ -209,8 +207,8 @@ public class PregeneratorJob implements PregenListener {
frame.add(renderer);
frame.setSize(1000, 1000);
frame.setVisible(true);
} catch (Throwable e) {
} catch (Throwable ignored) {
Iris.error("Error opening pregen gui");
}
});
}

View File

@@ -25,7 +25,6 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.function.BiFunction;
@SuppressWarnings("ClassCanBeRecord")
public class IrisRenderer {
private final Engine renderer;

View File

@@ -25,21 +25,22 @@ import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
// See/update https://app.gitbook.com/@volmitsoftware/s/iris/compatability/papi/
public class IrisPapiExpansion extends PlaceholderExpansion {
@Override
public String getIdentifier() {
public @NotNull String getIdentifier() {
return "iris";
}
@Override
public String getAuthor() {
public @NotNull String getAuthor() {
return "Volmit Software";
}
@Override
public String getVersion() {
public @NotNull String getVersion() {
return Iris.instance.getDescription().getVersion();
}

View File

@@ -1,5 +1,6 @@
package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.util.data.Cuboid;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -23,8 +24,8 @@ public class WorldEditLink {
(int) min.getClass().getDeclaredMethod("getY").invoke(max),
(int) min.getClass().getDeclaredMethod("getZ").invoke(max)
);
} catch (Throwable e) {
} catch (Throwable ignored) {
Iris.error("Failed to get WorldEdit Selection");
}
return null;

View File

@@ -29,6 +29,7 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Set;
public class ImageResourceLoader extends ResourceLoader<IrisImage> {
public ImageResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
@@ -66,6 +67,17 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
}
}
void getPNGFiles(File directory, Set<String> m) {
for (File file : directory.listFiles()) {
if (file.isFile() && file.getName().endsWith(".png")) {
m.add(file.getName().replaceAll("\\Q.png\\E", ""));
} else if (file.isDirectory()) {
getPNGFiles(file, m);
}
}
}
public String[] getPossibleKeys() {
if (possibleKeys != null) {
return possibleKeys;
@@ -74,26 +86,31 @@ public class ImageResourceLoader extends ResourceLoader<IrisImage> {
Iris.debug("Building " + resourceTypeName + " Possibility Lists");
KSet<String> m = new KSet<>();
for (File i : getFolders()) {
for (File j : i.listFiles()) {
if (j.isFile() && j.getName().endsWith(".png")) {
m.add(j.getName().replaceAll("\\Q.png\\E", ""));
} else if (j.isDirectory()) {
for (File k : j.listFiles()) {
if (k.isFile() && k.getName().endsWith(".png")) {
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.png\\E", ""));
} else if (k.isDirectory()) {
for (File l : k.listFiles()) {
if (l.isFile() && l.getName().endsWith(".png")) {
m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.png\\E", ""));
}
}
}
}
}
}
getPNGFiles(i, m);
}
// for (File i : getFolders()) {
// for (File j : i.listFiles()) {
// if (j.isFile() && j.getName().endsWith(".png")) {
// m.add(j.getName().replaceAll("\\Q.png\\E", ""));
// } else if (j.isDirectory()) {
// for (File k : j.listFiles()) {
// if (k.isFile() && k.getName().endsWith(".png")) {
// m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.png\\E", ""));
// } else if (k.isDirectory()) {
// for (File l : k.listFiles()) {
// if (l.isFile() && l.getName().endsWith(".png")) {
// m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.png\\E", ""));
// }
// }
// }
// }
// }
// }
// }
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
return possibleKeys;

View File

@@ -369,8 +369,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
}
}
String ff = g.substring(1).split("\\Q.\\E")[0];
return ff;
return g.substring(1).split("\\Q.\\E")[0];
} else {
Iris.error("Forign file from loader " + f.getPath() + " (loader realm: " + getDataFolder().getPath() + ")");
}

View File

@@ -29,6 +29,8 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import java.io.File;
public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject> {
private String[] possibleKeys;
public MatterObjectResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
super(root, idm, folderName, resourceTypeName, IrisMatterObject.class);
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getObjectLoaderCacheSize());
@@ -63,6 +65,16 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
}
}
private void findMatFiles(File dir, KSet<String> m) {
for (File file : dir.listFiles()) {
if (file.isFile() && file.getName().endsWith(".mat")) {
m.add(file.getName().replaceAll("\\Q.mat\\E", ""));
} else if (file.isDirectory()) {
findMatFiles(file, m);
}
}
}
public String[] getPossibleKeys() {
if (possibleKeys != null) {
return possibleKeys;
@@ -71,24 +83,8 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
Iris.debug("Building " + resourceTypeName + " Possibility Lists");
KSet<String> m = new KSet<>();
for (File i : getFolders()) {
for (File j : i.listFiles()) {
if (j.isFile() && j.getName().endsWith(".mat")) {
m.add(j.getName().replaceAll("\\Q.mat\\E", ""));
} else if (j.isDirectory()) {
for (File k : j.listFiles()) {
if (k.isFile() && k.getName().endsWith(".mat")) {
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.mat\\E", ""));
} else if (k.isDirectory()) {
for (File l : k.listFiles()) {
if (l.isFile() && l.getName().endsWith(".mat")) {
m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.mat\\E", ""));
}
}
}
}
}
}
for (File folder : getFolders()) {
findMatFiles(folder, m);
}
KList<String> v = new KList<>(m);
@@ -96,6 +92,40 @@ public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject>
return possibleKeys;
}
// public String[] getPossibleKeys() {
// if (possibleKeys != null) {
// return possibleKeys;
// }
//
// Iris.debug("Building " + resourceTypeName + " Possibility Lists");
// KSet<String> m = new KSet<>();
//
// for (File i : getFolders()) {
// for (File j : i.listFiles()) {
// if (j.isFile() && j.getName().endsWith(".mat")) {
// m.add(j.getName().replaceAll("\\Q.mat\\E", ""));
// } else if (j.isDirectory()) {
// for (File k : j.listFiles()) {
// if (k.isFile() && k.getName().endsWith(".mat")) {
// m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.mat\\E", ""));
// } else if (k.isDirectory()) {
// for (File l : k.listFiles()) {
// if (l.isFile() && l.getName().endsWith(".mat")) {
// m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.mat\\E", ""));
// }
// }
// }
// }
// }
// }
// }
//
// KList<String> v = new KList<>(m);
// possibleKeys = v.toArray(new String[0]);
// return possibleKeys;
// }
public File findFile(String name) {
for (File i : getFolders(name)) {
for (File j : i.listFiles()) {

View File

@@ -21,13 +21,13 @@ package com.volmit.iris.core.loader;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.engine.object.IrisScript;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.KCache;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
public ScriptResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
@@ -60,39 +60,70 @@ public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
}
}
public String[] getPossibleKeys() {
if (possibleKeys != null) {
return possibleKeys;
}
Iris.debug("Building " + resourceTypeName + " Possibility Lists");
KSet<String> m = new KSet<>();
Set<String> keys = new HashSet<>();
for (File i : getFolders()) {
for (File j : i.listFiles()) {
if (j.isFile() && j.getName().endsWith(".js")) {
m.add(j.getName().replaceAll("\\Q.js\\E", ""));
} else if (j.isDirectory()) {
for (File k : j.listFiles()) {
if (k.isFile() && k.getName().endsWith(".js")) {
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.js\\E", ""));
} else if (k.isDirectory()) {
for (File l : k.listFiles()) {
if (l.isFile() && l.getName().endsWith(".js")) {
m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.js\\E", ""));
}
}
}
}
}
if (i.isDirectory()) {
keys.addAll(getKeysInDirectory(i));
}
}
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
possibleKeys = keys.toArray(new String[0]);
return possibleKeys;
}
private Set<String> getKeysInDirectory(File directory) {
Set<String> keys = new HashSet<>();
for (File file : directory.listFiles()) {
if (file.isFile() && file.getName().endsWith(".js")) {
keys.add(file.getName().replaceAll("\\Q.js\\E", ""));
} else if (file.isDirectory()) {
keys.addAll(getKeysInDirectory(file));
}
}
return keys;
}
// public String[] getPossibleKeys() {
// if (possibleKeys != null) {
// return possibleKeys;
// }
//
// Iris.debug("Building " + resourceTypeName + " Possibility Lists");
// KSet<String> m = new KSet<>();
//
// for (File i : getFolders()) {
// for (File j : i.listFiles()) {
// if (j.isFile() && j.getName().endsWith(".js")) {
// m.add(j.getName().replaceAll("\\Q.js\\E", ""));
// } else if (j.isDirectory()) {
// for (File k : j.listFiles()) {
// if (k.isFile() && k.getName().endsWith(".js")) {
// m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.js\\E", ""));
// } else if (k.isDirectory()) {
// for (File l : k.listFiles()) {
// if (l.isFile() && l.getName().endsWith(".js")) {
// m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.js\\E", ""));
// }
// }
// }
// }
// }
// }
// }
//
// KList<String> v = new KList<>(m);
// possibleKeys = v.toArray(new String[0]);
// return possibleKeys;
// }
public File findFile(String name) {
for (File i : getFolders(name)) {
for (File j : i.listFiles()) {

View File

@@ -1,159 +0,0 @@
/*
* 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.core.nms;
import com.volmit.iris.Iris;
import java.util.ArrayList;
import java.util.List;
public enum NMSVersion {
R1_19_1,
R1_18_2,
R1_18,
R1_17,
R1_16,
R1_15,
R1_14,
R1_13,
R1_13_1,
R1_12,
R1_11,
R1_10,
R1_9_4,
R1_9_2,
R1_8;
public static NMSVersion getMinimum() {
return values()[values().length - 1];
}
public static NMSVersion getMaximum() {
return values()[0];
}
public static NMSVersion current() {
if (tryVersion("1_8_R3")) {
return R1_8;
}
if (tryVersion("1_9_R1")) {
return R1_9_2;
}
if (tryVersion("1_9_R2")) {
return R1_9_4;
}
if (tryVersion("1_10_R1")) {
return R1_10;
}
if (tryVersion("1_11_R1")) {
return R1_11;
}
if (tryVersion("1_12_R1")) {
return R1_12;
}
if (tryVersion("1_13_R1")) {
return R1_13;
}
if (tryVersion("1_13_R2")) {
return R1_13_1;
}
if (tryVersion("1_14_R1")) {
return R1_14;
}
if (tryVersion("1_15_R1")) {
return R1_15;
}
if (tryVersion("1_16_R1")) {
return R1_16;
}
if (tryVersion("1_17_R1")) {
return R1_17;
}
if (tryVersion("1_18_R1")) {
return R1_18;
}
if (tryVersion("1_18_R2")) {
return R1_18_2;
}
if (tryVersion("1_19_R1")) {
return R1_19_1;
}
return null;
}
private static boolean tryVersion(String v) {
try {
Class.forName("org.bukkit.craftbukkit.v" + v + ".CraftWorld");
return true;
} catch (Throwable e) {
Iris.reportError(e);
}
return false;
}
public List<NMSVersion> getAboveInclusive() {
List<NMSVersion> n = new ArrayList<>();
for (NMSVersion i : values()) {
if (i.ordinal() >= ordinal()) {
n.add(i);
}
}
return n;
}
public List<NMSVersion> betweenInclusive(NMSVersion other) {
List<NMSVersion> n = new ArrayList<>();
for (NMSVersion i : values()) {
if (i.ordinal() <= Math.max(other.ordinal(), ordinal()) && i.ordinal() >= Math.min(ordinal(), other.ordinal())) {
n.add(i);
}
}
return n;
}
public List<NMSVersion> getBelowInclusive() {
List<NMSVersion> n = new ArrayList<>();
for (NMSVersion i : values()) {
if (i.ordinal() <= ordinal()) {
n.add(i);
}
}
return n;
}
}

View File

@@ -38,8 +38,8 @@ public class WandSelection {
}
public void draw() {
double accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(c.getCenter()));
double dist = M.lerp(0.125, 3.5, accuracy);
double accuracy;
double dist;
for (double i = c.getLowerX() - 1; i < c.getUpperX() + 1; i += 0.25) {
for (double j = c.getLowerY() - 1; j < c.getUpperY() + 1; j += 0.25) {

View File

@@ -83,7 +83,7 @@ public class Spiral implements Iterable<Position2> {
@NotNull
@Override
public Iterator<Position2> iterator() {
return new SpiralIterator( this, 0, start);
return new SpiralIterator(this, 0, start);
}
@AllArgsConstructor