From ef23d6d51a111fbd70de2db8db1ee67f99c4c3ea Mon Sep 17 00:00:00 2001 From: DanMB Date: Thu, 30 Dec 2021 19:56:37 -0800 Subject: [PATCH 01/42] Test --- build.gradle | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 572b0d128..e03e8b0f0 100644 --- a/build.gradle +++ b/build.gradle @@ -19,11 +19,13 @@ plugins { id 'java' id 'io.freefair.lombok' version '5.2.1' id "com.github.johnrengelman.shadow" version "7.0.0" + id "de.undercouch.download" version "4.1.2" } group 'com.volmit.iris' -version '1.9.6-1.17.X' -def apiVersion = '1.17' +version '1.9.7-1.18.X' +def nmsVersion = "1.18.1" +def apiVersion = '1.18' def name = getRootProject().getName() // Defined in settings.gradle def main = 'com.volmit.iris.Iris' @@ -147,11 +149,12 @@ dependencies { // Provided or Classpath compileOnly 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22' - implementation 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT' - implementation 'org.bukkit.craftbukkit:1.17.1:1.17.1' + implementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT' implementation 'me.clip:placeholderapi:2.10.10' implementation 'io.th0rgal:oraxen:1.94.0' + compileOnly 'org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:remapped-mojang' + // Shaded implementation 'com.dfsek:Paralithic:0.4.0' implementation 'io.papermc:paperlib:1.0.5' @@ -172,3 +175,26 @@ dependencies { implementation 'com.github.ben-manes.caffeine:caffeine:3.0.5' implementation 'org.apache.commons:commons-lang3:3.12.0' } + +def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar"); +def buildToolsFolder = new File(buildDir, "buildtools"); + +// ======================== Building Mapped Jars ============================= +task downloadBuildtools(type: Download) { + src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar' + dest buildToolsJar +} + +task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) +{ + classpath = files(buildToolsJar) + workingDir = buildToolsFolder + args = [ + "--rev", + nmsVersion, + "--compile", + "craftbukkit", + "--compile-if-changed", + "--remap" + ] +} \ No newline at end of file From b40a86e114c76464f3008d6c03ef12d726e0637b Mon Sep 17 00:00:00 2001 From: DanMB Date: Thu, 30 Dec 2021 20:07:30 -0800 Subject: [PATCH 02/42] Update gradle --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f78c2786..0abd22c41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -17,6 +17,6 @@ # distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file From e66e6e0b512a5a1773d02fa00c176731fec318bb Mon Sep 17 00:00:00 2001 From: DanMB Date: Thu, 30 Dec 2021 20:07:39 -0800 Subject: [PATCH 03/42] Print java version --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index e03e8b0f0..2e5f46104 100644 --- a/build.gradle +++ b/build.gradle @@ -176,6 +176,7 @@ dependencies { implementation 'org.apache.commons:commons-lang3:3.12.0' } +System.out.println("Gradle is using Java: " + JavaVersion.current()); def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar"); def buildToolsFolder = new File(buildDir, "buildtools"); From ffc1d01a0af16914c1fa7e46a9f3dd7a80366315 Mon Sep 17 00:00:00 2001 From: DanMB Date: Thu, 30 Dec 2021 20:15:36 -0800 Subject: [PATCH 04/42] Build tools exec fixes --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index 2e5f46104..739a62dfd 100644 --- a/build.gradle +++ b/build.gradle @@ -178,6 +178,7 @@ dependencies { System.out.println("Gradle is using Java: " + JavaVersion.current()); def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar"); +def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar"); def buildToolsFolder = new File(buildDir, "buildtools"); // ======================== Building Mapped Jars ============================= @@ -186,6 +187,11 @@ task downloadBuildtools(type: Download) { dest buildToolsJar } +task downloadSpecialSource(type: Download){ + src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar' + dest specialSourceJar +} + task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) { classpath = files(buildToolsJar) From 9c5966c49c0cb806494269fc48a75bbd7d164ad1 Mon Sep 17 00:00:00 2001 From: DanMB Date: Thu, 30 Dec 2021 20:58:43 -0800 Subject: [PATCH 05/42] Im about to just throw the entire spigot jar into the cp fuck md5 --- build.gradle | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 739a62dfd..efe0bacb4 100644 --- a/build.gradle +++ b/build.gradle @@ -101,8 +101,15 @@ processResources { * Unified repo */ repositories { + mavenLocal{ + content{ + includeGroup("org.bukkit") + includeGroup("org.spigotmc") + } + } maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" } mavenCentral() + mavenLocal() } /** @@ -152,8 +159,8 @@ dependencies { implementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT' implementation 'me.clip:placeholderapi:2.10.10' implementation 'io.th0rgal:oraxen:1.94.0' - - compileOnly 'org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:remapped-mojang' + compileOnly 'org.bukkit:craftbukkit:1.18.1-R0.1-SNAPSHOT:remapped-mojang' + compileOnly 'org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:remapped-mojang' // Shaded implementation 'com.dfsek:Paralithic:0.4.0' @@ -185,11 +192,17 @@ def buildToolsFolder = new File(buildDir, "buildtools"); task downloadBuildtools(type: Download) { src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar' dest buildToolsJar + onlyIf{ + !buildToolsJar.exists() + } } task downloadSpecialSource(type: Download){ src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar' dest specialSourceJar + onlyIf{ + !specialSourceJar.exists() + } } task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) @@ -201,7 +214,11 @@ task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) nmsVersion, "--compile", "craftbukkit", - "--compile-if-changed", "--remap" ] -} \ No newline at end of file + onlyIf{ + !buildToolsFolder.exists() + } +} + +tasks.compileJava.dependsOn(executeBuildTools) \ No newline at end of file From a63a3a8fa5e8f674d4e199989d4e98a2d93ca688 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 21:05:58 -0500 Subject: [PATCH 06/42] Handle new mappings for now --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index efe0bacb4..2f266ac21 100644 --- a/build.gradle +++ b/build.gradle @@ -159,8 +159,7 @@ dependencies { implementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT' implementation 'me.clip:placeholderapi:2.10.10' implementation 'io.th0rgal:oraxen:1.94.0' - compileOnly 'org.bukkit:craftbukkit:1.18.1-R0.1-SNAPSHOT:remapped-mojang' - compileOnly 'org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:remapped-mojang' + implementation 'org.bukkit:craftbukkit:1.18.1-R0.1-SNAPSHOT:remapped-mojang' // Shaded implementation 'com.dfsek:Paralithic:0.4.0' @@ -187,6 +186,7 @@ System.out.println("Gradle is using Java: " + JavaVersion.current()); def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar"); def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar"); def buildToolsFolder = new File(buildDir, "buildtools"); +def buildToolsHint = new File(buildDir, "buildtools/craftbukkit-" + nmsVersion + ".jar"); // ======================== Building Mapped Jars ============================= task downloadBuildtools(type: Download) { @@ -217,7 +217,7 @@ task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) "--remap" ] onlyIf{ - !buildToolsFolder.exists() + !buildToolsHint.exists() } } From 878c39413aa5b5036b8eb4443a69bc9cb46efab5 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 21:06:05 -0500 Subject: [PATCH 07/42] A good nms start for 1.18 --- .../iris/core/nms/v18_1/NMSBinding18_1.java | 295 ++++++++++++++++++ 1 file changed, 295 insertions(+) create mode 100644 src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java new file mode 100644 index 000000000..80b065ebc --- /dev/null +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -0,0 +1,295 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 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 . + */ + +package com.volmit.iris.core.nms.v18_1; + + +import com.volmit.iris.Iris; +import com.volmit.iris.core.nms.INMSBinding; +import com.volmit.iris.engine.data.cache.AtomicCache; +import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.nbt.io.NBTUtil; +import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer; +import com.volmit.iris.util.nbt.mca.palette.MCAChunkBiomeContainer; +import com.volmit.iris.util.nbt.mca.palette.MCAIdMap; +import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; +import com.volmit.iris.util.nbt.tag.CompoundTag; +import net.minecraft.core.Registry; +import net.minecraft.nbt.NbtIo; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.v1_18_R1.CraftServer; +import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.entity.Entity; +import org.bukkit.generator.ChunkGenerator; +import org.jetbrains.annotations.NotNull; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.util.Iterator; +import java.util.concurrent.atomic.AtomicInteger; + +public class NMSBinding18_1 implements INMSBinding { + + private final KMap baseBiomeCache = new KMap<>(); + private final AtomicCache> biomeMapCache = new AtomicCache<>(); + + @Override + public boolean hasTile(Location l) { + return ((CraftWorld) l.getWorld()).getHandle().getBlockEntity(new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null; + } + + @Override + public CompoundTag serializeTile(Location location) { + BlockEntity e = ((CraftWorld) location.getWorld()).getHandle().getBlockEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true); + + if (e == null) { + return null; + } + + net.minecraft.nbt.CompoundTag tag = e.saveWithFullMetadata(); + return convert(tag); + } + + private CompoundTag convert(net.minecraft.nbt.CompoundTag tag) { + try { + ByteArrayOutputStream boas = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(boas); + tag.write(dos); + dos.close(); + return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag(); + } catch (Throwable ex) { + ex.printStackTrace(); + } + + return null; + } + + private net.minecraft.nbt.CompoundTag convert(CompoundTag tag) { + try { + ByteArrayOutputStream boas = new ByteArrayOutputStream(); + NBTUtil.write(tag, boas, false); + DataInputStream din = new DataInputStream(new ByteArrayInputStream(boas.toByteArray())); + net.minecraft.nbt.CompoundTag c = NbtIo.read(din); + din.close(); + return c; + } catch (Throwable e) { + e.printStackTrace(); + } + + return null; + } + + @Override + public void deserializeTile(CompoundTag c, Location newPosition) { + ((CraftWorld) newPosition.getWorld()).getHandle().getChunkAt(new BlockPos(newPosition.getBlockX(), 0, newPosition.getBlockZ())).setBlockEntityNbt(convert(c)); + } + + @Override + public CompoundTag serializeEntity(Entity location) { + return null;// TODO: + } + + @Override + public Entity deserializeEntity(CompoundTag s, Location newPosition) { + return null;// TODO: + } + + @Override + public boolean supportsCustomHeight() { + return true; + } + + private Registry getCustomBiomeRegistry() { + return ((CraftServer) Bukkit.getServer()).getHandle().getServer().registryHolder.registry(Registry.BIOME_REGISTRY).orElse(null); + } + + @Override + public Object getBiomeBaseFromId(int id) { + return getCustomBiomeRegistry().byId(id); + } + + @Override + public int getMinHeight(World world) { + return world.getMinHeight(); + } + + @Override + public boolean supportsCustomBiomes() { + return true; + } + + @Override + public int getTrueBiomeBaseId(Object biomeBase) { + return getCustomBiomeRegistry().getId((net.minecraft.world.level.biome.Biome) biomeBase); + } + + @Override + public Object getTrueBiomeBase(Location location) { + return ((CraftWorld) location.getWorld()).getHandle().getBiome(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ())); + } + + @Override + public String getTrueBiomeBaseKey(Location location) { + return getKeyForBiomeBase(getTrueBiomeBase(location)); + } + + @Override + public Object getCustomBiomeBaseFor(String mckey) { + return null; + } + + @Override + public String getKeyForBiomeBase(Object biomeBase) { + return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something + } + + @Override + public Object getBiomeBase(World world, Biome biome) { + return getBiomeBase(((CraftWorld)world).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null), biome); + } + + @Override + public Object getBiomeBase(Object registry, Biome biome) { + Object v = baseBiomeCache.get(biome); + + if (v != null) { + return v; + } + //noinspection unchecked + v = org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry) registry, biome); + if (v == null) { + // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. + // But, this does NOT exist within CraftBukkit which makes it return an error. + // So, we will just return the ID that the plains biome returns instead. + //noinspection unchecked + return org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry) registry, Biome.PLAINS); + } + baseBiomeCache.put(biome, v); + return v; + } + + @Override + public boolean isBukkit() { + return true; + } + + @Override + public int getBiomeId(Biome biome) { + for (World i : Bukkit.getWorlds()) { + if (i.getEnvironment().equals(World.Environment.NORMAL)) { + Registry registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null); + return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome)); + } + } + + return biome.ordinal(); + } + + private MCAIdMap getBiomeMapping() { + return biomeMapCache.aquire(() -> new MCAIdMap<>() { + @NotNull + @Override + public Iterator iterator() { + return getCustomBiomeRegistry().iterator(); + } + + @Override + public int getId(net.minecraft.world.level.biome.Biome paramT) { + return getCustomBiomeRegistry().getId(paramT); + } + + @Override + public net.minecraft.world.level.biome.Biome byId(int paramInt) { + return getCustomBiomeRegistry().fromId(paramInt); + } + }); + } + + @NotNull + private MCABiomeContainer getBiomeContainerInterface(MCAIdMap biomeMapping, MCAChunkBiomeContainer base) { + return new MCABiomeContainer() { + @Override + public int[] getData() { + return base.writeBiomes(); + } + + @Override + public void setBiome(int x, int y, int z, int id) { + base.setBiome(x, y, z, biomeMapping.byId(id)); + } + + @Override + public int getBiome(int x, int y, int z) { + return biomeMapping.getId(base.getBiome(x, y, z)); + } + }; + } + + @Override + public MCABiomeContainer newBiomeContainer(int min, int max) { + MCAChunkBiomeContainer base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max); + return getBiomeContainerInterface(getBiomeMapping(), base); + } + + @Override + public MCABiomeContainer newBiomeContainer(int min, int max, int[] data) { + MCAChunkBiomeContainer base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max, data); + return getBiomeContainerInterface(getBiomeMapping(), base); + } + + @Override + public int countCustomBiomes() { + AtomicInteger a = new AtomicInteger(0); + + getCustomBiomeRegistry().keySet().forEach((i) -> { + if (i.getNamespace().equals("minecraft")) { + return; + } + + a.incrementAndGet(); + Iris.debug("Custom Biome: " + i); + }); + + return a.get(); + } + + @Override + public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { + try { + + BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); + s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); + } catch (IllegalAccessException e) { + Iris.reportError(e); + e.printStackTrace(); + } + } + + @Override + public MCAPaletteAccess createPalette() { + return null; + } +} From 136ea445096161068e258c7b9da0a085e715b6a5 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 23:20:24 -0500 Subject: [PATCH 08/42] NMS Stuff --- .../iris/core/nms/v18_1/NMSBinding18_1.java | 78 +++++++++++++++++-- .../util/nbt/mca/palette/MCAIdMapper.java | 27 ++++++- 2 files changed, 96 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index 80b065ebc..ecaab0e6b 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -24,22 +24,37 @@ import com.volmit.iris.core.nms.INMSBinding; import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.nbt.io.NBTUtil; +import com.volmit.iris.util.nbt.mca.NBTWorld; import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer; import com.volmit.iris.util.nbt.mca.palette.MCAChunkBiomeContainer; +import com.volmit.iris.util.nbt.mca.palette.MCAGlobalPalette; import com.volmit.iris.util.nbt.mca.palette.MCAIdMap; +import com.volmit.iris.util.nbt.mca.palette.MCAIdMapper; +import com.volmit.iris.util.nbt.mca.palette.MCAPalette; import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; +import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer; +import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; import com.volmit.iris.util.nbt.tag.CompoundTag; +import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.core.Registry; import net.minecraft.nbt.NbtIo; import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.v1_18_R1.CraftChunk; import org.bukkit.craftbukkit.v1_18_R1.CraftServer; import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_18_R1.generator.CustomChunkGenerator; import org.bukkit.entity.Entity; import org.bukkit.generator.ChunkGenerator; import org.jetbrains.annotations.NotNull; @@ -48,13 +63,20 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; +import java.lang.reflect.Field; +import java.util.IdentityHashMap; import java.util.Iterator; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; public class NMSBinding18_1 implements INMSBinding { private final KMap baseBiomeCache = new KMap<>(); + private final BlockData AIR = Material.AIR.createBlockData(); private final AtomicCache> biomeMapCache = new AtomicCache<>(); + private final AtomicCache> registryCache = new AtomicCache<>(); + private final AtomicCache> globalCache = new AtomicCache<>(); + private Field biomeStorageCache = null; @Override public boolean hasTile(Location l) { @@ -126,6 +148,10 @@ public class NMSBinding18_1 implements INMSBinding { return ((CraftServer) Bukkit.getServer()).getHandle().getServer().registryHolder.registry(Registry.BIOME_REGISTRY).orElse(null); } + private Registry getBlockRegistry() { + return ((CraftServer) Bukkit.getServer()).getHandle().getServer().registryHolder.registry(Registry.BLOCK_REGISTRY).orElse(null); + } + @Override public Object getBiomeBaseFromId(int id) { return getCustomBiomeRegistry().byId(id); @@ -223,7 +249,7 @@ public class NMSBinding18_1 implements INMSBinding { @Override public net.minecraft.world.level.biome.Biome byId(int paramInt) { - return getCustomBiomeRegistry().fromId(paramInt); + return getCustomBiomeRegistry().byId(paramInt); } }); } @@ -279,17 +305,57 @@ public class NMSBinding18_1 implements INMSBinding { @Override public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { try { - - BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); - s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); + ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk); + s.setBiome(x, y, z, (net.minecraft.world.level.biome.Biome) somethingVeryDirty); } catch (IllegalAccessException e) { Iris.reportError(e); e.printStackTrace(); } } - @Override - public MCAPaletteAccess createPalette() { + private Field getFieldForBiomeStorage(Object storage) { + Field f = biomeStorageCache; + + if (f != null) { + return f; + } + try { + + f = storage.getClass().getDeclaredField("biome"); + f.setAccessible(true); + return f; + } catch (Throwable e) { + Iris.reportError(e); + e.printStackTrace(); + Iris.error(storage.getClass().getCanonicalName()); + } + + biomeStorageCache = f; return null; } + + @Override + public MCAPaletteAccess createPalette() { + MCAIdMapper registry = registryCache.aquireNasty(() -> { + Field cf = net.minecraft.core.IdMapper.class.getDeclaredField("tToId"); + Field df = net.minecraft.core.IdMapper.class.getDeclaredField("idToT"); + Field bf = net.minecraft.core.IdMapper.class.getDeclaredField("nextId"); + cf.setAccessible(true); + df.setAccessible(true); + bf.setAccessible(true); + net.minecraft.core.IdMapper blockData = Block.BLOCK_STATE_REGISTRY; + int b = bf.getInt(blockData); + Object2IntMap c = (Object2IntMap) cf.get(blockData); + List d = (List) df.get(blockData); + return new MCAIdMapper(c, d, b); + }); + MCAPalette global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState())); + MCAPalettedContainer container = new MCAPalettedContainer<>(global, registry, + i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(), + i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), + ((CraftBlockData) AIR).getState()); + return new MCAWrappedPalettedContainer<>(container, + i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), + i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState()); + } } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java index d12f094f9..b0d78e843 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java @@ -21,6 +21,12 @@ package com.volmit.iris.util.nbt.mca.palette; import com.google.common.base.Predicates; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import it.unimi.dsi.fastutil.Hash; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap; +import net.kyori.adventure.identity.Identity; +import net.minecraft.Util; import java.util.IdentityHashMap; import java.util.Iterator; @@ -28,11 +34,11 @@ import java.util.List; public class MCAIdMapper implements MCAIdMap { public static final int DEFAULT = -1; - private final IdentityHashMap tToId; + private final Object2IntMap tToId; private final List idToT; private int nextId; - public MCAIdMapper(IdentityHashMap tToId, List idToT, int nextId) { + public MCAIdMapper(Object2IntMap tToId, List idToT, int nextId) { this.tToId = tToId; this.idToT = idToT; this.nextId = nextId; @@ -44,7 +50,7 @@ public class MCAIdMapper implements MCAIdMap { public MCAIdMapper(int var0) { this.idToT = Lists.newArrayListWithExpectedSize(var0); - this.tToId = new IdentityHashMap<>(var0); + this.tToId = new Object2IntOpenCustomHashMap<>(var0, IdentityStrategy.INSTANCE); } public void addMapping(T var0, int var1) { @@ -82,4 +88,19 @@ public class MCAIdMapper implements MCAIdMap { public int size() { return this.tToId.size(); } + + static enum IdentityStrategy implements Hash.Strategy { + INSTANCE; + + private IdentityStrategy() { + } + + public int hashCode(Object var0) { + return System.identityHashCode(var0); + } + + public boolean equals(Object var0, Object var1) { + return var0 == var1; + } + } } \ No newline at end of file From 755c84039a41a2c9fc00d327a6acbd3e98026f68 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 23:44:48 -0500 Subject: [PATCH 09/42] NMS 1.18 --- .../java/com/volmit/iris/core/nms/INMS.java | 4 +- .../com/volmit/iris/core/nms/NMSVersion.java | 10 + .../iris/core/nms/v17_1/NMSBinding17_1.java | 486 ------------------ 3 files changed, 12 insertions(+), 488 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java diff --git a/src/main/java/com/volmit/iris/core/nms/INMS.java b/src/main/java/com/volmit/iris/core/nms/INMS.java index f624fa418..589045e27 100644 --- a/src/main/java/com/volmit/iris/core/nms/INMS.java +++ b/src/main/java/com/volmit/iris/core/nms/INMS.java @@ -20,7 +20,7 @@ package com.volmit.iris.core.nms; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; -import com.volmit.iris.core.nms.v17_1.NMSBinding17_1; +import com.volmit.iris.core.nms.v18_1.NMSBinding18_1; import com.volmit.iris.core.nms.v1X.NMSBinding1X; import com.volmit.iris.util.collection.KMap; import org.bukkit.Bukkit; @@ -28,7 +28,7 @@ import org.bukkit.Bukkit; public class INMS { //@builder private static final KMap> bindings = new KMap>() - .qput("v1_17_R1", NMSBinding17_1.class); + .qput("v1_18_R1", NMSBinding18_1.class); //@done private static final INMSBinding binding = bind(); diff --git a/src/main/java/com/volmit/iris/core/nms/NMSVersion.java b/src/main/java/com/volmit/iris/core/nms/NMSVersion.java index c6e629039..7389f6909 100644 --- a/src/main/java/com/volmit/iris/core/nms/NMSVersion.java +++ b/src/main/java/com/volmit/iris/core/nms/NMSVersion.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.List; public enum NMSVersion { + R1_18, + R1_17, R1_16, R1_15, R1_14, @@ -88,6 +90,14 @@ public enum NMSVersion { if (tryVersion("1_16_R1")) { return R1_16; } + + if (tryVersion("1_17_R1")) { + return R1_17; + } + + if (tryVersion("1_18_R1")) { + return R1_18; + } return null; } diff --git a/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java b/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java deleted file mode 100644 index eb5ca2d0d..000000000 --- a/src/main/java/com/volmit/iris/core/nms/v17_1/NMSBinding17_1.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2021 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 . - */ - -package com.volmit.iris.core.nms.v17_1; - -import com.volmit.iris.Iris; -import com.volmit.iris.core.nms.INMSBinding; -import com.volmit.iris.engine.data.cache.AtomicCache; -import com.volmit.iris.util.collection.KMap; -import com.volmit.iris.util.nbt.io.NBTUtil; -import com.volmit.iris.util.nbt.mca.NBTWorld; -import com.volmit.iris.util.nbt.mca.palette.MCABiomeContainer; -import com.volmit.iris.util.nbt.mca.palette.MCAChunkBiomeContainer; -import com.volmit.iris.util.nbt.mca.palette.MCAGlobalPalette; -import com.volmit.iris.util.nbt.mca.palette.MCAIdMap; -import com.volmit.iris.util.nbt.mca.palette.MCAIdMapper; -import com.volmit.iris.util.nbt.mca.palette.MCAPalette; -import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; -import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer; -import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; -import com.volmit.iris.util.nbt.tag.CompoundTag; -import net.minecraft.core.BlockPosition; -import net.minecraft.core.IRegistry; -import net.minecraft.core.IRegistryWritable; -import net.minecraft.nbt.NBTCompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagDouble; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.WorldServer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.biome.BiomeBase; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.TileEntity; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.BiomeStorage; -import net.minecraft.world.level.chunk.Chunk; -import net.minecraft.world.level.chunk.ChunkSection; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; -import org.bukkit.entity.EntityType; -import org.bukkit.generator.ChunkGenerator; -import org.jetbrains.annotations.NotNull; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -public class NMSBinding17_1 implements INMSBinding { - private final BlockData AIR = Material.AIR.createBlockData(); - private final KMap baseBiomeCache = new KMap<>(); - private final AtomicCache> registryCache = new AtomicCache<>(); - private final AtomicCache> globalCache = new AtomicCache<>(); - private final AtomicCache> biomeMapCache = new AtomicCache<>(); - private Field biomeStorageCache = null; - - public boolean supportsDataPacks() { - return true; - } - - @Override - public MCAPaletteAccess createPalette() { - MCAIdMapper registry = registryCache.aquireNasty(() -> { - Field cf = net.minecraft.core.RegistryBlockID.class.getDeclaredField("c"); - Field df = net.minecraft.core.RegistryBlockID.class.getDeclaredField("d"); - Field bf = net.minecraft.core.RegistryBlockID.class.getDeclaredField("b"); - cf.setAccessible(true); - df.setAccessible(true); - bf.setAccessible(true); - net.minecraft.core.RegistryBlockID blockData = Block.p; - int b = bf.getInt(blockData); - IdentityHashMap c = (IdentityHashMap) cf.get(blockData); - List d = (List) df.get(blockData); - return new MCAIdMapper<>(c, d, b); - }); - MCAPalette global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState())); - MCAPalettedContainer container = new MCAPalettedContainer<>(global, registry, - i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(), - i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), - ((CraftBlockData) AIR).getState()); - return new MCAWrappedPalettedContainer<>(container, - i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), - i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState()); - } - - private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) { - try { - return getFieldForBiomeStorage(g).get(g); - } catch (IllegalAccessException e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - @Override - public boolean hasTile(Location l) { - return ((CraftWorld) l.getWorld()).getHandle().getTileEntity(new BlockPosition(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null; - } - - @Override - public CompoundTag serializeTile(Location location) { - TileEntity e = ((CraftWorld) location.getWorld()).getHandle().getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true); - - if (e == null) { - return null; - } - - NBTTagCompound tag = new NBTTagCompound(); - e.save(tag); - return convert(tag); - } - - @Override - public void deserializeTile(CompoundTag s, Location newPosition) { - NBTTagCompound c = convert(s); - - if (c != null) { - int x = newPosition.getBlockX(); - int y = newPosition.getBlockY(); - int z = newPosition.getBlockZ(); - WorldServer w = ((CraftWorld) newPosition.getWorld()).getHandle(); - Chunk ch = w.getChunkAt(x >> 4, z >> 4); - ChunkSection sect = ch.getSections()[y >> 4]; - IBlockData block = sect.getBlocks().a(x & 15, y & 15, z & 15); - BlockPosition pos = new BlockPosition(x, y, z); - ch.b(TileEntity.create(pos, block, c)); - } - } - - private NBTTagCompound convert(CompoundTag tag) { - try { - ByteArrayOutputStream boas = new ByteArrayOutputStream(); - NBTUtil.write(tag, boas, false); - DataInputStream din = new DataInputStream(new ByteArrayInputStream(boas.toByteArray())); - NBTTagCompound c = NBTCompressedStreamTools.a((DataInput) din); - din.close(); - return c; - } catch (Throwable e) { - e.printStackTrace(); - } - - return null; - } - - private CompoundTag convert(NBTTagCompound tag) { - try { - ByteArrayOutputStream boas = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(boas); - NBTCompressedStreamTools.a(tag, (DataOutput) dos); - dos.close(); - return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag(); - } catch (Throwable ex) { - ex.printStackTrace(); - } - - return null; - } - - @Override - public CompoundTag serializeEntity(org.bukkit.entity.Entity be) { - Entity entity = ((CraftEntity) be).getHandle(); - NBTTagCompound tag = new NBTTagCompound(); - entity.save(tag); - CompoundTag t = convert(tag); - t.putInt("btype", be.getType().ordinal()); - return t; - } - - @Override - public org.bukkit.entity.Entity deserializeEntity(CompoundTag s, Location newPosition) { - - EntityType type = EntityType.values()[s.getInt("btype")]; - s.remove("btype"); - NBTTagCompound tag = convert(s); - NBTTagList pos = tag.getList("Pos", 6); - pos.a(0, NBTTagDouble.a(newPosition.getX())); - pos.a(1, NBTTagDouble.a(newPosition.getY())); - pos.a(2, NBTTagDouble.a(newPosition.getZ())); - tag.set("Pos", pos); - org.bukkit.entity.Entity be = newPosition.getWorld().spawnEntity(newPosition, type); - ((CraftEntity) be).getHandle().load(tag); - - return be; - } - - @Override - public boolean supportsCustomHeight() { - return false; - } - - private Field getFieldForBiomeStorage(Object storage) { - Field f = biomeStorageCache; - - if (f != null) { - return f; - } - try { - - f = storage.getClass().getDeclaredField("biome"); - f.setAccessible(true); - return f; - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - Iris.error(storage.getClass().getCanonicalName()); - } - - biomeStorageCache = f; - return null; - } - - private IRegistryWritable getCustomBiomeRegistry() { - return ((CraftServer) Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.aO); - } - - @Override - public Object getBiomeBaseFromId(int id) { - return getCustomBiomeRegistry().fromId(id); - } - - @Override - public int getTrueBiomeBaseId(Object biomeBase) { - return getCustomBiomeRegistry().getId((BiomeBase) biomeBase); - } - - @Override - public Object getTrueBiomeBase(Location location) { - return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - @Override - public String getTrueBiomeBaseKey(Location location) { - return getKeyForBiomeBase(getTrueBiomeBase(location)); - } - - @Override - public boolean supportsCustomBiomes() { - return true; - } - - @Override - public int getMinHeight(World world) { - return world.getMinHeight(); - } - - @Override - public Object getCustomBiomeBaseFor(String mckey) { - try { - return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey.toLowerCase()))); - } catch (Throwable e) { - Iris.reportError(e); - } - - return null; - } - - @SuppressWarnings("OptionalGetWithoutIsPresent") - @Override - public String getKeyForBiomeBase(Object biomeBase) { - return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); - } - - @Override - public Object getBiomeBase(World world, Biome biome) { - return getBiomeBase(((CraftWorld) world).getHandle().t().d(IRegistry.aO), biome); - } - - private Class[] classify(Object... par) { - Class[] g = new Class[par.length]; - for (int i = 0; i < g.length; i++) { - g[i] = par[i].getClass(); - } - - return g; - } - - private T invoke(Object from, String name, Object... par) { - try { - Method f = from.getClass().getDeclaredMethod(name, classify(par)); - f.setAccessible(true); - //noinspection unchecked - return (T) f.invoke(from, par); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T invokeStatic(Class from, String name, Object... par) { - try { - Method f = from.getDeclaredMethod(name, classify(par)); - f.setAccessible(true); - //noinspection unchecked - return (T) f.invoke(null, par); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T getField(Object from, String name) { - try { - Field f = from.getClass().getDeclaredField(name); - f.setAccessible(true); - //noinspection unchecked - return (T) f.get(from); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T getStaticField(Class t, String name) { - try { - Field f = t.getDeclaredField(name); - f.setAccessible(true); - //noinspection unchecked - return (T) f.get(null); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - @Override - public Object getBiomeBase(Object registry, Biome biome) { - Object v = baseBiomeCache.get(biome); - - if (v != null) { - return v; - } - //noinspection unchecked - v = org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, biome); - if (v == null) { - // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. - // But, this does NOT exist within CraftBukkit which makes it return an error. - // So, we will just return the ID that the plains biome returns instead. - //noinspection unchecked - return org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, Biome.PLAINS); - } - baseBiomeCache.put(biome, v); - return v; - } - - @Override - public int getBiomeId(Biome biome) { - for (World i : Bukkit.getWorlds()) { - if (i.getEnvironment().equals(World.Environment.NORMAL)) { - - IRegistry registry = ((CraftWorld) i).getHandle().t().d(IRegistry.aO); - - return registry.getId((BiomeBase) getBiomeBase(registry, biome)); - } - } - - return biome.ordinal(); - } - - private MCAIdMap getBiomeMapping() { - return biomeMapCache.aquire(() -> new MCAIdMap<>() { - @NotNull - @Override - public Iterator iterator() { - return getCustomBiomeRegistry().iterator(); - } - - @Override - public int getId(BiomeBase paramT) { - return getCustomBiomeRegistry().getId(paramT); - } - - @Override - public BiomeBase byId(int paramInt) { - return getCustomBiomeRegistry().fromId(paramInt); - } - }); - } - - @Override - public MCABiomeContainer newBiomeContainer(int min, int max) { - MCAChunkBiomeContainer base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max); - return getBiomeContainerInterface(getBiomeMapping(), base); - } - - @Override - public MCABiomeContainer newBiomeContainer(int min, int max, int[] data) { - MCAChunkBiomeContainer base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max, data); - return getBiomeContainerInterface(getBiomeMapping(), base); - } - - @NotNull - private MCABiomeContainer getBiomeContainerInterface(MCAIdMap biomeMapping, MCAChunkBiomeContainer base) { - return new MCABiomeContainer() { - @Override - public int[] getData() { - return base.writeBiomes(); - } - - @Override - public void setBiome(int x, int y, int z, int id) { - base.setBiome(x, y, z, biomeMapping.byId(id)); - } - - @Override - public int getBiome(int x, int y, int z) { - return biomeMapping.getId(base.getBiome(x, y, z)); - } - }; - } - - @Override - public int countCustomBiomes() { - AtomicInteger a = new AtomicInteger(0); - getCustomBiomeRegistry().d().forEach((i) -> { - MinecraftKey k = i.getKey().a(); - - if (k.getNamespace().equals("minecraft")) { - return; - } - - a.incrementAndGet(); - Iris.debug("Custom Biome: " + k); - }); - - return a.get(); - } - - @Override - public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { - try { - BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); - s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); - } catch (IllegalAccessException e) { - Iris.reportError(e); - e.printStackTrace(); - } - } - - @Override - public boolean isBukkit() { - return false; - } -} From 5a296f2d06a181599a829e2cfd9b7a8572667198 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 23:45:02 -0500 Subject: [PATCH 10/42] Update vanilla biome map (needs style) --- .../iris/util/data/VanillaBiomeMap.java | 142 ++++++++---------- 1 file changed, 63 insertions(+), 79 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java index 967d4ef7b..ae87a7316 100644 --- a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java +++ b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java @@ -34,90 +34,74 @@ public class VanillaBiomeMap { static { add(Biome.OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.PLAINS, 0x8DB360, (short) 1, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.DESERT, 0xFA9418, (short) 2, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.MOUNTAINS, 0x606060, (short) 3, Color.MONOCHROME, Luminosity.BRIGHT, null); - add(Biome.FOREST, 0x056621, (short) 4, Color.GREEN, Luminosity.BRIGHT); - add(Biome.TAIGA, 0x0B6659, (short) 5, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SWAMP, 0x07F9B2, (short) 6, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM); - add(Biome.RIVER, 0x0000FF, (short) 7, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.NETHER_WASTES, 0xBF3B3B, (short) 8, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.THE_END, 0x8080FF, (short) 9, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.FROZEN_OCEAN, 0x7070D6, (short) 10, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FROZEN_RIVER, 0xA0A0FF, (short) 11, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_TUNDRA, 0xFFFFFF, (short) 12, Color.MONOCHROME, Luminosity.LIGHT); - add(Biome.SNOWY_MOUNTAINS, 0xA0A0A0, (short) 13, Color.MONOCHROME, Luminosity.LIGHT); - add(Biome.MUSHROOM_FIELDS, 0xFF00FF, (short) 14, Color.PURPLE, Luminosity.BRIGHT); - add(Biome.MUSHROOM_FIELD_SHORE, 0xA000FF, (short) 15, Color.PURPLE, Luminosity.BRIGHT); - add(Biome.BEACH, 0xFADE55, (short) 16, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.DESERT_HILLS, 0xD25F12, (short) 17, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.WOODED_HILLS, 0x22551C, (short) 18, Color.GREEN, Luminosity.LIGHT); - add(Biome.TAIGA_HILLS, 0x163933, (short) 19, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.MOUNTAIN_EDGE, 0x72789A, (short) 20, Color.MONOCHROME, Luminosity.BRIGHT); - add(Biome.JUNGLE, 0x537B09, (short) 21, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.JUNGLE_HILLS, 0x2C4205, (short) 22, Color.GREEN, Luminosity.DARK, SaturationType.HIGH); - add(Biome.JUNGLE_EDGE, 0x628B17, (short) 23, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.DEEP_OCEAN, 0x000030, (short) 24, Color.BLUE, Luminosity.DARK); - add(Biome.STONE_SHORE, 0xA2A284, (short) 25, Color.GREEN, Luminosity.DARK); - add(Biome.SNOWY_BEACH, 0xFAF0C0, (short) 26, Color.YELLOW, Luminosity.LIGHT); - add(Biome.BIRCH_FOREST, 0x307444, (short) 27, Color.GREEN, Luminosity.LIGHT); - add(Biome.BIRCH_FOREST_HILLS, 0x1F5F32, (short) 28, Color.GREEN, Luminosity.LIGHT); - add(Biome.DARK_FOREST, 0x40511A, (short) 29, Color.GREEN, Luminosity.DARK); - add(Biome.SNOWY_TAIGA, 0x31554A, (short) 30, Color.BLUE, Luminosity.LIGHT); - add(Biome.SNOWY_TAIGA_HILLS, 0x243F36, (short) 31, Color.BLUE, Luminosity.LIGHT); - add(Biome.GIANT_TREE_TAIGA, 0x596651, (short) 32, Color.ORANGE, Luminosity.LIGHT); - add(Biome.GIANT_TREE_TAIGA_HILLS, 0x454F3E, (short) 33, Color.ORANGE, Luminosity.LIGHT); - add(Biome.WOODED_MOUNTAINS, 0x507050, (short) 34, Color.MONOCHROME, Luminosity.BRIGHT); - add(Biome.SAVANNA, 0xBDB25F, (short) 35, Color.GREEN, Luminosity.LIGHT); - add(Biome.SAVANNA_PLATEAU, 0xA79D64, (short) 36, Color.GREEN, Luminosity.LIGHT); - add(Biome.BADLANDS, 0xD94515, (short) 37, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WOODED_BADLANDS_PLATEAU, 0xB09765, (short) 38, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.BADLANDS_PLATEAU, 0xCA8C65, (short) 39, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.END_MIDLANDS, 0x8080FF, (short) 41, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.END_HIGHLANDS, 0x8080FF, (short) 42, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.END_BARRENS, 0x8080FF, (short) 43, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.WARM_OCEAN, 0x0000AC, (short) 44, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW); - add(Biome.LUKEWARM_OCEAN, 0x000090, (short) 45, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.COLD_OCEAN, 0x202070, (short) 46, Color.BLUE, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.DEEP_WARM_OCEAN, 0x000050, (short) 47, Color.BLUE, Luminosity.DARK, SaturationType.LOW); - add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, (short) 48, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM); - add(Biome.DEEP_COLD_OCEAN, 0x202038, (short) 49, Color.BLUE, Luminosity.DARK, SaturationType.HIGH); - add(Biome.DEEP_FROZEN_OCEAN, 0x404090, (short) 50, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.THE_VOID, 0x000000, (short) 127, Color.MONOCHROME, Luminosity.DARK); - add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, (short) 129, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.DESERT_LAKES, 0xFFBC40, (short) 130, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.GRAVELLY_MOUNTAINS, 0x888888, (short) 131, Color.MONOCHROME, Luminosity.LIGHT); - add(Biome.FLOWER_FOREST, 0x2D8E49, (short) 132, Color.RED, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.TAIGA_MOUNTAINS, 0x338E81, (short) 133, Color.GREEN, Luminosity.DARK, SaturationType.MEDIUM); - add(Biome.SWAMP_HILLS, 0x2FFFDA, (short) 134, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM); - add(Biome.ICE_SPIKES, 0xB4DCDC, (short) 140, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.MODIFIED_JUNGLE, 0x7BA331, (short) 149, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.MODIFIED_JUNGLE_EDGE, 0x8AB33F, (short) 151, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.TALL_BIRCH_FOREST, 0x589C6C, (short) 155, Color.GREEN, Luminosity.LIGHT); - add(Biome.TALL_BIRCH_HILLS, 0x47875A, (short) 156, Color.GREEN, Luminosity.LIGHT); - add(Biome.DARK_FOREST_HILLS, 0x687942, (short) 157, Color.GREEN, Luminosity.DARK); - add(Biome.SNOWY_TAIGA_MOUNTAINS, 0x597D72, (short) 158, Color.BLUE, Luminosity.LIGHT); - add(Biome.GIANT_SPRUCE_TAIGA, 0x818E79, (short) 160, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH); - add(Biome.GIANT_SPRUCE_TAIGA_HILLS, 0x6D7766, (short) 161, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH); - add(Biome.GRAVELLY_MOUNTAINS, 0x789878, (short) 162, Color.MONOCHROME, Luminosity.LIGHT); - add(Biome.SHATTERED_SAVANNA, 0xE5DA87, (short) 163, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); - add(Biome.SHATTERED_SAVANNA_PLATEAU, 0xCFC58C, (short) 164, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); - add(Biome.ERODED_BADLANDS, 0xFF6D3D, (short) 165, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); - add(Biome.MODIFIED_WOODED_BADLANDS_PLATEAU, 0xD8BF8D, (short) 166, Color.ORANGE, Luminosity.BRIGHT); - add(Biome.MODIFIED_BADLANDS_PLATEAU, 0xF2B48D, (short) 167, Color.ORANGE, Luminosity.BRIGHT); - add(Biome.BAMBOO_JUNGLE, 0x768E14, (short) 168, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.BAMBOO_JUNGLE_HILLS, 0x3B470A, (short) 169, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.SOUL_SAND_VALLEY, 0x5E3830, (short) 170, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.CRIMSON_FOREST, 0xDD0808, (short) 171, Color.RED, Luminosity.DARK, SaturationType.HIGH); - add(Biome.WARPED_FOREST, 0x49907B, (short) 172, Color.BLUE, Luminosity.BRIGHT); - add(Biome.BASALT_DELTAS, 0x403636, (short) 173, Color.MONOCHROME, Luminosity.DARK); + add(Biome.PLAINS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DESERT, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WINDSWEPT_HILLS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SWAMP, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.RIVER, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.NETHER_WASTES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.THE_END, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_RIVER, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_PLAINS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.MUSHROOM_FIELDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.BEACH, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.JUNGLE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SPARSE_JUNGLE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DEEP_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.STONY_SHORE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_BEACH, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.BIRCH_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DARK_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.OLD_GROWTH_PINE_TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WINDSWEPT_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SAVANNA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SAVANNA_PLATEAU, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.BADLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WOODED_BADLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SMALL_END_ISLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.END_MIDLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.END_HIGHLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.END_BARRENS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WARM_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.LUKEWARM_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.COLD_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DEEP_LUKEWARM_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DEEP_COLD_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DEEP_FROZEN_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.THE_VOID, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SUNFLOWER_PLAINS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FLOWER_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.ICE_SPIKES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.OLD_GROWTH_BIRCH_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WINDSWEPT_SAVANNA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.ERODED_BADLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.BAMBOO_JUNGLE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SOUL_SAND_VALLEY, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.CRIMSON_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WARPED_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.BASALT_DELTAS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.DRIPSTONE_CAVES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.LUSH_CAVES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.MEADOW, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.GROVE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_SLOPES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_PEAKS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.JAGGED_PEAKS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.STONY_PEAKS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.CUSTOM, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); } private static void add(Biome biome, int color, short id, Color randomColor, Luminosity luminosity, SaturationType saturation) { BIOME_HEX.put(biome, color); BIOME_COLOR.put(biome, randomColor); - if (luminosity != null) BIOME_LUMINOSITY.put(biome, luminosity); - if (saturation != null) BIOME_SATURATION.put(biome, saturation); + if(luminosity != null) BIOME_LUMINOSITY.put(biome, luminosity); + if(saturation != null) BIOME_SATURATION.put(biome, saturation); BIOME_IDs.put(biome, id); } From b19358914a0361f97d0411266a6ab161122bd526 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 23:45:13 -0500 Subject: [PATCH 11/42] Drop unused (broken) math helper funcs --- .../com/volmit/iris/util/math/MathHelper.java | 79 ------------------- 1 file changed, 79 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/math/MathHelper.java b/src/main/java/com/volmit/iris/util/math/MathHelper.java index cf4d70c46..74960cbe2 100644 --- a/src/main/java/com/volmit/iris/util/math/MathHelper.java +++ b/src/main/java/com/volmit/iris/util/math/MathHelper.java @@ -18,12 +18,6 @@ package com.volmit.iris.util.math; -import net.minecraft.SystemUtils; -import net.minecraft.core.BaseBlockPosition; -import net.minecraft.world.phys.AxisAlignedBB; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.math.NumberUtils; - import java.util.Random; import java.util.UUID; import java.util.function.IntPredicate; @@ -43,12 +37,6 @@ public class MathHelper { private static final long l = -4611686018427387904L; private static final long m = -9223372036854775808L; private static final float n = 10430.378F; - private static final float[] o = SystemUtils.a(new float[65536], (var0x) -> { - for (int var1 = 0; var1 < var0x.length; ++var1) { - var0x[var1] = (float) Math.sin((double) var1 * 3.141592653589793D * 2.0D / 65536.0D); - } - - }); private static final Random p = new Random(); private static final int[] q = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; private static final double r = 0.16666666666666666D; @@ -71,14 +59,6 @@ public class MathHelper { public MathHelper() { } - public static float sin(float var0) { - return o[(int) (var0 * 10430.378F) & '\uffff']; - } - - public static float cos(float var0) { - return o[(int) (var0 * 10430.378F + 16384.0F) & '\uffff']; - } - public static float c(float var0) { return (float) Math.sqrt(var0); } @@ -304,14 +284,6 @@ public class MathHelper { return d(var0, var0 + var3, var2); } - public static int a(String var0, int var1) { - return NumberUtils.toInt(var0, var1); - } - - public static int a(String var0, int var1, int var2) { - return Math.max(var2, a(var0, var1)); - } - public static double a(String var0, double var1) { try { return Double.parseDouble(var0); @@ -388,18 +360,6 @@ public class MathHelper { return var0 - (double) c(var0); } - public static Vec3D a(Vec3D var0, Vec3D var1, Vec3D var2, Vec3D var3, double var4) { - double var6 = ((-var4 + 2.0D) * var4 - 1.0D) * var4 * 0.5D; - double var8 = ((3.0D * var4 - 5.0D) * var4 * var4 + 2.0D) * 0.5D; - double var10 = ((-3.0D * var4 + 4.0D) * var4 + 1.0D) * var4 * 0.5D; - double var12 = (var4 - 1.0D) * var4 * var4 * 0.5D; - return new Vec3D(var0.b * var6 + var1.b * var8 + var2.b * var10 + var3.b * var12, var0.c * var6 + var1.c * var8 + var2.c * var10 + var3.c * var12, var0.d * var6 + var1.d * var8 + var2.d * var10 + var3.d * var12); - } - - public static long a(BaseBlockPosition var0) { - return c(var0.getX(), var0.getY(), var0.getZ()); - } - public static long c(int var0, int var1, int var2) { long var3 = (long) (var0 * 3129871) ^ (long) var2 * 116129781L ^ (long) var1; var3 = var3 * var3 * 42317861L + var3 * 11L; @@ -420,45 +380,6 @@ public class MathHelper { return (var0 - var2) / (var4 - var2); } - public static boolean a(Vec3D var0, Vec3D var1, AxisAlignedBB var2) { - double var3 = (var2.a + var2.d) * 0.5D; - double var5 = (var2.d - var2.a) * 0.5D; - double var7 = var0.b - var3; - if (Math.abs(var7) > var5 && var7 * var1.b >= 0.0D) { - return false; - } else { - double var9 = (var2.b + var2.e) * 0.5D; - double var11 = (var2.e - var2.b) * 0.5D; - double var13 = var0.c - var9; - if (Math.abs(var13) > var11 && var13 * var1.c >= 0.0D) { - return false; - } else { - double var15 = (var2.c + var2.f) * 0.5D; - double var17 = (var2.f - var2.c) * 0.5D; - double var19 = var0.d - var15; - if (Math.abs(var19) > var17 && var19 * var1.d >= 0.0D) { - return false; - } else { - double var21 = Math.abs(var1.b); - double var23 = Math.abs(var1.c); - double var25 = Math.abs(var1.d); - double var27 = var1.c * var19 - var1.d * var13; - if (Math.abs(var27) > var11 * var25 + var17 * var23) { - return false; - } else { - var27 = var1.d * var7 - var1.b * var19; - if (Math.abs(var27) > var5 * var25 + var17 * var21) { - return false; - } else { - var27 = var1.b * var13 - var1.c * var7; - return Math.abs(var27) < var5 * var23 + var11 * var21; - } - } - } - } - } - } - public static double d(double var0, double var2) { double var4 = var2 * var2 + var0 * var0; if (Double.isNaN(var4)) { From a21850e85fb364ecdcdd8d262e998fe9e8cc0b27 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 23:47:01 -0500 Subject: [PATCH 12/42] Fix ver --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2f266ac21..c55dcdc35 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ plugins { } group 'com.volmit.iris' -version '1.9.7-1.18.X' +version '1.9.6-1.18.X' def nmsVersion = "1.18.1" def apiVersion = '1.18' def name = getRootProject().getName() // Defined in settings.gradle From 26396bbe1a02c3123b2a8134584423668d30d9ae Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sun, 9 Jan 2022 23:47:30 -0500 Subject: [PATCH 13/42] Update shadow --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c55dcdc35..91aeb3572 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { id 'java' id 'io.freefair.lombok' version '5.2.1' - id "com.github.johnrengelman.shadow" version "7.0.0" + id "com.github.johnrengelman.shadow" version "7.1.2" id "de.undercouch.download" version "4.1.2" } From 9df288e7e32de1956caca630107a535042773c6c Mon Sep 17 00:00:00 2001 From: Brian Fopiano Date: Sun, 9 Jan 2022 21:38:39 -0800 Subject: [PATCH 14/42] Added Biomes (Fixed them / modded some) --- .../iris/util/data/VanillaBiomeMap.java | 132 +++++++++--------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java index ae87a7316..0aa6295e8 100644 --- a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java +++ b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java @@ -33,79 +33,81 @@ public class VanillaBiomeMap { private static final KMap BIOME_IDs = new KMap<>(); static { - add(Biome.OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.PLAINS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DESERT, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WINDSWEPT_HILLS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SWAMP, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.RIVER, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.NETHER_WASTES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.THE_END, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FROZEN_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FROZEN_RIVER, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_PLAINS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.MUSHROOM_FIELDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.BEACH, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.JUNGLE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SPARSE_JUNGLE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DEEP_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.STONY_SHORE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_BEACH, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.BIRCH_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DARK_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.OLD_GROWTH_PINE_TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WINDSWEPT_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SAVANNA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SAVANNA_PLATEAU, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.BADLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WOODED_BADLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SMALL_END_ISLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.END_MIDLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.END_HIGHLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.END_BARRENS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WARM_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.LUKEWARM_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.COLD_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DEEP_LUKEWARM_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DEEP_COLD_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DEEP_FROZEN_OCEAN, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.THE_VOID, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SUNFLOWER_PLAINS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FLOWER_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.ICE_SPIKES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.OLD_GROWTH_BIRCH_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WINDSWEPT_SAVANNA, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.ERODED_BADLANDS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.BAMBOO_JUNGLE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SOUL_SAND_VALLEY, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.CRIMSON_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WARPED_FOREST, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.BASALT_DELTAS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.DRIPSTONE_CAVES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.LUSH_CAVES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.MEADOW, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.GROVE, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_SLOPES, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FROZEN_PEAKS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.JAGGED_PEAKS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.STONY_PEAKS, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.CUSTOM, 0x000070, (short) 0, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.OCEAN, 0x000070, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.PLAINS, 0x8DB360, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.DESERT, 0xFA9418, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.WINDSWEPT_HILLS, 0x606060, Color.MONOCHROME, Luminosity.BRIGHT, null); + add(Biome.FOREST, 0x056621, Color.GREEN, Luminosity.BRIGHT, null); + add(Biome.TAIGA, 0x0B6659, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SWAMP, 0x07F9B2, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM); + add(Biome.RIVER, 0x0000FF, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.NETHER_WASTES, 0xBF3B3B, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.THE_END, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.FROZEN_OCEAN, 0x7070D6, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_RIVER, 0xA0A0FF, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_PLAINS, 0xFFFFFF, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.MUSHROOM_FIELDS, 0xFF00FF, Color.PURPLE, Luminosity.BRIGHT, null); + add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.SPARSE_JUNGLE, 0x628B17, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null; + add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null); + add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null); + add(Biome.BIRCH_FOREST, 0x307444, Color.GREEN, Luminosity.LIGHT, null); + add(Biome.DARK_FOREST, 0x40511A, Color.GREEN, Luminosity.DARK, null); + add(Biome.SNOWY_TAIGA, 0x31554A, Color.BLUE, Luminosity.LIGHT, null); + add(Biome.OLD_GROWTH_PINE_TAIGA, 0x596651, Color.ORANGE, Luminosity.LIGHT, null); + add(Biome.WINDSWEPT_FOREST, 0x507050, Color.MONOCHROME, Luminosity.BRIGHT, null); + add(Biome.SAVANNA, 0xBDB25F, Color.GREEN, Luminosity.LIGHT, null); + add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null); + add(Biome.BADLANDS, 0xD94515, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM); // Need to do - + add(Biome.END_MIDLANDS, 0x8080FF, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.WARM_OCEAN, 0x0000AC, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW); + add(Biome.LUKEWARM_OCEAN, 0x000090, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.COLD_OCEAN, 0x202070, Color.BLUE, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM); + add(Biome.DEEP_COLD_OCEAN, 0x202038, Color.BLUE, Luminosity.DARK, SaturationType.HIGH); + add(Biome.DEEP_FROZEN_OCEAN, 0x404090, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.THE_VOID, 0x000000, Color.MONOCHROME, Luminosity.DARK, null); + add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x789878, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.FLOWER_FOREST, 0x2D8E49, Color.RED, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.ICE_SPIKES, 0xB4DCDC, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.OLD_GROWTH_BIRCH_FOREST, 0x589C6C, Color.GREEN, Luminosity.LIGHT, null); + add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x818E79, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH); + add(Biome.WINDSWEPT_SAVANNA, 0xE5DA87, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); + add(Biome.ERODED_BADLANDS, 0xFF6D3D, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); + add(Biome.BAMBOO_JUNGLE, 0x768E14, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.SOUL_SAND_VALLEY, 0x5E3830, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.CRIMSON_FOREST, 0xDD0808, Color.RED, Luminosity.DARK, SaturationType.HIGH); + add(Biome.WARPED_FOREST, 0x49907B, Color.BLUE, Luminosity.BRIGHT, null); + add(Biome.BASALT_DELTAS, 0x403636, Color.MONOCHROME, Luminosity.DARK, null); + add(Biome.DRIPSTONE_CAVES, 0xcc6600, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.LUSH_CAVES, 0x003300, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.MEADOW, 0xff00ff, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW); + add(Biome.GROVE, 0x80ff80, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_SLOPES, 0x00ffff, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_PEAKS, 0xA0A0A0, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.JAGGED_PEAKS, 0x3d7bc2, Color.MONOCHROME, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.STONY_PEAKS, 0x888888, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.CUSTOM, 0xffffff, Color.MONOCHROME, Luminosity.DARK, SaturationType.MONOCHROME); + } - private static void add(Biome biome, int color, short id, Color randomColor, Luminosity luminosity, SaturationType saturation) { + + private static void add(Biome biome, int color, Color randomColor, Luminosity luminosity, SaturationType saturation) { BIOME_HEX.put(biome, color); BIOME_COLOR.put(biome, randomColor); if(luminosity != null) BIOME_LUMINOSITY.put(biome, luminosity); if(saturation != null) BIOME_SATURATION.put(biome, saturation); - BIOME_IDs.put(biome, id); + BIOME_IDs.put(biome, (short) biome.ordinal()); } - private static void add(Biome biome, int color, short id, Color randomColor, Luminosity luminosity) { + private static void add(Biome biome, int color Color randomColor, Luminosity luminosity) { add(biome, color, id, randomColor, luminosity, null); } From 7cd752ceb7bf55d197b31dca88bcf5a4e8a1eda7 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 00:48:42 -0500 Subject: [PATCH 15/42] Remapped packaging --- build.gradle | 191 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 145 insertions(+), 46 deletions(-) diff --git a/build.gradle b/build.gradle index 91aeb3572..8ae9a6ba0 100644 --- a/build.gradle +++ b/build.gradle @@ -26,58 +26,22 @@ group 'com.volmit.iris' version '1.9.6-1.18.X' def nmsVersion = "1.18.1" def apiVersion = '1.18' +def spigotJarVersion = '1.18.1-R0.1-SNAPSHOT' def name = getRootProject().getName() // Defined in settings.gradle def main = 'com.volmit.iris.Iris' // ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED // ======================== WINDOWS ============================= -registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins', name) -registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins', name) -registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins', name) -registerCustomOutputTask('Coco', 'C://Users/sjoer/Desktop/MCSM/plugins', name) -registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins', name) +registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins') +registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins') +registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins') +registerCustomOutputTask('Coco', 'C://Users/sjoer/Desktop/MCSM/plugins') +registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins') // ========================== UNIX ============================== -registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/Documents/development/server/plugins', name) -registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins', name) +registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/Documents/development/server/plugins') +registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins') // ============================================================== - -def registerCustomOutputTask(name, path, plugin) { - if (!System.properties['os.name'].toLowerCase().contains('windows')) - { - return; - } - - tasks.register('build' + name, Copy) { - group('development') - outputs.upToDateWhen { false } - dependsOn ':shadowJar' - from(file('build/libs/' + plugin + '-' + version + '-all.jar')) - into(file(path)) - rename { String fileName -> - fileName.replace(plugin + '-' + version + '-all.jar', plugin + ".jar") - } - } -} - -def registerCustomOutputTaskUnix(name, path, plugin) { - if(System.properties['os.name'].toLowerCase().contains('windows')) - { - return; - } - - tasks.register('build' + name, Copy) { - group('development') - outputs.upToDateWhen { false } - dependsOn ':shadowJar' - from(file('build/libs/' + plugin + '-' + version + '-all.jar')) - into(file(path)) - rename { String fileName -> - fileName.replace(plugin + '-' + version + '-all.jar', plugin + ".jar") - } - } -} - /** * Gradle is weird sometimes, we need to delete the plugin yml from the build folder to actually filter properly. */ @@ -182,14 +146,70 @@ dependencies { implementation 'org.apache.commons:commons-lang3:3.12.0' } -System.out.println("Gradle is using Java: " + JavaVersion.current()); +if(JavaVersion.current().toString() != "17") +{ + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println("=========================================================================================================") + System.err.println("You must run gradle on Java 17. You are using " + JavaVersion.current()) + System.err.println() + System.err.println("=== For IDEs ===") + System.err.println("1. Configure the project for Java 17") + System.err.println("2. Configure the bundled gradle to use Java 17 in settings") + System.err.println() + System.err.println("=== For Command Line (gradlew) ===") + System.err.println("1. Install JDK 17 from https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html") + System.err.println("2. Set JAVA_HOME environment variable to the new jdk installation folder such as C:\\Program Files\\Java\\jdk-17.0.1") + System.err.println("3. Open a new command prompt window to get the new environment variables if need be.") + System.err.println("=========================================================================================================") + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.err.println() + System.exit(69); +} + def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar"); def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar"); def buildToolsFolder = new File(buildDir, "buildtools"); +def specialSourceFolder = new File(buildDir, "specialsource"); def buildToolsHint = new File(buildDir, "buildtools/craftbukkit-" + nmsVersion + ".jar"); +def outputShadeJar = new File(buildDir, "libs/Iris-" + version + "-all.jar"); +def ssiJar = new File(buildDir, "specialsource/Iris-" + version + "-all.jar"); +def ssobfJar = new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar"); +def homePath = System.properties['user.home'] +def m2 = new File(homePath + "/.m2/repository") +def m2s = m2.getAbsolutePath(); // ======================== Building Mapped Jars ============================= task downloadBuildtools(type: Download) { + group "remapping" src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar' dest buildToolsJar onlyIf{ @@ -198,6 +218,7 @@ task downloadBuildtools(type: Download) { } task downloadSpecialSource(type: Download){ + group "remapping" src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar' dest specialSourceJar onlyIf{ @@ -207,6 +228,7 @@ task downloadSpecialSource(type: Download){ task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) { + group "remapping" classpath = files(buildToolsJar) workingDir = buildToolsFolder args = [ @@ -221,4 +243,81 @@ task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec) } } -tasks.compileJava.dependsOn(executeBuildTools) \ No newline at end of file +task copyBuildToSpecialSource(type: Copy) +{ + group "remapping" + from outputShadeJar + into specialSourceFolder + dependsOn(downloadSpecialSource, shadowJar) +} + +task specialSourceRemapObfuscate(type: JavaExec) +{ + group "remapping" + dependsOn(copyBuildToSpecialSource, downloadSpecialSource, shadowJar) + workingDir = specialSourceFolder + classpath = files(specialSourceJar, + new File(m2s + "/org/spigotmc/spigot/"+spigotJarVersion+"/spigot-" + spigotJarVersion + "-remapped-mojang.jar")) + mainClass = "net.md_5.specialsource.SpecialSource" + args = [ + "--live", + "-i", + ssiJar.getName(), + "-o", + ssobfJar.getName(), + "-m", + m2s + "/org/spigotmc/minecraft-server/"+spigotJarVersion+"/minecraft-server-" + spigotJarVersion + "-maps-mojang.txt", + "--reverse", + ] +} + +tasks.compileJava.dependsOn(executeBuildTools) + +task iris(type: Copy) +{ + group "iris" + from ssobfJar + into buildDir + rename { String fileName -> + fileName.replace('Iris-' + version + '-rmo.jar', "Iris-" + version + ".jar") + } + dependsOn(specialSourceRemapObfuscate) +} + + +def registerCustomOutputTask(name, path) { + if (!System.properties['os.name'].toLowerCase().contains('windows')) + { + return; + } + + tasks.register('build' + name, Copy) { + group('development') + outputs.upToDateWhen { false } + dependsOn ':shadowJar' + from(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar")) + into(file(path)) + rename { String fileName -> + fileName.replace(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar").getName(), "Iris.jar") + } + } +} + +def registerCustomOutputTaskUnix(name, path) { + if(System.properties['os.name'].toLowerCase().contains('windows')) + { + return; + } + + tasks.register('build' + name, Copy) { + group('development') + outputs.upToDateWhen { false } + dependsOn(iris) + from(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar")) + into(file(path)) + rename { String fileName -> + fileName.replace(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar").getName(), "Iris.jar") + } + } +} + From ad19baf1f6c0f3eadb32c36b6ba2a9cf4053e8ae Mon Sep 17 00:00:00 2001 From: Brian Fopiano Date: Sun, 9 Jan 2022 21:50:05 -0800 Subject: [PATCH 16/42] f --- src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java index 0aa6295e8..364c70ee5 100644 --- a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java +++ b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java @@ -62,7 +62,7 @@ public class VanillaBiomeMap { add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null); add(Biome.BADLANDS, 0xD94515, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM); add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM); // Need to do - + add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM); add(Biome.END_MIDLANDS, 0x8080FF, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM); From 75385e5c018b1a9bc25ae45047a9f09f34902e0b Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 01:01:05 -0500 Subject: [PATCH 17/42] Fixes --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index 8ae9a6ba0..485f3cf3a 100644 --- a/build.gradle +++ b/build.gradle @@ -273,6 +273,12 @@ task specialSourceRemapObfuscate(type: JavaExec) tasks.compileJava.dependsOn(executeBuildTools) +task setup() +{ + group("iris") + dependsOn(clean, executeBuildTools) +} + task iris(type: Copy) { group "iris" From aef5b9a0570b1037f43c640944d64e11df06dd0d Mon Sep 17 00:00:00 2001 From: Brian Fopiano Date: Sun, 9 Jan 2022 22:14:36 -0800 Subject: [PATCH 18/42] Fixed Typo --- .../java/com/volmit/iris/util/data/VanillaBiomeMap.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java index 364c70ee5..a6133e4b9 100644 --- a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java +++ b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java @@ -50,7 +50,7 @@ public class VanillaBiomeMap { add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); add(Biome.SPARSE_JUNGLE, 0x628B17, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null; + add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null); add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null); add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null); add(Biome.BIRCH_FOREST, 0x307444, Color.GREEN, Luminosity.LIGHT, null); @@ -107,8 +107,8 @@ public class VanillaBiomeMap { BIOME_IDs.put(biome, (short) biome.ordinal()); } - private static void add(Biome biome, int color Color randomColor, Luminosity luminosity) { - add(biome, color, id, randomColor, luminosity, null); + private static void add(Biome biome, int color, Color randomColor, Luminosity luminosity) { + add(biome, color, randomColor, luminosity, null); } public static int getColor(Biome biome) { From 4eac0978ed2437e6c0ae5070ce2d23273b785ce0 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 01:20:10 -0500 Subject: [PATCH 19/42] Readme stuff --- README.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0800e0fb..84584c781 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,39 @@ For 1.16 and below, see the 1.14-1.16 branch. The master branch is for the lates # [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **|** [Git](https://github.com/IrisDimensions) -## Iris Toolbelt +# Building + +Building Iris is fairly simple, though you will need to setup a few things if your system has never been used for java development. + +Consider supporting our development by buying Iris on spigot! We work hard to make Iris the best it can be for everyone. + + +### Command Line Builds +1. Install [Java JDK 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) +2. Set the JDK installation path to `JAVA_HOME` as an environment variable. + * Windows + 1. Start > Type `env` and press Enter + 2. Advanced > Environment Variables + 3. Under System Variables, click `New...` + 4. Variable Name: `JAVA_HOME` + 5. Variable Value: `C:\Program Files\Java\jdk-17.0.1` (verify this eixsts after installing java dont just copy the example text) + * MacOS + 1. Run `/usr/libexec/java_home -V` and look for Java 17 + 2. Run `sudo nano ~/.zshenv` + 3. Add `export JAVA_HOME=$(/usr/libexec/java_home)` as a new line + 4. Use `CTRL + X`, then Press `Y`, Then `ENTER` + 5. Quit & Reopen Terminal and verify with `echo $JAVA_HOME`. It should print a directory +3. If this is your first time building Iris for MC 1.18+ run `gradlew setup` inside the root Iris project folder. Otherwise skip this step. Grab a coffee, this may take up to 5 minutes depending on your cpu & internet connection. +4. Once the project is setup, run `gradlew iris` +5. The Iris jar will be placed in `Iris/build/Iris-XXX-XXX.jar` Enjoy! Consider supporting us by buying it on spigot! + +### IDE Builds (for development) +* Run `gradlew setup` any time you get dependency issues with craftbukkit +* Configure ITJ Gradle to use JDK 17 (in settings, search for gradle) +* Add a build line in the build.gradle for your own build task to directly compile Iris into your plugins folder if you prefer. +* Resync the project & run your newly created task (under the development folder in gradle tasks!) + +# Iris Toolbelt Everyone needs a toolbelt. From e38e11b8907787dbbb7f17576fadb4b7046cce38 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 01:28:53 -0500 Subject: [PATCH 20/42] Fix? --- .../java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index ecaab0e6b..3c86b69f7 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -302,6 +302,10 @@ public class NMSBinding18_1 implements INMSBinding { return a.get(); } + public boolean supportsDataPacks() { + return false; + } + @Override public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { try { From 5333d23ad8aa25b5634bef743cea4a499ddf26fc Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 01:33:24 -0500 Subject: [PATCH 21/42] f --- .../java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index 3c86b69f7..40f2bf4bc 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -303,7 +303,7 @@ public class NMSBinding18_1 implements INMSBinding { } public boolean supportsDataPacks() { - return false; + return true; } @Override From 90b8747775ad6c9bda9421b65561a6a9af254722 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 19:55:51 -0500 Subject: [PATCH 22/42] Fix deps --- build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 485f3cf3a..1e8b6cbac 100644 --- a/build.gradle +++ b/build.gradle @@ -300,11 +300,11 @@ def registerCustomOutputTask(name, path) { tasks.register('build' + name, Copy) { group('development') outputs.upToDateWhen { false } - dependsOn ':shadowJar' - from(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar")) + dependsOn(iris) + from(new File(buildDir, "Iris-" + version + ".jar")) into(file(path)) rename { String fileName -> - fileName.replace(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar").getName(), "Iris.jar") + fileName.replace("Iris-" + version + ".jar", "Iris.jar") } } } @@ -319,10 +319,10 @@ def registerCustomOutputTaskUnix(name, path) { group('development') outputs.upToDateWhen { false } dependsOn(iris) - from(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar")) + from(new File(buildDir, "Iris-" + version + ".jar")) into(file(path)) rename { String fileName -> - fileName.replace(new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar").getName(), "Iris.jar") + fileName.replace("Iris-" + version + ".jar", "Iris.jar") } } } From 0d3f8de8110e00402b2fcc03f2591e7831d9c9cb Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 21:01:03 -0500 Subject: [PATCH 23/42] Fixes --- build.gradle | 58 ++++++++----------- .../iris/core/nms/v18_1/NMSBinding18_1.java | 1 + 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/build.gradle b/build.gradle index 1e8b6cbac..b7738b25f 100644 --- a/build.gradle +++ b/build.gradle @@ -87,7 +87,7 @@ compileJava { * Configure Iris for shading */ shadowJar { - minimize() + //minimize() append("plugin.yml") relocate 'com.dfsek.paralithic', 'com.volmit.iris.util.paralithic' relocate 'io.papermc.lib', 'com.volmit.iris.util.paper' @@ -148,32 +148,6 @@ dependencies { if(JavaVersion.current().toString() != "17") { - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() System.err.println() System.err.println("=========================================================================================================") System.err.println("You must run gradle on Java 17. You are using " + JavaVersion.current()) @@ -188,10 +162,6 @@ if(JavaVersion.current().toString() != "17") System.err.println("3. Open a new command prompt window to get the new environment variables if need be.") System.err.println("=========================================================================================================") System.err.println() - System.err.println() - System.err.println() - System.err.println() - System.err.println() System.exit(69); } @@ -203,6 +173,7 @@ def buildToolsHint = new File(buildDir, "buildtools/craftbukkit-" + nmsVersion + def outputShadeJar = new File(buildDir, "libs/Iris-" + version + "-all.jar"); def ssiJar = new File(buildDir, "specialsource/Iris-" + version + "-all.jar"); def ssobfJar = new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar"); +def ssJar = new File(buildDir, "specialsource/Iris-" + version + "-rma.jar"); def homePath = System.properties['user.home'] def m2 = new File(homePath + "/.m2/repository") def m2s = m2.getAbsolutePath(); @@ -271,6 +242,25 @@ task specialSourceRemapObfuscate(type: JavaExec) ] } +task specialSourceRemap(type: JavaExec) +{ + group "remapping" + dependsOn(specialSourceRemapObfuscate) + workingDir = specialSourceFolder + classpath = files(specialSourceJar, + new File(m2s + "/org/spigotmc/spigot/"+spigotJarVersion+"/spigot-" + spigotJarVersion + "-remapped-obf.jar")) + mainClass = "net.md_5.specialsource.SpecialSource" + args = [ + "--live", + "-i", + ssobfJar.getName(), + "-o", + ssJar.getName(), + "-m", + m2s + "/org/spigotmc/minecraft-server/"+spigotJarVersion+"/minecraft-server-" + spigotJarVersion + "-maps-spigot.csrg" + ] +} + tasks.compileJava.dependsOn(executeBuildTools) task setup() @@ -282,12 +272,12 @@ task setup() task iris(type: Copy) { group "iris" - from ssobfJar + from ssJar into buildDir rename { String fileName -> - fileName.replace('Iris-' + version + '-rmo.jar', "Iris-" + version + ".jar") + fileName.replace('Iris-' + version + '-rma.jar', "Iris-" + version + ".jar") } - dependsOn(specialSourceRemapObfuscate) + dependsOn(specialSourceRemap) } diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index 40f2bf4bc..d15fb0878 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -35,6 +35,7 @@ import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer; import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; import com.volmit.iris.util.nbt.tag.CompoundTag; +import com.volmit.iris.util.scheduling.Queue; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.core.Registry; import net.minecraft.nbt.NbtIo; From 32dac5fbe29118a8c55d57e2d169c807b6c4c89d Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 10 Jan 2022 21:38:00 -0500 Subject: [PATCH 24/42] Fix registry access --- .../iris/core/nms/v18_1/NMSBinding18_1.java | 65 ++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index d15fb0878..00b56bd01 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -38,8 +38,10 @@ import com.volmit.iris.util.nbt.tag.CompoundTag; import com.volmit.iris.util.scheduling.Queue; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.NbtIo; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.core.BlockPos; @@ -65,6 +67,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; @@ -77,6 +80,7 @@ public class NMSBinding18_1 implements INMSBinding { private final AtomicCache> biomeMapCache = new AtomicCache<>(); private final AtomicCache> registryCache = new AtomicCache<>(); private final AtomicCache> globalCache = new AtomicCache<>(); + private final AtomicCache registryAccess = new AtomicCache<>(); private Field biomeStorageCache = null; @Override @@ -145,12 +149,18 @@ public class NMSBinding18_1 implements INMSBinding { return true; } + private RegistryAccess registry() + { + return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer())); + } + private Registry getCustomBiomeRegistry() { - return ((CraftServer) Bukkit.getServer()).getHandle().getServer().registryHolder.registry(Registry.BIOME_REGISTRY).orElse(null); + + return registry().registry(Registry.BIOME_REGISTRY).orElse(null); } private Registry getBlockRegistry() { - return ((CraftServer) Bukkit.getServer()).getHandle().getServer().registryHolder.registry(Registry.BLOCK_REGISTRY).orElse(null); + return registry().registry(Registry.BLOCK_REGISTRY).orElse(null); } @Override @@ -185,7 +195,7 @@ public class NMSBinding18_1 implements INMSBinding { @Override public Object getCustomBiomeBaseFor(String mckey) { - return null; + return getCustomBiomeRegistry().get(new ResourceLocation(mckey)); } @Override @@ -363,4 +373,53 @@ public class NMSBinding18_1 implements INMSBinding { i -> NBTWorld.getCompound(CraftBlockData.fromData(i)), i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState()); } + + private static Object getFor(Class type, Object source) { + Object o = fieldFor(type, source); + + if(o != null) + { + return o; + } + + return invokeFor(type, source); + } + + private static Object invokeFor(Class returns, Object in) + { + for(Method i : in.getClass().getMethods()) + { + if(i.getReturnType().equals(returns)) + { + i.setAccessible(true); + try { + Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() +"."+ i.getName() + "()"); + return i.invoke(in); + } catch(Throwable e) { + e.printStackTrace(); + } + } + } + + return null; + } + + private static Object fieldFor(Class returns, Object in) + { + for(Field i : in.getClass().getFields()) + { + if(i.getType().equals(returns)) + { + i.setAccessible(true); + try { + Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() +"."+ i.getName()); + return i.get(in); + } catch(IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + return null; + } } From 8c00499e7602c024ec2dadef05a13539f261cd78 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 01:24:12 -0500 Subject: [PATCH 25/42] Height fixes --- .../volmit/iris/engine/framework/Engine.java | 2 +- .../engine/platform/BukkitChunkGenerator.java | 4 ++-- .../iris/engine/platform/HeadlessGenerator.java | 2 +- .../java/com/volmit/iris/util/hunk/Hunk.java | 4 ++-- .../iris/util/hunk/view/BiomeGridHunkView.java | 17 ++++++++++------- .../iris/util/hunk/view/ChunkDataHunkView.java | 8 ++++---- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/framework/Engine.java b/src/main/java/com/volmit/iris/engine/framework/Engine.java index 06afb363f..daf7b79d0 100644 --- a/src/main/java/com/volmit/iris/engine/framework/Engine.java +++ b/src/main/java/com/volmit/iris/engine/framework/Engine.java @@ -145,7 +145,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat @BlockCoordinates default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException { - generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc), multicore); + generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()), multicore); } @BlockCoordinates diff --git a/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java b/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java index b4745f3fc..968839ef3 100644 --- a/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java +++ b/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java @@ -139,7 +139,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun IrisBiomeStorage st = new IrisBiomeStorage(); TerrainChunk tc = TerrainChunk.createUnsafe(world, st); Hunk blocks = Hunk.view((ChunkData) tc); - Hunk biomes = Hunk.view((BiomeGrid) tc); + Hunk biomes = Hunk.view((BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()); this.world.bind(world); getEngine().generate(x << 4, z << 4, blocks, biomes, true); Iris.debug("Regenerated " + x + " " + z); @@ -284,7 +284,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun studioGenerator.generateChunk(getEngine(), tc, x, z); } else { Hunk blocks = Hunk.view((ChunkData) tc); - Hunk biomes = Hunk.view((BiomeGrid) tc); + Hunk biomes = Hunk.view((BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()); getEngine().generate(x << 4, z << 4, blocks, biomes, true); } diff --git a/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java b/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java index e698bb0cb..e8af96455 100644 --- a/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java +++ b/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java @@ -86,7 +86,7 @@ public class HeadlessGenerator implements PlatformChunkGenerator { INMS.get().getTrueBiomeBaseId(biomeBase))) .build(); getEngine().generate(x << 4, z << 4, - Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc), + Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()), false); chunk.cleanupPalettesAndBlockStates(); } catch (Throwable e) { diff --git a/src/main/java/com/volmit/iris/util/hunk/Hunk.java b/src/main/java/com/volmit/iris/util/hunk/Hunk.java index 5522908db..3e20715c8 100644 --- a/src/main/java/com/volmit/iris/util/hunk/Hunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/Hunk.java @@ -98,8 +98,8 @@ public interface Hunk { return new FunctionalHunkView(src, reader, writer); } - static Hunk view(BiomeGrid biome) { - return new BiomeGridHunkView(biome); + static Hunk view(BiomeGrid biome, int minHeight, int maxHeight) { + return new BiomeGridHunkView(biome, minHeight, maxHeight); } static Hunk fringe(Hunk i, Hunk o) { diff --git a/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java index 1ce534580..43dcbaf75 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java @@ -29,9 +29,13 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid; public class BiomeGridHunkView implements Hunk { @Getter private final BiomeGrid chunk; + private final int minHeight; + private final int maxHeight; - public BiomeGridHunkView(BiomeGrid chunk) { + public BiomeGridHunkView(BiomeGrid chunk, int minHeight, int maxHeight) { this.chunk = chunk; + this.minHeight = minHeight; + this.maxHeight = maxHeight; } @Override @@ -46,25 +50,24 @@ public class BiomeGridHunkView implements Hunk { @Override public int getHeight() { - // TODO: WARNING HEIGHT - return 256; + return maxHeight - minHeight; } @Override public void setRaw(int x, int y, int z, Biome t) { - chunk.setBiome(x, y, z, t); + chunk.setBiome(x, y+minHeight, z, t); } @Override public Biome getRaw(int x, int y, int z) { - return chunk.getBiome(x, y, z); + return chunk.getBiome(x, y+minHeight, z); } public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) { if (chunk instanceof LinkedTerrainChunk) { - INMS.get().forceBiomeInto(x, y, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome()); + INMS.get().forceBiomeInto(x, y+minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome()); return; } - INMS.get().forceBiomeInto(x, y, z, somethingVeryDirty, chunk); + INMS.get().forceBiomeInto(x, y+minHeight, z, somethingVeryDirty, chunk); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java index e229178cb..8dab96d69 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java @@ -42,7 +42,7 @@ public class ChunkDataHunkView implements Hunk { @Override public int getHeight() { - return chunk.getMaxHeight(); + return chunk.getMaxHeight() - chunk.getMinHeight(); } @Override @@ -51,7 +51,7 @@ public class ChunkDataHunkView implements Hunk { return; } - chunk.setRegion(x1, y1, z1, x2, y2, z2, t); + chunk.setRegion(x1, y1+chunk.getMinHeight(), z1, x2, y2+chunk.getMinHeight(), z2, t); } @Override @@ -60,11 +60,11 @@ public class ChunkDataHunkView implements Hunk { return; } - chunk.setBlock(x, y, z, t); + chunk.setBlock(x, y+chunk.getMinHeight(), z, t); } @Override public BlockData getRaw(int x, int y, int z) { - return chunk.getBlockData(x, y, z); + return chunk.getBlockData(x, y+chunk.getMinHeight(), z); } } From 2dde426df66043d5229bfbf8e69cc8da3e4995d3 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 01:47:38 -0500 Subject: [PATCH 26/42] Cleanup --- src/main/java/com/volmit/iris/Iris.java | 150 ++-- .../com/volmit/iris/core/IrisSettings.java | 16 +- .../volmit/iris/core/ServerConfigurator.java | 82 +- .../iris/core/commands/CommandEdit.java | 87 +- .../iris/core/commands/CommandFind.java | 24 +- .../iris/core/commands/CommandIris.java | 144 ++-- .../iris/core/commands/CommandJigsaw.java | 26 +- .../iris/core/commands/CommandObject.java | 116 +-- .../iris/core/commands/CommandPregen.java | 30 +- .../iris/core/commands/CommandStudio.java | 276 +++--- .../iris/core/commands/CommandWhat.java | 44 +- .../volmit/iris/core/edit/BlockSignal.java | 6 +- .../volmit/iris/core/edit/DustRevealer.java | 12 +- .../volmit/iris/core/edit/JigsawEditor.java | 64 +- .../iris/core/gui/NoiseExplorerGUI.java | 54 +- .../volmit/iris/core/gui/PregeneratorJob.java | 54 +- .../com/volmit/iris/core/gui/VisionGUI.java | 166 ++-- .../core/gui/components/IrisRenderer.java | 6 +- .../iris/core/link/IrisPapiExpansion.java | 50 +- .../iris/core/link/MultiverseCoreLink.java | 20 +- .../volmit/iris/core/link/MythicMobsLink.java | 20 +- .../com/volmit/iris/core/link/OraxenLink.java | 22 +- .../iris/core/loader/ImageResourceLoader.java | 39 +- .../com/volmit/iris/core/loader/IrisData.java | 86 +- .../iris/core/loader/IrisRegistrant.java | 2 +- .../core/loader/ObjectResourceLoader.java | 38 +- .../iris/core/loader/ResourceLoader.java | 83 +- .../core/loader/ScriptResourceLoader.java | 38 +- .../java/com/volmit/iris/core/nms/INMS.java | 10 +- .../com/volmit/iris/core/nms/NMSVersion.java | 40 +- .../iris/core/nms/v18_1/NMSBinding18_1.java | 59 +- .../iris/core/nms/v1X/NMSBinding1X.java | 4 +- .../com/volmit/iris/core/pack/IrisPack.java | 90 +- .../iris/core/pack/IrisPackRepository.java | 63 +- .../core/pregenerator/IrisPregenerator.java | 30 +- .../iris/core/pregenerator/PregenTask.java | 10 +- .../core/pregenerator/PregeneratorMethod.java | 28 +- .../methods/AsyncPregenMethod.java | 18 +- .../methods/HybridPregenMethod.java | 12 +- .../methods/MedievalPregenMethod.java | 12 +- .../methods/SyndicatePregenMethod.java | 206 ++--- .../syndicate/SyndicateClient.java | 2 +- .../syndicate/SyndicateServer.java | 40 +- .../volmit/iris/core/project/IrisProject.java | 168 ++-- .../iris/core/project/SchemaBuilder.java | 174 ++-- .../volmit/iris/core/service/BoardSVC.java | 19 +- .../volmit/iris/core/service/CommandSVC.java | 10 +- .../iris/core/service/ConversionSVC.java | 54 +- .../volmit/iris/core/service/DolphinSVC.java | 4 +- .../com/volmit/iris/core/service/EditSVC.java | 10 +- .../volmit/iris/core/service/ObjectSVC.java | 11 +- .../iris/core/service/PreservationSVC.java | 14 +- .../volmit/iris/core/service/StudioSVC.java | 110 +-- .../com/volmit/iris/core/service/TreeSVC.java | 104 ++- .../volmit/iris/core/service/VillageSVC.java | 10 +- .../com/volmit/iris/core/service/WandSVC.java | 141 ++-- .../volmit/iris/core/tools/IrisCreator.java | 47 +- .../volmit/iris/core/tools/IrisToolbelt.java | 64 +- .../iris/core/tools/IrisWorldCreator.java | 26 +- .../volmit/iris/core/wand/WandSelection.java | 36 +- .../com/volmit/iris/engine/EnginePanic.java | 18 +- .../com/volmit/iris/engine/IrisComplex.java | 154 ++-- .../com/volmit/iris/engine/IrisEngine.java | 79 +- .../volmit/iris/engine/IrisEngineEffects.java | 18 +- .../volmit/iris/engine/IrisEngineMantle.java | 76 +- .../iris/engine/IrisExecutionEnvironment.java | 6 +- .../volmit/iris/engine/IrisWorldManager.java | 252 +++--- .../engine/actuator/IrisBiomeActuator.java | 22 +- .../engine/actuator/IrisDecorantActuator.java | 36 +- .../actuator/IrisTerrainNormalActuator.java | 49 +- .../iris/engine/data/cache/AtomicCache.java | 18 +- .../volmit/iris/engine/data/cache/Cache.java | 2 +- .../engine/data/chunk/LinkedTerrainChunk.java | 12 +- .../engine/data/chunk/MCATerrainChunk.java | 8 +- .../iris/engine/data/chunk/TerrainChunk.java | 61 +- .../iris/engine/data/io/Deserializer.java | 8 +- .../iris/engine/data/io/MaxDepthIO.java | 4 +- .../iris/engine/data/io/Serializer.java | 2 +- .../engine/data/io/StringDeserializer.java | 4 +- .../iris/engine/data/io/StringSerializer.java | 2 +- .../decorator/IrisCeilingDecorator.java | 28 +- .../engine/decorator/IrisEngineDecorator.java | 8 +- .../decorator/IrisSeaFloorDecorator.java | 18 +- .../decorator/IrisSeaSurfaceDecorator.java | 18 +- .../decorator/IrisShoreLineDecorator.java | 24 +- .../decorator/IrisSurfaceDecorator.java | 42 +- .../volmit/iris/engine/framework/Engine.java | 242 +++--- .../framework/EngineAssignedModifier.java | 2 +- .../framework/EngineAssignedWorldManager.java | 32 +- .../engine/framework/EngineComponent.java | 4 +- .../iris/engine/framework/EngineData.java | 4 +- .../engine/framework/EngineDecorator.java | 2 +- .../iris/engine/framework/EngineMode.java | 4 +- .../iris/engine/framework/EnginePlayer.java | 16 +- .../iris/engine/framework/EngineStage.java | 2 +- .../iris/engine/framework/Fallible.java | 2 +- .../iris/engine/framework/IrisEngineMode.java | 2 +- .../volmit/iris/engine/framework/Locator.java | 30 +- .../engine/framework/PregeneratedData.java | 8 +- .../iris/engine/framework/SeedManager.java | 2 +- .../iris/engine/jigsaw/PlannedPiece.java | 30 +- .../iris/engine/jigsaw/PlannedStructure.java | 92 +- .../iris/engine/mantle/EngineMantle.java | 24 +- .../iris/engine/mantle/MantleWriter.java | 297 ++++--- .../components/MantleJigsawComponent.java | 46 +- .../components/MantleObjectComponent.java | 32 +- .../iris/engine/mode/ModeEnclosure.java | 4 +- .../volmit/iris/engine/mode/ModeIslands.java | 4 +- .../iris/engine/mode/ModeOverworld.java | 6 +- .../iris/engine/mode/ModeSuperFlat.java | 4 +- .../engine/modifier/IrisCarveModifier.java | 84 +- .../engine/modifier/IrisDepositModifier.java | 30 +- .../modifier/IrisPerfectionModifier.java | 34 +- .../engine/modifier/IrisPostModifier.java | 74 +- .../iris/engine/object/HeadlessWorld.java | 34 +- .../com/volmit/iris/engine/object/IRare.java | 60 +- .../engine/object/IrisAttributeModifier.java | 4 +- .../engine/object/IrisAxisRotationClamp.java | 8 +- .../volmit/iris/engine/object/IrisBiome.java | 152 ++-- .../iris/engine/object/IrisBiomeCustom.java | 16 +- .../engine/object/IrisBiomeGeneratorLink.java | 2 +- .../engine/object/IrisBiomePaletteLayer.java | 10 +- .../iris/engine/object/IrisBlockData.java | 40 +- .../iris/engine/object/IrisBlockDrops.java | 12 +- .../iris/engine/object/IrisCarving.java | 36 +- .../volmit/iris/engine/object/IrisCave.java | 12 +- .../iris/engine/object/IrisCavePlacer.java | 12 +- .../volmit/iris/engine/object/IrisColor.java | 14 +- .../iris/engine/object/IrisCommand.java | 12 +- .../engine/object/IrisCommandRegistry.java | 18 +- .../volmit/iris/engine/object/IrisCompat.java | 50 +- .../object/IrisCompatabilityBlockFilter.java | 2 +- .../object/IrisCompatabilityItemFilter.java | 2 +- .../iris/engine/object/IrisDecorator.java | 48 +- .../engine/object/IrisDepositGenerator.java | 10 +- .../iris/engine/object/IrisDimension.java | 51 +- .../iris/engine/object/IrisDirection.java | 81 +- .../iris/engine/object/IrisDuration.java | 20 +- .../volmit/iris/engine/object/IrisEffect.java | 84 +- .../iris/engine/object/IrisElipsoid.java | 6 +- .../iris/engine/object/IrisEnchantment.java | 12 +- .../engine/object/IrisEngineChunkData.java | 4 +- .../iris/engine/object/IrisEngineData.java | 12 +- .../volmit/iris/engine/object/IrisEntity.java | 98 +-- .../iris/engine/object/IrisEntitySpawn.java | 46 +- .../iris/engine/object/IrisExpression.java | 12 +- .../engine/object/IrisExpressionLoad.java | 12 +- .../iris/engine/object/IrisFluidBodies.java | 12 +- .../iris/engine/object/IrisGenerator.java | 46 +- .../engine/object/IrisGeneratorStyle.java | 37 +- .../volmit/iris/engine/object/IrisImage.java | 32 +- .../iris/engine/object/IrisImageMap.java | 21 +- .../iris/engine/object/IrisInterpolator.java | 2 +- .../iris/engine/object/IrisJigsawPiece.java | 10 +- .../engine/object/IrisJigsawStructure.java | 26 +- .../volmit/iris/engine/object/IrisLoot.java | 50 +- .../iris/engine/object/IrisLootReference.java | 2 +- .../iris/engine/object/IrisLootTable.java | 6 +- .../engine/object/IrisMaterialPalette.java | 10 +- .../engine/object/IrisNoiseGenerator.java | 8 +- .../volmit/iris/engine/object/IrisObject.java | 342 ++++---- .../iris/engine/object/IrisObjectLoot.java | 8 +- .../iris/engine/object/IrisObjectMarker.java | 4 +- .../engine/object/IrisObjectPlacement.java | 44 +- .../iris/engine/object/IrisObjectReplace.java | 4 +- .../engine/object/IrisObjectRotation.java | 130 +-- .../iris/engine/object/IrisObjectScale.java | 16 +- .../engine/object/IrisObjectTranslate.java | 4 +- .../iris/engine/object/IrisOreGenerator.java | 14 +- .../iris/engine/object/IrisPotionEffect.java | 14 +- .../iris/engine/object/IrisPyramid.java | 2 +- .../volmit/iris/engine/object/IrisRange.java | 2 +- .../volmit/iris/engine/object/IrisRavine.java | 30 +- .../iris/engine/object/IrisRavinePlacer.java | 8 +- .../volmit/iris/engine/object/IrisRegion.java | 60 +- .../iris/engine/object/IrisSlopeClip.java | 2 +- .../iris/engine/object/IrisSpawner.java | 8 +- .../iris/engine/object/IrisStyledRange.java | 4 +- .../iris/engine/object/IrisSurface.java | 23 +- .../iris/engine/object/IrisTimeBlock.java | 4 +- .../volmit/iris/engine/object/IrisTree.java | 6 +- .../iris/engine/object/IrisTreeSize.java | 3 +- .../engine/object/IrisVillagerOverride.java | 28 +- .../iris/engine/object/IrisVillagerTrade.java | 20 +- .../iris/engine/object/IrisWeather.java | 2 +- .../volmit/iris/engine/object/IrisWorld.java | 24 +- .../volmit/iris/engine/object/IrisWorm.java | 14 +- .../volmit/iris/engine/object/TileBanner.java | 8 +- .../volmit/iris/engine/object/TileData.java | 12 +- .../engine/platform/BukkitChunkGenerator.java | 60 +- .../engine/platform/HeadlessGenerator.java | 30 +- .../generators/BiomeBuffetGenerator.java | 4 +- .../iris/util/atomics/AtomicAverage.java | 12 +- .../util/atomics/AtomicRollingSequence.java | 10 +- .../com/volmit/iris/util/board/Board.java | 18 +- .../volmit/iris/util/board/BoardEntry.java | 6 +- .../volmit/iris/util/board/BoardManager.java | 2 +- .../volmit/iris/util/collection/GBiset.java | 15 +- .../iris/util/collection/GListAdapter.java | 16 +- .../volmit/iris/util/collection/KList.java | 142 ++-- .../com/volmit/iris/util/collection/KMap.java | 81 +- .../volmit/iris/util/collection/KeyPair.java | 12 +- .../iris/util/collection/StateList.java | 14 +- .../volmit/iris/util/context/IrisContext.java | 12 +- .../java/com/volmit/iris/util/data/B.java | 463 +++++------ .../com/volmit/iris/util/data/ChunkCache.java | 2 +- .../com/volmit/iris/util/data/Cuboid.java | 189 +++-- .../java/com/volmit/iris/util/data/DUTF.java | 3 - .../volmit/iris/util/data/DataPalette.java | 14 +- .../com/volmit/iris/util/data/Dimension.java | 21 +- .../iris/util/data/DoubleArrayUtils.java | 4 +- .../iris/util/data/IrisBiomeStorage.java | 8 +- .../com/volmit/iris/util/data/KCache.java | 10 +- .../volmit/iris/util/data/MaterialBlock.java | 20 +- .../volmit/iris/util/data/NibbleArray.java | 24 +- .../iris/util/data/NibbleDataPalette.java | 14 +- .../iris/util/data/VanillaBiomeMap.java | 94 +-- .../com/volmit/iris/util/data/Varint.java | 78 +- .../com/volmit/iris/util/data/WeightMap.java | 4 +- .../volmit/iris/util/data/WeightedRandom.java | 2 +- .../iris/util/data/palette/BitStorage.java | 60 +- .../CrudeIncrementalIntIdentityHashBiMap.java | 44 +- .../iris/util/data/palette/GlobalPalette.java | 2 +- .../util/data/palette/HashMapPalette.java | 4 +- .../iris/util/data/palette/IdMapper.java | 6 +- .../iris/util/data/palette/LinearPalette.java | 14 +- .../volmit/iris/util/data/palette/Mth.java | 126 +-- .../iris/util/data/palette/PaletteType.java | 4 +- .../util/data/palette/PalettedContainer.java | 22 +- .../iris/util/decree/DecreeContext.java | 8 +- .../util/decree/DecreeContextHandler.java | 4 +- .../iris/util/decree/DecreeExecutor.java | 8 +- .../volmit/iris/util/decree/DecreeNode.java | 10 +- .../volmit/iris/util/decree/DecreeOrigin.java | 5 +- .../iris/util/decree/DecreeParameter.java | 12 +- .../util/decree/DecreeParameterHandler.java | 51 +- .../volmit/iris/util/decree/DecreeSystem.java | 57 +- .../iris/util/decree/annotations/Decree.java | 3 +- .../iris/util/decree/annotations/Param.java | 3 +- .../decree/context/BiomeContextHandler.java | 6 +- .../context/DimensionContextHandler.java | 6 +- .../context/GeneratorContextHandler.java | 6 +- .../decree/context/RegionContextHandler.java | 6 +- .../util/decree/handlers/BiomeHandler.java | 12 +- .../decree/handlers/BlockVectorHandler.java | 30 +- .../util/decree/handlers/BooleanHandler.java | 4 +- .../util/decree/handlers/ByteHandler.java | 2 +- .../util/decree/handlers/CaveHandler.java | 17 +- .../decree/handlers/DimensionHandler.java | 13 +- .../util/decree/handlers/DoubleHandler.java | 2 +- .../util/decree/handlers/EntityHandler.java | 25 +- .../util/decree/handlers/FloatHandler.java | 2 +- .../decree/handlers/GeneratorHandler.java | 13 +- .../util/decree/handlers/IntegerHandler.java | 2 +- .../decree/handlers/JigsawPieceHandler.java | 15 +- .../decree/handlers/JigsawPoolHandler.java | 16 +- .../handlers/JigsawStructureHandler.java | 15 +- .../util/decree/handlers/LongHandler.java | 2 +- .../util/decree/handlers/PlayerHandler.java | 7 +- .../util/decree/handlers/RegionHandler.java | 15 +- .../util/decree/handlers/ScriptHandler.java | 13 +- .../util/decree/handlers/ShortHandler.java | 2 +- .../util/decree/handlers/StringHandler.java | 2 +- .../util/decree/handlers/VectorHandler.java | 38 +- .../util/decree/handlers/WorldHandler.java | 11 +- .../decree/specialhandlers/ObjectHandler.java | 11 +- .../decree/virtual/VirtualDecreeCommand.java | 195 +++-- .../java/com/volmit/iris/util/format/C.java | 105 +-- .../com/volmit/iris/util/format/Form.java | 450 +++++----- .../iris/util/format/MemoryMonitor.java | 12 +- .../java/com/volmit/iris/util/hunk/Hunk.java | 463 ++++++----- .../volmit/iris/util/hunk/bits/DataBits.java | 61 +- .../iris/util/hunk/bits/DataContainer.java | 48 +- .../iris/util/hunk/bits/HashPalette.java | 12 +- .../iris/util/hunk/bits/LinearPalette.java | 19 +- .../volmit/iris/util/hunk/bits/Palette.java | 6 +- .../volmit/iris/util/hunk/bits/TecTest.java | 41 +- .../iris/util/hunk/storage/MappedHunk.java | 6 +- .../util/hunk/storage/MappedSyncHunk.java | 18 +- .../iris/util/hunk/storage/PaletteHunk.java | 17 +- .../iris/util/hunk/storage/PaletteOrHunk.java | 2 +- .../iris/util/hunk/storage/StorageHunk.java | 2 +- .../hunk/storage/SynchronizedArrayHunk.java | 6 +- .../util/hunk/view/BiomeGridHunkView.java | 10 +- .../util/hunk/view/ChunkBiomeHunkView.java | 4 +- .../util/hunk/view/ChunkDataHunkView.java | 10 +- .../iris/util/hunk/view/ChunkHunkView.java | 2 +- .../util/hunk/view/FunctionalHunkView.java | 4 +- .../iris/util/hunk/view/RotatedXHunkView.java | 10 +- .../iris/util/hunk/view/RotatedYHunkView.java | 12 +- .../iris/util/hunk/view/RotatedZHunkView.java | 4 +- .../util/hunk/view/SynchronizedHunkView.java | 2 +- .../iris/util/hunk/view/WriteTrackHunk.java | 2 +- .../util/interpolation/IrisInterpolation.java | 787 +++++++++--------- .../iris/util/interpolation/Starcast.java | 452 +++++----- .../iris/util/inventorygui/RandomColor.java | 98 +-- .../iris/util/inventorygui/UIElement.java | 12 +- .../iris/util/inventorygui/UIWindow.java | 62 +- .../com/volmit/iris/util/io/FileWatcher.java | 2 +- .../volmit/iris/util/io/FolderWatcher.java | 32 +- src/main/java/com/volmit/iris/util/io/IO.java | 783 ++++++++++------- .../volmit/iris/util/io/InstanceState.java | 4 +- .../com/volmit/iris/util/io/JarScanner.java | 16 +- .../volmit/iris/util/io/ReactiveFolder.java | 26 +- .../java/com/volmit/iris/util/json/HTTP.java | 21 +- .../volmit/iris/util/json/HTTPTokener.java | 17 +- .../com/volmit/iris/util/json/JSONArray.java | 434 ++++++---- .../volmit/iris/util/json/JSONException.java | 6 +- .../com/volmit/iris/util/json/JSONML.java | 149 ++-- .../com/volmit/iris/util/json/JSONObject.java | 700 +++++++++------- .../volmit/iris/util/json/JSONTokener.java | 118 +-- .../com/volmit/iris/util/json/JSONWriter.java | 111 ++- .../java/com/volmit/iris/util/json/XML.java | 160 ++-- .../com/volmit/iris/util/json/XMLTokener.java | 99 ++- .../com/volmit/iris/util/mantle/Mantle.java | 231 +++-- .../volmit/iris/util/mantle/MantleChunk.java | 74 +- .../iris/util/mantle/TectonicPlate.java | 63 +- .../com/volmit/iris/util/math/Average.java | 10 +- .../volmit/iris/util/math/BlockPosition.java | 4 +- .../java/com/volmit/iris/util/math/CDou.java | 2 +- .../com/volmit/iris/util/math/Direction.java | 73 +- .../volmit/iris/util/math/FinalInteger.java | 6 +- .../volmit/iris/util/math/IrisMathHelper.java | 70 +- .../math/KochanekBartelsInterpolation.java | 52 +- .../java/com/volmit/iris/util/math/M.java | 175 ++-- .../com/volmit/iris/util/math/MathHelper.java | 84 +- .../iris/util/math/PathInterpolation.java | 18 +- .../com/volmit/iris/util/math/Point3d.java | 41 +- .../com/volmit/iris/util/math/Point3f.java | 39 +- .../com/volmit/iris/util/math/Point4d.java | 50 +- .../com/volmit/iris/util/math/Point4f.java | 48 +- .../com/volmit/iris/util/math/Position2.java | 4 +- .../java/com/volmit/iris/util/math/RNG.java | 14 +- .../iris/util/math/RollingSequence.java | 10 +- .../com/volmit/iris/util/math/Spiral.java | 20 +- .../com/volmit/iris/util/math/Spiraler.java | 6 +- .../com/volmit/iris/util/math/Tuple2d.java | 182 ++-- .../com/volmit/iris/util/math/Tuple2f.java | 182 ++-- .../com/volmit/iris/util/math/Tuple3d.java | 208 +++-- .../com/volmit/iris/util/math/Tuple3f.java | 208 +++-- .../com/volmit/iris/util/math/Tuple4d.java | 237 ++++-- .../com/volmit/iris/util/math/Tuple4f.java | 237 ++++-- .../volmit/iris/util/math/VecMathUtil.java | 10 +- .../com/volmit/iris/util/math/Vector2d.java | 34 +- .../com/volmit/iris/util/math/Vector2f.java | 36 +- .../com/volmit/iris/util/math/Vector3d.java | 43 +- .../com/volmit/iris/util/math/Vector3f.java | 47 +- .../com/volmit/iris/util/math/VectorMath.java | 156 ++-- .../volmit/iris/util/matter/IrisMatter.java | 9 +- .../com/volmit/iris/util/matter/Matter.java | 101 ++- .../volmit/iris/util/matter/MatterHeader.java | 1 - .../volmit/iris/util/matter/MatterPlacer.java | 2 +- .../volmit/iris/util/matter/MatterSlice.java | 33 +- .../volmit/iris/util/matter/WorldMatter.java | 6 +- .../iris/util/matter/slices/BlockMatter.java | 1 - .../iris/util/matter/slices/EntityMatter.java | 53 +- .../iris/util/matter/slices/TileMatter.java | 4 +- .../iris/util/nbt/io/NBTDeserializer.java | 2 +- .../iris/util/nbt/io/NBTInputStream.java | 12 +- .../iris/util/nbt/io/NBTOutputStream.java | 18 +- .../iris/util/nbt/io/NBTSerializer.java | 2 +- .../com/volmit/iris/util/nbt/io/NBTUtil.java | 8 +- .../iris/util/nbt/io/ParseException.java | 2 +- .../iris/util/nbt/io/SNBTDeserializer.java | 2 +- .../volmit/iris/util/nbt/io/SNBTParser.java | 92 +- .../volmit/iris/util/nbt/io/SNBTWriter.java | 14 +- .../iris/util/nbt/io/StringPointer.java | 34 +- .../com/volmit/iris/util/nbt/mca/Chunk.java | 213 +++-- .../iris/util/nbt/mca/CompressionType.java | 4 +- .../com/volmit/iris/util/nbt/mca/MCAFile.java | 136 +-- .../com/volmit/iris/util/nbt/mca/MCAUtil.java | 122 ++- .../volmit/iris/util/nbt/mca/NBTWorld.java | 50 +- .../com/volmit/iris/util/nbt/mca/Section.java | 54 +- .../util/nbt/mca/palette/MCABitStorage.java | 52 +- .../mca/palette/MCAChunkBiomeContainer.java | 10 +- ...ACrudeIncrementalIntIdentityHashBiMap.java | 36 +- .../nbt/mca/palette/MCAHashMapPalette.java | 12 +- .../util/nbt/mca/palette/MCAIdMapper.java | 14 +- .../nbt/mca/palette/MCALinearPalette.java | 14 +- .../iris/util/nbt/mca/palette/MCAMth.java | 126 +-- .../nbt/mca/palette/MCAPalettedContainer.java | 26 +- .../volmit/iris/util/nbt/tag/ArrayTag.java | 7 +- .../volmit/iris/util/nbt/tag/CompoundTag.java | 18 +- .../com/volmit/iris/util/nbt/tag/ListTag.java | 58 +- .../iris/util/nbt/tag/NonNullEntrySet.java | 2 +- .../com/volmit/iris/util/nbt/tag/Tag.java | 53 +- .../java/com/volmit/iris/util/network/DL.java | 22 +- .../iris/util/network/MeteredInputStream.java | 2 +- .../util/network/MeteredOutputStream.java | 2 +- .../java/com/volmit/iris/util/noise/CNG.java | 116 ++- .../volmit/iris/util/noise/CellGenerator.java | 8 +- .../volmit/iris/util/noise/CloverNoise.java | 211 +++-- .../com/volmit/iris/util/noise/FastNoise.java | 261 +++--- .../iris/util/noise/FastNoiseDouble.java | 236 +++--- .../volmit/iris/util/noise/ImageNoise.java | 4 +- .../iris/util/noise/InterpolatedNoise.java | 2 +- .../iris/util/noise/NoiseGenerator.java | 3 +- .../volmit/iris/util/noise/PerlinNoise.java | 12 +- .../iris/util/noise/RarityCellGenerator.java | 18 +- .../volmit/iris/util/noise/SimplexNoise.java | 12 +- .../iris/util/parallel/BurstExecutor.java | 30 +- .../volmit/iris/util/parallel/GridLock.java | 2 +- .../volmit/iris/util/parallel/HyperLock.java | 32 +- .../volmit/iris/util/parallel/MultiBurst.java | 44 +- .../iris/util/particle/FastParticle.java | 8 +- .../iris/util/particle/FastReflection.java | 2 +- .../iris/util/particle/ParticleSender.java | 22 +- .../util/particle/ParticleSenderLegacy.java | 58 +- .../iris/util/particle/ParticleType.java | 16 +- .../com/volmit/iris/util/plugin/Chunks.java | 18 +- .../com/volmit/iris/util/plugin/ICommand.java | 9 +- .../com/volmit/iris/util/plugin/Metrics.java | 207 +++-- .../volmit/iris/util/plugin/MetricsLite.java | 97 ++- .../iris/util/plugin/MortarCommand.java | 44 +- .../iris/util/plugin/MortarPermission.java | 14 +- .../iris/util/plugin/PluginRegistry.java | 4 +- .../iris/util/plugin/PluginRegistryGroup.java | 8 +- .../iris/util/plugin/RouterCommand.java | 6 +- .../iris/util/plugin/VirtualCommand.java | 46 +- .../volmit/iris/util/plugin/VolmitPlugin.java | 128 +-- .../volmit/iris/util/plugin/VolmitSender.java | 164 ++-- .../java/com/volmit/iris/util/reflect/V.java | 26 +- .../volmit/iris/util/reflect/Violator.java | 56 +- .../volmit/iris/util/scheduling/Callback.java | 6 +- .../iris/util/scheduling/ChronoLatch.java | 2 +- .../iris/util/scheduling/GroupedExecutor.java | 14 +- .../volmit/iris/util/scheduling/IrisLock.java | 8 +- .../com/volmit/iris/util/scheduling/J.java | 110 ++- .../volmit/iris/util/scheduling/Looper.java | 8 +- .../com/volmit/iris/util/scheduling/O.java | 4 +- .../util/scheduling/PrecisionStopwatch.java | 2 +- .../iris/util/scheduling/QueueExecutor.java | 6 +- .../iris/util/scheduling/ShurikenQueue.java | 4 +- .../iris/util/scheduling/TaskExecutor.java | 22 +- .../iris/util/scheduling/ThreadMonitor.java | 12 +- .../volmit/iris/util/scheduling/Wrapper.java | 10 +- .../util/scheduling/jobs/DownloadJob.java | 6 +- .../volmit/iris/util/scheduling/jobs/Job.java | 4 +- .../util/scheduling/jobs/JobCollection.java | 2 +- .../scheduling/jobs/ParallelQueueJob.java | 4 +- .../iris/util/scheduling/jobs/QueueJob.java | 2 +- .../iris/util/stream/ArraySignificance.java | 8 +- .../iris/util/stream/ProceduralStream.java | 40 +- .../convert/AwareConversionStream2D.java | 2 +- .../convert/AwareConversionStream3D.java | 2 +- .../util/stream/convert/ConversionStream.java | 2 +- .../stream/convert/ForceDoubleStream.java | 2 +- .../util/stream/convert/SelectionStream.java | 4 +- .../stream/convert/SignificanceStream.java | 6 +- .../stream/interpolation/BiHermiteStream.java | 34 +- .../interpolation/BiStarcastStream.java | 2 +- .../stream/interpolation/BicubicStream.java | 34 +- .../stream/interpolation/BilinearStream.java | 10 +- .../stream/interpolation/Interpolated.java | 2 +- .../stream/interpolation/Interpolator.java | 2 +- .../interpolation/TriHermiteStream.java | 130 +-- .../interpolation/TriStarcastStream.java | 2 +- .../stream/interpolation/TricubicStream.java | 130 +-- .../stream/interpolation/TrilinearStream.java | 18 +- .../util/stream/utility/NullSafeStream.java | 4 +- .../util/stream/utility/ProfiledStream.java | 20 +- .../util/stream/utility/SemaphoreStream.java | 4 +- .../stream/utility/SynchronizedStream.java | 4 +- 463 files changed, 11845 insertions(+), 10159 deletions(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 5b171a32f..9c6536c58 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -97,7 +97,7 @@ public class Iris extends VolmitPlugin implements Listener { try { fixShading(); InstanceState.updateInstanceId(); - } catch (Throwable ignored) { + } catch(Throwable ignored) { } } @@ -115,7 +115,7 @@ public class Iris extends VolmitPlugin implements Listener { } public static void callEvent(Event e) { - if (!e.isAsynchronous()) { + if(!e.isAsynchronous()) { J.s(() -> Bukkit.getPluginManager().callEvent(e)); } else { Bukkit.getPluginManager().callEvent(e); @@ -126,11 +126,11 @@ public class Iris extends VolmitPlugin implements Listener { JarScanner js = new JarScanner(instance.getJarFile(), s); KList v = new KList<>(); J.attempt(js::scan); - for (Class i : js.getClasses()) { - if (slicedClass == null || i.isAnnotationPresent(slicedClass)) { + for(Class i : js.getClasses()) { + if(slicedClass == null || i.isAnnotationPresent(slicedClass)) { try { v.add(i.getDeclaredConstructor().newInstance()); - } catch (Throwable ignored) { + } catch(Throwable ignored) { } } @@ -143,11 +143,11 @@ public class Iris extends VolmitPlugin implements Listener { JarScanner js = new JarScanner(instance.getJarFile(), s); KList> v = new KList<>(); J.attempt(js::scan); - for (Class i : js.getClasses()) { - if (slicedClass == null || i.isAnnotationPresent(slicedClass)) { + for(Class i : js.getClasses()) { + if(slicedClass == null || i.isAnnotationPresent(slicedClass)) { try { v.add(i); - } catch (Throwable ignored) { + } catch(Throwable ignored) { } } @@ -161,7 +161,7 @@ public class Iris extends VolmitPlugin implements Listener { } public static void sq(Runnable r) { - synchronized (syncJobs) { + synchronized(syncJobs) { syncJobs.queue(r); } } @@ -173,10 +173,10 @@ public class Iris extends VolmitPlugin implements Listener { public static void msg(String string) { try { sender.sendMessage(string); - } catch (Throwable e) { + } catch(Throwable e) { try { System.out.println(instance.getTag() + string.replaceAll("(<([^>]+)>)", "")); - } catch (Throwable ignored1) { + } catch(Throwable ignored1) { } } @@ -186,15 +186,15 @@ public class Iris extends VolmitPlugin implements Listener { String h = IO.hash(name + "@" + url); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); - if (!f.exists()) { - try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) { + if(!f.exists()) { + try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) { byte[] dataBuffer = new byte[1024]; int bytesRead; - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { + while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { fileOutputStream.write(dataBuffer, 0, bytesRead); Iris.verbose("Aquiring " + name); } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } } @@ -206,19 +206,19 @@ public class Iris extends VolmitPlugin implements Listener { String h = IO.hash(name + "*" + url); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); - try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) { + try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) { byte[] dataBuffer = new byte[1024]; int bytesRead; - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { + while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { fileOutputStream.write(dataBuffer, 0, bytesRead); } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } try { return IO.readAll(f); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } @@ -229,15 +229,15 @@ public class Iris extends VolmitPlugin implements Listener { String h = IO.hash(name + "*" + url); File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h); Iris.verbose("Download " + name + " -> " + url); - try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) { + try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) { byte[] dataBuffer = new byte[1024]; int bytesRead; - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { + while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { fileOutputStream.write(dataBuffer, 0, bytesRead); } fileOutputStream.flush(); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); Iris.reportError(e); } @@ -254,35 +254,35 @@ public class Iris extends VolmitPlugin implements Listener { } public static void debug(String string) { - if (!IrisSettings.get().getGeneral().isDebug()) { + if(!IrisSettings.get().getGeneral().isDebug()) { return; } try { throw new RuntimeException(); - } catch (Throwable e) { + } catch(Throwable e) { try { String[] cc = e.getStackTrace()[1].getClassName().split("\\Q.\\E"); - if (cc.length > 5) { + if(cc.length > 5) { debug(cc[3] + "/" + cc[4] + "/" + cc[cc.length - 1], e.getStackTrace()[1].getLineNumber(), string); } else { debug(cc[3] + "/" + cc[4], e.getStackTrace()[1].getLineNumber(), string); } - } catch (Throwable ex) { + } catch(Throwable ex) { debug("Origin", -1, string); } } } public static void debug(String category, int line, String string) { - if (!IrisSettings.get().getGeneral().isDebug()) { + if(!IrisSettings.get().getGeneral().isDebug()) { return; } - if(IrisSettings.get().getGeneral().isUseConsoleCustomColors()){ + if(IrisSettings.get().getGeneral().isUseConsoleCustomColors()) { msg("" + category + " <#bf3b76>" + line + " " + C.LIGHT_PURPLE + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]")); } else { - msg(C.BLUE + category + ":" + C.AQUA +line + C.RESET + C.LIGHT_PURPLE + " " + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]")); + msg(C.BLUE + category + ":" + C.AQUA + line + C.RESET + C.LIGHT_PURPLE + " " + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]")); } } @@ -301,21 +301,17 @@ public class Iris extends VolmitPlugin implements Listener { @SuppressWarnings("deprecation") public static void later(NastyRunnable object) { - try - { + try { Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () -> { try { object.run(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } }, RNG.r.i(100, 1200)); - } - - catch(IllegalPluginAccessException ignored) - { + } catch(IllegalPluginAccessException ignored) { } } @@ -325,18 +321,18 @@ public class Iris extends VolmitPlugin implements Listener { } public static void clearQueues() { - synchronized (syncJobs) { + synchronized(syncJobs) { syncJobs.clear(); } } private static int getJavaVersion() { String version = System.getProperty("java.version"); - if (version.startsWith("1.")) { + if(version.startsWith("1.")) { version = version.substring(2, 3); } else { int dot = version.indexOf("."); - if (dot != -1) { + if(dot != -1) { version = version.substring(0, dot); } } @@ -344,10 +340,10 @@ public class Iris extends VolmitPlugin implements Listener { } public static void reportErrorChunk(int x, int z, Throwable e, String extra) { - if (IrisSettings.get().getGeneral().isDebug()) { + if(IrisSettings.get().getGeneral().isDebug()) { File f = instance.getDataFile("debug", "chunk-errors", "chunk." + x + "." + z + ".txt"); - if (!f.exists()) { + if(!f.exists()) { J.attempt(() -> { PrintWriter pw = new PrintWriter(f); pw.println("Thread: " + Thread.currentThread().getName()); @@ -362,16 +358,16 @@ public class Iris extends VolmitPlugin implements Listener { } public static void reportError(Throwable e) { - if (IrisSettings.get().getGeneral().isDebug()) { + if(IrisSettings.get().getGeneral().isDebug()) { String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber(); - if (e.getCause() != null) { + if(e.getCause() != null) { n += "-" + e.getCause().getStackTrace()[0].getClassName() + "-" + e.getCause().getStackTrace()[0].getLineNumber(); } File f = instance.getDataFile("debug", "caught-exceptions", n + ".txt"); - if (!f.exists()) { + if(!f.exists()) { J.attempt(() -> { PrintWriter pw = new PrintWriter(f); pw.println("Thread: " + Thread.currentThread().getName()); @@ -417,19 +413,19 @@ public class Iris extends VolmitPlugin implements Listener { } private void autoStartStudio() { - if (IrisSettings.get().getStudio().isAutoStartDefaultStudio()) { + if(IrisSettings.get().getStudio().isAutoStartDefaultStudio()) { Iris.info("Starting up auto Studio!"); try { Player r = new KList<>(getServer().getOnlinePlayers()).getRandom(); Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r) : sender, 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> { J.s(() -> { - for (Player i : getServer().getOnlinePlayers()) { + for(Player i : getServer().getOnlinePlayers()) { i.setGameMode(GameMode.SPECTATOR); i.teleport(new Location(w, 0, 200, 0)); } }); }); - } catch (IrisException e) { + } catch(IrisException e) { e.printStackTrace(); } } @@ -438,7 +434,7 @@ public class Iris extends VolmitPlugin implements Listener { private void setupAudience() { try { audiences = BukkitAudiences.create(this); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); IrisSettings.get().getGeneral().setUseConsoleCustomColors(false); IrisSettings.get().getGeneral().setUseCustomColorsIngame(false); @@ -452,11 +448,11 @@ public class Iris extends VolmitPlugin implements Listener { FileOutputStream fos = new FileOutputStream(fi); Map f = Thread.getAllStackTraces(); PrintWriter pw = new PrintWriter(fos); - for (Thread i : f.keySet()) { + for(Thread i : f.keySet()) { pw.println("========================================"); pw.println("Thread: '" + i.getName() + "' ID: " + i.getId() + " STATUS: " + i.getState().name()); - for (StackTraceElement j : f.get(i)) { + for(StackTraceElement j : f.get(i)) { pw.println(" @ " + j.toString()); } @@ -467,7 +463,7 @@ public class Iris extends VolmitPlugin implements Listener { pw.close(); System.out.println("DUMPED! See " + fi.getAbsolutePath()); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -476,13 +472,11 @@ public class Iris extends VolmitPlugin implements Listener { postShutdown.add(r); } - public static void panic() - { + public static void panic() { EnginePanic.panic(); } - public static void addPanic(String s, String v) - { + public static void addPanic(String s, String v) { EnginePanic.add(s, v); } @@ -508,7 +502,7 @@ public class Iris extends VolmitPlugin implements Listener { } private void setupPapi() { - if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { + if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { new IrisPapiExpansion().register(); } } @@ -529,7 +523,7 @@ public class Iris extends VolmitPlugin implements Listener { } private void checkConfigHotload() { - if (configWatcher.checkModified()) { + if(configWatcher.checkModified()) { IrisSettings.invalidate(); IrisSettings.get(); configWatcher.checkModified(); @@ -538,17 +532,17 @@ public class Iris extends VolmitPlugin implements Listener { } private void tickQueue() { - synchronized (Iris.syncJobs) { - if (!Iris.syncJobs.hasNext()) { + synchronized(Iris.syncJobs) { + if(!Iris.syncJobs.hasNext()) { return; } long ms = M.ms(); - while (Iris.syncJobs.hasNext() && M.ms() - ms < 25) { + while(Iris.syncJobs.hasNext() && M.ms() - ms < 25) { try { Iris.syncJobs.next().run(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } @@ -557,7 +551,7 @@ public class Iris extends VolmitPlugin implements Listener { } private void bstats() { - if (IrisSettings.get().getGeneral().isPluginMetrics()) { + if(IrisSettings.get().getGeneral().isPluginMetrics()) { J.s(() -> new Metrics(Iris.instance, 8757)); } } @@ -573,12 +567,12 @@ public class Iris extends VolmitPlugin implements Listener { @Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { - if (worldName.equals("test")) { + if(worldName.equals("test")) { try { throw new RuntimeException(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.info(e.getStackTrace()[1].getClassName()); - if (e.getStackTrace()[1].getClassName().contains("com.onarandombox.MultiverseCore")) { + if(e.getStackTrace()[1].getClassName().contains("com.onarandombox.MultiverseCore")) { Iris.debug("MVC Test detected, Quick! Send them the dummy!"); return new DummyChunkGenerator(); } @@ -586,20 +580,20 @@ public class Iris extends VolmitPlugin implements Listener { } IrisDimension dim; - if (id == null || id.isEmpty()) { + if(id == null || id.isEmpty()) { dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType()); } else { dim = IrisData.loadAnyDimension(id); } Iris.debug("Generator ID: " + id + " requested by bukkit/plugin"); - if (dim == null) { + if(dim == null) { Iris.warn("Unable to find dimension type " + id + " Looking for online packs..."); service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true); dim = IrisData.loadAnyDimension(id); - if (dim == null) { + if(dim == null) { throw new RuntimeException("Can't find dimension " + id + "!"); } else { Iris.info("Resolved missing dimension, proceeding with generation."); @@ -609,18 +603,18 @@ public class Iris extends VolmitPlugin implements Listener { Iris.debug("Assuming IrisDimension: " + dim.getName()); IrisWorld w = IrisWorld.builder() - .name(worldName) - .seed(1337) - .environment(dim.getEnvironment()) - .worldFolder(new File(worldName)) - .minHeight(0) - .maxHeight(256) - .build(); + .name(worldName) + .seed(1337) + .environment(dim.getEnvironment()) + .worldFolder(new File(worldName)) + .minHeight(0) + .maxHeight(256) + .build(); Iris.debug("Generator Config: " + w.toString()); File ff = new File(w.worldFolder(), "iris/pack"); - if (!ff.exists() || ff.listFiles().length == 0) { + if(!ff.exists() || ff.listFiles().length == 0) { ff.mkdirs(); service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile()); } @@ -629,7 +623,7 @@ public class Iris extends VolmitPlugin implements Listener { } public void splash() { - if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) { + if(!IrisSettings.get().getGeneral().isSplashLogoStartup()) { return; } @@ -645,7 +639,7 @@ public class Iris extends VolmitPlugin implements Listener { Iris.info("Bukkit version: " + Bukkit.getBukkitVersion()); Iris.info("Java version: " + getJavaVersion()); Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes()); - for (int i = 0; i < info.length; i++) { + for(int i = 0; i < info.length; i++) { splash[i] += info[i]; } diff --git a/src/main/java/com/volmit/iris/core/IrisSettings.java b/src/main/java/com/volmit/iris/core/IrisSettings.java index 530d96b55..bd7ffc64b 100644 --- a/src/main/java/com/volmit/iris/core/IrisSettings.java +++ b/src/main/java/com/volmit/iris/core/IrisSettings.java @@ -43,7 +43,7 @@ public class IrisSettings { private IrisSettingsPerformance performance = new IrisSettingsPerformance(); public static int getThreadCount(int c) { - return switch (c) { + return switch(c) { case -1, -2, -4 -> Runtime.getRuntime().availableProcessors() / -c; case 0, 1, 2 -> 1; default -> Math.max(c, 2); @@ -134,7 +134,7 @@ public class IrisSettings { } public static IrisSettings get() { - if (settings != null) { + if(settings != null) { return settings; } @@ -142,10 +142,10 @@ public class IrisSettings { File s = Iris.instance.getDataFile("settings.json"); - if (!s.exists()) { + if(!s.exists()) { try { IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); - } catch (JSONException | IOException e) { + } catch(JSONException | IOException e) { e.printStackTrace(); Iris.reportError(e); } @@ -155,10 +155,10 @@ public class IrisSettings { settings = new Gson().fromJson(ss, IrisSettings.class); try { IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } - } catch (Throwable ee) { + } catch(Throwable ee) { // Iris.reportError(ee); causes a self-reference & stackoverflow Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage()); } @@ -168,7 +168,7 @@ public class IrisSettings { } public static void invalidate() { - synchronized (settings) { + synchronized(settings) { settings = null; } } @@ -178,7 +178,7 @@ public class IrisSettings { try { IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); - } catch (JSONException | IOException e) { + } catch(JSONException | IOException e) { e.printStackTrace(); Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/core/ServerConfigurator.java b/src/main/java/com/volmit/iris/core/ServerConfigurator.java index daff067c6..90bd46c0d 100644 --- a/src/main/java/com/volmit/iris/core/ServerConfigurator.java +++ b/src/main/java/com/volmit/iris/core/ServerConfigurator.java @@ -43,11 +43,11 @@ import java.util.concurrent.TimeUnit; public class ServerConfigurator { public static void configure() { IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration(); - if (s.isConfigureSpigotTimeoutTime()) { + if(s.isConfigureSpigotTimeoutTime()) { J.attempt(ServerConfigurator::increaseKeepAliveSpigot); } - if (s.isConfigurePaperWatchdogDelay()) { + if(s.isConfigurePaperWatchdogDelay()) { J.attempt(ServerConfigurator::increasePaperWatchdog); } @@ -60,7 +60,7 @@ public class ServerConfigurator { f.load(spigotConfig); long tt = f.getLong("settings.timeout-time"); - if (tt < TimeUnit.MINUTES.toSeconds(5)) { + if(tt < TimeUnit.MINUTES.toSeconds(5)) { Iris.warn("Updating spigot.yml timeout-time: " + tt + " -> " + TimeUnit.MINUTES.toSeconds(5) + " (5 minutes)"); Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value."); f.set("settings.timeout-time", TimeUnit.MINUTES.toSeconds(5)); @@ -74,7 +74,7 @@ public class ServerConfigurator { f.load(spigotConfig); long tt = f.getLong("settings.watchdog.early-warning-delay"); - if (tt < TimeUnit.MINUTES.toMillis(3)) { + if(tt < TimeUnit.MINUTES.toMillis(3)) { Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes)"); Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value."); f.set("settings.watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3)); @@ -83,22 +83,22 @@ public class ServerConfigurator { } private static File getDatapacksFolder() { - if (!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) { + if(!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) { return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks"); } File props = new File("server.properties"); - if (props.exists()) { + if(props.exists()) { try { KList m = new KList<>(IO.readAll(props).split("\\Q\n\\E")); - for (String i : m) { - if (i.trim().startsWith("level-name=")) { + for(String i : m) { + if(i.trim().startsWith("level-name=")) { return new File(i.trim().split("\\Q=\\E")[1] + "/datapacks"); } } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -113,29 +113,29 @@ public class ServerConfigurator { File packs = new File("plugins/Iris/packs"); File dpacks = getDatapacksFolder(); - if (dpacks == null) { + if(dpacks == null) { Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?"); return; } - if (packs.exists()) { - for (File i : packs.listFiles()) { - if (i.isDirectory()) { + if(packs.exists()) { + for(File i : packs.listFiles()) { + if(i.isDirectory()) { Iris.verbose("Checking Pack: " + i.getPath()); IrisData data = IrisData.get(i); File dims = new File(i, "dimensions"); - if (dims.exists()) { - for (File j : dims.listFiles()) { - if (j.getName().endsWith(".json")) { + if(dims.exists()) { + for(File j : dims.listFiles()) { + if(j.getName().endsWith(".json")) { IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]); - if (dim == null) { + if(dim == null) { continue; } Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath()); - if (dim.installDataPack(() -> data, dpacks)) { + if(dim.installDataPack(() -> data, dpacks)) { reboot = true; } } @@ -147,7 +147,7 @@ public class ServerConfigurator { Iris.info("Data Packs Setup!"); - if (fullInstall) { + if(fullInstall) { verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall()); } } @@ -156,30 +156,30 @@ public class ServerConfigurator { File packs = new File("plugins/Iris/packs"); File dpacks = getDatapacksFolder(); - if (dpacks == null) { + if(dpacks == null) { Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?"); return; } boolean bad = false; - if (packs.exists()) { - for (File i : packs.listFiles()) { - if (i.isDirectory()) { + if(packs.exists()) { + for(File i : packs.listFiles()) { + if(i.isDirectory()) { Iris.verbose("Checking Pack: " + i.getPath()); IrisData data = IrisData.get(i); File dims = new File(i, "dimensions"); - if (dims.exists()) { - for (File j : dims.listFiles()) { - if (j.getName().endsWith(".json")) { + if(dims.exists()) { + for(File j : dims.listFiles()) { + if(j.getName().endsWith(".json")) { IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]); - if (dim == null) { + if(dim == null) { Iris.error("Failed to load " + j.getPath() + " "); continue; } - if (!verifyDataPackInstalled(dim)) { + if(!verifyDataPackInstalled(dim)) { bad = true; } } @@ -189,10 +189,10 @@ public class ServerConfigurator { } } - if (bad) { - if (allowRestarting) { + if(bad) { + if(allowRestarting) { restart(); - } else if (INMS.get().supportsDataPacks()) { + } else if(INMS.get().supportsDataPacks()) { Iris.error("============================================================================"); Iris.error(C.ITALIC + "You need to restart your server to properly generate custom biomes."); Iris.error(C.ITALIC + "By continuing, Iris will use backup biomes in place of the custom biomes."); @@ -200,8 +200,8 @@ public class ServerConfigurator { Iris.error(C.UNDERLINE + "IT IS HIGHLY RECOMMENDED YOU RESTART THE SERVER BEFORE GENERATING!"); Iris.error("============================================================================"); - for (Player i : Bukkit.getOnlinePlayers()) { - if (i.isOp() || i.hasPermission("iris.all")) { + for(Player i : Bukkit.getOnlinePlayers()) { + if(i.isOp() || i.hasPermission("iris.all")) { VolmitSender sender = new VolmitSender(i, Iris.instance.getTag("WARNING")); sender.sendMessage("There are some Iris Packs that have custom biomes in them"); sender.sendMessage("You need to restart your server to use these packs."); @@ -231,16 +231,16 @@ public class ServerConfigurator { KSet keys = new KSet<>(); boolean warn = false; - for (IrisBiome i : dimension.getAllBiomes(() -> idm)) { - if (i.isCustom()) { - for (IrisBiomeCustom j : i.getCustomDerivitives()) { + for(IrisBiome i : dimension.getAllBiomes(() -> idm)) { + if(i.isCustom()) { + for(IrisBiomeCustom j : i.getCustomDerivitives()) { keys.add(dimension.getLoadKey() + ":" + j.getId()); } } } - if (!INMS.get().supportsDataPacks()) { - if (!keys.isEmpty()) { + if(!INMS.get().supportsDataPacks()) { + if(!keys.isEmpty()) { Iris.warn("==================================================================================="); Iris.warn("Pack " + dimension.getLoadKey() + " has " + keys.size() + " custom biome(s). "); Iris.warn("Your server version does not yet support datapacks for iris."); @@ -251,16 +251,16 @@ public class ServerConfigurator { return true; } - for (String i : keys) { + for(String i : keys) { Object o = INMS.get().getCustomBiomeBaseFor(i); - if (o == null) { + if(o == null) { Iris.warn("The Biome " + i + " is not registered on the server."); warn = true; } } - if (warn) { + if(warn) { Iris.error("The Pack " + dimension.getLoadKey() + " is INCAPABLE of generating custom biomes"); Iris.error("If not done automatically, restart your server before generating with this pack!"); } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandEdit.java b/src/main/java/com/volmit/iris/core/commands/CommandEdit.java index 679071c6a..f953d631a 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandEdit.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandEdit.java @@ -19,44 +19,36 @@ package com.volmit.iris.core.commands; import com.volmit.iris.Iris; -import com.volmit.iris.core.edit.BlockSignal; -import com.volmit.iris.core.loader.IrisRegistrant; -import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.service.StudioSVC; -import com.volmit.iris.core.tools.IrisToolbelt; -import com.volmit.iris.engine.object.*; -import com.volmit.iris.util.data.B; +import com.volmit.iris.engine.object.IrisBiome; +import com.volmit.iris.engine.object.IrisCave; +import com.volmit.iris.engine.object.IrisDimension; +import com.volmit.iris.engine.object.IrisJigsawPiece; +import com.volmit.iris.engine.object.IrisJigsawPool; +import com.volmit.iris.engine.object.IrisJigsawStructure; +import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; -import com.volmit.iris.util.matter.MatterMarker; -import com.volmit.iris.util.scheduling.J; -import org.bukkit.Chunk; -import org.bukkit.FluidCollisionMode; -import org.bukkit.Material; -import org.bukkit.block.Biome; -import org.bukkit.block.data.BlockData; - -import java.awt.*; -import java.util.concurrent.atomic.AtomicInteger; +import java.awt.Desktop; @Decree(name = "edit", origin = DecreeOrigin.PLAYER, studio = true, description = "Edit something") public class CommandEdit implements DecreeExecutor { private boolean noStudio() { - if (!sender().isPlayer()) { + if(!sender().isPlayer()) { sender().sendMessage(C.RED + "Players only!"); return true; } - if (!Iris.service(StudioSVC.class).isProjectOpen()) { + if(!Iris.service(StudioSVC.class).isProjectOpen()) { sender().sendMessage(C.RED + "No studio world is open!"); return true; } - if (!engine().isStudio()) { + if(!engine().isStudio()) { sender().sendMessage(C.RED + "You must be in a studio world!"); return true; } @@ -64,18 +56,19 @@ public class CommandEdit implements DecreeExecutor { } - @Decree(description = "Edit the biome you specified", aliases = {"b"}, origin = DecreeOrigin.PLAYER) public void biome(@Param(contextual = false, description = "The biome to edit") IrisBiome biome) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( biome==null || biome.getLoadFile() == null) { + if(biome == null || biome.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(biome.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + biome.getTypeName() + " " + biome.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } @@ -83,15 +76,17 @@ public class CommandEdit implements DecreeExecutor { @Decree(description = "Edit the region you specified", aliases = {"r"}, origin = DecreeOrigin.PLAYER) public void region(@Param(contextual = false, description = "The region to edit") IrisRegion region) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( region==null || region.getLoadFile() == null) { + if(region == null || region.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(region.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + region.getTypeName() + " " + region.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } @@ -99,15 +94,17 @@ public class CommandEdit implements DecreeExecutor { @Decree(description = "Edit the dimension you specified", aliases = {"d"}, origin = DecreeOrigin.PLAYER) public void dimension(@Param(contextual = false, description = "The dimension to edit") IrisDimension dimension) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( dimension==null || dimension.getLoadFile() == null) { + if(dimension == null || dimension.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(dimension.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + dimension.getTypeName() + " " + dimension.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } @@ -115,15 +112,17 @@ public class CommandEdit implements DecreeExecutor { @Decree(description = "Edit the cave file you specified", aliases = {"c"}, origin = DecreeOrigin.PLAYER) public void cave(@Param(contextual = false, description = "The cave to edit") IrisCave cave) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( cave==null || cave.getLoadFile() == null) { + if(cave == null || cave.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(cave.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + cave.getTypeName() + " " + cave.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } @@ -131,15 +130,17 @@ public class CommandEdit implements DecreeExecutor { @Decree(description = "Edit the structure file you specified", aliases = {"jigsawstructure", "structure"}, origin = DecreeOrigin.PLAYER) public void jigsaw(@Param(contextual = false, description = "The jigsaw structure to edit") IrisJigsawStructure jigsaw) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( jigsaw==null || jigsaw.getLoadFile() == null) { + if(jigsaw == null || jigsaw.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(jigsaw.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + jigsaw.getTypeName() + " " + jigsaw.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } @@ -147,15 +148,17 @@ public class CommandEdit implements DecreeExecutor { @Decree(description = "Edit the pool file you specified", aliases = {"jigsawpool", "pool"}, origin = DecreeOrigin.PLAYER) public void jigsawPool(@Param(contextual = false, description = "The jigsaw pool to edit") IrisJigsawPool pool) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( pool==null || pool.getLoadFile() == null) { + if(pool == null || pool.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(pool.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + pool.getTypeName() + " " + pool.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } @@ -163,15 +166,17 @@ public class CommandEdit implements DecreeExecutor { @Decree(description = "Edit the jigsaw piece file you specified", aliases = {"jigsawpiece", "piece"}, origin = DecreeOrigin.PLAYER) public void jigsawPiece(@Param(contextual = false, description = "The jigsaw piece to edit") IrisJigsawPiece piece) { - if (noStudio()) {return;} + if(noStudio()) { + return; + } try { - if ( piece==null || piece.getLoadFile() == null) { + if(piece == null || piece.getLoadFile() == null) { sender().sendMessage(C.GOLD + "Cannot find the file; Perhaps it was not loaded directly from a file?"); return; } Desktop.getDesktop().open(piece.getLoadFile()); sender().sendMessage(C.GREEN + "Opening " + piece.getTypeName() + " " + piece.getLoadFile().getName().split("\\Q.\\E")[0] + " in VSCode! "); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Or registrant does not exist"); } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandFind.java b/src/main/java/com/volmit/iris/core/commands/CommandFind.java index 1592eba81..aad4a0914 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandFind.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandFind.java @@ -33,12 +33,12 @@ import com.volmit.iris.util.format.C; public class CommandFind implements DecreeExecutor { @Decree(description = "Find a biome") public void biome( - @Param(description = "The biome to look for") - IrisBiome biome + @Param(description = "The biome to look for") + IrisBiome biome ) { Engine e = engine(); - if (e == null) { + if(e == null) { sender().sendMessage(C.GOLD + "Not in an Iris World!"); return; } @@ -48,12 +48,12 @@ public class CommandFind implements DecreeExecutor { @Decree(description = "Find a region") public void region( - @Param(description = "The region to look for") - IrisRegion region + @Param(description = "The region to look for") + IrisRegion region ) { Engine e = engine(); - if (e == null) { + if(e == null) { sender().sendMessage(C.GOLD + "Not in an Iris World!"); return; } @@ -63,12 +63,12 @@ public class CommandFind implements DecreeExecutor { @Decree(description = "Find a structure") public void structure( - @Param(description = "The structure to look for") - IrisJigsawStructure structure + @Param(description = "The structure to look for") + IrisJigsawStructure structure ) { Engine e = engine(); - if (e == null) { + if(e == null) { sender().sendMessage(C.GOLD + "Not in an Iris World!"); return; } @@ -78,12 +78,12 @@ public class CommandFind implements DecreeExecutor { @Decree(description = "Find an object") public void object( - @Param(description = "The object to look for", customHandler = ObjectHandler.class) - String object + @Param(description = "The object to look for", customHandler = ObjectHandler.class) + String object ) { Engine e = engine(); - if (e == null) { + if(e == null) { sender().sendMessage(C.GOLD + "Not in an Iris World!"); return; } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandIris.java b/src/main/java/com/volmit/iris/core/commands/CommandIris.java index 768f2d2d1..73948cd38 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -58,20 +58,20 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Create a new world", aliases = {"+", "c"}) public void create( - @Param(aliases = "world-name", description = "The name of the world to create") - String name, - @Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") - IrisDimension type, - @Param(description = "The seed to generate the world with", defaultValue = "1337") - long seed + @Param(aliases = "world-name", description = "The name of the world to create") + String name, + @Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") + IrisDimension type, + @Param(description = "The seed to generate the world with", defaultValue = "1337") + long seed ) { - if (name.equals("iris")) { + if(name.equals("iris")) { sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds."); sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?"); return; } - if (new File(name).exists()) { + if(new File(name).exists()) { sender().sendMessage(C.RED + "That folder already exists!"); return; } @@ -80,13 +80,13 @@ public class CommandIris implements DecreeExecutor { try { IrisToolbelt.createWorld() - .dimension(type.getLoadKey()) - .name(name) - .seed(seed) - .sender(sender()) - .studio(false) - .create(); - } catch (Throwable e) { + .dimension(type.getLoadKey()) + .name(name) + .seed(seed) + .sender(sender()) + .studio(false) + .create(); + } catch(Throwable e) { sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details."); Iris.error("Exception raised during world creation: " + e.getMessage()); Iris.reportError(e); @@ -103,12 +103,12 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Set aura spins") public void aura( - @Param(description = "The h color value", defaultValue = "-20") - int h, - @Param(description = "The s color value", defaultValue = "7") - int s, - @Param(description = "The b color value", defaultValue = "8") - int b + @Param(description = "The h color value", defaultValue = "-20") + int h, + @Param(description = "The s color value", defaultValue = "7") + int s, + @Param(description = "The b color value", defaultValue = "8") + int b ) { IrisSettings.get().getGeneral().setSpinh(h); IrisSettings.get().getGeneral().setSpins(s); @@ -119,15 +119,15 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Bitwise calculations") public void bitwise( - @Param(description = "The first value to run calculations on") - int value1, - @Param(description = "The operator: | & ^ ≺≺ ≻≻ %") - String operator, - @Param(description = "The second value to run calculations on") - int value2 + @Param(description = "The first value to run calculations on") + int value1, + @Param(description = "The operator: | & ^ ≺≺ ≻≻ %") + String operator, + @Param(description = "The second value to run calculations on") + int value2 ) { Integer v = null; - switch (operator) { + switch(operator) { case "|" -> v = value1 | value2; case "&" -> v = value1 & value2; case "^" -> v = value1 ^ value2; @@ -135,7 +135,7 @@ public class CommandIris implements DecreeExecutor { case ">>" -> v = value1 >> value2; case "<<" -> v = value1 << value2; } - if (v == null) { + if(v == null) { sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!"); return; } @@ -144,8 +144,8 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Toggle debug") public void debug( - @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "other") - Boolean on + @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "other") + Boolean on ) { boolean to = on == null ? !IrisSettings.get().getGeneral().isDebug() : on; IrisSettings.get().getGeneral().setDebug(to); @@ -155,14 +155,14 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Download a project.", aliases = "dl") public void download( - @Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project") - String pack, - @Param(name = "branch", description = "The branch to download from", defaultValue = "master") - String branch, - @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false") - boolean trim, - @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") - boolean overwrite + @Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project") + String pack, + @Param(name = "branch", description = "The branch to download from", defaultValue = "master") + String branch, + @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false") + boolean trim, + @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") + boolean overwrite ) { branch = pack.equals("overworld") ? "stable" : branch; sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "") + (overwrite ? " overwriting" : "")); @@ -171,7 +171,7 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER) public void metrics() { - if (!IrisToolbelt.isIrisWorld(world())) { + if(!IrisToolbelt.isIrisWorld(world())) { sender().sendMessage(C.RED + "You must be in an Iris world"); return; } @@ -188,10 +188,10 @@ public class CommandIris implements DecreeExecutor { @Decree(name = "regen", description = "Regenerate nearby chunks.", aliases = "rg", sync = true, origin = DecreeOrigin.PLAYER) public void regen( - @Param(name = "radius", description = "The radius of nearby cunks", defaultValue = "5") - int radius + @Param(name = "radius", description = "The radius of nearby cunks", defaultValue = "5") + int radius ) { - if (IrisToolbelt.isIrisWorld(player().getWorld())) { + if(IrisToolbelt.isIrisWorld(player().getWorld())) { VolmitSender sender = sender(); J.a(() -> { DecreeContext.touch(sender); @@ -203,18 +203,18 @@ public class CommandIris implements DecreeExecutor { BurstExecutor b = MultiBurst.burst.burst(); b.setMulticore(false); int rad = engine.getMantle().getRealRadius(); - for (int i = -(radius + rad); i <= radius + rad; i++) { - for (int j = -(radius + rad); j <= radius + rad; j++) { + for(int i = -(radius + rad); i <= radius + rad; i++) { + for(int j = -(radius + rad); j <= radius + rad; j++) { engine.getMantle().getMantle().deleteChunk(i + cx.getX(), j + cx.getZ()); } } - for (int i = -radius; i <= radius; i++) { - for (int j = -radius; j <= radius; j++) { + for(int i = -radius; i <= radius; i++) { + for(int j = -radius; j <= radius; j++) { int finalJ = j; int finalI = i; b.queue(() -> plat.injectChunkReplacement(player().getWorld(), finalI + cx.getX(), finalJ + cx.getZ(), (f) -> { - synchronized (js) { + synchronized(js) { js.add(f); } })); @@ -230,11 +230,11 @@ public class CommandIris implements DecreeExecutor { public void execute(Runnable runnable) { futures.add(J.sfut(runnable)); - if (futures.size() > 64) { - while (futures.isNotEmpty()) { + if(futures.size() > 64) { + while(futures.isNotEmpty()) { try { futures.remove(0).get(); - } catch (InterruptedException | ExecutionException e) { + } catch(InterruptedException | ExecutionException e) { e.printStackTrace(); } } @@ -248,7 +248,7 @@ public class CommandIris implements DecreeExecutor { }; r.queue(js); r.execute(sender()); - } catch (Throwable e) { + } catch(Throwable e) { sender().sendMessage("Unable to parse view-distance"); } }); @@ -259,26 +259,26 @@ public class CommandIris implements DecreeExecutor { @Decree(description = "Update the pack of a world (UNSAFE!)", name = "^world", aliases = "update-world") public void updateWorld( - @Param(description = "The world to update", contextual = true) - World world, - @Param(description = "The pack to install into the world", contextual = true, aliases = "dimension") - IrisDimension pack, - @Param(description = "Make sure to make a backup & read the warnings first!", defaultValue = "false", aliases = "c") - boolean confirm, - @Param(description = "Should Iris download the pack again for you", defaultValue = "false", name = "fresh-download", aliases = {"fresh", "new"}) - boolean freshDownload + @Param(description = "The world to update", contextual = true) + World world, + @Param(description = "The pack to install into the world", contextual = true, aliases = "dimension") + IrisDimension pack, + @Param(description = "Make sure to make a backup & read the warnings first!", defaultValue = "false", aliases = "c") + boolean confirm, + @Param(description = "Should Iris download the pack again for you", defaultValue = "false", name = "fresh-download", aliases = {"fresh", "new"}) + boolean freshDownload ) { - if (!confirm) { - sender().sendMessage(new String[]{ - C.RED + "You should always make a backup before using this", - C.YELLOW + "Issues caused by this can be, but are not limited to:", - C.YELLOW + " - Broken chunks (cut-offs) between old and new chunks (before & after the update)", - C.YELLOW + " - Regenerated chunks that do not fit in with the old chunks", - C.YELLOW + " - Structures not spawning again when regenerating", - C.YELLOW + " - Caves not lining up", - C.YELLOW + " - Terrain layers not lining up", - C.RED + "Now that you are aware of the risks, and have made a back-up:", - C.RED + "/iris ^world confirm=true" + if(!confirm) { + sender().sendMessage(new String[] { + C.RED + "You should always make a backup before using this", + C.YELLOW + "Issues caused by this can be, but are not limited to:", + C.YELLOW + " - Broken chunks (cut-offs) between old and new chunks (before & after the update)", + C.YELLOW + " - Regenerated chunks that do not fit in with the old chunks", + C.YELLOW + " - Structures not spawning again when regenerating", + C.YELLOW + " - Caves not lining up", + C.YELLOW + " - Terrain layers not lining up", + C.RED + "Now that you are aware of the risks, and have made a back-up:", + C.RED + "/iris ^world confirm=true" }); return; } @@ -286,7 +286,7 @@ public class CommandIris implements DecreeExecutor { File folder = world.getWorldFolder(); folder.mkdirs(); - if (freshDownload) { + if(freshDownload) { Iris.service(StudioSVC.class).downloadSearch(sender(), pack.getLoadKey(), false, true); } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java b/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java index 57a0e0cad..3c862c925 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java @@ -42,8 +42,8 @@ import java.io.File; public class CommandJigsaw implements DecreeExecutor { @Decree(description = "Edit a jigsaw piece") public void edit( - @Param(description = "The jigsaw piece to edit") - IrisJigsawPiece piece + @Param(description = "The jigsaw piece to edit") + IrisJigsawPiece piece ) { File dest = piece.getLoadFile(); new JigsawEditor(player(), piece, IrisData.loadAnyObject(piece.getObject()), dest); @@ -51,8 +51,8 @@ public class CommandJigsaw implements DecreeExecutor { @Decree(description = "Place a jigsaw structure") public void place( - @Param(description = "The jigsaw structure to place") - IrisJigsawStructure structure + @Param(description = "The jigsaw structure to place") + IrisJigsawStructure structure ) { PrecisionStopwatch p = PrecisionStopwatch.start(); PlannedStructure ps = new PlannedStructure(structure, new IrisPosition(player().getLocation()), new RNG()); @@ -62,16 +62,16 @@ public class CommandJigsaw implements DecreeExecutor { @Decree(description = "Create a jigsaw piece") public void create( - @Param(description = "The name of the jigsaw piece") - String piece, - @Param(description = "The project to add the jigsaw piece to") - String project, - @Param(description = "The object to use for this piece", customHandler = ObjectHandler.class) - String object + @Param(description = "The name of the jigsaw piece") + String piece, + @Param(description = "The project to add the jigsaw piece to") + String project, + @Param(description = "The object to use for this piece", customHandler = ObjectHandler.class) + String object ) { IrisObject o = IrisData.loadAnyObject(object); - if (object == null) { + if(object == null) { sender().sendMessage(C.RED + "Failed to find existing object"); return; } @@ -88,7 +88,7 @@ public class CommandJigsaw implements DecreeExecutor { public void exit() { JigsawEditor editor = JigsawEditor.editors.get(player()); - if (editor == null) { + if(editor == null) { sender().sendMessage(C.GOLD + "You don't have any pieces open to exit!"); return; } @@ -101,7 +101,7 @@ public class CommandJigsaw implements DecreeExecutor { public void save() { JigsawEditor editor = JigsawEditor.editors.get(player()); - if (editor == null) { + if(editor == null) { sender().sendMessage(C.GOLD + "You don't have any pieces open to save!"); return; } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandObject.java b/src/main/java/com/volmit/iris/core/commands/CommandObject.java index 130e9ea2d..d08fcfcd5 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandObject.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandObject.java @@ -71,7 +71,7 @@ import java.util.stream.Collectors; public class CommandObject implements DecreeExecutor { private static final Set skipBlocks = Set.of(Material.GRASS, Material.SNOW, Material.VINE, Material.TORCH, Material.DEAD_BUSH, - Material.POPPY, Material.DANDELION); + Material.POPPY, Material.DANDELION); public static IObjectPlacer createPlacer(World world, Map futureBlockChanges) { @@ -91,7 +91,7 @@ public class CommandObject implements DecreeExecutor { Block block = world.getBlockAt(x, y, z); //Prevent blocks being set in or bellow bedrock - if (y <= world.getMinHeight() || block.getType() == Material.BEDROCK) return; + if(y <= world.getMinHeight() || block.getType() == Material.BEDROCK) return; futureBlockChanges.put(block, block.getBlockData()); @@ -149,8 +149,8 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Check the composition of an object") public void analyze( - @Param(description = "The object to analyze", customHandler = ObjectHandler.class) - String object + @Param(description = "The object to analyze", customHandler = ObjectHandler.class) + String object ) { IrisObject o = IrisData.loadAnyObject(object); sender().sendMessage("Object Size: " + o.getW() + " * " + o.getH() + " * " + o.getD() + ""); @@ -160,19 +160,19 @@ public class CommandObject implements DecreeExecutor { Map> unsorted = new HashMap<>(); Map amounts = new HashMap<>(); Map materials = new HashMap<>(); - while (queue.hasNext()) { + while(queue.hasNext()) { BlockData block = queue.next(); //unsorted.put(block.getMaterial(), block); - if (!amounts.containsKey(block)) { + if(!amounts.containsKey(block)) { amounts.put(block, 1); } else amounts.put(block, amounts.get(block) + 1); - if (!materials.containsKey(block.getMaterial())) { + if(!materials.containsKey(block.getMaterial())) { materials.put(block.getMaterial(), 1); unsorted.put(block.getMaterial(), new HashSet<>()); unsorted.get(block.getMaterial()).add(block); @@ -184,13 +184,13 @@ public class CommandObject implements DecreeExecutor { } List sortedMatsList = amounts.keySet().stream().map(BlockData::getMaterial) - .sorted().collect(Collectors.toList()); + .sorted().collect(Collectors.toList()); Set sortedMats = new TreeSet<>(Comparator.comparingInt(materials::get).reversed()); sortedMats.addAll(sortedMatsList); sender().sendMessage("== Blocks in object =="); int n = 0; - for (Material mat : sortedMats) { + for(Material mat : sortedMats) { int amount = materials.get(mat); List set = new ArrayList<>(unsorted.get(mat)); set.sort(Comparator.comparingInt(amounts::get).reversed()); @@ -198,17 +198,17 @@ public class CommandObject implements DecreeExecutor { int dataAmount = amounts.get(data); String string = " - " + mat.toString() + "*" + amount; - if (data.getAsString(true).contains("[")) { + if(data.getAsString(true).contains("[")) { string = string + " --> [" + data.getAsString(true).split("\\[")[1] - .replaceAll("true", ChatColor.GREEN + "true" + ChatColor.GRAY) - .replaceAll("false", ChatColor.RED + "false" + ChatColor.GRAY) + "*" + dataAmount; + .replaceAll("true", ChatColor.GREEN + "true" + ChatColor.GRAY) + .replaceAll("false", ChatColor.RED + "false" + ChatColor.GRAY) + "*" + dataAmount; } sender().sendMessage(string); n++; - if (n >= 10) { + if(n >= 10) { sender().sendMessage(" + " + (sortedMats.size() - n) + " other block types"); return; } @@ -223,10 +223,10 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Contract a selection based on your looking direction", aliases = "-") public void contract( - @Param(description = "The amount to inset by", defaultValue = "1") - int amount + @Param(description = "The amount to inset by", defaultValue = "1") + int amount ) { - if (!WandSVC.isHoldingWand(player())) { + if(!WandSVC.isHoldingWand(player())) { sender().sendMessage("Hold your wand."); return; } @@ -248,20 +248,20 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Set point 1 to look", aliases = "p1") public void position1( - @Param(description = "Whether to use your current position, or where you look", defaultValue = "true") - boolean here + @Param(description = "Whether to use your current position, or where you look", defaultValue = "true") + boolean here ) { - if (!WandSVC.isHoldingWand(player())) { + if(!WandSVC.isHoldingWand(player())) { sender().sendMessage("Ready your Wand."); return; } ItemStack wand = player().getInventory().getItemInMainHand(); - if (WandSVC.isWand(wand)) { + if(WandSVC.isWand(wand)) { Location[] g = WandSVC.getCuboid(wand); - if (!here) { + if(!here) { // TODO: WARNING HEIGHT g[1] = player().getTargetBlock(null, 256).getLocation().clone(); } else { @@ -273,20 +273,20 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Set point 2 to look", aliases = "p2") public void position2( - @Param(description = "Whether to use your current position, or where you look", defaultValue = "true") - boolean here + @Param(description = "Whether to use your current position, or where you look", defaultValue = "true") + boolean here ) { - if (!WandSVC.isHoldingWand(player())) { + if(!WandSVC.isHoldingWand(player())) { sender().sendMessage("Ready your Wand."); return; } ItemStack wand = player().getInventory().getItemInMainHand(); - if (WandSVC.isWand(wand)) { + if(WandSVC.isWand(wand)) { Location[] g = WandSVC.getCuboid(wand); - if (!here) { + if(!here) { // TODO: WARNING HEIGHT g[0] = player().getTargetBlock(null, 256).getLocation().clone(); } else { @@ -298,21 +298,21 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Paste an object", sync = true) public void paste( - @Param(description = "The object to paste", customHandler = ObjectHandler.class) - String object, - @Param(description = "Whether or not to edit the object (need to hold wand)", defaultValue = "false") - boolean edit, - @Param(description = "The amount of degrees to rotate by", defaultValue = "0") - int rotate, - @Param(description = "The factor by which to scale the object placement", defaultValue = "1") - double scale + @Param(description = "The object to paste", customHandler = ObjectHandler.class) + String object, + @Param(description = "Whether or not to edit the object (need to hold wand)", defaultValue = "false") + boolean edit, + @Param(description = "The amount of degrees to rotate by", defaultValue = "0") + int rotate, + @Param(description = "The factor by which to scale the object placement", defaultValue = "1") + double scale // , // @Param(description = "The scale interpolator to use", defaultValue = "none") // IrisObjectPlacementScaleInterpolator interpolator ) { IrisObject o = IrisData.loadAnyObject(object); double maxScale = Double.max(10 - o.getBlocks().size() / 10000d, 1); - if (scale > maxScale) { + if(scale > maxScale) { sender().sendMessage(C.YELLOW + "Indicated scale exceeds maximum. Downscaled to maximum: " + maxScale); scale = maxScale; } @@ -332,16 +332,16 @@ public class CommandObject implements DecreeExecutor { Iris.service(ObjectSVC.class).addChanges(futureChanges); - if (edit) { + if(edit) { ItemStack newWand = WandSVC.createWand(block.clone().subtract(o.getCenter()).add(o.getW() - 1, - o.getH() + o.getCenter().clone().getY() - 1, o.getD() - 1), block.clone().subtract(o.getCenter().clone().setY(0))); - if (WandSVC.isWand(wand)) { + o.getH() + o.getCenter().clone().getY() - 1, o.getD() - 1), block.clone().subtract(o.getCenter().clone().setY(0))); + if(WandSVC.isWand(wand)) { wand = newWand; player().getInventory().setItemInMainHand(wand); sender().sendMessage("Updated wand for " + "objects/" + o.getLoadKey() + ".iob "); } else { int slot = WandSVC.findWand(player().getInventory()); - if (slot == -1) { + if(slot == -1) { player().getInventory().addItem(newWand); sender().sendMessage("Given new wand for " + "objects/" + o.getLoadKey() + ".iob "); } else { @@ -356,29 +356,29 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Save an object") public void save( - @Param(description = "The dimension to store the object in", contextual = true) - IrisDimension dimension, - @Param(description = "The file to store it in, can use / for subfolders") - String name, - @Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force") - boolean overwrite + @Param(description = "The dimension to store the object in", contextual = true) + IrisDimension dimension, + @Param(description = "The file to store it in, can use / for subfolders") + String name, + @Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force") + boolean overwrite ) { IrisObject o = WandSVC.createSchematic(player().getInventory().getItemInMainHand()); - if (o == null) { + if(o == null) { sender().sendMessage(C.YELLOW + "You need to hold your wand!"); return; } File file = Iris.service(StudioSVC.class).getWorkspaceFile(dimension.getLoadKey(), "objects", name + ".iob"); - if (file.exists() && !overwrite) { + if(file.exists() && !overwrite) { sender().sendMessage(C.RED + "File already exists. Set overwrite=true to overwrite it."); return; } try { o.write(file); - } catch (IOException e) { + } catch(IOException e) { sender().sendMessage(C.RED + "Failed to save object because of an IOException: " + e.getMessage()); Iris.reportError(e); } @@ -389,10 +389,10 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Shift a selection in your looking direction", aliases = "-") public void shift( - @Param(description = "The amount to shift by", defaultValue = "1") - int amount + @Param(description = "The amount to shift by", defaultValue = "1") + int amount ) { - if (!WandSVC.isHoldingWand(player())) { + if(!WandSVC.isHoldingWand(player())) { sender().sendMessage("Hold your wand."); return; } @@ -413,8 +413,8 @@ public class CommandObject implements DecreeExecutor { @Decree(description = "Undo a number of pastes", aliases = "-") public void undo( - @Param(description = "The amount of pastes to undo", defaultValue = "1") - int amount + @Param(description = "The amount of pastes to undo", defaultValue = "1") + int amount ) { ObjectSVC service = Iris.service(ObjectSVC.class); int actualReverts = Math.min(service.getUndos().size(), amount); @@ -431,7 +431,7 @@ public class CommandObject implements DecreeExecutor { @Decree(name = "x&y", description = "Autoselect up, down & out", sync = true) public void xay() { - if (!WandSVC.isHoldingWand(player())) { + if(!WandSVC.isHoldingWand(player())) { sender().sendMessage(C.YELLOW + "Hold your wand!"); return; } @@ -444,7 +444,7 @@ public class CommandObject implements DecreeExecutor { Cuboid cursor = new Cuboid(a1, a2); Cuboid cursorx = new Cuboid(a1, a2); - while (!cursor.containsOnly(Material.AIR)) { + while(!cursor.containsOnly(Material.AIR)) { a1.add(new org.bukkit.util.Vector(0, 1, 0)); a2.add(new org.bukkit.util.Vector(0, 1, 0)); cursor = new Cuboid(a1, a2); @@ -453,7 +453,7 @@ public class CommandObject implements DecreeExecutor { a1.add(new org.bukkit.util.Vector(0, -1, 0)); a2.add(new org.bukkit.util.Vector(0, -1, 0)); - while (!cursorx.containsOnly(Material.AIR)) { + while(!cursorx.containsOnly(Material.AIR)) { a1x.add(new org.bukkit.util.Vector(0, -1, 0)); a2x.add(new org.bukkit.util.Vector(0, -1, 0)); cursorx = new Cuboid(a1x, a2x); @@ -478,7 +478,7 @@ public class CommandObject implements DecreeExecutor { @Decree(name = "x+y", description = "Autoselect up & out", sync = true) public void xpy() { - if (!WandSVC.isHoldingWand(player())) { + if(!WandSVC.isHoldingWand(player())) { sender().sendMessage(C.YELLOW + "Hold your wand!"); return; } @@ -490,7 +490,7 @@ public class CommandObject implements DecreeExecutor { Location a2 = b[1].clone(); Cuboid cursor = new Cuboid(a1, a2); - while (!cursor.containsOnly(Material.AIR)) { + while(!cursor.containsOnly(Material.AIR)) { a1.add(new Vector(0, 1, 0)); a2.add(new Vector(0, 1, 0)); cursor = new Cuboid(a1, a2); diff --git a/src/main/java/com/volmit/iris/core/commands/CommandPregen.java b/src/main/java/com/volmit/iris/core/commands/CommandPregen.java index 7c53a1693..3f9d108ab 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandPregen.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandPregen.java @@ -34,30 +34,30 @@ import org.bukkit.util.Vector; public class CommandPregen implements DecreeExecutor { @Decree(description = "Pregenerate a world") public void start( - @Param(description = "The radius of the pregen in blocks", aliases = "size") - int radius, - @Param(description = "The world to pregen", contextual = true) - World world, - @Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") - Vector center + @Param(description = "The radius of the pregen in blocks", aliases = "size") + int radius, + @Param(description = "The world to pregen", contextual = true) + World world, + @Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") + Vector center ) { try { - if (sender().isPlayer() && access() == null) { + if(sender().isPlayer() && access() == null) { sender().sendMessage(C.RED + "The engine access for this world is null!"); sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example."); } radius = Math.max(radius, 1024); int w = (radius >> 9 + 1) * 2; IrisToolbelt.pregenerate(PregenTask - .builder() - .center(new Position2(center)) - .width(w) - .height(w) - .build(), world); + .builder() + .center(new Position2(center)) + .width(w) + .height(w) + .build(), world); String msg = C.GREEN + "Pregen started in " + C.GOLD + world.getName() + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ(); sender().sendMessage(msg); Iris.info(msg); - } catch (Throwable e) { + } catch(Throwable e) { sender().sendMessage(C.RED + "Epic fail. See console."); Iris.reportError(e); e.printStackTrace(); @@ -66,7 +66,7 @@ public class CommandPregen implements DecreeExecutor { @Decree(description = "Stop the active pregeneration task", aliases = "x") public void stop() { - if (PregeneratorJob.shutdownInstance()) { + if(PregeneratorJob.shutdownInstance()) { sender().sendMessage(C.GREEN + "Stopped pregeneration task"); } else { sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop"); @@ -75,7 +75,7 @@ public class CommandPregen implements DecreeExecutor { @Decree(description = "Pause / continue the active pregeneration task", aliases = {"t", "resume", "unpause"}) public void pause() { - if (PregeneratorJob.pauseResume()) { + if(PregeneratorJob.pauseResume()) { sender().sendMessage(C.GREEN + "Paused/unpaused pregeneration task, now: " + (PregeneratorJob.isPaused() ? "Paused" : "Running") + "."); } else { sender().sendMessage(C.YELLOW + "No active pregeneration tasks to pause/unpause."); diff --git a/src/main/java/com/volmit/iris/core/commands/CommandStudio.java b/src/main/java/com/volmit/iris/core/commands/CommandStudio.java index 7f2a65a0f..ac69dd607 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandStudio.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandStudio.java @@ -23,7 +23,6 @@ import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.gui.VisionGUI; import com.volmit.iris.core.loader.IrisData; -import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.service.ConversionSVC; import com.volmit.iris.core.service.StudioSVC; @@ -82,7 +81,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; -import java.awt.Desktop; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -102,38 +100,39 @@ public class CommandStudio implements DecreeExecutor { public static String hrf(Duration duration) { return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase(); } + private CommandFind find; private CommandEdit edit; @Decree(description = "Download a project.", aliases = "dl") public void download( - @Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project") - String pack, - @Param(name = "branch", description = "The branch to download from", defaultValue = "master") - String branch, - @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false") - boolean trim, - @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") - boolean overwrite + @Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project") + String pack, + @Param(name = "branch", description = "The branch to download from", defaultValue = "master") + String branch, + @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false") + boolean trim, + @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") + boolean overwrite ) { new CommandIris().download(pack, branch, trim, overwrite); } @Decree(description = "Open a new studio world", aliases = "o", sync = true) public void open( - @Param(defaultValue = "overworld", description = "The dimension to open a studio for", aliases = "dim") - IrisDimension dimension, - @Param(defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") - long seed) { + @Param(defaultValue = "overworld", description = "The dimension to open a studio for", aliases = "dim") + IrisDimension dimension, + @Param(defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") + long seed) { sender().sendMessage(C.GREEN + "Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); Iris.service(StudioSVC.class).open(sender(), seed, dimension.getLoadKey()); } @Decree(description = "Open VSCode for a dimension", aliases = {"vsc", "edit"}) public void vscode( - @Param(defaultValue = "overworld", description = "The dimension to open VSCode for", aliases = "dim") - IrisDimension dimension + @Param(defaultValue = "overworld", description = "The dimension to open VSCode for", aliases = "dim") + IrisDimension dimension ) { sender().sendMessage(C.GREEN + "Opening VSCode for the \"" + dimension.getName() + "\" pack"); Iris.service(StudioSVC.class).openVSCode(sender(), dimension.getLoadKey()); @@ -141,7 +140,7 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Close an open studio project", aliases = {"x", "c"}, sync = true) public void close() { - if (!Iris.service(StudioSVC.class).isProjectOpen()) { + if(!Iris.service(StudioSVC.class).isProjectOpen()) { sender().sendMessage(C.RED + "No open studio projects."); return; } @@ -152,11 +151,11 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Create a new studio project", aliases = "+", sync = true) public void create( - @Param(description = "The name of this new Iris Project.") - String name, - @Param(description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", contextual = true) - IrisDimension template) { - if (template != null) { + @Param(description = "The name of this new Iris Project.") + String name, + @Param(description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", contextual = true) + IrisDimension template) { + if(template != null) { Iris.service(StudioSVC.class).create(sender(), name, template.getLoadKey()); } else { Iris.service(StudioSVC.class).create(sender(), name); @@ -165,17 +164,17 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Clean an Iris Project, optionally beautifying JSON & fixing block ids with missing keys. Also rebuilds the vscode schemas. ") public void clean( - @Param(description = "The project to update", contextual = true) - IrisDimension project, + @Param(description = "The project to update", contextual = true) + IrisDimension project, - @Param(defaultValue = "true", description = "Filters all valid JSON files with a beautifier (indentation: 4)") - boolean beautify, + @Param(defaultValue = "true", description = "Filters all valid JSON files with a beautifier (indentation: 4)") + boolean beautify, - @Param(name = "fix-ids", defaultValue = "true", description = "Fixes any block ids used such as \"dirt\" will be converted to \"minecraft:dirt\"") - boolean fixIds, + @Param(name = "fix-ids", defaultValue = "true", description = "Fixes any block ids used such as \"dirt\" will be converted to \"minecraft:dirt\"") + boolean fixIds, - @Param(name = "rewrite-objects", defaultValue = "false", description = "Imports all objects and re-writes them cleaning up positions & block data in the process.") - boolean rewriteObjects + @Param(name = "rewrite-objects", defaultValue = "false", description = "Imports all objects and re-writes them cleaning up positions & block data in the process.") + boolean rewriteObjects ) { KList jobs = new KList<>(); KList files = new KList(); @@ -183,7 +182,7 @@ public class CommandStudio implements DecreeExecutor { MultiBurst burst = MultiBurst.burst; jobs.add(new SingleJob("Updating Workspace", () -> { - if (!new IrisProject(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey())).updateWorkspace()) { + if(!new IrisProject(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey())).updateWorkspace()) { sender().sendMessage(C.GOLD + "Invalid project: " + project.getLoadKey() + ". Try deleting the code-workspace file and try again."); } J.sleep(250); @@ -191,7 +190,7 @@ public class CommandStudio implements DecreeExecutor { sender().sendMessage("Files: " + files.size()); - if (fixIds) { + if(fixIds) { QueueJob r = new QueueJob<>() { @Override public void execute(File f) { @@ -201,7 +200,7 @@ public class CommandStudio implements DecreeExecutor { J.sleep(1); IO.writeAll(f, p.toString(4)); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } } @@ -216,7 +215,7 @@ public class CommandStudio implements DecreeExecutor { jobs.add(r); } - if (beautify) { + if(beautify) { QueueJob r = new QueueJob<>() { @Override public void execute(File f) { @@ -224,7 +223,7 @@ public class CommandStudio implements DecreeExecutor { JSONObject p = new JSONObject(IO.readAll(f)); IO.writeAll(f, p.toString(4)); J.sleep(1); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } } @@ -239,7 +238,7 @@ public class CommandStudio implements DecreeExecutor { jobs.add(r); } - if (rewriteObjects) { + if(rewriteObjects) { QueueJob q = new QueueJob<>() { @Override public void execute(Runnable runnable) { @@ -254,20 +253,20 @@ public class CommandStudio implements DecreeExecutor { }; IrisData data = IrisData.get(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey())); - for (String f : data.getObjectLoader().getPossibleKeys()) { + for(String f : data.getObjectLoader().getPossibleKeys()) { Future gg = burst.complete(() -> { File ff = data.getObjectLoader().findFile(f); IrisObject oo = new IrisObject(0, 0, 0); try { oo.read(ff); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("FAILER TO READ: " + f); return; } try { oo.write(ff); - } catch (IOException e) { + } catch(IOException e) { Iris.error("FAILURE TO WRITE: " + oo.getLoadFile()); } }); @@ -275,7 +274,7 @@ public class CommandStudio implements DecreeExecutor { q.queue(() -> { try { gg.get(); - } catch (InterruptedException | ExecutionException e) { + } catch(InterruptedException | ExecutionException e) { e.printStackTrace(); } }); @@ -289,8 +288,8 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Get the version of a pack") public void version( - @Param(defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim", contextual = true) - IrisDimension dimension + @Param(defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim", contextual = true) + IrisDimension dimension ) { sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); } @@ -301,25 +300,24 @@ public class CommandStudio implements DecreeExecutor { } - @Decree(description = "Execute a script", aliases = "run", origin = DecreeOrigin.PLAYER) public void execute( - @Param(description = "The script to run") - IrisScript script + @Param(description = "The script to run") + IrisScript script ) { engine().getExecution().execute(script.getLoadKey()); } @Decree(description = "Open the noise explorer (External GUI)", aliases = {"nmap", "n"}) public void noise() { - if (noGUI()) return; + if(noGUI()) return; sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); NoiseExplorerGUI.launch(); } @Decree(description = "Charges all spawners in the area", aliases = "zzt", origin = DecreeOrigin.PLAYER) public void charge() { - if (!IrisToolbelt.isIrisWorld(world())) { + if(!IrisToolbelt.isIrisWorld(world())) { sender().sendMessage(C.RED + "You must be in an Iris world to charge spawners!"); return; } @@ -329,17 +327,17 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Preview noise gens (External GUI)", aliases = {"generator", "gen"}) public void explore( - @Param(description = "The generator to explore", contextual = true) - IrisGenerator generator, - @Param(description = "The seed to generate with", defaultValue = "12345") - long seed + @Param(description = "The generator to explore", contextual = true) + IrisGenerator generator, + @Param(description = "The seed to generate with", defaultValue = "12345") + long seed ) { - if (noGUI()) return; + if(noGUI()) return; sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); Supplier> l = () -> { - if (generator == null) { + if(generator == null) { return (x, z) -> 0D; } @@ -350,7 +348,7 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Hotload a studio", aliases = {"reload", "h"}) public void hotload() { - if (!Iris.service(StudioSVC.class).isProjectOpen()) { + if(!Iris.service(StudioSVC.class).isProjectOpen()) { sender().sendMessage(C.RED + "No studio world open!"); return; } @@ -360,19 +358,19 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER, sync = true) public void loot( - @Param(description = "Fast insertion of items in virtual inventory (may cause performance drop)", defaultValue = "false") - boolean fast, - @Param(description = "Whether or not to append to the inventory currently open (if false, clears opened inventory)", defaultValue = "true") - boolean add + @Param(description = "Fast insertion of items in virtual inventory (may cause performance drop)", defaultValue = "false") + boolean fast, + @Param(description = "Whether or not to append to the inventory currently open (if false, clears opened inventory)", defaultValue = "true") + boolean add ) { - if (noStudio()) return; + if(noStudio()) return; KList tables = engine().getLootTables(RNG.r, player().getLocation().getBlock()); Inventory inv = Bukkit.createInventory(null, 27 * 2); try { engine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cannot add items to virtual inventory because of: " + e.getMessage()); return; @@ -384,13 +382,13 @@ public class CommandStudio implements DecreeExecutor { ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> { - if (!player().getOpenInventory().getType().equals(InventoryType.CHEST)) { + if(!player().getOpenInventory().getType().equals(InventoryType.CHEST)) { Bukkit.getScheduler().cancelTask(ta.get()); sender().sendMessage(C.GREEN + "Opened inventory!"); return; } - if (!add) { + if(!add) { inv.clear(); } @@ -403,12 +401,12 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Render a world map (External GUI)", aliases = "render") public void map( - @Param(name = "world", description = "The world to open the generator for", contextual = true) + @Param(name = "world", description = "The world to open the generator for", contextual = true) World world ) { - if (noGUI()) return; + if(noGUI()) return; - if (!IrisToolbelt.isIrisWorld(world)) { + if(!IrisToolbelt.isIrisWorld(world)) { sender().sendMessage(C.RED + "You need to be in or specify an Iris-generated world!"); return; } @@ -419,20 +417,20 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Package a dimension into a compressed format", aliases = "package") public void pkg( - @Param(name = "dimension", description = "The dimension pack to compress", contextual = true, defaultValue = "overworld") - IrisDimension dimension, - @Param(name = "obfuscate", description = "Whether or not to obfuscate the pack", defaultValue = "false") - boolean obfuscate, - @Param(name = "minify", description = "Whether or not to minify the pack", defaultValue = "true") - boolean minify + @Param(name = "dimension", description = "The dimension pack to compress", contextual = true, defaultValue = "overworld") + IrisDimension dimension, + @Param(name = "obfuscate", description = "Whether or not to obfuscate the pack", defaultValue = "false") + boolean obfuscate, + @Param(name = "minify", description = "Whether or not to minify the pack", defaultValue = "true") + boolean minify ) { Iris.service(StudioSVC.class).compilePackage(sender(), dimension.getLoadKey(), obfuscate, minify); } @Decree(description = "Profiles the performance of a dimension", origin = DecreeOrigin.PLAYER) public void profile( - @Param(description = "The dimension to profile", contextual = true, defaultValue = "overworld") - IrisDimension dimension + @Param(description = "The dimension to profile", contextual = true, defaultValue = "overworld") + IrisDimension dimension ) { File pack = dimension.getLoadFile().getParentFile().getParentFile(); File report = Iris.instance.getDataFile("profile.txt"); @@ -449,17 +447,17 @@ public class CommandStudio implements DecreeExecutor { sender().sendMessage("Calculating Performance Metrics for Noise generators"); - for (NoiseStyle i : NoiseStyle.values()) { + for(NoiseStyle i : NoiseStyle.values()) { CNG c = i.create(new RNG(i.hashCode())); - for (int j = 0; j < 3000; j++) { + for(int j = 0; j < 3000; j++) { c.noise(j, j + 1000, j * j); c.noise(j, -j); } PrecisionStopwatch px = PrecisionStopwatch.start(); - for (int j = 0; j < 100000; j++) { + for(int j = 0; j < 100000; j++) { c.noise(j, j + 1000, j * j); c.noise(j, -j); } @@ -469,7 +467,7 @@ public class CommandStudio implements DecreeExecutor { fileText.add("Noise Style Performance Impacts: "); - for (NoiseStyle i : styleTimings.sortKNumber()) { + for(NoiseStyle i : styleTimings.sortKNumber()) { fileText.add(i.name() + ": " + styleTimings.get(i)); } @@ -477,20 +475,20 @@ public class CommandStudio implements DecreeExecutor { sender().sendMessage("Calculating Interpolator Timings..."); - for (InterpolationMethod i : InterpolationMethod.values()) { + for(InterpolationMethod i : InterpolationMethod.values()) { IrisInterpolator in = new IrisInterpolator(); in.setFunction(i); in.setHorizontalScale(8); NoiseProvider np = (x, z) -> Math.random(); - for (int j = 0; j < 3000; j++) { + for(int j = 0; j < 3000; j++) { in.interpolate(j, -j, np); } PrecisionStopwatch px = PrecisionStopwatch.start(); - for (int j = 0; j < 100000; j++) { + for(int j = 0; j < 100000; j++) { in.interpolate(j + 10000, -j - 100000, np); } @@ -499,7 +497,7 @@ public class CommandStudio implements DecreeExecutor { fileText.add("Noise Interpolator Performance Impacts: "); - for (InterpolationMethod i : interpolatorTimings.sortKNumber()) { + for(InterpolationMethod i : interpolatorTimings.sortKNumber()) { fileText.add(i.name() + ": " + interpolatorTimings.get(i)); } @@ -509,13 +507,13 @@ public class CommandStudio implements DecreeExecutor { KMap> btx = new KMap<>(); - for (String i : data.getGeneratorLoader().getPossibleKeys()) { + for(String i : data.getGeneratorLoader().getPossibleKeys()) { KList vv = new KList<>(); IrisGenerator g = data.getGeneratorLoader().load(i); KList composites = g.getAllComposites(); double score = 0; int m = 0; - for (IrisNoiseGenerator j : composites) { + for(IrisNoiseGenerator j : composites) { m++; score += styleTimings.get(j.getStyle().getStyle()); vv.add("Composite Noise Style " + m + " " + j.getStyle().getStyle().name() + ": " + styleTimings.get(j.getStyle().getStyle())); @@ -529,7 +527,7 @@ public class CommandStudio implements DecreeExecutor { fileText.add("Project Generator Performance Impacts: "); - for (String i : generatorTimings.sortKNumber()) { + for(String i : generatorTimings.sortKNumber()) { fileText.add(i + ": " + generatorTimings.get(i)); btx.get(i).forEach((ii) -> fileText.add(" " + ii)); @@ -539,13 +537,13 @@ public class CommandStudio implements DecreeExecutor { KMap> bt = new KMap<>(); - for (String i : data.getBiomeLoader().getPossibleKeys()) { + for(String i : data.getBiomeLoader().getPossibleKeys()) { KList vv = new KList<>(); IrisBiome b = data.getBiomeLoader().load(i); double score = 0; int m = 0; - for (IrisBiomePaletteLayer j : b.getLayers()) { + for(IrisBiomePaletteLayer j : b.getLayers()) { m++; score += styleTimings.get(j.getStyle().getStyle()); vv.add("Palette Layer " + m + ": " + styleTimings.get(j.getStyle().getStyle())); @@ -561,7 +559,7 @@ public class CommandStudio implements DecreeExecutor { fileText.add("Project Biome Performance Impacts: "); - for (String i : biomeTimings.sortKNumber()) { + for(String i : biomeTimings.sortKNumber()) { fileText.add(i + ": " + biomeTimings.get(i)); bt.get(i).forEach((ff) -> fileText.add(" " + ff)); @@ -569,7 +567,7 @@ public class CommandStudio implements DecreeExecutor { fileText.add(""); - for (String i : data.getRegionLoader().getPossibleKeys()) { + for(String i : data.getRegionLoader().getPossibleKeys()) { IrisRegion b = data.getRegionLoader().load(i); double score = 0; @@ -580,25 +578,25 @@ public class CommandStudio implements DecreeExecutor { fileText.add("Project Region Performance Impacts: "); - for (String i : regionTimings.sortKNumber()) { + for(String i : regionTimings.sortKNumber()) { fileText.add(i + ": " + regionTimings.get(i)); } fileText.add(""); double m = 0; - for (double i : biomeTimings.v()) { + for(double i : biomeTimings.v()) { m += i; } m /= biomeTimings.size(); double mm = 0; - for (double i : generatorTimings.v()) { + for(double i : generatorTimings.v()) { mm += i; } mm /= generatorTimings.size(); m += mm; double mmm = 0; - for (double i : regionTimings.v()) { + for(double i : regionTimings.v()) { mmm += i; } mmm /= regionTimings.size(); @@ -609,7 +607,7 @@ public class CommandStudio implements DecreeExecutor { try { IO.writeAll(report, fileText.toString("\n")); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -619,12 +617,12 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER) public void summon( - @Param(description = "The Iris Entity to spawn") - IrisEntity entity, - @Param(description = "The location at which to spawn the entity", defaultValue = "self") - Vector location + @Param(description = "The Iris Entity to spawn") + IrisEntity entity, + @Param(description = "The location at which to spawn the entity", defaultValue = "self") + Vector location ) { - if (!sender().isPlayer()) { + if(!sender().isPlayer()) { sender().sendMessage(C.RED + "Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)"); return; } @@ -635,12 +633,12 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Teleport to the active studio world", aliases = "stp", origin = DecreeOrigin.PLAYER, sync = true) public void tpstudio() { - if (!Iris.service(StudioSVC.class).isProjectOpen()) { + if(!Iris.service(StudioSVC.class).isProjectOpen()) { sender().sendMessage(C.RED + "No studio world is open!"); return; } - if (IrisToolbelt.isIrisWorld(world()) && engine().isStudio()) { + if(IrisToolbelt.isIrisWorld(world()) && engine().isStudio()) { sender().sendMessage(C.RED + "You are already in a studio world!"); return; } @@ -652,11 +650,11 @@ public class CommandStudio implements DecreeExecutor { @Decree(description = "Update your dimension projects VSCode workspace") public void update( - @Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld") - IrisDimension dimension + @Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld") + IrisDimension dimension ) { sender().sendMessage(C.GOLD + "Updating Code Workspace for " + dimension.getName() + "..."); - if (new IrisProject(dimension.getLoader().getDataFolder()).updateWorkspace()) { + if(new IrisProject(dimension.getLoader().getDataFolder()).updateWorkspace()) { sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName()); } else { sender().sendMessage(C.RED + "Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again."); @@ -665,14 +663,14 @@ public class CommandStudio implements DecreeExecutor { @Decree(aliases = "find-objects", description = "Get information about nearby structures") public void objects() { - if (!IrisToolbelt.isIrisWorld(player().getWorld())) { + if(!IrisToolbelt.isIrisWorld(player().getWorld())) { sender().sendMessage(C.RED + "You must be in an Iris world"); return; } World world = player().getWorld(); - if (!IrisToolbelt.isIrisWorld(world)) { + if(!IrisToolbelt.isIrisWorld(world)) { sender().sendMessage("You must be in an iris world."); return; } @@ -686,7 +684,7 @@ public class CommandStudio implements DecreeExecutor { int cx = l.getChunk().getX(); int cz = l.getChunk().getZ(); new Spiraler(3, 3, (x, z) -> chunks.addIfMissing(world.getChunkAt(x + cx, z + cz))).drain(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -704,7 +702,7 @@ public class CommandStudio implements DecreeExecutor { pw.println("Report Captured At: " + new Date()); pw.println("Chunks: (" + chunks.size() + "): "); - for (Chunk i : chunks) { + for(Chunk i : chunks) { pw.println("- [" + i.getX() + ", " + i.getZ() + "]"); } @@ -713,19 +711,19 @@ public class CommandStudio implements DecreeExecutor { String age = "No idea..."; try { - for (File i : Objects.requireNonNull(new File(world.getWorldFolder(), "region").listFiles())) { - if (i.isFile()) { + for(File i : Objects.requireNonNull(new File(world.getWorldFolder(), "region").listFiles())) { + if(i.isFile()) { size += i.length(); } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } try { FileTime creationTime = (FileTime) Files.getAttribute(world.getWorldFolder().toPath(), "creationTime"); age = hrf(Duration.of(M.ms() - creationTime.toMillis(), ChronoUnit.MILLIS)); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } @@ -733,10 +731,10 @@ public class CommandStudio implements DecreeExecutor { KList caveBiomes = new KList<>(); KMap>> objects = new KMap<>(); - for (Chunk i : chunks) { - for (int j = 0; j < 16; j += 3) { + for(Chunk i : chunks) { + for(int j = 0; j < 16; j += 3) { - for (int k = 0; k < 16; k += 3) { + for(int k = 0; k < 16; k += 3) { assert engine() != null; IrisBiome bb = engine().getSurfaceBiome((i.getX() * 16) + j, (i.getZ() * 16) + k); @@ -763,20 +761,20 @@ public class CommandStudio implements DecreeExecutor { pw.println("== Biome Info =="); pw.println("Found " + biomes.size() + " Biome(s): "); - for (String i : biomes) { + for(String i : biomes) { pw.println("- " + i); } pw.println(); pw.println("== Object Info =="); - for (String i : objects.k()) { + for(String i : objects.k()) { pw.println("- " + i); - for (String j : objects.get(i).k()) { + for(String j : objects.get(i).k()) { pw.println(" @ " + j); - for (String k : objects.get(i).get(j)) { + for(String k : objects.get(i).get(j)) { pw.println(" * " + k); } } @@ -786,7 +784,7 @@ public class CommandStudio implements DecreeExecutor { pw.close(); sender().sendMessage("Reported to: " + ff.getPath()); - } catch (FileNotFoundException e) { + } catch(FileNotFoundException e) { e.printStackTrace(); Iris.reportError(e); } @@ -796,15 +794,15 @@ public class CommandStudio implements DecreeExecutor { String n1 = bb.getName() + " [" + Form.capitalize(bb.getInferredType().name().toLowerCase()) + "] " + " (" + bb.getLoadFile().getName() + ")"; int m = 0; KSet stop = new KSet<>(); - for (IrisObjectPlacement f : bb.getObjects()) { + for(IrisObjectPlacement f : bb.getObjects()) { m++; String n2 = "Placement #" + m + " (" + f.getPlace().size() + " possible objects)"; - for (String i : f.getPlace()) { + for(String i : f.getPlace()) { String nn3 = i + ": [ERROR] Failed to find object!"; try { - if (stop.contains(i)) { + if(stop.contains(i)) { continue; } @@ -812,13 +810,13 @@ public class CommandStudio implements DecreeExecutor { BlockVector sz = IrisObject.sampleSize(ff); nn3 = i + ": size=[" + sz.getBlockX() + "," + sz.getBlockY() + "," + sz.getBlockZ() + "] location=[" + ff.getPath() + "]"; stop.add(i); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } String n3 = nn3; objects.computeIfAbsent(n1, (k1) -> new KMap<>()) - .computeIfAbsent(n2, (k) -> new KList<>()).addIfMissing(n3); + .computeIfAbsent(n2, (k) -> new KList<>()).addIfMissing(n3); } } } @@ -827,7 +825,7 @@ public class CommandStudio implements DecreeExecutor { * @return true if server GUIs are not enabled */ private boolean noGUI() { - if (!IrisSettings.get().getGui().isUseServerLaunchedGuis()) { + if(!IrisSettings.get().getGui().isUseServerLaunchedGuis()) { sender().sendMessage(C.RED + "You must have server launched GUIs enabled in the settings!"); return true; } @@ -838,15 +836,15 @@ public class CommandStudio implements DecreeExecutor { * @return true if no studio is open or the player is not in one */ private boolean noStudio() { - if (!sender().isPlayer()) { + if(!sender().isPlayer()) { sender().sendMessage(C.RED + "Players only!"); return true; } - if (!Iris.service(StudioSVC.class).isProjectOpen()) { + if(!Iris.service(StudioSVC.class).isProjectOpen()) { sender().sendMessage(C.RED + "No studio world is open!"); return true; } - if (!engine().isStudio()) { + if(!engine().isStudio()) { sender().sendMessage(C.RED + "You must be in a studio world!"); return true; } @@ -855,14 +853,14 @@ public class CommandStudio implements DecreeExecutor { public void files(File clean, KList files) { - if (clean.isDirectory()) { - for (File i : clean.listFiles()) { + if(clean.isDirectory()) { + for(File i : clean.listFiles()) { files(i, files); } - } else if (clean.getName().endsWith(".json")) { + } else if(clean.getName().endsWith(".json")) { try { files.add(clean); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!"); } @@ -870,28 +868,28 @@ public class CommandStudio implements DecreeExecutor { } private void fixBlocks(JSONObject obj) { - for (String i : obj.keySet()) { + for(String i : obj.keySet()) { Object o = obj.get(i); - if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { + if(i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { obj.put(i, "minecraft:" + o); } - if (o instanceof JSONObject) { + if(o instanceof JSONObject) { fixBlocks((JSONObject) o); - } else if (o instanceof JSONArray) { + } else if(o instanceof JSONArray) { fixBlocks((JSONArray) o); } } } private void fixBlocks(JSONArray obj) { - for (int i = 0; i < obj.length(); i++) { + for(int i = 0; i < obj.length(); i++) { Object o = obj.get(i); - if (o instanceof JSONObject) { + if(o instanceof JSONObject) { fixBlocks((JSONObject) o); - } else if (o instanceof JSONArray) { + } else if(o instanceof JSONArray) { fixBlocks((JSONArray) o); } } diff --git a/src/main/java/com/volmit/iris/core/commands/CommandWhat.java b/src/main/java/com/volmit/iris/core/commands/CommandWhat.java index 884621c93..20e806a01 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandWhat.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandWhat.java @@ -45,16 +45,16 @@ public class CommandWhat implements DecreeExecutor { public void hand() { try { BlockData bd = player().getInventory().getItemInMainHand().getType().createBlockData(); - if (!bd.getMaterial().equals(Material.AIR)) { + if(!bd.getMaterial().equals(Material.AIR)) { sender().sendMessage("Material: " + C.GREEN + bd.getMaterial().name()); sender().sendMessage("Full: " + C.WHITE + bd.getAsString(true)); } else { sender().sendMessage("Please hold a block/item"); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Material bd = player().getInventory().getItemInMainHand().getType(); - if (!bd.equals(Material.AIR)) { + if(!bd.equals(Material.AIR)) { sender().sendMessage("Material: " + C.GREEN + bd.name()); } else { sender().sendMessage("Please hold a block/item"); @@ -68,14 +68,14 @@ public class CommandWhat implements DecreeExecutor { IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ()); sender().sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")"); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); sender().sendMessage("Non-Iris Biome: " + player().getLocation().getBlock().getBiome().name()); - if (player().getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) { + if(player().getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) { try { sender().sendMessage("Data Pack Biome: " + INMS.get().getTrueBiomeBaseKey(player().getLocation()) + " (ID: " + INMS.get().getTrueBiomeBaseId(INMS.get().getTrueBiomeBase(player().getLocation())) + ")"); - } catch (Throwable ee) { + } catch(Throwable ee) { Iris.reportError(ee); } } @@ -87,41 +87,41 @@ public class CommandWhat implements DecreeExecutor { BlockData bd; try { bd = player().getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData(); - } catch (NullPointerException e) { + } catch(NullPointerException e) { Iris.reportError(e); sender().sendMessage("Please look at any block, not at the sky"); bd = null; } - if (bd != null) { + if(bd != null) { sender().sendMessage("Material: " + C.GREEN + bd.getMaterial().name()); sender().sendMessage("Full: " + C.WHITE + bd.getAsString(true)); - if (B.isStorage(bd)) { + if(B.isStorage(bd)) { sender().sendMessage(C.YELLOW + "* Storage Block (Loot Capable)"); } - if (B.isLit(bd)) { + if(B.isLit(bd)) { sender().sendMessage(C.YELLOW + "* Lit Block (Light Capable)"); } - if (B.isFoliage(bd)) { + if(B.isFoliage(bd)) { sender().sendMessage(C.YELLOW + "* Foliage Block"); } - if (B.isDecorant(bd)) { + if(B.isDecorant(bd)) { sender().sendMessage(C.YELLOW + "* Decorant Block"); } - if (B.isFluid(bd)) { + if(B.isFluid(bd)) { sender().sendMessage(C.YELLOW + "* Fluid Block"); } - if (B.isFoliagePlantable(bd)) { + if(B.isFoliagePlantable(bd)) { sender().sendMessage(C.YELLOW + "* Plantable Foliage Block"); } - if (B.isSolid(bd)) { + if(B.isSolid(bd)) { sender().sendMessage(C.YELLOW + "* Solid Block"); } } @@ -131,17 +131,17 @@ public class CommandWhat implements DecreeExecutor { public void markers(@Param(description = "Marker name such as cave_floor or cave_ceiling") String marker) { Chunk c = player().getLocation().getChunk(); - if (IrisToolbelt.isIrisWorld(c.getWorld())) { + if(IrisToolbelt.isIrisWorld(c.getWorld())) { int m = 1; AtomicInteger v = new AtomicInteger(0); - for (int xxx = c.getX() - 4; xxx <= c.getX() + 4; xxx++) { - for (int zzz = c.getZ() - 4; zzz <= c.getZ() + 4; zzz++) { + for(int xxx = c.getX() - 4; xxx <= c.getX() + 4; xxx++) { + for(int zzz = c.getZ() - 4; zzz <= c.getZ() + 4; zzz++) { IrisToolbelt.access(c.getWorld()).getEngine().getMantle().findMarkers(xxx, zzz, new MatterMarker(marker)) - .convert((i) -> i.toLocation(c.getWorld())).forEach((i) -> { - J.s(() -> BlockSignal.of(i.getBlock(), 100)); - v.incrementAndGet(); - }); + .convert((i) -> i.toLocation(c.getWorld())).forEach((i) -> { + J.s(() -> BlockSignal.of(i.getBlock(), 100)); + v.incrementAndGet(); + }); } } diff --git a/src/main/java/com/volmit/iris/core/edit/BlockSignal.java b/src/main/java/com/volmit/iris/core/edit/BlockSignal.java index efa0375b9..148ebb468 100644 --- a/src/main/java/com/volmit/iris/core/edit/BlockSignal.java +++ b/src/main/java/com/volmit/iris/core/edit/BlockSignal.java @@ -52,7 +52,7 @@ public class BlockSignal { active.decrementAndGet(); BlockData type = block.getBlockData(); MultiBurst.burst.lazy(() -> { - for (Player i : block.getWorld().getPlayers()) { + for(Player i : block.getWorld().getPlayers()) { i.sendBlockChange(block.getLocation(), block.getBlockData()); } }); @@ -83,7 +83,7 @@ public class BlockSignal { new SR(20) { @Override public void run() { - if (e.isDead()) { + if(e.isDead()) { cancel(); return; } @@ -99,7 +99,7 @@ public class BlockSignal { BlockData type = block.getBlockData(); MultiBurst.burst.lazy(() -> { - for (Player i : block.getWorld().getPlayers()) { + for(Player i : block.getWorld().getPlayers()) { i.sendBlockChange(block.getLocation(), block.getBlockData()); } }); diff --git a/src/main/java/com/volmit/iris/core/edit/DustRevealer.java b/src/main/java/com/volmit/iris/core/edit/DustRevealer.java index 9a5934dd7..4582306c4 100644 --- a/src/main/java/com/volmit/iris/core/edit/DustRevealer.java +++ b/src/main/java/com/volmit/iris/core/edit/DustRevealer.java @@ -50,11 +50,11 @@ public class DustRevealer { J.s(() -> { new BlockSignal(world.getBlockAt(block.getX(), block.getY(), block.getZ()), 7); - if (M.r(0.25)) { + if(M.r(0.25)) { world.playSound(block.toBlock(world).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1f, RNG.r.f(0.2f, 2f)); } J.a(() -> { - while (BlockSignal.active.get() > 128) { + while(BlockSignal.active.get() > 128) { J.sleep(5); } @@ -85,7 +85,7 @@ public class DustRevealer { is(new BlockPosition(block.getX() + 1, block.getY() + 1, block.getZ() + 1)); is(new BlockPosition(block.getX() + 1, block.getY() - 1, block.getZ() - 1)); is(new BlockPosition(block.getX() + 1, block.getY() - 1, block.getZ() + 1)); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -97,10 +97,10 @@ public class DustRevealer { World world = block.getWorld(); Engine access = IrisToolbelt.access(world).getEngine(); - if (access != null) { + if(access != null) { String a = access.getObjectPlacementKey(block.getX(), block.getY(), block.getZ()); - if (a != null) { + if(a != null) { world.playSound(block.getLocation(), Sound.ITEM_LODESTONE_COMPASS_LOCK, 1f, 0.1f); sender.sendMessage("Found object " + a); @@ -112,7 +112,7 @@ public class DustRevealer { } private boolean is(BlockPosition a) { - if (isValidTry(a) && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()) != null && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()).equals(key)) { + if(isValidTry(a) && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()) != null && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()).equals(key)) { hits.add(a); new DustRevealer(engine, world, a, key, hits); return true; diff --git a/src/main/java/com/volmit/iris/core/edit/JigsawEditor.java b/src/main/java/com/volmit/iris/core/edit/JigsawEditor.java index a8eb4d8bb..2161e7445 100644 --- a/src/main/java/com/volmit/iris/core/edit/JigsawEditor.java +++ b/src/main/java/com/volmit/iris/core/edit/JigsawEditor.java @@ -63,7 +63,7 @@ public class JigsawEditor implements Listener { private Location target; public JigsawEditor(Player player, IrisJigsawPiece piece, IrisObject object, File saveLocation) { - if (editors.containsKey(player)) { + if(editors.containsKey(player)) { editors.get(player).close(); } @@ -83,20 +83,20 @@ public class JigsawEditor implements Listener { @EventHandler public void on(PlayerMoveEvent e) { - if (e.getPlayer().equals(player)) { + if(e.getPlayer().equals(player)) { try { target = player.getTargetBlockExact(7).getLocation(); - } catch (Throwable ex) { + } catch(Throwable ex) { Iris.reportError(ex); target = player.getLocation(); return; } - if (cuboid.contains(target)) { - for (IrisPosition i : falling.k()) { + if(cuboid.contains(target)) { + for(IrisPosition i : falling.k()) { Location at = toLocation(i); - if (at.equals(target)) { + if(at.equals(target)) { falling.remove(i).run(); } } @@ -106,43 +106,43 @@ public class JigsawEditor implements Listener { public Location toLocation(IrisPosition i) { return origin.clone() - .add(new Vector(i.getX(), i.getY(), i.getZ())) - .add(object.getCenter()) - .getBlock() - .getLocation(); + .add(new Vector(i.getX(), i.getY(), i.getZ())) + .add(object.getCenter()) + .getBlock() + .getLocation(); } public IrisPosition toPosition(Location l) { return new IrisPosition(l.clone().getBlock().getLocation() - .subtract(origin.clone()) - .subtract(object.getCenter()) - .add(1, 1, 1) - .toVector()); + .subtract(origin.clone()) + .subtract(object.getCenter()) + .add(1, 1, 1) + .toVector()); } @EventHandler public void on(PlayerInteractEvent e) { - if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { - if (e.getClickedBlock() != null && cuboid.contains(e.getClickedBlock().getLocation()) && e.getPlayer().equals(player)) { + if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + if(e.getClickedBlock() != null && cuboid.contains(e.getClickedBlock().getLocation()) && e.getPlayer().equals(player)) { IrisPosition pos = toPosition(e.getClickedBlock().getLocation()); IrisJigsawPieceConnector connector = null; - for (IrisJigsawPieceConnector i : piece.getConnectors()) { - if (i.getPosition().equals(pos)) { + for(IrisJigsawPieceConnector i : piece.getConnectors()) { + if(i.getPosition().equals(pos)) { connector = i; break; } } - if (!player.isSneaking() && connector == null) { + if(!player.isSneaking() && connector == null) { connector = new IrisJigsawPieceConnector(); connector.setDirection(IrisDirection.getDirection(e.getBlockFace())); connector.setPosition(pos); piece.getConnectors().add(connector); player.playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ITEM_FRAME_ADD_ITEM, 1f, 1f); - } else if (player.isSneaking() && connector != null) { + } else if(player.isSneaking() && connector != null) { piece.getConnectors().remove(connector); player.playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1f, 1f); - } else if (connector != null && !player.isSneaking()) { + } else if(connector != null && !player.isSneaking()) { connector.setDirection(IrisDirection.getDirection(e.getBlockFace())); player.playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 1f); } @@ -154,7 +154,7 @@ public class JigsawEditor implements Listener { exit(); try { IO.writeAll(targetSaveLocation, new JSONObject(new Gson().toJson(piece)).toString(4)); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -168,20 +168,20 @@ public class JigsawEditor implements Listener { object.unplaceCenterY(origin); falling.v().forEach(Runnable::run); }).get(); - } catch (InterruptedException | ExecutionException e) { + } catch(InterruptedException | ExecutionException e) { e.printStackTrace(); } editors.remove(player); } public void onTick() { - if (cl.flip()) { + if(cl.flip()) { Iris.service(WandSVC.class).draw(cuboid, player); f: - for (IrisPosition i : falling.k()) { - for (IrisJigsawPieceConnector j : piece.getConnectors()) { - if (j.getPosition().equals(i)) { + for(IrisPosition i : falling.k()) { + for(IrisJigsawPieceConnector j : piece.getConnectors()) { + if(j.getPosition().equals(i)) { continue f; } } @@ -189,23 +189,23 @@ public class JigsawEditor implements Listener { falling.remove(i).run(); } - for (IrisJigsawPieceConnector i : piece.getConnectors()) { + for(IrisJigsawPieceConnector i : piece.getConnectors()) { IrisPosition pos = i.getPosition(); Location at = toLocation(pos); Vector dir = i.getDirection().toVector().clone(); - for (int ix = 0; ix < RNG.r.i(1, 3); ix++) { + for(int ix = 0; ix < RNG.r.i(1, 3); ix++) { at.getWorld().spawnParticle(Particle.SOUL_FIRE_FLAME, at.clone().getBlock().getLocation().add(0.25, 0.25, 0.25).add(RNG.r.d(0.5), RNG.r.d(0.5), RNG.r.d(0.5)), 0, dir.getX(), dir.getY(), dir.getZ(), 0.092 + RNG.r.d(-0.03, 0.08)); } - if (at.getBlock().getLocation().equals(target)) { + if(at.getBlock().getLocation().equals(target)) { continue; } - if (!falling.containsKey(pos)) { - if (at.getBlock().getType().isAir()) { + if(!falling.containsKey(pos)) { + if(at.getBlock().getType().isAir()) { at.getBlock().setType(Material.STONE); } diff --git a/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java b/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java index 75cb1065c..4f80abaaf 100644 --- a/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java +++ b/src/main/java/com/volmit/iris/core/gui/NoiseExplorerGUI.java @@ -133,10 +133,10 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List frame.add(pane); File file = Iris.getCached("Iris Icon", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/icon.png"); - if (file != null) { + if(file != null) { try { frame.setIconImage(ImageIO.read(file)); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } } @@ -167,10 +167,10 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List frame.add(pane); File file = Iris.getCached("Iris Icon", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/icon.png"); - if (file != null) { + if(file != null) { try { frame.setIconImage(ImageIO.read(file)); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } } @@ -194,14 +194,14 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List @EventHandler public void on(IrisEngineHotloadEvent e) { - if (generator != null) + if(generator != null) generator = loader.get(); } public void mouseWheelMoved(MouseWheelEvent e) { int notches = e.getWheelRotation(); - if (e.isControlDown()) { + if(e.isControlDown()) { t = t + ((0.0025 * t) * notches); return; } @@ -212,51 +212,51 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List @Override public void paint(Graphics g) { - if (scale < ascale) { + if(scale < ascale) { ascale -= Math.abs(scale - ascale) * 0.16; } - if (scale > ascale) { + if(scale > ascale) { ascale += Math.abs(ascale - scale) * 0.16; } - if (t < tz) { + if(t < tz) { tz -= Math.abs(t - tz) * 0.29; } - if (t > tz) { + if(t > tz) { tz += Math.abs(tz - t) * 0.29; } - if (ox < oxp) { + if(ox < oxp) { oxp -= Math.abs(ox - oxp) * 0.16; } - if (ox > oxp) { + if(ox > oxp) { oxp += Math.abs(oxp - ox) * 0.16; } - if (oz < ozp) { + if(oz < ozp) { ozp -= Math.abs(oz - ozp) * 0.16; } - if (oz > ozp) { + if(oz > ozp) { ozp += Math.abs(ozp - oz) * 0.16; } - if (mx < mxx) { + if(mx < mxx) { mxx -= Math.abs(mx - mxx) * 0.16; } - if (mx > mxx) { + if(mx > mxx) { mxx += Math.abs(mxx - mx) * 0.16; } - if (mz < mzz) { + if(mz < mzz) { mzz -= Math.abs(mz - mzz) * 0.16; } - if (mz > mzz) { + if(mz > mzz) { mzz += Math.abs(mzz - mz) * 0.16; } @@ -265,26 +265,26 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List accuracy = down ? accuracy * 4 : accuracy; int v = 1000; - if (g instanceof Graphics2D gg) { + if(g instanceof Graphics2D gg) { - if (getParent().getWidth() != w || getParent().getHeight() != h) { + if(getParent().getWidth() != w || getParent().getHeight() != h) { w = getParent().getWidth(); h = getParent().getHeight(); img = null; } - if (img == null) { + if(img == null) { img = new BufferedImage(w / accuracy, h / accuracy, BufferedImage.TYPE_INT_RGB); } BurstExecutor e = gx.burst(w); - for (int x = 0; x < w / accuracy; x++) { + for(int x = 0; x < w / accuracy; x++) { int xx = x; int finalAccuracy = accuracy; e.queue(() -> { - for (int z = 0; z < h / finalAccuracy; z++) { + for(int z = 0; z < h / finalAccuracy; z++) { double n = generator != null ? generator.apply(((xx * finalAccuracy) * ascale) + oxp, ((z * finalAccuracy) * ascale) + ozp) : cng.noise(((xx * finalAccuracy) * ascale) + oxp, ((z * finalAccuracy) * ascale) + ozp); n = n > 1 ? 1 : n < 0 ? 0 : n; @@ -292,7 +292,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 xxx) { } } @@ -308,15 +308,15 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener, List t += 1D; r.put(p.getMilliseconds()); - if (!isVisible()) { + if(!isVisible()) { return; } - if (!getParent().isVisible()) { + if(!getParent().isVisible()) { return; } - if (!getParent().getParent().isVisible()) { + if(!getParent().getParent().isVisible()) { return; } diff --git a/src/main/java/com/volmit/iris/core/gui/PregeneratorJob.java b/src/main/java/com/volmit/iris/core/gui/PregeneratorJob.java index 79ce58ae6..e77621110 100644 --- a/src/main/java/com/volmit/iris/core/gui/PregeneratorJob.java +++ b/src/main/java/com/volmit/iris/core/gui/PregeneratorJob.java @@ -78,7 +78,7 @@ public class PregeneratorJob implements PregenListener { instance = this; monitor = new MemoryMonitor(50); saving = false; - info = new String[]{"Initializing..."}; + info = new String[] {"Initializing..."}; this.task = task; this.pregenerator = new IrisPregenerator(task, method, this); max = new Position2(0, 0); @@ -91,7 +91,7 @@ public class PregeneratorJob implements PregenListener { max.setZ(Math.max((zz << 5) + 31, max.getZ())); }); - if (IrisSettings.get().getGui().isUseServerLaunchedGuis()) { + if(IrisSettings.get().getGui().isUseServerLaunchedGuis()) { open(); } @@ -103,7 +103,7 @@ public class PregeneratorJob implements PregenListener { } public static boolean shutdownInstance() { - if (instance == null) { + if(instance == null) { return false; } @@ -116,11 +116,11 @@ public class PregeneratorJob implements PregenListener { } public static boolean pauseResume() { - if (instance == null) { + if(instance == null) { return false; } - if (isPaused()) { + if(isPaused()) { instance.pregenerator.resume(); } else { instance.pregenerator.pause(); @@ -129,7 +129,7 @@ public class PregeneratorJob implements PregenListener { } public static boolean isPaused() { - if (instance == null) { + if(instance == null) { return true; } @@ -140,7 +140,7 @@ public class PregeneratorJob implements PregenListener { String v = (c.startsWith("#") ? c : "#" + c).trim(); try { return Color.decode(v); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Error Parsing 'color', (" + c + ")"); } @@ -169,10 +169,10 @@ public class PregeneratorJob implements PregenListener { public void draw(int x, int z, Color color) { try { - if (renderer != null && frame != null && frame.isVisible()) { + if(renderer != null && frame != null && frame.isVisible()) { renderer.func.accept(new Position2(x, z), color); } - } catch (Throwable ignored) { + } catch(Throwable ignored) { } } @@ -191,7 +191,7 @@ public class PregeneratorJob implements PregenListener { monitor.close(); J.sleep(3000); frame.setVisible(false); - } catch (Throwable e) { + } catch(Throwable e) { } }); @@ -215,7 +215,7 @@ public class PregeneratorJob implements PregenListener { frame.add(renderer); frame.setSize(1000, 1000); frame.setVisible(true); - } catch (Throwable e) { + } catch(Throwable e) { } }); @@ -223,23 +223,23 @@ public class PregeneratorJob implements PregenListener { @Override public void onTick(double chunksPerSecond, double chunksPerMinute, double regionsPerMinute, double percent, int generated, int totalChunks, int chunksRemaining, long eta, long elapsed, String method) { - info = new String[]{ - (paused() ? "PAUSED" : (saving ? "Saving... " : "Generating")) + " " + Form.f(generated) + " of " + Form.f(totalChunks) + " (" + Form.pc(percent, 0) + " Complete)", - "Speed: " + Form.f(chunksPerSecond, 0) + " Chunks/s, " + Form.f(regionsPerMinute, 1) + " Regions/m, " + Form.f(chunksPerMinute, 0) + " Chunks/m", - Form.duration(eta, 2) + " Remaining " + " (" + Form.duration(elapsed, 2) + " Elapsed)", - "Generation Method: " + method, - "Memory: " + Form.memSize(monitor.getUsedBytes(), 2) + " (" + Form.pc(monitor.getUsagePercent(), 0) + ") Pressure: " + Form.memSize(monitor.getPressure(), 0) + "/s", + info = new String[] { + (paused() ? "PAUSED" : (saving ? "Saving... " : "Generating")) + " " + Form.f(generated) + " of " + Form.f(totalChunks) + " (" + Form.pc(percent, 0) + " Complete)", + "Speed: " + Form.f(chunksPerSecond, 0) + " Chunks/s, " + Form.f(regionsPerMinute, 1) + " Regions/m, " + Form.f(chunksPerMinute, 0) + " Chunks/m", + Form.duration(eta, 2) + " Remaining " + " (" + Form.duration(elapsed, 2) + " Elapsed)", + "Generation Method: " + method, + "Memory: " + Form.memSize(monitor.getUsedBytes(), 2) + " (" + Form.pc(monitor.getUsagePercent(), 0) + ") Pressure: " + Form.memSize(monitor.getPressure(), 0) + "/s", }; - for (Consumer i : onProgress) { + for(Consumer i : onProgress) { i.accept(percent); } } @Override public void onChunkGenerating(int x, int z) { - if (engine != null) { + if(engine != null) { return; } @@ -248,7 +248,7 @@ public class PregeneratorJob implements PregenListener { @Override public void onChunkGenerated(int x, int z) { - if (engine != null) { + if(engine != null) { draw(x, z, engine.draw((x << 4) + 8, (z << 4) + 8)); return; } @@ -263,7 +263,7 @@ public class PregeneratorJob implements PregenListener { } private void shouldGc() { - if (cl.flip() && rgc > 16) { + if(cl.flip() && rgc > 16) { System.gc(); } } @@ -322,7 +322,7 @@ public class PregeneratorJob implements PregenListener { @Override public void onChunkExistsInRegionGen(int x, int z) { - if (engine != null) { + if(engine != null) { draw(x, z, engine.draw((x << 4) + 8, (z << 4) + 8)); return; } @@ -371,10 +371,10 @@ public class PregeneratorJob implements PregenListener { bg = (Graphics2D) image.getGraphics(); l.lock(); - while (order.isNotEmpty()) { + while(order.isNotEmpty()) { try { order.pop().run(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -388,12 +388,12 @@ public class PregeneratorJob implements PregenListener { int h = g.getFontMetrics().getHeight() + 5; int hh = 20; - if (job.paused()) { + if(job.paused()) { g.drawString("PAUSED", 20, hh += h); g.drawString("Press P to Resume", 20, hh += h); } else { - for (String i : prog) { + for(String i : prog) { g.drawString(i, 20, hh += h); } @@ -429,7 +429,7 @@ public class PregeneratorJob implements PregenListener { @Override public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_P) { + if(e.getKeyCode() == KeyEvent.VK_P) { PregeneratorJob.pauseResume(); } } diff --git a/src/main/java/com/volmit/iris/core/gui/VisionGUI.java b/src/main/java/com/volmit/iris/core/gui/VisionGUI.java index 192ae406b..4bad67d2c 100644 --- a/src/main/java/com/volmit/iris/core/gui/VisionGUI.java +++ b/src/main/java/com/volmit/iris/core/gui/VisionGUI.java @@ -149,7 +149,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener J.a(() -> { J.sleep(10000); - if (!helpIgnored && help) { + if(!helpIgnored && help) { help = false; } }); @@ -173,11 +173,11 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener frame.setVisible(true); File file = Iris.getCached("Iris Icon", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/icon.png"); - if (file != null) { + if(file != null) { try { nv.texture = ImageIO.read(file); frame.setIconImage(ImageIO.read(file)); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } @@ -186,17 +186,17 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener public static void launch(Engine g, int i) { J.a(() -> - createAndShowGUI(g, i, g.getWorld())); + createAndShowGUI(g, i, g.getWorld())); } public boolean updateEngine() { - if (engine.isClosed()) { - if (world.hasRealWorld()) { + if(engine.isClosed()) { + if(world.hasRealWorld()) { try { engine = IrisToolbelt.access(world.realWorld()).getEngine(); Iris.info("Updated Renderer"); return !engine.isClosed(); - } catch (Throwable e) { + } catch(Throwable e) { } } @@ -224,7 +224,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener public int getColor(double wx, double wz) { BiFunction colorFunction = (d, dx) -> Color.black.getRGB(); - switch (currentType) { + switch(currentType) { case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> engine.getComplex().getTrueBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); case BIOME_LAND -> colorFunction = (x, z) -> engine.getComplex().getLandBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); case BIOME_SEA -> colorFunction = (x, z) -> engine.getComplex().getSeaBiomeStream().get(x, z).getColor(engine, currentType).getRGB(); @@ -247,51 +247,51 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener @Override public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_SHIFT) { + if(e.getKeyCode() == KeyEvent.VK_SHIFT) { shift = true; } - if (e.getKeyCode() == KeyEvent.VK_CONTROL) { + if(e.getKeyCode() == KeyEvent.VK_CONTROL) { control = true; } - if (e.getKeyCode() == KeyEvent.VK_SEMICOLON) { + if(e.getKeyCode() == KeyEvent.VK_SEMICOLON) { debug = true; } - if (e.getKeyCode() == KeyEvent.VK_SLASH) { + if(e.getKeyCode() == KeyEvent.VK_SLASH) { help = true; helpIgnored = true; } - if (e.getKeyCode() == KeyEvent.VK_ALT) { + if(e.getKeyCode() == KeyEvent.VK_ALT) { alt = true; } } @Override public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_SEMICOLON) { + if(e.getKeyCode() == KeyEvent.VK_SEMICOLON) { debug = false; } - if (e.getKeyCode() == KeyEvent.VK_SHIFT) { + if(e.getKeyCode() == KeyEvent.VK_SHIFT) { shift = false; } - if (e.getKeyCode() == KeyEvent.VK_CONTROL) { + if(e.getKeyCode() == KeyEvent.VK_CONTROL) { control = false; } - if (e.getKeyCode() == KeyEvent.VK_SLASH) { + if(e.getKeyCode() == KeyEvent.VK_SLASH) { help = false; helpIgnored = true; } - if (e.getKeyCode() == KeyEvent.VK_ALT) { + if(e.getKeyCode() == KeyEvent.VK_ALT) { alt = false; } // Pushes - if (e.getKeyCode() == KeyEvent.VK_F) { + if(e.getKeyCode() == KeyEvent.VK_F) { follow = !follow; - if (player != null && follow) { + if(player != null && follow) { notify("Following " + player.getName() + ". Press F to disable"); - } else if (follow) { + } else if(follow) { notify("Can't follow, no one is in the world"); follow = false; } else { @@ -301,38 +301,38 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener return; } - if (e.getKeyCode() == KeyEvent.VK_R) { + if(e.getKeyCode() == KeyEvent.VK_R) { dump(); notify("Refreshing Chunks"); return; } - if (e.getKeyCode() == KeyEvent.VK_P) { + if(e.getKeyCode() == KeyEvent.VK_P) { lowtile = !lowtile; dump(); notify("Rendering " + (lowtile ? "Low" : "High") + " Quality Tiles"); return; } - if (e.getKeyCode() == KeyEvent.VK_E) { + if(e.getKeyCode() == KeyEvent.VK_E) { eco = !eco; dump(); notify("Using " + (eco ? "60" : "Uncapped") + " FPS Limit"); return; } - if (e.getKeyCode() == KeyEvent.VK_EQUALS) { + if(e.getKeyCode() == KeyEvent.VK_EQUALS) { mscale = mscale + ((0.044 * mscale) * -3); mscale = Math.max(mscale, 0.00001); dump(); return; } - if (e.getKeyCode() == KeyEvent.VK_MINUS) { + if(e.getKeyCode() == KeyEvent.VK_MINUS) { mscale = mscale + ((0.044 * mscale) * 3); mscale = Math.max(mscale, 0.00001); dump(); return; } - if (e.getKeyCode() == KeyEvent.VK_BACK_SLASH) { + if(e.getKeyCode() == KeyEvent.VK_BACK_SLASH) { mscale = 1D; dump(); notify("Zoom Reset"); @@ -341,9 +341,9 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener int currentMode = currentType.ordinal(); - for (RenderType i : RenderType.values()) { - if (e.getKeyChar() == String.valueOf(i.ordinal() + 1).charAt(0)) { - if (i.ordinal() != currentMode) { + for(RenderType i : RenderType.values()) { + if(e.getKeyChar() == String.valueOf(i.ordinal() + 1).charAt(0)) { + if(i.ordinal() != currentMode) { currentType = i; dump(); notify("Rendering " + Form.capitalizeWords(currentType.name().toLowerCase().replaceAll("\\Q_\\E", " "))); @@ -352,7 +352,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener } } - if (e.getKeyCode() == KeyEvent.VK_M) { + if(e.getKeyCode() == KeyEvent.VK_M) { currentType = RenderType.values()[(currentMode + 1) % RenderType.values().length]; notify("Rendering " + Form.capitalizeWords(currentType.name().toLowerCase().replaceAll("\\Q_\\E", " "))); dump(); @@ -368,15 +368,15 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener BlockPosition key = new BlockPosition((int) mscale, Math.floorDiv(x, div), Math.floorDiv(z, div)); fg.add(key); - if (positions.containsKey(key)) { + if(positions.containsKey(key)) { return positions.get(key); } - if (fastpositions.containsKey(key)) { - if (!working.contains(key) && working.size() < 9) { + if(fastpositions.containsKey(key)) { + if(!working.contains(key) && working.size() < 9) { m.set(m.get() - 1); - if (m.get() >= 0 && velocity < 50) { + if(m.get() >= 0 && velocity < 50) { working.add(key); double mk = mscale; double mkd = scale; @@ -387,7 +387,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener rs.put(ps.getMilliseconds()); working.remove(key); - if (mk == mscale && mkd == scale) { + if(mk == mscale && mkd == scale) { positions.put(key, b); } }); @@ -397,7 +397,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener return fastpositions.get(key); } - if (workingfast.contains(key) || workingfast.size() > Runtime.getRuntime().availableProcessors()) { + if(workingfast.contains(key) || workingfast.size() > Runtime.getRuntime().availableProcessors()) { return null; } @@ -411,7 +411,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener rs.put(ps.getMilliseconds()); workingfast.remove(key); - if (mk == mscale && mkd == scale) { + if(mk == mscale && mkd == scale) { fastpositions.put(key, b); } }); @@ -437,49 +437,49 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener @Override public void paint(Graphics gx) { - if (updateEngine()) { + if(updateEngine()) { dump(); } - if (ox < oxp) { + if(ox < oxp) { velocity = Math.abs(ox - oxp) * 0.36; oxp -= velocity; } - if (ox > oxp) { + if(ox > oxp) { velocity = Math.abs(oxp - ox) * 0.36; oxp += velocity; } - if (oz < ozp) { + if(oz < ozp) { velocity = Math.abs(oz - ozp) * 0.36; ozp -= velocity; } - if (oz > ozp) { + if(oz > ozp) { velocity = Math.abs(ozp - oz) * 0.36; ozp += velocity; } - if (lx < hx) { + if(lx < hx) { hx -= Math.abs(lx - hx) * 0.36; } - if (lx > hx) { + if(lx > hx) { hx += Math.abs(hx - lx) * 0.36; } - if (lz < hz) { + if(lz < hz) { hz -= Math.abs(lz - hz) * 0.36; } - if (lz > hz) { + if(lz > hz) { hz += Math.abs(hz - lz) * 0.36; } - if (centities.flip()) { + if(centities.flip()) { J.s(() -> { - synchronized (lastEntities) { + synchronized(lastEntities) { lastEntities.clear(); lastEntities.addAll(world.getEntitiesByClass(LivingEntity.class)); } @@ -493,7 +493,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener double vscale = scale; scale = w / 12D; - if (scale != vscale) { + if(scale != vscale) { positions.clear(); } @@ -505,15 +505,15 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener posZ = (int) ozp; m.set(3); - for (int r = 0; r < Math.max(w, h); r += iscale) { - for (int i = -iscale; i < w + iscale; i += iscale) { - for (int j = -iscale; j < h + iscale; j += iscale) { + for(int r = 0; r < Math.max(w, h); r += iscale) { + for(int i = -iscale; i < w + iscale; i += iscale) { + for(int j = -iscale; j < h + iscale; j += iscale) { int a = i - (w / 2); int b = j - (h / 2); - if (a * a + b * b <= r * r) { + if(a * a + b * b <= r * r) { BufferedImage t = getTile(gg, iscale, Math.floorDiv((posX / iscale) + i, iscale) * iscale, Math.floorDiv((posZ / iscale) + j, iscale) * iscale, m); - if (t != null) { + if(t != null) { g.drawImage(t, i - ((posX / iscale) % (iscale)), j - ((posZ / iscale) % (iscale)), iscale, iscale, (img, infoflags, x, y, width, height) -> true); } } @@ -523,8 +523,8 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener p.end(); - for (BlockPosition i : positions.k()) { - if (!gg.contains(i)) { + for(BlockPosition i : positions.k()) { + if(!gg.contains(i)) { positions.remove(i); } } @@ -532,15 +532,15 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener hanleFollow(); renderOverlays(g); - if (!isVisible()) { + if(!isVisible()) { return; } - if (!getParent().isVisible()) { + if(!getParent().isVisible()) { return; } - if (!getParent().getParent().isVisible()) { + if(!getParent().getParent().isVisible()) { return; } @@ -552,7 +552,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener } private void hanleFollow() { - if (follow && player != null) { + if(follow && player != null) { animateTo(player.getLocation().getX(), player.getLocation().getZ()); } } @@ -560,16 +560,16 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener private void renderOverlays(Graphics2D g) { renderPlayer(g); - if (help) { + if(help) { renderOverlayHelp(g); - } else if (debug) { + } else if(debug) { renderOverlayDebug(g); } renderOverlayLegend(g); renderHoverOverlay(g, shift); - if (!notifications.isEmpty()) { + if(!notifications.isEmpty()) { renderNotification(g); } } @@ -587,8 +587,8 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener private void renderNotification(Graphics2D g) { drawCardCB(g, notifications.k()); - for (String i : notifications.k()) { - if (M.ms() > notifications.get(i)) { + for(String i : notifications.k()) { + if(M.ms() > notifications.get(i)) { notifications.remove(i); } } @@ -597,32 +597,32 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener private void renderPlayer(Graphics2D g) { Player b = null; - for (Player i : world.getPlayers()) { + for(Player i : world.getPlayers()) { b = i; renderPosition(g, i.getLocation().getX(), i.getLocation().getZ()); } - synchronized (lastEntities) { + synchronized(lastEntities) { double dist = Double.MAX_VALUE; LivingEntity h = null; - for (LivingEntity i : lastEntities) { - if (i instanceof Player) { + for(LivingEntity i : lastEntities) { + if(i instanceof Player) { continue; } renderMobPosition(g, i, i.getLocation().getX(), i.getLocation().getZ()); - if (shift) { + if(shift) { double d = i.getLocation().distanceSquared(new Location(i.getWorld(), getWorldX(hx), i.getLocation().getY(), getWorldZ(hz))); - if (d < dist) { + if(d < dist) { dist = d; h = i; } } } - if (h != null && shift) { + if(h != null && shift) { g.setColor(Color.red); g.fillRoundRect((int) getScreenX(h.getLocation().getX()) - 10, (int) getScreenZ(h.getLocation().getZ()) - 10, 20, 20, 20, 20); KList k = new KList<>(); @@ -647,7 +647,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener } private void renderPosition(Graphics2D g, double x, double z) { - if (texture != null) { + if(texture != null) { g.drawImage(texture, (int) getScreenX(x), (int) getScreenZ(z), 66, 66, (img, infoflags, xx, xy, width, height) -> true); } else { g.setColor(Color.darkGray); @@ -669,7 +669,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener l.add("Biome: " + biome.getName()); l.add("Region: " + region.getName() + "(" + region.getLoadKey() + ")"); l.add("Block " + (int) getWorldX(hx) + ", " + (int) getWorldZ(hz)); - if (detailed) { + if(detailed) { l.add("Chunk " + ((int) getWorldX(hx) >> 4) + ", " + ((int) getWorldZ(hz) >> 4)); l.add("Region " + (((int) getWorldX(hx) >> 4) >> 5) + ", " + (((int) getWorldZ(hz) >> 4) >> 5)); l.add("Key: " + biome.getLoadKey()); @@ -698,7 +698,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener l.add("E to toggle Eco FPS Mode"); int ff = 0; - for (RenderType i : RenderType.values()) { + for(RenderType i : RenderType.values()) { ff++; l.add(ff + " to view " + Form.capitalizeWords(i.name().toLowerCase().replaceAll("\\Q_\\E", " "))); } @@ -728,7 +728,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener private void open() { IrisComplex complex = engine.getComplex(); File r = null; - switch (currentType) { + switch(currentType) { case BIOME, LAYER_LOAD, DECORATOR_LOAD, OBJECT_LOAD, HEIGHT -> r = complex.getTrueBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); case BIOME_LAND -> r = complex.getLandBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); case BIOME_SEA -> r = complex.getSeaBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode(); @@ -741,7 +741,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener private void teleport() { J.s(() -> { - if (player != null) { + if(player != null) { int xx = (int) getWorldX(hx); int zz = (int) getWorldZ(hz); int h = engine.getComplex().getRoundedHeighteightStream().get(xx, zz); @@ -766,7 +766,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener int h = 0; int w = 0; - for (String i : text) { + for(String i : text) { h += g.getFontMetrics().getHeight(); w = Math.max(w, g.getFontMetrics().stringWidth(i)); } @@ -786,14 +786,14 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener g.setColor(Color.black); int m = 0; - for (String i : text) { + for(String i : text) { g.drawString(i, x + 14 - cw, y + 14 - ch + (++m * g.getFontMetrics().getHeight())); } } public void mouseWheelMoved(MouseWheelEvent e) { int notches = e.getWheelRotation(); - if (e.isControlDown()) { + if(e.isControlDown()) { return; } @@ -806,9 +806,9 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener @Override public void mouseClicked(MouseEvent e) { - if (control) { + if(control) { teleport(); - } else if (alt) { + } else if(alt) { open(); } } diff --git a/src/main/java/com/volmit/iris/core/gui/components/IrisRenderer.java b/src/main/java/com/volmit/iris/core/gui/components/IrisRenderer.java index cbc8cadb8..8a88acefe 100644 --- a/src/main/java/com/volmit/iris/core/gui/components/IrisRenderer.java +++ b/src/main/java/com/volmit/iris/core/gui/components/IrisRenderer.java @@ -37,7 +37,7 @@ public class IrisRenderer { BufferedImage image = new BufferedImage(resolution, resolution, BufferedImage.TYPE_INT_RGB); BiFunction colorFunction = (d, dx) -> Color.black.getRGB(); - switch (currentType) { + switch(currentType) { case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> renderer.getComplex().getTrueBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); case BIOME_LAND -> colorFunction = (x, z) -> renderer.getComplex().getLandBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); case BIOME_SEA -> colorFunction = (x, z) -> renderer.getComplex().getSeaBiomeStream().get(x, z).getColor(renderer, currentType).getRGB(); @@ -48,10 +48,10 @@ public class IrisRenderer { double x, z; int i, j; - for (i = 0; i < resolution; i++) { + for(i = 0; i < resolution; i++) { x = IrisInterpolation.lerp(sx, sx + size, (double) i / (double) (resolution)); - for (j = 0; j < resolution; j++) { + for(j = 0; j < resolution; j++) { z = IrisInterpolation.lerp(sz, sz + size, (double) j / (double) (resolution)); image.setRGB(i, j, colorFunction.apply(x, z)); } diff --git a/src/main/java/com/volmit/iris/core/link/IrisPapiExpansion.java b/src/main/java/com/volmit/iris/core/link/IrisPapiExpansion.java index 519e18d5f..f920cb662 100644 --- a/src/main/java/com/volmit/iris/core/link/IrisPapiExpansion.java +++ b/src/main/java/com/volmit/iris/core/link/IrisPapiExpansion.java @@ -52,55 +52,55 @@ public class IrisPapiExpansion extends PlaceholderExpansion { Location l = null; PlatformChunkGenerator a = null; - if (player.isOnline()) { + if(player.isOnline()) { l = player.getPlayer().getLocation(); a = IrisToolbelt.access(l.getWorld()); } - if (p.equalsIgnoreCase("biome_name")) { - if (a != null) { + if(p.equalsIgnoreCase("biome_name")) { + if(a != null) { return a.getEngine().getBiome(l).getName(); } - } else if (p.equalsIgnoreCase("biome_id")) { - if (a != null) { + } else if(p.equalsIgnoreCase("biome_id")) { + if(a != null) { return a.getEngine().getBiome(l).getLoadKey(); } - } else if (p.equalsIgnoreCase("biome_file")) { - if (a != null) { + } else if(p.equalsIgnoreCase("biome_file")) { + if(a != null) { return a.getEngine().getBiome(l).getLoadFile().getPath(); } - } else if (p.equalsIgnoreCase("region_name")) { - if (a != null) { + } else if(p.equalsIgnoreCase("region_name")) { + if(a != null) { return a.getEngine().getRegion(l).getName(); } - } else if (p.equalsIgnoreCase("region_id")) { - if (a != null) { + } else if(p.equalsIgnoreCase("region_id")) { + if(a != null) { return a.getEngine().getRegion(l).getLoadKey(); } - } else if (p.equalsIgnoreCase("region_file")) { - if (a != null) { + } else if(p.equalsIgnoreCase("region_file")) { + if(a != null) { return a.getEngine().getRegion(l).getLoadFile().getPath(); } - } else if (p.equalsIgnoreCase("terrain_slope")) { - if (a != null) { + } else if(p.equalsIgnoreCase("terrain_slope")) { + if(a != null) { return (a.getEngine()) - .getComplex().getSlopeStream() - .get(l.getX(), l.getZ()) + ""; + .getComplex().getSlopeStream() + .get(l.getX(), l.getZ()) + ""; } - } else if (p.equalsIgnoreCase("terrain_height")) { - if (a != null) { + } else if(p.equalsIgnoreCase("terrain_height")) { + if(a != null) { return Math.round(a.getEngine().getHeight(l.getBlockX(), l.getBlockZ())) + ""; } - } else if (p.equalsIgnoreCase("world_mode")) { - if (a != null) { + } else if(p.equalsIgnoreCase("world_mode")) { + if(a != null) { return a.isStudio() ? "Studio" : "Production"; } - } else if (p.equalsIgnoreCase("world_seed")) { - if (a != null) { + } else if(p.equalsIgnoreCase("world_seed")) { + if(a != null) { return a.getEngine().getSeedManager().getSeed() + ""; } - } else if (p.equalsIgnoreCase("world_speed")) { - if (a != null) { + } else if(p.equalsIgnoreCase("world_speed")) { + if(a != null) { return a.getEngine().getGeneratedPerSecond() + "/s"; } } diff --git a/src/main/java/com/volmit/iris/core/link/MultiverseCoreLink.java b/src/main/java/com/volmit/iris/core/link/MultiverseCoreLink.java index 56d3fd900..05bf7ad82 100644 --- a/src/main/java/com/volmit/iris/core/link/MultiverseCoreLink.java +++ b/src/main/java/com/volmit/iris/core/link/MultiverseCoreLink.java @@ -38,7 +38,7 @@ public class MultiverseCoreLink { } public boolean addWorld(String worldName, IrisDimension dim, String seed) { - if (!isSupported()) { + if(!isSupported()) { return false; } @@ -47,11 +47,11 @@ public class MultiverseCoreLink { Object mvWorldManager = p.getClass().getDeclaredMethod("getMVWorldManager").invoke(p); Method m = mvWorldManager.getClass().getDeclaredMethod("addWorld", - String.class, World.Environment.class, String.class, WorldType.class, Boolean.class, String.class, boolean.class); + String.class, World.Environment.class, String.class, WorldType.class, Boolean.class, String.class, boolean.class); boolean b = (boolean) m.invoke(mvWorldManager, worldName, dim.getEnvironment(), seed, WorldType.NORMAL, false, "Iris", false); saveConfig(); return b; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -67,7 +67,7 @@ public class MultiverseCoreLink { Field f = mvWorldManager.getClass().getDeclaredField("worldsFromTheConfig"); f.setAccessible(true); return (Map) f.get(mvWorldManager); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -76,7 +76,7 @@ public class MultiverseCoreLink { } public void removeFromConfig(World world) { - if (!isSupported()) { + if(!isSupported()) { return; } @@ -85,7 +85,7 @@ public class MultiverseCoreLink { } public void removeFromConfig(String world) { - if (!isSupported()) { + if(!isSupported()) { return; } @@ -98,7 +98,7 @@ public class MultiverseCoreLink { Plugin p = getMultiverse(); Object mvWorldManager = p.getClass().getDeclaredMethod("getMVWorldManager").invoke(p); mvWorldManager.getClass().getDeclaredMethod("saveWorldsConfig").invoke(mvWorldManager); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -112,7 +112,7 @@ public class MultiverseCoreLink { try { String t = worldNameTypes.get(worldName); return t == null ? defaultType : t; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); return defaultType; } @@ -128,11 +128,11 @@ public class MultiverseCoreLink { } public String envName(World.Environment environment) { - if (environment == null) { + if(environment == null) { return "normal"; } - return switch (environment) { + return switch(environment) { case NORMAL -> "normal"; case NETHER -> "nether"; case THE_END -> "end"; diff --git a/src/main/java/com/volmit/iris/core/link/MythicMobsLink.java b/src/main/java/com/volmit/iris/core/link/MythicMobsLink.java index 1a4287136..cf72e9009 100644 --- a/src/main/java/com/volmit/iris/core/link/MythicMobsLink.java +++ b/src/main/java/com/volmit/iris/core/link/MythicMobsLink.java @@ -50,15 +50,17 @@ public class MythicMobsLink { /** * Spawn a mythic mob at this location * - * @param mob The mob - * @param location The location + * @param mob + * The mob + * @param location + * The location * @return The mob, or null if it can't be spawned */ public @Nullable Entity spawnMob(String mob, Location location) { - if (!isEnabled()) return null; + if(!isEnabled()) return null; - if (spawnMobFunction != null) { + if(spawnMobFunction != null) { return spawnMobFunction.apply(mob, location); } @@ -73,14 +75,14 @@ public class MythicMobsLink { spawnMobFunction = (str, loc) -> { try { return (Entity) spawnMobMethod.invoke(apiHelper, str, loc); - } catch (InvocationTargetException | IllegalAccessException e) { + } catch(InvocationTargetException | IllegalAccessException e) { e.printStackTrace(); } return null; }; return spawnMobFunction.apply(mob, location); - } catch (Exception e) { + } catch(Exception e) { e.printStackTrace(); } @@ -88,11 +90,11 @@ public class MythicMobsLink { } public Collection getMythicMobTypes() { - if (mobs != null) { + if(mobs != null) { return mobs; } - if (isEnabled()) { + if(isEnabled()) { try { Class mythicMobClass = Class.forName("io.lumine.xikage.mythicmobs.MythicMobs"); @@ -103,7 +105,7 @@ public class MythicMobsLink { Method getMobNames = mobManager.getClass().getDeclaredMethod("getMobNames"); mobs = (Collection) getMobNames.invoke(mobManager); return mobs; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + } catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { e.printStackTrace(); } } diff --git a/src/main/java/com/volmit/iris/core/link/OraxenLink.java b/src/main/java/com/volmit/iris/core/link/OraxenLink.java index 4f9afe70d..188013467 100644 --- a/src/main/java/com/volmit/iris/core/link/OraxenLink.java +++ b/src/main/java/com/volmit/iris/core/link/OraxenLink.java @@ -44,22 +44,22 @@ public class OraxenLink { } public BlockData getBlockDataFor(String id) { - if (!supported()) { + if(!supported()) { return null; } MechanicFactory f = getFactory(id); - if (f == null) { + if(f == null) { return null; } Mechanic m = f.getMechanic(id); // TODO: Why isnt there a simple getBlockData() function? - if (m.getFactory() instanceof NoteBlockMechanicFactory) { + if(m.getFactory() instanceof NoteBlockMechanicFactory) { return ((NoteBlockMechanicFactory) m.getFactory()).createNoteBlockData(id); - } else if (m.getFactory() instanceof BlockMechanicFactory) { + } else if(m.getFactory() instanceof BlockMechanicFactory) { MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM); Utils.setBlockFacing(newBlockData, ((BlockMechanic) m).getCustomVariation()); return newBlockData; @@ -69,7 +69,7 @@ public class OraxenLink { } public MechanicFactory getFactory(String id) { - if (!supported()) { + if(!supported()) { return null; } @@ -78,12 +78,12 @@ public class OraxenLink { f.setAccessible(true); Map map = (Map) f.get(null); - for (MechanicFactory i : map.values()) { - if (i.getItems().contains(id)) { + for(MechanicFactory i : map.values()) { + if(i.getItems().contains(id)) { return i; } } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -91,14 +91,14 @@ public class OraxenLink { } public String[] getItemTypes() { - if (!supported()) { + if(!supported()) { return EMPTY; } KList v = new KList<>(); - for (String i : OraxenItems.getItemNames()) { - if (getBlockDataFor(i) != null) { + for(String i : OraxenItems.getItemNames()) { + if(getBlockDataFor(i) != null) { v.add(i); } } diff --git a/src/main/java/com/volmit/iris/core/loader/ImageResourceLoader.java b/src/main/java/com/volmit/iris/core/loader/ImageResourceLoader.java index e525e4ffe..fbdc7c445 100644 --- a/src/main/java/com/volmit/iris/core/loader/ImageResourceLoader.java +++ b/src/main/java/com/volmit/iris/core/loader/ImageResourceLoader.java @@ -21,7 +21,6 @@ package com.volmit.iris.core.loader; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.engine.object.IrisImage; -import com.volmit.iris.engine.object.IrisObject; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.data.KCache; @@ -60,7 +59,7 @@ public class ImageResourceLoader extends ResourceLoader { logLoad(j, img); tlt.addAndGet(p.getMilliseconds()); return img; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage()); return null; @@ -68,24 +67,24 @@ public class ImageResourceLoader extends ResourceLoader { } public String[] getPossibleKeys() { - if (possibleKeys != null) { + if(possibleKeys != null) { return possibleKeys; } Iris.debug("Building " + resourceTypeName + " Possibility Lists"); KSet m = new KSet<>(); - for (File i : getFolders()) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".png")) { + 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")) { + } 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")) { + } 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", "")); } } @@ -101,16 +100,16 @@ public class ImageResourceLoader extends ResourceLoader { } public File findFile(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".png") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".png") && j.getName().split("\\Q.\\E")[0].equals(name)) { return j; } } File file = new File(i, name + ".png"); - if (file.exists()) { + if(file.exists()) { return file; } } @@ -125,16 +124,16 @@ public class ImageResourceLoader extends ResourceLoader { } private IrisImage loadRaw(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".png") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".png") && j.getName().split("\\Q.\\E")[0].equals(name)) { return loadFile(j, name); } } File file = new File(i, name + ".png"); - if (file.exists()) { + if(file.exists()) { return loadFile(file, name); } } diff --git a/src/main/java/com/volmit/iris/core/loader/IrisData.java b/src/main/java/com/volmit/iris/core/loader/IrisData.java index 9c837205c..4d63bd553 100644 --- a/src/main/java/com/volmit/iris/core/loader/IrisData.java +++ b/src/main/java/com/volmit/iris/core/loader/IrisData.java @@ -115,8 +115,8 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { public static int cacheSize() { int m = 0; - for (IrisData i : dataLoaders.values()) { - for (ResourceLoader j : i.getLoaders().values()) { + for(IrisData i : dataLoaders.values()) { + for(ResourceLoader j : i.getLoaders().values()) { m += j.getLoadCache().getSize(); } } @@ -206,17 +206,17 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { public static T loadAny(String key, Function v) { try { - for (File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles())) { - if (i.isDirectory()) { + for(File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles())) { + if(i.isDirectory()) { IrisData dm = get(i); T t = v.apply(dm); - if (t != null) { + if(t != null) { return t; } } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -227,9 +227,9 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { public ResourceLoader getTypedLoaderFor(File f) { String[] k = f.getPath().split("\\Q" + File.separator + "\\E"); - for (String i : k) { - for (ResourceLoader j : loaders.values()) { - if (j.getFolderName().equals(i)) { + for(String i : k) { + for(ResourceLoader j : loaders.values()) { + if(j.getFolderName().equals(i)) { return j; } } @@ -239,7 +239,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { } public void cleanupEngine() { - if (engine != null && engine.isClosed()) { + if(engine != null && engine.isClosed()) { engine = null; Iris.debug("Dereferenced Data " + getId() + " " + getDataFolder()); } @@ -250,30 +250,30 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { IrisContext ctx = IrisContext.get(); Engine engine = this.engine; - if (engine == null && ctx != null && ctx.getEngine() != null) { + if(engine == null && ctx != null && ctx.getEngine() != null) { engine = ctx.getEngine(); } - if (engine == null && t.getPreprocessors().isNotEmpty()) { + if(engine == null && t.getPreprocessors().isNotEmpty()) { Iris.error("Failed to preprocess object " + t.getLoadKey() + " because there is no engine context here. (See stack below)"); try { throw new RuntimeException(); - } catch (Throwable ex) { + } catch(Throwable ex) { ex.printStackTrace(); } } - if (engine != null && t.getPreprocessors().isNotEmpty()) { - synchronized (this) { + if(engine != null && t.getPreprocessors().isNotEmpty()) { + synchronized(this) { engine.getExecution().getAPI().setPreprocessorObject(t); - for (String i : t.getPreprocessors()) { + for(String i : t.getPreprocessors()) { engine.getExecution().execute(i); Iris.debug("Loader<" + C.GREEN + t.getTypeName() + C.LIGHT_PURPLE + "> iprocess " + C.YELLOW + t.getLoadKey() + C.LIGHT_PURPLE + " in " + i); } } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("Failed to preprocess object!"); e.printStackTrace(); } @@ -292,13 +292,13 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { try { IrisRegistrant rr = registrant.getConstructor().newInstance(); ResourceLoader r = null; - if (registrant.equals(IrisObject.class)) { + if(registrant.equals(IrisObject.class)) { r = (ResourceLoader) new ObjectResourceLoader(dataFolder, this, rr.getFolderName(), - rr.getTypeName()); - } else if (registrant.equals(IrisScript.class)) { + rr.getTypeName()); + } else if(registrant.equals(IrisScript.class)) { r = (ResourceLoader) new ScriptResourceLoader(dataFolder, this, rr.getFolderName(), rr.getTypeName()); - }else if (registrant.equals(IrisImage.class)) { + } else if(registrant.equals(IrisImage.class)) { r = (ResourceLoader) new ImageResourceLoader(dataFolder, this, rr.getFolderName(), rr.getTypeName()); } else { @@ -309,7 +309,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { loaders.put(registrant, r); return r; - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.error("Failed to create loader! " + registrant.getCanonicalName()); } @@ -320,11 +320,11 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { public synchronized void hotloaded() { possibleSnippets = new KMap<>(); builder = new GsonBuilder() - .addDeserializationExclusionStrategy(this) - .addSerializationExclusionStrategy(this) - .setLenient() - .registerTypeAdapterFactory(this) - .setPrettyPrinting(); + .addDeserializationExclusionStrategy(this) + .addSerializationExclusionStrategy(this) + .setLenient() + .registerTypeAdapterFactory(this) + .setPrettyPrinting(); loaders.clear(); File packs = dataFolder; packs.mkdirs(); @@ -351,26 +351,26 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { } public void dump() { - for (ResourceLoader i : loaders.values()) { + for(ResourceLoader i : loaders.values()) { i.clearCache(); } } public void clearLists() { - for (ResourceLoader i : loaders.values()) { + for(ResourceLoader i : loaders.values()) { i.clearList(); } } public String toLoadKey(File f) { - if (f.getPath().startsWith(getDataFolder().getPath())) { + if(f.getPath().startsWith(getDataFolder().getPath())) { String[] full = f.getPath().split("\\Q" + File.separator + "\\E"); String[] df = getDataFolder().getPath().split("\\Q" + File.separator + "\\E"); String g = ""; boolean m = true; - for (int i = 0; i < full.length; i++) { - if (i >= df.length) { - if (m) { + for(int i = 0; i < full.length; i++) { + if(i >= df.length) { + if(m) { m = false; continue; } @@ -397,14 +397,14 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { @Override public boolean shouldSkipClass(Class c) { - if (c.equals(AtomicCache.class)) { + if(c.equals(AtomicCache.class)) { return true; } else return c.equals(ChronoLatch.class); } @Override public TypeAdapter create(Gson gson, TypeToken typeToken) { - if (!typeToken.getRawType().isAnnotationPresent(Snippet.class)) { + if(!typeToken.getRawType().isAnnotationPresent(Snippet.class)) { return null; } @@ -420,17 +420,17 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { public T read(JsonReader reader) throws IOException { TypeAdapter adapter = gson.getDelegateAdapter(IrisData.this, typeToken); - if (reader.peek().equals(JsonToken.STRING)) { + if(reader.peek().equals(JsonToken.STRING)) { String r = reader.nextString(); - if (r.startsWith("snippet/" + snippetType + "/")) { + if(r.startsWith("snippet/" + snippetType + "/")) { File f = new File(getDataFolder(), r + ".json"); - if (f.exists()) { + if(f.exists()) { try { JsonReader snippetReader = new JsonReader(new FileReader(f)); return adapter.read(snippetReader); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("Couldn't read snippet " + r + " in " + reader.getPath() + " (" + e.getMessage() + ")"); } } else { @@ -443,11 +443,11 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { try { return adapter.read(reader); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("Failed to read " + typeToken.getRawType().getCanonicalName() + "... faking objects a little to load the file at least."); try { return (T) typeToken.getRawType().getConstructor().newInstance(); - } catch (Throwable ignored) { + } catch(Throwable ignored) { } } @@ -462,8 +462,8 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory { File snippetFolder = new File(getDataFolder(), "snippet/" + f); - if (snippetFolder.exists() && snippetFolder.isDirectory()) { - for (File i : snippetFolder.listFiles()) { + if(snippetFolder.exists() && snippetFolder.isDirectory()) { + for(File i : snippetFolder.listFiles()) { l.add("snippet/" + f + "/" + i.getName().split("\\Q.\\E")[0]); } } diff --git a/src/main/java/com/volmit/iris/core/loader/IrisRegistrant.java b/src/main/java/com/volmit/iris/core/loader/IrisRegistrant.java index 51bad94a4..b06886c92 100644 --- a/src/main/java/com/volmit/iris/core/loader/IrisRegistrant.java +++ b/src/main/java/com/volmit/iris/core/loader/IrisRegistrant.java @@ -56,7 +56,7 @@ public abstract class IrisRegistrant { public File openInVSCode() { try { Desktop.getDesktop().open(getLoadFile()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/core/loader/ObjectResourceLoader.java b/src/main/java/com/volmit/iris/core/loader/ObjectResourceLoader.java index 62736470c..e4141da7d 100644 --- a/src/main/java/com/volmit/iris/core/loader/ObjectResourceLoader.java +++ b/src/main/java/com/volmit/iris/core/loader/ObjectResourceLoader.java @@ -57,7 +57,7 @@ public class ObjectResourceLoader extends ResourceLoader { logLoad(j, t); tlt.addAndGet(p.getMilliseconds()); return t; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage()); return null; @@ -65,24 +65,24 @@ public class ObjectResourceLoader extends ResourceLoader { } public String[] getPossibleKeys() { - if (possibleKeys != null) { + if(possibleKeys != null) { return possibleKeys; } Iris.debug("Building " + resourceTypeName + " Possibility Lists"); KSet m = new KSet<>(); - for (File i : getFolders()) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".iob")) { + for(File i : getFolders()) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".iob")) { m.add(j.getName().replaceAll("\\Q.iob\\E", "")); - } else if (j.isDirectory()) { - for (File k : j.listFiles()) { - if (k.isFile() && k.getName().endsWith(".iob")) { + } else if(j.isDirectory()) { + for(File k : j.listFiles()) { + if(k.isFile() && k.getName().endsWith(".iob")) { m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.iob\\E", "")); - } else if (k.isDirectory()) { - for (File l : k.listFiles()) { - if (l.isFile() && l.getName().endsWith(".iob")) { + } else if(k.isDirectory()) { + for(File l : k.listFiles()) { + if(l.isFile() && l.getName().endsWith(".iob")) { m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.iob\\E", "")); } } @@ -98,16 +98,16 @@ public class ObjectResourceLoader extends ResourceLoader { } public File findFile(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name)) { return j; } } File file = new File(i, name + ".iob"); - if (file.exists()) { + if(file.exists()) { return file; } } @@ -122,16 +122,16 @@ public class ObjectResourceLoader extends ResourceLoader { } private IrisObject loadRaw(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name)) { return loadFile(j, name); } } File file = new File(i, name + ".iob"); - if (file.exists()) { + if(file.exists()) { return loadFile(file, name); } } diff --git a/src/main/java/com/volmit/iris/core/loader/ResourceLoader.java b/src/main/java/com/volmit/iris/core/loader/ResourceLoader.java index 39135d04c..e74ddee18 100644 --- a/src/main/java/com/volmit/iris/core/loader/ResourceLoader.java +++ b/src/main/java/com/volmit/iris/core/loader/ResourceLoader.java @@ -41,7 +41,6 @@ import java.io.File; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Stream; @@ -82,7 +81,7 @@ public class ResourceLoader implements MeteredCache { JSONObject o = new JSONObject(); KList fm = new KList<>(); - for (int g = 1; g < 8; g++) { + for(int g = 1; g < 8; g++) { fm.add("/" + folderName + Form.repeat("/*", g) + ".json"); } @@ -95,16 +94,16 @@ public class ResourceLoader implements MeteredCache { } public File findFile(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(name)) { return j; } } File file = new File(i, name + ".json"); - if (file.exists()) { + if(file.exists()) { return file; } } @@ -117,11 +116,11 @@ public class ResourceLoader implements MeteredCache { public void logLoad(File path, T t) { loads.getAndIncrement(); - if (loads.get() == 1) { + if(loads.get() == 1) { sec.flip(); } - if (sec.flip()) { + if(sec.flip()) { J.a(() -> { Iris.verbose("Loaded " + C.WHITE + loads.get() + " " + resourceTypeName + (loads.get() == 1 ? "" : "s") + C.GRAY + " (" + Form.f(getLoadCache().getSize()) + " " + resourceTypeName + (loadCache.getSize() == 1 ? "" : "s") + " Loaded)"); loads.set(0); @@ -142,32 +141,32 @@ public class ResourceLoader implements MeteredCache { } private void matchFiles(File at, KList files, Predicate f) { - if (at.isDirectory()) { - for (File i : at.listFiles()) { + if(at.isDirectory()) { + for(File i : at.listFiles()) { matchFiles(i, files, f); } } else { - if (f.test(at)) { + if(f.test(at)) { files.add(at); } } } public String[] getPossibleKeys() { - if (possibleKeys != null) { + if(possibleKeys != null) { return possibleKeys; } KSet m = new KSet<>(); KList files = getFolders(); - if (files == null) { + if(files == null) { possibleKeys = new String[0]; return possibleKeys; } - for (File i : files) { - for (File j : matchAllFiles(i, (f) -> f.getName().endsWith(".json"))) { + for(File i : files) { + for(File j : matchAllFiles(i, (f) -> f.getName().endsWith(".json"))) { m.add(i.toURI().relativize(j.toURI()).getPath().replaceAll("\\Q.json\\E", "")); } } @@ -185,7 +184,7 @@ public class ResourceLoader implements MeteredCache { try { PrecisionStopwatch p = PrecisionStopwatch.start(); T t = getManager().getGson() - .fromJson(preprocess(new JSONObject(IO.readAll(j))).toString(0), objectClass); + .fromJson(preprocess(new JSONObject(IO.readAll(j))).toString(0), objectClass); t.setLoadKey(name); t.setLoadFile(j); t.setLoader(manager); @@ -193,7 +192,7 @@ public class ResourceLoader implements MeteredCache { logLoad(j, t); tlt.addAndGet(p.getMilliseconds()); return t; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); failLoad(j, e); return null; @@ -211,10 +210,10 @@ public class ResourceLoader implements MeteredCache { public KList loadAll(KList s) { KList m = new KList<>(); - for (String i : s) { + for(String i : s) { T t = load(i); - if (t != null) { + if(t != null) { m.add(t); } } @@ -225,10 +224,10 @@ public class ResourceLoader implements MeteredCache { public KList loadAll(KList s, Consumer postLoad) { KList m = new KList<>(); - for (String i : s) { + for(String i : s) { T t = load(i); - if (t != null) { + if(t != null) { m.add(t); postLoad.accept(t); } @@ -240,10 +239,10 @@ public class ResourceLoader implements MeteredCache { public KList loadAll(String[] s) { KList m = new KList<>(); - for (String i : s) { + for(String i : s) { T t = load(i); - if (t != null) { + if(t != null) { m.add(t); } } @@ -256,17 +255,17 @@ public class ResourceLoader implements MeteredCache { } private T loadRaw(String name) { - for (File i : getFolders(name)) { + for(File i : getFolders(name)) { //noinspection ConstantConditions - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(name)) { return loadFile(j, name); } } File file = new File(i, name + ".json"); - if (file.exists()) { + if(file.exists()) { return loadFile(file, name); } } @@ -275,11 +274,11 @@ public class ResourceLoader implements MeteredCache { } public T load(String name, boolean warn) { - if (name == null) { + if(name == null) { return null; } - if (name.trim().isEmpty()) { + if(name.trim().isEmpty()) { return null; } @@ -287,12 +286,12 @@ public class ResourceLoader implements MeteredCache { } public KList getFolders() { - if (folderCache.get() == null) { + if(folderCache.get() == null) { folderCache.set(new KList<>()); - for (File i : root.listFiles()) { - if (i.isDirectory()) { - if (i.getName().equals(folderName)) { + for(File i : root.listFiles()) { + if(i.isDirectory()) { + if(i.getName().equals(folderName)) { folderCache.get().add(i); break; } @@ -306,9 +305,9 @@ public class ResourceLoader implements MeteredCache { public KList getFolders(String rc) { KList folders = getFolders().copy(); - if (rc.contains(":")) { - for (File i : folders.copy()) { - if (!rc.startsWith(i.getName() + ":")) { + if(rc.contains(":")) { + for(File i : folders.copy()) { + if(!rc.startsWith(i.getName() + ":")) { folders.remove(i); } } @@ -324,16 +323,16 @@ public class ResourceLoader implements MeteredCache { } public File fileFor(T b) { - for (File i : getFolders()) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(b.getLoadKey())) { + for(File i : getFolders()) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(b.getLoadKey())) { return j; } } File file = new File(i, b.getLoadKey() + ".json"); - if (file.exists()) { + if(file.exists()) { return file; } } @@ -353,8 +352,8 @@ public class ResourceLoader implements MeteredCache { public KList getPossibleKeys(String arg) { KList f = new KList<>(); - for (String i : getPossibleKeys()) { - if (i.equalsIgnoreCase(arg) || i.toLowerCase(Locale.ROOT).startsWith(arg.toLowerCase(Locale.ROOT)) || i.toLowerCase(Locale.ROOT).contains(arg.toLowerCase(Locale.ROOT)) || arg.toLowerCase(Locale.ROOT).contains(i.toLowerCase(Locale.ROOT))) { + for(String i : getPossibleKeys()) { + if(i.equalsIgnoreCase(arg) || i.toLowerCase(Locale.ROOT).startsWith(arg.toLowerCase(Locale.ROOT)) || i.toLowerCase(Locale.ROOT).contains(arg.toLowerCase(Locale.ROOT)) || arg.toLowerCase(Locale.ROOT).contains(i.toLowerCase(Locale.ROOT))) { f.add(i); } } diff --git a/src/main/java/com/volmit/iris/core/loader/ScriptResourceLoader.java b/src/main/java/com/volmit/iris/core/loader/ScriptResourceLoader.java index 329756a00..4df464b59 100644 --- a/src/main/java/com/volmit/iris/core/loader/ScriptResourceLoader.java +++ b/src/main/java/com/volmit/iris/core/loader/ScriptResourceLoader.java @@ -53,7 +53,7 @@ public class ScriptResourceLoader extends ResourceLoader { logLoad(j, t); tlt.addAndGet(p.getMilliseconds()); return t; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage()); return null; @@ -61,24 +61,24 @@ public class ScriptResourceLoader extends ResourceLoader { } public String[] getPossibleKeys() { - if (possibleKeys != null) { + if(possibleKeys != null) { return possibleKeys; } Iris.debug("Building " + resourceTypeName + " Possibility Lists"); KSet m = new KSet<>(); - for (File i : getFolders()) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".js")) { + 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")) { + } 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")) { + } 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", "")); } } @@ -94,16 +94,16 @@ public class ScriptResourceLoader extends ResourceLoader { } public File findFile(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".js") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".js") && j.getName().split("\\Q.\\E")[0].equals(name)) { return j; } } File file = new File(i, name + ".js"); - if (file.exists()) { + if(file.exists()) { return file; } } @@ -114,16 +114,16 @@ public class ScriptResourceLoader extends ResourceLoader { } private IrisScript loadRaw(String name) { - for (File i : getFolders(name)) { - for (File j : i.listFiles()) { - if (j.isFile() && j.getName().endsWith(".js") && j.getName().split("\\Q.\\E")[0].equals(name)) { + for(File i : getFolders(name)) { + for(File j : i.listFiles()) { + if(j.isFile() && j.getName().endsWith(".js") && j.getName().split("\\Q.\\E")[0].equals(name)) { return loadFile(j, name); } } File file = new File(i, name + ".js"); - if (file.exists()) { + if(file.exists()) { return loadFile(file, name); } } diff --git a/src/main/java/com/volmit/iris/core/nms/INMS.java b/src/main/java/com/volmit/iris/core/nms/INMS.java index 589045e27..2f04acbf7 100644 --- a/src/main/java/com/volmit/iris/core/nms/INMS.java +++ b/src/main/java/com/volmit/iris/core/nms/INMS.java @@ -28,7 +28,7 @@ import org.bukkit.Bukkit; public class INMS { //@builder private static final KMap> bindings = new KMap>() - .qput("v1_18_R1", NMSBinding18_1.class); + .qput("v1_18_R1", NMSBinding18_1.class); //@done private static final INMSBinding binding = bind(); @@ -37,13 +37,13 @@ public class INMS { } public static final String getNMSTag() { - if (IrisSettings.get().getGeneral().isDisableNMS()) { + if(IrisSettings.get().getGeneral().isDisableNMS()) { return "BUKKIT"; } try { return Bukkit.getServer().getClass().getCanonicalName().split("\\Q.\\E")[3]; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to determine server nms version!"); e.printStackTrace(); @@ -56,13 +56,13 @@ public class INMS { String code = getNMSTag(); Iris.info("Locating NMS Binding for " + code); - if (bindings.containsKey(code)) { + if(bindings.containsKey(code)) { try { INMSBinding b = bindings.get(code).getConstructor().newInstance(); Iris.info("Craftbukkit " + code + " <-> " + b.getClass().getSimpleName() + " Successfully Bound"); return b; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/core/nms/NMSVersion.java b/src/main/java/com/volmit/iris/core/nms/NMSVersion.java index 7389f6909..fed03088d 100644 --- a/src/main/java/com/volmit/iris/core/nms/NMSVersion.java +++ b/src/main/java/com/volmit/iris/core/nms/NMSVersion.java @@ -47,55 +47,55 @@ public enum NMSVersion { } public static NMSVersion current() { - if (tryVersion("1_8_R3")) { + if(tryVersion("1_8_R3")) { return R1_8; } - if (tryVersion("1_9_R1")) { + if(tryVersion("1_9_R1")) { return R1_9_2; } - if (tryVersion("1_9_R2")) { + if(tryVersion("1_9_R2")) { return R1_9_4; } - if (tryVersion("1_10_R1")) { + if(tryVersion("1_10_R1")) { return R1_10; } - if (tryVersion("1_11_R1")) { + if(tryVersion("1_11_R1")) { return R1_11; } - if (tryVersion("1_12_R1")) { + if(tryVersion("1_12_R1")) { return R1_12; } - if (tryVersion("1_13_R1")) { + if(tryVersion("1_13_R1")) { return R1_13; } - if (tryVersion("1_13_R2")) { + if(tryVersion("1_13_R2")) { return R1_13_1; } - if (tryVersion("1_14_R1")) { + if(tryVersion("1_14_R1")) { return R1_14; } - if (tryVersion("1_15_R1")) { + if(tryVersion("1_15_R1")) { return R1_15; } - if (tryVersion("1_16_R1")) { + if(tryVersion("1_16_R1")) { return R1_16; } - if (tryVersion("1_17_R1")) { + if(tryVersion("1_17_R1")) { return R1_17; } - if (tryVersion("1_18_R1")) { + if(tryVersion("1_18_R1")) { return R1_18; } return null; @@ -105,7 +105,7 @@ public enum NMSVersion { try { Class.forName("org.bukkit.craftbukkit.v" + v + ".CraftWorld"); return true; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -116,8 +116,8 @@ public enum NMSVersion { public List getAboveInclusive() { List n = new ArrayList<>(); - for (NMSVersion i : values()) { - if (i.ordinal() >= ordinal()) { + for(NMSVersion i : values()) { + if(i.ordinal() >= ordinal()) { n.add(i); } } @@ -128,8 +128,8 @@ public enum NMSVersion { public List betweenInclusive(NMSVersion other) { List n = new ArrayList<>(); - for (NMSVersion i : values()) { - if (i.ordinal() <= Math.max(other.ordinal(), ordinal()) && i.ordinal() >= Math.min(ordinal(), other.ordinal())) { + for(NMSVersion i : values()) { + if(i.ordinal() <= Math.max(other.ordinal(), ordinal()) && i.ordinal() >= Math.min(ordinal(), other.ordinal())) { n.add(i); } } @@ -140,8 +140,8 @@ public enum NMSVersion { public List getBelowInclusive() { List n = new ArrayList<>(); - for (NMSVersion i : values()) { - if (i.ordinal() <= ordinal()) { + for(NMSVersion i : values()) { + if(i.ordinal() <= ordinal()) { n.add(i); } } diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index 00b56bd01..fabf939d2 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -35,16 +35,14 @@ import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer; import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; import com.volmit.iris.util.nbt.tag.CompoundTag; -import com.volmit.iris.util.scheduling.Queue; import it.unimi.dsi.fastutil.objects.Object2IntMap; +import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.NbtIo; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; import org.bukkit.Bukkit; @@ -53,11 +51,9 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_18_R1.CraftChunk; import org.bukkit.craftbukkit.v1_18_R1.CraftServer; import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_18_R1.generator.CustomChunkGenerator; import org.bukkit.entity.Entity; import org.bukkit.generator.ChunkGenerator; import org.jetbrains.annotations.NotNull; @@ -68,7 +64,6 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -92,7 +87,7 @@ public class NMSBinding18_1 implements INMSBinding { public CompoundTag serializeTile(Location location) { BlockEntity e = ((CraftWorld) location.getWorld()).getHandle().getBlockEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true); - if (e == null) { + if(e == null) { return null; } @@ -107,7 +102,7 @@ public class NMSBinding18_1 implements INMSBinding { tag.write(dos); dos.close(); return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag(); - } catch (Throwable ex) { + } catch(Throwable ex) { ex.printStackTrace(); } @@ -122,7 +117,7 @@ public class NMSBinding18_1 implements INMSBinding { net.minecraft.nbt.CompoundTag c = NbtIo.read(din); din.close(); return c; - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -149,8 +144,7 @@ public class NMSBinding18_1 implements INMSBinding { return true; } - private RegistryAccess registry() - { + private RegistryAccess registry() { return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer())); } @@ -205,19 +199,19 @@ public class NMSBinding18_1 implements INMSBinding { @Override public Object getBiomeBase(World world, Biome biome) { - return getBiomeBase(((CraftWorld)world).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null), biome); + return getBiomeBase(((CraftWorld) world).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null), biome); } @Override public Object getBiomeBase(Object registry, Biome biome) { Object v = baseBiomeCache.get(biome); - if (v != null) { + if(v != null) { return v; } //noinspection unchecked v = org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry) registry, biome); - if (v == null) { + if(v == null) { // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. // But, this does NOT exist within CraftBukkit which makes it return an error. // So, we will just return the ID that the plains biome returns instead. @@ -235,8 +229,8 @@ public class NMSBinding18_1 implements INMSBinding { @Override public int getBiomeId(Biome biome) { - for (World i : Bukkit.getWorlds()) { - if (i.getEnvironment().equals(World.Environment.NORMAL)) { + for(World i : Bukkit.getWorlds()) { + if(i.getEnvironment().equals(World.Environment.NORMAL)) { Registry registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registry.BIOME_REGISTRY).orElse(null); return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome)); } @@ -302,7 +296,7 @@ public class NMSBinding18_1 implements INMSBinding { AtomicInteger a = new AtomicInteger(0); getCustomBiomeRegistry().keySet().forEach((i) -> { - if (i.getNamespace().equals("minecraft")) { + if(i.getNamespace().equals("minecraft")) { return; } @@ -322,7 +316,7 @@ public class NMSBinding18_1 implements INMSBinding { try { ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk); s.setBiome(x, y, z, (net.minecraft.world.level.biome.Biome) somethingVeryDirty); - } catch (IllegalAccessException e) { + } catch(IllegalAccessException e) { Iris.reportError(e); e.printStackTrace(); } @@ -331,7 +325,7 @@ public class NMSBinding18_1 implements INMSBinding { private Field getFieldForBiomeStorage(Object storage) { Field f = biomeStorageCache; - if (f != null) { + if(f != null) { return f; } try { @@ -339,7 +333,7 @@ public class NMSBinding18_1 implements INMSBinding { f = storage.getClass().getDeclaredField("biome"); f.setAccessible(true); return f; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); Iris.error(storage.getClass().getCanonicalName()); @@ -377,23 +371,19 @@ public class NMSBinding18_1 implements INMSBinding { private static Object getFor(Class type, Object source) { Object o = fieldFor(type, source); - if(o != null) - { + if(o != null) { return o; } return invokeFor(type, source); } - private static Object invokeFor(Class returns, Object in) - { - for(Method i : in.getClass().getMethods()) - { - if(i.getReturnType().equals(returns)) - { + private static Object invokeFor(Class returns, Object in) { + for(Method i : in.getClass().getMethods()) { + if(i.getReturnType().equals(returns)) { i.setAccessible(true); try { - Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() +"."+ i.getName() + "()"); + Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()"); return i.invoke(in); } catch(Throwable e) { e.printStackTrace(); @@ -404,15 +394,12 @@ public class NMSBinding18_1 implements INMSBinding { return null; } - private static Object fieldFor(Class returns, Object in) - { - for(Field i : in.getClass().getFields()) - { - if(i.getType().equals(returns)) - { + private static Object fieldFor(Class returns, Object in) { + for(Field i : in.getClass().getFields()) { + if(i.getType().equals(returns)) { i.setAccessible(true); try { - Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() +"."+ i.getName()); + Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName()); return i.get(in); } catch(IllegalAccessException e) { e.printStackTrace(); diff --git a/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java b/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java index 7e50c1122..023ecc07c 100644 --- a/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java +++ b/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java @@ -35,12 +35,12 @@ public class NMSBinding1X implements INMSBinding { @SuppressWarnings("ConstantConditions") private static boolean testCustomHeight() { try { - if (World.class.getDeclaredMethod("getMaxHeight") != null && World.class.getDeclaredMethod("getMinHeight") != null) + if(World.class.getDeclaredMethod("getMaxHeight") != null && World.class.getDeclaredMethod("getMinHeight") != null) ; { return true; } - } catch (Throwable ignored) { + } catch(Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/core/pack/IrisPack.java b/src/main/java/com/volmit/iris/core/pack/IrisPack.java index 1dbc64cf0..3954e0d17 100644 --- a/src/main/java/com/volmit/iris/core/pack/IrisPack.java +++ b/src/main/java/com/volmit/iris/core/pack/IrisPack.java @@ -54,7 +54,8 @@ public class IrisPack { * Create an iris pack backed by a data folder * the data folder is assumed to be in the Iris/packs/NAME folder * - * @param name the name + * @param name + * the name */ public IrisPack(String name) { this(packsPack(name)); @@ -63,16 +64,17 @@ public class IrisPack { /** * Create an iris pack backed by a data folder * - * @param folder the folder of the pack. Must be a directory + * @param folder + * the folder of the pack. Must be a directory */ public IrisPack(File folder) { this.folder = folder; - if (!folder.exists()) { + if(!folder.exists()) { throw new RuntimeException("Cannot open Pack " + folder.getPath() + " (directory doesnt exist)"); } - if (!folder.isDirectory()) { + if(!folder.isDirectory()) { throw new RuntimeException("Cannot open Pack " + folder.getPath() + " (not a directory)"); } @@ -82,20 +84,23 @@ public class IrisPack { /** * Create a new pack from the input url * - * @param sender the sender - * @param url the url, or name, or really anything see IrisPackRepository.from(String) + * @param sender + * the sender + * @param url + * the url, or name, or really anything see IrisPackRepository.from(String) * @return the iris pack - * @throws IrisException fails + * @throws IrisException + * fails */ public static Future from(VolmitSender sender, String url) throws IrisException { IrisPackRepository repo = IrisPackRepository.from(url); - if (repo == null) { + if(repo == null) { throw new IrisException("Null Repo"); } try { return from(sender, repo); - } catch (MalformedURLException e) { + } catch(MalformedURLException e) { throw new IrisException("Malformed URL " + e.getMessage()); } } @@ -103,10 +108,13 @@ public class IrisPack { /** * Create a pack from a repo * - * @param sender the sender - * @param repo the repo + * @param sender + * the sender + * @param repo + * the repo * @return the pack - * @throws MalformedURLException shit happens + * @throws MalformedURLException + * shit happens */ public static Future from(VolmitSender sender, IrisPackRepository repo) throws MalformedURLException { CompletableFuture pack = new CompletableFuture<>(); @@ -119,14 +127,16 @@ public class IrisPack { /** * Create a blank pack with a given name * - * @param name the name of the pack + * @param name + * the name of the pack * @return the pack - * @throws IrisException if the pack already exists or another error + * @throws IrisException + * if the pack already exists or another error */ public static IrisPack blank(String name) throws IrisException { File f = packsPack(name); - if (f.exists()) { + if(f.exists()) { throw new IrisException("Already exists"); } @@ -134,10 +144,10 @@ public class IrisPack { fd.getParentFile().mkdirs(); try { IO.writeAll(fd, "{\n" + - " \"name\": \"" + Form.capitalize(name) + "\",\n" + - " \"version\": 1\n" + - "}\n"); - } catch (IOException e) { + " \"name\": \"" + Form.capitalize(name) + "\",\n" + + " \"version\": 1\n" + + "}\n"); + } catch(IOException e) { throw new IrisException(e.getMessage(), e); } @@ -149,7 +159,8 @@ public class IrisPack { /** * Get a packs pack folder for a name. Such that overworld would resolve as Iris/packs/overworld * - * @param name the name + * @param name + * the name * @return the file path */ public static File packsPack(String name) { @@ -159,11 +170,11 @@ public class IrisPack { private static KList collectFiles(File f, String fileExtension) { KList l = new KList<>(); - if (f.isDirectory()) { - for (File i : f.listFiles()) { + if(f.isDirectory()) { + for(File i : f.listFiles()) { l.addAll(collectFiles(i, fileExtension)); } - } else if (f.getName().endsWith("." + fileExtension)) { + } else if(f.getName().endsWith("." + fileExtension)) { l.add(f); } @@ -214,13 +225,13 @@ public class IrisPack { p.end(); Iris.debug("Building Workspace: " + ws.getPath() + " took " + Form.duration(p.getMilliseconds(), 2)); return true; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Pack invalid: " + ws.getAbsolutePath() + " Re-creating. You may loose some vs-code workspace settings! But not your actual project!"); ws.delete(); try { IO.writeAll(ws, generateWorkspaceConfig()); - } catch (IOException e1) { + } catch(IOException e1) { Iris.reportError(e1); e1.printStackTrace(); } @@ -232,7 +243,8 @@ public class IrisPack { /** * Install this pack into a world * - * @param world the world to install into (world/iris/pack) + * @param world + * the world to install into (world/iris/pack) * @return the installed pack */ public IrisPack install(World world) throws IrisException { @@ -242,7 +254,8 @@ public class IrisPack { /** * Install this pack into a world * - * @param world the world to install into (world/iris/pack) + * @param world + * the world to install into (world/iris/pack) * @return the installed pack */ public IrisPack install(IrisWorld world) throws IrisException { @@ -252,11 +265,12 @@ public class IrisPack { /** * Install this pack into a world * - * @param folder the folder to install this pack into + * @param folder + * the folder to install this pack into * @return the installed pack */ public IrisPack install(File folder) throws IrisException { - if (folder.exists()) { + if(folder.exists()) { throw new IrisException("Cannot install new pack because the folder " + folder.getName() + " already exists!"); } @@ -264,7 +278,7 @@ public class IrisPack { try { FileUtils.copyDirectory(getFolder(), folder); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } @@ -275,19 +289,20 @@ public class IrisPack { * Create a new pack using this pack as a template. The new pack will be renamed & have a renamed dimension * to match it. * - * @param newName the new pack name + * @param newName + * the new pack name * @return the new IrisPack */ public IrisPack install(String newName) throws IrisException { File newPack = packsPack(newName); - if (newPack.exists()) { + if(newPack.exists()) { throw new IrisException("Cannot install new pack because the folder " + newName + " already exists!"); } try { FileUtils.copyDirectory(getFolder(), newPack); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } @@ -299,7 +314,7 @@ public class IrisPack { try { FileUtils.moveFile(from, to); new File(newPack, getWorkspaceFile().getName()).delete(); - } catch (Throwable e) { + } catch(Throwable e) { throw new IrisException(e); } @@ -330,7 +345,8 @@ public class IrisPack { /** * Find all files in this pack with the given extension * - * @param fileExtension the extension + * @param fileExtension + * the extension * @return the list of files */ public KList collectFiles(String fileExtension) { @@ -370,8 +386,8 @@ public class IrisPack { JSONArray schemas = new JSONArray(); IrisData dm = IrisData.get(getFolder()); - for (ResourceLoader r : dm.getLoaders().v()) { - if (r.supportsSchemas()) { + for(ResourceLoader r : dm.getLoaders().v()) { + if(r.supportsSchemas()) { schemas.put(r.buildSchema()); } } diff --git a/src/main/java/com/volmit/iris/core/pack/IrisPackRepository.java b/src/main/java/com/volmit/iris/core/pack/IrisPackRepository.java index d006198b5..181dc57f9 100644 --- a/src/main/java/com/volmit/iris/core/pack/IrisPackRepository.java +++ b/src/main/java/com/volmit/iris/core/pack/IrisPackRepository.java @@ -51,39 +51,38 @@ public class IrisPackRepository { private String tag = ""; /** - * @param g - * @return + * */ public static IrisPackRepository from(String g) { // https://github.com/IrisDimensions/overworld - if (g.startsWith("https://github.com/")) { + if(g.startsWith("https://github.com/")) { String sub = g.split("\\Qgithub.com/\\E")[1]; IrisPackRepository r = IrisPackRepository.builder() - .user(sub.split("\\Q/\\E")[0]) - .repo(sub.split("\\Q/\\E")[1]).build(); + .user(sub.split("\\Q/\\E")[0]) + .repo(sub.split("\\Q/\\E")[1]).build(); - if (g.contains("/tree/")) { + if(g.contains("/tree/")) { r.setBranch(g.split("/tree/")[1]); } return r; - } else if (g.contains("/")) { + } else if(g.contains("/")) { String[] f = g.split("\\Q/\\E"); - if (f.length == 1) { + if(f.length == 1) { return from(g); - } else if (f.length == 2) { + } else if(f.length == 2) { return IrisPackRepository.builder() - .user(f[0]) - .repo(f[1]) - .build(); - } else if (f.length >= 3) { + .user(f[0]) + .repo(f[1]) + .build(); + } else if(f.length >= 3) { IrisPackRepository r = IrisPackRepository.builder() - .user(f[0]) - .repo(f[1]) - .build(); + .user(f[0]) + .repo(f[1]) + .build(); - if (f[2].startsWith("#")) { + if(f[2].startsWith("#")) { r.setTag(f[2].substring(1)); } else { r.setBranch(f[2]); @@ -93,17 +92,17 @@ public class IrisPackRepository { } } else { return IrisPackRepository.builder() - .user("IrisDimensions") - .repo(g) - .branch(g.equals("overworld") ? "stable" : "master") - .build(); + .user("IrisDimensions") + .repo(g) + .branch(g.equals("overworld") ? "stable" : "master") + .build(); } return null; } public String toURL() { - if (!tag.trim().isEmpty()) { + if(!tag.trim().isEmpty()) { return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/tags/" + tag; } @@ -113,19 +112,19 @@ public class IrisPackRepository { public void install(VolmitSender sender, Runnable whenComplete) throws MalformedURLException { File pack = Iris.instance.getDataFolderNoCreate(StudioSVC.WORKSPACE_NAME, getRepo()); - if (!pack.exists()) { + if(!pack.exists()) { File dl = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID() + ".zip"); File work = new File(Iris.getTemp(), "extk-" + UUID.randomUUID()); new JobCollection(Form.capitalize(getRepo()), - new DownloadJob(toURL(), pack), - new SingleJob("Extracting", () -> ZipUtil.unpack(dl, work)), - new SingleJob("Installing", () -> { - try { - FileUtils.copyDirectory(work.listFiles()[0], pack); - } catch (IOException e) { - e.printStackTrace(); - } - })).execute(sender, whenComplete); + new DownloadJob(toURL(), pack), + new SingleJob("Extracting", () -> ZipUtil.unpack(dl, work)), + new SingleJob("Installing", () -> { + try { + FileUtils.copyDirectory(work.listFiles()[0], pack); + } catch(IOException e) { + e.printStackTrace(); + } + })).execute(sender, whenComplete); } else { sender.sendMessage("Pack already exists!"); } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/IrisPregenerator.java b/src/main/java/com/volmit/iris/core/pregenerator/IrisPregenerator.java index e0afec95f..df562bba9 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/IrisPregenerator.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/IrisPregenerator.java @@ -85,7 +85,7 @@ public class IrisPregenerator { generatedLast.set(generated.get()); chunksPerSecond.put(secondGenerated); - if (minuteLatch.flip()) { + if(minuteLatch.flip()) { int minuteGenerated = generated.get() - generatedLastMinute.get(); generatedLastMinute.set(generated.get()); chunksPerMinute.put(minuteGenerated); @@ -93,13 +93,13 @@ public class IrisPregenerator { } listener.onTick(chunksPerSecond.getAverage(), chunksPerMinute.getAverage(), - regionsPerMinute.getAverage(), - (double) generated.get() / (double) totalChunks.get(), - generated.get(), totalChunks.get(), - totalChunks.get() - generated.get(), - eta, M.ms() - startTime.get(), currentGeneratorMethod.get()); + regionsPerMinute.getAverage(), + (double) generated.get() / (double) totalChunks.get(), + generated.get(), totalChunks.get(), + totalChunks.get() - generated.get(), + eta, M.ms() - startTime.get(), currentGeneratorMethod.get()); - if (cl.flip()) { + if(cl.flip()) { Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (" + Form.pc((double) generated.get() / (double) totalChunks.get(), 0) + ") " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2)); } @@ -110,7 +110,7 @@ public class IrisPregenerator { private long computeETA() { return (long) ((totalChunks.get() - generated.get()) * - ((double) (M.ms() - startTime.get()) / (double) generated.get())); + ((double) (M.ms() - startTime.get()) / (double) generated.get())); } public void close() { @@ -143,34 +143,34 @@ public class IrisPregenerator { } private void visitRegion(int x, int z, boolean regions) { - while (paused.get() && !shutdown.get()) { + while(paused.get() && !shutdown.get()) { J.sleep(50); } - if (shutdown.get()) { + if(shutdown.get()) { listener.onRegionSkipped(x, z); return; } Position2 pos = new Position2(x, z); - if (generatedRegions.contains(pos)) { + if(generatedRegions.contains(pos)) { return; } currentGeneratorMethod.set(generator.getMethod(x, z)); boolean hit = false; - if (generator.supportsRegions(x, z, listener) && regions) { + if(generator.supportsRegions(x, z, listener) && regions) { hit = true; listener.onRegionGenerating(x, z); generator.generateRegion(x, z, listener); - } else if (!regions) { + } else if(!regions) { hit = true; listener.onRegionGenerating(x, z); PregenTask.iterateRegion(x, z, (xx, zz) -> generator.generateChunk(xx, zz, listener)); } - if (hit) { + if(hit) { listener.onRegionGenerated(x, z); listener.onSaving(); generator.save(); @@ -180,7 +180,7 @@ public class IrisPregenerator { } private void checkRegion(int x, int z) { - if (generatedRegions.contains(new Position2(x, z))) { + if(generatedRegions.contains(new Position2(x, z))) { return; } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/PregenTask.java b/src/main/java/com/volmit/iris/core/pregenerator/PregenTask.java index facaf8e2e..660f40745 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/PregenTask.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/PregenTask.java @@ -43,7 +43,7 @@ public class PregenTask { private int height = 1; public static void iterateRegion(int xr, int zr, Spiraled s, Position2 pull) { - for (Position2 i : ORDERS.computeIfAbsent(pull, PregenTask::computeOrder)) { + for(Position2 i : ORDERS.computeIfAbsent(pull, PregenTask::computeOrder)) { s.on(i.getX() + (xr << 5), i.getZ() + (zr << 5)); } } @@ -57,7 +57,7 @@ public class PregenTask { new Spiraler(33, 33, (x, z) -> { int xx = (x + 15); int zz = (z + 15); - if (xx < 0 || xx > 31 || zz < 0 || zz > 31) { + if(xx < 0 || xx > 31 || zz < 0 || zz > 31) { return; } @@ -74,7 +74,7 @@ public class PregenTask { new Spiraler(33, 33, (x, z) -> { int xx = x + 15; int zz = z + 15; - if (xx < 0 || xx > 31 || zz < 0 || zz > 31) { + if(xx < 0 || xx > 31 || zz < 0 || zz > 31) { return; } @@ -86,11 +86,11 @@ public class PregenTask { public void iterateRegions(Spiraled s) { new Spiraler(getWidth() * 2, getHeight() * 2, s) - .setOffset(center.getX(), center.getZ()).drain(); + .setOffset(center.getX(), center.getZ()).drain(); } public void iterateAllChunks(Spiraled s) { new Spiraler(getWidth() * 2, getHeight() * 2, (x, z) -> iterateRegion(x, z, s)) - .setOffset(center.getX(), center.getZ()).drain(); + .setOffset(center.getX(), center.getZ()).drain(); } } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java index 3ab5f3e1c..8a3154fc8 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java @@ -43,8 +43,10 @@ public interface PregeneratorMethod { /** * Return true if regions can be generated * - * @param x the x region - * @param z the z region + * @param x + * the x region + * @param z + * the z region * @return true if they can be */ boolean supportsRegions(int x, int z, PregenListener listener); @@ -52,8 +54,10 @@ public interface PregeneratorMethod { /** * Return the name of the method being used * - * @param x the x region - * @param z the z region + * @param x + * the x region + * @param z + * the z region * @return the name */ String getMethod(int x, int z); @@ -62,18 +66,22 @@ public interface PregeneratorMethod { * Called to generate a region. Execute sync, if multicore internally, wait * for the task to complete * - * @param x the x - * @param z the z - * @param listener signal chunks generating & generated. Parallel capable. + * @param x + * the x + * @param z + * the z + * @param listener + * signal chunks generating & generated. Parallel capable. */ void generateRegion(int x, int z, PregenListener listener); /** * Called to generate a chunk. You can go async so long as save will wait on the threads to finish * - * @param x the x - * @param z the z - * @param listener + * @param x + * the x + * @param z + * the z */ void generateChunk(int x, int z, PregenListener listener); diff --git a/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java index aa828ffd5..40f7773ee 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/methods/AsyncPregenMethod.java @@ -39,7 +39,7 @@ public class AsyncPregenMethod implements PregeneratorMethod { private final KList> future; public AsyncPregenMethod(World world, int threads) { - if (!PaperLib.isPaper()) { + if(!PaperLib.isPaper()) { throw new UnsupportedOperationException("Cannot use PaperAsync on non paper!"); } @@ -51,17 +51,17 @@ public class AsyncPregenMethod implements PregeneratorMethod { private void unloadAndSaveAllChunks() { try { J.sfut(() -> { - if (world == null) { + if(world == null) { Iris.warn("World was null somehow..."); return; } - for (Chunk i : world.getLoadedChunks()) { + for(Chunk i : world.getLoadedChunks()) { i.unload(true); } world.save(); }).get(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -71,7 +71,7 @@ public class AsyncPregenMethod implements PregeneratorMethod { PaperLib.getChunkAtAsync(world, x, z, true).get(); listener.onChunkGenerated(x, z); listener.onChunkCleaned(x, z); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); J.sleep(5); future.add(burst.complete(() -> completeChunk(x, z, listener))); @@ -79,11 +79,11 @@ public class AsyncPregenMethod implements PregeneratorMethod { } private void waitForChunks() { - for (Future i : future.copy()) { + for(Future i : future.copy()) { try { i.get(); future.remove(i); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -123,7 +123,7 @@ public class AsyncPregenMethod implements PregeneratorMethod { @Override public void generateChunk(int x, int z, PregenListener listener) { - if (future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) { // TODO: FIX + if(future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) { // TODO: FIX waitForChunks(); } @@ -133,7 +133,7 @@ public class AsyncPregenMethod implements PregeneratorMethod { @Override public Mantle getMantle() { - if (IrisToolbelt.isIrisWorld(world)) { + if(IrisToolbelt.isIrisWorld(world)) { return IrisToolbelt.access(world).getEngine().getMantle().getMantle(); } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java index 753610582..649d105f4 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/methods/HybridPregenMethod.java @@ -38,7 +38,7 @@ public class HybridPregenMethod implements PregeneratorMethod { public HybridPregenMethod(World world, int threads) { this.world = world; headless = supportsHeadless(world) - ? new HeadlessPregenMethod(HeadlessWorld.from(world)) : new DummyPregenMethod(); + ? new HeadlessPregenMethod(HeadlessWorld.from(world)) : new DummyPregenMethod(); inWorld = new AsyncOrMedievalPregenMethod(world, threads); } @@ -71,18 +71,18 @@ public class HybridPregenMethod implements PregeneratorMethod { @Override public boolean supportsRegions(int x, int z, PregenListener listener) { - if (headless instanceof DummyPregenMethod) { + if(headless instanceof DummyPregenMethod) { return false; } boolean r = !new File(world.getWorldFolder(), "region/r." + x + "." + z + ".mca").exists(); - if (!r && listener != null) { + if(!r && listener != null) { try { - for (Position2 i : ((HeadlessPregenMethod) headless).getGenerator().getChunksInRegion(x, z)) { + for(Position2 i : ((HeadlessPregenMethod) headless).getGenerator().getChunksInRegion(x, z)) { listener.onChunkExistsInRegionGen((x << 5) + i.getX(), (z << 5) + i.getZ()); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } @@ -102,7 +102,7 @@ public class HybridPregenMethod implements PregeneratorMethod { @Override public Mantle getMantle() { - if (headless == null) { + if(headless == null) { return inWorld.getMantle(); } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/methods/MedievalPregenMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/methods/MedievalPregenMethod.java index 2ee50ea2f..b2fbadce4 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/methods/MedievalPregenMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/methods/MedievalPregenMethod.java @@ -40,10 +40,10 @@ public class MedievalPregenMethod implements PregeneratorMethod { } private void waitForChunks() { - for (CompletableFuture i : futures) { + for(CompletableFuture i : futures) { try { i.get(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -55,12 +55,12 @@ public class MedievalPregenMethod implements PregeneratorMethod { waitForChunks(); try { J.sfut(() -> { - for (Chunk i : world.getLoadedChunks()) { + for(Chunk i : world.getLoadedChunks()) { i.unload(true); } world.save(); }).get(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -97,7 +97,7 @@ public class MedievalPregenMethod implements PregeneratorMethod { @Override public void generateChunk(int x, int z, PregenListener listener) { - if (futures.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) { + if(futures.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) { waitForChunks(); } @@ -111,7 +111,7 @@ public class MedievalPregenMethod implements PregeneratorMethod { @Override public Mantle getMantle() { - if (IrisToolbelt.isIrisWorld(world)) { + if(IrisToolbelt.isIrisWorld(world)) { return IrisToolbelt.access(world).getEngine().getMantle().getMantle(); } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/methods/SyndicatePregenMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/methods/SyndicatePregenMethod.java index ebc369d10..edfc06bf8 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/methods/SyndicatePregenMethod.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/methods/SyndicatePregenMethod.java @@ -70,40 +70,40 @@ public class SyndicatePregenMethod implements PregeneratorMethod { } public synchronized void setup() { - if (ready) { + if(ready) { return; } ready = false; try { connect().command(SyndicateInstallPack - .builder() - .dimension(dimension) - .pack(pack) - .seed(seed) - .build()) - .output((o) -> { - File to = new File(Iris.getTemp(), "send-" + pack + ".zip"); - ZipUtil.pack(dimension.getLoader().getDataFolder(), to); + .builder() + .dimension(dimension) + .pack(pack) + .seed(seed) + .build()) + .output((o) -> { + File to = new File(Iris.getTemp(), "send-" + pack + ".zip"); + ZipUtil.pack(dimension.getLoader().getDataFolder(), to); - try { - IO.writeAll(to, o); - } catch (IOException e) { - e.printStackTrace(); - } + try { + IO.writeAll(to, o); + } catch(IOException e) { + e.printStackTrace(); + } - to.deleteOnExit(); - }) - .build().go((response, data) -> { - if (response instanceof SyndicateBusy) { - throw new RuntimeException("Service is busy, will try later"); - } + to.deleteOnExit(); + }) + .build().go((response, data) -> { + if(response instanceof SyndicateBusy) { + throw new RuntimeException("Service is busy, will try later"); + } - ready = true; - }); + ready = true; + }); ready = true; - } catch (Throwable throwable) { - if (throwable instanceof RuntimeException) { + } catch(Throwable throwable) { + if(throwable instanceof RuntimeException) { ready = false; return; } @@ -113,7 +113,7 @@ public class SyndicatePregenMethod implements PregeneratorMethod { } public boolean canGenerate() { - if (!ready) { + if(!ready) { J.a(this::setup); } @@ -127,17 +127,17 @@ public class SyndicatePregenMethod implements PregeneratorMethod { @Override public void close() { - if (ready) { + if(ready) { try { connect() - .command(SyndicateClose - .builder() - .pack(pack) - .build()) - .build() - .go((__, __b) -> { - }); - } catch (Throwable throwable) { + .command(SyndicateClose + .builder() + .pack(pack) + .build()) + .build() + .go((__, __b) -> { + }); + } catch(Throwable throwable) { throwable.printStackTrace(); } } @@ -162,24 +162,24 @@ public class SyndicatePregenMethod implements PregeneratorMethod { AtomicDouble progress = new AtomicDouble(-1); try { connect() - .command(SyndicateGetProgress.builder() - .pack(pack).build()).output((i) -> { - }).build().go((response, o) -> { - if (response instanceof SyndicateSendProgress) { - if (((SyndicateSendProgress) response).isAvailable()) { - progress.set(((SyndicateSendProgress) response).getProgress()); - File f = new File(worldFolder, "region/r." + x + "." + z + ".mca"); - try { - f.getParentFile().mkdirs(); - IO.writeAll(f, o); - progress.set(1000); - } catch (Throwable e) { - e.printStackTrace(); - } + .command(SyndicateGetProgress.builder() + .pack(pack).build()).output((i) -> { + }).build().go((response, o) -> { + if(response instanceof SyndicateSendProgress) { + if(((SyndicateSendProgress) response).isAvailable()) { + progress.set(((SyndicateSendProgress) response).getProgress()); + File f = new File(worldFolder, "region/r." + x + "." + z + ".mca"); + try { + f.getParentFile().mkdirs(); + IO.writeAll(f, o); + progress.set(1000); + } catch(Throwable e) { + e.printStackTrace(); } } - }); - } catch (Throwable throwable) { + } + }); + } catch(Throwable throwable) { throwable.printStackTrace(); } @@ -188,73 +188,73 @@ public class SyndicatePregenMethod implements PregeneratorMethod { @Override public void generateRegion(int x, int z, PregenListener listener) { - if (!ready) { + if(!ready) { throw new RuntimeException(); } try { connect().command(SyndicateGenerate - .builder() - .x(x).z(z).pack(pack) - .build()) - .build().go((response, data) -> { - if (response instanceof SyndicateOK) { - listener.onNetworkStarted(x, z); - J.a(() -> { - double lastp = 0; - int calls = 0; - boolean installed = false; - while (true) { - J.sleep(100); - double progress = checkProgress(x, z); - - if (progress == 1000) { - installed = true; - AtomicInteger a = new AtomicInteger(calls); - PregenTask.iterateRegion(x, z, (xx, zz) -> { - if (a.decrementAndGet() < 0) { - listener.onNetworkGeneratedChunk(xx, zz); - } - }); - calls = 1024; - } else if (progress < 0) { - break; - } - - int change = (int) Math.floor((progress - lastp) * 1024D); - change = change == 0 ? 1 : change; + .builder() + .x(x).z(z).pack(pack) + .build()) + .build().go((response, data) -> { + if(response instanceof SyndicateOK) { + listener.onNetworkStarted(x, z); + J.a(() -> { + double lastp = 0; + int calls = 0; + boolean installed = false; + while(true) { + J.sleep(100); + double progress = checkProgress(x, z); + if(progress == 1000) { + installed = true; AtomicInteger a = new AtomicInteger(calls); - AtomicInteger b = new AtomicInteger(change); PregenTask.iterateRegion(x, z, (xx, zz) -> { - if (a.decrementAndGet() < 0) { - if (b.decrementAndGet() >= 0) { - listener.onNetworkGeneratedChunk(xx, zz); - } + if(a.decrementAndGet() < 0) { + listener.onNetworkGeneratedChunk(xx, zz); } }); - calls += change; + calls = 1024; + } else if(progress < 0) { + break; } - if (!installed) { - // TODO RETRY REGION - return; - } + int change = (int) Math.floor((progress - lastp) * 1024D); + change = change == 0 ? 1 : change; - listener.onNetworkDownloaded(x, z); - }); - } else if (response instanceof SyndicateInstallFirst) { - ready = false; - throw new RuntimeException(); - } else if (response instanceof SyndicateBusy) { - throw new RuntimeException(); - } else { - throw new RuntimeException(); - } - }); - } catch (Throwable throwable) { + AtomicInteger a = new AtomicInteger(calls); + AtomicInteger b = new AtomicInteger(change); + PregenTask.iterateRegion(x, z, (xx, zz) -> { + if(a.decrementAndGet() < 0) { + if(b.decrementAndGet() >= 0) { + listener.onNetworkGeneratedChunk(xx, zz); + } + } + }); + calls += change; + } - if (throwable instanceof RuntimeException) { + if(!installed) { + // TODO RETRY REGION + return; + } + + listener.onNetworkDownloaded(x, z); + }); + } else if(response instanceof SyndicateInstallFirst) { + ready = false; + throw new RuntimeException(); + } else if(response instanceof SyndicateBusy) { + throw new RuntimeException(); + } else { + throw new RuntimeException(); + } + }); + } catch(Throwable throwable) { + + if(throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateClient.java b/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateClient.java index 83a5e44e3..491713f07 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateClient.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateClient.java @@ -40,7 +40,7 @@ public class SyndicateClient { DataOutputStream o = new DataOutputStream(socket.getOutputStream()); SyndicateCommandIO.write(command, o); - if (output != null) { + if(output != null) { output.accept(o); } diff --git a/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateServer.java b/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateServer.java index 5762de8b4..e971396dd 100644 --- a/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateServer.java +++ b/src/main/java/com/volmit/iris/core/pregenerator/syndicate/SyndicateServer.java @@ -69,7 +69,7 @@ public class SyndicateServer extends Thread implements PregenListener { } public void run() { - while (!interrupted()) { + while(!interrupted()) { try { Socket client = server.accept(); DataInputStream i = new DataInputStream(client.getInputStream()); @@ -77,13 +77,13 @@ public class SyndicateServer extends Thread implements PregenListener { try { handle(client, i, o); o.flush(); - } catch (Throwable throwable) { + } catch(Throwable throwable) { throwable.printStackTrace(); } client.close(); - } catch (SocketTimeoutException ignored) { + } catch(SocketTimeoutException ignored) { - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } } @@ -92,7 +92,7 @@ public class SyndicateServer extends Thread implements PregenListener { private void handle(Socket client, DataInputStream i, DataOutputStream o) throws Throwable { SyndicateCommand cmd = handle(SyndicateCommandIO.read(i), i, o); - if (cmd != null) { + if(cmd != null) { SyndicateCommandIO.write(cmd, o); } @@ -104,12 +104,12 @@ public class SyndicateServer extends Thread implements PregenListener { } private SyndicateCommand handle(SyndicateCommand command, DataInputStream i, DataOutputStream o) throws Throwable { - if (command instanceof SyndicateInstallPack) { - if (busy) { + if(command instanceof SyndicateInstallPack) { + if(busy) { return new SyndicateBusy(); } - if (generator != null) { + if(generator != null) { generator.close(); IO.delete(generator.getWorld().getWorld().worldFolder()); generator = null; @@ -133,12 +133,12 @@ public class SyndicateServer extends Thread implements PregenListener { return new SyndicateOK(); } - if (command instanceof SyndicateGenerate) { - if (busy) { + if(command instanceof SyndicateGenerate) { + if(busy) { return new SyndicateBusy(); } - if (generator == null || !Objects.equals(currentId, ((SyndicateGenerate) command).getPack())) { + if(generator == null || !Objects.equals(currentId, ((SyndicateGenerate) command).getPack())) { return new SyndicateInstallFirst(); } @@ -151,8 +151,8 @@ public class SyndicateServer extends Thread implements PregenListener { return new SyndicateOK(); } - if (command instanceof SyndicateClose) { - if (generator != null && Objects.equals(currentId, ((SyndicateClose) command).getPack()) && !busy) { + if(command instanceof SyndicateClose) { + if(generator != null && Objects.equals(currentId, ((SyndicateClose) command).getPack()) && !busy) { generator.close(); IO.delete(generator.getWorld().getWorld().worldFolder()); generator = null; @@ -160,18 +160,18 @@ public class SyndicateServer extends Thread implements PregenListener { } } - if (command instanceof SyndicateGetProgress) { - if (generator != null && busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack())) { + if(command instanceof SyndicateGetProgress) { + if(generator != null && busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack())) { return SyndicateSendProgress.builder().progress((double) g.get() / 1024D).build(); - } else if (generator != null && !busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack()) && lastGeneratedRegion != null && lastGeneratedRegion.exists()) { + } else if(generator != null && !busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack()) && lastGeneratedRegion != null && lastGeneratedRegion.exists()) { SyndicateCommandIO.write(SyndicateSendProgress - .builder() - .progress(1).available(true) - .build(), o); + .builder() + .progress(1).available(true) + .build(), o); o.writeLong(lastGeneratedRegion.length()); IO.writeAll(lastGeneratedRegion, o); return null; - } else if (generator == null) { + } else if(generator == null) { return new SyndicateInstallFirst(); } else { return new SyndicateBusy(); diff --git a/src/main/java/com/volmit/iris/core/project/IrisProject.java b/src/main/java/com/volmit/iris/core/project/IrisProject.java index 8e2735f60..d5a847012 100644 --- a/src/main/java/com/volmit/iris/core/project/IrisProject.java +++ b/src/main/java/com/volmit/iris/core/project/IrisProject.java @@ -82,14 +82,14 @@ public class IrisProject { public static int clean(VolmitSender s, File clean) { int c = 0; - if (clean.isDirectory()) { - for (File i : clean.listFiles()) { + if(clean.isDirectory()) { + for(File i : clean.listFiles()) { c += clean(s, i); } - } else if (clean.getName().endsWith(".json")) { + } else if(clean.getName().endsWith(".json")) { try { clean(clean); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!"); } @@ -108,29 +108,29 @@ public class IrisProject { } public static void fixBlocks(JSONObject obj, File f) { - for (String i : obj.keySet()) { + for(String i : obj.keySet()) { Object o = obj.get(i); - if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { + if(i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { obj.put(i, "minecraft:" + o); Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath()); } - if (o instanceof JSONObject) { + if(o instanceof JSONObject) { fixBlocks((JSONObject) o, f); - } else if (o instanceof JSONArray) { + } else if(o instanceof JSONArray) { fixBlocks((JSONArray) o, f); } } } public static void fixBlocks(JSONArray obj, File f) { - for (int i = 0; i < obj.length(); i++) { + for(int i = 0; i < obj.length(); i++) { Object o = obj.get(i); - if (o instanceof JSONObject) { + if(o instanceof JSONObject) { fixBlocks((JSONObject) o, f); - } else if (o instanceof JSONArray) { + } else if(o instanceof JSONArray) { fixBlocks((JSONArray) o, f); } } @@ -143,11 +143,11 @@ public class IrisProject { public KList collectFiles(File f, String fileExtension) { KList l = new KList<>(); - if (f.isDirectory()) { - for (File i : f.listFiles()) { + if(f.isDirectory()) { + for(File i : f.listFiles()) { l.addAll(collectFiles(i, fileExtension)); } - } else if (f.getName().endsWith("." + fileExtension)) { + } else if(f.getName().endsWith("." + fileExtension)) { l.add(f); } @@ -170,28 +170,28 @@ public class IrisProject { J.attemptAsync(() -> { try { - if (d.getLoader() == null) { + if(d.getLoader() == null) { sender.sendMessage("Could not get dimension loader"); return; } File f = d.getLoader().getDataFolder(); - if (!doOpenVSCode(f)) { + if(!doOpenVSCode(f)) { File ff = new File(d.getLoader().getDataFolder(), d.getLoadKey() + ".code-workspace"); Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace."); try { IO.writeAll(ff, createCodeWorkspaceConfig()); - } catch (IOException e1) { + } catch(IOException e1) { Iris.reportError(e1); e1.printStackTrace(); } updateWorkspace(); - if (!doOpenVSCode(f)) { + if(!doOpenVSCode(f)) { Iris.warn("Tried creating code workspace but failed a second time. Your project is likely corrupt."); } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -200,16 +200,16 @@ public class IrisProject { private boolean doOpenVSCode(File f) throws IOException { boolean foundWork = false; - for (File i : Objects.requireNonNull(f.listFiles())) { - if (i.getName().endsWith(".code-workspace")) { + for(File i : Objects.requireNonNull(f.listFiles())) { + if(i.getName().endsWith(".code-workspace")) { foundWork = true; J.a(() -> { updateWorkspace(); }); - if (IrisSettings.get().getStudio().isOpenVSCode()) { - if (!GraphicsEnvironment.isHeadless()) { + if(IrisSettings.get().getStudio().isOpenVSCode()) { + if(!GraphicsEnvironment.isHeadless()) { Iris.msg("Opening VSCode. You may see the output from VSCode."); Iris.msg("VSCode output always starts with: '(node:#####) electron'"); Desktop.getDesktop().open(i); @@ -223,21 +223,21 @@ public class IrisProject { } public void open(VolmitSender sender, long seed, Consumer onDone) throws IrisException { - if (isOpen()) { + if(isOpen()) { close(); } boolean hasError = false; - if (hasError) { + if(hasError) { return; } IrisDimension d = IrisData.loadAnyDimension(getName()); - if (d == null) { + if(d == null) { sender.sendMessage("Can't find dimension: " + getName()); return; - } else if (sender.isPlayer()) { + } else if(sender.isPlayer()) { sender.player().setGameMode(GameMode.SPECTATOR); } @@ -247,14 +247,14 @@ public class IrisProject { J.a(() -> { try { activeProvider = (PlatformChunkGenerator) IrisToolbelt.createWorld() - .seed(seed) - .sender(sender) - .studio(true) - .name("iris/" + UUID.randomUUID()) - .dimension(d.getLoadKey()) - .create().getGenerator(); + .seed(seed) + .sender(sender) + .studio(true) + .name("iris/" + UUID.randomUUID()) + .dimension(d.getLoadKey()) + .create().getGenerator(); onDone.accept(activeProvider.getTarget().getWorld().realWorld()); - } catch (IrisException e) { + } catch(IrisException e) { e.printStackTrace(); } }); @@ -286,13 +286,13 @@ public class IrisProject { IO.writeAll(ws, j.toString(4)); p.end(); return true; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Project invalid: " + ws.getAbsolutePath() + " Re-creating. You may loose some vs-code workspace settings! But not your actual project!"); ws.delete(); try { IO.writeAll(ws, createCodeWorkspaceConfig()); - } catch (IOException e1) { + } catch(IOException e1) { Iris.reportError(e1); e1.printStackTrace(); } @@ -334,19 +334,19 @@ public class IrisProject { JSONArray schemas = new JSONArray(); IrisData dm = IrisData.get(getPath()); - for (ResourceLoader r : dm.getLoaders().v()) { - if (r.supportsSchemas()) { + for(ResourceLoader r : dm.getLoaders().v()) { + if(r.supportsSchemas()) { schemas.put(r.buildSchema()); } } - for (Class i : Iris.getClasses("com.volmit.iris.engine.object.", Snippet.class)) { + for(Class i : Iris.getClasses("com.volmit.iris.engine.object.", Snippet.class)) { try { String snipType = i.getDeclaredAnnotation(Snippet.class).value(); JSONObject o = new JSONObject(); KList fm = new KList<>(); - for (int g = 1; g < 8; g++) { + for(int g = 1; g < 8; g++) { fm.add("/snippet/" + snipType + Form.repeat("/*", g) + ".json"); } @@ -357,11 +357,11 @@ public class IrisProject { J.attemptAsync(() -> { try { IO.writeAll(a, new SchemaBuilder(i, dm).construct().toString(4)); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } }); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -387,7 +387,7 @@ public class IrisProject { KSet loot = new KSet<>(); KSet blocks = new KSet<>(); - for (String i : dm.getDimensionLoader().getPossibleKeys()) { + for(String i : dm.getDimensionLoader().getPossibleKeys()) { blocks.add(dm.getBlockLoader().load(i)); } @@ -407,13 +407,13 @@ public class IrisProject { StringBuilder c = new StringBuilder(); sender.sendMessage("Serializing Objects"); - for (IrisBiome i : biomes) { - for (IrisObjectPlacement j : i.getObjects()) { + for(IrisBiome i : biomes) { + for(IrisObjectPlacement j : i.getObjects()) { b.append(j.hashCode()); KList newNames = new KList<>(); - for (String k : j.getPlace()) { - if (renameObjects.containsKey(k)) { + for(String k : j.getPlace()) { + if(renameObjects.containsKey(k)) { newNames.add(renameObjects.get(k)); continue; } @@ -441,12 +441,12 @@ public class IrisProject { gb.append(IO.hash(f)); ggg.set(ggg.get() + 1); - if (cl.flip()) { + if(cl.flip()) { int g = ggg.get(); ggg.set(0); sender.sendMessage("Wrote another " + g + " Objects"); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } }))); @@ -462,7 +462,7 @@ public class IrisProject { IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a); b.append(IO.hash(a)); - for (IrisGenerator i : generators) { + for(IrisGenerator i : generators) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); IO.writeAll(new File(folder, "generators/" + i.getLoadKey() + ".json"), a); b.append(IO.hash(a)); @@ -471,31 +471,31 @@ public class IrisProject { c.append(IO.hash(b.toString())); b = new StringBuilder(); - for (IrisRegion i : regions) { + for(IrisRegion i : regions) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a); b.append(IO.hash(a)); } - for (IrisBlockData i : blocks) { + for(IrisBlockData i : blocks) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); IO.writeAll(new File(folder, "blocks/" + i.getLoadKey() + ".json"), a); b.append(IO.hash(a)); } - for (IrisBiome i : biomes) { + for(IrisBiome i : biomes) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a); b.append(IO.hash(a)); } - for (IrisEntity i : entities) { + for(IrisEntity i : entities) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), a); b.append(IO.hash(a)); } - for (IrisLootTable i : loot) { + for(IrisLootTable i : loot) { a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4); IO.writeAll(new File(folder, "loot/" + i.getLoadKey() + ".json"), a); b.append(IO.hash(a)); @@ -515,7 +515,7 @@ public class IrisProject { sender.sendMessage("Package Compiled!"); return p; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -538,18 +538,18 @@ public class IrisProject { IrisObject o = new IrisObject(0, 0, 0); o.read(f); - if (o.getBlocks().isEmpty()) { + if(o.getBlocks().isEmpty()) { sender.sendMessageRaw("" + f.getPath() + - "'>- IOB " + f.getName() + " has 0 blocks!"); + "" + f.getPath() + + "'>- IOB " + f.getName() + " has 0 blocks!"); } - if (o.getW() == 0 || o.getH() == 0 || o.getD() == 0) { + if(o.getW() == 0 || o.getH() == 0 || o.getD() == 0) { sender.sendMessageRaw("" + f.getPath() + "\nThe width height or depth has a zero in it (bad format)" + - "'>- IOB " + f.getName() + " is not 3D!"); + "" + f.getPath() + "\nThe width height or depth has a zero in it (bad format)" + + "'>- IOB " + f.getName() + " is not 3D!"); } - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } } @@ -569,11 +569,11 @@ public class IrisProject { scanForErrors(data, f, p, sender); IO.writeAll(f, p.toString(4)); - } catch (Throwable e) { + } catch(Throwable e) { sender.sendMessageRaw("" + f.getPath() + - "\n" + e.getMessage() + - "'>- JSON Error " + f.getName()); + "" + f.getPath() + + "\n" + e.getMessage() + + "'>- JSON Error " + f.getName()); } } @@ -590,7 +590,7 @@ public class IrisProject { String key = data.toLoadKey(f); ResourceLoader loader = data.getTypedLoaderFor(f); - if (loader == null) { + if(loader == null) { sender.sendMessageBasic("Can't find loader for " + f.getPath()); return; } @@ -603,62 +603,62 @@ public class IrisProject { public void compare(Class c, JSONObject j, VolmitSender sender, KList path) { try { Object o = c.getClass().getConstructor().newInstance(); - } catch (Throwable e) { + } catch(Throwable e) { } } public void files(File clean, KList files) { - if (clean.isDirectory()) { - for (File i : clean.listFiles()) { + if(clean.isDirectory()) { + for(File i : clean.listFiles()) { files(i, files); } - } else if (clean.getName().endsWith(".json")) { + } else if(clean.getName().endsWith(".json")) { try { files.add(clean); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } } public void filesObjects(File clean, KList files) { - if (clean.isDirectory()) { - for (File i : clean.listFiles()) { + if(clean.isDirectory()) { + for(File i : clean.listFiles()) { filesObjects(i, files); } - } else if (clean.getName().endsWith(".iob")) { + } else if(clean.getName().endsWith(".iob")) { try { files.add(clean); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } } private void fixBlocks(JSONObject obj) { - for (String i : obj.keySet()) { + for(String i : obj.keySet()) { Object o = obj.get(i); - if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { + if(i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { obj.put(i, "minecraft:" + o); } - if (o instanceof JSONObject) { + if(o instanceof JSONObject) { fixBlocks((JSONObject) o); - } else if (o instanceof JSONArray) { + } else if(o instanceof JSONArray) { fixBlocks((JSONArray) o); } } } private void fixBlocks(JSONArray obj) { - for (int i = 0; i < obj.length(); i++) { + for(int i = 0; i < obj.length(); i++) { Object o = obj.get(i); - if (o instanceof JSONObject) { + if(o instanceof JSONObject) { fixBlocks((JSONObject) o); - } else if (o instanceof JSONArray) { + } else if(o instanceof JSONArray) { fixBlocks((JSONArray) o); } } diff --git a/src/main/java/com/volmit/iris/core/project/SchemaBuilder.java b/src/main/java/com/volmit/iris/core/project/SchemaBuilder.java index c5aaca024..65cd6c735 100644 --- a/src/main/java/com/volmit/iris/core/project/SchemaBuilder.java +++ b/src/main/java/com/volmit/iris/core/project/SchemaBuilder.java @@ -70,7 +70,7 @@ public class SchemaBuilder { private static JSONArray getEnchantmentTypes() { JSONArray a = new JSONArray(); - for (Field gg : Enchantment.class.getDeclaredFields()) { + for(Field gg : Enchantment.class.getDeclaredFields()) { a.put(gg.getName()); } @@ -80,7 +80,7 @@ public class SchemaBuilder { private static JSONArray getPotionTypes() { JSONArray a = new JSONArray(); - for (PotionEffectType gg : PotionEffectType.values()) { + for(PotionEffectType gg : PotionEffectType.values()) { a.put(gg.getName().toUpperCase().replaceAll("\\Q \\E", "_")); } @@ -94,21 +94,21 @@ public class SchemaBuilder { JSONObject props = buildProperties(root); - for (String i : props.keySet()) { - if (!schema.has(i)) { + for(String i : props.keySet()) { + if(!schema.has(i)) { schema.put(i, props.get(i)); } } JSONObject defs = new JSONObject(); - for (Map.Entry entry : definitions.entrySet()) { + for(Map.Entry entry : definitions.entrySet()) { defs.put(entry.getKey(), entry.getValue()); } schema.put("definitions", defs); - for (String i : warnings) { + for(String i : warnings) { Iris.warn(root.getSimpleName() + ": " + i); } @@ -122,17 +122,17 @@ public class SchemaBuilder { o.put("type", getType(c)); JSONArray required = new JSONArray(); - if (c.isAssignableFrom(IrisRegistrant.class) || IrisRegistrant.class.isAssignableFrom(c)) { - for (Field k : IrisRegistrant.class.getDeclaredFields()) { + if(c.isAssignableFrom(IrisRegistrant.class) || IrisRegistrant.class.isAssignableFrom(c)) { + for(Field k : IrisRegistrant.class.getDeclaredFields()) { k.setAccessible(true); - if (Modifier.isStatic(k.getModifiers()) || Modifier.isFinal(k.getModifiers()) || Modifier.isTransient(k.getModifiers())) { + if(Modifier.isStatic(k.getModifiers()) || Modifier.isFinal(k.getModifiers()) || Modifier.isTransient(k.getModifiers())) { continue; } JSONObject property = buildProperty(k, c); - if (property.getBoolean("!required")) { + if(property.getBoolean("!required")) { required.put(k.getName()); } @@ -141,10 +141,10 @@ public class SchemaBuilder { } } - for (Field k : c.getDeclaredFields()) { + for(Field k : c.getDeclaredFields()) { k.setAccessible(true); - if (Modifier.isStatic(k.getModifiers()) || Modifier.isFinal(k.getModifiers()) || Modifier.isTransient(k.getModifiers())) { + if(Modifier.isStatic(k.getModifiers()) || Modifier.isFinal(k.getModifiers()) || Modifier.isTransient(k.getModifiers())) { continue; } @@ -154,14 +154,14 @@ public class SchemaBuilder { properties.put(k.getName(), property); } - if (required.length() > 0) { + if(required.length() > 0) { o.put("required", required); } o.put("properties", properties); - if (c.isAnnotationPresent(Snippet.class)) { + if(c.isAnnotationPresent(Snippet.class)) { JSONObject anyOf = new JSONObject(); JSONArray arr = new JSONArray(); JSONObject str = new JSONObject(); @@ -184,16 +184,16 @@ public class SchemaBuilder { prop.put("type", type); String fancyType = "Unknown Type"; - switch (type) { + switch(type) { case "boolean" -> fancyType = "Boolean"; case "integer" -> { fancyType = "Integer"; - if (k.isAnnotationPresent(MinNumber.class)) { + if(k.isAnnotationPresent(MinNumber.class)) { int min = (int) k.getDeclaredAnnotation(MinNumber.class).value(); prop.put("minimum", min); description.add(SYMBOL_LIMIT__N + " Minimum allowed is " + min); } - if (k.isAnnotationPresent(MaxNumber.class)) { + if(k.isAnnotationPresent(MaxNumber.class)) { int max = (int) k.getDeclaredAnnotation(MaxNumber.class).value(); prop.put("maximum", max); description.add(SYMBOL_LIMIT__N + " Maximum allowed is " + max); @@ -201,12 +201,12 @@ public class SchemaBuilder { } case "number" -> { fancyType = "Number"; - if (k.isAnnotationPresent(MinNumber.class)) { + if(k.isAnnotationPresent(MinNumber.class)) { double min = k.getDeclaredAnnotation(MinNumber.class).value(); prop.put("minimum", min); description.add(SYMBOL_LIMIT__N + " Minimum allowed is " + min); } - if (k.isAnnotationPresent(MaxNumber.class)) { + if(k.isAnnotationPresent(MaxNumber.class)) { double max = k.getDeclaredAnnotation(MaxNumber.class).value(); prop.put("maximum", max); description.add(SYMBOL_LIMIT__N + " Maximum allowed is " + max); @@ -214,26 +214,26 @@ public class SchemaBuilder { } case "string" -> { fancyType = "Text"; - if (k.isAnnotationPresent(MinNumber.class)) { + if(k.isAnnotationPresent(MinNumber.class)) { int min = (int) k.getDeclaredAnnotation(MinNumber.class).value(); prop.put("minLength", min); description.add(SYMBOL_LIMIT__N + " Minimum Length allowed is " + min); } - if (k.isAnnotationPresent(MaxNumber.class)) { + if(k.isAnnotationPresent(MaxNumber.class)) { int max = (int) k.getDeclaredAnnotation(MaxNumber.class).value(); prop.put("maxLength", max); description.add(SYMBOL_LIMIT__N + " Maximum Length allowed is " + max); } - if (k.isAnnotationPresent(RegistryListResource.class)) { + if(k.isAnnotationPresent(RegistryListResource.class)) { RegistryListResource rr = k.getDeclaredAnnotation(RegistryListResource.class); ResourceLoader loader = data.getLoaders().get(rr.value()); - if (loader != null) { + if(loader != null) { String key = "erz" + loader.getFolderName(); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", new JSONArray(loader.getPossibleKeys())); definitions.put(key, j); @@ -245,18 +245,18 @@ public class SchemaBuilder { } else { Iris.error("Cannot find Registry Loader for type " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName()); } - } else if (k.isAnnotationPresent(RegistryListBlockType.class)) { + } else if(k.isAnnotationPresent(RegistryListBlockType.class)) { String key = "enum-block-type"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); JSONArray ja = new JSONArray(); - for (String i : data.getBlockLoader().getPossibleKeys()) { + for(String i : data.getBlockLoader().getPossibleKeys()) { ja.put(i); } - for (String i : B.getBlockTypes()) { + for(String i : B.getBlockTypes()) { ja.put(i); } @@ -268,10 +268,10 @@ public class SchemaBuilder { prop.put("$ref", "#/definitions/" + key); description.add(SYMBOL_TYPE__N + " Must be a valid Block Type (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListItemType.class)) { + } else if(k.isAnnotationPresent(RegistryListItemType.class)) { String key = "enum-item-type"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", ITEM_TYPES); definitions.put(key, j); @@ -281,10 +281,10 @@ public class SchemaBuilder { prop.put("$ref", "#/definitions/" + key); description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListSpecialEntity.class)) { + } else if(k.isAnnotationPresent(RegistryListSpecialEntity.class)) { String key = "enum-reg-specialentity"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); KList list = new KList<>(); list.addAll(Iris.linkMythicMobs.getMythicMobTypes().stream().map(s -> "MythicMobs:" + s).collect(Collectors.toList())); @@ -296,10 +296,10 @@ public class SchemaBuilder { fancyType = "Mythic Mob Type"; prop.put("$ref", "#/definitions/" + key); description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Define mythic mobs with the mythic mobs plugin configuration files."); - } else if (k.isAnnotationPresent(RegistryListFont.class)) { + } else if(k.isAnnotationPresent(RegistryListFont.class)) { String key = "enum-font"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", FONT_TYPES); definitions.put(key, j); @@ -309,10 +309,10 @@ public class SchemaBuilder { prop.put("$ref", "#/definitions/" + key); description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); - } else if (k.getType().equals(Enchantment.class)) { + } else if(k.getType().equals(Enchantment.class)) { String key = "enum-enchantment"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", ENCHANT_TYPES); definitions.put(key, j); @@ -321,10 +321,10 @@ public class SchemaBuilder { fancyType = "Enchantment Type"; prop.put("$ref", "#/definitions/" + key); description.add(SYMBOL_TYPE__N + " Must be a valid Enchantment Type (use ctrl+space for auto complete!)"); - } else if (k.getType().equals(PotionEffectType.class)) { + } else if(k.getType().equals(PotionEffectType.class)) { String key = "enum-potion-effect-type"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", POTION_TYPES); definitions.put(key, j); @@ -334,12 +334,12 @@ public class SchemaBuilder { prop.put("$ref", "#/definitions/" + key); description.add(SYMBOL_TYPE__N + " Must be a valid Potion Effect Type (use ctrl+space for auto complete!)"); - } else if (k.getType().isEnum()) { + } else if(k.getType().isEnum()) { fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", ""); JSONArray a = new JSONArray(); boolean advanced = k.getType().isAnnotationPresent(Desc.class); - for (Object gg : k.getType().getEnumConstants()) { - if (advanced) { + for(Object gg : k.getType().getEnumConstants()) { + if(advanced) { try { JSONObject j = new JSONObject(); String name = ((Enum) gg).name(); @@ -347,7 +347,7 @@ public class SchemaBuilder { Desc dd = k.getType().getField(name).getAnnotation(Desc.class); j.put("description", dd == null ? ("No Description for " + name) : dd.value()); a.put(j); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -358,7 +358,7 @@ public class SchemaBuilder { String key = (advanced ? "oneof-" : "") + "enum-" + k.getType().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put(advanced ? "oneOf" : "enum", a); definitions.put(key, j); @@ -372,7 +372,7 @@ public class SchemaBuilder { case "object" -> { fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", "") + " (Object)"; String key = "obj-" + k.getType().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { definitions.put(key, new JSONObject()); definitions.put(key, buildProperties(k.getType())); } @@ -381,10 +381,10 @@ public class SchemaBuilder { case "array" -> { fancyType = "List of Something...?"; ArrayType t = k.getDeclaredAnnotation(ArrayType.class); - if (t != null) { - if (t.min() > 0) { + if(t != null) { + if(t.min() > 0) { prop.put("minItems", t.min()); - if (t.min() == 1) { + if(t.min() == 1) { description.add(SYMBOL_LIMIT__N + " At least one entry must be defined, or just remove this list."); } else { description.add(SYMBOL_LIMIT__N + " Requires at least " + t.min() + " entries."); @@ -393,13 +393,13 @@ public class SchemaBuilder { String arrayType = getType(t.type()); - switch (arrayType) { + switch(arrayType) { case "integer" -> fancyType = "List of Integers"; case "number" -> fancyType = "List of Numbers"; case "object" -> { fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s (Objects)"; String key = "obj-" + t.type().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { definitions.put(key, new JSONObject()); definitions.put(key, buildProperties(t.type())); } @@ -410,15 +410,15 @@ public class SchemaBuilder { case "string" -> { fancyType = "List of Text"; - if (k.isAnnotationPresent(RegistryListResource.class)) { + if(k.isAnnotationPresent(RegistryListResource.class)) { RegistryListResource rr = k.getDeclaredAnnotation(RegistryListResource.class); ResourceLoader loader = data.getLoaders().get(rr.value()); - if (loader != null) { + if(loader != null) { fancyType = "List<" + loader.getResourceTypeName() + ">"; String key = "erz" + loader.getFolderName(); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", new JSONArray(loader.getPossibleKeys())); definitions.put(key, j); @@ -431,19 +431,19 @@ public class SchemaBuilder { } else { Iris.error("Cannot find Registry Loader for type (list schema) " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName()); } - } else if (k.isAnnotationPresent(RegistryListBlockType.class)) { + } else if(k.isAnnotationPresent(RegistryListBlockType.class)) { fancyType = "List of Block Types"; String key = "enum-block-type"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); JSONArray ja = new JSONArray(); - for (String i : data.getBlockLoader().getPossibleKeys()) { + for(String i : data.getBlockLoader().getPossibleKeys()) { ja.put(i); } - for (String i : B.getBlockTypes()) { + for(String i : B.getBlockTypes()) { ja.put(i); } @@ -455,11 +455,11 @@ public class SchemaBuilder { items.put("$ref", "#/definitions/" + key); prop.put("items", items); description.add(SYMBOL_TYPE__N + " Must be a valid Block Type (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListItemType.class)) { + } else if(k.isAnnotationPresent(RegistryListItemType.class)) { fancyType = "List of Item Types"; String key = "enum-item-type"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", ITEM_TYPES); definitions.put(key, j); @@ -469,11 +469,11 @@ public class SchemaBuilder { items.put("$ref", "#/definitions/" + key); prop.put("items", items); description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListFont.class)) { + } else if(k.isAnnotationPresent(RegistryListFont.class)) { String key = "enum-font"; fancyType = "List of Font Families"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", FONT_TYPES); definitions.put(key, j); @@ -483,11 +483,11 @@ public class SchemaBuilder { items.put("$ref", "#/definitions/" + key); prop.put("items", items); description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); - } else if (t.type().equals(Enchantment.class)) { + } else if(t.type().equals(Enchantment.class)) { fancyType = "List of Enchantment Types"; String key = "enum-enchantment"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", ENCHANT_TYPES); definitions.put(key, j); @@ -497,11 +497,11 @@ public class SchemaBuilder { items.put("$ref", "#/definitions/" + key); prop.put("items", items); description.add(SYMBOL_TYPE__N + " Must be a valid Enchantment Type (use ctrl+space for auto complete!)"); - } else if (t.type().equals(PotionEffectType.class)) { + } else if(t.type().equals(PotionEffectType.class)) { fancyType = "List of Potion Effect Types"; String key = "enum-potion-effect-type"; - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put("enum", POTION_TYPES); definitions.put(key, j); @@ -511,12 +511,12 @@ public class SchemaBuilder { items.put("$ref", "#/definitions/" + key); prop.put("items", items); description.add(SYMBOL_TYPE__N + " Must be a valid Potion Effect Type (use ctrl+space for auto complete!)"); - } else if (t.type().isEnum()) { + } else if(t.type().isEnum()) { fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s"; JSONArray a = new JSONArray(); boolean advanced = t.type().isAnnotationPresent(Desc.class); - for (Object gg : t.type().getEnumConstants()) { - if (advanced) { + for(Object gg : t.type().getEnumConstants()) { + if(advanced) { try { JSONObject j = new JSONObject(); String name = ((Enum) gg).name(); @@ -524,7 +524,7 @@ public class SchemaBuilder { Desc dd = t.type().getField(name).getAnnotation(Desc.class); j.put("description", dd == null ? ("No Description for " + name) : dd.value()); a.put(j); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -535,7 +535,7 @@ public class SchemaBuilder { String key = (advanced ? "oneof-" : "") + "enum-" + t.type().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); j.put(advanced ? "oneOf" : "enum", a); definitions.put(key, j); @@ -562,7 +562,7 @@ public class SchemaBuilder { d.add(fancyType); d.add(getDescription(k.getType())); - if (k.getType().isAnnotationPresent(Snippet.class)) { + if(k.getType().isAnnotationPresent(Snippet.class)) { String sm = k.getType().getDeclaredAnnotation(Snippet.class).value(); d.add(" "); d.add("You can instead specify \"snippet/" + sm + "/some-name.json\" to use a snippet file instead of specifying it here."); @@ -572,11 +572,11 @@ public class SchemaBuilder { k.setAccessible(true); Object value = k.get(cl.newInstance()); - if (value != null) { - if (value instanceof List) { + if(value != null) { + if(value instanceof List) { d.add(" "); d.add("* Default Value is an empty list"); - } else if (!cl.isPrimitive() && !(value instanceof Number) && !(value instanceof String) && !(cl.isEnum())) { + } else if(!cl.isPrimitive() && !(value instanceof Number) && !(value instanceof String) && !(cl.isEnum())) { d.add(" "); d.add("* Default Value is a default object (create this object to see default properties)"); } else { @@ -584,7 +584,7 @@ public class SchemaBuilder { d.add("* Default Value is " + value); } } - } catch (Throwable ignored) { + } catch(Throwable ignored) { } @@ -592,7 +592,7 @@ public class SchemaBuilder { prop.put("type", type); prop.put("description", d.toString("\n")); - if (k.getType().isAnnotationPresent(Snippet.class)) { + if(k.getType().isAnnotationPresent(Snippet.class)) { JSONObject anyOf = new JSONObject(); JSONArray arr = new JSONArray(); JSONObject str = new JSONObject(); @@ -600,7 +600,7 @@ public class SchemaBuilder { String key = "enum-snippet-" + k.getType().getDeclaredAnnotation(Snippet.class).value(); str.put("$ref", "#/definitions/" + key); - if (!definitions.containsKey(key)) { + if(!definitions.containsKey(key)) { JSONObject j = new JSONObject(); JSONArray snl = new JSONArray(); data.getPossibleSnippets(k.getType().getDeclaredAnnotation(Snippet.class).value()).forEach(snl::put); @@ -623,31 +623,31 @@ public class SchemaBuilder { } private String getType(Class c) { - if (c.equals(int.class) || c.equals(Integer.class) || c.equals(long.class) || c.equals(Long.class)) { + if(c.equals(int.class) || c.equals(Integer.class) || c.equals(long.class) || c.equals(Long.class)) { return "integer"; } - if (c.equals(float.class) || c.equals(double.class) || c.equals(Float.class) || c.equals(Double.class)) { + if(c.equals(float.class) || c.equals(double.class) || c.equals(Float.class) || c.equals(Double.class)) { return "number"; } - if (c.equals(boolean.class) || c.equals(Boolean.class)) { + if(c.equals(boolean.class) || c.equals(Boolean.class)) { return "boolean"; } - if (c.equals(String.class) || c.isEnum() || c.equals(Enchantment.class) || c.equals(PotionEffectType.class)) { + if(c.equals(String.class) || c.isEnum() || c.equals(Enchantment.class) || c.equals(PotionEffectType.class)) { return "string"; } - if (c.equals(KList.class)) { + if(c.equals(KList.class)) { return "array"; } - if (c.equals(KMap.class)) { + if(c.equals(KMap.class)) { return "object"; } - if (!c.isAnnotationPresent(Desc.class) && c.getCanonicalName().startsWith("com.volmit.iris.")) { + if(!c.isAnnotationPresent(Desc.class) && c.getCanonicalName().startsWith("com.volmit.iris.")) { warnings.addIfMissing("Unsupported Type: " + c.getCanonicalName() + " Did you forget @Desc?"); } @@ -656,12 +656,12 @@ public class SchemaBuilder { private String getFieldDescription(Field r) { - if (r.isAnnotationPresent(Desc.class)) { + if(r.isAnnotationPresent(Desc.class)) { return r.getDeclaredAnnotation(Desc.class).value(); } // suppress warnings on bukkit classes - if (r.getDeclaringClass().getName().startsWith("org.bukkit.")) { + if(r.getDeclaringClass().getName().startsWith("org.bukkit.")) { return "Bukkit package classes and enums have no descriptions"; } @@ -670,11 +670,11 @@ public class SchemaBuilder { } private String getDescription(Class r) { - if (r.isAnnotationPresent(Desc.class)) { + if(r.isAnnotationPresent(Desc.class)) { return r.getDeclaredAnnotation(Desc.class).value(); } - if (!r.isPrimitive() && !r.equals(KList.class) && !r.equals(KMap.class) && r.getCanonicalName().startsWith("com.volmit.")) { + if(!r.isPrimitive() && !r.equals(KList.class) && !r.equals(KMap.class) && r.getCanonicalName().startsWith("com.volmit.")) { warnings.addIfMissing("Missing @Desc on " + r.getSimpleName() + " in " + (r.getDeclaringClass() != null ? r.getDeclaringClass().getCanonicalName() : " NOSRC")); } return ""; diff --git a/src/main/java/com/volmit/iris/core/service/BoardSVC.java b/src/main/java/com/volmit/iris/core/service/BoardSVC.java index 11403c56d..72c020479 100644 --- a/src/main/java/com/volmit/iris/core/service/BoardSVC.java +++ b/src/main/java/com/volmit/iris/core/service/BoardSVC.java @@ -19,9 +19,7 @@ package com.volmit.iris.core.service; import com.volmit.iris.Iris; -import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.loader.IrisData; -import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.util.board.BoardManager; @@ -50,9 +48,9 @@ public class BoardSVC implements IrisService, BoardProvider { public void onEnable() { J.ar(this::tick, 20); manager = new BoardManager(Iris.instance, BoardSettings.builder() - .boardProvider(this) - .scoreDirection(ScoreDirection.DOWN) - .build()); + .boardProvider(this) + .scoreDirection(ScoreDirection.DOWN) + .build()); } @Override @@ -72,7 +70,7 @@ public class BoardSVC implements IrisService, BoardProvider { } public void updatePlayer(Player p) { - if (IrisToolbelt.isIrisStudioWorld(p.getWorld())) { + if(IrisToolbelt.isIrisStudioWorld(p.getWorld())) { manager.remove(p); manager.setup(p); } else { @@ -87,8 +85,7 @@ public class BoardSVC implements IrisService, BoardProvider { } public void tick() { - if(!Iris.service(StudioSVC.class).isProjectOpen()) - { + if(!Iris.service(StudioSVC.class).isProjectOpen()) { return; } @@ -98,7 +95,7 @@ public class BoardSVC implements IrisService, BoardProvider { @Override public List getLines(Player player) { PlayerBoard pb = boards.computeIfAbsent(player, PlayerBoard::new); - synchronized (pb.lines) { + synchronized(pb.lines) { return pb.lines; } } @@ -115,10 +112,10 @@ public class BoardSVC implements IrisService, BoardProvider { } public void update() { - synchronized (lines) { + synchronized(lines) { lines.clear(); - if (!IrisToolbelt.isIrisStudioWorld(player.getWorld())) { + if(!IrisToolbelt.isIrisStudioWorld(player.getWorld())) { return; } diff --git a/src/main/java/com/volmit/iris/core/service/CommandSVC.java b/src/main/java/com/volmit/iris/core/service/CommandSVC.java index 371fa3379..15a240de7 100644 --- a/src/main/java/com/volmit/iris/core/service/CommandSVC.java +++ b/src/main/java/com/volmit/iris/core/service/CommandSVC.java @@ -56,18 +56,18 @@ public class CommandSVC implements IrisService, DecreeSystem { public void on(PlayerCommandPreprocessEvent e) { String msg = e.getMessage().startsWith("/") ? e.getMessage().substring(1) : e.getMessage(); - if (msg.startsWith("irisdecree ")) { + if(msg.startsWith("irisdecree ")) { String[] args = msg.split("\\Q \\E"); CompletableFuture future = futures.get(args[1]); - if (future != null) { + if(future != null) { future.complete(args[2]); e.setCancelled(true); return; } } - if ((msg.startsWith("locate ") || msg.startsWith("locatebiome ")) && IrisToolbelt.isIrisWorld(e.getPlayer().getWorld())) { + if((msg.startsWith("locate ") || msg.startsWith("locatebiome ")) && IrisToolbelt.isIrisWorld(e.getPlayer().getWorld())) { new VolmitSender(e.getPlayer()).sendMessage(C.RED + "Locating biomes & objects is disabled in Iris Worlds. Use /iris studio goto "); e.setCancelled(true); } @@ -75,8 +75,8 @@ public class CommandSVC implements IrisService, DecreeSystem { @EventHandler public void on(ServerCommandEvent e) { - if (consoleFuture != null && !consoleFuture.isCancelled() && !consoleFuture.isDone()) { - if (!e.getCommand().contains(" ")) { + if(consoleFuture != null && !consoleFuture.isCancelled() && !consoleFuture.isDone()) { + if(!e.getCommand().contains(" ")) { String pick = e.getCommand().trim().toLowerCase(Locale.ROOT); consoleFuture.complete(pick); e.setCancelled(true); diff --git a/src/main/java/com/volmit/iris/core/service/ConversionSVC.java b/src/main/java/com/volmit/iris/core/service/ConversionSVC.java index ac58a918d..dd777788f 100644 --- a/src/main/java/com/volmit/iris/core/service/ConversionSVC.java +++ b/src/main/java/com/volmit/iris/core/service/ConversionSVC.java @@ -60,10 +60,10 @@ public class ConversionSVC implements IrisService { converters = new KList<>(); J.s(() -> - J.attemptAsync(() -> - { + J.attemptAsync(() -> + { - }), 5); + }), 5); } @Override @@ -84,13 +84,13 @@ public class ConversionSVC implements IrisService { destPools.mkdirs(); findAllNBT(in, (folder, file) -> { total.getAndIncrement(); - if (roots.addIfMissing(folder)) { + if(roots.addIfMissing(folder)) { String b = in.toURI().relativize(folder.toURI()).getPath(); - if (b.startsWith("/")) { + if(b.startsWith("/")) { b = b.substring(1); } - if (b.endsWith("/")) { + if(b.endsWith("/")) { b = b.substring(0, b.length() - 1); } @@ -100,11 +100,11 @@ public class ConversionSVC implements IrisService { findAllNBT(in, (folder, file) -> { at.getAndIncrement(); String b = in.toURI().relativize(folder.toURI()).getPath(); - if (b.startsWith("/")) { + if(b.startsWith("/")) { b = b.substring(1); } - if (b.endsWith("/")) { + if(b.endsWith("/")) { b = b.substring(0, b.length() - 1); } IrisJigsawPool jpool = pools.get(b); @@ -117,7 +117,7 @@ public class ConversionSVC implements IrisService { NamedTag tag = NBTUtil.read(file); CompoundTag compound = (CompoundTag) tag.getTag(); - if (compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size")) { + if(compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size")) { String id = in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]; @SuppressWarnings("unchecked") ListTag size = (ListTag) compound.getListTag("size"); int w = size.get(0).asInt(); @@ -125,14 +125,14 @@ public class ConversionSVC implements IrisService { int d = size.get(2).asInt(); KList palette = new KList<>(); @SuppressWarnings("unchecked") ListTag paletteList = (ListTag) compound.getListTag("palette"); - for (int i = 0; i < paletteList.size(); i++) { + for(int i = 0; i < paletteList.size(); i++) { CompoundTag cp = paletteList.get(i); palette.add(NBTWorld.getBlockData(cp)); } IrisJigsawPiece piece = new IrisJigsawPiece(); IrisObject object = new IrisObject(w, h, d); @SuppressWarnings("unchecked") ListTag blockList = (ListTag) compound.getListTag("blocks"); - for (int i = 0; i < blockList.size(); i++) { + for(int i = 0; i < blockList.size(); i++) { CompoundTag cp = blockList.get(i); @SuppressWarnings("unchecked") ListTag pos = (ListTag) cp.getListTag("pos"); int x = pos.get(0).asInt(); @@ -140,7 +140,7 @@ public class ConversionSVC implements IrisService { int z = pos.get(2).asInt(); BlockData bd = palette.get(cp.getInt("state")).clone(); - if (bd.getMaterial().equals(Material.JIGSAW) && cp.containsKey("nbt")) { + if(bd.getMaterial().equals(Material.JIGSAW) && cp.containsKey("nbt")) { piece.setObject(in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]); IrisPosition spos = new IrisPosition(object.getSigned(x, y, z)); CompoundTag nbt = cp.getCompoundTag("nbt"); @@ -162,14 +162,14 @@ public class ConversionSVC implements IrisService { connector.getPools().add(poolId); connector.setDirection(IrisDirection.getDirection(((Jigsaw) jd).getOrientation())); - if (target.equals("minecraft:building_entrance")) { + if(target.equals("minecraft:building_entrance")) { connector.setInnerConnector(true); } piece.getConnectors().add(connector); } - if (!bd.getMaterial().equals(Material.STRUCTURE_VOID) && !bd.getMaterial().equals(Material.AIR)) { + if(!bd.getMaterial().equals(Material.STRUCTURE_VOID) && !bd.getMaterial().equals(Material.AIR)) { object.setUnsigned(x, y, z, bd); } } @@ -179,16 +179,16 @@ public class ConversionSVC implements IrisService { IO.writeAll(new File(destPieces, file.getName().split("\\Q.\\E")[0] + ".json"), new JSONObject(new Gson().toJson(piece)).toString(4)); Iris.info("[Jigsaw]: (" + Form.pc((double) at.get() / (double) total.get(), 0) + ") Exported Piece: " + id); } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } }); - for (String i : pools.k()) { + for(String i : pools.k()) { try { IO.writeAll(new File(destPools, i + ".json"), new JSONObject(new Gson().toJson(pools.get(i))).toString(4)); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); Iris.reportError(e); } @@ -198,19 +198,19 @@ public class ConversionSVC implements IrisService { } public void findAllNBT(File path, Consumer2 inFile) { - if (path == null) { + if(path == null) { return; } - if (path.isFile() && path.getName().endsWith(".nbt")) { + if(path.isFile() && path.getName().endsWith(".nbt")) { inFile.accept(path.getParentFile(), path); return; } - for (File i : path.listFiles()) { - if (i.isDirectory()) { + for(File i : path.listFiles()) { + if(i.isDirectory()) { findAllNBT(i, inFile); - } else if (i.isFile() && i.getName().endsWith(".nbt")) { + } else if(i.isFile() && i.getName().endsWith(".nbt")) { inFile.accept(path, i); } } @@ -220,9 +220,9 @@ public class ConversionSVC implements IrisService { int m = 0; Iris.instance.getDataFolder("convert"); - for (File i : folder.listFiles()) { - for (Converter j : converters) { - if (i.getName().endsWith("." + j.getInExtension())) { + for(File i : folder.listFiles()) { + for(Converter j : converters) { + if(i.getName().endsWith("." + j.getInExtension())) { File out = new File(folder, i.getName().replaceAll("\\Q." + j.getInExtension() + "\\E", "." + j.getOutExtension())); m++; j.convert(i, out); @@ -230,10 +230,10 @@ public class ConversionSVC implements IrisService { } } - if (i.isDirectory() && i.getName().equals("structures")) { + if(i.isDirectory() && i.getName().equals("structures")) { File f = new File(folder, "jigsaw"); - if (!f.exists()) { + if(!f.exists()) { s.sendMessage("Converting NBT Structures into Iris Jigsaw Structures..."); f.mkdirs(); J.a(() -> convertStructures(i, f, s)); diff --git a/src/main/java/com/volmit/iris/core/service/DolphinSVC.java b/src/main/java/com/volmit/iris/core/service/DolphinSVC.java index 0135673fa..312e88277 100644 --- a/src/main/java/com/volmit/iris/core/service/DolphinSVC.java +++ b/src/main/java/com/volmit/iris/core/service/DolphinSVC.java @@ -42,12 +42,12 @@ public class DolphinSVC implements IrisService { */ @EventHandler public void on(PlayerInteractEntityEvent event) { - if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) { + if(!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) { return; } Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType(); - if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) { + if(event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) { event.setCancelled(true); } } diff --git a/src/main/java/com/volmit/iris/core/service/EditSVC.java b/src/main/java/com/volmit/iris/core/service/EditSVC.java index 1012c7eea..909810a54 100644 --- a/src/main/java/com/volmit/iris/core/service/EditSVC.java +++ b/src/main/java/com/volmit/iris/core/service/EditSVC.java @@ -71,27 +71,27 @@ public class EditSVC implements IrisService { @EventHandler public void on(WorldUnloadEvent e) { - if (editors.containsKey(e.getWorld())) { + if(editors.containsKey(e.getWorld())) { editors.remove(e.getWorld()).close(); } } public void update() { - for (World i : editors.k()) { - if (M.ms() - editors.get(i).last() > 1000) { + for(World i : editors.k()) { + if(M.ms() - editors.get(i).last() > 1000) { editors.remove(i).close(); } } } public void flushNow() { - for (World i : editors.k()) { + for(World i : editors.k()) { editors.remove(i).close(); } } public BlockEditor open(World world) { - if (editors.containsKey(world)) { + if(editors.containsKey(world)) { return editors.get(world); } diff --git a/src/main/java/com/volmit/iris/core/service/ObjectSVC.java b/src/main/java/com/volmit/iris/core/service/ObjectSVC.java index 812a5f3bc..6853c6a26 100644 --- a/src/main/java/com/volmit/iris/core/service/ObjectSVC.java +++ b/src/main/java/com/volmit/iris/core/service/ObjectSVC.java @@ -54,9 +54,9 @@ public class ObjectSVC implements IrisService { } private void loopChange(int amount) { - if (undos.size() > 0) { + if(undos.size() > 0) { revert(undos.pollLast()); - if (amount > 1) { + if(amount > 1) { J.s(() -> loopChange(amount - 1), 2); } } @@ -65,12 +65,13 @@ public class ObjectSVC implements IrisService { /** * Reverts all the block changes provided, 200 blocks per tick * - * @param blocks The blocks to remove + * @param blocks + * The blocks to remove */ private void revert(Map blocks) { int amount = 0; Iterator> it = blocks.entrySet().iterator(); - while (it.hasNext()) { + while(it.hasNext()) { Map.Entry entry = it.next(); BlockData data = entry.getValue(); entry.getKey().setBlockData(data, false); @@ -78,7 +79,7 @@ public class ObjectSVC implements IrisService { amount++; - if (amount > 200) { + if(amount > 200) { J.s(() -> revert(blocks), 1); } } diff --git a/src/main/java/com/volmit/iris/core/service/PreservationSVC.java b/src/main/java/com/volmit/iris/core/service/PreservationSVC.java index b3081f7dc..3648db9fe 100644 --- a/src/main/java/com/volmit/iris/core/service/PreservationSVC.java +++ b/src/main/java/com/volmit/iris/core/service/PreservationSVC.java @@ -57,8 +57,8 @@ public class PreservationSVC implements IrisService { double p = 0; double mf = 0; - for (MeteredCache i : caches) { - if (i.isClosed()) { + for(MeteredCache i : caches) { + if(i.isClosed()) { continue; } @@ -100,22 +100,22 @@ public class PreservationSVC implements IrisService { dereference(); postShutdown(() -> { - for (Thread i : threads) { - if (i.isAlive()) { + for(Thread i : threads) { + if(i.isAlive()) { try { i.interrupt(); Iris.info("Shutdown Thread " + i.getName()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } } - for (ExecutorService i : services) { + for(ExecutorService i : services) { try { i.shutdownNow(); Iris.info("Shutdown Executor Service " + i); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } diff --git a/src/main/java/com/volmit/iris/core/service/StudioSVC.java b/src/main/java/com/volmit/iris/core/service/StudioSVC.java index 4614bb5f1..da209d80b 100644 --- a/src/main/java/com/volmit/iris/core/service/StudioSVC.java +++ b/src/main/java/com/volmit/iris/core/service/StudioSVC.java @@ -61,7 +61,7 @@ public class StudioSVC implements IrisService { String pack = IrisSettings.get().getGenerator().getDefaultWorldType(); File f = IrisPack.packsPack(pack); - if (!f.exists()) { + if(!f.exists()) { Iris.info("Downloading Default Pack " + pack); downloadSearch(Iris.getSender(), pack, false); } @@ -72,9 +72,9 @@ public class StudioSVC implements IrisService { public void onDisable() { Iris.debug("Studio Mode Active: Closing Projects"); - for (World i : Bukkit.getWorlds()) { - if (IrisToolbelt.isIrisWorld(i)) { - if (IrisToolbelt.isStudio(i)) { + for(World i : Bukkit.getWorlds()) { + if(IrisToolbelt.isIrisWorld(i)) { + if(IrisToolbelt.isStudio(i)) { IrisToolbelt.evacuate(i); IrisToolbelt.access(i).close(); } @@ -88,9 +88,9 @@ public class StudioSVC implements IrisService { File irispack = new File(folder, "iris/pack"); IrisDimension dim = IrisData.loadAnyDimension(type); - if (dim == null) { - for (File i : getWorkspaceFolder().listFiles()) { - if (i.isFile() && i.getName().equals(type + ".iris")) { + if(dim == null) { + for(File i : getWorkspaceFolder().listFiles()) { + if(i.isFile() && i.getName().equals(type + ".iris")) { sender.sendMessage("Found " + type + ".iris in " + WORKSPACE_NAME + " folder"); ZipUtil.unpack(i, irispack); break; @@ -102,29 +102,29 @@ public class StudioSVC implements IrisService { try { FileUtils.copyDirectory(f, irispack); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } } File dimf = new File(irispack, "dimensions/" + type + ".json"); - if (!dimf.exists() || !dimf.isFile()) { + if(!dimf.exists() || !dimf.isFile()) { downloadSearch(sender, type, false); File downloaded = getWorkspaceFolder(type); - for (File i : downloaded.listFiles()) { - if (i.isFile()) { + for(File i : downloaded.listFiles()) { + if(i.isFile()) { try { FileUtils.copyFile(i, new File(irispack, i.getName())); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); Iris.reportError(e); } } else { try { FileUtils.copyDirectory(i, new File(irispack, i.getName())); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); Iris.reportError(e); } @@ -134,7 +134,7 @@ public class StudioSVC implements IrisService { IO.delete(downloaded); } - if (!dimf.exists() || !dimf.isFile()) { + if(!dimf.exists() || !dimf.isFile()) { sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!"); return null; } @@ -142,7 +142,7 @@ public class StudioSVC implements IrisService { IrisData dm = IrisData.get(irispack); dim = dm.getDimensionLoader().load(type); - if (dim == null) { + if(dim == null) { sender.sendMessage("Can't load the dimension! Failed!"); return null; } @@ -161,7 +161,7 @@ public class StudioSVC implements IrisService { try { url = getListing(false).get(key); - if (url == null) { + if(url == null) { Iris.warn("ITS ULL for " + key); } @@ -172,7 +172,7 @@ public class StudioSVC implements IrisService { String repo = nodes.length == 1 ? "IrisDimensions/" + nodes[0] : nodes[0] + "/" + nodes[1]; branch = nodes.length > 2 ? nodes[2] : branch; download(sender, repo, branch, trim, forceOverwrite); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); sender.sendMessage("Failed to download '" + key + "' from " + url + "."); @@ -191,7 +191,7 @@ public class StudioSVC implements IrisService { File work = new File(temp, "dl-" + UUID.randomUUID()); File packs = getWorkspaceFolder(); - if (zip == null || !zip.exists()) { + if(zip == null || !zip.exists()) { sender.sendMessage("Failed to find pack at " + url); sender.sendMessage("Make sure you specified the correct repo and branch!"); sender.sendMessage("For example: /iris download IrisDimensions/overworld branch=master"); @@ -200,58 +200,58 @@ public class StudioSVC implements IrisService { sender.sendMessage("Unpacking " + repo); try { ZipUtil.unpack(zip, work); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); sender.sendMessage( - """ - Issue when unpacking. Please check/do the following: - 1. Do you have a functioning internet connection? - 2. Did the download corrupt? - 3. Try deleting the */plugins/iris/packs folder and re-download. - 4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld - 5. Contact support (if all other options do not help)""" + """ + Issue when unpacking. Please check/do the following: + 1. Do you have a functioning internet connection? + 2. Did the download corrupt? + 3. Try deleting the */plugins/iris/packs folder and re-download. + 4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld + 5. Contact support (if all other options do not help)""" ); } File dir = null; File[] zipFiles = work.listFiles(); - if (zipFiles == null) { + if(zipFiles == null) { sender.sendMessage("No files were extracted from the zip file."); return; } try { dir = zipFiles.length == 1 && zipFiles[0].isDirectory() ? zipFiles[0] : null; - } catch (NullPointerException e) { + } catch(NullPointerException e) { Iris.reportError(e); sender.sendMessage("Error when finding home directory. Are there any non-text characters in the file name?"); return; } - if (dir == null) { + if(dir == null) { sender.sendMessage("Invalid Format. Missing root folder or too many folders!"); return; } File dimensions = new File(dir, "dimensions"); - if (!(dimensions.exists() && dimensions.isDirectory())) { + if(!(dimensions.exists() && dimensions.isDirectory())) { sender.sendMessage("Invalid Format. Missing dimensions folder"); return; } - if (dimensions.listFiles() == null) { + if(dimensions.listFiles() == null) { sender.sendMessage("No dimension file found in the extracted zip file."); sender.sendMessage("Check it is there on GitHub and report this to staff!"); - } else if (dimensions.listFiles().length != 1) { + } else if(dimensions.listFiles().length != 1) { sender.sendMessage("Dimensions folder must have 1 file in it"); return; } File dim = dimensions.listFiles()[0]; - if (!dim.isFile()) { + if(!dim.isFile()) { sender.sendMessage("Invalid dimension (folder) in dimensions folder"); return; } @@ -261,23 +261,23 @@ public class StudioSVC implements IrisService { sender.sendMessage("Importing " + d.getName() + " (" + key + ")"); File packEntry = new File(packs, key); - if (forceOverwrite) { + if(forceOverwrite) { IO.delete(packEntry); } - if (IrisData.loadAnyDimension(key) != null) { + if(IrisData.loadAnyDimension(key) != null) { sender.sendMessage("Another dimension in the packs folder is already using the key " + key + " IMPORT FAILED!"); return; } - if (packEntry.exists() && packEntry.listFiles().length > 0) { + if(packEntry.exists() && packEntry.listFiles().length > 0) { sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!"); return; } FileUtils.copyDirectory(dir, packEntry); - if (trim) { + if(trim) { sender.sendMessage("Trimming " + key); File cp = compilePackage(sender, key, false, false); IO.delete(packEntry); @@ -292,7 +292,7 @@ public class StudioSVC implements IrisService { public KMap getListing(boolean cached) { JSONObject a; - if (cached) { + if(cached) { a = new JSONObject(Iris.getCached("cachedlisting", LISTING)); } else { a = new JSONObject(Iris.getNonCached(true + "listing", LISTING)); @@ -300,8 +300,8 @@ public class StudioSVC implements IrisService { KMap l = new KMap<>(); - for (String i : a.keySet()) { - if (a.get(i) instanceof String) + for(String i : a.keySet()) { + if(a.get(i) instanceof String) l.put(i, a.getString(i)); } @@ -324,7 +324,7 @@ public class StudioSVC implements IrisService { try { open(sender, seed, dimm, (w) -> { }); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); sender.sendMessage("Error when creating studio world:"); e.printStackTrace(); @@ -332,7 +332,7 @@ public class StudioSVC implements IrisService { } public void open(VolmitSender sender, long seed, String dimm, Consumer onDone) throws IrisException { - if (isProjectOpen()) { + if(isProjectOpen()) { close(); } @@ -354,7 +354,7 @@ public class StudioSVC implements IrisService { } public void close() { - if (isProjectOpen()) { + if(isProjectOpen()) { Iris.debug("Closing Active Project"); activeProject.close(); activeProject = null; @@ -369,14 +369,14 @@ public class StudioSVC implements IrisService { File importPack = getWorkspaceFolder(existingPack); File newPack = getWorkspaceFolder(newName); - if (importPack.listFiles().length == 0) { + if(importPack.listFiles().length == 0) { Iris.warn("Couldn't find the pack to create a new dimension from."); return; } try { FileUtils.copyDirectory(importPack, newPack, pathname -> !pathname.getAbsolutePath().contains(".git"), false); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -387,7 +387,7 @@ public class StudioSVC implements IrisService { try { FileUtils.copyFile(dimFile, newDimFile); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -397,11 +397,11 @@ public class StudioSVC implements IrisService { try { JSONObject json = new JSONObject(IO.readAll(newDimFile)); - if (json.has("name")) { + if(json.has("name")) { json.put("name", Form.capitalizeWords(newName.replaceAll("\\Q-\\E", " "))); IO.writeAll(newDimFile, json.toString(4)); } - } catch (JSONException | IOException e) { + } catch(JSONException | IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -410,7 +410,7 @@ public class StudioSVC implements IrisService { IrisProject p = new IrisProject(getWorkspaceFolder(newName)); JSONObject ws = p.createCodeWorkspaceConfig(); IO.writeAll(getWorkspaceFile(newName, newName + ".code-workspace"), ws.toString(0)); - } catch (JSONException | IOException e) { + } catch(JSONException | IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -420,29 +420,29 @@ public class StudioSVC implements IrisService { boolean shouldDelete = false; File importPack = getWorkspaceFolder(downloadable); - if (importPack.listFiles().length == 0) { + if(importPack.listFiles().length == 0) { downloadSearch(sender, downloadable, false); - if (importPack.listFiles().length > 0) { + if(importPack.listFiles().length > 0) { shouldDelete = true; } } - if (importPack.listFiles().length == 0) { + if(importPack.listFiles().length == 0) { sender.sendMessage("Couldn't find the pack to create a new dimension from."); return; } File importDimensionFile = new File(importPack, "dimensions/" + downloadable + ".json"); - if (!importDimensionFile.exists()) { + if(!importDimensionFile.exists()) { sender.sendMessage("Missing Imported Dimension File"); return; } sender.sendMessage("Importing " + downloadable + " into new Project " + s); createFrom(downloadable, s); - if (shouldDelete) { + if(shouldDelete) { importPack.delete(); } open(sender, s); @@ -457,7 +457,7 @@ public class StudioSVC implements IrisService { } public void updateWorkspace() { - if (isProjectOpen()) { + if(isProjectOpen()) { activeProject.updateWorkspace(); } } diff --git a/src/main/java/com/volmit/iris/core/service/TreeSVC.java b/src/main/java/com/volmit/iris/core/service/TreeSVC.java index eac9e8117..b3e47af57 100644 --- a/src/main/java/com/volmit/iris/core/service/TreeSVC.java +++ b/src/main/java/com/volmit/iris/core/service/TreeSVC.java @@ -79,22 +79,23 @@ public class TreeSVC implements IrisService { *
4. Check biome, region and dimension for overrides for that sapling type -> Found -> use
*
5. Exit if none are found, cancel event if one or more are.
* - * @param event Checks the given event for sapling overrides + * @param event + * Checks the given event for sapling overrides */ @EventHandler(priority = EventPriority.HIGHEST) public void on(StructureGrowEvent event) { - if (block || event.isCancelled()) { + if(block || event.isCancelled()) { return; } Iris.debug(this.getClass().getName() + " received a structure grow event"); - if (!IrisToolbelt.isIrisWorld(event.getWorld())) { + if(!IrisToolbelt.isIrisWorld(event.getWorld())) { Iris.debug(this.getClass().getName() + " passed grow event off to vanilla since not an Iris world"); return; } PlatformChunkGenerator worldAccess = IrisToolbelt.access(event.getWorld()); - if (worldAccess == null) { + if(worldAccess == null) { Iris.debug(this.getClass().getName() + " passed it off to vanilla because could not get IrisAccess for this world"); Iris.reportError(new NullPointerException(event.getWorld().getName() + " could not be accessed despite being an Iris world")); return; @@ -102,7 +103,7 @@ public class TreeSVC implements IrisService { Engine engine = worldAccess.getEngine(); - if (engine == null) { + if(engine == null) { Iris.debug(this.getClass().getName() + " passed it off to vanilla because could not get Engine for this world"); Iris.reportError(new NullPointerException(event.getWorld().getName() + " could not be accessed despite being an Iris world")); return; @@ -110,13 +111,13 @@ public class TreeSVC implements IrisService { IrisDimension dimension = engine.getDimension(); - if (dimension == null) { + if(dimension == null) { Iris.debug(this.getClass().getName() + " passed it off to vanilla because could not get Dimension for this world"); Iris.reportError(new NullPointerException(event.getWorld().getName() + " could not be accessed despite being an Iris world")); return; } - if (!dimension.getTreeSettings().isEnabled()) { + if(!dimension.getTreeSettings().isEnabled()) { Iris.debug(this.getClass().getName() + " cancelled because tree overrides are disabled"); return; } @@ -128,7 +129,7 @@ public class TreeSVC implements IrisService { Iris.debug("Sapling plane is: " + saplingPlane.getSizeX() + " by " + saplingPlane.getSizeZ()); IrisObjectPlacement placement = getObjectPlacement(worldAccess, event.getLocation(), event.getSpecies(), new IrisTreeSize(1, 1)); - if (placement == null) { + if(placement == null) { Iris.debug(this.getClass().getName() + " had options but did not manage to find objectPlacements for them"); return; } @@ -207,13 +208,13 @@ public class TreeSVC implements IrisService { }; object.place( - saplingPlane.getCenter().getBlockX(), - (saplingPlane.getCenter().getBlockY() + object.getH() / 2), - saplingPlane.getCenter().getBlockZ(), - placer, - placement, - RNG.r, - Objects.requireNonNull(worldAccess).getData() + saplingPlane.getCenter().getBlockX(), + (saplingPlane.getCenter().getBlockY() + object.getH() / 2), + saplingPlane.getCenter().getBlockZ(), + placer, + placement, + RNG.r, + Objects.requireNonNull(worldAccess).getData() ); event.setCancelled(true); @@ -225,11 +226,11 @@ public class TreeSVC implements IrisService { Bukkit.getServer().getPluginManager().callEvent(iGrow); block = false; - if (!iGrow.isCancelled()) { - for (BlockState block : iGrow.getBlocks()) { + if(!iGrow.isCancelled()) { + for(BlockState block : iGrow.getBlocks()) { Location l = block.getLocation(); - if (dataCache.containsKey(l)) { + if(dataCache.containsKey(l)) { l.getBlock().setBlockData(dataCache.get(l), false); } } @@ -238,12 +239,17 @@ public class TreeSVC implements IrisService { } /** - * Finds a single object placement (which may contain more than one object) for the requirements species, location & size + * Finds a single object placement (which may contain more than one object) for the requirements species, location & + * size * - * @param worldAccess The world to access (check for biome, region, dimension, etc) - * @param location The location of the growth event (For biome/region finding) - * @param type The bukkit TreeType to match - * @param size The size of the sapling area + * @param worldAccess + * The world to access (check for biome, region, dimension, etc) + * @param location + * The location of the growth event (For biome/region finding) + * @param type + * The bukkit TreeType to match + * @param size + * The size of the sapling area * @return An object placement which contains the matched tree, or null if none were found / it's disabled. */ private IrisObjectPlacement getObjectPlacement(PlatformChunkGenerator worldAccess, Location location, TreeType type, IrisTreeSize size) { @@ -256,7 +262,7 @@ public class TreeSVC implements IrisService { placements.addAll(matchObjectPlacements(biome.getObjects(), size, type)); // Add more or find any in the region - if (isUseAll || placements.isEmpty()) { + if(isUseAll || placements.isEmpty()) { IrisRegion region = worldAccess.getEngine().getRegion(location.getBlockX(), location.getBlockZ()); placements.addAll(matchObjectPlacements(region.getObjects(), size, type)); } @@ -268,17 +274,20 @@ public class TreeSVC implements IrisService { /** * Filters out mismatches and returns matches * - * @param objects The object placements to check - * @param size The size of the sapling area to filter with - * @param type The type of the tree to filter with + * @param objects + * The object placements to check + * @param size + * The size of the sapling area to filter with + * @param type + * The type of the tree to filter with * @return A list of objectPlacements that matched. May be empty. */ private KList matchObjectPlacements(KList objects, IrisTreeSize size, TreeType type) { KList p = new KList<>(); - for (IrisObjectPlacement i : objects) { - if (i.matches(size, type)) { + for(IrisObjectPlacement i : objects) { + if(i.matches(size, type)) { p.add(i); } } @@ -289,9 +298,12 @@ public class TreeSVC implements IrisService { /** * Get the Cuboid of sapling sizes at a location & blockData predicate * - * @param at this location - * @param valid with this blockData predicate - * @param world the world to check in + * @param at + * this location + * @param valid + * with this blockData predicate + * @param world + * the world to check in * @return A cuboid containing only saplings */ public Cuboid getSaplings(Location at, Predicate valid, World world) { @@ -301,7 +313,7 @@ public class TreeSVC implements IrisService { BlockPosition b = new BlockPosition(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); // Maximise the block position in x and z to get max cuboid bounds - for (BlockPosition blockPosition : blockPositions) { + for(BlockPosition blockPosition : blockPositions) { a.max(blockPosition); b.min(blockPosition); } @@ -314,12 +326,12 @@ public class TreeSVC implements IrisService { boolean cuboidIsValid = true; // Loop while the cuboid is larger than 2 - while (Math.min(cuboid.getSizeX(), cuboid.getSizeZ()) > 0) { + while(Math.min(cuboid.getSizeX(), cuboid.getSizeZ()) > 0) { checking: - for (int i = cuboid.getLowerX(); i < cuboid.getUpperX(); i++) { - for (int j = cuboid.getLowerY(); j < cuboid.getUpperY(); j++) { - for (int k = cuboid.getLowerZ(); k < cuboid.getUpperZ(); k++) { - if (!blockPositions.contains(new BlockPosition(i, j, k))) { + for(int i = cuboid.getLowerX(); i < cuboid.getUpperX(); i++) { + for(int j = cuboid.getLowerY(); j < cuboid.getUpperY(); j++) { + for(int k = cuboid.getLowerZ(); k < cuboid.getUpperZ(); k++) { + if(!blockPositions.contains(new BlockPosition(i, j, k))) { cuboidIsValid = false; break checking; } @@ -328,7 +340,7 @@ public class TreeSVC implements IrisService { } // Return this cuboid if it's valid - if (cuboidIsValid) { + if(cuboidIsValid) { return cuboid; } @@ -343,14 +355,18 @@ public class TreeSVC implements IrisService { /** * Grows the blockPosition list by means of checking neighbours in * - * @param world the world to check in - * @param center the location of this position - * @param valid validation on blockData to check block with - * @param l list of block positions to add new neighbors too + * @param world + * the world to check in + * @param center + * the location of this position + * @param valid + * validation on blockData to check block with + * @param l + * list of block positions to add new neighbors too */ private void grow(World world, BlockPosition center, Predicate valid, KList l) { // Make sure size is less than 50, the block to check isn't already in, and make sure the blockData still matches - if (l.size() <= 50 && !l.contains(center) && valid.test(center.toBlock(world).getBlockData())) { + if(l.size() <= 50 && !l.contains(center) && valid.test(center.toBlock(world).getBlockData())) { l.add(center); grow(world, center.add(1, 0, 0), valid, l); grow(world, center.add(-1, 0, 0), valid, l); diff --git a/src/main/java/com/volmit/iris/core/service/VillageSVC.java b/src/main/java/com/volmit/iris/core/service/VillageSVC.java index 6f31fbe10..49519d72c 100644 --- a/src/main/java/com/volmit/iris/core/service/VillageSVC.java +++ b/src/main/java/com/volmit/iris/core/service/VillageSVC.java @@ -43,25 +43,25 @@ public class VillageSVC implements IrisService { */ @EventHandler public void on(VillagerAcquireTradeEvent event) { - if (!IrisToolbelt.isIrisWorld((event.getEntity().getWorld()))) { + if(!IrisToolbelt.isIrisWorld((event.getEntity().getWorld()))) { return; } // Iris.info("Trade event: type " + event.getRecipe().getResult().getType() + " / meta " + event.getRecipe().getResult().getItemMeta() + " / data " + event.getRecipe().getResult().getData()); - if (!event.getRecipe().getResult().getType().equals(Material.FILLED_MAP)) { + if(!event.getRecipe().getResult().getType().equals(Material.FILLED_MAP)) { return; } IrisVillagerOverride override = IrisToolbelt.access(event.getEntity().getWorld()).getEngine() - .getDimension().getPatchCartographers(); + .getDimension().getPatchCartographers(); - if (override.isDisableTrade()) { + if(override.isDisableTrade()) { event.setCancelled(true); Iris.debug("Cancelled cartographer trade @ " + event.getEntity().getLocation()); return; } - if (override.getValidItems() == null) { + if(override.getValidItems() == null) { event.setCancelled(true); Iris.debug("Cancelled cartographer trade because no override items are valid @ " + event.getEntity().getLocation()); return; diff --git a/src/main/java/com/volmit/iris/core/service/WandSVC.java b/src/main/java/com/volmit/iris/core/service/WandSVC.java index 494a8c48e..dd53d6f82 100644 --- a/src/main/java/com/volmit/iris/core/service/WandSVC.java +++ b/src/main/java/com/volmit/iris/core/service/WandSVC.java @@ -64,11 +64,12 @@ public class WandSVC implements IrisService { /** * Creates an Iris Object from the 2 coordinates selected with a wand * - * @param wand The wand itemstack + * @param wand + * The wand itemstack * @return The new object */ public static IrisObject createSchematic(ItemStack wand) { - if (!isWand(wand)) { + if(!isWand(wand)) { return null; } @@ -76,8 +77,8 @@ public class WandSVC implements IrisService { Location[] f = getCuboid(wand); Cuboid c = new Cuboid(f[0], f[1]); IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ()); - for (Block b : c) { - if (b.getType().equals(Material.AIR)) { + for(Block b : c) { + if(b.getType().equals(Material.AIR)) { continue; } @@ -86,7 +87,7 @@ public class WandSVC implements IrisService { } return s; - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } @@ -97,11 +98,12 @@ public class WandSVC implements IrisService { /** * Creates an Iris Object from the 2 coordinates selected with a wand * - * @param wand The wand itemstack + * @param wand + * The wand itemstack * @return The new object */ public static Matter createMatterSchem(Player p, ItemStack wand) { - if (!isWand(wand)) { + if(!isWand(wand)) { return null; } @@ -109,7 +111,7 @@ public class WandSVC implements IrisService { Location[] f = getCuboid(wand); return WorldMatter.createMatter(p.getName(), f[0], f[1]); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } @@ -120,7 +122,8 @@ public class WandSVC implements IrisService { /** * Converts a user friendly location string to an actual Location * - * @param s The string + * @param s + * The string * @return The location */ public static Location stringToLocation(String s) { @@ -128,7 +131,7 @@ public class WandSVC implements IrisService { String[] f = s.split("\\Q in \\E"); String[] g = f[0].split("\\Q,\\E"); return new Location(Bukkit.getWorld(f[1]), Integer.parseInt(g[0]), Integer.parseInt(g[1]), Integer.parseInt(g[2])); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); return null; } @@ -137,11 +140,12 @@ public class WandSVC implements IrisService { /** * Get a user friendly string of a location * - * @param loc The location + * @param loc + * The location * @return The string */ public static String locationToString(Location loc) { - if (loc == null) { + if(loc == null) { return "<#>"; } @@ -178,7 +182,8 @@ public class WandSVC implements IrisService { /** * Finds an existing wand in a users inventory * - * @param inventory The inventory to search + * @param inventory + * The inventory to search * @return The slot number the wand is in. Or -1 if none are found */ public static int findWand(Inventory inventory) { @@ -187,14 +192,14 @@ public class WandSVC implements IrisService { meta.setLore(new ArrayList<>()); //We are resetting the lore as the lore differs between wands wand.setItemMeta(meta); - for (int s = 0; s < inventory.getSize(); s++) { + for(int s = 0; s < inventory.getSize(); s++) { ItemStack stack = inventory.getItem(s); - if (stack == null) continue; + if(stack == null) continue; meta = stack.getItemMeta(); meta.setLore(new ArrayList<>()); //Reset the lore on this too so we can compare them stack.setItemMeta(meta); //We dont need to clone the item as items from .get are cloned - if (wand.isSimilar(stack)) return s; //If the name, material and NBT is the same + if(wand.isSimilar(stack)) return s; //If the name, material and NBT is the same } return -1; } @@ -202,8 +207,10 @@ public class WandSVC implements IrisService { /** * Creates an Iris wand. The locations should be the currently selected locations, or null * - * @param a Location A - * @param b Location B + * @param a + * Location A + * @param b + * Location B * @return A new wand */ public static ItemStack createWand(Location a, Location b) { @@ -222,18 +229,20 @@ public class WandSVC implements IrisService { /** * Get a pair of locations that are selected in an Iris wand * - * @param is The wand item + * @param is + * The wand item * @return An array with the 2 locations */ public static Location[] getCuboid(ItemStack is) { ItemMeta im = is.getItemMeta(); - return new Location[]{stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))}; + return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))}; } /** * Is a player holding an Iris wand * - * @param p The player + * @param p + * The player * @return True if they are */ public static boolean isHoldingWand(Player p) { @@ -244,16 +253,17 @@ public class WandSVC implements IrisService { /** * Is the itemstack passed an Iris wand * - * @param is The itemstack + * @param is + * The itemstack * @return True if it is */ public static boolean isWand(ItemStack is) { ItemStack wand = createWand(); - if (is.getItemMeta() == null) return false; + if(is.getItemMeta() == null) return false; return is.getType().equals(wand.getType()) && - is.getItemMeta().getDisplayName().equals(wand.getItemMeta().getDisplayName()) && - is.getItemMeta().getEnchants().equals(wand.getItemMeta().getEnchants()) && - is.getItemMeta().getItemFlags().equals(wand.getItemMeta().getItemFlags()); + is.getItemMeta().getDisplayName().equals(wand.getItemMeta().getDisplayName()) && + is.getItemMeta().getEnchants().equals(wand.getItemMeta().getEnchants()) && + is.getItemMeta().getItemFlags().equals(wand.getItemMeta().getItemFlags()); } @Override @@ -262,7 +272,7 @@ public class WandSVC implements IrisService { dust = createDust(); J.ar(() -> { - for (Player i : Bukkit.getOnlinePlayers()) { + for(Player i : Bukkit.getOnlinePlayers()) { tick(i); } }, 0); @@ -276,14 +286,14 @@ public class WandSVC implements IrisService { public void tick(Player p) { try { try { - if (isWand(p.getInventory().getItemInMainHand())) { + if(isWand(p.getInventory().getItemInMainHand())) { Location[] d = getCuboid(p.getInventory().getItemInMainHand()); new WandSelection(new Cuboid(d[0], d[1]), p).draw(); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -291,18 +301,22 @@ public class WandSVC implements IrisService { /** * Draw the outline of a selected region * - * @param d The cuboid - * @param p The player to show it to + * @param d + * The cuboid + * @param p + * The player to show it to */ public void draw(Cuboid d, Player p) { - draw(new Location[]{d.getLowerNE(), d.getUpperSW()}, p); + draw(new Location[] {d.getLowerNE(), d.getUpperSW()}, p); } /** * Draw the outline of a selected region * - * @param d A pair of locations - * @param p The player to show them to + * @param d + * A pair of locations + * @param p + * The player to show them to */ public void draw(Location[] d, Player p) { Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); @@ -310,11 +324,11 @@ public class WandSVC implements IrisService { Vector gxx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); d[1].getWorld().spawnParticle(Particle.CRIT, d[1], 1, 0.5 + gxx.getX(), 0.5 + gxx.getY(), 0.5 + gxx.getZ(), 0, null, false); - if (!d[0].getWorld().equals(d[1].getWorld())) { + if(!d[0].getWorld().equals(d[1].getWorld())) { return; } - if (d[0].distanceSquared(d[1]) > 64 * 64) { + if(d[0].distanceSquared(d[1]) > 64 * 64) { return; } @@ -325,38 +339,38 @@ public class WandSVC implements IrisService { int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY()); int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ()); - for (double j = minx - 1; j < maxx + 1; j += 0.25) { - for (double k = miny - 1; k < maxy + 1; k += 0.25) { - for (double l = minz - 1; l < maxz + 1; l += 0.25) { - if (M.r(0.2)) { + for(double j = minx - 1; j < maxx + 1; j += 0.25) { + for(double k = miny - 1; k < maxy + 1; k += 0.25) { + for(double l = minz - 1; l < maxz + 1; l += 0.25) { + if(M.r(0.2)) { boolean jj = j == minx || j == maxx; boolean kk = k == miny || k == maxy; boolean ll = l == minz || l == maxz; - if ((jj && kk) || (jj && ll) || (ll && kk)) { + if((jj && kk) || (jj && ll) || (ll && kk)) { Vector push = new Vector(0, 0, 0); - if (j == minx) { + if(j == minx) { push.add(new Vector(-0.55, 0, 0)); } - if (k == miny) { + if(k == miny) { push.add(new Vector(0, -0.55, 0)); } - if (l == minz) { + if(l == minz) { push.add(new Vector(0, 0, -0.55)); } - if (j == maxx) { + if(j == maxx) { push.add(new Vector(0.55, 0, 0)); } - if (k == maxy) { + if(k == maxy) { push.add(new Vector(0, 0.55, 0)); } - if (l == maxz) { + if(l == maxz) { push.add(new Vector(0, 0, 0.55)); } @@ -376,13 +390,13 @@ public class WandSVC implements IrisService { @EventHandler public void on(PlayerInteractEvent e) { try { - if (isHoldingWand(e.getPlayer())) { - if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) { + if(isHoldingWand(e.getPlayer())) { + if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)) { e.setCancelled(true); e.getPlayer().getInventory().setItemInMainHand(update(true, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand())); e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f); e.getPlayer().updateInventory(); - } else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + } else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { e.setCancelled(true); e.getPlayer().getInventory().setItemInMainHand(update(false, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand())); e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f); @@ -390,15 +404,15 @@ public class WandSVC implements IrisService { } } - if (isHoldingDust(e.getPlayer())) { - if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + if(isHoldingDust(e.getPlayer())) { + if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { e.setCancelled(true); e.getPlayer().playSound(Objects.requireNonNull(e.getClickedBlock()).getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f); DustRevealer.spawn(e.getClickedBlock(), new VolmitSender(e.getPlayer(), Iris.instance.getTag())); } } - } catch (Throwable xx) { + } catch(Throwable xx) { Iris.reportError(xx); } } @@ -406,7 +420,8 @@ public class WandSVC implements IrisService { /** * Is the player holding Dust? * - * @param p The player + * @param p + * The player * @return True if they are */ public boolean isHoldingDust(Player p) { @@ -417,7 +432,8 @@ public class WandSVC implements IrisService { /** * Is the itemstack passed Iris dust? * - * @param is The itemstack + * @param is + * The itemstack * @return True if it is */ public boolean isDust(ItemStack is) { @@ -427,20 +443,23 @@ public class WandSVC implements IrisService { /** * Update the location on an Iris wand * - * @param left True for first location, false for second - * @param a The location - * @param item The wand + * @param left + * True for first location, false for second + * @param a + * The location + * @param item + * The wand * @return The updated wand */ public ItemStack update(boolean left, Location a, ItemStack item) { - if (!isWand(item)) { + if(!isWand(item)) { return item; } Location[] f = getCuboid(item); Location other = left ? f[1] : f[0]; - if (other != null && !other.getWorld().getName().equals(a.getWorld().getName())) { + if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) { other = null; } diff --git a/src/main/java/com/volmit/iris/core/tools/IrisCreator.java b/src/main/java/com/volmit/iris/core/tools/IrisCreator.java index f05b8752b..520b9fa0e 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisCreator.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisCreator.java @@ -88,20 +88,21 @@ public class IrisCreator { * Create the IrisAccess (contains the world) * * @return the IrisAccess - * @throws IrisException shit happens + * @throws IrisException + * shit happens */ public World create() throws IrisException { - if (Bukkit.isPrimaryThread()) { + if(Bukkit.isPrimaryThread()) { throw new IrisException("You cannot invoke create() on the main thread."); } IrisDimension d = IrisToolbelt.getDimension(dimension()); - if (d == null) { + if(d == null) { throw new IrisException("Dimension cannot be found null for id " + dimension()); } - if (!studio()) { + if(!studio()) { Iris.service(StudioSVC.class).installIntoWorld(sender, d.getLoadKey(), new File(name())); } @@ -111,11 +112,11 @@ public class IrisCreator { O done = new O<>(); done.set(false); WorldCreator wc = new IrisWorldCreator() - .dimension(dimension) - .name(name) - .seed(seed) - .studio(studio) - .create(); + .dimension(dimension) + .name(name) + .seed(seed) + .studio(studio) + .create(); access = (PlatformChunkGenerator) wc.generator(); PlatformChunkGenerator finalAccess1 = access; @@ -126,14 +127,14 @@ public class IrisCreator { Supplier g = () -> { try { return finalAccess1.getEngine().getGenerated(); - } catch (Throwable e) { + } catch(Throwable e) { return 0; } }; - while (g.get() < req) { + while(g.get() < req) { double v = (double) g.get() / (double) req; - if (sender.isPlayer()) { + if(sender.isPlayer()) { sender.sendProgress(v, "Generating"); J.sleep(16); } else { @@ -148,27 +149,27 @@ public class IrisCreator { J.sfut(() -> { world.set(wc.createWorld()); }).get(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } - if (access == null) { + if(access == null) { throw new IrisException("Access is null. Something bad happened."); } done.set(true); - if (sender.isPlayer()) { + if(sender.isPlayer()) { J.s(() -> { sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0)); }); } - if (studio) { + if(studio) { J.s(() -> { Iris.linkMultiverseCore.removeFromConfig(world.get()); - if (IrisSettings.get().getStudio().isDisableTimeAndWeather()) { + if(IrisSettings.get().getStudio().isDisableTimeAndWeather()) { world.get().setGameRule(GameRule.DO_WEATHER_CYCLE, false); world.get().setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false); world.get().setTime(6000); @@ -176,19 +177,19 @@ public class IrisCreator { }); } - if (pregen != null) { + if(pregen != null) { CompletableFuture ff = new CompletableFuture<>(); IrisToolbelt.pregenerate(pregen, access) - .onProgress(pp::set) - .whenDone(() -> ff.complete(true)); + .onProgress(pp::set) + .whenDone(() -> ff.complete(true)); try { AtomicBoolean dx = new AtomicBoolean(false); J.a(() -> { - while (!dx.get()) { - if (sender.isPlayer()) { + while(!dx.get()) { + if(sender.isPlayer()) { sender.sendProgress(pp.get(), "Pregenerating"); J.sleep(16); } else { @@ -200,7 +201,7 @@ public class IrisCreator { ff.get(); dx.set(true); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } diff --git a/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java b/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java index faf696db3..e87e055ca 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java @@ -51,17 +51,18 @@ public class IrisToolbelt { * - GithubUsername/repository * - GithubUsername/repository/branch * - * @param dimension the dimension id such as overworld or flat + * @param dimension + * the dimension id such as overworld or flat * @return the IrisDimension or null */ public static IrisDimension getDimension(String dimension) { File pack = Iris.instance.getDataFolder("packs", dimension); - if (!pack.exists()) { + if(!pack.exists()) { Iris.service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), dimension, false, false); } - if (!pack.exists()) { + if(!pack.exists()) { return null; } @@ -80,15 +81,16 @@ public class IrisToolbelt { /** * Checks if the given world is an Iris World (same as access(world) != null) * - * @param world the world + * @param world + * the world * @return true if it is an Iris Access world */ public static boolean isIrisWorld(World world) { - if (world == null) { + if(world == null) { return false; } - if (world.getGenerator() instanceof PlatformChunkGenerator f) { + if(world.getGenerator() instanceof PlatformChunkGenerator f) { f.touch(world); return true; } @@ -103,11 +105,12 @@ public class IrisToolbelt { /** * Get the Iris generator for the given world * - * @param world the given world + * @param world + * the given world * @return the IrisAccess or null if it's not an Iris World */ public static PlatformChunkGenerator access(World world) { - if (isIrisWorld(world)) { + if(isIrisWorld(world)) { return ((PlatformChunkGenerator) world.getGenerator()); } @@ -117,8 +120,10 @@ public class IrisToolbelt { /** * Start a pregenerator task * - * @param task the scheduled task - * @param method the method to execute the task + * @param task + * the scheduled task + * @param method + * the method to execute the task * @return the pregenerator job (already started) */ public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method, Engine engine) { @@ -129,29 +134,33 @@ public class IrisToolbelt { * Start a pregenerator task. If the supplied generator is headless, headless mode is used, * otherwise Hybrid mode is used. * - * @param task the scheduled task - * @param gen the Iris Generator + * @param task + * the scheduled task + * @param gen + * the Iris Generator * @return the pregenerator job (already started) */ public static PregeneratorJob pregenerate(PregenTask task, PlatformChunkGenerator gen) { - if (gen.isHeadless()) { + if(gen.isHeadless()) { return pregenerate(task, new HeadlessPregenMethod(((HeadlessGenerator) gen).getWorld(), (HeadlessGenerator) gen), gen.getEngine()); } return pregenerate(task, new HybridPregenMethod(gen.getEngine().getWorld().realWorld(), - IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())), gen.getEngine()); + IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())), gen.getEngine()); } /** * Start a pregenerator task. If the supplied generator is headless, headless mode is used, * otherwise Hybrid mode is used. * - * @param task the scheduled task - * @param world the World + * @param task + * the scheduled task + * @param world + * the World * @return the pregenerator job (already started) */ public static PregeneratorJob pregenerate(PregenTask task, World world) { - if (isIrisWorld(world)) { + if(isIrisWorld(world)) { return pregenerate(task, access(world)); } @@ -162,12 +171,13 @@ public class IrisToolbelt { * Evacuate all players from the world into literally any other world. * If there are no other worlds, kick them! Not the best but what's mine is mine sometimes... * - * @param world the world to evac + * @param world + * the world to evac */ public static boolean evacuate(World world) { - for (World i : Bukkit.getWorlds()) { - if (!i.getName().equals(world.getName())) { - for (Player j : world.getPlayers()) { + for(World i : Bukkit.getWorlds()) { + if(!i.getName().equals(world.getName())) { + for(Player j : world.getPlayers()) { new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world."); j.teleport(i.getSpawnLocation()); } @@ -182,14 +192,16 @@ public class IrisToolbelt { /** * Evacuate all players from the world * - * @param world the world to leave - * @param m the message + * @param world + * the world to leave + * @param m + * the message * @return true if it was evacuated. */ public static boolean evacuate(World world, String m) { - for (World i : Bukkit.getWorlds()) { - if (!i.getName().equals(world.getName())) { - for (Player j : world.getPlayers()) { + for(World i : Bukkit.getWorlds()) { + if(!i.getName().equals(world.getName())) { + for(Player j : world.getPlayers()) { new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world. " + m); j.teleport(i.getSpawnLocation()); } diff --git a/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java b/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java index c05d3b0a3..6322e76f5 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java @@ -79,26 +79,26 @@ public class IrisWorldCreator { public WorldCreator create() { IrisWorld w = IrisWorld.builder() - .name(name) - .minHeight(minHeight) - .maxHeight(maxHeight) - .seed(seed) - .worldFolder(new File(name)) - .environment(findEnvironment()) - .build(); + .name(name) + .minHeight(minHeight) + .maxHeight(maxHeight) + .seed(seed) + .worldFolder(new File(name)) + .environment(findEnvironment()) + .build(); ChunkGenerator g = new BukkitChunkGenerator(w, studio, studio - ? IrisData.loadAnyDimension(dimensionName).getLoader().getDataFolder() : - new File(w.worldFolder(), "iris/pack"), dimensionName); + ? IrisData.loadAnyDimension(dimensionName).getLoader().getDataFolder() : + new File(w.worldFolder(), "iris/pack"), dimensionName); return new WorldCreator(name) - .environment(findEnvironment()) - .generateStructures(true) - .generator(g).seed(seed); + .environment(findEnvironment()) + .generateStructures(true) + .generator(g).seed(seed); } private World.Environment findEnvironment() { IrisDimension dim = IrisData.loadAnyDimension(dimensionName); - if (dim == null || dim.getEnvironment() == null) { + if(dim == null || dim.getEnvironment() == null) { return World.Environment.NORMAL; } else { return dim.getEnvironment(); diff --git a/src/main/java/com/volmit/iris/core/wand/WandSelection.java b/src/main/java/com/volmit/iris/core/wand/WandSelection.java index 7554b58f8..987eb5c50 100644 --- a/src/main/java/com/volmit/iris/core/wand/WandSelection.java +++ b/src/main/java/com/volmit/iris/core/wand/WandSelection.java @@ -41,37 +41,37 @@ public class WandSelection { double accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(c.getCenter())); double dist = M.lerp(0.125, 3.5, accuracy); - 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) { - for (double k = c.getLowerZ() - 1; k < c.getUpperZ() + 1; k += 0.25) { + 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) { + for(double k = c.getLowerZ() - 1; k < c.getUpperZ() + 1; k += 0.25) { boolean ii = i == c.getLowerX() || i == c.getUpperX(); boolean jj = j == c.getLowerY() || j == c.getUpperY(); boolean kk = k == c.getLowerZ() || k == c.getUpperZ(); - if ((ii && jj) || (ii && kk) || (kk && jj)) { + if((ii && jj) || (ii && kk) || (kk && jj)) { Vector push = new Vector(0, 0, 0); - if (i == c.getLowerX()) { + if(i == c.getLowerX()) { push.add(new Vector(-0.55, 0, 0)); } - if (j == c.getLowerY()) { + if(j == c.getLowerY()) { push.add(new Vector(0, -0.55, 0)); } - if (k == c.getLowerZ()) { + if(k == c.getLowerZ()) { push.add(new Vector(0, 0, -0.55)); } - if (i == c.getUpperX()) { + if(i == c.getUpperX()) { push.add(new Vector(0.55, 0, 0)); } - if (j == c.getUpperY()) { + if(j == c.getUpperY()) { push.add(new Vector(0, 0.55, 0)); } - if (k == c.getUpperZ()) { + if(k == c.getUpperZ()) { push.add(new Vector(0, 0, 0.55)); } @@ -79,32 +79,32 @@ public class WandSelection { accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(a)); dist = M.lerp(0.125, 3.5, accuracy); - if (M.r(M.min(dist * 5, 0.9D) * 0.995)) { + if(M.r(M.min(dist * 5, 0.9D) * 0.995)) { continue; } - if (ii && jj) { + if(ii && jj) { a.add(0, 0, RNG.r.d(-0.3, 0.3)); } - if (kk && jj) { + if(kk && jj) { a.add(RNG.r.d(-0.3, 0.3), 0, 0); } - if (ii && kk) { + if(ii && kk) { a.add(0, RNG.r.d(-0.3, 0.3), 0); } - if (p.getLocation().distanceSquared(a) < 256 * 256) { + if(p.getLocation().distanceSquared(a) < 256 * 256) { Color color = Color.getHSBColor((float) (0.5f + (Math.sin((i + j + k + (p.getTicksLived() / 2f)) / (20f)) / 2)), 1, 1); int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); p.spawnParticle(Particle.REDSTONE, a.getX(), a.getY(), a.getZ(), - 1, 0, 0, 0, 0, - new Particle.DustOptions(org.bukkit.Color.fromRGB(r, g, b), - (float) dist * 3f)); + 1, 0, 0, 0, 0, + new Particle.DustOptions(org.bukkit.Color.fromRGB(r, g, b), + (float) dist * 3f)); } } } diff --git a/src/main/java/com/volmit/iris/engine/EnginePanic.java b/src/main/java/com/volmit/iris/engine/EnginePanic.java index 41689f282..56d8baee7 100644 --- a/src/main/java/com/volmit/iris/engine/EnginePanic.java +++ b/src/main/java/com/volmit/iris/engine/EnginePanic.java @@ -25,29 +25,23 @@ public class EnginePanic { private static final KMap stuff = new KMap<>(); private static KMap last = new KMap<>(); - public static void add(String key, String value) - { + public static void add(String key, String value) { stuff.put(key, value); } - public static void saveLast() - { + public static void saveLast() { last = stuff.copy(); } - public static void lastPanic() - { - for(String i : last.keySet()) - { + public static void lastPanic() { + for(String i : last.keySet()) { Iris.error("Last Panic " + i + ": " + stuff.get(i)); } } - public static void panic() - { + public static void panic() { lastPanic(); - for(String i : stuff.keySet()) - { + for(String i : stuff.keySet()) { Iris.error("Engine Panic " + i + ": " + stuff.get(i)); } } diff --git a/src/main/java/com/volmit/iris/engine/IrisComplex.java b/src/main/java/com/volmit/iris/engine/IrisComplex.java index 063a12b8e..650a02343 100644 --- a/src/main/java/com/volmit/iris/engine/IrisComplex.java +++ b/src/main/java/com/volmit/iris/engine/IrisComplex.java @@ -102,70 +102,70 @@ public class IrisComplex implements DataProvider { focusRegion = engine.getFocusRegion(); KMap> inferredStreams = new KMap<>(); - if (focusBiome != null) { + if(focusBiome != null) { focusBiome.setInferredType(InferredType.LAND); focusRegion = findRegion(focusBiome, engine); } //@builder engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i) - .getAllBiomes(this).forEach((b) -> b - .getGenerators() - .forEach((c) -> registerGenerator(c.getCachedGenerator(this))))); + .getAllBiomes(this).forEach((b) -> b + .getGenerators() + .forEach((c) -> registerGenerator(c.getCachedGenerator(this))))); overlayStream = ProceduralStream.ofDouble((x, z) -> 0D); engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, getData(), x, z))); rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream() - .select(engine.getDimension().getRockPalette().getBlockData(data)); + .select(engine.getDimension().getRockPalette().getBlockData(data)); fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream() - .select(engine.getDimension().getFluidPalette().getBlockData(data)); + .select(engine.getDimension().getFluidPalette().getBlockData(data)); regionStyleStream = engine.getDimension().getRegionStyle().create(rng.nextParallelRNG(883), getData()).stream() - .zoom(engine.getDimension().getRegionZoom()); + .zoom(engine.getDimension().getRegionZoom()); regionIdentityStream = regionStyleStream.fit(Integer.MIN_VALUE, Integer.MAX_VALUE); regionStream = focusRegion != null ? - ProceduralStream.of((x, z) -> focusRegion, - Interpolated.of(a -> 0D, a -> focusRegion)) - : regionStyleStream - .selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions())) - .cache2D("regionStream", engine, cacheSize); + ProceduralStream.of((x, z) -> focusRegion, + Interpolated.of(a -> 0D, a -> focusRegion)) + : regionStyleStream + .selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions())) + .cache2D("regionStream", engine, cacheSize); regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L)); caveBiomeStream = regionStream.convert((r) - -> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream() - .zoom(r.getCaveBiomeZoom()) - .selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes())) - .onNull(emptyBiome) + -> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream() + .zoom(r.getCaveBiomeZoom()) + .selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes())) + .onNull(emptyBiome) ).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize); inferredStreams.put(InferredType.CAVE, caveBiomeStream); landBiomeStream = regionStream.convert((r) - -> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream() - .zoom(r.getLandBiomeZoom()) - .selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND))) - ).convertAware2D(ProceduralStream::get) - .cache2D("landBiomeStream", engine, cacheSize); + -> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream() + .zoom(r.getLandBiomeZoom()) + .selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND))) + ).convertAware2D(ProceduralStream::get) + .cache2D("landBiomeStream", engine, cacheSize); inferredStreams.put(InferredType.LAND, landBiomeStream); seaBiomeStream = regionStream.convert((r) - -> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream() - .zoom(r.getSeaBiomeZoom()) - .selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA))) - ).convertAware2D(ProceduralStream::get) - .cache2D("seaBiomeStream", engine, cacheSize); + -> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream() + .zoom(r.getSeaBiomeZoom()) + .selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA))) + ).convertAware2D(ProceduralStream::get) + .cache2D("seaBiomeStream", engine, cacheSize); inferredStreams.put(InferredType.SEA, seaBiomeStream); shoreBiomeStream = regionStream.convert((r) - -> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream() - .zoom(r.getShoreBiomeZoom()) - .selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE))) + -> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream() + .zoom(r.getShoreBiomeZoom()) + .selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE))) ).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize); inferredStreams.put(InferredType.SHORE, shoreBiomeStream); bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(), - Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) : - engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData()) - .bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream() - .convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND) - .cache2D("bridgeStream", engine, cacheSize); + Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) : + engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData()) + .bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream() + .convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND) + .cache2D("bridgeStream", engine, cacheSize); baseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome, - Interpolated.of(a -> 0D, a -> focusBiome)) : - bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z)) - .convertAware2D(this::implode) - .cache2D("baseBiomeStream", engine, cacheSize); + Interpolated.of(a -> 0D, a -> focusBiome)) : + bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z)) + .convertAware2D(this::implode) + .cache2D("baseBiomeStream", engine, cacheSize); heightStream = ProceduralStream.of((x, z) -> { IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z); return getHeight(engine, b, x, z, engine.getSeedManager().getHeight()); @@ -173,40 +173,40 @@ public class IrisComplex implements DataProvider { roundedHeighteightStream = heightStream.round(); slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize); trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D, - b -> focusBiome)) - .cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream - .convertAware2D((h, x, z) -> - fixBiomeType(h, baseBiomeStream.get(x, z), - regionStream.get(x, z), x, z, fluidHeight)) - .cache2D("trueBiomeStream", engine, cacheSize); + b -> focusBiome)) + .cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream + .convertAware2D((h, x, z) -> + fixBiomeType(h, baseBiomeStream.get(x, z), + regionStream.get(x, z), x, z, fluidHeight)) + .cache2D("trueBiomeStream", engine, cacheSize); trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize); heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize); maxHeightStream = ProceduralStream.ofDouble((x, z) -> height); terrainSurfaceDecoration = trueBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize); terrainCeilingDecoration = trueBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize); terrainCaveSurfaceDecoration = caveBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize); terrainCaveCeilingDecoration = caveBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize); shoreSurfaceDecoration = trueBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize); seaSurfaceDecoration = trueBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize); seaFloorDecoration = trueBiomeStream - .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize); + .convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize); baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> { - UUID d = regionIDStream.get(x, z); - return new UUID(b.getLoadKey().hashCode() * 818223L, - d.hashCode()); - }) - .cache2D("", engine, cacheSize); + UUID d = regionIDStream.get(x, z); + return new UUID(b.getLoadKey().hashCode() * 818223L, + d.hashCode()); + }) + .cache2D("", engine, cacheSize); //@done } public ProceduralStream getBiomeStream(InferredType type) { - switch (type) { + switch(type) { case CAVE: return caveBiomeStream; case LAND: @@ -224,8 +224,8 @@ public class IrisComplex implements DataProvider { } private IrisRegion findRegion(IrisBiome focus, Engine engine) { - for (IrisRegion i : engine.getDimension().getAllRegions(engine)) { - if (i.getAllBiomeIds().contains(focus.getLoadKey())) { + for(IrisRegion i : engine.getDimension().getAllRegions(engine)) { + if(i.getAllBiomeIds().contains(focus.getLoadKey())) { return i; } } @@ -236,14 +236,14 @@ public class IrisComplex implements DataProvider { private IrisDecorator decorateFor(IrisBiome b, double x, double z, IrisDecorationPart part) { RNG rngc = new RNG(Cache.key(((int) x), ((int) z))); - for (IrisDecorator i : b.getDecorators()) { - if (!i.getPartOf().equals(part)) { + for(IrisDecorator i : b.getDecorators()) { + if(!i.getPartOf().equals(part)) { continue; } BlockData block = i.getBlockData(b, rngc, x, z, data); - if (block != null) { + if(block != null) { return i; } } @@ -254,19 +254,19 @@ public class IrisComplex implements DataProvider { private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight) { double sh = region.getShoreHeight(x, z); - if (height >= fluidHeight - 1 && height <= fluidHeight + sh && !biome.isShore()) { + if(height >= fluidHeight - 1 && height <= fluidHeight + sh && !biome.isShore()) { return shoreBiomeStream.get(x, z); } - if (height > fluidHeight + sh && !biome.isLand()) { + if(height > fluidHeight + sh && !biome.isLand()) { return landBiomeStream.get(x, z); } - if (height < fluidHeight && !biome.isAquatic()) { + if(height < fluidHeight && !biome.isAquatic()) { return seaBiomeStream.get(x, z); } - if (height == fluidHeight && !biome.isShore()) { + if(height == fluidHeight && !biome.isShore()) { return shoreBiomeStream.get(x, z); } @@ -274,7 +274,7 @@ public class IrisComplex implements DataProvider { } private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, KSet generators, double x, double z, long seed) { - if (generators.isEmpty()) { + if(generators.isEmpty()) { return 0; } @@ -283,12 +283,12 @@ public class IrisComplex implements DataProvider { IrisBiome bx = baseBiomeStream.get(xx, zz); double b = 0; - for (IrisGenerator gen : generators) { + for(IrisGenerator gen : generators) { b += bx.getGenLinkMax(gen.getLoadKey()); } return b; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); Iris.error("Failed to sample hi biome at " + xx + " " + zz + "..."); @@ -302,12 +302,12 @@ public class IrisComplex implements DataProvider { IrisBiome bx = baseBiomeStream.get(xx, zz); double b = 0; - for (IrisGenerator gen : generators) { + for(IrisGenerator gen : generators) { b += bx.getGenLinkMin(gen.getLoadKey()); } return b; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); Iris.error("Failed to sample lo biome at " + xx + " " + zz + "..."); @@ -318,7 +318,7 @@ public class IrisComplex implements DataProvider { double d = 0; - for (IrisGenerator i : generators) { + for(IrisGenerator i : generators) { d += M.lerp(lo, hi, i.getHeight(x, z, seed + 239945)); } @@ -328,7 +328,7 @@ public class IrisComplex implements DataProvider { private double getInterpolatedHeight(Engine engine, double x, double z, long seed) { double h = 0; - for (IrisInterpolator i : generators.keySet()) { + for(IrisInterpolator i : generators.keySet()) { h += interpolateGenerators(engine, i, generators.get(i), x, z, seed); } @@ -337,7 +337,7 @@ public class IrisComplex implements DataProvider { private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed) { return Math.min(engine.getHeight(), - Math.max(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), 0)); + Math.max(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), 0)); } private void registerGenerator(IrisGenerator cachedGenerator) { @@ -345,7 +345,7 @@ public class IrisComplex implements DataProvider { } private IrisBiome implode(IrisBiome b, Double x, Double z) { - if (b.getChildren().isEmpty()) { + if(b.getChildren().isEmpty()) { return b; } @@ -353,11 +353,11 @@ public class IrisComplex implements DataProvider { } private IrisBiome implode(IrisBiome b, Double x, Double z, int max) { - if (max < 0) { + if(max < 0) { return b; } - if (b.getChildren().isEmpty()) { + if(b.getChildren().isEmpty()) { return b; } diff --git a/src/main/java/com/volmit/iris/engine/IrisEngine.java b/src/main/java/com/volmit/iris/engine/IrisEngine.java index ae973e58b..d1c37dcca 100644 --- a/src/main/java/com/volmit/iris/engine/IrisEngine.java +++ b/src/main/java/com/volmit/iris/engine/IrisEngine.java @@ -35,7 +35,13 @@ import com.volmit.iris.engine.framework.EngineWorldManager; import com.volmit.iris.engine.framework.SeedManager; import com.volmit.iris.engine.framework.WrongEngineBroException; import com.volmit.iris.engine.mantle.EngineMantle; -import com.volmit.iris.engine.object.*; +import com.volmit.iris.engine.object.IrisBiome; +import com.volmit.iris.engine.object.IrisBiomePaletteLayer; +import com.volmit.iris.engine.object.IrisDecorator; +import com.volmit.iris.engine.object.IrisEngineData; +import com.volmit.iris.engine.object.IrisJigsawStructure; +import com.volmit.iris.engine.object.IrisObjectPlacement; +import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.engine.scripting.EngineExecutionEnvironment; import com.volmit.iris.util.atomics.AtomicRollingSequence; import com.volmit.iris.util.collection.KMap; @@ -132,18 +138,18 @@ public class IrisEngine implements Engine { } private void verifySeed() { - if (getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) { + if(getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) { target.getWorld().setRawWorldSeed(getEngineData().getSeed()); } } private void tickRandomPlayer() { - if (perSecondBudLatch.flip()) { + if(perSecondBudLatch.flip()) { buds.set(bud.get()); bud.set(0); } - if (effects != null) { + if(effects != null) { effects.tickRandomPlayer(); } } @@ -168,7 +174,7 @@ public class IrisEngine implements Engine { effects = new IrisEngineEffects(this); setupMode(); J.a(this::computeBiomeMaxes); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("FAILED TO SETUP ENGINE!"); e.printStackTrace(); } @@ -177,7 +183,7 @@ public class IrisEngine implements Engine { } private void setupMode() { - if (mode != null) { + if(mode != null) { mode.close(); } @@ -200,8 +206,8 @@ public class IrisEngine implements Engine { } private void warmupChunk(int x, int z) { - for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { + for(int i = 0; i < 16; i++) { + for(int j = 0; j < 16; j++) { int xx = x + (i << 4); int zz = z + (z << 4); getComplex().getTrueBiomeStream().get(xx, zz); @@ -237,18 +243,18 @@ public class IrisEngine implements Engine { //TODO: Method this file File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json"); - if (!f.exists()) { + if(!f.exists()) { try { f.getParentFile().mkdirs(); IO.writeAll(f, new Gson().toJson(new IrisEngineData())); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } } try { return new Gson().fromJson(IO.readAll(f), IrisEngineData.class); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -263,11 +269,11 @@ public class IrisEngine implements Engine { @Override public double getGeneratedPerSecond() { - if (perSecondLatch.flip()) { + if(perSecondLatch.flip()) { double g = generated.get() - generatedLast.get(); generatedLast.set(generated.get()); - if (g == 0) { + if(g == 0) { return 0; } @@ -285,24 +291,24 @@ public class IrisEngine implements Engine { } private void computeBiomeMaxes() { - for (IrisBiome i : getDimension().getAllBiomes(this)) { + for(IrisBiome i : getDimension().getAllBiomes(this)) { double density = 0; - for (IrisObjectPlacement j : i.getObjects()) { + for(IrisObjectPlacement j : i.getObjects()) { density += j.getDensity() * j.getChance(); } maxBiomeObjectDensity = Math.max(maxBiomeObjectDensity, density); density = 0; - for (IrisDecorator j : i.getDecorators()) { + for(IrisDecorator j : i.getDecorators()) { density += Math.max(j.getStackMax(), 1) * j.getChance(); } maxBiomeDecoratorDensity = Math.max(maxBiomeDecoratorDensity, density); density = 0; - for (IrisBiomePaletteLayer j : i.getLayers()) { + for(IrisBiomePaletteLayer j : i.getLayers()) { density++; } @@ -323,11 +329,11 @@ public class IrisEngine implements Engine { double totalWeight = 0; double wallClock = getMetrics().getTotal().getAverage(); - for (double j : timings.values()) { + for(double j : timings.values()) { totalWeight += j; } - for (String j : timings.k()) { + for(String j : timings.k()) { weights.put(getName() + "." + j, (wallClock / totalWeight) * timings.get(j)); } @@ -335,33 +341,33 @@ public class IrisEngine implements Engine { double mtotals = 0; - for (double i : totals.values()) { + for(double i : totals.values()) { mtotals += i; } - for (String i : totals.k()) { + for(String i : totals.k()) { totals.put(i, (masterWallClock / mtotals) * totals.get(i)); } double v = 0; - for (double i : weights.values()) { + for(double i : weights.values()) { v += i; } - for (String i : weights.k()) { + for(String i : weights.k()) { weights.put(i, weights.get(i) / v); } sender.sendMessage("Total: " + C.BOLD + C.WHITE + Form.duration(masterWallClock, 0)); - for (String i : totals.k()) { + for(String i : totals.k()) { sender.sendMessage(" Engine " + C.UNDERLINE + C.GREEN + i + C.RESET + ": " + C.BOLD + C.WHITE + Form.duration(totals.get(i), 0)); } sender.sendMessage("Details: "); - for (String i : weights.sortKNumber().reverse()) { + for(String i : weights.sortKNumber().reverse()) { String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "["; String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "]."; String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY; @@ -395,11 +401,11 @@ public class IrisEngine implements Engine { @Override public void recycle() { - if (!cleanLatch.flip()) { + if(!cleanLatch.flip()) { return; } - if (cleaning.get()) { + if(cleaning.get()) { cleanLatch.flipDown(); return; } @@ -410,7 +416,7 @@ public class IrisEngine implements Engine { try { getMantle().trim(); getData().getObjectLoader().clean(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Cleanup failed! Enable debug to see stacktrace."); } @@ -422,7 +428,7 @@ public class IrisEngine implements Engine { @BlockCoordinates @Override public void generate(int x, int z, Hunk vblocks, Hunk vbiomes, boolean multicore) throws WrongEngineBroException { - if (closed) { + if(closed) { throw new WrongEngineBroException(); } @@ -432,9 +438,9 @@ public class IrisEngine implements Engine { PrecisionStopwatch p = PrecisionStopwatch.start(); Hunk blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t)); - if (getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) { - for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { + if(getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) { + for(int i = 0; i < 16; i++) { + for(int j = 0; j < 16; j++) { blocks.set(i, 0, j, Material.CRYING_OBSIDIAN.createBlockData()); } } @@ -446,7 +452,7 @@ public class IrisEngine implements Engine { getMetrics().getTotal().put(p.getMilliseconds()); generated.incrementAndGet(); recycle(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); fail("Failed to generate " + x + ", " + z, e); } @@ -460,7 +466,7 @@ public class IrisEngine implements Engine { try { IO.writeAll(f, new Gson().toJson(getEngineData())); Iris.debug("Saved Engine Data"); - } catch (IOException e) { + } catch(IOException e) { Iris.error("Failed to save Engine Data"); e.printStackTrace(); } @@ -473,7 +479,7 @@ public class IrisEngine implements Engine { @Override public IrisBiome getFocus() { - if (getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) { + if(getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) { return null; } @@ -482,12 +488,13 @@ public class IrisEngine implements Engine { @Override public IrisRegion getFocusRegion() { - if (getDimension().getFocusRegion() == null || getDimension().getFocusRegion().trim().isEmpty()) { + if(getDimension().getFocusRegion() == null || getDimension().getFocusRegion().trim().isEmpty()) { return null; } return getData().getRegionLoader().load(getDimension().getFocusRegion()); } + @Override public void fail(String error, Throwable e) { failing = true; diff --git a/src/main/java/com/volmit/iris/engine/IrisEngineEffects.java b/src/main/java/com/volmit/iris/engine/IrisEngineEffects.java index 8fcc6799c..f72e8af1e 100644 --- a/src/main/java/com/volmit/iris/engine/IrisEngineEffects.java +++ b/src/main/java/com/volmit/iris/engine/IrisEngineEffects.java @@ -45,19 +45,19 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine public void updatePlayerMap() { List pr = getEngine().getWorld().getPlayers(); - if (pr == null) { + if(pr == null) { return; } - for (Player i : pr) { + for(Player i : pr) { boolean pcc = players.containsKey(i.getUniqueId()); - if (!pcc) { + if(!pcc) { players.put(i.getUniqueId(), new EnginePlayer(getEngine(), i)); } } - for (UUID i : players.k()) { - if (!pr.contains(players.get(i).getPlayer())) { + for(UUID i : players.k()) { + if(!pr.contains(players.get(i).getPlayer())) { players.remove(i); } } @@ -65,14 +65,14 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine @Override public void tickRandomPlayer() { - if (limit.tryAcquire()) { - if (M.r(0.02)) { + if(limit.tryAcquire()) { + if(M.r(0.02)) { updatePlayerMap(); limit.release(); return; } - if (players.isEmpty()) { + if(players.isEmpty()) { limit.release(); return; } @@ -81,7 +81,7 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine int max = players.size(); PrecisionStopwatch p = new PrecisionStopwatch(); - while (max-- > 0 && M.ms() - p.getMilliseconds() < limitms) { + while(max-- > 0 && M.ms() - p.getMilliseconds() < limitms) { players.v().getRandom().tick(); } diff --git a/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java b/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java index 1a1044193..dab4b2c91 100644 --- a/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java +++ b/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java @@ -89,7 +89,7 @@ public class IrisEngineMantle implements EngineMantle { private KList getAllRegions() { KList r = new KList<>(); - for (String i : getEngine().getDimension().getRegions()) { + for(String i : getEngine().getDimension().getRegions()) { r.add(getEngine().getData().getRegionLoader().load(i)); } @@ -99,7 +99,7 @@ public class IrisEngineMantle implements EngineMantle { private KList getAllBiomes() { KList r = new KList<>(); - for (IrisRegion i : getAllRegions()) { + for(IrisRegion i : getAllRegions()) { r.addAll(i.getAllBiomes(getEngine())); } @@ -107,13 +107,13 @@ public class IrisEngineMantle implements EngineMantle { } private void warn(String ob, BlockVector bv) { - if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) { + if(Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) { Iris.warn("Object " + ob + " has a large size (" + bv + ") and may increase memory usage!"); } } private void warnScaled(String ob, BlockVector bv, double ms) { - if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) { + if(Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) { Iris.warn("Object " + ob + " has a large size (" + bv + ") and may increase memory usage! (Object scaled up to " + Form.pc(ms, 2) + ")"); } } @@ -130,46 +130,46 @@ public class IrisEngineMantle implements EngineMantle { int x = xg.get(); int z = zg.get(); - if (getEngine().getDimension().isUseMantle()) { + if(getEngine().getDimension().isUseMantle()) { KList r = getAllRegions(); KList b = getAllBiomes(); - for (IrisBiome i : b) { - for (IrisObjectPlacement j : i.getObjects()) { - if (j.getScale().canScaleBeyond()) { + for(IrisBiome i : b) { + for(IrisObjectPlacement j : i.getObjects()) { + if(j.getScale().canScaleBeyond()) { scalars.put(j.getScale(), j.getPlace()); } else { objects.addAll(j.getPlace()); } } - for (IrisJigsawStructurePlacement j : i.getJigsawStructures()) { + for(IrisJigsawStructurePlacement j : i.getJigsawStructures()) { jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension()); } } - for (IrisRegion i : r) { - for (IrisObjectPlacement j : i.getObjects()) { - if (j.getScale().canScaleBeyond()) { + for(IrisRegion i : r) { + for(IrisObjectPlacement j : i.getObjects()) { + if(j.getScale().canScaleBeyond()) { scalars.put(j.getScale(), j.getPlace()); } else { objects.addAll(j.getPlace()); } } - for (IrisJigsawStructurePlacement j : i.getJigsawStructures()) { + for(IrisJigsawStructurePlacement j : i.getJigsawStructures()) { jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension()); } } - for (IrisJigsawStructurePlacement j : getEngine().getDimension().getJigsawStructures()) { + for(IrisJigsawStructurePlacement j : getEngine().getDimension().getJigsawStructures()) { jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension()); } - if (getEngine().getDimension().getStronghold() != null) { + if(getEngine().getDimension().getStronghold() != null) { try { jig = Math.max(jig, getData().getJigsawStructureLoader().load(getEngine().getDimension().getStronghold()).getMaxDimension()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -178,13 +178,13 @@ public class IrisEngineMantle implements EngineMantle { Iris.verbose("Checking sizes for " + Form.f(objects.size()) + " referenced objects."); BurstExecutor e = getEngine().getTarget().getBurster().burst(objects.size()); KMap sizeCache = new KMap<>(); - for (String i : objects) { + for(String i : objects) { e.queue(() -> { try { BlockVector bv = sizeCache.computeIfAbsent(i, (k) -> { try { return IrisObject.sampleSize(getData().getObjectLoader().findFile(i)); - } catch (IOException ex) { + } catch(IOException ex) { Iris.reportError(ex); ex.printStackTrace(); } @@ -192,35 +192,35 @@ public class IrisEngineMantle implements EngineMantle { return null; }); - if (bv == null) { + if(bv == null) { throw new RuntimeException(); } warn(i, bv); - synchronized (xg) { + synchronized(xg) { xg.getAndSet(Math.max(bv.getBlockX(), xg.get())); } - synchronized (zg) { + synchronized(zg) { zg.getAndSet(Math.max(bv.getBlockZ(), zg.get())); } - } catch (Throwable ed) { + } catch(Throwable ed) { Iris.reportError(ed); } }); } - for (Map.Entry> entry : scalars.entrySet()) { + for(Map.Entry> entry : scalars.entrySet()) { double ms = entry.getKey().getMaximumScale(); - for (String j : entry.getValue()) { + for(String j : entry.getValue()) { e.queue(() -> { try { BlockVector bv = sizeCache.computeIfAbsent(j, (k) -> { try { return IrisObject.sampleSize(getData().getObjectLoader().findFile(j)); - } catch (IOException ioException) { + } catch(IOException ioException) { Iris.reportError(ioException); ioException.printStackTrace(); } @@ -228,20 +228,20 @@ public class IrisEngineMantle implements EngineMantle { return null; }); - if (bv == null) { + if(bv == null) { throw new RuntimeException(); } warnScaled(j, bv, ms); - synchronized (xg) { + synchronized(xg) { xg.getAndSet((int) Math.max(Math.ceil(bv.getBlockX() * ms), xg.get())); } - synchronized (zg) { + synchronized(zg) { zg.getAndSet((int) Math.max(Math.ceil(bv.getBlockZ() * ms), zg.get())); } - } catch (Throwable ee) { + } catch(Throwable ee) { Iris.reportError(ee); } @@ -254,22 +254,22 @@ public class IrisEngineMantle implements EngineMantle { x = xg.get(); z = zg.get(); - for (IrisDepositGenerator i : getEngine().getDimension().getDeposits()) { + for(IrisDepositGenerator i : getEngine().getDimension().getDeposits()) { int max = i.getMaxDimension(); x = Math.max(max, x); z = Math.max(max, z); } - for (IrisRegion v : r) { - for (IrisDepositGenerator i : v.getDeposits()) { + for(IrisRegion v : r) { + for(IrisDepositGenerator i : v.getDeposits()) { int max = i.getMaxDimension(); x = Math.max(max, x); z = Math.max(max, z); } } - for (IrisBiome v : b) { - for (IrisDepositGenerator i : v.getDeposits()) { + for(IrisBiome v : b) { + for(IrisDepositGenerator i : v.getDeposits()) { int max = i.getMaxDimension(); x = Math.max(max, x); z = Math.max(max, z); @@ -299,11 +299,11 @@ public class IrisEngineMantle implements EngineMantle { m = Math.max(m, getDimension().getFluidBodies().getMaxRange(getData())); - for (IrisRegion i : getDimension().getAllRegions(getEngine())) { + for(IrisRegion i : getDimension().getAllRegions(getEngine())) { m = Math.max(m, i.getFluidBodies().getMaxRange(getData())); } - for (IrisBiome i : getDimension().getAllBiomes(getEngine())) { + for(IrisBiome i : getDimension().getAllBiomes(getEngine())) { m = Math.max(m, i.getFluidBodies().getMaxRange(getData())); } @@ -315,11 +315,11 @@ public class IrisEngineMantle implements EngineMantle { m = Math.max(m, getDimension().getCarving().getMaxRange(getData())); - for (IrisRegion i : getDimension().getAllRegions(getEngine())) { + for(IrisRegion i : getDimension().getAllRegions(getEngine())) { m = Math.max(m, i.getCarving().getMaxRange(getData())); } - for (IrisBiome i : getDimension().getAllBiomes(getEngine())) { + for(IrisBiome i : getDimension().getAllBiomes(getEngine())) { m = Math.max(m, i.getCarving().getMaxRange(getData())); } diff --git a/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java b/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java index d33fc34f8..cf81edec3 100644 --- a/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java +++ b/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java @@ -44,7 +44,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment { try { this.manager.declareBean("Iris", api, api.getClass()); this.javaScriptEngine = (JavaScriptEngine) this.manager.loadScriptingEngine("javascript"); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } @@ -62,7 +62,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment { Iris.debug("Execute Script (void) " + C.DARK_GREEN + script.getLoadKey()); try { javaScriptEngine.exec("", 0, 0, script); - } catch (BSFException e) { + } catch(BSFException e) { e.printStackTrace(); } } @@ -71,7 +71,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment { Iris.debug("Execute Script (for result) " + C.DARK_GREEN + script); try { return javaScriptEngine.eval("", 0, 0, getEngine().getData().getScriptLoader().load(script)); - } catch (BSFException e) { + } catch(BSFException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/IrisWorldManager.java b/src/main/java/com/volmit/iris/engine/IrisWorldManager.java index 9e283cdeb..028955552 100644 --- a/src/main/java/com/volmit/iris/engine/IrisWorldManager.java +++ b/src/main/java/com/volmit/iris/engine/IrisWorldManager.java @@ -118,47 +118,47 @@ public class IrisWorldManager extends EngineAssignedWorldManager { looper = new Looper() { @Override protected long loop() { - if (getEngine().isClosed() || getEngine().getCacheID() != id) { + if(getEngine().isClosed() || getEngine().getCacheID() != id) { interrupt(); } - if (!getEngine().getWorld().hasRealWorld() && clw.flip()) { + if(!getEngine().getWorld().hasRealWorld() && clw.flip()) { getEngine().getWorld().tryGetRealWorld(); } - if (!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()) { + if(!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()) { return 3000; } - if (getEngine().getWorld().hasRealWorld()) { - if (getEngine().getWorld().getPlayers().isEmpty()) { + if(getEngine().getWorld().hasRealWorld()) { + if(getEngine().getWorld().getPlayers().isEmpty()) { return 5000; } - if (chunkUpdater.flip()) { + if(chunkUpdater.flip()) { updateChunks(); } - if (getDimension().isInfiniteEnergy()) { + if(getDimension().isInfiniteEnergy()) { energy += 1000; fixEnergy(); } - if (M.ms() < charge) { + if(M.ms() < charge) { energy += 70; fixEnergy(); } - if (cln.flip()) { + if(cln.flip()) { engine.getEngineData().cleanup(getEngine()); } - if (precount != null) { + if(precount != null) { entityCount = 0; - for (Entity i : precount) { - if (i instanceof LivingEntity) { - if (!i.isDead()) { + for(Entity i : precount) { + if(i instanceof LivingEntity) { + if(!i.isDead()) { entityCount++; } } @@ -167,8 +167,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager { precount = null; } - if (energy < 650) { - if (ecl.flip()) { + if(energy < 650) { + if(ecl.flip()) { energy *= 1 + (0.02 * M.clip((1D - getEntitySaturation()), 0D, 1D)); fixEnergy(); } @@ -186,34 +186,34 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private void updateChunks() { - for (Player i : getEngine().getWorld().realWorld().getPlayers()) { + for(Player i : getEngine().getWorld().realWorld().getPlayers()) { int r = 1; Chunk c = i.getLocation().getChunk(); - for (int x = -r; x <= r; x++) { - for (int z = -r; z <= r; z++) { - if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) { + for(int x = -r; x <= r; x++) { + for(int z = -r; z <= r; z++) { + if(c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) { - if (IrisSettings.get().getWorld().isPostLoadBlockUpdates()) { + if(IrisSettings.get().getWorld().isPostLoadBlockUpdates()) { getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z)); } - if (IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) { + if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) { Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z); int finalX = c.getX() + x; int finalZ = c.getZ() + z; J.a(() -> getMantle().raiseFlag(finalX, finalZ, MantleFlag.INITIAL_SPAWNED_MARKER, - () -> { - J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200)); - getSpawnersFromMarkers(cx).forEach((block, spawners) -> { - if (spawners.isEmpty()) { - return; - } + () -> { + J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200)); + getSpawnersFromMarkers(cx).forEach((block, spawners) -> { + if(spawners.isEmpty()) { + return; + } - IrisSpawner s = new KList<>(spawners).getRandom(); - spawn(block, s, true); - }); - })); + IrisSpawner s = new KList<>(spawners).getRandom(); + spawn(block, s, true); + }); + })); } } } @@ -222,42 +222,42 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private boolean onAsyncTick() { - if (getEngine().isClosed()) { + if(getEngine().isClosed()) { return false; } actuallySpawned = 0; - if (energy < 100) { + if(energy < 100) { J.sleep(200); return false; } - if (!getEngine().getWorld().hasRealWorld()) { + if(!getEngine().getWorld().hasRealWorld()) { Iris.debug("Can't spawn. No real world"); J.sleep(5000); return false; } double epx = getEntitySaturation(); - if (epx > IrisSettings.get().getWorld().getTargetSpawnEntitiesPerChunk()) { + if(epx > IrisSettings.get().getWorld().getTargetSpawnEntitiesPerChunk()) { Iris.debug("Can't spawn. The entity per chunk ratio is at " + Form.pc(epx, 2) + " > 100% (total entities " + entityCount + ")"); J.sleep(5000); return false; } - if (cl.flip()) { + if(cl.flip()) { try { J.s(() -> precount = getEngine().getWorld().realWorld().getEntities()); - } catch (Throwable e) { + } catch(Throwable e) { close(); } } int chunkCooldownSeconds = 60; - for (Long i : chunkCooldowns.k()) { - if (M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) { + for(Long i : chunkCooldowns.k()) { + if(M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) { chunkCooldowns.remove(i); } } @@ -265,15 +265,15 @@ public class IrisWorldManager extends EngineAssignedWorldManager { int spawnBuffer = RNG.r.i(2, 12); Chunk[] cc = getEngine().getWorld().realWorld().getLoadedChunks(); - while (spawnBuffer-- > 0) { - if (cc.length == 0) { + while(spawnBuffer-- > 0) { + if(cc.length == 0) { Iris.debug("Can't spawn. No chunks!"); return false; } Chunk c = cc[RNG.r.nextInt(cc.length)]; - if (!c.isLoaded() || !Chunks.isSafe(c.getWorld(), c.getX(), c.getZ())) { + if(!c.isLoaded() || !Chunks.isSafe(c.getWorld(), c.getX(), c.getZ())) { continue; } @@ -290,55 +290,55 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private void spawnIn(Chunk c, boolean initial) { - if (getEngine().isClosed()) { + if(getEngine().isClosed()) { return; } - if (initial) { + if(initial) { energy += 1.2; } //@builder IrisBiome biome = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem() - ? getEngine().getSurfaceBiome(c) : null; + ? getEngine().getSurfaceBiome(c) : null; IrisEntitySpawn v = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem() - ? spawnRandomly(Stream.concat(getData().getSpawnerLoader() - .loadAll(getDimension().getEntitySpawners()) - .shuffleCopy(RNG.r).stream() - .filter(this::canSpawn) - .filter((i) -> i.isValid(biome)) - .flatMap((i) -> stream(i, initial)), - Stream.concat(getData().getSpawnerLoader() - .loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners()) - .shuffleCopy(RNG.r).stream().filter(this::canSpawn) - .flatMap((i) -> stream(i, initial)), - getData().getSpawnerLoader() - .loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners()) - .shuffleCopy(RNG.r).stream().filter(this::canSpawn) - .flatMap((i) -> stream(i, initial)))) - .collect(Collectors.toList())) - .popRandom(RNG.r) : null; + ? spawnRandomly(Stream.concat(getData().getSpawnerLoader() + .loadAll(getDimension().getEntitySpawners()) + .shuffleCopy(RNG.r).stream() + .filter(this::canSpawn) + .filter((i) -> i.isValid(biome)) + .flatMap((i) -> stream(i, initial)), + Stream.concat(getData().getSpawnerLoader() + .loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners()) + .shuffleCopy(RNG.r).stream().filter(this::canSpawn) + .flatMap((i) -> stream(i, initial)), + getData().getSpawnerLoader() + .loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners()) + .shuffleCopy(RNG.r).stream().filter(this::canSpawn) + .flatMap((i) -> stream(i, initial)))) + .collect(Collectors.toList())) + .popRandom(RNG.r) : null; //@done - if (IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) { + if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) { getSpawnersFromMarkers(c).forEach((block, spawners) -> { - if (spawners.isEmpty()) { + if(spawners.isEmpty()) { return; } IrisSpawner s = new KList<>(spawners).getRandom(); spawn(block, s, false); J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER, - () -> spawn(block, s, true))); + () -> spawn(block, s, true))); }); } - if (v != null && v.getReferenceSpawner() != null) { + if(v != null && v.getReferenceSpawner() != null) { int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk(); - for (Entity i : c.getEntities()) { - if (i instanceof LivingEntity) { - if (-maxEntCount <= 0) { + for(Entity i : c.getEntities()) { + if(i instanceof LivingEntity) { + if(-maxEntCount <= 0) { return; } } @@ -346,7 +346,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { try { spawn(c, v); - } catch (Throwable e) { + } catch(Throwable e) { J.s(() -> spawn(c, v)); } } @@ -355,33 +355,33 @@ public class IrisWorldManager extends EngineAssignedWorldManager { private void spawn(Chunk c, IrisEntitySpawn i) { boolean allow = true; - if (!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) { + if(!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) { allow = false; IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX(), c.getZ()); IrisEngineSpawnerCooldown sc = null; - for (IrisEngineSpawnerCooldown j : cd.getCooldowns()) { - if (j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) { + for(IrisEngineSpawnerCooldown j : cd.getCooldowns()) { + if(j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) { sc = j; break; } } - if (sc == null) { + if(sc == null) { sc = new IrisEngineSpawnerCooldown(); sc.setSpawner(i.getReferenceSpawner().getLoadKey()); cd.getCooldowns().add(sc); } - if (sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) { + if(sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) { sc.spawn(getEngine()); allow = true; } } - if (allow) { + if(allow) { int s = i.spawn(getEngine(), c, RNG.r); actuallySpawned += s; - if (s > 0) { + if(s > 0) { getCooldown(i.getReferenceSpawner()).spawn(getEngine()); energy -= s * ((i.getEnergyMultiplier() * i.getReferenceSpawner().getEnergyMultiplier() * 1)); } @@ -391,33 +391,33 @@ public class IrisWorldManager extends EngineAssignedWorldManager { private void spawn(IrisPosition c, IrisEntitySpawn i) { boolean allow = true; - if (!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) { + if(!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) { allow = false; IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX() >> 4, c.getZ() >> 4); IrisEngineSpawnerCooldown sc = null; - for (IrisEngineSpawnerCooldown j : cd.getCooldowns()) { - if (j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) { + for(IrisEngineSpawnerCooldown j : cd.getCooldowns()) { + if(j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) { sc = j; break; } } - if (sc == null) { + if(sc == null) { sc = new IrisEngineSpawnerCooldown(); sc.setSpawner(i.getReferenceSpawner().getLoadKey()); cd.getCooldowns().add(sc); } - if (sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) { + if(sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) { sc.spawn(getEngine()); allow = true; } } - if (allow) { + if(allow) { int s = i.spawn(getEngine(), c, RNG.r); actuallySpawned += s; - if (s > 0) { + if(s > 0) { getCooldown(i.getReferenceSpawner()).spawn(getEngine()); energy -= s * ((i.getEnergyMultiplier() * i.getReferenceSpawner().getEnergyMultiplier() * 1)); } @@ -425,7 +425,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private Stream stream(IrisSpawner s, boolean initial) { - for (IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) { + for(IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) { i.setReferenceSpawner(s); i.setReferenceMarker(s.getReferenceMarker()); } @@ -437,11 +437,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager { KList rarityTypes = new KList<>(); int totalRarity = 0; - for (IrisEntitySpawn i : types) { + for(IrisEntitySpawn i : types) { totalRarity += IRare.get(i); } - for (IrisEntitySpawn i : types) { + for(IrisEntitySpawn i : types) { rarityTypes.addMultiple(i, totalRarity / IRare.get(i)); } @@ -450,20 +450,20 @@ public class IrisWorldManager extends EngineAssignedWorldManager { public boolean canSpawn(IrisSpawner i) { return i.isValid(getEngine().getWorld().realWorld()) - && getCooldown(i).canSpawn(i.getMaximumRate()); + && getCooldown(i).canSpawn(i.getMaximumRate()); } private IrisEngineSpawnerCooldown getCooldown(IrisSpawner i) { IrisEngineData ed = getEngine().getEngineData(); IrisEngineSpawnerCooldown cd = null; - for (IrisEngineSpawnerCooldown j : ed.getSpawnerCooldowns()) { - if (j.getSpawner().equals(i.getLoadKey())) { + for(IrisEngineSpawnerCooldown j : ed.getSpawnerCooldowns()) { + if(j.getSpawner().equals(i.getLoadKey())) { cd = j; } } - if (cd == null) { + if(cd == null) { cd = new IrisEngineSpawnerCooldown(); cd.setSpawner(i.getLoadKey()); cd.setLastSpawn(M.ms() - i.getMaximumRate().getInterval()); @@ -485,7 +485,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { @Override public void onChunkLoad(Chunk e, boolean generated) { - if (getEngine().isClosed()) { + if(getEngine().isClosed()) { return; } @@ -495,16 +495,16 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) { - if (getEngine().isClosed()) { + if(getEngine().isClosed()) { return; } - if (spawner == null) { + if(spawner == null) { return; } KList s = initial ? spawner.getInitialSpawns() : spawner.getSpawns(); - if (s.isEmpty()) { + if(s.isEmpty()) { return; } @@ -525,7 +525,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { @Override public void teleportAsync(PlayerTeleportEvent e) { - if (IrisSettings.get().getWorld().getAsyncTeleport().isEnabled()) { + if(IrisSettings.get().getWorld().getAsyncTeleport().isEnabled()) { e.setCancelled(true); warmupAreaAsync(e.getPlayer(), e.getTo(), () -> J.s(() -> { ignoreTP.set(true); @@ -539,21 +539,21 @@ public class IrisWorldManager extends EngineAssignedWorldManager { J.a(() -> { int viewDistance = IrisSettings.get().getWorld().getAsyncTeleport().getLoadViewDistance(); KList> futures = new KList<>(); - for (int i = -viewDistance; i <= viewDistance; i++) { - for (int j = -viewDistance; j <= viewDistance; j++) { + for(int i = -viewDistance; i <= viewDistance; i++) { + for(int j = -viewDistance; j <= viewDistance; j++) { int finalJ = j; int finalI = i; - if (to.getWorld().isChunkLoaded((to.getBlockX() >> 4) + i, (to.getBlockZ() >> 4) + j)) { + if(to.getWorld().isChunkLoaded((to.getBlockX() >> 4) + i, (to.getBlockZ() >> 4) + j)) { futures.add(CompletableFuture.completedFuture(null)); continue; } futures.add(MultiBurst.burst.completeValue(() - -> PaperLib.getChunkAtAsync(to.getWorld(), - (to.getBlockX() >> 4) + finalI, - (to.getBlockZ() >> 4) + finalJ, - true, IrisSettings.get().getWorld().getAsyncTeleport().isUrgent()).get())); + -> PaperLib.getChunkAtAsync(to.getWorld(), + (to.getBlockX() >> 4) + finalI, + (to.getBlockZ() >> 4) + finalJ, + true, IrisSettings.get().getWorld().getAsyncTeleport().isUrgent()).get())); } } @@ -562,7 +562,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { public void execute(Future chunkFuture) { try { chunkFuture.get(); - } catch (InterruptedException | ExecutionException e) { + } catch(InterruptedException | ExecutionException e) { } } @@ -579,45 +579,45 @@ public class IrisWorldManager extends EngineAssignedWorldManager { Map> p = new KMap<>(); Set b = new KSet<>(); getMantle().iterateChunk(c.getX(), c.getZ(), MatterMarker.class, (x, y, z, t) -> { - if (t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling")) { + if(t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling")) { return; } IrisMarker mark = getData().getMarkerLoader().load(t.getTag()); IrisPosition pos = new IrisPosition((c.getX() << 4) + x, y, (c.getZ() << 4) + z); - if (mark.isEmptyAbove()) { + if(mark.isEmptyAbove()) { AtomicBoolean remove = new AtomicBoolean(false); try { J.sfut(() -> { - if (c.getBlock(x, y + 1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y + 2, z).getBlockData().getMaterial().isSolid()) { + if(c.getBlock(x, y + 1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y + 2, z).getBlockData().getMaterial().isSolid()) { remove.set(true); } }).get(); - } catch (InterruptedException | ExecutionException e) { + } catch(InterruptedException | ExecutionException e) { e.printStackTrace(); } - if (remove.get()) { + if(remove.get()) { b.add(pos); return; } } - for (String i : mark.getSpawners()) { + for(String i : mark.getSpawners()) { IrisSpawner m = getData().getSpawnerLoader().load(i); m.setReferenceMarker(mark); // This is so fucking incorrect its a joke //noinspection ConstantConditions - if (m != null) { + if(m != null) { p.computeIfAbsent(pos, (k) -> new KSet<>()).add(m); } } }); - for (IrisPosition i : b) { + for(IrisPosition i : b) { getEngine().getMantle().getMantle().remove(i.getX(), i.getY(), i.getZ(), MatterMarker.class); } @@ -626,19 +626,19 @@ public class IrisWorldManager extends EngineAssignedWorldManager { @Override public void onBlockBreak(BlockBreakEvent e) { - if (e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) { J.a(() -> { MatterMarker marker = getMantle().get(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class); - if (marker != null) { - if (marker.getTag().equals("cave_floor") || marker.getTag().equals("cave_ceiling")) { + if(marker != null) { + if(marker.getTag().equals("cave_floor") || marker.getTag().equals("cave_ceiling")) { return; } IrisMarker mark = getData().getMarkerLoader().load(marker.getTag()); - if (mark == null || mark.isRemoveOnChange()) { + if(mark == null || mark.isRemoveOnChange()) { getMantle().remove(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class); } } @@ -648,25 +648,25 @@ public class IrisWorldManager extends EngineAssignedWorldManager { Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i))); IrisBiome b = getEngine().getBiome(e.getBlock().getLocation()); - if (dropItems(e, d, drop, b.getBlockDrops(), b)) { + if(dropItems(e, d, drop, b.getBlockDrops(), b)) { return; } IrisRegion r = getEngine().getRegion(e.getBlock().getLocation()); - if (dropItems(e, d, drop, r.getBlockDrops(), b)) { + if(dropItems(e, d, drop, r.getBlockDrops(), b)) { return; } - for (IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) { - if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) { - if (i.isReplaceVanillaDrops()) { + for(IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) { + if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) { + if(i.isReplaceVanillaDrops()) { e.setDropItems(false); } i.fillDrops(false, d); - if (i.isSkipParents()) { + if(i.isSkipParents()) { drop.run(); return; } @@ -676,15 +676,15 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private boolean dropItems(BlockBreakEvent e, KList d, Runnable drop, KList blockDrops, IrisBiome b) { - for (IrisBlockDrops i : blockDrops) { - if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) { - if (i.isReplaceVanillaDrops()) { + for(IrisBlockDrops i : blockDrops) { + if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) { + if(i.isReplaceVanillaDrops()) { e.setDropItems(false); } i.fillDrops(false, d); - if (i.isSkipParents()) { + if(i.isSkipParents()) { drop.run(); return true; } @@ -711,7 +711,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { @Override public double getEntitySaturation() { - if (!getEngine().getWorld().hasRealWorld()) { + if(!getEngine().getWorld().hasRealWorld()) { return 1; } diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java index 70fd1bc21..ff3a21938 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java @@ -45,16 +45,16 @@ public class IrisBiomeActuator extends EngineAssignedActuator { @BlockCoordinates private boolean injectBiome(Hunk h, int x, int y, int z, Object bb) { try { - if (h instanceof BiomeGridHunkView hh) { + if(h instanceof BiomeGridHunkView hh) { ChunkGenerator.BiomeGrid g = hh.getChunk(); - if (g instanceof TerrainChunk) { + if(g instanceof TerrainChunk) { ((TerrainChunk) g).getBiomeBaseInjector().setBiome(x, y, z, bb); } else { hh.forceBiomeBaseInto(x, y, z, bb); } return true; } - } catch (Throwable e) { + } catch(Throwable e) { } @@ -67,35 +67,35 @@ public class IrisBiomeActuator extends EngineAssignedActuator { PrecisionStopwatch p = PrecisionStopwatch.start(); BurstExecutor burst = burst().burst(multicore); - for (int xf = 0; xf < h.getWidth(); xf++) { + for(int xf = 0; xf < h.getWidth(); xf++) { int finalXf = xf; burst.queue(() -> { IrisBiome ib; - for (int zf = 0; zf < h.getDepth(); zf++) { + for(int zf = 0; zf < h.getDepth(); zf++) { ib = getComplex().getTrueBiomeStream().get(finalXf + x, zf + z); int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData())); - if (ib.isCustom()) { + if(ib.isCustom()) { try { IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z); Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey() + ":" + custom.getId()); - if (biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) { + if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) { throw new RuntimeException("Cant inject biome!"); } - for (int i = 0; i < maxHeight; i++) { + for(int i = 0; i < maxHeight; i++) { injectBiome(h, finalXf, i, zf, biomeBase); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Biome v = ib.getSkyBiome(rng, x, 0, z); - for (int i = 0; i < maxHeight; i++) { + for(int i = 0; i < maxHeight; i++) { h.set(finalXf, i, zf, v); } } } else { Biome v = ib.getSkyBiome(rng, x, 0, z); - for (int i = 0; i < maxHeight; i++) { + for(int i = 0; i < maxHeight; i++) { h.set(finalXf, i, zf, v); } } diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java index 9ad02e022..56ce772a4 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java @@ -67,21 +67,21 @@ public class IrisDecorantActuator extends EngineAssignedActuator { @BlockCoordinates @Override public void onActuate(int x, int z, Hunk output, boolean multicore) { - if (!getEngine().getDimension().isDecorate()) { + if(!getEngine().getDimension().isDecorate()) { return; } PrecisionStopwatch p = PrecisionStopwatch.start(); BurstExecutor burst = burst().burst(multicore); - for (int i = 0; i < output.getWidth(); i++) { + for(int i = 0; i < output.getWidth(); i++) { int finalI = i; burst.queue(() -> { int height; int realX = Math.round(x + finalI); int realZ; IrisBiome biome, cave; - for (int j = 0; j < output.getDepth(); j++) { + for(int j = 0; j < output.getDepth(); j++) { boolean solid; int emptyFor = 0; int lastSolid = 0; @@ -90,36 +90,36 @@ public class IrisDecorantActuator extends EngineAssignedActuator { biome = getComplex().getTrueBiomeStream().get(realX, realZ); cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null; - if (biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) { + if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) { continue; } - if (height < getDimension().getFluidHeight()) { + if(height < getDimension().getFluidHeight()) { getSeaSurfaceDecorator().decorate(finalI, j, - realX, Math.round(+finalI + 1), Math.round(x + finalI - 1), - realZ, Math.round(z + j + 1), Math.round(z + j - 1), - output, biome, getDimension().getFluidHeight(), getEngine().getHeight()); + realX, Math.round(+finalI + 1), Math.round(x + finalI - 1), + realZ, Math.round(z + j + 1), Math.round(z + j - 1), + output, biome, getDimension().getFluidHeight(), getEngine().getHeight()); getSeaFloorDecorator().decorate(finalI, j, - realX, realZ, output, biome, height + 1, - getDimension().getFluidHeight() + 1); + realX, realZ, output, biome, height + 1, + getDimension().getFluidHeight() + 1); } - if (height == getDimension().getFluidHeight()) { + if(height == getDimension().getFluidHeight()) { getShoreLineDecorator().decorate(finalI, j, - realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1), - realZ, Math.round(z + j + 1), Math.round(z + j - 1), - output, biome, height, getEngine().getHeight()); + realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1), + realZ, Math.round(z + j + 1), Math.round(z + j - 1), + output, biome, height, getEngine().getHeight()); } getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, biome, height, getEngine().getHeight() - height); - if (cave != null && cave.getDecorators().isNotEmpty()) { - for (int k = height; k > 0; k--) { + if(cave != null && cave.getDecorators().isNotEmpty()) { + for(int k = height; k > 0; k--) { solid = PREDICATE_SOLID.test(output.get(finalI, k, j)); - if (solid) { - if (emptyFor > 0) { + if(solid) { + if(emptyFor > 0) { getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, cave, k, lastSolid); getCeilingDecorator().decorate(finalI, j, realX, realZ, output, cave, lastSolid - 1, emptyFor); emptyFor = 0; diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisTerrainNormalActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisTerrainNormalActuator.java index 6662f1437..1bcba78b8 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisTerrainNormalActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisTerrainNormalActuator.java @@ -21,7 +21,6 @@ package com.volmit.iris.engine.actuator; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.object.IrisBiome; -import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisRegion; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.documentation.BlockCoordinates; @@ -54,7 +53,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator PrecisionStopwatch p = PrecisionStopwatch.start(); BurstExecutor e = burst().burst(multicore); - for (int xf = 0; xf < h.getWidth(); xf++) { + for(int xf = 0; xf < h.getWidth(); xf++) { int finalXf = xf; e.queue(() -> terrainSliver(x, z, finalXf, h)); } @@ -71,10 +70,14 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator /** * This is calling 1/16th of a chunk x/z slice. It is a plane from sky to bedrock 1 thick in the x direction. * - * @param x the chunk x in blocks - * @param z the chunk z in blocks - * @param xf the current x slice - * @param h the blockdata + * @param x + * the chunk x in blocks + * @param z + * the chunk z in blocks + * @param xf + * the current x slice + * @param h + * the blockdata */ @BlockCoordinates public void terrainSliver(int x, int z, int xf, Hunk h) { @@ -83,7 +86,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator IrisBiome biome; IrisRegion region; - for (zf = 0; zf < h.getDepth(); zf++) { + for(zf = 0; zf < h.getDepth(); zf++) { realX = xf + x; realZ = zf + z; biome = getComplex().getTrueBiomeStream().get(realX, realZ); @@ -92,7 +95,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he)); // this 0 is where we are going to need to modify the world base height, the Zero, not this instance... - if (hf < 0) { + if(hf < 0) { continue; } @@ -101,28 +104,28 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator int depth, fdepth; // Fluid height and lower - for (int i = hf; i >= 0; i--) { - if (i >= h.getHeight()) { // h.getheight is terrain height + for(int i = hf; i >= 0; i--) { + if(i >= h.getHeight()) { // h.getheight is terrain height continue; } // will need to change - if (i == 0) { - if (getDimension().isBedrock()) { + if(i == 0) { + if(getDimension().isBedrock()) { h.set(xf, i, zf, BEDROCK); lastBedrock = i; continue; } } - if (i > he && i <= hf) { + if(i > he && i <= hf) { fdepth = hf - i; - if (fblocks == null) { + if(fblocks == null) { fblocks = biome.generateSeaLayers(realX, realZ, rng, hf - he, getData()); } - if (fblocks.hasIndex(fdepth)) { + if(fblocks.hasIndex(fdepth)) { h.set(xf, i, zf, fblocks.get(fdepth)); continue; } @@ -132,18 +135,18 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator } // top of surface - if (i <= he) { + if(i <= he) { depth = he - i; - if (blocks == null) { + if(blocks == null) { blocks = biome.generateLayers(getDimension(), realX, realZ, rng, - he, - he, - getData(), - getComplex()); + he, + he, + getData(), + getComplex()); } - if (blocks.hasIndex(depth)) { + if(blocks.hasIndex(depth)) { h.set(xf, i, zf, blocks.get(depth)); continue; } @@ -152,7 +155,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore; ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore; - if (ore != null) { + if(ore != null) { h.set(xf, i, zf, ore); } else { h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ)); diff --git a/src/main/java/com/volmit/iris/engine/data/cache/AtomicCache.java b/src/main/java/com/volmit/iris/engine/data/cache/AtomicCache.java index 6155b52f4..38df7a63e 100644 --- a/src/main/java/com/volmit/iris/engine/data/cache/AtomicCache.java +++ b/src/main/java/com/volmit/iris/engine/data/cache/AtomicCache.java @@ -46,7 +46,7 @@ public class AtomicCache { public void reset() { t.set(null); - if (nullSupport) { + if(nullSupport) { set.set(false); } } @@ -55,7 +55,7 @@ public class AtomicCache { return aquire(() -> { try { return t.get(); - } catch (Throwable e) { + } catch(Throwable e) { return null; } }); @@ -65,7 +65,7 @@ public class AtomicCache { return aquire(() -> { try { return t.get(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); return null; } @@ -73,18 +73,18 @@ public class AtomicCache { } public T aquire(Supplier t) { - if (this.t.get() != null) { + if(this.t.get() != null) { return this.t.get(); - } else if (nullSupport && set.get()) { + } else if(nullSupport && set.get()) { return null; } lock.lock(); - if (this.t.get() != null) { + if(this.t.get() != null) { lock.unlock(); return this.t.get(); - } else if (nullSupport && set.get()) { + } else if(nullSupport && set.get()) { lock.unlock(); return null; } @@ -92,10 +92,10 @@ public class AtomicCache { try { this.t.set(t.get()); - if (nullSupport) { + if(nullSupport) { set.set(true); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("Atomic cache failure!"); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/data/cache/Cache.java b/src/main/java/com/volmit/iris/engine/data/cache/Cache.java index c549d450a..2a39b7553 100644 --- a/src/main/java/com/volmit/iris/engine/data/cache/Cache.java +++ b/src/main/java/com/volmit/iris/engine/data/cache/Cache.java @@ -46,7 +46,7 @@ public interface Cache { idx -= (z * w * h); final int y = idx / w; final int x = idx % w; - return new int[]{x, y, z}; + return new int[] {x, y, z}; } int getId(); diff --git a/src/main/java/com/volmit/iris/engine/data/chunk/LinkedTerrainChunk.java b/src/main/java/com/volmit/iris/engine/data/chunk/LinkedTerrainChunk.java index 7bc829aa9..df0999702 100644 --- a/src/main/java/com/volmit/iris/engine/data/chunk/LinkedTerrainChunk.java +++ b/src/main/java/com/volmit/iris/engine/data/chunk/LinkedTerrainChunk.java @@ -56,7 +56,7 @@ public class LinkedTerrainChunk implements TerrainChunk { @Override public BiomeBaseInjector getBiomeBaseInjector() { - if (unsafe) { + if(unsafe) { return (a, b, c, d) -> { }; } @@ -67,7 +67,7 @@ public class LinkedTerrainChunk implements TerrainChunk { @Override public Biome getBiome(int x, int z) { - if (storage != null) { + if(storage != null) { return storage.getBiome(x, z); } @@ -77,7 +77,7 @@ public class LinkedTerrainChunk implements TerrainChunk { @Override public Biome getBiome(int x, int y, int z) { - if (storage != null) { + if(storage != null) { return storage.getBiome(x, y, z); } @@ -86,7 +86,7 @@ public class LinkedTerrainChunk implements TerrainChunk { @Override public void setBiome(int x, int z, Biome bio) { - if (storage != null) { + if(storage != null) { storage.setBiome(x, z, bio); return; } @@ -100,7 +100,7 @@ public class LinkedTerrainChunk implements TerrainChunk { @Override public void setBiome(int x, int y, int z, Biome bio) { - if (storage != null) { + if(storage != null) { storage.setBiome(x, y, z, bio); return; } @@ -190,7 +190,7 @@ public class LinkedTerrainChunk implements TerrainChunk { @Override public void inject(BiomeGrid biome) { - if (biome3D != null) { + if(biome3D != null) { biome3D.inject(biome); } } diff --git a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java index 449b85567..89e7bd947 100644 --- a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java +++ b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java @@ -81,11 +81,11 @@ public class MCATerrainChunk implements TerrainChunk { int xx = (x + ox) & 15; int zz = (z + oz) & 15; - if (y > 255 || y < 0) { + if(y > 255 || y < 0) { return; } - if (blockData == null) { + if(blockData == null) { Iris.error("NULL BD"); } @@ -94,11 +94,11 @@ public class MCATerrainChunk implements TerrainChunk { @Override public org.bukkit.block.data.BlockData getBlockData(int x, int y, int z) { - if (y > getMaxHeight()) { + if(y > getMaxHeight()) { y = getMaxHeight(); } - if (y < 0) { + if(y < 0) { y = 0; } diff --git a/src/main/java/com/volmit/iris/engine/data/chunk/TerrainChunk.java b/src/main/java/com/volmit/iris/engine/data/chunk/TerrainChunk.java index adfb30fe3..a5f8f410e 100644 --- a/src/main/java/com/volmit/iris/engine/data/chunk/TerrainChunk.java +++ b/src/main/java/com/volmit/iris/engine/data/chunk/TerrainChunk.java @@ -49,8 +49,10 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { /** * Get biome at x, z within chunk being generated * - * @param x - 0-15 - * @param z - 0-15 + * @param x + * - 0-15 + * @param z + * - 0-15 * @return Biome value * @deprecated biomes are now 3-dimensional */ @@ -61,9 +63,12 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { /** * Get biome at x, z within chunk being generated * - * @param x - 0-15 - * @param y - 0-255 - * @param z - 0-15 + * @param x + * - 0-15 + * @param y + * - 0-255 + * @param z + * - 0-15 * @return Biome value */ Biome getBiome(int x, int y, int z); @@ -71,9 +76,12 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { /** * Set biome at x, z within chunk being generated * - * @param x - 0-15 - * @param z - 0-15 - * @param bio - Biome value + * @param x + * - 0-15 + * @param z + * - 0-15 + * @param bio + * - Biome value * @deprecated biomes are now 3-dimensional */ @Deprecated @@ -82,10 +90,14 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { /** * Set biome at x, z within chunk being generated * - * @param x - 0-15 - * @param y - 0-255 - * @param z - 0-15 - * @param bio - Biome value + * @param x + * - 0-15 + * @param y + * - 0-255 + * @param z + * - 0-15 + * @param bio + * - Biome value */ void setBiome(int x, int y, int z, Biome bio); @@ -103,11 +115,15 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { *

* Setting blocks outside the chunk's bounds does nothing. * - * @param x the x location in the chunk from 0-15 inclusive - * @param y the y location in the chunk from 0 (inclusive) - maxHeight - * (exclusive) - * @param z the z location in the chunk from 0-15 inclusive - * @param blockData the type to set the block to + * @param x + * the x location in the chunk from 0-15 inclusive + * @param y + * the y location in the chunk from 0 (inclusive) - maxHeight + * (exclusive) + * @param z + * the z location in the chunk from 0-15 inclusive + * @param blockData + * the type to set the block to */ void setBlock(int x, int y, int z, BlockData blockData); @@ -116,10 +132,13 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { *

* Getting blocks outside the chunk's bounds returns air. * - * @param x the x location in the chunk from 0-15 inclusive - * @param y the y location in the chunk from 0 (inclusive) - maxHeight - * (exclusive) - * @param z the z location in the chunk from 0-15 inclusive + * @param x + * the x location in the chunk from 0-15 inclusive + * @param y + * the y location in the chunk from 0 (inclusive) - maxHeight + * (exclusive) + * @param z + * the z location in the chunk from 0-15 inclusive * @return the data of the block or the BlockData for air if x, y or z are * outside the chunk's bounds */ diff --git a/src/main/java/com/volmit/iris/engine/data/io/Deserializer.java b/src/main/java/com/volmit/iris/engine/data/io/Deserializer.java index 183886689..d5174b72d 100644 --- a/src/main/java/com/volmit/iris/engine/data/io/Deserializer.java +++ b/src/main/java/com/volmit/iris/engine/data/io/Deserializer.java @@ -31,7 +31,7 @@ public interface Deserializer { T fromStream(InputStream stream) throws IOException; default T fromFile(File file) throws IOException { - try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { + try(BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { return fromStream(bis); } } @@ -42,8 +42,8 @@ public interface Deserializer { } default T fromResource(Class clazz, String path) throws IOException { - try (InputStream stream = clazz.getClassLoader().getResourceAsStream(path)) { - if (stream == null) { + try(InputStream stream = clazz.getClassLoader().getResourceAsStream(path)) { + if(stream == null) { throw new IOException("resource \"" + path + "\" not found"); } return fromStream(stream); @@ -51,7 +51,7 @@ public interface Deserializer { } default T fromURL(URL url) throws IOException { - try (InputStream stream = url.openStream()) { + try(InputStream stream = url.openStream()) { return fromStream(stream); } } diff --git a/src/main/java/com/volmit/iris/engine/data/io/MaxDepthIO.java b/src/main/java/com/volmit/iris/engine/data/io/MaxDepthIO.java index 2146275d4..0f95dac97 100644 --- a/src/main/java/com/volmit/iris/engine/data/io/MaxDepthIO.java +++ b/src/main/java/com/volmit/iris/engine/data/io/MaxDepthIO.java @@ -21,9 +21,9 @@ package com.volmit.iris.engine.data.io; public interface MaxDepthIO { default int decrementMaxDepth(int maxDepth) { - if (maxDepth < 0) { + if(maxDepth < 0) { throw new IllegalArgumentException("negative maximum depth is not allowed"); - } else if (maxDepth == 0) { + } else if(maxDepth == 0) { throw new MaxDepthReachedException("reached maximum depth of NBT structure"); } return --maxDepth; diff --git a/src/main/java/com/volmit/iris/engine/data/io/Serializer.java b/src/main/java/com/volmit/iris/engine/data/io/Serializer.java index 0e0102282..f9dd08e9e 100644 --- a/src/main/java/com/volmit/iris/engine/data/io/Serializer.java +++ b/src/main/java/com/volmit/iris/engine/data/io/Serializer.java @@ -30,7 +30,7 @@ public interface Serializer { void toStream(T object, OutputStream out) throws IOException; default void toFile(T object, File file) throws IOException { - try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) { + try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) { toStream(object, bos); } } diff --git a/src/main/java/com/volmit/iris/engine/data/io/StringDeserializer.java b/src/main/java/com/volmit/iris/engine/data/io/StringDeserializer.java index 59321afba..156c81e3b 100644 --- a/src/main/java/com/volmit/iris/engine/data/io/StringDeserializer.java +++ b/src/main/java/com/volmit/iris/engine/data/io/StringDeserializer.java @@ -36,14 +36,14 @@ public interface StringDeserializer extends Deserializer { @Override default T fromStream(InputStream stream) throws IOException { - try (Reader reader = new InputStreamReader(stream)) { + try(Reader reader = new InputStreamReader(stream)) { return fromReader(reader); } } @Override default T fromFile(File file) throws IOException { - try (Reader reader = new FileReader(file)) { + try(Reader reader = new FileReader(file)) { return fromReader(reader); } } diff --git a/src/main/java/com/volmit/iris/engine/data/io/StringSerializer.java b/src/main/java/com/volmit/iris/engine/data/io/StringSerializer.java index c1a482017..b4b8ef455 100644 --- a/src/main/java/com/volmit/iris/engine/data/io/StringSerializer.java +++ b/src/main/java/com/volmit/iris/engine/data/io/StringSerializer.java @@ -46,7 +46,7 @@ public interface StringSerializer extends Serializer { @Override default void toFile(T object, File file) throws IOException { - try (Writer writer = new FileWriter(file)) { + try(Writer writer = new FileWriter(file)) { toWriter(object, writer); } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java index b1a4a27f1..abe0d3e24 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java @@ -40,49 +40,49 @@ public class IrisCeilingDecorator extends IrisEngineDecorator { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk data, IrisBiome biome, int height, int max) { IrisDecorator decorator = getDecorator(biome, realX, realZ); - if (decorator != null) { - if (!decorator.isStacking()) { - if (height >= 0 || height < getEngine().getHeight()) { + if(decorator != null) { + if(!decorator.isStacking()) { + if(height >= 0 || height < getEngine().getHeight()) { data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - if (decorator.isScaleStack()) { + if(decorator.isScaleStack()) { stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack()); } else { stack = Math.min(max, stack); } - if (stack == 1) { + if(stack == 1) { data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } - for (int i = 0; i < stack; i++) { + for(int i = 0; i < stack; i++) { int h = height - i; - if (h < getEngine().getMinHeight()) { + if(h < getEngine().getMinHeight()) { continue; } double threshold = (((double) i) / (double) (stack - 1)); BlockData bd = threshold >= decorator.getTopThreshold() ? - decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : - decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()); + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()); - if (bd instanceof PointedDripstone) { + if(bd instanceof PointedDripstone) { PointedDripstone.Thickness th = PointedDripstone.Thickness.BASE; - if (stack == 2) { + if(stack == 2) { th = PointedDripstone.Thickness.FRUSTUM; - if (i == stack - 1) { + if(i == stack - 1) { th = PointedDripstone.Thickness.TIP; } } else { - if (i == stack - 1) { + if(i == stack - 1) { th = PointedDripstone.Thickness.TIP; - } else if (i == stack - 2) { + } else if(i == stack - 2) { th = PointedDripstone.Thickness.FRUSTUM; } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisEngineDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisEngineDecorator.java index 9ada1f848..d5e14fcfd 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisEngineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisEngineDecorator.java @@ -48,18 +48,18 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem KList v = new KList<>(); RNG rng = new RNG(Cache.key((int) realX, (int) realZ)); - for (IrisDecorator i : biome.getDecorators()) { + for(IrisDecorator i : biome.getDecorators()) { try { - if (i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null) { + if(i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null) { v.add(i); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("PART OF: " + biome.getLoadFile().getAbsolutePath() + " HAS AN INVALID DECORATOR near 'partOf'!!!"); } } - if (v.isNotEmpty()) { + if(v.isNotEmpty()) { return v.get(rng.nextInt(v.size())); } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java index 3962ce30f..13b580e36 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java @@ -37,33 +37,33 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk data, IrisBiome biome, int height, int max) { IrisDecorator decorator = getDecorator(biome, realX, realZ); - if (decorator != null) { - if (!decorator.isStacking()) { - if (height >= 0 || height < getEngine().getHeight()) { + if(decorator != null) { + if(!decorator.isStacking()) { + if(height >= 0 || height < getEngine().getHeight()) { data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - if (decorator.isScaleStack()) { + if(decorator.isScaleStack()) { int maxStack = max - height; stack = (int) Math.ceil((double) maxStack * ((double) stack / 100)); } else stack = Math.min(stack, max - height); - if (stack == 1) { + if(stack == 1) { data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } - for (int i = 0; i < stack; i++) { + for(int i = 0; i < stack; i++) { int h = height + i; - if (h > max || h > getEngine().getHeight()) { + if(h > max || h > getEngine().getHeight()) { continue; } double threshold = ((double) i) / (stack - 1); data.set(x, h, z, threshold >= decorator.getTopThreshold() ? - decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : - decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java index fd2006b18..35863835c 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java @@ -37,33 +37,33 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk data, IrisBiome biome, int height, int max) { IrisDecorator decorator = getDecorator(biome, realX, realZ); - if (decorator != null) { - if (!decorator.isStacking()) { - if (height >= 0 || height < getEngine().getHeight()) { + if(decorator != null) { + if(!decorator.isStacking()) { + if(height >= 0 || height < getEngine().getHeight()) { data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - if (decorator.isScaleStack()) { + if(decorator.isScaleStack()) { int maxStack = max - height; stack = (int) Math.ceil((double) maxStack * ((double) stack / 100)); } - if (stack == 1) { + if(stack == 1) { data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } - for (int i = 0; i < stack; i++) { + for(int i = 0; i < stack; i++) { int h = height + i; - if (h >= max || h >= getEngine().getHeight()) { + if(h >= max || h >= getEngine().getHeight()) { continue; } double threshold = ((double) i) / (stack - 1); data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ? - decorator.getBlockDataForTop(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()) : - decorator.getBlockData100(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData())); + decorator.getBlockDataForTop(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java index 3ad2f1b63..b1f9b1d2e 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java @@ -36,35 +36,35 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { @Override public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk data, IrisBiome biome, int height, int max) { - if (height == getDimension().getFluidHeight()) { - if (Math.round(getComplex().getHeightStream().get(realX1, realZ)) < getComplex().getFluidHeight() || - Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() || - Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() || - Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight() + if(height == getDimension().getFluidHeight()) { + if(Math.round(getComplex().getHeightStream().get(realX1, realZ)) < getComplex().getFluidHeight() || + Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() || + Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() || + Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight() ) { IrisDecorator decorator = getDecorator(biome, realX, realZ); - if (decorator != null) { - if (!decorator.isStacking()) { + if(decorator != null) { + if(!decorator.isStacking()) { data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - if (decorator.isScaleStack()) { + if(decorator.isScaleStack()) { int maxStack = max - height; stack = (int) Math.ceil((double) maxStack * ((double) stack / 100)); } else stack = Math.min(max - height, stack); - if (stack == 1) { + if(stack == 1) { data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } - for (int i = 0; i < stack; i++) { + for(int i = 0; i < stack; i++) { int h = height + i; double threshold = ((double) i) / (stack - 1); data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ? - decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : - decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java index 0ecee8513..6cd3f856d 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java @@ -41,7 +41,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { @BlockCoordinates @Override public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk data, IrisBiome biome, int height, int max) { - if (biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) { + if(biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) { return; } @@ -50,22 +50,22 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { bdx = data.get(x, height, z); boolean underwater = height < getDimension().getFluidHeight(); - if (decorator != null) { - if (!decorator.isStacking()) { + if(decorator != null) { + if(!decorator.isStacking()) { bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()); - if (!underwater) { - if (!canGoOn(bd, bdx)) { + if(!underwater) { + if(!canGoOn(bd, bdx)) { return; } } - if (bd instanceof Bisected) { + if(bd instanceof Bisected) { bd = bd.clone(); ((Bisected) bd).setHalf(Bisected.Half.TOP); try { data.set(x, height + 2, z, bd); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } bd = bd.clone(); @@ -75,55 +75,55 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { data.set(x, height + 1, z, bd); } else { - if (height < getDimension().getFluidHeight()) { + if(height < getDimension().getFluidHeight()) { max = getDimension().getFluidHeight(); } int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - if (decorator.isScaleStack()) { + if(decorator.isScaleStack()) { stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack()); } else { stack = Math.min(max, stack); } - if (stack == 1) { + if(stack == 1) { data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } - for (int i = 0; i < stack; i++) { + for(int i = 0; i < stack; i++) { int h = height + i; double threshold = ((double) i) / (stack - 1); bd = threshold >= decorator.getTopThreshold() ? - decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : - decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()); + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()); - if (bd == null) { + if(bd == null) { break; } - if (i == 0 && !underwater && !canGoOn(bd, bdx)) { + if(i == 0 && !underwater && !canGoOn(bd, bdx)) { break; } - if (underwater && height + 1 + i > getDimension().getFluidHeight()) { + if(underwater && height + 1 + i > getDimension().getFluidHeight()) { break; } - if (bd instanceof PointedDripstone) { + if(bd instanceof PointedDripstone) { PointedDripstone.Thickness th = PointedDripstone.Thickness.BASE; - if (stack == 2) { + if(stack == 2) { th = PointedDripstone.Thickness.FRUSTUM; - if (i == stack - 1) { + if(i == stack - 1) { th = PointedDripstone.Thickness.TIP; } } else { - if (i == stack - 1) { + if(i == stack - 1) { th = PointedDripstone.Thickness.TIP; - } else if (i == stack - 2) { + } else if(i == stack - 2) { th = PointedDripstone.Thickness.FRUSTUM; } } diff --git a/src/main/java/com/volmit/iris/engine/framework/Engine.java b/src/main/java/com/volmit/iris/engine/framework/Engine.java index daf7b79d0..177ce0e4d 100644 --- a/src/main/java/com/volmit/iris/engine/framework/Engine.java +++ b/src/main/java/com/volmit/iris/engine/framework/Engine.java @@ -145,7 +145,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat @BlockCoordinates default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException { - generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()), multicore); + generate(x, z, Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()), multicore); } @BlockCoordinates @@ -210,10 +210,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat default IrisBiome getCaveOrMantleBiome(int x, int y, int z) { MatterCavern m = getMantle().getMantle().get(x, y, z, MatterCavern.class); - if (m != null && m.getCustomBiome() != null && !m.getCustomBiome().isEmpty()) { + if(m != null && m.getCustomBiome() != null && !m.getCustomBiome().isEmpty()) { IrisBiome biome = getData().getBiomeLoader().load(m.getCustomBiome()); - if (biome != null) { + if(biome != null) { return biome; } } @@ -250,11 +250,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat @BlockCoordinates @Override default void catchBlockUpdates(int x, int y, int z, BlockData data) { - if (data == null) { + if(data == null) { return; } - if (B.isUpdatable(data)) { + if(B.isUpdatable(data)) { getMantle().updateBlock(x, y, z); } } @@ -269,38 +269,38 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat @ChunkCoordinates @Override default void updateChunk(Chunk c) { - if (c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() + 1) - && c.getWorld().isChunkLoaded(c.getX(), c.getZ() + 1) - && c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ()) - && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() - 1) - && c.getWorld().isChunkLoaded(c.getX(), c.getZ() - 1) - && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ()) - && c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1) - && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) { + if(c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() + 1) + && c.getWorld().isChunkLoaded(c.getX(), c.getZ() + 1) + && c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ()) + && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() - 1) + && c.getWorld().isChunkLoaded(c.getX(), c.getZ() - 1) + && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ()) + && c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1) + && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) { getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> { PrecisionStopwatch p = PrecisionStopwatch.start(); KMap updates = new KMap<>(); RNG r = new RNG(Cache.key(c.getX(), c.getZ())); getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, v) -> { - if (!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) { + if(!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) { return; } boolean u = false; - if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) { + if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) { u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) { + } else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) { u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) { + } else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) { u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) { + } else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) { u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) { + } else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) { u = true; } - if (u) { + if(u) { updates.compute(Cache.key(x & 15, z & 15), (k, vv) -> { - if (vv != null) { + if(vv != null) { return Math.max(vv, y); } @@ -311,11 +311,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat updates.forEach((k, v) -> update(Cache.keyX(k), v, Cache.keyZ(k), c, r)); getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterUpdate.class, (x, y, z, v) -> { - if (v != null && v.isUpdate()) { + if(v != null && v.isUpdate()) { int vx = x & 15; int vz = z & 15; update(x, y, z, c, new RNG(Cache.key(c.getX(), c.getZ()))); - if (vx > 0 && vx < 15 && vz > 0 && vz < 15) { + if(vx > 0 && vx < 15 && vz > 0 && vz < 15) { updateLighting(x, y, z, c); } } @@ -331,11 +331,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat Block block = c.getBlock(x, y, z); BlockData data = block.getBlockData(); - if (B.isLit(data)) { + if(B.isLit(data)) { try { block.setType(Material.AIR, false); block.setBlockData(data, true); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); } } @@ -347,21 +347,21 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat Block block = c.getBlock(x, y, z); BlockData data = block.getBlockData(); blockUpdatedMetric(); - if (B.isStorage(data)) { + if(B.isStorage(data)) { RNG rx = rf.nextParallelRNG(BlockPosition.toLong(x, y, z)); InventorySlotType slot = null; - if (B.isStorageChest(data)) { + if(B.isStorageChest(data)) { slot = InventorySlotType.STORAGE; } - if (slot != null) { + if(slot != null) { KList tables = getLootTables(rx, block); try { InventoryHolder m = (InventoryHolder) block.getState(); addItems(false, m.getInventory(), rx, tables, slot, x, y, z, 15); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } @@ -379,12 +379,12 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat boolean packedFull = false; splitting: - for (int i = 0; i < nitems.length; i++) { + for(int i = 0; i < nitems.length; i++) { ItemStack is = nitems[i]; - if (is != null && is.getAmount() > 1 && !packedFull) { - for (int j = 0; j < nitems.length; j++) { - if (nitems[j] == null) { + if(is != null && is.getAmount() > 1 && !packedFull) { + for(int j = 0; j < nitems.length; j++) { + if(nitems[j] == null) { int take = rng.nextInt(is.getAmount()); take = take == 0 ? 1 : take; is.setAmount(is.getAmount() - take); @@ -398,11 +398,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } } - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) { try { Arrays.parallelSort(nitems, (a, b) -> rng.nextInt()); break; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -413,7 +413,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat @Override default void injectTables(KList list, IrisLootReference r) { - if (r.getMode().equals(IrisLootMode.CLEAR) || r.getMode().equals(IrisLootMode.REPLACE)) { + if(r.getMode().equals(IrisLootMode.CLEAR) || r.getMode().equals(IrisLootMode.REPLACE)) { list.clear(); } @@ -427,11 +427,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat int rz = b.getZ(); double he = getComplex().getHeightStream().get(rx, rz); PlacedObject po = getObjectPlacement(rx, b.getY(), rz); - if (po != null && po.getPlacement() != null) { + if(po != null && po.getPlacement() != null) { - if (B.isStorageChest(b.getBlockData())) { + if(B.isStorageChest(b.getBlockData())) { IrisLootTable table = po.getPlacement().getTable(b.getBlockData(), getData()); - if (table != null) { + if(table != null) { return new KList<>(table); } } @@ -446,14 +446,14 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat injectTables(tables, biomeSurface.getLoot()); injectTables(tables, biomeUnder.getLoot()); - if (tables.isNotEmpty()) { + if(tables.isNotEmpty()) { int target = (int) Math.round(tables.size() * multiplier); - while (tables.size() < target && tables.isNotEmpty()) { + while(tables.size() < target && tables.isNotEmpty()) { tables.add(tables.get(rng.i(tables.size() - 1))); } - while (tables.size() > target && tables.isNotEmpty()) { + while(tables.size() > target && tables.isNotEmpty()) { tables.remove(rng.i(tables.size() - 1)); } } @@ -466,29 +466,29 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat KList items = new KList<>(); int b = 4; - for (IrisLootTable i : tables) { + for(IrisLootTable i : tables) { b++; items.addAll(i.getLoot(debug, items.isEmpty(), rng, slot, x, y, z, b + b, mgf + b)); } - if (PaperLib.isPaper() && getWorld().hasRealWorld()) { + if(PaperLib.isPaper() && getWorld().hasRealWorld()) { PaperLib.getChunkAtAsync(getWorld().realWorld(), x >> 4, z >> 4).thenAccept((c) -> { Runnable r = () -> { - for (ItemStack i : items) { + for(ItemStack i : items) { inv.addItem(i); } scramble(inv, rng); }; - if (Bukkit.isPrimaryThread()) { + if(Bukkit.isPrimaryThread()) { r.run(); } else { J.s(r); } }); } else { - for (ItemStack i : items) { + for(ItemStack i : items) { inv.addItem(i); } @@ -548,17 +548,17 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat AtomicReference r = new AtomicReference<>(); BurstExecutor b = burst().burst(); - while (M.ms() - time.get() < timeout && r.get() == null) { + while(M.ms() - time.get() < timeout && r.get() == null) { b.queue(() -> { - for (int i = 0; i < 1000; i++) { - if (M.ms() - time.get() > timeout) { + for(int i = 0; i < 1000; i++) { + if(M.ms() - time.get() > timeout) { return; } int x = RNG.r.i(-29999970, 29999970); int z = RNG.r.i(-29999970, 29999970); checked.incrementAndGet(); - if (matcher.apply(stream.get(x, z), find)) { + if(matcher.apply(stream.get(x, z), find)) { r.set(new IrisPosition(x, 120, z)); time.set(0); } @@ -570,7 +570,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } default IrisPosition lookForBiome(IrisBiome biome, long timeout, Consumer triesc) { - if (!getWorld().hasRealWorld()) { + if(!getWorld().hasRealWorld()) { Iris.error("Cannot GOTO without a bound world (headless mode)"); return null; } @@ -579,7 +579,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat long s = M.ms(); int cpus = (Runtime.getRuntime().availableProcessors()); - if (!getDimension().getAllBiomes(this).contains(biome)) { + if(!getDimension().getAllBiomes(this).contains(biome)) { return null; } @@ -587,50 +587,50 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat AtomicBoolean found = new AtomicBoolean(false); AtomicBoolean running = new AtomicBoolean(true); AtomicReference location = new AtomicReference<>(); - for (int i = 0; i < cpus; i++) { + for(int i = 0; i < cpus; i++) { J.a(() -> { try { Engine e; IrisBiome b; int x, z; - while (!found.get() && running.get()) { + while(!found.get() && running.get()) { try { x = RNG.r.i(-29999970, 29999970); z = RNG.r.i(-29999970, 29999970); b = getSurfaceBiome(x, z); - if (b != null && b.getLoadKey() == null) { + if(b != null && b.getLoadKey() == null) { continue; } - if (b != null && b.getLoadKey().equals(biome.getLoadKey())) { + if(b != null && b.getLoadKey().equals(biome.getLoadKey())) { found.lazySet(true); location.lazySet(new IrisPosition(x, getHeight(x, z), z)); } tries.getAndIncrement(); - } catch (Throwable ex) { + } catch(Throwable ex) { Iris.reportError(ex); ex.printStackTrace(); return; } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } }); } - while (!found.get() || location.get() == null) { + while(!found.get() || location.get() == null) { J.sleep(50); - if (cl.flip()) { + if(cl.flip()) { triesc.accept(tries.get()); } - if (M.ms() - s > timeout) { + if(M.ms() - s > timeout) { running.set(false); return null; } @@ -641,7 +641,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } default IrisPosition lookForRegion(IrisRegion reg, long timeout, Consumer triesc) { - if (getWorld().hasRealWorld()) { + if(getWorld().hasRealWorld()) { Iris.error("Cannot GOTO without a bound world (headless mode)"); return null; } @@ -650,7 +650,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat long s = M.ms(); int cpus = (Runtime.getRuntime().availableProcessors()); - if (!getDimension().getRegions().contains(reg.getLoadKey())) { + if(!getDimension().getRegions().contains(reg.getLoadKey())) { return null; } @@ -659,25 +659,25 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat AtomicBoolean running = new AtomicBoolean(true); AtomicReference location = new AtomicReference<>(); - for (int i = 0; i < cpus; i++) { + for(int i = 0; i < cpus; i++) { J.a(() -> { Engine e; IrisRegion b; int x, z; - while (!found.get() && running.get()) { + while(!found.get() && running.get()) { try { x = RNG.r.i(-29999970, 29999970); z = RNG.r.i(-29999970, 29999970); b = getRegion(x, z); - if (b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey())) { + if(b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey())) { found.lazySet(true); location.lazySet(new IrisPosition(x, getHeight(x, z), z)); } tries.getAndIncrement(); - } catch (Throwable xe) { + } catch(Throwable xe) { Iris.reportError(xe); xe.printStackTrace(); return; @@ -686,14 +686,14 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat }); } - while (!found.get() || location.get() != null) { + while(!found.get() || location.get() != null) { J.sleep(50); - if (cl.flip()) { + if(cl.flip()) { triesc.accept(tries.get()); } - if (M.ms() - s > timeout) { + if(M.ms() - s > timeout) { triesc.accept(tries.get()); running.set(false); return null; @@ -714,7 +714,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat boolean isStudio(); default IrisBiome getBiome(int x, int y, int z) { - if (y <= getHeight(x, z) - 2) { + if(y <= getHeight(x, z) - 2) { return getCaveBiome(x, z); } @@ -722,7 +722,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } default IrisBiome getBiomeOrMantle(int x, int y, int z) { - if (y <= getHeight(x, z) - 2) { + if(y <= getHeight(x, z) - 2) { return getCaveOrMantleBiome(x, y, z); } @@ -732,7 +732,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat default String getObjectPlacementKey(int x, int y, int z) { PlacedObject o = getObjectPlacement(x, y, z); - if (o != null && o.getObject() != null) { + if(o != null && o.getObject() != null) { return o.getObject().getLoadKey() + "@" + o.getId(); } @@ -742,7 +742,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat default PlacedObject getObjectPlacement(int x, int y, int z) { String objectAt = getMantle().getMantle().get(x, y, z, String.class); - if (objectAt == null || objectAt.isEmpty()) { + if(objectAt == null || objectAt.isEmpty()) { return null; } @@ -751,16 +751,16 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat int id = Integer.parseInt(v[1]); IrisRegion region = getRegion(x, z); - for (IrisObjectPlacement i : region.getObjects()) { - if (i.getPlace().contains(object)) { + for(IrisObjectPlacement i : region.getObjects()) { + if(i.getPlace().contains(object)) { return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z); } } IrisBiome biome = getBiome(x, y, z); - for (IrisObjectPlacement i : biome.getObjects()) { - if (i.getPlace().contains(object)) { + for(IrisObjectPlacement i : biome.getObjects()) { + if(i.getPlace().contains(object)) { return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z); } } @@ -777,16 +777,16 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat default void gotoBiome(IrisBiome biome, Player player) { Set regionKeys = getDimension() - .getAllRegions(this).stream() - .filter((i) -> i.getAllBiomes(this).contains(biome)) - .map(IrisRegistrant::getLoadKey) - .collect(Collectors.toSet()); + .getAllRegions(this).stream() + .filter((i) -> i.getAllBiomes(this).contains(biome)) + .map(IrisRegistrant::getLoadKey) + .collect(Collectors.toSet()); Locator lb = Locator.surfaceBiome(biome.getLoadKey()); Locator locator = (engine, chunk) - -> regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey()) - && lb.matches(engine, chunk); + -> regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey()) + && lb.matches(engine, chunk); - if (!regionKeys.isEmpty()) { + if(!regionKeys.isEmpty()) { locator.find(player); } else { player.sendMessage(C.RED + biome.getName() + " is not in any defined regions!"); @@ -794,10 +794,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } default void gotoJigsaw(IrisJigsawStructure s, Player player) { - if (s.getLoadKey().equals(getDimension().getStronghold())) { + if(s.getLoadKey().equals(getDimension().getStronghold())) { KList p = getDimension().getStrongholds(getSeedManager().getSpawn()); - if (p.isEmpty()) { + if(p.isEmpty()) { player.sendMessage(C.GOLD + "No strongholds in world."); } @@ -807,19 +807,19 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat Iris.debug("Ps: " + p.size()); - for (Position2 i : p) { + for(Position2 i : p) { Iris.debug("- " + i.getX() + " " + i.getZ()); } - for (Position2 i : p) { + for(Position2 i : p) { double dx = i.distance(px); - if (dx < d) { + if(dx < d) { d = dx; pr = i; } } - if (pr != null) { + if(pr != null) { Location ll = new Location(player.getWorld(), pr.getX(), 40, pr.getZ()); J.s(() -> player.teleport(ll)); } @@ -827,36 +827,36 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat return; } - if (getDimension().getJigsawStructures().stream() - .map(IrisJigsawStructurePlacement::getStructure) - .collect(Collectors.toSet()).contains(s.getLoadKey())) { + if(getDimension().getJigsawStructures().stream() + .map(IrisJigsawStructurePlacement::getStructure) + .collect(Collectors.toSet()).contains(s.getLoadKey())) { Locator.jigsawStructure(s.getLoadKey()).find(player); } else { Set biomeKeys = getDimension().getAllBiomes(this).stream() - .filter((i) -> i.getJigsawStructures() - .stream() - .anyMatch((j) -> j.getStructure().equals(s.getLoadKey()))) - .map(IrisRegistrant::getLoadKey) - .collect(Collectors.toSet()); + .filter((i) -> i.getJigsawStructures() + .stream() + .anyMatch((j) -> j.getStructure().equals(s.getLoadKey()))) + .map(IrisRegistrant::getLoadKey) + .collect(Collectors.toSet()); Set regionKeys = getDimension().getAllRegions(this).stream() - .filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains) - || i.getJigsawStructures() - .stream() - .anyMatch((j) -> j.getStructure().equals(s.getLoadKey()))) - .map(IrisRegistrant::getLoadKey) - .collect(Collectors.toSet()); + .filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains) + || i.getJigsawStructures() + .stream() + .anyMatch((j) -> j.getStructure().equals(s.getLoadKey()))) + .map(IrisRegistrant::getLoadKey) + .collect(Collectors.toSet()); Locator sl = Locator.jigsawStructure(s.getLoadKey()); Locator locator = (engine, chunk) -> { - if (biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { + if(biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { return sl.matches(engine, chunk); - } else if (regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { + } else if(regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { return sl.matches(engine, chunk); } return false; }; - if (!regionKeys.isEmpty()) { + if(!regionKeys.isEmpty()) { locator.find(player); } else { player.sendMessage(C.RED + s.getLoadKey() + " is not in any defined regions, biomes or dimensions!"); @@ -867,27 +867,27 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat default void gotoObject(String s, Player player) { Set biomeKeys = getDimension().getAllBiomes(this).stream() - .filter((i) -> i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s))) - .map(IrisRegistrant::getLoadKey) - .collect(Collectors.toSet()); + .filter((i) -> i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s))) + .map(IrisRegistrant::getLoadKey) + .collect(Collectors.toSet()); Set regionKeys = getDimension().getAllRegions(this).stream() - .filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains) - || i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s))) - .map(IrisRegistrant::getLoadKey) - .collect(Collectors.toSet()); + .filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains) + || i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s))) + .map(IrisRegistrant::getLoadKey) + .collect(Collectors.toSet()); Locator sl = Locator.object(s); Locator locator = (engine, chunk) -> { - if (biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { + if(biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { return sl.matches(engine, chunk); - } else if (regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { + } else if(regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) { return sl.matches(engine, chunk); } return false; }; - if (!regionKeys.isEmpty()) { + if(!regionKeys.isEmpty()) { locator.find(player); } else { player.sendMessage(C.RED + s + " is not in any defined regions or biomes!"); @@ -895,7 +895,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } default void gotoRegion(IrisRegion r, Player player) { - if (!getDimension().getAllRegions(this).contains(r)) { + if(!getDimension().getAllRegions(this).contains(r)) { player.sendMessage(C.RED + r.getName() + " is not defined in the dimension!"); return; } @@ -904,7 +904,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat } default void cleanupMantleChunk(int x, int z) { - if (IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) { + if(IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) { J.a(() -> getMantle().cleanupChunk(x, z)); } } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineAssignedModifier.java b/src/main/java/com/volmit/iris/engine/framework/EngineAssignedModifier.java index 543a3739f..170bdac01 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineAssignedModifier.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineAssignedModifier.java @@ -35,7 +35,7 @@ public abstract class EngineAssignedModifier extends EngineAssignedComponent public void modify(int x, int z, Hunk output, boolean multicore) { try { onModify(x, z, output, multicore); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("Modifier Failure: " + getName()); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java b/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java index 6632ebf1b..34405e966 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineAssignedWorldManager.java @@ -60,7 +60,7 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent @EventHandler public void on(IrisEngineHotloadEvent e) { - for (Player i : e.getEngine().getWorld().getPlayers()) { + for(Player i : e.getEngine().getWorld().getPlayers()) { i.playSound(i.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_BREAK, 1f, 1.8f); VolmitSender s = new VolmitSender(i); s.sendTitle(C.IRIS + "Engine " + C.AQUA + "Hotloaded", 70, 60, 410); @@ -71,34 +71,34 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void on(PlayerTeleportEvent e) { - if (ignoreTP.get()) { + if(ignoreTP.get()) { return; } - if (!PaperLib.isPaper() || e.getTo() == null) { + if(!PaperLib.isPaper() || e.getTo() == null) { return; } try { - if (e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) { getEngine().getWorldManager().teleportAsync(e); } - } catch (Throwable ex) { + } catch(Throwable ex) { } } @EventHandler public void on(WorldSaveEvent e) { - if (e.getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getWorld().equals(getTarget().getWorld().realWorld())) { getEngine().save(); } } @EventHandler public void on(EntitySpawnEvent e) { - if (e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) { - if (e.getEntityType().equals(EntityType.ENDER_SIGNAL)) { + if(e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getEntityType().equals(EntityType.ENDER_SIGNAL)) { KList p = getEngine().getDimension().getStrongholds(getEngine().getSeedManager().getSpawn()); Position2 px = new Position2(e.getEntity().getLocation().getBlockX(), e.getEntity().getLocation().getBlockZ()); Position2 pr = null; @@ -106,19 +106,19 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent Iris.debug("Ps: " + p.size()); - for (Position2 i : p) { + for(Position2 i : p) { Iris.debug("- " + i.getX() + " " + i.getZ()); } - for (Position2 i : p) { + for(Position2 i : p) { double dx = i.distance(px); - if (dx < d) { + if(dx < d) { d = dx; pr = i; } } - if (pr != null) { + if(pr != null) { e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.ITEM_TRIDENT_THROW, 1f, 1.6f); Location ll = new Location(e.getEntity().getWorld(), pr.getX(), 40, pr.getZ()); Iris.debug("ESignal: " + ll.getBlockX() + " " + ll.getBlockZ()); @@ -130,28 +130,28 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent @EventHandler public void on(WorldUnloadEvent e) { - if (e.getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getWorld().equals(getTarget().getWorld().realWorld())) { getEngine().close(); } } @EventHandler public void on(BlockBreakEvent e) { - if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) { onBlockBreak(e); } } @EventHandler public void on(BlockPlaceEvent e) { - if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) { onBlockPlace(e); } } @EventHandler public void on(ChunkLoadEvent e) { - if (e.getChunk().getWorld().equals(getTarget().getWorld().realWorld())) { + if(e.getChunk().getWorld().equals(getTarget().getWorld().realWorld())) { onChunkLoad(e.getChunk(), e.isNewChunk()); } } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineComponent.java b/src/main/java/com/volmit/iris/engine/framework/EngineComponent.java index 451327825..78fa97958 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineComponent.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineComponent.java @@ -39,10 +39,10 @@ public interface EngineComponent { default void close() { try { - if (this instanceof Listener) { + if(this instanceof Listener) { Iris.instance.unregisterListener((Listener) this); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineData.java b/src/main/java/com/volmit/iris/engine/framework/EngineData.java index 5dc173a8e..2689b0d6e 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineData.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineData.java @@ -38,7 +38,7 @@ public class EngineData { try { f.getParentFile().mkdirs(); return new Gson().fromJson(IO.readAll(f), EngineData.class); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -50,7 +50,7 @@ public class EngineData { try { f.getParentFile().mkdirs(); IO.writeAll(f, new Gson().toJson(this)); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineDecorator.java b/src/main/java/com/volmit/iris/engine/framework/EngineDecorator.java index 17154e64d..2988d8ec9 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineDecorator.java @@ -36,7 +36,7 @@ public interface EngineDecorator extends EngineComponent { @SuppressWarnings("BooleanMethodIsAlwaysInverted") default boolean canGoOn(BlockData decorant, BlockData atop) { - if (atop == null || B.isAir(atop)) { + if(atop == null || B.isAir(atop)) { return false; } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineMode.java b/src/main/java/com/volmit/iris/engine/framework/EngineMode.java index 44bb57963..2505508b2 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineMode.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineMode.java @@ -41,7 +41,7 @@ public interface EngineMode extends Staged { BurstExecutor e = burst().burst(stages.length); e.setMulticore(multicore); - for (EngineStage i : stages) { + for(EngineStage i : stages) { e.queue(() -> i.generate(x, z, blocks, biomes, multicore)); } @@ -63,7 +63,7 @@ public interface EngineMode extends Staged { @BlockCoordinates default void generate(int x, int z, Hunk blocks, Hunk biomes, boolean multicore) { - for (EngineStage i : getStages()) { + for(EngineStage i : getStages()) { i.generate(x, z, blocks, biomes, multicore); } } diff --git a/src/main/java/com/volmit/iris/engine/framework/EnginePlayer.java b/src/main/java/com/volmit/iris/engine/framework/EnginePlayer.java index 5afa34b33..8547170d5 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EnginePlayer.java +++ b/src/main/java/com/volmit/iris/engine/framework/EnginePlayer.java @@ -49,22 +49,22 @@ public class EnginePlayer { sample(); J.a(() -> { - if (region != null) { - for (IrisEffect j : region.getEffects()) { + if(region != null) { + for(IrisEffect j : region.getEffects()) { try { j.apply(player, getEngine()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } } - if (biome != null) { - for (IrisEffect j : biome.getEffects()) { + if(biome != null) { + for(IrisEffect j : biome.getEffects()) { try { j.apply(player, getEngine()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -79,12 +79,12 @@ public class EnginePlayer { public void sample() { try { - if (ticksSinceLastSample() > 55 && player.getLocation().distanceSquared(lastLocation) > 9 * 9) { + if(ticksSinceLastSample() > 55 && player.getLocation().distanceSquared(lastLocation) > 9 * 9) { lastLocation = player.getLocation().clone(); lastSample = M.ms(); sampleBiomeRegion(); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/engine/framework/EngineStage.java b/src/main/java/com/volmit/iris/engine/framework/EngineStage.java index 21d7e541a..6c1b29ae7 100644 --- a/src/main/java/com/volmit/iris/engine/framework/EngineStage.java +++ b/src/main/java/com/volmit/iris/engine/framework/EngineStage.java @@ -28,7 +28,7 @@ public interface EngineStage { void generate(int x, int z, Hunk blocks, Hunk biomes, boolean multicore); default void close() { - if (this instanceof EngineComponent c) { + if(this instanceof EngineComponent c) { c.close(); } } diff --git a/src/main/java/com/volmit/iris/engine/framework/Fallible.java b/src/main/java/com/volmit/iris/engine/framework/Fallible.java index 352640156..79223bb95 100644 --- a/src/main/java/com/volmit/iris/engine/framework/Fallible.java +++ b/src/main/java/com/volmit/iris/engine/framework/Fallible.java @@ -24,7 +24,7 @@ public interface Fallible { default void fail(String error) { try { throw new RuntimeException(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); fail(error, e); } diff --git a/src/main/java/com/volmit/iris/engine/framework/IrisEngineMode.java b/src/main/java/com/volmit/iris/engine/framework/IrisEngineMode.java index bdc675376..9e2e400b5 100644 --- a/src/main/java/com/volmit/iris/engine/framework/IrisEngineMode.java +++ b/src/main/java/com/volmit/iris/engine/framework/IrisEngineMode.java @@ -33,7 +33,7 @@ public abstract class IrisEngineMode implements EngineMode { @Override public synchronized void close() { - if (closed) { + if(closed) { return; } diff --git a/src/main/java/com/volmit/iris/engine/framework/Locator.java b/src/main/java/com/volmit/iris/engine/framework/Locator.java index dc7092a95..367fc6a38 100644 --- a/src/main/java/com/volmit/iris/engine/framework/Locator.java +++ b/src/main/java/com/volmit/iris/engine/framework/Locator.java @@ -51,7 +51,7 @@ public interface Locator { boolean matches(Engine engine, Position2 chunk); static void cancelSearch() { - if (LocatorCanceller.cancel != null) { + if(LocatorCanceller.cancel != null) { LocatorCanceller.cancel.run(); LocatorCanceller.cancel = null; } @@ -68,14 +68,14 @@ public interface Locator { try { Position2 at = find(IrisToolbelt.access(player.getWorld()).getEngine(), new Position2(player.getLocation().getBlockX() >> 4, player.getLocation().getBlockZ() >> 4), timeout, checks::set).get(); - if (at != null) { + if(at != null) { J.s(() -> player.teleport(new Location(player.getWorld(), (at.getX() << 4) + 8, - IrisToolbelt.access(player.getWorld()).getEngine().getHeight( - (at.getX() << 4) + 8, - (at.getZ() << 4) + 8, false), - (at.getZ() << 4) + 8))); + IrisToolbelt.access(player.getWorld()).getEngine().getHeight( + (at.getX() << 4) + 8, + (at.getZ() << 4) + 8, false), + (at.getZ() << 4) + 8))); } - } catch (WrongEngineBroException | InterruptedException | ExecutionException e) { + } catch(WrongEngineBroException | InterruptedException | ExecutionException e) { e.printStackTrace(); } }) { @@ -97,7 +97,7 @@ public interface Locator { } default Future find(Engine engine, Position2 pos, long timeout, Consumer checks) throws WrongEngineBroException { - if (engine.isClosed()) { + if(engine.isClosed()) { throw new WrongEngineBroException(); } @@ -117,15 +117,15 @@ public interface Locator { Spiraler s = new Spiraler(100000, 100000, (x, z) -> next.set(new Position2(x, z))); s.setOffset(cursor.getX(), cursor.getZ()); s.next(); - while (!found.get() && !stop.get() && px.getMilliseconds() < timeout) { + while(!found.get() && !stop.get() && px.getMilliseconds() < timeout) { BurstExecutor e = burst.burst(tc); - for (int i = 0; i < tc; i++) { + for(int i = 0; i < tc; i++) { Position2 p = next.get(); s.next(); e.queue(() -> { - if (matches(engine, p)) { - if (foundPos.get() == null) { + if(matches(engine, p)) { + if(foundPos.get() == null) { foundPos.set(p); } @@ -141,7 +141,7 @@ public interface Locator { LocatorCanceller.cancel = null; - if (found.get() && foundPos.get() != null) { + if(found.get() && foundPos.get() != null) { return foundPos.get(); } @@ -177,11 +177,11 @@ public interface Locator { AtomicBoolean found = new AtomicBoolean(false); e.generateMatter(c.getX(), c.getZ(), true); e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, t) -> { - if (found.get()) { + if(found.get()) { return; } - if (t != null && t.getCustomBiome().equals(loadKey)) { + if(t != null && t.getCustomBiome().equals(loadKey)) { found.set(true); } }); diff --git a/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java b/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java index 5bcc2df6a..6a2ef9f2c 100644 --- a/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java +++ b/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java @@ -45,18 +45,18 @@ public class PregeneratedData { public Runnable inject(TerrainChunk tc) { blocks.iterateSync((x, y, z, b) -> { - if (b != null) { + if(b != null) { tc.setBlock(x, y, z, b); } Biome bf = biomes.get(x, y, z); - if (bf != null) { + if(bf != null) { tc.setBiome(x, y, z, bf); } }); - if (postMod.get()) { - return () -> Hunk.view((ChunkGenerator.ChunkData) tc).insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b)); + if(postMod.get()) { + return () -> Hunk.view(tc).insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b)); } return () -> { diff --git a/src/main/java/com/volmit/iris/engine/framework/SeedManager.java b/src/main/java/com/volmit/iris/engine/framework/SeedManager.java index 66a146895..283b66648 100644 --- a/src/main/java/com/volmit/iris/engine/framework/SeedManager.java +++ b/src/main/java/com/volmit/iris/engine/framework/SeedManager.java @@ -94,7 +94,7 @@ public class SeedManager { RNG e = new RNG((IRIS_TERRAIN_VERSION * 42) + IRIS_SIGNATURE); double gsoup = 0; int gk = a.i(1_000, 10_000); - for (char i : (a.s(4) + b.s(4) + c.s(4) + d.s(4) + e.s(4)).toCharArray()) { + for(char i : (a.s(4) + b.s(4) + c.s(4) + d.s(4) + e.s(4)).toCharArray()) { gsoup += ((gk * b.d(3, Math.PI)) / c.d(10, 18 * Math.E)) + 6_549; gsoup *= d.d(90.5, 1_234_567); gsoup += e.d(39.95, 99.25); diff --git a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java index 6a8a242b0..54af0809e 100644 --- a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java +++ b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java @@ -93,7 +93,7 @@ public class PlannedPiece { } public AxisAlignedBB getBox() { - if (box != null) { + if(box != null) { return box; } @@ -111,18 +111,18 @@ public class PlannedPiece { } public KList getAvailableConnectors() { - if (connected.isEmpty()) { + if(connected.isEmpty()) { return piece.getConnectors().copy(); } - if (connected.size() == piece.getConnectors().size()) { + if(connected.size() == piece.getConnectors().size()) { return new KList<>(); } KList c = new KList<>(); - for (IrisJigsawPieceConnector i : piece.getConnectors()) { - if (!connected.contains(i)) { + for(IrisJigsawPieceConnector i : piece.getConnectors()) { + if(!connected.contains(i)) { c.add(i); } } @@ -131,7 +131,7 @@ public class PlannedPiece { } public boolean connect(IrisJigsawPieceConnector c) { - if (piece.getConnectors().contains(c)) { + if(piece.getConnectors().contains(c)) { return connected.addIfMissing(c); } @@ -154,10 +154,10 @@ public class PlannedPiece { PlatformChunkGenerator a = IrisToolbelt.access(world); int minY = 0; - if (a != null) { + if(a != null) { minY = a.getEngine().getMinHeight(); - if (!a.getEngine().getDimension().isBedrock()) + if(!a.getEngine().getDimension().isBedrock()) minY--; //If the dimension has no bedrock, allow it to go a block lower } @@ -183,19 +183,19 @@ public class PlannedPiece { Block block = world.getBlockAt(x, y, z); //Prevent blocks being set in or bellow bedrock - if (y <= finalMinY || block.getType() == Material.BEDROCK) return; + if(y <= finalMinY || block.getType() == Material.BEDROCK) return; block.setBlockData(d); - if (a != null && getPiece().getPlacementOptions().getLoot().isNotEmpty() && - block.getState() instanceof InventoryHolder) { + if(a != null && getPiece().getPlacementOptions().getLoot().isNotEmpty() && + block.getState() instanceof InventoryHolder) { IrisLootTable table = getPiece().getPlacementOptions().getTable(block.getBlockData(), getData()); - if (table == null) return; + if(table == null) return; Engine engine = a.getEngine(); engine.addItems(false, ((InventoryHolder) block.getState()).getInventory(), - rng.nextParallelRNG(BlockPosition.toLong(x, y, z)), - new KList<>(table), InventorySlotType.STORAGE, x, y, z, 15); + rng.nextParallelRNG(BlockPosition.toLong(x, y, z)), + new KList<>(table), InventorySlotType.STORAGE, x, y, z, 15); } } @@ -243,7 +243,7 @@ public class PlannedPiece { @Override public Engine getEngine() { - if (IrisToolbelt.isIrisWorld(world)) { + if(IrisToolbelt.isIrisWorld(world)) { return IrisToolbelt.access(world).getEngine(); } diff --git a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java index ad8d987a6..69aa41b42 100644 --- a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java +++ b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java @@ -43,11 +43,11 @@ import org.bukkit.World; @Data public class PlannedStructure { private static transient ConcurrentLinkedHashMap objectRotationCache - = new ConcurrentLinkedHashMap.Builder() - .initialCapacity(64) - .maximumWeightedCapacity(1024) - .concurrencyLevel(32) - .build(); + = new ConcurrentLinkedHashMap.Builder() + .initialCapacity(64) + .maximumWeightedCapacity(1024) + .concurrencyLevel(32) + .build(); private KList pieces; private IrisJigsawStructure structure; private IrisPosition position; @@ -66,7 +66,7 @@ public class PlannedStructure { this.data = structure.getLoader(); generateStartPiece(); - for (int i = 0; i < structure.getMaxDepth(); i++) { + for(int i = 0; i < structure.getMaxDepth(); i++) { generateOutwards(); } @@ -74,7 +74,7 @@ public class PlannedStructure { Iris.debug("JPlace: ROOT @ relative " + position.toString()); - for (PlannedPiece i : pieces) { + for(PlannedPiece i : pieces) { Iris.debug("Place: " + i.getObject().getLoadKey() + " at @ relative " + i.getPosition().toString()); } } @@ -84,7 +84,7 @@ public class PlannedStructure { options.getRotation().setEnabled(false); int startHeight = pieces.get(0).getPosition().getY(); - for (PlannedPiece i : pieces) { + for(PlannedPiece i : pieces) { place(i, startHeight, options, placer, e, eng); } } @@ -92,7 +92,7 @@ public class PlannedStructure { public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, Mantle e, Engine eng) { IrisObjectPlacement options = o; - if (i.getPiece().getPlacementOptions() != null) { + if(i.getPiece().getPlacementOptions() != null) { options = i.getPiece().getPlacementOptions(); options.getRotation().setEnabled(false); } else { @@ -109,8 +109,8 @@ public class PlannedStructure { int offset = i.getPosition().getY() - startHeight; int height = 0; - if (i.getStructure().getStructure().getLockY() == -1) { - if (i.getStructure().getStructure().getOverrideYRange() != null) { + if(i.getStructure().getStructure().getLockY() == -1) { + if(i.getStructure().getStructure().getOverrideYRange() != null) { height = (int) i.getStructure().getStructure().getOverrideYRange().get(rng, xx, zz, getData()); } else { height = placer.getHighest(xx, zz, getData()); @@ -121,24 +121,24 @@ public class PlannedStructure { height += offset + (v.getH() / 2); - if (options.getMode().equals(ObjectPlaceMode.PAINT)) { + if(options.getMode().equals(ObjectPlaceMode.PAINT)) { height = -1; } int id = rng.i(0, Integer.MAX_VALUE); vo.place(xx, height, zz, placer, options, rng, e.shouldReduce(eng) ? null : (b) - -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData()); + -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData()); } public void place(World world) { - for (PlannedPiece i : pieces) { + for(PlannedPiece i : pieces) { Iris.sq(() -> i.place(world)); } } private void generateOutwards() { - for (PlannedPiece i : getPiecesWithAvailableConnectors().shuffle(rng)) { - if (!generatePieceOutwards(i)) { + for(PlannedPiece i : getPiecesWithAvailableConnectors().shuffle(rng)) { + if(!generatePieceOutwards(i)) { i.setDead(true); } } @@ -147,8 +147,8 @@ public class PlannedStructure { private boolean generatePieceOutwards(PlannedPiece piece) { boolean b = false; - for (IrisJigsawPieceConnector i : piece.getAvailableConnectors().shuffleCopy(rng)) { - if (generateConnectorOutwards(piece, i)) { + for(IrisJigsawPieceConnector i : piece.getAvailableConnectors().shuffleCopy(rng)) { + if(generateConnectorOutwards(piece, i)) { b = true; } } @@ -157,8 +157,8 @@ public class PlannedStructure { } private boolean generateConnectorOutwards(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector) { - for (IrisJigsawPiece i : getShuffledPiecesFor(pieceConnector)) { - if (generateRotatedPiece(piece, pieceConnector, i)) { + for(IrisJigsawPiece i : getShuffledPiecesFor(pieceConnector)) { + if(generateRotatedPiece(piece, pieceConnector, i)) { return true; } } @@ -167,8 +167,8 @@ public class PlannedStructure { } private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea) { - if (!piece.getPiece().getPlacementOptions().getRotation().isEnabled()) { - if (generateRotatedPiece(piece, pieceConnector, idea, 0, 0, 0)) { + if(!piece.getPiece().getPlacementOptions().getRotation().isEnabled()) { + if(generateRotatedPiece(piece, pieceConnector, idea, 0, 0, 0)) { return true; } } @@ -176,23 +176,23 @@ public class PlannedStructure { KList forder1 = new KList().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng); KList forder2 = new KList().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng); - for (Integer i : forder1) { - if (pieceConnector.isRotateConnector()) { + for(Integer i : forder1) { + if(pieceConnector.isRotateConnector()) { assert pieceConnector.getDirection().getAxis() != null; - if (!pieceConnector.getDirection().getAxis().equals(Axis.Y)) { - for (Integer j : forder2) { - if (pieceConnector.getDirection().getAxis().equals(Axis.X) && generateRotatedPiece(piece, pieceConnector, idea, j, i, 0)) { + if(!pieceConnector.getDirection().getAxis().equals(Axis.Y)) { + for(Integer j : forder2) { + if(pieceConnector.getDirection().getAxis().equals(Axis.X) && generateRotatedPiece(piece, pieceConnector, idea, j, i, 0)) { return true; } - if (pieceConnector.getDirection().getAxis().equals(Axis.Z) && generateRotatedPiece(piece, pieceConnector, idea, 0, i, j)) { + if(pieceConnector.getDirection().getAxis().equals(Axis.Z) && generateRotatedPiece(piece, pieceConnector, idea, 0, i, j)) { return true; } } } } - if (generateRotatedPiece(piece, pieceConnector, idea, 0, i, 0)) { + if(generateRotatedPiece(piece, pieceConnector, idea, 0, i, 0)) { return true; } } @@ -201,14 +201,14 @@ public class PlannedStructure { } private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, IrisObjectRotation rotation) { - if (!idea.getPlacementOptions().getRotation().isEnabled()) { + if(!idea.getPlacementOptions().getRotation().isEnabled()) { rotation = piece.getRotation(); } PlannedPiece test = new PlannedPiece(this, piece.getPosition(), idea, rotation); - for (IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) { - if (generatePositionedPiece(piece, pieceConnector, test, j)) { + for(IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) { + if(generatePositionedPiece(piece, pieceConnector, test, j)) { return true; } } @@ -229,18 +229,18 @@ public class PlannedStructure { IrisDirection desiredDirection = pieceConnector.getDirection().reverse(); IrisPosition desiredPosition = connector.sub(new IrisPosition(desiredDirection.toVector())); - if (!pieceConnector.getTargetName().equals("*") && !pieceConnector.getTargetName().equals(testConnector.getName())) { + if(!pieceConnector.getTargetName().equals("*") && !pieceConnector.getTargetName().equals(testConnector.getName())) { return false; } - if (!testConnector.getDirection().equals(desiredDirection)) { + if(!testConnector.getDirection().equals(desiredDirection)) { return false; } IrisPosition shift = test.getWorldPosition(testConnector); test.setPosition(desiredPosition.sub(shift)); - if (collidesWith(test, piece)) { + if(collidesWith(test, piece)) { return false; } @@ -254,11 +254,11 @@ public class PlannedStructure { private KList getShuffledPiecesFor(IrisJigsawPieceConnector c) { KList p = new KList<>(); - for (String i : c.getPools().shuffleCopy(rng)) { - for (String j : getData().getJigsawPoolLoader().load(i).getPieces().shuffleCopy(rng)) { + for(String i : c.getPools().shuffleCopy(rng)) { + for(String j : getData().getJigsawPoolLoader().load(i).getPieces().shuffleCopy(rng)) { IrisJigsawPiece pi = getData().getJigsawPieceLoader().load(j); - if (pi == null || (terminating && !pi.isTerminal())) { + if(pi == null || (terminating && !pi.isTerminal())) { continue; } @@ -273,7 +273,7 @@ public class PlannedStructure { } private void generateTerminators() { - if (getStructure().isTerminate()) { + if(getStructure().isTerminate()) { terminating = true; generateOutwards(); } @@ -286,7 +286,7 @@ public class PlannedStructure { public int getVolume() { int v = 0; - for (PlannedPiece i : pieces) { + for(PlannedPiece i : pieces) { v += i.getObject().getH() * i.getObject().getW() * i.getObject().getD(); } @@ -296,7 +296,7 @@ public class PlannedStructure { public int getMass() { int v = 0; - for (PlannedPiece i : pieces) { + for(PlannedPiece i : pieces) { v += i.getObject().getBlocks().size(); } @@ -304,12 +304,12 @@ public class PlannedStructure { } public boolean collidesWith(PlannedPiece piece, PlannedPiece ignore) { - for (PlannedPiece i : pieces) { - if (i.equals(ignore)) { + for(PlannedPiece i : pieces) { + if(i.equals(ignore)) { continue; } - if (i.collidesWith(piece)) { + if(i.collidesWith(piece)) { return true; } } @@ -318,8 +318,8 @@ public class PlannedStructure { } public boolean contains(IrisPosition p) { - for (PlannedPiece i : pieces) { - if (i.contains(p)) { + for(PlannedPiece i : pieces) { + if(i.contains(p)) { return true; } } diff --git a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java index bbeb78aa6..11f5fec08 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java +++ b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java @@ -72,7 +72,7 @@ public interface EngineMantle extends IObjectPlacer { default KList findMarkers(int x, int z, MatterMarker marker) { KList p = new KList<>(); getMantle().iterateChunk(x, z, MatterMarker.class, (xx, yy, zz, mm) -> { - if (marker.equals(mm)) { + if(marker.equals(mm)) { p.add(new IrisPosition(xx + (x << 4), yy, zz + (z << 4))); } }); @@ -116,7 +116,7 @@ public interface EngineMantle extends IObjectPlacer { default BlockData get(int x, int y, int z) { BlockData block = getMantle().get(x, y, z, BlockData.class); - if (block == null) { + if(block == null) { return AIR; } @@ -195,15 +195,15 @@ public interface EngineMantle extends IObjectPlacer { @ChunkCoordinates default void generateMatter(int x, int z, boolean multicore) { - if (!getEngine().getDimension().isUseMantle()) { + if(!getEngine().getDimension().isUseMantle()) { return; } int s = getRealRadius(); BurstExecutor burst = burst().burst(multicore); MantleWriter writer = getMantle().write(this, x, z, s * 2); - for (int i = -s; i <= s; i++) { - for (int j = -s; j <= s; j++) { + for(int i = -s; i <= s; i++) { + for(int j = -s; j <= s; j++) { int xx = i + x; int zz = j + z; burst.queue(() -> { @@ -211,7 +211,7 @@ public interface EngineMantle extends IObjectPlacer { getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> { MantleChunk mc = getMantle().getChunk(xx, zz); - for (MantleComponent k : getComponents()) { + for(MantleComponent k : getComponents()) { generateMantleComponent(writer, xx, zz, k, mc); } }); @@ -228,7 +228,7 @@ public interface EngineMantle extends IObjectPlacer { @ChunkCoordinates default void insertMatter(int x, int z, Class t, Hunk blocks, boolean multicore) { - if (!getEngine().getDimension().isUseMantle()) { + if(!getEngine().getDimension().isUseMantle()) { return; } @@ -244,7 +244,7 @@ public interface EngineMantle extends IObjectPlacer { default void dropCavernBlock(int x, int y, int z) { Matter matter = getMantle().getChunk(x & 15, z & 15).get(y & 15); - if (matter != null) { + if(matter != null) { matter.slice(MatterCavern.class).set(x & 15, y & 15, z & 15, null); } } @@ -268,11 +268,11 @@ public interface EngineMantle extends IObjectPlacer { default boolean isCovered(int x, int z) { int s = getRealRadius(); - for (int i = -s; i <= s; i++) { - for (int j = -s; j <= s; j++) { + for(int i = -s; i <= s; i++) { + for(int j = -s; j <= s; j++) { int xx = i + x; int zz = j + z; - if (!getMantle().hasFlag(xx, zz, MantleFlag.REAL)) { + if(!getMantle().hasFlag(xx, zz, MantleFlag.REAL)) { return false; } } @@ -282,7 +282,7 @@ public interface EngineMantle extends IObjectPlacer { } default void cleanupChunk(int x, int z) { - if (!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z)) { + if(!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z)) { getMantle().raiseFlag(x, z, MantleFlag.CLEANED, () -> { getMantle().deleteChunkSlice(x, z, BlockData.class); getMantle().deleteChunkSlice(x, z, String.class); diff --git a/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java b/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java index 9e454b2e4..bb4fc72c9 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java +++ b/src/main/java/com/volmit/iris/engine/mantle/MantleWriter.java @@ -58,8 +58,8 @@ public class MantleWriter implements IObjectPlacer { this.x = x; this.z = z; - for (int i = -radius; i <= radius; i++) { - for (int j = -radius; j <= radius; j++) { + for(int i = -radius; i <= radius; i++) { + for(int j = -radius; j <= radius; j++) { cachedChunks.put(Cache.key(i + x, j + z), mantle.getChunk(i + x, j + z)); } } @@ -69,15 +69,15 @@ public class MantleWriter implements IObjectPlacer { Set returnset = new HashSet<>(); int ceilrad = (int) Math.ceil(radius); - for (IrisPosition v : vset) { + for(IrisPosition v : vset) { int tipx = v.getX(); int tipy = v.getY(); int tipz = v.getZ(); - for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { - for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) { - for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) { - if (hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) { + for(int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { + for(int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) { + for(int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) { + if(hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) { returnset.add(new IrisPosition(loopx, loopy, loopz)); } } @@ -89,16 +89,16 @@ public class MantleWriter implements IObjectPlacer { private static Set getHollowed(Set vset) { Set returnset = new KSet<>(); - for (IrisPosition v : vset) { + for(IrisPosition v : vset) { double x = v.getX(); double y = v.getY(); double z = v.getZ(); - if (!(vset.contains(new IrisPosition(x + 1, y, z)) - && vset.contains(new IrisPosition(x - 1, y, z)) - && vset.contains(new IrisPosition(x, y + 1, z)) - && vset.contains(new IrisPosition(x, y - 1, z)) - && vset.contains(new IrisPosition(x, y, z + 1)) - && vset.contains(new IrisPosition(x, y, z - 1)))) { + if(!(vset.contains(new IrisPosition(x + 1, y, z)) + && vset.contains(new IrisPosition(x - 1, y, z)) + && vset.contains(new IrisPosition(x, y + 1, z)) + && vset.contains(new IrisPosition(x, y - 1, z)) + && vset.contains(new IrisPosition(x, y, z + 1)) + && vset.contains(new IrisPosition(x, y, z - 1)))) { returnset.add(v); } } @@ -107,7 +107,7 @@ public class MantleWriter implements IObjectPlacer { private static double hypot(double... pars) { double sum = 0; - for (double d : pars) { + for(double d : pars) { sum += Math.pow(d, 2); } return Math.sqrt(sum); @@ -122,22 +122,22 @@ public class MantleWriter implements IObjectPlacer { } public void setData(int x, int y, int z, T t) { - if (t == null) { + if(t == null) { return; } int cx = x >> 4; int cz = z >> 4; - if (y < 0 || y >= mantle.getWorldHeight()) { + if(y < 0 || y >= mantle.getWorldHeight()) { return; } - if (cx >= this.x - radius && cx <= this.x + radius - && cz >= this.z - radius && cz <= this.z + radius) { + if(cx >= this.x - radius && cx <= this.x + radius + && cz >= this.z - radius && cz <= this.z + radius) { MantleChunk chunk = cachedChunks.get(Cache.key(cx, cz)); - if (chunk == null) { + if(chunk == null) { Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)"); return; } @@ -210,13 +210,20 @@ public class MantleWriter implements IObjectPlacer { /** * Set a sphere into the mantle * - * @param cx the center x - * @param cy the center y - * @param cz the center z - * @param radius the radius of this sphere - * @param fill should it be filled? or just the outer shell? - * @param data the data to set - * @param the type of data to apply to the mantle + * @param cx + * the center x + * @param cy + * the center y + * @param cz + * the center z + * @param radius + * the radius of this sphere + * @param fill + * should it be filled? or just the outer shell? + * @param data + * the data to set + * @param + * the type of data to apply to the mantle */ public void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) { setElipsoid(cx, cy, cz, radius, radius, radius, fill, data); @@ -229,15 +236,24 @@ public class MantleWriter implements IObjectPlacer { /** * Set an elipsoid into the mantle * - * @param cx the center x - * @param cy the center y - * @param cz the center z - * @param rx the x radius - * @param ry the y radius - * @param rz the z radius - * @param fill should it be filled or just the outer shell? - * @param data the data to set - * @param the type of data to apply to the mantle + * @param cx + * the center x + * @param cy + * the center y + * @param cz + * the center z + * @param rx + * the x radius + * @param ry + * the y radius + * @param rz + * the z radius + * @param fill + * should it be filled or just the outer shell? + * @param data + * the data to set + * @param + * the type of data to apply to the mantle */ public void setElipsoidFunction(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3 data) { rx += 0.5; @@ -252,23 +268,23 @@ public class MantleWriter implements IObjectPlacer { double nextXn = 0; forX: - for (int x = 0; x <= ceilRadiusX; ++x) { + for(int x = 0; x <= ceilRadiusX; ++x) { final double xn = nextXn; nextXn = (x + 1) * invRadiusX; double nextYn = 0; forY: - for (int y = 0; y <= ceilRadiusY; ++y) { + for(int y = 0; y <= ceilRadiusY; ++y) { final double yn = nextYn; nextYn = (y + 1) * invRadiusY; double nextZn = 0; - for (int z = 0; z <= ceilRadiusZ; ++z) { + for(int z = 0; z <= ceilRadiusZ; ++z) { final double zn = nextZn; nextZn = (z + 1) * invRadiusZ; double distanceSq = lengthSq(xn, yn, zn); - if (distanceSq > 1) { - if (z == 0) { - if (y == 0) { + if(distanceSq > 1) { + if(z == 0) { + if(y == 0) { break forX; } break forY; @@ -276,8 +292,8 @@ public class MantleWriter implements IObjectPlacer { break; } - if (!fill) { - if (lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) { + if(!fill) { + if(lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) { continue; } } @@ -299,21 +315,29 @@ public class MantleWriter implements IObjectPlacer { /** * Set a cuboid of data in the mantle * - * @param x1 the min x - * @param y1 the min y - * @param z1 the min z - * @param x2 the max x - * @param y2 the max y - * @param z2 the max z - * @param data the data to set - * @param the type of data to apply to the mantle + * @param x1 + * the min x + * @param y1 + * the min y + * @param z1 + * the min z + * @param x2 + * the max x + * @param y2 + * the max y + * @param z2 + * the max z + * @param data + * the data to set + * @param + * the type of data to apply to the mantle */ public void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) { int j, k; - for (int i = x1; i <= x2; i++) { - for (j = x1; j <= x2; j++) { - for (k = x1; k <= x2; k++) { + for(int i = x1; i <= x2; i++) { + for(j = x1; j <= x2; j++) { + for(k = x1; k <= x2; k++) { setData(i, j, k, data); } } @@ -323,23 +347,30 @@ public class MantleWriter implements IObjectPlacer { /** * Set a pyramid of data in the mantle * - * @param cx the center x - * @param cy the base y - * @param cz the center z - * @param data the data to set - * @param size the size of the pyramid (width of base & height) - * @param filled should it be filled or hollow - * @param the type of data to apply to the mantle + * @param cx + * the center x + * @param cy + * the base y + * @param cz + * the center z + * @param data + * the data to set + * @param size + * the size of the pyramid (width of base & height) + * @param filled + * should it be filled or hollow + * @param + * the type of data to apply to the mantle */ @SuppressWarnings("ConstantConditions") public void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) { int height = size; - for (int y = 0; y <= height; ++y) { + for(int y = 0; y <= height; ++y) { size--; - for (int x = 0; x <= size; ++x) { - for (int z = 0; z <= size; ++z) { - if ((filled && z <= size && x <= size) || z == size || x == size) { + for(int x = 0; x <= size; ++x) { + for(int z = 0; z <= size; ++z) { + if((filled && z <= size && x <= size) || z == size || x == size) { setData(x + cx, y + cy, z + cz, data); setData(-x + cx, y + cy, z + cz, data); setData(x + cx, y + cy, -z + cz, data); @@ -353,12 +384,18 @@ public class MantleWriter implements IObjectPlacer { /** * Set a 3d line * - * @param a the first point - * @param b the second point - * @param radius the radius - * @param filled hollow or filled? - * @param data the data - * @param the type of data to apply to the mantle + * @param a + * the first point + * @param b + * the second point + * @param radius + * the radius + * @param filled + * hollow or filled? + * @param data + * the data + * @param + * the type of data to apply to the mantle */ public void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) { setLine(ImmutableList.of(a, b), radius, filled, data); @@ -371,16 +408,21 @@ public class MantleWriter implements IObjectPlacer { /** * Set lines for points * - * @param vectors the points - * @param radius the radius - * @param filled hollow or filled? - * @param data the data to set - * @param the type of data to apply to the mantle + * @param vectors + * the points + * @param radius + * the radius + * @param filled + * hollow or filled? + * @param data + * the data to set + * @param + * the type of data to apply to the mantle */ public void setLineConsumer(List vectors, double radius, boolean filled, Function3 data) { Set vset = new KSet<>(); - for (int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) { + for(int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) { IrisPosition pos1 = vectors.get(i); IrisPosition pos2 = vectors.get(i + 1); int x1 = pos1.getX(); @@ -396,22 +438,22 @@ public class MantleWriter implements IObjectPlacer { int dy = Math.abs(y2 - y1); int dz = Math.abs(z2 - z1); - if (dx + dy + dz == 0) { + if(dx + dy + dz == 0) { vset.add(new IrisPosition(tipx, tipy, tipz)); continue; } int dMax = Math.max(Math.max(dx, dy), dz); - if (dMax == dx) { - for (int domstep = 0; domstep <= dx; domstep++) { + if(dMax == dx) { + for(int domstep = 0; domstep <= dx; domstep++) { tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1); tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1)); tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1)); vset.add(new IrisPosition(tipx, tipy, tipz)); } - } else if (dMax == dy) { - for (int domstep = 0; domstep <= dy; domstep++) { + } else if(dMax == dy) { + for(int domstep = 0; domstep <= dy; domstep++) { tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1); tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1)); tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1)); @@ -419,7 +461,7 @@ public class MantleWriter implements IObjectPlacer { vset.add(new IrisPosition(tipx, tipy, tipz)); } } else /* if (dMax == dz) */ { - for (int domstep = 0; domstep <= dz; domstep++) { + for(int domstep = 0; domstep <= dz; domstep++) { tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1); tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2 - y1 > 0 ? 1 : -1)); tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2 - x1 > 0 ? 1 : -1)); @@ -431,7 +473,7 @@ public class MantleWriter implements IObjectPlacer { vset = getBallooned(vset, radius); - if (!filled) { + if(!filled) { vset = getHollowed(vset); } @@ -441,13 +483,20 @@ public class MantleWriter implements IObjectPlacer { /** * Set a cylinder in the mantle * - * @param cx the center x - * @param cy the base y - * @param cz the center z - * @param data the data to set - * @param radius the radius - * @param height the height of the cyl - * @param filled filled or not + * @param cx + * the center x + * @param cy + * the base y + * @param cz + * the center z + * @param data + * the data to set + * @param radius + * the radius + * @param height + * the height of the cyl + * @param filled + * filled or not */ public void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) { setCylinder(cx, cy, cz, data, radius, radius, height, filled); @@ -456,30 +505,38 @@ public class MantleWriter implements IObjectPlacer { /** * Set a cylinder in the mantle * - * @param cx the center x - * @param cy the base y - * @param cz the center z - * @param data the data to set - * @param radiusX the x radius - * @param radiusZ the z radius - * @param height the height of this cyl - * @param filled filled or hollow? + * @param cx + * the center x + * @param cy + * the base y + * @param cz + * the center z + * @param data + * the data to set + * @param radiusX + * the x radius + * @param radiusZ + * the z radius + * @param height + * the height of this cyl + * @param filled + * filled or hollow? */ public void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) { int affected = 0; radiusX += 0.5; radiusZ += 0.5; - if (height == 0) { + if(height == 0) { return; - } else if (height < 0) { + } else if(height < 0) { height = -height; cy = cy - height; } - if (cy < 0) { + if(cy < 0) { cy = 0; - } else if (cy + height - 1 > getMantle().getWorldHeight()) { + } else if(cy + height - 1 > getMantle().getWorldHeight()) { height = getMantle().getWorldHeight() - cy + 1; } @@ -490,30 +547,30 @@ public class MantleWriter implements IObjectPlacer { double nextXn = 0; forX: - for (int x = 0; x <= ceilRadiusX; ++x) { + for(int x = 0; x <= ceilRadiusX; ++x) { final double xn = nextXn; nextXn = (x + 1) * invRadiusX; double nextZn = 0; - for (int z = 0; z <= ceilRadiusZ; ++z) { + for(int z = 0; z <= ceilRadiusZ; ++z) { final double zn = nextZn; nextZn = (z + 1) * invRadiusZ; double distanceSq = lengthSq(xn, zn); - if (distanceSq > 1) { - if (z == 0) { + if(distanceSq > 1) { + if(z == 0) { break forX; } break; } - if (!filled) { - if (lengthSq(nextXn, zn) <= 1 && lengthSq(xn, nextZn) <= 1) { + if(!filled) { + if(lengthSq(nextXn, zn) <= 1 && lengthSq(xn, nextZn) <= 1) { continue; } } - for (int y = 0; y < height; ++y) { + for(int y = 0; y < height; ++y) { setData(cx + x, cy + y, cz + z, data); setData(cx + -x, cy + y, cz + z, data); setData(cx + x, cy + y, cz + -z, data); @@ -524,31 +581,27 @@ public class MantleWriter implements IObjectPlacer { } public void set(IrisPosition pos, T data) { - try - { + try { setData(pos.getX(), pos.getY(), pos.getZ(), data); - } - - catch(Throwable e) - { + } catch(Throwable e) { Iris.error("No set? " + data.toString() + " for " + pos.toString()); } } public void set(List positions, T data) { - for (IrisPosition i : positions) { + for(IrisPosition i : positions) { set(i, data); } } public void set(Set positions, T data) { - for (IrisPosition i : positions) { + for(IrisPosition i : positions) { set(i, data); } } public void setConsumer(Set positions, Function3 data) { - for (IrisPosition i : positions) { + for(IrisPosition i : positions) { set(i, data.apply(i.getX(), i.getY(), i.getZ())); } } @@ -561,11 +614,11 @@ public class MantleWriter implements IObjectPlacer { int cx = x >> 4; int cz = z >> 4; - if (y < 0 || y >= mantle.getWorldHeight()) { + if(y < 0 || y >= mantle.getWorldHeight()) { return false; } return cx >= this.x - radius && cx <= this.x + radius - && cz >= this.z - radius && cz <= this.z + radius; + && cz >= this.z - radius && cz <= this.z + radius; } } diff --git a/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java b/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java index 29a2d427b..41d231a97 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java +++ b/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java @@ -59,12 +59,12 @@ public class MantleJigsawComponent extends IrisMantleComponent { private void generateJigsaw(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) { boolean placed = false; - if (getDimension().getStronghold() != null) { + if(getDimension().getStronghold() != null) { List poss = getDimension().getStrongholds(seed()); - if (poss != null) { - for (Position2 pos : poss) { - if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) { + if(poss != null) { + for(Position2 pos : poss) { + if(x == pos.getX() >> 4 && z == pos.getZ() >> 4) { IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold()); place(writer, pos.toIris(), structure, rng); placed = true; @@ -73,9 +73,9 @@ public class MantleJigsawComponent extends IrisMantleComponent { } } - if (!placed) { - for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { + if(!placed) { + for(IrisJigsawStructurePlacement i : biome.getJigsawStructures()) { + if(rng.nextInt(i.getRarity()) == 0) { IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); place(writer, position, structure, rng); @@ -84,9 +84,9 @@ public class MantleJigsawComponent extends IrisMantleComponent { } } - if (!placed) { - for (IrisJigsawStructurePlacement i : region.getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { + if(!placed) { + for(IrisJigsawStructurePlacement i : region.getJigsawStructures()) { + if(rng.nextInt(i.getRarity()) == 0) { IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); place(writer, position, structure, rng); @@ -95,9 +95,9 @@ public class MantleJigsawComponent extends IrisMantleComponent { } } - if (!placed) { - for (IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { + if(!placed) { + for(IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) { + if(rng.nextInt(i.getRarity()) == 0) { IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); place(writer, position, structure, rng); @@ -112,32 +112,32 @@ public class MantleJigsawComponent extends IrisMantleComponent { IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8); IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8); - if (getDimension().getStronghold() != null) { + if(getDimension().getStronghold() != null) { List poss = getDimension().getStrongholds(seed()); - if (poss != null) { - for (Position2 pos : poss) { - if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) { + if(poss != null) { + for(Position2 pos : poss) { + if(x == pos.getX() >> 4 && z == pos.getZ() >> 4) { return getData().getJigsawStructureLoader().load(getDimension().getStronghold()); } } } } - for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { + for(IrisJigsawStructurePlacement i : biome.getJigsawStructures()) { + if(rng.nextInt(i.getRarity()) == 0) { return getData().getJigsawStructureLoader().load(i.getStructure()); } } - for (IrisJigsawStructurePlacement i : region.getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { + for(IrisJigsawStructurePlacement i : region.getJigsawStructures()) { + if(rng.nextInt(i.getRarity()) == 0) { return getData().getJigsawStructureLoader().load(i.getStructure()); } } - for (IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { + for(IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) { + if(rng.nextInt(i.getRarity()) == 0) { return getData().getJigsawStructureLoader().load(i.getStructure()); } } diff --git a/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java b/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java index 35c1ad505..44bda0121 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java +++ b/src/main/java/com/volmit/iris/engine/mantle/components/MantleObjectComponent.java @@ -54,12 +54,12 @@ public class MantleObjectComponent extends IrisMantleComponent { private void placeObjects(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) { long s = Cache.key(x, z) + seed(); RNG rnp = new RNG(s); - for (IrisObjectPlacement i : biome.getSurfaceObjects()) { - if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { + for(IrisObjectPlacement i : biome.getSurfaceObjects()) { + if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { try { placeObject(writer, rnp, x << 4, z << 4, i); rnp.setSeed(s); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to place objects in the following biome: " + biome.getName()); Iris.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); @@ -69,12 +69,12 @@ public class MantleObjectComponent extends IrisMantleComponent { } } - for (IrisObjectPlacement i : region.getSurfaceObjects()) { - if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { + for(IrisObjectPlacement i : region.getSurfaceObjects()) { + if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { try { placeObject(writer, rnp, x << 4, z << 4, i); rnp.setSeed(s); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to place objects in the following region: " + region.getName()); Iris.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ")."); @@ -87,26 +87,26 @@ public class MantleObjectComponent extends IrisMantleComponent { @BlockCoordinates private void placeObject(MantleWriter writer, RNG rng, int x, int z, IrisObjectPlacement objectPlacement) { - for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { + for(int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng)); - if (v == null) { + if(v == null) { return; } int xx = rng.i(x, x + 15); int zz = rng.i(z, z + 15); int id = rng.i(0, Integer.MAX_VALUE); v.place(xx, -1, zz, writer, objectPlacement, rng, - getMantle().shouldReduce(getEngineMantle().getEngine()) ? null : (b) -> writer.setData(b.getX(), b.getY(), b.getZ(), - v.getLoadKey() + "@" + id), null, getData()); + getMantle().shouldReduce(getEngineMantle().getEngine()) ? null : (b) -> writer.setData(b.getX(), b.getY(), b.getZ(), + v.getLoadKey() + "@" + id), null, getData()); } } @BlockCoordinates private Set guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) { Set f = new KSet<>(); - for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { + for(int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng)); - if (v == null) { + if(v == null) { continue; } @@ -123,15 +123,15 @@ public class MantleObjectComponent extends IrisMantleComponent { IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8); IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8); Set v = new KSet<>(); - for (IrisObjectPlacement i : biome.getSurfaceObjects()) { - if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { + for(IrisObjectPlacement i : biome.getSurfaceObjects()) { + if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { v.addAll(guessPlacedKeys(rngd, x, z, i)); rngd.setSeed(s); } } - for (IrisObjectPlacement i : region.getSurfaceObjects()) { - if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { + for(IrisObjectPlacement i : region.getSurfaceObjects()) { + if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { v.addAll(guessPlacedKeys(rngd, x, z, i)); rngd.setSeed(s); } diff --git a/src/main/java/com/volmit/iris/engine/mode/ModeEnclosure.java b/src/main/java/com/volmit/iris/engine/mode/ModeEnclosure.java index 3ea7e28f4..4cf8ea028 100644 --- a/src/main/java/com/volmit/iris/engine/mode/ModeEnclosure.java +++ b/src/main/java/com/volmit/iris/engine/mode/ModeEnclosure.java @@ -31,8 +31,8 @@ public class ModeEnclosure extends IrisEngineMode implements EngineMode { var biome = new IrisBiomeActuator(getEngine()); registerStage(burst( - (x, z, k, p, m) -> terrain.actuate(x, z, k, m), - (x, z, k, p, m) -> biome.actuate(x, z, p, m) + (x, z, k, p, m) -> terrain.actuate(x, z, k, m), + (x, z, k, p, m) -> biome.actuate(x, z, p, m) )); } } diff --git a/src/main/java/com/volmit/iris/engine/mode/ModeIslands.java b/src/main/java/com/volmit/iris/engine/mode/ModeIslands.java index 0ad388a43..06e9a7557 100644 --- a/src/main/java/com/volmit/iris/engine/mode/ModeIslands.java +++ b/src/main/java/com/volmit/iris/engine/mode/ModeIslands.java @@ -31,8 +31,8 @@ public class ModeIslands extends IrisEngineMode implements EngineMode { var biome = new IrisBiomeActuator(getEngine()); registerStage(burst( - (x, z, k, p, m) -> terrain.actuate(x, z, k, m), - (x, z, k, p, m) -> biome.actuate(x, z, p, m) + (x, z, k, p, m) -> terrain.actuate(x, z, k, m), + (x, z, k, p, m) -> biome.actuate(x, z, p, m) )); } } diff --git a/src/main/java/com/volmit/iris/engine/mode/ModeOverworld.java b/src/main/java/com/volmit/iris/engine/mode/ModeOverworld.java index c5ebdfd3c..bc27515c5 100644 --- a/src/main/java/com/volmit/iris/engine/mode/ModeOverworld.java +++ b/src/main/java/com/volmit/iris/engine/mode/ModeOverworld.java @@ -43,9 +43,9 @@ public class ModeOverworld extends IrisEngineMode implements EngineMode { var perfection = new IrisPerfectionModifier(getEngine()); registerStage(burst( - (x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m), - (x, z, k, p, m) -> terrain.actuate(x, z, k, m), - (x, z, k, p, m) -> biome.actuate(x, z, p, m) + (x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m), + (x, z, k, p, m) -> terrain.actuate(x, z, k, m), + (x, z, k, p, m) -> biome.actuate(x, z, p, m) )); registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m)); registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m)); diff --git a/src/main/java/com/volmit/iris/engine/mode/ModeSuperFlat.java b/src/main/java/com/volmit/iris/engine/mode/ModeSuperFlat.java index 76c450500..dd7f2f743 100644 --- a/src/main/java/com/volmit/iris/engine/mode/ModeSuperFlat.java +++ b/src/main/java/com/volmit/iris/engine/mode/ModeSuperFlat.java @@ -31,8 +31,8 @@ public class ModeSuperFlat extends IrisEngineMode implements EngineMode { var biome = new IrisBiomeActuator(getEngine()); registerStage(burst( - (x, z, k, p, m) -> terrain.actuate(x, z, k, m), - (x, z, k, p, m) -> biome.actuate(x, z, p, m) + (x, z, k, p, m) -> terrain.actuate(x, z, k, m), + (x, z, k, p, m) -> biome.actuate(x, z, p, m) )); } } diff --git a/src/main/java/com/volmit/iris/engine/modifier/IrisCarveModifier.java b/src/main/java/com/volmit/iris/engine/modifier/IrisCarveModifier.java index cd765e0b3..d034b434d 100644 --- a/src/main/java/com/volmit/iris/engine/modifier/IrisCarveModifier.java +++ b/src/main/java/com/volmit/iris/engine/modifier/IrisCarveModifier.java @@ -64,11 +64,11 @@ public class IrisCarveModifier extends EngineAssignedModifier { KMap> positions = new KMap<>(); KMap walls = new KMap<>(); Consumer4 iterator = (xx, yy, zz, c) -> { - if (c == null) { + if(c == null) { return; } - if (yy >= 256 || yy <= 0) { // Yes, skip bedrock + if(yy >= 256 || yy <= 0) { // Yes, skip bedrock return; } @@ -77,7 +77,7 @@ public class IrisCarveModifier extends EngineAssignedModifier { BlockData current = output.get(rx, yy, rz); - if (B.isFluid(current)) { + if(B.isFluid(current)) { return; } @@ -85,29 +85,29 @@ public class IrisCarveModifier extends EngineAssignedModifier { //todo: Fix chunk decoration not working on chunk's border - if (rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null) { + if(rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null) { walls.put(new IrisPosition(rx, yy, rz + 1), c); } - if (rx < 15 && mantle.get(xx + 1, yy, zz, MatterCavern.class) == null) { + if(rx < 15 && mantle.get(xx + 1, yy, zz, MatterCavern.class) == null) { walls.put(new IrisPosition(rx + 1, yy, rz), c); } - if (rz > 0 && mantle.get(xx, yy, zz - 1, MatterCavern.class) == null) { + if(rz > 0 && mantle.get(xx, yy, zz - 1, MatterCavern.class) == null) { walls.put(new IrisPosition(rx, yy, rz - 1), c); } - if (rx > 0 && mantle.get(xx - 1, yy, zz, MatterCavern.class) == null) { + if(rx > 0 && mantle.get(xx - 1, yy, zz, MatterCavern.class) == null) { walls.put(new IrisPosition(rx - 1, yy, rz), c); } - if (current.getMaterial().isAir()) { + if(current.getMaterial().isAir()) { return; } - if (c.isWater()) { + if(c.isWater()) { output.set(rx, yy, rz, WATER); - } else if (c.isLava()) { + } else if(c.isLava()) { output.set(rx, yy, rz, LAVA); } else { output.set(rx, yy, rz, AIR); @@ -118,21 +118,21 @@ public class IrisCarveModifier extends EngineAssignedModifier { walls.forEach((i, v) -> { IrisBiome biome = v.getCustomBiome().isEmpty() - ? getEngine().getCaveBiome(i.getX() + (x << 4), i.getZ() + (z << 4)) - : getEngine().getData().getBiomeLoader().load(v.getCustomBiome()); + ? getEngine().getCaveBiome(i.getX() + (x << 4), i.getZ() + (z << 4)) + : getEngine().getData().getBiomeLoader().load(v.getCustomBiome()); - if (biome != null) { + if(biome != null) { biome.setInferredType(InferredType.CAVE); BlockData d = biome.getWall().get(rng, i.getX() + (x << 4), i.getY(), i.getZ() + (z << 4), getData()); - if (d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= getComplex().getHeightStream().get(i.getX() + (x << 4), i.getZ() + (z << 4))) { + if(d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= getComplex().getHeightStream().get(i.getX() + (x << 4), i.getZ() + (z << 4))) { output.set(i.getX(), i.getY(), i.getZ(), d); } } }); positions.forEach((k, v) -> { - if (v.isEmpty()) { + if(v.isEmpty()) { return; } @@ -143,15 +143,15 @@ public class IrisCarveModifier extends EngineAssignedModifier { zone.setFloor(v.get(0)); int buf = v.get(0) - 1; - for (Integer i : v) { - if (i < 0 || i > 255) { + for(Integer i : v) { + if(i < 0 || i > 255) { continue; } - if (i == buf + 1) { + if(i == buf + 1) { buf = i; zone.ceiling = buf; - } else if (zone.isValid()) { + } else if(zone.isValid()) { processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4)); zone = new CaveZone(); zone.setFloor(i); @@ -159,7 +159,7 @@ public class IrisCarveModifier extends EngineAssignedModifier { } } - if (zone.isValid()) { + if(zone.isValid()) { processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4)); } }); @@ -174,62 +174,62 @@ public class IrisCarveModifier extends EngineAssignedModifier { int thickness = zone.airThickness(); String customBiome = ""; - if (B.isDecorant(output.getClosest(rx, zone.ceiling + 1, rz))) { + if(B.isDecorant(output.getClosest(rx, zone.ceiling + 1, rz))) { output.set(rx, zone.ceiling + 1, rz, AIR); } - if (B.isDecorant(output.get(rx, zone.ceiling, rz))) { + if(B.isDecorant(output.get(rx, zone.ceiling, rz))) { output.set(rx, zone.ceiling, rz, AIR); } - if (M.r(1D / 16D)) { + if(M.r(1D / 16D)) { mantle.set(xx, zone.ceiling, zz, MarkerMatter.CAVE_CEILING); } - if (M.r(1D / 16D)) { + if(M.r(1D / 16D)) { mantle.set(xx, zone.floor, zz, MarkerMatter.CAVE_FLOOR); } - for (int i = zone.floor; i <= zone.ceiling; i++) { + for(int i = zone.floor; i <= zone.ceiling; i++) { MatterCavern cavernData = (MatterCavern) mc.getOrCreate(i >> 4).slice(MatterCavern.class) - .get(rx, i & 15, rz); + .get(rx, i & 15, rz); - if (cavernData != null && !cavernData.getCustomBiome().isEmpty()) { + if(cavernData != null && !cavernData.getCustomBiome().isEmpty()) { customBiome = cavernData.getCustomBiome(); break; } } IrisBiome biome = customBiome.isEmpty() - ? getEngine().getCaveBiome(xx, zz) - : getEngine().getData().getBiomeLoader().load(customBiome); + ? getEngine().getCaveBiome(xx, zz) + : getEngine().getData().getBiomeLoader().load(customBiome); - if (biome == null) { + if(biome == null) { return; } biome.setInferredType(InferredType.CAVE); - for (IrisDecorator i : biome.getDecorators()) { - if (i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor() - 1, rz))) { + for(IrisDecorator i : biome.getDecorators()) { + if(i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor() - 1, rz))) { decorant.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.airThickness()); - } else if (i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) { + } else if(i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) { decorant.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling(), zone.airThickness()); } } KList blocks = biome.generateLayers(getDimension(), xx, zz, rng, 3, zone.floor, getData(), getComplex()); - for (int i = 0; i < zone.floor - 1; i++) { - if (!blocks.hasIndex(i)) { + for(int i = 0; i < zone.floor - 1; i++) { + if(!blocks.hasIndex(i)) { break; } - if (!B.isSolid(output.get(rx, zone.floor - i - 1, rz))) { + if(!B.isSolid(output.get(rx, zone.floor - i - 1, rz))) { continue; } - if (B.isOre(output.get(rx, zone.floor - i - 1, rz))) { + if(B.isOre(output.get(rx, zone.floor - i - 1, rz))) { continue; } @@ -238,20 +238,20 @@ public class IrisCarveModifier extends EngineAssignedModifier { blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.ceiling, getData(), getComplex()); - if (zone.ceiling + 1 < mantle.getWorldHeight()) { - for (int i = 0; i < zone.ceiling + 1; i++) { - if (!blocks.hasIndex(i)) { + if(zone.ceiling + 1 < mantle.getWorldHeight()) { + for(int i = 0; i < zone.ceiling + 1; i++) { + if(!blocks.hasIndex(i)) { break; } BlockData b = blocks.get(i); BlockData up = output.get(rx, zone.ceiling + i + 1, rz); - if (!B.isSolid(up)) { + if(!B.isSolid(up)) { continue; } - if (B.isOre(up)) { + if(B.isOre(up)) { output.set(rx, zone.ceiling + i + 1, rz, B.toDeepSlateOre(up, b)); continue; } diff --git a/src/main/java/com/volmit/iris/engine/modifier/IrisDepositModifier.java b/src/main/java/com/volmit/iris/engine/modifier/IrisDepositModifier.java index c4ce9d826..62c29d21f 100644 --- a/src/main/java/com/volmit/iris/engine/modifier/IrisDepositModifier.java +++ b/src/main/java/com/volmit/iris/engine/modifier/IrisDepositModifier.java @@ -54,18 +54,18 @@ public class IrisDepositModifier extends EngineAssignedModifier { IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7); BurstExecutor burst = burst().burst(multicore); - for (IrisDepositGenerator k : getDimension().getDeposits()) { + for(IrisDepositGenerator k : getDimension().getDeposits()) { burst.queue(() -> generate(k, terrain, ro, x, z, false)); } - for (IrisDepositGenerator k : region.getDeposits()) { - for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { + for(IrisDepositGenerator k : region.getDeposits()) { + for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { burst.queue(() -> generate(k, terrain, ro, x, z, false)); } } - for (IrisDepositGenerator k : biome.getDeposits()) { - for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { + for(IrisDepositGenerator k : biome.getDeposits()) { + for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { burst.queue(() -> generate(k, terrain, ro, x, z, false)); } } @@ -77,25 +77,25 @@ public class IrisDepositModifier extends EngineAssignedModifier { } public void generate(IrisDepositGenerator k, Hunk data, RNG rng, int cx, int cz, boolean safe, HeightMap he) { - for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { + for(int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) { IrisObject clump = k.getClump(rng, getData()); int af = (int) Math.floor(clump.getW() / 2D); int bf = (int) Math.floor(16D - (clump.getW() / 2D)); - if (af > bf || af < 0 || bf > 15 || af > 15 || bf < 0) { + if(af > bf || af < 0 || bf > 15 || af > 15 || bf < 0) { af = 6; bf = 9; } - af = Math.max(af-1, 0); + af = Math.max(af - 1, 0); int x = rng.i(af, bf); int z = rng.i(af, bf); int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round( - getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z) + getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z) ))) - 7; - if (height <= 0) { + if(height <= 0) { return; } @@ -103,26 +103,26 @@ public class IrisDepositModifier extends EngineAssignedModifier { // TODO: WARNING HEIGHT int a = Math.min(height, Math.min(256, k.getMaxHeight())); - if (i >= a) { + if(i >= a) { return; } int h = rng.i(i, a); - if (h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) { + if(h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) { return; } - for (BlockVector j : clump.getBlocks().keySet()) { + for(BlockVector j : clump.getBlocks().keySet()) { int nx = j.getBlockX() + x; int ny = j.getBlockY() + h; int nz = j.getBlockZ() + z; - if (ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) { + if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) { continue; } - if (!getEngine().getMantle().isCarved((cx << 4) + nx, ny, (cz << 4) + nz)) { + if(!getEngine().getMantle().isCarved((cx << 4) + nx, ny, (cz << 4) + nz)) { data.set(nx, ny, nz, B.toDeepSlateOre(data.get(nx, ny, nz), clump.getBlocks().get(j))); } } diff --git a/src/main/java/com/volmit/iris/engine/modifier/IrisPerfectionModifier.java b/src/main/java/com/volmit/iris/engine/modifier/IrisPerfectionModifier.java index 953033149..6554eb813 100644 --- a/src/main/java/com/volmit/iris/engine/modifier/IrisPerfectionModifier.java +++ b/src/main/java/com/volmit/iris/engine/modifier/IrisPerfectionModifier.java @@ -49,27 +49,27 @@ public class IrisPerfectionModifier extends EngineAssignedModifier { List surfaces = new ArrayList<>(); List ceilings = new ArrayList<>(); BurstExecutor burst = burst().burst(multicore); - while (changed.get()) { + while(changed.get()) { passes++; changed.set(false); - for (int i = 0; i < 16; i++) { + for(int i = 0; i < 16; i++) { int finalI = i; burst.queue(() -> { - for (int j = 0; j < 16; j++) { + for(int j = 0; j < 16; j++) { surfaces.clear(); ceilings.clear(); int top = getHeight(output, finalI, j); boolean inside = true; surfaces.add(top); - for (int k = top; k >= 0; k--) { + for(int k = top; k >= 0; k--) { BlockData b = output.get(finalI, k, j); boolean now = b != null && !(B.isAir(b) || B.isFluid(b)); - if (now != inside) { + if(now != inside) { inside = now; - if (inside) { + if(inside) { surfaces.add(k); } else { ceilings.add(k + 1); @@ -77,37 +77,37 @@ public class IrisPerfectionModifier extends EngineAssignedModifier { } } - for (int k : surfaces) { + for(int k : surfaces) { BlockData tip = output.get(finalI, k, j); - if (tip == null) { + if(tip == null) { continue; } boolean remove = false; boolean remove2 = false; - if (B.isDecorant(tip)) { + if(B.isDecorant(tip)) { BlockData bel = output.get(finalI, k - 1, j); - if (bel == null) { + if(bel == null) { remove = true; - } else if (!B.canPlaceOnto(tip.getMaterial(), bel.getMaterial())) { + } else if(!B.canPlaceOnto(tip.getMaterial(), bel.getMaterial())) { remove = true; - } else if (bel instanceof Bisected) { + } else if(bel instanceof Bisected) { BlockData bb = output.get(finalI, k - 2, j); - if (bb == null || !B.canPlaceOnto(bel.getMaterial(), bb.getMaterial())) { + if(bb == null || !B.canPlaceOnto(bel.getMaterial(), bb.getMaterial())) { remove = true; remove2 = true; } } - if (remove) { + if(remove) { changed.set(true); changes.getAndIncrement(); output.set(finalI, k, j, AIR); - if (remove2) { + if(remove2) { changes.getAndIncrement(); output.set(finalI, k - 1, j, AIR); } @@ -123,10 +123,10 @@ public class IrisPerfectionModifier extends EngineAssignedModifier { } private int getHeight(Hunk output, int x, int z) { - for (int i = output.getHeight() - 1; i >= 0; i--) { + for(int i = output.getHeight() - 1; i >= 0; i--) { BlockData b = output.get(x, i, z); - if (b != null && !B.isAir(b) && !B.isFluid(b)) { + if(b != null && !B.isAir(b) && !B.isFluid(b)) { return i; } } diff --git a/src/main/java/com/volmit/iris/engine/modifier/IrisPostModifier.java b/src/main/java/com/volmit/iris/engine/modifier/IrisPostModifier.java index a54a67be6..6230b1073 100644 --- a/src/main/java/com/volmit/iris/engine/modifier/IrisPostModifier.java +++ b/src/main/java/com/volmit/iris/engine/modifier/IrisPostModifier.java @@ -49,8 +49,8 @@ public class IrisPostModifier extends EngineAssignedModifier { AtomicInteger i = new AtomicInteger(); AtomicInteger j = new AtomicInteger(); Hunk sync = output.synchronize(); - for (i.set(0); i.get() < output.getWidth(); i.getAndIncrement()) { - for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) { + for(i.set(0); i.get() < output.getWidth(); i.getAndIncrement()) { + for(j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) { int ii = i.get(); int jj = j.get(); post(ii, jj, sync, ii + x, jj + z); @@ -71,7 +71,7 @@ public class IrisPostModifier extends EngineAssignedModifier { // Floating Nibs int g = 0; - if (h < 1) { + if(h < 1) { return; } @@ -80,11 +80,11 @@ public class IrisPostModifier extends EngineAssignedModifier { g += hc < h - 1 ? 1 : 0; g += hd < h - 1 ? 1 : 0; - if (g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) { + if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) { setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData); - for (int i = h - 1; i > 0; i--) { - if (!isAir(x, i, z, currentPostX, currentPostZ, currentData)) { + for(int i = h - 1; i > 0; i--) { + if(!isAir(x, i, z, currentPostX, currentPostZ, currentData)) { h = i; break; } @@ -98,13 +98,13 @@ public class IrisPostModifier extends EngineAssignedModifier { g += hc == h - 1 ? 1 : 0; g += hd == h - 1 ? 1 : 0; - if (g >= 4) { + if(g >= 4) { BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); Material m = bc.getMaterial(); - if ((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) { - if (m.isSolid()) { + if((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) { + if(m.isSolid()) { setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData); h--; } @@ -117,7 +117,7 @@ public class IrisPostModifier extends EngineAssignedModifier { g += hc == h + 1 ? 1 : 0; g += hd == h + 1 ? 1 : 0; - if (g >= 4) { + if(g >= 4) { BlockData ba = getPostBlock(x, ha, z, currentPostX, currentPostZ, currentData); BlockData bb = getPostBlock(x, hb, z, currentPostX, currentPostZ, currentData); BlockData bc = getPostBlock(x, hc, z, currentPostX, currentPostZ, currentData); @@ -128,7 +128,7 @@ public class IrisPostModifier extends EngineAssignedModifier { g = B.isSolid(bc) ? g + 1 : g; g = B.isSolid(bd) ? g + 1 : g; - if (g >= 3) { + if(g >= 3) { setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData); h++; } @@ -138,18 +138,18 @@ public class IrisPostModifier extends EngineAssignedModifier { // Wall Patcher IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z); - if (getDimension().isPostProcessingWalls()) { - if (!biome.getWall().getPalette().isEmpty()) { - if (ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) { + if(getDimension().isPostProcessingWalls()) { + if(!biome.getWall().getPalette().isEmpty()) { + if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) { boolean brokeGround = false; int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd)))); - for (int i = h; i > h - max; i--) { + for(int i = h; i > h - max; i--) { BlockData d = biome.getWall().get(rng, x + i, i + h, z + i, getData()); - if (d != null) { - if (isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) { - if (brokeGround) { + if(d != null) { + if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) { + if(brokeGround) { break; } @@ -165,28 +165,28 @@ public class IrisPostModifier extends EngineAssignedModifier { } // Slab - if (getDimension().isPostProcessingSlabs()) { + if(getDimension().isPostProcessingSlabs()) { //@builder - if ((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData)) - || (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData)) - || (hc == h + 1 && isSolidNonSlab(x - 1, hc, z, currentPostX, currentPostZ, currentData)) - || (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, currentPostX, currentPostZ, currentData))) + if((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData)) + || (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData)) + || (hc == h + 1 && isSolidNonSlab(x - 1, hc, z, currentPostX, currentPostZ, currentData)) + || (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, currentPostX, currentPostZ, currentData))) //@done { BlockData d = biome.getSlab().get(rng, x, h, z, getData()); - if (d != null) { + if(d != null) { boolean cancel = B.isAir(d); - if (d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) { + if(d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) { cancel = true; } - if (isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) { + if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) { cancel = true; } - if (!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData)) { + if(!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData)) { setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData); h++; } @@ -197,24 +197,24 @@ public class IrisPostModifier extends EngineAssignedModifier { // Waterlogging BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); - if (b instanceof Waterlogged) { + if(b instanceof Waterlogged) { Waterlogged ww = (Waterlogged) b.clone(); boolean w = false; - if (h <= getDimension().getFluidHeight() + 1) { - if (isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData)) { + if(h <= getDimension().getFluidHeight() + 1) { + if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData)) { w = true; - } else if ((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) { + } else if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) { w = true; } } - if (w != ww.isWaterlogged()) { + if(w != ww.isWaterlogged()) { ww.setWaterlogged(w); setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData); } - } else if (b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight()) { - if ((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) { + } else if(b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight()) { + if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) { setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData); } } @@ -222,10 +222,10 @@ public class IrisPostModifier extends EngineAssignedModifier { // Foliage b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); - if (B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) { + if(B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) { Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial(); - if (!B.canPlaceOnto(b.getMaterial(), onto)) { + if(!B.canPlaceOnto(b.getMaterial(), onto)) { setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData); } } @@ -282,7 +282,7 @@ public class IrisPostModifier extends EngineAssignedModifier { } public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk currentData) { - if (y < currentData.getHeight()) { + if(y < currentData.getHeight()) { currentData.set(x & 15, y, z & 15, d); } } diff --git a/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java b/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java index 708714c34..3e8876dab 100644 --- a/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java +++ b/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java @@ -50,24 +50,24 @@ public class HeadlessWorld { this.dimension = dimension; this.studio = studio; world = IrisWorld.builder() - .environment(dimension.getEnvironment()) - .worldFolder(new File(worldName)) - .seed(seed) - .maxHeight(256) - .minHeight(0) - .name(worldName) - .build(); + .environment(dimension.getEnvironment()) + .worldFolder(new File(worldName)) + .seed(seed) + .maxHeight(256) + .minHeight(0) + .name(worldName) + .build(); world.worldFolder().mkdirs(); new File(world.worldFolder(), "region").mkdirs(); - if (!studio && !new File(world.worldFolder(), "iris/pack").exists()) { + if(!studio && !new File(world.worldFolder(), "iris/pack").exists()) { Iris.service(StudioSVC.class).installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder()); } } public static HeadlessWorld from(World world) { return new HeadlessWorld(world.getName(), IrisToolbelt.access(world) - .getEngine().getTarget().getDimension(), world.getSeed()); + .getEngine().getTarget().getDimension(), world.getSeed()); } public static HeadlessWorld from(String name, String dimension, long seed) { @@ -78,13 +78,13 @@ public class HeadlessWorld { public HeadlessGenerator generate() { Engine e = null; - if (getWorld().tryGetRealWorld()) { - if (IrisToolbelt.isIrisWorld(getWorld().realWorld())) { + if(getWorld().tryGetRealWorld()) { + if(IrisToolbelt.isIrisWorld(getWorld().realWorld())) { e = IrisToolbelt.access(getWorld().realWorld()).getEngine(); } } - if (e != null) { + if(e != null) { Iris.info("Using Existing Engine " + getWorld().name() + " for Headless Pregeneration."); } @@ -93,11 +93,11 @@ public class HeadlessWorld { public World load() { World w = new WorldCreator(worldName) - .environment(dimension.getEnvironment()) - .seed(world.getRawWorldSeed()) - .generator(new BukkitChunkGenerator(world, studio, dimension.getLoader().getDataFolder(), - dimension.getLoadKey())) - .createWorld(); + .environment(dimension.getEnvironment()) + .seed(world.getRawWorldSeed()) + .generator(new BukkitChunkGenerator(world, studio, dimension.getLoader().getDataFolder(), + dimension.getLoadKey())) + .createWorld(); world.realWorld(w); return w; } diff --git a/src/main/java/com/volmit/iris/engine/object/IRare.java b/src/main/java/com/volmit/iris/engine/object/IRare.java index 4028f85ff..820ced661 100644 --- a/src/main/java/com/volmit/iris/engine/object/IRare.java +++ b/src/main/java/com/volmit/iris/engine/object/IRare.java @@ -18,54 +18,46 @@ package com.volmit.iris.engine.object; -import com.volmit.iris.Iris; -import com.volmit.iris.engine.EnginePanic; import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.math.RNG; -import com.volmit.iris.util.reflect.V; -import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.stream.ProceduralStream; -import com.volmit.iris.util.stream.arithmetic.FittedStream; import com.volmit.iris.util.stream.interpolation.Interpolated; -import lombok.AllArgsConstructor; -import lombok.Data; -import java.util.*; +import java.util.List; public interface IRare { static ProceduralStream stream(ProceduralStream noise, List possibilities) { return ProceduralStream.of((x, z) -> pick(possibilities, noise.get(x, z)), - (x, y, z) -> pick(possibilities, noise.get(x, y, z)), - new Interpolated() { - @Override - public double toDouble(T t) { - return 0; - } + (x, y, z) -> pick(possibilities, noise.get(x, y, z)), + new Interpolated() { + @Override + public double toDouble(T t) { + return 0; + } - @Override - public T fromDouble(double d) { - return null; - } - }); + @Override + public T fromDouble(double d) { + return null; + } + }); } static T pickSlowly(List possibilities, double noiseValue) { - if (possibilities.isEmpty()) { + if(possibilities.isEmpty()) { return null; } - if (possibilities.size() == 1) { + if(possibilities.size() == 1) { return possibilities.get(0); } KList rarityTypes = new KList<>(); int totalRarity = 0; - for (T i : possibilities) { + for(T i : possibilities) { totalRarity += IRare.get(i); } - for (T i : possibilities) { + for(T i : possibilities) { rarityTypes.addMultiple(i, totalRarity / IRare.get(i)); } @@ -73,23 +65,23 @@ public interface IRare { } static T pick(List possibilities, double noiseValue) { - if (possibilities.isEmpty()) { + if(possibilities.isEmpty()) { return null; } - if (possibilities.size() == 1) { + if(possibilities.size() == 1) { return possibilities.get(0); } int totalWeight = 0; // This is he baseline int buffer = 0; - for (T i : possibilities) { // Im adding all of the rarity together + for(T i : possibilities) { // Im adding all of the rarity together totalWeight += i.getRarity(); } double threshold = totalWeight * (possibilities.size() - 1) * noiseValue; - for (T i : possibilities) { + for(T i : possibilities) { buffer += totalWeight - i.getRarity(); - if (buffer >= threshold) { + if(buffer >= threshold) { return i; } } @@ -98,18 +90,18 @@ public interface IRare { static T pickOld(List possibilities, double noiseValue) { - if (possibilities.isEmpty()) { + if(possibilities.isEmpty()) { return null; } - if (possibilities.size() == 1) { + if(possibilities.size() == 1) { return possibilities.get(0); } double completeWeight = 0.0; double highestWeight = 0.0; - for (T item : possibilities) { + for(T item : possibilities) { double weight = Math.max(item.getRarity(), 1); highestWeight = Math.max(highestWeight, weight); completeWeight += weight; @@ -118,10 +110,10 @@ public interface IRare { double r = noiseValue * completeWeight; double countWeight = 0.0; - for (T item : possibilities) { + for(T item : possibilities) { double weight = Math.max(highestWeight - Math.max(item.getRarity(), 1), 1); countWeight += weight; - if (countWeight >= r) { + if(countWeight >= r) { return item; } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java b/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java index 27463aae4..725531cca 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisAttributeModifier.java @@ -65,13 +65,13 @@ public class IrisAttributeModifier { private double chance = 1; public void apply(RNG rng, ItemMeta meta) { - if (rng.nextDouble() < getChance()) { + if(rng.nextDouble() < getChance()) { meta.addAttributeModifier(getAttribute(), new AttributeModifier(getName(), getAmount(rng), getOperation())); } } public void apply(RNG rng, Attributable meta) { - if (rng.nextDouble() < getChance()) { + if(rng.nextDouble() < getChance()) { meta.getAttribute(getAttribute()).addModifier(new AttributeModifier(getName(), getAmount(rng), getOperation())); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java b/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java index 09ac16d1e..7549a89f7 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisAxisRotationClamp.java @@ -78,19 +78,19 @@ public class IrisAxisRotationClamp { } public double getRadians(int rng) { - if (forceLock) { + if(forceLock) { return Math.toRadians(Math.ceil(Math.abs((max % 360D)))); } - if (isUnlimited()) { - if (interval < 1) { + if(isUnlimited()) { + if(interval < 1) { interval = 1; } return Math.toRadians((interval * (Math.ceil(Math.abs((rng % 360D) / interval)))) % 360D); } - if (min == max && min != 0) { + if(min == max && min != 0) { return Math.toRadians(max); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiome.java b/src/main/java/com/volmit/iris/engine/object/IrisBiome.java index 9bb931980..8be0ca994 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiome.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiome.java @@ -183,14 +183,14 @@ public class IrisBiome extends IrisRegistrant implements IRare { private KList ores = new KList<>(); public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) { - if (ores.isEmpty()) { + if(ores.isEmpty()) { return null; } BlockData b = null; - for (IrisOreGenerator i : ores) { + for(IrisOreGenerator i : ores) { - b = i.generate(x,y,z,rng,data); - if(b != null ){ + b = i.generate(x, y, z, rng, data); + if(b != null) { return b; } } @@ -210,7 +210,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { { KMap l = new KMap<>(); - for (IrisBiomeGeneratorLink i : getGenerators()) { + for(IrisBiomeGeneratorLink i : getGenerators()) { l.put(i.getGenerator(), i.getMax()); } @@ -225,7 +225,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { { KMap l = new KMap<>(); - for (IrisBiomeGeneratorLink i : getGenerators()) { + for(IrisBiomeGeneratorLink i : getGenerators()) { l.put(i.getGenerator(), i.getMin()); } @@ -240,7 +240,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { { KMap l = new KMap<>(); - for (IrisBiomeGeneratorLink i : getGenerators()) { + for(IrisBiomeGeneratorLink i : getGenerators()) { l.put(i.getGenerator(), i); } @@ -253,7 +253,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { { IrisBiome biome = data.getBiomeLoader().load(getCarvingBiome()); - if (biome == null) { + if(biome == null) { biome = this; } @@ -266,8 +266,8 @@ public class IrisBiome extends IrisRegistrant implements IRare { { KList o = getObjects().copy(); - for (IrisObjectPlacement i : o.copy()) { - if (!i.getCarvingSupport().supportsSurface()) { + for(IrisObjectPlacement i : o.copy()) { + if(!i.getCarvingSupport().supportsSurface()) { o.remove(i); } } @@ -281,8 +281,8 @@ public class IrisBiome extends IrisRegistrant implements IRare { { KList o = getObjects().copy(); - for (IrisObjectPlacement i : o.copy()) { - if (!i.getCarvingSupport().supportsCarving()) { + for(IrisObjectPlacement i : o.copy()) { + if(!i.getCarvingSupport().supportsCarving()) { o.remove(i); } } @@ -294,7 +294,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { public double getHeight(Engine xg, double x, double z, long seed) { double height = 0; - for (IrisBiomeGeneratorLink i : generators) { + for(IrisBiomeGeneratorLink i : generators) { height += i.getHeight(xg, x, z, seed); } @@ -303,7 +303,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { public CNG getBiomeGenerator(RNG random) { return biomeGenerator.aquire(() -> - biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader())); + biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader())); } public CNG getChildrenGenerator(RNG random, int sig, double scale) { @@ -311,54 +311,54 @@ public class IrisBiome extends IrisRegistrant implements IRare { } public KList generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) { - if (isLockLayers()) { + if(isLockLayers()) { return generateLockedLayers(wx, wz, random, maxDepth, height, rdata, complex); } KList data = new KList<>(); - if (maxDepth <= 0) { + if(maxDepth <= 0) { return data; } - for (int i = 0; i < layers.size(); i++) { + for(int i = 0; i < layers.size(); i++) { CNG hgen = getLayerHeightGenerators(random, rdata).get(i); double d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom()); IrisSlopeClip sc = getLayers().get(i).getSlopeCondition(); - if (!sc.isDefault()) { - if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) { + if(!sc.isDefault()) { + if(!sc.isValid(complex.getSlopeStream().get(wx, wz))) { d = 0; } } - if (d <= 0) { + if(d <= 0) { continue; } - for (int j = 0; j < d; j++) { - if (data.size() >= maxDepth) { + for(int j = 0; j < d; j++) { + if(data.size() >= maxDepth) { break; } try { data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata)); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } } - if (data.size() >= maxDepth) { + if(data.size() >= maxDepth) { break; } - if (dim.isExplodeBiomePalettes()) { - for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) { + if(dim.isExplodeBiomePalettes()) { + for(int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) { data.add(BARRIER); - if (data.size() >= maxDepth) { + if(data.size() >= maxDepth) { break; } } @@ -371,40 +371,40 @@ public class IrisBiome extends IrisRegistrant implements IRare { public KList generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) { KList data = new KList<>(); - if (maxDepth <= 0) { + if(maxDepth <= 0) { return data; } - for (int i = 0; i < caveCeilingLayers.size(); i++) { + for(int i = 0; i < caveCeilingLayers.size(); i++) { CNG hgen = getLayerHeightGenerators(random, rdata).get(i); double d = hgen.fit(caveCeilingLayers.get(i).getMinHeight(), caveCeilingLayers.get(i).getMaxHeight(), wx / caveCeilingLayers.get(i).getZoom(), wz / caveCeilingLayers.get(i).getZoom()); - if (d <= 0) { + if(d <= 0) { continue; } - for (int j = 0; j < d; j++) { - if (data.size() >= maxDepth) { + for(int j = 0; j < d; j++) { + if(data.size() >= maxDepth) { break; } try { data.add(getCaveCeilingLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / caveCeilingLayers.get(i).getZoom(), j, (wz - j) / caveCeilingLayers.get(i).getZoom(), rdata)); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } } - if (data.size() >= maxDepth) { + if(data.size() >= maxDepth) { break; } - if (dim.isExplodeBiomePalettes()) { - for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) { + if(dim.isExplodeBiomePalettes()) { + for(int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) { data.add(BARRIER); - if (data.size() >= maxDepth) { + if(data.size() >= maxDepth) { break; } } @@ -418,41 +418,41 @@ public class IrisBiome extends IrisRegistrant implements IRare { KList data = new KList<>(); KList real = new KList<>(); int maxDepth = Math.min(maxDepthf, getLockLayersMax()); - if (maxDepth <= 0) { + if(maxDepth <= 0) { return data; } - for (int i = 0; i < layers.size(); i++) { + for(int i = 0; i < layers.size(); i++) { CNG hgen = getLayerHeightGenerators(random, rdata).get(i); double d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom()); IrisSlopeClip sc = getLayers().get(i).getSlopeCondition(); - if (!sc.isDefault()) { - if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) { + if(!sc.isDefault()) { + if(!sc.isValid(complex.getSlopeStream().get(wx, wz))) { d = 0; } } - if (d <= 0) { + if(d <= 0) { continue; } - for (int j = 0; j < d; j++) { + for(int j = 0; j < d; j++) { try { data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata)); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } } } - if (data.isEmpty()) { + if(data.isEmpty()) { return real; } - for (int i = 0; i < maxDepth; i++) { + for(int i = 0; i < maxDepth; i++) { int offset = (255 - height) - i; int index = offset % data.size(); real.add(data.get(Math.max(index, 0))); @@ -466,7 +466,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { { int maxHeight = 0; - for (IrisBiomeGeneratorLink i : getGenerators()) { + for(IrisBiomeGeneratorLink i : getGenerators()) { maxHeight += i.getMax(); } @@ -479,14 +479,14 @@ public class IrisBiome extends IrisRegistrant implements IRare { { int maxHeight = 0; - for (IrisBiomeGeneratorLink i : getGenerators()) { + for(IrisBiomeGeneratorLink i : getGenerators()) { maxHeight += i.getMax(); } int gg = 0; - for (IrisObjectPlacement i : getObjects()) { - for (IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) { + for(IrisObjectPlacement i : getObjects()) { + for(IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) { gg = Math.max(gg, j.getH()); } } @@ -503,28 +503,28 @@ public class IrisBiome extends IrisRegistrant implements IRare { public KList generateSeaLayers(double wx, double wz, RNG random, int maxDepth, IrisData rdata) { KList data = new KList<>(); - for (int i = 0; i < seaLayers.size(); i++) { + for(int i = 0; i < seaLayers.size(); i++) { CNG hgen = getLayerSeaHeightGenerators(random, rdata).get(i); int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(), wx / seaLayers.get(i).getZoom(), wz / seaLayers.get(i).getZoom()); - if (d < 0) { + if(d < 0) { continue; } - for (int j = 0; j < d; j++) { - if (data.size() >= maxDepth) { + for(int j = 0; j < d; j++) { + if(data.size() >= maxDepth) { break; } try { data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / seaLayers.get(i).getZoom(), j, (wz - j) / seaLayers.get(i).getZoom(), rdata)); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } } - if (data.size() >= maxDepth) { + if(data.size() >= maxDepth) { break; } } @@ -539,7 +539,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { int m = 7235; - for (IrisBiomePaletteLayer i : getLayers()) { + for(IrisBiomePaletteLayer i : getLayers()) { layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), rdata)); } @@ -554,7 +554,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { int m = 7735; - for (IrisBiomePaletteLayer i : getSeaLayers()) { + for(IrisBiomePaletteLayer i : getSeaLayers()) { layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), data)); } @@ -563,7 +563,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { } public boolean isLand() { - if (inferredType == null) { + if(inferredType == null) { return true; } @@ -571,7 +571,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { } public boolean isSea() { - if (inferredType == null) { + if(inferredType == null) { return false; } return inferredType.equals(InferredType.SEA); @@ -583,18 +583,18 @@ public class IrisBiome extends IrisRegistrant implements IRare { @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isShore() { - if (inferredType == null) { + if(inferredType == null) { return false; } return inferredType.equals(InferredType.SHORE); } public Biome getSkyBiome(RNG rng, double x, double y, double z) { - if (biomeSkyScatter.size() == 1) { + if(biomeSkyScatter.size() == 1) { return biomeSkyScatter.get(0); } - if (biomeSkyScatter.isEmpty()) { + if(biomeSkyScatter.isEmpty()) { return getGroundBiome(rng, x, y, z); } @@ -602,7 +602,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { } public IrisBiomeCustom getCustomBiome(RNG rng, double x, double y, double z) { - if (customDerivitives.size() == 1) { + if(customDerivitives.size() == 1) { return customDerivitives.get(0); } @@ -614,7 +614,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { { KList realChildren = new KList<>(); - for (String i : getChildren()) { + for(String i : getChildren()) { realChildren.add(g.getData().getBiomeLoader().load(i)); } @@ -627,8 +627,8 @@ public class IrisBiome extends IrisRegistrant implements IRare { m.addAll(getChildren()); limit--; - if (limit > 0) { - for (String i : getChildren()) { + if(limit > 0) { + for(String i : getChildren()) { IrisBiome b = g.getData().getBiomeLoader().load(i); m.addAll(b.getAllChildren(g, limit)); } @@ -639,11 +639,11 @@ public class IrisBiome extends IrisRegistrant implements IRare { //TODO: Test public Biome getGroundBiome(RNG rng, double x, double y, double z) { - if (biomeScatter.isEmpty()) { + if(biomeScatter.isEmpty()) { return getDerivative(); } - if (biomeScatter.size() == 1) { + if(biomeScatter.size() == 1) { return biomeScatter.get(0); } @@ -651,7 +651,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { } public BlockData getSurfaceBlock(int x, int z, RNG rng, IrisData idm) { - if (getLayers().isEmpty()) { + if(getLayers().isEmpty()) { return B.get("AIR"); } @@ -659,12 +659,12 @@ public class IrisBiome extends IrisRegistrant implements IRare { } public Color getColor(Engine engine, RenderType type) { - switch (type) { + switch(type) { case BIOME, HEIGHT, CAVE_LAND, REGION, BIOME_SEA, BIOME_LAND -> { return this.cacheColor.aquire(() -> { - if (this.color == null) { + if(this.color == null) { RandomColor randomColor = new RandomColor(getName().hashCode()); - if (this.getVanillaDerivative() == null) { + if(this.getVanillaDerivative() == null) { Iris.warn("No vanilla biome found for " + getName()); return new Color(randomColor.randomColor()); } @@ -678,7 +678,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { try { return Color.decode(this.color); - } catch (NumberFormatException e) { + } catch(NumberFormatException e) { Iris.warn("Could not parse color \"" + this.color + "\" for biome " + getName()); return new Color(new RandomColor(getName().hashCode()).randomColor()); } @@ -688,7 +688,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { return cacheColorObjectDensity.aquire(() -> { double density = 0; - for (IrisObjectPlacement i : getObjects()) { + for(IrisObjectPlacement i : getObjects()) { density += i.getDensity() * i.getChance(); } @@ -699,7 +699,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { return cacheColorDecoratorLoad.aquire(() -> { double density = 0; - for (IrisDecorator i : getDecorators()) { + for(IrisDecorator i : getDecorators()) { density += i.getChance() * Math.min(1, i.getStackMax()) * 256; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java index 505352a4d..c619b6538 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeCustom.java @@ -102,7 +102,7 @@ public class IrisBiomeCustom { effects.put("water_color", parseColor(getWaterColor())); effects.put("water_fog_color", parseColor(getWaterFogColor())); - if (ambientParticle != null) { + if(ambientParticle != null) { JSONObject particle = new JSONObject(); JSONObject po = new JSONObject(); po.put("type", ambientParticle.getParticle().name().toLowerCase()); @@ -111,11 +111,11 @@ public class IrisBiomeCustom { effects.put("particle", particle); } - if (!getGrassColor().isEmpty()) { + if(!getGrassColor().isEmpty()) { effects.put("grass_color", parseColor(getGrassColor())); } - if (!getFoliageColor().isEmpty()) { + if(!getFoliageColor().isEmpty()) { effects.put("foliage_color", parseColor(getFoliageColor())); } @@ -135,15 +135,15 @@ public class IrisBiomeCustom { j.put("carvers", new JSONObject()); j.put("features", new JSONArray()); - if (spawnRarity > 0) { + if(spawnRarity > 0) { j.put("creature_spawn_probability", spawnRarity); } - if (getSpawns() != null && getSpawns().isNotEmpty()) { + if(getSpawns() != null && getSpawns().isNotEmpty()) { JSONObject spawners = new JSONObject(); KMap groups = new KMap<>(); - for (IrisBiomeCustomSpawn i : getSpawns()) { + for(IrisBiomeCustomSpawn i : getSpawns()) { JSONArray g = groups.computeIfAbsent(i.getGroup(), (k) -> new JSONArray()); JSONObject o = new JSONObject(); o.put("type", "minecraft:" + i.getType().name().toLowerCase()); @@ -153,7 +153,7 @@ public class IrisBiomeCustom { g.put(o); } - for (IrisBiomeCustomSpawnType i : groups.k()) { + for(IrisBiomeCustomSpawnType i : groups.k()) { spawners.put(i.name().toLowerCase(Locale.ROOT), groups.get(i)); } @@ -167,7 +167,7 @@ public class IrisBiomeCustom { String v = (c.startsWith("#") ? c : "#" + c).trim(); try { return Color.decode(v).getRGB(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Error Parsing '''color''', (" + c + ")"); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java index d6aa2ebee..7c9f22669 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomeGeneratorLink.java @@ -63,7 +63,7 @@ public class IrisBiomeGeneratorLink { { IrisGenerator gen = g.getData().getGeneratorLoader().load(getGenerator()); - if (gen == null) { + if(gen == null) { gen = new IrisGenerator(); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java b/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java index 1b9ac6aa4..a48e6db48 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBiomePaletteLayer.java @@ -75,11 +75,11 @@ public class IrisBiomePaletteLayer { } public BlockData get(RNG rng, double x, double y, double z, IrisData data) { - if (getBlockData(data).isEmpty()) { + if(getBlockData(data).isEmpty()) { return null; } - if (getBlockData(data).size() == 1) { + if(getBlockData(data).size() == 1) { return getBlockData(data).get(0); } @@ -104,10 +104,10 @@ public class IrisBiomePaletteLayer { return blockData.aquire(() -> { KList blockData = new KList<>(); - for (IrisBlockData ix : palette) { + for(IrisBlockData ix : palette) { BlockData bx = ix.getBlockData(data); - if (bx != null) { - for (int i = 0; i < ix.getWeight(); i++) { + if(bx != null) { + for(int i = 0; i < ix.getWeight(); i++) { blockData.add(bx); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java b/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java index 8ce429751..29716d988 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBlockData.java @@ -74,18 +74,18 @@ public class IrisBlockData extends IrisRegistrant { IrisBlockData b = new IrisBlockData(); String v = j.toLowerCase().trim(); - if (v.contains("[")) { + if(v.contains("[")) { KList props = new KList<>(); String rp = v.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", ""); b.setBlock(v.split("\\Q[\\E")[0]); - if (rp.contains(",")) { + if(rp.contains(",")) { props.add(rp.split("\\Q,\\E")); } else { props.add(rp); } - for (String i : props) { + for(String i : props) { Object kg = filter(i.split("\\Q=\\E")[1]); b.data.put(i.split("\\Q=\\E")[0], kg); } @@ -97,23 +97,23 @@ public class IrisBlockData extends IrisRegistrant { } private static Object filter(String string) { - if (string.equals("true")) { + if(string.equals("true")) { return true; } - if (string.equals("false")) { + if(string.equals("false")) { return false; } try { return Integer.parseInt(string); - } catch (Throwable ignored) { + } catch(Throwable ignored) { // Checks } try { return Double.valueOf(string).intValue(); - } catch (Throwable ignored) { + } catch(Throwable ignored) { // Checks } @@ -121,13 +121,13 @@ public class IrisBlockData extends IrisRegistrant { } public String computeProperties(KMap data) { - if (data.isEmpty()) { + if(data.isEmpty()) { return ""; } KList r = new KList<>(); - for (Map.Entry entry : data.entrySet()) { + for(Map.Entry entry : data.entrySet()) { r.add(entry.getKey() + "=" + filter(entry.getValue().toString())); } @@ -145,37 +145,37 @@ public class IrisBlockData extends IrisRegistrant { IrisBlockData customData = data.getBlockLoader().load(getBlock(), false); - if (customData != null) { + if(customData != null) { b = customData.getBlockData(data); - if (b != null) { + if(b != null) { b = b.clone(); String st = b.getAsString(true); - if (st.contains("[")) { + if(st.contains("[")) { st = st.split("\\Q[\\E")[0]; } KMap cdata = customData.getData().copy(); - for (String i : getData().keySet()) { + for(String i : getData().keySet()) { cdata.put(i, getData().get(i)); } String sx = keyify(st) + computeProperties(cdata); - if (debug) { + if(debug) { Iris.debug("Block Data used " + sx + " (CUSTOM)"); } BlockData bx = B.get(sx); - if (bx != null) { + if(bx != null) { return bx; } - if (b != null) { + if(b != null) { return b; } } @@ -184,15 +184,15 @@ public class IrisBlockData extends IrisRegistrant { String ss = keyify(getBlock()) + computeProperties(); b = B.get(ss); - if (debug) { + if(debug) { Iris.debug("Block Data used " + ss); } - if (b != null) { + if(b != null) { return b; } - if (backup != null) { + if(backup != null) { return backup.getBlockData(data); } @@ -201,7 +201,7 @@ public class IrisBlockData extends IrisRegistrant { } private String keyify(String dat) { - if (dat.contains(":")) { + if(dat.contains(":")) { return dat; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java b/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java index 4eda716af..fdb4f9eb8 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisBlockDrops.java @@ -60,10 +60,10 @@ public class IrisBlockDrops { { KList b = new KList<>(); - for (IrisBlockData i : getBlocks()) { + for(IrisBlockData i : getBlocks()) { BlockData dd = i.getBlockData(rdata); - if (dd != null) { + if(dd != null) { b.add(dd); } } @@ -71,8 +71,8 @@ public class IrisBlockDrops { return b.removeDuplicates(); }); - for (BlockData i : list) { - if (exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial())) { + for(BlockData i : list) { + if(exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial())) { return true; } } @@ -81,8 +81,8 @@ public class IrisBlockDrops { } public void fillDrops(boolean debug, KList d) { - for (IrisLoot i : getDrops()) { - if (RNG.r.i(1, i.getRarity()) == i.getRarity()) { + for(IrisLoot i : getDrops()) { + if(RNG.r.i(1, i.getRarity()) == i.getRarity()) { d.add(i.get(debug, RNG.r)); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCarving.java b/src/main/java/com/volmit/iris/engine/object/IrisCarving.java index 901a681aa..2945165a5 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCarving.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCarving.java @@ -67,37 +67,37 @@ public class IrisCarving { @BlockCoordinates public void doCarving(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) { - if (caves.isNotEmpty()) { - for (IrisCavePlacer i : caves) { + if(caves.isNotEmpty()) { + for(IrisCavePlacer i : caves) { i.generateCave(writer, rng, engine, x, y, z, waterHint); } } - if (ravines.isNotEmpty()) { - for (IrisRavinePlacer i : ravines) { + if(ravines.isNotEmpty()) { + for(IrisRavinePlacer i : ravines) { i.generateRavine(writer, rng, engine, x, y, z, waterHint); } } - if (spheres.isNotEmpty()) { - for (IrisSphere i : spheres) { - if (rng.nextInt(i.getRarity()) == 0) { + if(spheres.isNotEmpty()) { + for(IrisSphere i : spheres) { + if(rng.nextInt(i.getRarity()) == 0) { i.generate(rng, engine, writer, x, y, z); } } } - if (elipsoids.isNotEmpty()) { - for (IrisElipsoid i : elipsoids) { - if (rng.nextInt(i.getRarity()) == 0) { + if(elipsoids.isNotEmpty()) { + for(IrisElipsoid i : elipsoids) { + if(rng.nextInt(i.getRarity()) == 0) { i.generate(rng, engine, writer, x, y, z); } } } - if (pyramids.isNotEmpty()) { - for (IrisPyramid i : pyramids) { - if (rng.nextInt(i.getRarity()) == 0) { + if(pyramids.isNotEmpty()) { + for(IrisPyramid i : pyramids) { + if(rng.nextInt(i.getRarity()) == 0) { i.generate(rng, engine, writer, x, y, z); } } @@ -107,23 +107,23 @@ public class IrisCarving { public int getMaxRange(IrisData data) { int max = 0; - for (IrisCavePlacer i : caves) { + for(IrisCavePlacer i : caves) { max = Math.max(max, i.getSize(data)); } - for (IrisRavinePlacer i : ravines) { + for(IrisRavinePlacer i : ravines) { max = Math.max(max, i.getSize(data)); } - if (elipsoids.isNotEmpty()) { + if(elipsoids.isNotEmpty()) { max = (int) Math.max(elipsoids.stream().mapToDouble(IrisElipsoid::maxSize).max().getAsDouble(), max); } - if (spheres.isNotEmpty()) { + if(spheres.isNotEmpty()) { max = (int) Math.max(spheres.stream().mapToDouble(IrisSphere::maxSize).max().getAsDouble(), max); } - if (pyramids.isNotEmpty()) { + if(pyramids.isNotEmpty()) { max = (int) Math.max(pyramids.stream().mapToDouble(IrisPyramid::maxSize).max().getAsDouble(), max); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCave.java b/src/main/java/com/volmit/iris/engine/object/IrisCave.java index d72bdc78a..0b40014f6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCave.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCave.java @@ -76,12 +76,12 @@ public class IrisCave extends IrisRegistrant { }); int highestWater = Math.max(waterHint, -1); - if (highestWater == -1) { - for (IrisPosition i : points) { + if(highestWater == -1) { + for(IrisPosition i : points) { double yy = i.getY() + girth; int th = engine.getHeight(x, z, true); - if (yy > th && th < engine.getDimension().getFluidHeight()) { + if(yy > th && th < engine.getDimension().getFluidHeight()) { highestWater = Math.max(highestWater, (int) yy); break; } @@ -91,7 +91,7 @@ public class IrisCave extends IrisRegistrant { int h = Math.min(Math.max(highestWater, waterHint), engine.getDimension().getFluidHeight()); - for (IrisPosition i : points) { + for(IrisPosition i : points) { fork.doCarving(writer, rng, engine, i.getX(), i.getY(), i.getZ(), h); } @@ -99,8 +99,8 @@ public class IrisCave extends IrisRegistrant { MatterCavern w = new MatterCavern(true, customBiome, (byte) 1); writer.setLineConsumer(points, - girth, true, - (xf, yf, zf) -> yf <= h ? w : c); + girth, true, + (xf, yf, zf) -> yf <= h ? w : c); } @Override diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCavePlacer.java b/src/main/java/com/volmit/iris/engine/object/IrisCavePlacer.java index 1355b9801..e0f8f1f2a 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCavePlacer.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCavePlacer.java @@ -68,24 +68,24 @@ public class IrisCavePlacer implements IRare { } public void generateCave(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) { - if (fail.get()) { + if(fail.get()) { return; } - if (rng.nextInt(rarity) != 0) { + if(rng.nextInt(rarity) != 0) { return; } IrisData data = engine.getData(); IrisCave cave = getRealCave(data); - if (cave == null) { + if(cave == null) { Iris.warn("Unable to locate cave for generation!"); fail.set(true); return; } - if (y == -1) { + if(y == -1) { int h = (int) caveStartHeight.get(rng, x, z, data); int ma = breakSurface ? h : (int) (engine.getComplex().getHeightStream().get(x, z) - 9); y = Math.min(h, ma); @@ -93,7 +93,7 @@ public class IrisCavePlacer implements IRare { try { cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); fail.set(true); } @@ -102,7 +102,7 @@ public class IrisCavePlacer implements IRare { public int getSize(IrisData data) { IrisCave cave = getRealCave(data); - if (cave != null) { + if(cave != null) { return cave.getMaxSize(data); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisColor.java b/src/main/java/com/volmit/iris/engine/object/IrisColor.java index eb65495f2..59022d7a0 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisColor.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisColor.java @@ -55,7 +55,7 @@ public class IrisColor { private int blue = 0; public static Color blend(Color... c) { - if (c == null || c.length <= 0) { + if(c == null || c.length <= 0) { return null; } float ratio = 1f / ((float) c.length); @@ -65,7 +65,7 @@ public class IrisColor { int g = 0; int b = 0; - for (Color value : c) { + for(Color value : c) { int rgb = value.getRGB(); int a1 = (rgb >> 24 & 0xff); int r1 = ((rgb & 0xff0000) >> 16); @@ -82,11 +82,11 @@ public class IrisColor { public Color getColor() { return color.aquire(() -> { - if (hex != null) { + if(hex != null) { String v = (hex.startsWith("#") ? hex : "#" + hex).trim(); try { return Color.decode(v); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -101,11 +101,11 @@ public class IrisColor { } public int getAsRGB() { - if (hex != null) { + if(hex != null) { try { - if (hex.startsWith("#")) hex = hex.substring(1); + if(hex.startsWith("#")) hex = hex.substring(1); return Integer.parseInt(hex, 16); - } catch (NumberFormatException e) { + } catch(NumberFormatException e) { return 0; } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCommand.java b/src/main/java/com/volmit/iris/engine/object/IrisCommand.java index 45b4a8510..f7e1cb4cc 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCommand.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCommand.java @@ -61,17 +61,17 @@ public class IrisCommand { } public void run(Location at) { - if (!isValid(at.getWorld())) { + if(!isValid(at.getWorld())) { return; } - for (String command : commands) { + for(String command : commands) { command = (command.startsWith("/") ? command.replaceFirst("/", "") : command) - .replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX())) - .replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY())) - .replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ())); + .replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX())) + .replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY())) + .replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ())); final String finalCommand = command; - if (repeat) { + if(repeat) { Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay, repeatDelay); } else { Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCommandRegistry.java b/src/main/java/com/volmit/iris/engine/object/IrisCommandRegistry.java index 8dcc244a1..c0978c9e7 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCommandRegistry.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCommandRegistry.java @@ -70,18 +70,18 @@ public class IrisCommandRegistry { private boolean commandAllRandomLocations = true; public void run(Player p) { - if (rawCommands.isNotEmpty()) { + if(rawCommands.isNotEmpty()) { Location part = p.getLocation().clone().add( - commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX, - commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY, - commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ); - for (IrisCommand rawCommand : rawCommands) { + commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX, + commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY, + commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ); + for(IrisCommand rawCommand : rawCommands) { rawCommand.run(part); - if (commandAllRandomLocations) { + if(commandAllRandomLocations) { part = p.getLocation().clone().add( - commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX, - commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY, - commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ); + commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX, + commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY, + commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ); } } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCompat.java b/src/main/java/com/volmit/iris/engine/object/IrisCompat.java index 089272214..a5738aa3d 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCompat.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCompat.java @@ -48,11 +48,11 @@ public class IrisCompat { J.attemptAsync(() -> IO.writeAll(new File(f.getParentFile(), "compat.default.json"), defa)); - if (!f.exists()) { + if(!f.exists()) { J.a(() -> { try { IO.writeAll(f, defa); - } catch (IOException e) { + } catch(IOException e) { Iris.error("Failed to writeNodeData to compat file"); Iris.reportError(e); } @@ -63,14 +63,14 @@ public class IrisCompat { try { IrisCompat rea = new Gson().fromJson(IO.readAll(f), IrisCompat.class); - for (IrisCompatabilityBlockFilter i : rea.getBlockFilters()) { + for(IrisCompatabilityBlockFilter i : rea.getBlockFilters()) { def.getBlockFilters().add(i); } - for (IrisCompatabilityItemFilter i : rea.getItemFilters()) { + for(IrisCompatabilityItemFilter i : rea.getItemFilters()) { def.getItemFilters().add(i); } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } @@ -264,21 +264,21 @@ public class IrisCompat { BlockData tx = B.getOrNull(buf); - if (tx != null) { + if(tx != null) { return tx; } searching: - while (true) { - if (err-- <= 0) { + while(true) { + if(err-- <= 0) { return B.get("STONE"); } - for (IrisCompatabilityBlockFilter i : blockFilters) { - if (i.getWhen().equalsIgnoreCase(buf)) { + for(IrisCompatabilityBlockFilter i : blockFilters) { + if(i.getWhen().equalsIgnoreCase(buf)) { BlockData b = i.getReplace(); - if (b != null) { + if(b != null) { return b; } @@ -296,28 +296,28 @@ public class IrisCompat { int err = 16; Material txf = B.getMaterialOrNull(buf); - if (txf != null) { + if(txf != null) { return txf; } int nomore = 64; searching: - while (true) { - if (nomore < 0) { + while(true) { + if(nomore < 0) { return B.getMaterial("STONE"); } nomore--; - if (err-- <= 0) { + if(err-- <= 0) { break; } - for (IrisCompatabilityItemFilter i : itemFilters) { - if (i.getWhen().equalsIgnoreCase(buf)) { + for(IrisCompatabilityItemFilter i : itemFilters) { + if(i.getWhen().equalsIgnoreCase(buf)) { Material b = i.getReplace(); - if (b != null) { + if(b != null) { return b; } @@ -332,28 +332,28 @@ public class IrisCompat { buf = n; BlockData tx = B.getOrNull(buf); - if (tx != null) { + if(tx != null) { return tx.getMaterial(); } nomore = 64; searching: - while (true) { - if (nomore < 0) { + while(true) { + if(nomore < 0) { return B.getMaterial("STONE"); } nomore--; - if (err-- <= 0) { + if(err-- <= 0) { return B.getMaterial("STONE"); } - for (IrisCompatabilityBlockFilter i : blockFilters) { - if (i.getWhen().equalsIgnoreCase(buf)) { + for(IrisCompatabilityBlockFilter i : blockFilters) { + if(i.getWhen().equalsIgnoreCase(buf)) { BlockData b = i.getReplace(); - if (b != null) { + if(b != null) { return b.getMaterial(); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java index bef92b2ef..01cc9fbdc 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityBlockFilter.java @@ -59,7 +59,7 @@ public class IrisCompatabilityBlockFilter { { BlockData b = B.getOrNull(supplement); - if (b == null) { + if(b == null) { return null; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java index 105eb7648..7cf009537 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisCompatabilityItemFilter.java @@ -56,7 +56,7 @@ public class IrisCompatabilityItemFilter { { Material b = B.getMaterialOrNull(supplement); - if (b == null) { + if(b == null) { return null; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java index 79b7e6de5..bc3300ea6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java @@ -75,7 +75,7 @@ public class IrisDecorator { private int stackMax = 1; @DependsOn({"stackMin", "stackMax"}) @Desc("Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height" + - "\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height") + "\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height") private boolean scaleStack = false; @Required @MinNumber(0) @@ -97,19 +97,19 @@ public class IrisDecorator { private double topThreshold = 1.0; public int getHeight(RNG rng, double x, double z, IrisData data) { - if (stackMin == stackMax) { + if(stackMin == stackMax) { return stackMin; } return getHeightGenerator(rng, data) - .fit(stackMin, stackMax, - x / heightVariance.getZoom(), - z / heightVariance.getZoom()) + 1; + .fit(stackMin, stackMax, + x / heightVariance.getZoom(), + z / heightVariance.getZoom()) + 1; } public CNG getHeightGenerator(RNG rng, IrisData data) { return heightGenerator.aquire(() -> - heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data)); + heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data)); } public CNG getGenerator(RNG rng, IrisData data) { @@ -118,9 +118,9 @@ public class IrisDecorator { public CNG getVarianceGenerator(RNG rng, IrisData data) { return varianceGenerator.aquire(() -> - variance.create( - rng.nextParallelRNG(getBlockData(data).size()), data) - .scale(1D / variance.getZoom())); + variance.create( + rng.nextParallelRNG(getBlockData(data).size()), data) + .scale(1D / variance.getZoom())); } public KList add(String b) { @@ -129,7 +129,7 @@ public class IrisDecorator { } public BlockData getBlockData(IrisBiome b, RNG rng, double x, double z, IrisData data) { - if (getBlockData(data).isEmpty()) { + if(getBlockData(data).isEmpty()) { Iris.warn("Empty Block Data for " + b.getName()); return null; } @@ -137,8 +137,8 @@ public class IrisDecorator { double xx = x / style.getZoom(); double zz = z / style.getZoom(); - if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { - if (getBlockData(data).size() == 1) { + if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { + if(getBlockData(data).size() == 1) { return getBlockData(data).get(0); } @@ -149,7 +149,7 @@ public class IrisDecorator { } public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) { - if (getBlockData(data).isEmpty()) { + if(getBlockData(data).isEmpty()) { Iris.warn("Empty Block Data for " + b.getName()); return null; } @@ -158,13 +158,13 @@ public class IrisDecorator { double yy = y; double zz = z; - if (!getVarianceGenerator(rng, data).isStatic()) { + if(!getVarianceGenerator(rng, data).isStatic()) { xx = x / style.getZoom(); yy = y / style.getZoom(); zz = z / style.getZoom(); } - if (getBlockData(data).size() == 1) { + if(getBlockData(data).size() == 1) { return getBlockData(data).get(0); } @@ -172,15 +172,15 @@ public class IrisDecorator { } public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) { - if (getBlockDataTops(data).isEmpty()) { + if(getBlockDataTops(data).isEmpty()) { return getBlockData100(b, rng, x, y, z, data); } double xx = x / style.getZoom(); double zz = z / style.getZoom(); - if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here - if (getBlockData(data).size() == 1) { + if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here + if(getBlockData(data).size() == 1) { return getBlockDataTops(data).get(0); } @@ -194,10 +194,10 @@ public class IrisDecorator { return blockData.aquire(() -> { KList blockData = new KList<>(); - for (IrisBlockData i : palette) { + for(IrisBlockData i : palette) { BlockData bx = i.getBlockData(data); - if (bx != null) { - for (int n = 0; n < i.getWeight(); n++) { + if(bx != null) { + for(int n = 0; n < i.getWeight(); n++) { blockData.add(bx); } } @@ -211,10 +211,10 @@ public class IrisDecorator { return blockDataTops.aquire(() -> { KList blockDataTops = new KList<>(); - for (IrisBlockData i : topPalette) { + for(IrisBlockData i : topPalette) { BlockData bx = i.getBlockData(data); - if (bx != null) { - for (int n = 0; n < i.getWeight(); n++) { + if(bx != null) { + for(int n = 0; n < i.getWeight(); n++) { blockDataTops.add(bx); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java index 38113072d..d1b7689d4 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDepositGenerator.java @@ -89,7 +89,7 @@ public class IrisDepositGenerator { RNG rngv = rng.nextParallelRNG(3957778); KList objectsf = new KList<>(); - for (int i = 0; i < varience; i++) { + for(int i = 0; i < varience; i++) { objectsf.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598), rdata)); } @@ -108,10 +108,10 @@ public class IrisDepositGenerator { int w = dim / 2; IrisObject o = new IrisObject(dim, dim, dim); - if (s == 1) { + if(s == 1) { o.getBlocks().put(o.getCenter(), nextBlock(rngv, rdata)); } else { - while (s > 0) { + while(s > 0) { s--; BlockVector ang = new BlockVector(rngv.i(-w, w), rngv.i(-w, w), rngv.i(-w, w)); BlockVector pos = o.getCenter().clone().add(ang).toBlockVector(); @@ -131,10 +131,10 @@ public class IrisDepositGenerator { { KList blockData = new KList<>(); - for (IrisBlockData ix : palette) { + for(IrisBlockData ix : palette) { BlockData bx = ix.getBlockData(rdata); - if (bx != null) { + if(bx != null) { blockData.add(bx); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index f0129e226..683dd364d 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -22,7 +22,6 @@ import com.volmit.iris.Iris; import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.engine.data.cache.AtomicCache; -import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.object.annotations.ArrayType; import com.volmit.iris.engine.object.annotations.Desc; import com.volmit.iris.engine.object.annotations.MaxNumber; @@ -230,14 +229,14 @@ public class IrisDimension extends IrisRegistrant { private KList ores = new KList<>(); public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) { - if (ores.isEmpty()) { + if(ores.isEmpty()) { return null; } BlockData b = null; - for (IrisOreGenerator i : ores) { + for(IrisOreGenerator i : ores) { - b = i.generate(x,y,z,rng,data); - if(b != null ){ + b = i.generate(x, y, z, rng, data); + if(b != null) { return b; } } @@ -250,11 +249,11 @@ public class IrisDimension extends IrisRegistrant { int jump = strongholdJumpDistance; RNG rng = new RNG((seed * 223) + 12945); - for (int i = 0; i < maxStrongholds + 1; i++) { + for(int i = 0; i < maxStrongholds + 1; i++) { int m = i + 1; pos.add(new Position2( - (int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)), - (int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)) + (int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)), + (int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)) )); } @@ -300,7 +299,7 @@ public class IrisDimension extends IrisRegistrant { public KList getAllRegions(DataProvider g) { KList r = new KList<>(); - for (String i : getRegions()) { + for(String i : getRegions()) { r.add(g.getData().getRegionLoader().load(i)); } @@ -310,7 +309,7 @@ public class IrisDimension extends IrisRegistrant { public KList getAllAnyRegions() { KList r = new KList<>(); - for (String i : getRegions()) { + for(String i : getRegions()) { r.add(IrisData.loadAnyRegion(i)); } @@ -324,8 +323,8 @@ public class IrisDimension extends IrisRegistrant { public KList getAllAnyBiomes() { KList r = new KList<>(); - for (IrisRegion i : getAllAnyRegions()) { - if (i == null) { + for(IrisRegion i : getAllAnyRegions()) { + if(i == null) { continue; } @@ -336,7 +335,7 @@ public class IrisDimension extends IrisRegistrant { } public IrisGeneratorStyle getBiomeStyle(InferredType type) { - switch (type) { + switch(type) { case CAVE: return caveBiomeStyle; case LAND: @@ -358,14 +357,14 @@ public class IrisDimension extends IrisRegistrant { IO.delete(new File(datapacks, "iris/data/" + getLoadKey().toLowerCase())); - for (IrisBiome i : getAllBiomes(data)) { - if (i.isCustom()) { + for(IrisBiome i : getAllBiomes(data)) { + if(i.isCustom()) { write = true; - for (IrisBiomeCustom j : i.getCustomDerivitives()) { + for(IrisBiomeCustom j : i.getCustomDerivitives()) { File output = new File(datapacks, "iris/data/" + getLoadKey().toLowerCase() + "/worldgen/biome/" + j.getId() + ".json"); - if (!output.exists()) { + if(!output.exists()) { changed = true; } @@ -373,7 +372,7 @@ public class IrisDimension extends IrisRegistrant { output.getParentFile().mkdirs(); try { IO.writeAll(output, j.generateJson()); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -381,18 +380,18 @@ public class IrisDimension extends IrisRegistrant { } } - if (write) { + if(write) { File mcm = new File(datapacks, "iris/pack.mcmeta"); try { IO.writeAll(mcm, """ - { - "pack": { - "description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.", - "pack_format": 7 - } + { + "pack": { + "description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.", + "pack_format": 7 } - """); - } catch (IOException e) { + } + """); + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDirection.java b/src/main/java/com/volmit/iris/engine/object/IrisDirection.java index 9cc17a8be..263483a5f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDirection.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDirection.java @@ -67,7 +67,7 @@ public enum IrisDirection { } public static IrisDirection getDirection(BlockFace f) { - return switch (f) { + return switch(f) { case DOWN -> DOWN_NEGATIVE_Y; case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X; case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z; @@ -79,9 +79,9 @@ public enum IrisDirection { } public static IrisDirection fromJigsawBlock(String direction) { - for (IrisDirection i : IrisDirection.values()) { - if (i.name().toLowerCase().split("\\Q_\\E")[0] - .equals(direction.split("\\Q_\\E")[0])) { + for(IrisDirection i : IrisDirection.values()) { + if(i.name().toLowerCase().split("\\Q_\\E")[0] + .equals(direction.split("\\Q_\\E")[0])) { return i; } } @@ -90,7 +90,7 @@ public enum IrisDirection { } public static IrisDirection getDirection(Jigsaw.Orientation orientation) { - return switch (orientation) { + return switch(orientation) { case DOWN_EAST, UP_EAST, EAST_UP -> EAST_POSITIVE_X; case DOWN_NORTH, UP_NORTH, NORTH_UP -> NORTH_NEGATIVE_Z; case DOWN_SOUTH, UP_SOUTH, SOUTH_UP -> SOUTH_POSITIVE_Z; @@ -103,11 +103,11 @@ public enum IrisDirection { double m = Double.MAX_VALUE; IrisDirection s = null; - for (IrisDirection i : values()) { + for(IrisDirection i : values()) { Vector x = i.toVector(); double g = x.distance(v); - if (g < m) { + if(g < m) { m = g; s = i; } @@ -120,11 +120,11 @@ public enum IrisDirection { double m = Double.MAX_VALUE; IrisDirection s = null; - for (IrisDirection i : d) { + for(IrisDirection i : d) { Vector x = i.toVector(); double g = x.distance(v); - if (g < m) { + if(g < m) { m = g; s = i; } @@ -137,11 +137,11 @@ public enum IrisDirection { double m = Double.MAX_VALUE; IrisDirection s = null; - for (IrisDirection i : d) { + for(IrisDirection i : d) { Vector x = i.toVector(); double g = x.distance(v); - if (g < m) { + if(g < m) { m = g; s = i; } @@ -157,8 +157,8 @@ public enum IrisDirection { public static IrisDirection getDirection(Vector v) { Vector k = VectorMath.triNormalize(v.clone().normalize()); - for (IrisDirection i : udnews()) { - if (i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) { + for(IrisDirection i : udnews()) { + if(i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) { return i; } } @@ -174,24 +174,25 @@ public enum IrisDirection { * Get the directional value from the given byte from common directional blocks * (MUST BE BETWEEN 0 and 5 INCLUSIVE) * - * @param b the byte + * @param b + * the byte * @return the direction or null if the byte is outside of the inclusive range * 0-5 */ public static IrisDirection fromByte(byte b) { - if (b > 5 || b < 0) { + if(b > 5 || b < 0) { return null; } - if (b == 0) { + if(b == 0) { return DOWN_NEGATIVE_Y; - } else if (b == 1) { + } else if(b == 1) { return UP_POSITIVE_Y; - } else if (b == 2) { + } else if(b == 2) { return NORTH_NEGATIVE_Z; - } else if (b == 3) { + } else if(b == 3) { return SOUTH_POSITIVE_Z; - } else if (b == 4) { + } else if(b == 4) { return WEST_NEGATIVE_X; } else { return EAST_POSITIVE_X; @@ -199,25 +200,25 @@ public enum IrisDirection { } public static void calculatePermutations() { - if (permute != null) { + if(permute != null) { return; } permute = new KMap<>(); - for (IrisDirection i : udnews()) { - for (IrisDirection j : udnews()) { + for(IrisDirection i : udnews()) { + for(IrisDirection j : udnews()) { GBiset b = new GBiset<>(i, j); - if (i.equals(j)) { + if(i.equals(j)) { permute.put(b, new DOP("DIRECT") { @Override public Vector op(Vector v) { return v; } }); - } else if (i.reverse().equals(j)) { - if (i.isVertical()) { + } else if(i.reverse().equals(j)) { + if(i.isVertical()) { permute.put(b, new DOP("R180CCZ") { @Override public Vector op(Vector v) { @@ -232,42 +233,42 @@ public enum IrisDirection { } }); } - } else if (getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CX") { @Override public Vector op(Vector v) { return VectorMath.rotate90CX(v); } }); - } else if (getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CCX") { @Override public Vector op(Vector v) { return VectorMath.rotate90CCX(v); } }); - } else if (getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CY") { @Override public Vector op(Vector v) { return VectorMath.rotate90CY(v); } }); - } else if (getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CCY") { @Override public Vector op(Vector v) { return VectorMath.rotate90CCY(v); } }); - } else if (getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CZ") { @Override public Vector op(Vector v) { return VectorMath.rotate90CZ(v); } }); - } else if (getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CCZ") { @Override public Vector op(Vector v) { @@ -288,7 +289,7 @@ public enum IrisDirection { @Override public String toString() { - return switch (this) { + return switch(this) { case DOWN_NEGATIVE_Y -> "Down"; case EAST_POSITIVE_X -> "East"; case NORTH_NEGATIVE_Z -> "North"; @@ -308,7 +309,7 @@ public enum IrisDirection { } public boolean isCrooked(IrisDirection to) { - if (equals(to.reverse())) { + if(equals(to.reverse())) { return false; } @@ -318,9 +319,9 @@ public enum IrisDirection { public Vector angle(Vector initial, IrisDirection d) { calculatePermutations(); - for (Map.Entry, DOP> entry : permute.entrySet()) { + for(Map.Entry, DOP> entry : permute.entrySet()) { GBiset i = entry.getKey(); - if (i.getA().equals(this) && i.getB().equals(d)) { + if(i.getA().equals(this) && i.getB().equals(d)) { return entry.getValue().op(initial); } } @@ -329,7 +330,7 @@ public enum IrisDirection { } public IrisDirection reverse() { - switch (this) { + switch(this) { case DOWN_NEGATIVE_Y: return UP_POSITIVE_Y; case EAST_POSITIVE_X: @@ -371,7 +372,7 @@ public enum IrisDirection { * @return the byte value */ public byte byteValue() { - switch (this) { + switch(this) { case DOWN_NEGATIVE_Y: return 0; case EAST_POSITIVE_X: @@ -392,7 +393,7 @@ public enum IrisDirection { } public BlockFace getFace() { - return switch (this) { + return switch(this) { case DOWN_NEGATIVE_Y -> BlockFace.DOWN; case EAST_POSITIVE_X -> BlockFace.EAST; case NORTH_NEGATIVE_Z -> BlockFace.NORTH; @@ -404,7 +405,7 @@ public enum IrisDirection { } public Axis getAxis() { - return switch (this) { + return switch(this) { case DOWN_NEGATIVE_Y, UP_POSITIVE_Y -> Axis.Y; case EAST_POSITIVE_X, WEST_NEGATIVE_X -> Axis.X; case NORTH_NEGATIVE_Z, SOUTH_POSITIVE_Z -> Axis.Z; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDuration.java b/src/main/java/com/volmit/iris/engine/object/IrisDuration.java index 9e30f9a0b..879cee2b1 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDuration.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDuration.java @@ -65,15 +65,15 @@ public class IrisDuration { public long toMilliseconds() { return getMilliseconds() - + TimeUnit.SECONDS.toMillis(getSeconds()) - + TimeUnit.MINUTES.toMillis(getMinutes()) - + TimeUnit.HOURS.toMillis(getHours()) - + TimeUnit.DAYS.toMillis(getDays()) - + (getMinecraftTicks() * 50L) - + (getMinecraftHours() * 50000L) - + (getMinecraftWeeks() * 50000L) - + (getMinecraftDays() * 24000L) - + (getMinecraftWeeks() * 168000L) - + (getMinecraftLunarCycles() * 192000L); + + TimeUnit.SECONDS.toMillis(getSeconds()) + + TimeUnit.MINUTES.toMillis(getMinutes()) + + TimeUnit.HOURS.toMillis(getHours()) + + TimeUnit.DAYS.toMillis(getDays()) + + (getMinecraftTicks() * 50L) + + (getMinecraftHours() * 50000L) + + (getMinecraftWeeks() * 50000L) + + (getMinecraftDays() * 24000L) + + (getMinecraftWeeks() * 168000L) + + (getMinecraftLunarCycles() * 192000L); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEffect.java b/src/main/java/com/volmit/iris/engine/object/IrisEffect.java index c8305111e..9ec736742 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEffect.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEffect.java @@ -166,19 +166,19 @@ public class IrisEffect { { PotionEffectType t = PotionEffectType.LUCK; - if (getPotionEffect().isEmpty()) { + if(getPotionEffect().isEmpty()) { return t; } try { - for (PotionEffectType i : PotionEffectType.values()) { - if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) { + for(PotionEffectType i : PotionEffectType.values()) { + if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) { t = i; return t; } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -190,50 +190,50 @@ public class IrisEffect { } public void apply(Player p, Engine g) { - if (!canTick()) { + if(!canTick()) { return; } - if (RNG.r.nextInt(chance) != 0) { + if(RNG.r.nextInt(chance) != 0) { return; } - if (sound != null) { + if(sound != null) { Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance)); J.s(() -> p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch))); } - if (particleEffect != null) { + if(particleEffect != null) { Location part = p.getLocation().clone().add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)).clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90)).multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth))); part.setY(Math.round(g.getHeight(part.getBlockX(), part.getBlockZ())) + 1); part.add(RNG.r.d(), 0, RNG.r.d()); - if (extra != 0) { + if(extra != 0) { J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), - part.getZ(), - particleCount, - randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, - randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, - randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, - extra)); + part.getZ(), + particleCount, + randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, + randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, + randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, + extra)); } else { J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), - particleCount, - randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, - randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, - randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ)); + particleCount, + randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, + randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, + randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ)); } } - if (commandRegistry != null) { + if(commandRegistry != null) { commandRegistry.run(p); } - if (potionStrength > -1) { - if (p.hasPotionEffect(getRealType())) { + if(potionStrength > -1) { + if(p.hasPotionEffect(getRealType())) { PotionEffect e = p.getPotionEffect(getRealType()); - if (e.getAmplifier() > getPotionStrength()) { + if(e.getAmplifier() > getPotionStrength()) { return; } @@ -241,45 +241,45 @@ public class IrisEffect { } J.s(() -> p.addPotionEffect(new PotionEffect(getRealType(), - RNG.r.i(Math.min(potionTicksMax, potionTicksMin), - Math.max(potionTicksMax, potionTicksMin)), - getPotionStrength(), - true, false, false))); + RNG.r.i(Math.min(potionTicksMax, potionTicksMin), + Math.max(potionTicksMax, potionTicksMin)), + getPotionStrength(), + true, false, false))); } } public void apply(Entity p) { - if (!canTick()) { + if(!canTick()) { return; } - if (RNG.r.nextInt(chance) != 0) { + if(RNG.r.nextInt(chance) != 0) { return; } - if (sound != null) { + if(sound != null) { Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance)); J.s(() -> p.getWorld().playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch))); } - if (particleEffect != null) { + if(particleEffect != null) { Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1, 1, 1).multiply(RNG.r.d())).subtract(new Vector(1, 1, 1).multiply(RNG.r.d())); part.add(RNG.r.d(), 0, RNG.r.d()); - if (extra != 0) { + if(extra != 0) { J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), - part.getZ(), - particleCount, - randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, - randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, - randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, - extra)); + part.getZ(), + particleCount, + randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, + randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, + randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, + extra)); } else { J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), - particleCount, - randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, - randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, - randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ)); + particleCount, + randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, + randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, + randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ)); } } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisElipsoid.java b/src/main/java/com/volmit/iris/engine/object/IrisElipsoid.java index 35ff3c9ac..c29ba4b49 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisElipsoid.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisElipsoid.java @@ -53,9 +53,9 @@ public class IrisElipsoid implements IRare { @SuppressWarnings("SuspiciousNameCombination") public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) { writer.setElipsoid(x, y, z, - xRadius.get(rng, z, y, engine.getData()), - yRadius.get(rng, x, z, engine.getData()), - zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0))); + xRadius.get(rng, z, y, engine.getData()), + yRadius.get(rng, x, z, engine.getData()), + zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0))); } public double maxSize() { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java b/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java index 2988d6807..f8276a1ce 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEnchantment.java @@ -61,25 +61,25 @@ public class IrisEnchantment { public void apply(RNG rng, ItemMeta meta) { try { - if (rng.nextDouble() < chance) { - if (meta instanceof EnchantmentStorageMeta) { + if(rng.nextDouble() < chance) { + if(meta instanceof EnchantmentStorageMeta) { ((EnchantmentStorageMeta) meta).addStoredEnchant(getEnchant(), getLevel(rng), true); return; } meta.addEnchant(getEnchant(), getLevel(rng), true); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } public Enchantment getEnchant() { - for (Field i : Enchantment.class.getDeclaredFields()) { - if (i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) { + for(Field i : Enchantment.class.getDeclaredFields()) { + if(i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) { try { return (Enchantment) i.get(null); - } catch (IllegalArgumentException | IllegalAccessException e) { + } catch(IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEngineChunkData.java b/src/main/java/com/volmit/iris/engine/object/IrisEngineChunkData.java index ed62a80a4..a4306af7a 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEngineChunkData.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEngineChunkData.java @@ -28,10 +28,10 @@ public class IrisEngineChunkData { private KList cooldowns = new KList<>(); public void cleanup(Engine engine) { - for (IrisEngineSpawnerCooldown i : getCooldowns().copy()) { + for(IrisEngineSpawnerCooldown i : getCooldowns().copy()) { IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner()); - if (sp == null || i.canSpawn(sp.getMaximumRate())) { + if(sp == null || i.canSpawn(sp.getMaximumRate())) { getCooldowns().remove(i); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEngineData.java b/src/main/java/com/volmit/iris/engine/object/IrisEngineData.java index 9b58040d4..5282de0b6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEngineData.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEngineData.java @@ -38,8 +38,8 @@ public class IrisEngineData { public IrisEngineChunkData getChunk(int x, int z) { long k = Cache.key(x, z); - for (IrisEngineChunkData i : chunks) { - if (i.getChunk() == k) { + for(IrisEngineChunkData i : chunks) { + if(i.getChunk() == k) { return i; } } @@ -51,18 +51,18 @@ public class IrisEngineData { } public void cleanup(Engine engine) { - for (IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) { + for(IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) { IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner()); - if (sp == null || i.canSpawn(sp.getMaximumRate())) { + if(sp == null || i.canSpawn(sp.getMaximumRate())) { getSpawnerCooldowns().remove(i); } } - for (IrisEngineChunkData i : chunks.copy()) { + for(IrisEngineChunkData i : chunks.copy()) { i.cleanup(engine); - if (i.isEmpty()) { + if(i.isEmpty()) { getChunks().remove(i); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEntity.java b/src/main/java/com/volmit/iris/engine/object/IrisEntity.java index f0b0a2b53..2297f8b06 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEntity.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEntity.java @@ -186,22 +186,22 @@ public class IrisEntity extends IrisRegistrant { } public Entity spawn(Engine gen, Location at, RNG rng) { - if (!Chunks.isSafe(at)) { + if(!Chunks.isSafe(at)) { return null; } - if (isSpawnEffectRiseOutOfGround()) { + if(isSpawnEffectRiseOutOfGround()) { AtomicReference f = new AtomicReference<>(at); try { J.sfut(() -> { - if (Chunks.hasPlayersNearby(f.get())) { + if(Chunks.hasPlayersNearby(f.get())) { Location b = f.get().clone(); Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ()); f.set(start); } }).get(); - } catch (InterruptedException e) { + } catch(InterruptedException e) { e.printStackTrace(); - } catch (ExecutionException e) { + } catch(ExecutionException e) { e.printStackTrace(); } at = f.get(); @@ -209,23 +209,23 @@ public class IrisEntity extends IrisRegistrant { Entity ee = doSpawn(at); - if (ee == null && !Chunks.isSafe(at)) { + if(ee == null && !Chunks.isSafe(at)) { return null; } - if (!spawnerScript.isEmpty() && ee == null) { - synchronized (this) { + if(!spawnerScript.isEmpty() && ee == null) { + synchronized(this) { gen.getExecution().getAPI().setLocation(at); try { ee = (Entity) gen.getExecution().evaluate(spawnerScript); - } catch (Throwable ex) { + } catch(Throwable ex) { Iris.error("You must return an Entity in your scripts to use entity scripts!"); ex.printStackTrace(); } } } - if (ee == null) { + if(ee == null) { return null; } @@ -239,25 +239,25 @@ public class IrisEntity extends IrisRegistrant { e.setPersistent(isKeepEntity() || IrisSettings.get().getWorld().isForcePersistEntities()); int gg = 0; - for (IrisEntity i : passengers) { + for(IrisEntity i : passengers) { Entity passenger = i.spawn(gen, at, rng.nextParallelRNG(234858 + gg++)); - if (!Bukkit.isPrimaryThread()) { + if(!Bukkit.isPrimaryThread()) { J.s(() -> e.addPassenger(passenger)); } } - if (e instanceof Attributable) { + if(e instanceof Attributable) { Attributable a = (Attributable) e; - for (IrisAttributeModifier i : getAttributes()) { + for(IrisAttributeModifier i : getAttributes()) { i.apply(rng, a); } } - if (e instanceof Lootable) { + if(e instanceof Lootable) { Lootable l = (Lootable) e; - if (getLoot().getTables().isNotEmpty()) { + if(getLoot().getTables().isNotEmpty()) { Location finalAt = at; l.setLootTable(new LootTable() { @Override @@ -269,7 +269,7 @@ public class IrisEntity extends IrisRegistrant { public Collection populateLoot(Random random, LootContext context) { KList items = new KList<>(); - for (String fi : getLoot().getTables()) { + for(String fi : getLoot().getTables()) { IrisLootTable i = gen.getData().getLootLoader().load(fi); items.addAll(i.getLoot(gen.isStudio(), false, rng.nextParallelRNG(345911), InventorySlotType.STORAGE, finalAt.getBlockX(), finalAt.getBlockY(), finalAt.getBlockZ(), 8, 4)); } @@ -279,7 +279,7 @@ public class IrisEntity extends IrisRegistrant { @Override public void fillInventory(Inventory inventory, Random random, LootContext context) { - for (ItemStack i : populateLoot(random, context)) { + for(ItemStack i : populateLoot(random, context)) { inventory.addItem(i); } @@ -289,52 +289,52 @@ public class IrisEntity extends IrisRegistrant { } } - if (e instanceof LivingEntity) { + if(e instanceof LivingEntity) { LivingEntity l = (LivingEntity) e; l.setAI(isAi()); l.setCanPickupItems(isPickupItems()); - if (getLeashHolder() != null) { + if(getLeashHolder() != null) { l.setLeashHolder(getLeashHolder().spawn(gen, at, rng.nextParallelRNG(234548))); } l.setRemoveWhenFarAway(isRemovable()); - if (getHelmet() != null && rng.i(1, getHelmet().getRarity()) == 1) { + if(getHelmet() != null && rng.i(1, getHelmet().getRarity()) == 1) { l.getEquipment().setHelmet(getHelmet().get(gen.isStudio(), rng)); } - if (getChestplate() != null && rng.i(1, getChestplate().getRarity()) == 1) { + if(getChestplate() != null && rng.i(1, getChestplate().getRarity()) == 1) { l.getEquipment().setChestplate(getChestplate().get(gen.isStudio(), rng)); } - if (getLeggings() != null && rng.i(1, getLeggings().getRarity()) == 1) { + if(getLeggings() != null && rng.i(1, getLeggings().getRarity()) == 1) { l.getEquipment().setLeggings(getLeggings().get(gen.isStudio(), rng)); } - if (getBoots() != null && rng.i(1, getBoots().getRarity()) == 1) { + if(getBoots() != null && rng.i(1, getBoots().getRarity()) == 1) { l.getEquipment().setBoots(getBoots().get(gen.isStudio(), rng)); } - if (getMainHand() != null && rng.i(1, getMainHand().getRarity()) == 1) { + if(getMainHand() != null && rng.i(1, getMainHand().getRarity()) == 1) { l.getEquipment().setItemInMainHand(getMainHand().get(gen.isStudio(), rng)); } - if (getOffHand() != null && rng.i(1, getOffHand().getRarity()) == 1) { + if(getOffHand() != null && rng.i(1, getOffHand().getRarity()) == 1) { l.getEquipment().setItemInOffHand(getOffHand().get(gen.isStudio(), rng)); } } - if (e instanceof Ageable && isBaby()) { + if(e instanceof Ageable && isBaby()) { ((Ageable) e).setBaby(); } - if (e instanceof Panda) { + if(e instanceof Panda) { ((Panda) e).setMainGene(getPandaMainGene()); ((Panda) e).setMainGene(getPandaHiddenGene()); } - if (e instanceof Villager) { + if(e instanceof Villager) { Villager villager = (Villager) e; villager.setRemoveWhenFarAway(false); Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> { @@ -342,27 +342,27 @@ public class IrisEntity extends IrisRegistrant { }, 1); } - if (e instanceof Mob) { + if(e instanceof Mob) { Mob m = (Mob) e; m.setAware(isAware()); } - if (spawnEffect != null) { + if(spawnEffect != null) { spawnEffect.apply(e); } - if (postSpawnScripts.isNotEmpty()) { - synchronized (this) { + if(postSpawnScripts.isNotEmpty()) { + synchronized(this) { gen.getExecution().getAPI().setLocation(at); gen.getExecution().getAPI().setEntity(ee); - for (String i : postSpawnScripts) { + for(String i : postSpawnScripts) { gen.getExecution().execute(i); } } } - if (rawCommands.isNotEmpty()) { + if(rawCommands.isNotEmpty()) { final Location fat = at; rawCommands.forEach(r -> r.run(fat)); } @@ -370,7 +370,7 @@ public class IrisEntity extends IrisRegistrant { Location finalAt1 = at; J.s(() -> { - if (isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) { + if(isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) { Location start = finalAt1.clone(); e.setInvulnerable(true); ((LivingEntity) e).setAI(false); @@ -379,17 +379,17 @@ public class IrisEntity extends IrisRegistrant { AtomicInteger t = new AtomicInteger(0); AtomicInteger v = new AtomicInteger(0); v.set(J.sr(() -> { - if (t.get() > 100) { + if(t.get() > 100) { J.csr(v.get()); return; } t.incrementAndGet(); - if (e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) { + if(e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) { e.teleport(start.add(new Vector(0, 0.1, 0))); ItemStack itemCrackData = new ItemStack(((LivingEntity) e).getEyeLocation().clone().subtract(0, 2, 0).getBlock().getBlockData().getMaterial()); e.getWorld().spawnParticle(Particle.ITEM_CRACK, ((LivingEntity) e).getEyeLocation(), 6, 0.2, 0.4, 0.2, 0.06f, itemCrackData); - if (M.r(0.2)) { + if(M.r(0.2)) { e.getWorld().playSound(e.getLocation(), Sound.BLOCK_CHORUS_FLOWER_GROW, 0.8f, 0.1f); } } else { @@ -410,11 +410,11 @@ public class IrisEntity extends IrisRegistrant { private int surfaceY(Location l) { int m = l.getBlockY(); - while (m-- > 0) { + while(m-- > 0) { Location ll = l.clone(); ll.setY(m); - if (ll.getBlock().getType().isSolid()) { + if(ll.getBlock().getType().isSolid()) { return m; } } @@ -423,30 +423,30 @@ public class IrisEntity extends IrisRegistrant { } private Entity doSpawn(Location at) { - if (!Chunks.isSafe(at)) { + if(!Chunks.isSafe(at)) { return null; } - if (type.equals(EntityType.UNKNOWN)) { + if(type.equals(EntityType.UNKNOWN)) { return null; } - if (!Bukkit.isPrimaryThread()) { + if(!Bukkit.isPrimaryThread()) { // Someone called spawn (worldedit maybe?) on a non server thread // Due to the structure of iris, we will call it sync and busy wait until it's done. AtomicReference ae = new AtomicReference<>(); try { J.s(() -> ae.set(doSpawn(at))); - } catch (Throwable e) { + } catch(Throwable e) { return null; } PrecisionStopwatch p = PrecisionStopwatch.start(); - while (ae.get() == null) { + while(ae.get() == null) { J.sleep(25); - if (p.getMilliseconds() > 500) { + if(p.getMilliseconds() > 500) { return null; } } @@ -454,8 +454,8 @@ public class IrisEntity extends IrisRegistrant { return ae.get(); } - if (isSpecialType()) { - if (specialType.toLowerCase().startsWith("mythicmobs:")) { + if(isSpecialType()) { + if(specialType.toLowerCase().startsWith("mythicmobs:")) { return Iris.linkMythicMobs.spawnMob(specialType.substring(11), at); } else { Iris.warn("Invalid mob type to spawn: '" + specialType + "'!"); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawn.java b/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawn.java index 85fc4286c..53d1336ac 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawn.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEntitySpawn.java @@ -70,28 +70,28 @@ public class IrisEntitySpawn implements IRare { int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns)); int s = 0; - if (spawns > 0) { - for (int id = 0; id < spawns; id++) { + if(spawns > 0) { + for(int id = 0; id < spawns; id++) { int x = (c.getX() * 16) + rng.i(15); int z = (c.getZ() * 16) + rng.i(15); int h = gen.getHeight(x, z, true); int hf = gen.getHeight(x, z, false); - Location l = switch (getReferenceSpawner().getGroup()) { + Location l = switch(getReferenceSpawner().getGroup()) { case NORMAL -> new Location(c.getWorld(), x, hf + 1, z); case CAVE -> gen.getMantle().findMarkers(c.getX(), c.getZ(), MarkerMatter.CAVE_FLOOR) - .convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng); + .convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng); case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h + 1, hf), z); }; - if (l != null) { - if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) { - if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) { - if (spawn100(gen, l) != null) { + if(l != null) { + if(referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) { + if(referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) { + if(spawn100(gen, l) != null) { s++; } } } else { - if (spawn100(gen, l) != null) { + if(spawn100(gen, l) != null) { s++; } } @@ -106,28 +106,28 @@ public class IrisEntitySpawn implements IRare { int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns)); int s = 0; - if (!gen.getWorld().tryGetRealWorld()) { + if(!gen.getWorld().tryGetRealWorld()) { return 0; } World world = gen.getWorld().realWorld(); - if (spawns > 0) { + if(spawns > 0) { - if (referenceMarker != null) { + if(referenceMarker != null) { gen.getMantle().getMantle().remove(c.getX(), c.getY(), c.getZ(), MatterMarker.class); } - for (int id = 0; id < spawns; id++) { + for(int id = 0; id < spawns; id++) { Location l = c.toLocation(world).add(0, 1, 0); - if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) { - if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) { - if (spawn100(gen, l, true) != null) { + if(referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) { + if(referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) { + if(spawn100(gen, l, true) != null) { s++; } } } else { - if (spawn100(gen, l, true) != null) { + if(spawn100(gen, l, true) != null) { s++; } } @@ -142,11 +142,11 @@ public class IrisEntitySpawn implements IRare { } public Entity spawn(Engine g, Location at) { - if (getRealEntity(g) == null) { + if(getRealEntity(g) == null) { return null; } - if (rng.aquire(() -> new RNG(g.getSeedManager().getEntity())).i(1, getRarity()) == 1) { + if(rng.aquire(() -> new RNG(g.getSeedManager().getEntity())).i(1, getRarity()) == 1) { return spawn100(g, at); } @@ -160,23 +160,23 @@ public class IrisEntitySpawn implements IRare { private Entity spawn100(Engine g, Location at, boolean ignoreSurfaces) { try { IrisEntity irisEntity = getRealEntity(g); - if(irisEntity == null){ // No entity + if(irisEntity == null) { // No entity Iris.debug(" You are trying to spawn an entity that does not exist!"); return null; } - if (!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) { + if(!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) { return null; } Entity e = irisEntity.spawn(g, at.add(0.5, 0, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity()))); - if (e != null) { + if(e != null) { Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ()); } return e; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); Iris.error(" Failed to retrieve real entity @ " + at + " (entity: " + getEntity() + ")"); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisExpression.java b/src/main/java/com/volmit/iris/engine/object/IrisExpression.java index 5a94533b4..518bf1ef1 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisExpression.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisExpression.java @@ -65,21 +65,21 @@ public class IrisExpression extends IrisRegistrant { Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables. try { - for (IrisExpressionLoad i : variables) { + for(IrisExpressionLoad i : variables) { scope.addInvocationVariable(i.getName()); } scope.addInvocationVariable("x"); scope.addInvocationVariable("y"); scope.addInvocationVariable("z"); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.error("Script Variable load error in " + getLoadFile().getPath()); } try { return parser.parse(getExpression(), scope); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.error("Script load error in " + getLoadFile().getPath()); } @@ -90,13 +90,13 @@ public class IrisExpression extends IrisRegistrant { public ProceduralStream stream(RNG rng) { return streamCache.aquire(() -> ProceduralStream.of((x, z) -> evaluate(rng, x, z), - (x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE)); + (x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE)); } public double evaluate(RNG rng, double x, double z) { double[] g = new double[3 + getVariables().size()]; int m = 0; - for (IrisExpressionLoad i : getVariables()) { + for(IrisExpressionLoad i : getVariables()) { g[m++] = i.getValue(rng, getLoader(), x, z); } @@ -110,7 +110,7 @@ public class IrisExpression extends IrisRegistrant { public double evaluate(RNG rng, double x, double y, double z) { double[] g = new double[3 + getVariables().size()]; int m = 0; - for (IrisExpressionLoad i : getVariables()) { + for(IrisExpressionLoad i : getVariables()) { g[m++] = i.getValue(rng, getLoader(), x, y, z); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisExpressionLoad.java b/src/main/java/com/volmit/iris/engine/object/IrisExpressionLoad.java index 6d58417fa..b9ee97f3f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisExpressionLoad.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisExpressionLoad.java @@ -60,15 +60,15 @@ public class IrisExpressionLoad { private transient AtomicCache valueCache = new AtomicCache<>(); public double getValue(RNG rng, IrisData data, double x, double z) { - if (engineValue != null) { + if(engineValue != null) { return valueCache.aquire(() -> engineValue.get(data.getEngine())); } - if (engineStreamValue != null) { + if(engineStreamValue != null) { return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z); } - if (styleValue != null) { + if(styleValue != null) { return styleValue.create(rng, data).noise(x, z); } @@ -76,15 +76,15 @@ public class IrisExpressionLoad { } public double getValue(RNG rng, IrisData data, double x, double y, double z) { - if (engineValue != null) { + if(engineValue != null) { return valueCache.aquire(() -> engineValue.get(data.getEngine())); } - if (engineStreamValue != null) { + if(engineStreamValue != null) { return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z); } - if (styleValue != null) { + if(styleValue != null) { return styleValue.create(rng, data).noise(x, y, z); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisFluidBodies.java b/src/main/java/com/volmit/iris/engine/object/IrisFluidBodies.java index 806c0e671..1c537a9f9 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisFluidBodies.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisFluidBodies.java @@ -49,14 +49,14 @@ public class IrisFluidBodies { @BlockCoordinates public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) { - if (rivers.isNotEmpty()) { - for (IrisRiver i : rivers) { + if(rivers.isNotEmpty()) { + for(IrisRiver i : rivers) { i.generate(writer, rng, engine, x, y, z); } } - if (lakes.isNotEmpty()) { - for (IrisLake i : lakes) { + if(lakes.isNotEmpty()) { + for(IrisLake i : lakes) { i.generate(writer, rng, engine, x, y, z); } } @@ -65,11 +65,11 @@ public class IrisFluidBodies { public int getMaxRange(IrisData data) { int max = 0; - for (IrisRiver i : rivers) { + for(IrisRiver i : rivers) { max = Math.max(max, i.getSize(data)); } - for (IrisLake i : lakes) { + for(IrisLake i : lakes) { max = Math.max(max, i.getSize(data)); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java index 98788fd94..b8f2bb150 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisGenerator.java @@ -105,28 +105,28 @@ public class IrisGenerator extends IrisRegistrant { } public T fitRarity(KList b, long superSeed, double rx, double rz) { - if (b.size() == 0) { + if(b.size() == 0) { return null; } - if (b.size() == 1) { + if(b.size() == 1) { return b.get(0); } KList rarityMapped = new KList<>(); boolean o = false; int max = 1; - for (T i : b) { - if (i.getRarity() > max) { + for(T i : b) { + if(i.getRarity() > max) { max = i.getRarity(); } } max++; - for (T i : b) { - for (int j = 0; j < max - i.getRarity(); j++) { - if (o = !o) { + for(T i : b) { + for(int j = 0; j < max - i.getRarity(); j++) { + if(o = !o) { rarityMapped.add(i); } else { rarityMapped.add(0, i); @@ -134,11 +134,11 @@ public class IrisGenerator extends IrisRegistrant { } } - if (rarityMapped.size() == 1) { + if(rarityMapped.size() == 1) { return rarityMapped.get(0); } - if (rarityMapped.isEmpty()) { + if(rarityMapped.isEmpty()) { throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly ")); } @@ -146,11 +146,11 @@ public class IrisGenerator extends IrisRegistrant { } public T fit(T[] v, long superSeed, double rx, double rz) { - if (v.length == 0) { + if(v.length == 0) { return null; } - if (v.length == 1) { + if(v.length == 1) { return v[0]; } @@ -158,11 +158,11 @@ public class IrisGenerator extends IrisRegistrant { } public T fit(List v, long superSeed, double rx, double rz) { - if (v.size() == 0) { + if(v.size() == 0) { return null; } - if (v.size() == 1) { + if(v.size() == 1) { return v.get(0); } @@ -170,7 +170,7 @@ public class IrisGenerator extends IrisRegistrant { } public int fit(int min, int max, long superSeed, double rx, double rz) { - if (min == max) { + if(min == max) { return min; } @@ -180,7 +180,7 @@ public class IrisGenerator extends IrisRegistrant { } public int fit(double min, double max, long superSeed, double rx, double rz) { - if (min == max) { + if(min == max) { return (int) Math.round(min); } @@ -190,7 +190,7 @@ public class IrisGenerator extends IrisRegistrant { } public double fitDouble(double min, double max, long superSeed, double rx, double rz) { - if (min == max) { + if(min == max) { return min; } @@ -209,7 +209,7 @@ public class IrisGenerator extends IrisRegistrant { } public double getHeight(double rx, double ry, double rz, long superSeed, boolean no3d) { - if (composite.isEmpty()) { + if(composite.isEmpty()) { return 0; } @@ -217,16 +217,16 @@ public class IrisGenerator extends IrisRegistrant { double h = multiplicitive ? 1 : 0; double tp = 0; - if (composite.size() == 1) { - if (multiplicitive) { + if(composite.size() == 1) { + if(multiplicitive) { h *= composite.get(0).getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader()); } else { tp += composite.get(0).getOpacity(); h += composite.get(0).getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader()); } } else { - for (IrisNoiseGenerator i : composite) { - if (multiplicitive) { + for(IrisNoiseGenerator i : composite) { + if(multiplicitive) { h *= i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader()); } else { tp += i.getOpacity(); @@ -237,7 +237,7 @@ public class IrisGenerator extends IrisRegistrant { double v = multiplicitive ? h * opacity : (h / tp) * opacity; - if (Double.isNaN(v)) { + if(Double.isNaN(v)) { v = 0; } @@ -275,7 +275,7 @@ public class IrisGenerator extends IrisRegistrant { public KList getAllComposites() { KList g = new KList<>(); - for (IrisNoiseGenerator i : composite) { + for(IrisNoiseGenerator i : composite) { g.addAll(i.getAllComposites()); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java b/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java index 2e4cffc26..cc4b3dda6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisGeneratorStyle.java @@ -29,14 +29,11 @@ import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.noise.CNG; import com.volmit.iris.util.noise.ExpressionNoise; import com.volmit.iris.util.noise.ImageNoise; -import com.volmit.iris.util.stream.ProceduralStream; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; -import java.util.List; - @Snippet("style") @Accessors(chain = true) @NoArgsConstructor @@ -84,39 +81,34 @@ public class IrisGeneratorStyle { } public CNG createNoCache(RNG rng, IrisData data) { - if (getExpression() != null) { + if(getExpression() != null) { IrisExpression e = data.getExpressionLoader().load(getExpression()); - if (e != null) { + if(e != null) { CNG cng = new CNG(rng, new ExpressionNoise(rng, e), 1D, 1) - .bake().scale(1D / zoom).pow(exponent).bake(); + .bake().scale(1D / zoom).pow(exponent).bake(); cng.setTrueFracturing(axialFracturing); - if (fracture != null) { + if(fracture != null) { cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier()); } - if(cellularFrequency > 0) - { - return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake(); + if(cellularFrequency > 0) { + return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake(); } return cng; } - } - - else if(getImageMap() != null) - { - CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D/zoom).pow(exponent).bake(); + } else if(getImageMap() != null) { + CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D / zoom).pow(exponent).bake(); cng.setTrueFracturing(axialFracturing); - if (fracture != null) { + if(fracture != null) { cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier()); } - if(cellularFrequency > 0) - { - return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake(); + if(cellularFrequency > 0) { + return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake(); } return cng; @@ -125,13 +117,12 @@ public class IrisGeneratorStyle { CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake(); cng.setTrueFracturing(axialFracturing); - if (fracture != null) { + if(fracture != null) { cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier()); } - if(cellularFrequency > 0) - { - return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake(); + if(cellularFrequency > 0) { + return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake(); } return cng; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisImage.java b/src/main/java/com/volmit/iris/engine/object/IrisImage.java index 0ddf9c287..c8fd8f0db 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisImage.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisImage.java @@ -30,34 +30,28 @@ import java.io.File; import java.io.IOException; public class IrisImage extends IrisRegistrant { - private BufferedImage image; + private final BufferedImage image; - public int getWidth() - { + public int getWidth() { return image.getWidth(); } - public int getHeight() - { + public int getHeight() { return image.getHeight(); } - public int getRawValue(int x, int z) - { - if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0) - { + public int getRawValue(int x, int z) { + if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0) { return 0; } return image.getRGB(x, z); } - public double getValue(IrisImageChannel channel, int x, int z) - { + public double getValue(IrisImageChannel channel, int x, int z) { int color = getRawValue(x, z); - switch(channel) - { + switch(channel) { case RED -> { return ((color >> 16) & 0xFF) / 255D; } @@ -105,13 +99,11 @@ public class IrisImage extends IrisRegistrant { return color; } - public IrisImage() - { + public IrisImage() { this(new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB)); } - public IrisImage(BufferedImage image) - { + public IrisImage(BufferedImage image) { this.image = image; } @@ -136,10 +128,8 @@ public class IrisImage extends IrisRegistrant { try { File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName()); BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); - for(int i = 0; i < getWidth(); i++) - { - for(int j = 0; j < getHeight(); j++) - { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB()); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisImageMap.java b/src/main/java/com/volmit/iris/engine/object/IrisImageMap.java index 2f3a0ec8b..909c6f89d 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisImageMap.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisImageMap.java @@ -20,21 +20,13 @@ package com.volmit.iris.engine.object; import com.volmit.iris.Iris; import com.volmit.iris.core.loader.IrisData; -import com.volmit.iris.core.project.SchemaBuilder; import com.volmit.iris.engine.data.cache.AtomicCache; -import com.volmit.iris.engine.framework.Engine; -import com.volmit.iris.engine.mantle.MantleWriter; -import com.volmit.iris.engine.object.annotations.ArrayType; import com.volmit.iris.engine.object.annotations.Desc; -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.collection.KList; -import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.interpolation.InterpolationMethod; import com.volmit.iris.util.interpolation.IrisInterpolation; -import com.volmit.iris.util.math.RNG; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -72,26 +64,23 @@ public class IrisImageMap { private transient AtomicCache imageCache = new AtomicCache(); - public double getNoise(IrisData data, int x, int z) - { + public double getNoise(IrisData data, int x, int z) { IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image)); - if(i == null) - { + if(i == null) { Iris.error("NULL IMAGE FOR " + image); } - return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx,zz) -> rawNoise(i, xx, zz)); + return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx, zz) -> rawNoise(i, xx, zz)); } - private double rawNoise(IrisImage i, double x, double z) - { + private double rawNoise(IrisImage i, double x, double z) { x /= coordinateScale; z /= coordinateScale; x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x; z = isCentered() ? z + ((i.getHeight() / 2D) * coordinateScale) : z; x = isTiled() ? x % i.getWidth() : x; z = isTiled() ? z % i.getHeight() : z; - double v = i.getValue(getChannel(), (int)x, (int)z); + double v = i.getValue(getChannel(), (int) x, (int) z); return isInverted() ? 1D - v : v; } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java b/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java index a76223feb..ec3c20fdc 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisInterpolator.java @@ -57,7 +57,7 @@ public class IrisInterpolator { @Override public boolean equals(Object o) { - if (o instanceof IrisInterpolator i) { + if(o instanceof IrisInterpolator i) { return i.getFunction().equals(function) && i.getHorizontalScale() == horizontalScale; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java index 1829f6926..a9b27d6ed 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawPiece.java @@ -67,7 +67,7 @@ public class IrisJigsawPiece extends IrisRegistrant { try { BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject())); return Math.max(v.getBlockX(), v.getBlockZ()); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -81,7 +81,7 @@ public class IrisJigsawPiece extends IrisRegistrant { try { BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject())); return Math.max(Math.max(v.getBlockX(), v.getBlockZ()), v.getBlockY()); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); e.printStackTrace(); } @@ -92,8 +92,8 @@ public class IrisJigsawPiece extends IrisRegistrant { public IrisJigsawPieceConnector getConnector(IrisPosition relativePosition) { - for (IrisJigsawPieceConnector i : connectors) { - if (i.getPosition().equals(relativePosition)) { + for(IrisJigsawPieceConnector i : connectors) { + if(i.getPosition().equals(relativePosition)) { return i; } } @@ -110,7 +110,7 @@ public class IrisJigsawPiece extends IrisRegistrant { p.setConnectors(new KList<>()); p.setPlacementOptions(getPlacementOptions()); - for (IrisJigsawPieceConnector i : getConnectors()) { + for(IrisJigsawPieceConnector i : getConnectors()) { p.getConnectors().add(i.copy()); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java b/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java index 26f18130a..795903cb1 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructure.java @@ -71,19 +71,19 @@ public class IrisJigsawStructure extends IrisRegistrant { private transient AtomicCache maxDimension = new AtomicCache<>(); private void loadPool(String p, KList pools, KList pieces) { - if (p.isEmpty()) { + if(p.isEmpty()) { return; } IrisJigsawPool pool = getLoader().getJigsawPoolLoader().load(p); - if (pool == null) { + if(pool == null) { Iris.warn("Can't find jigsaw pool: " + p); return; } - for (String i : pool.getPieces()) { - if (pieces.addIfMissing(i)) { + for(String i : pool.getPieces()) { + if(pieces.addIfMissing(i)) { loadPiece(i, pools, pieces); } } @@ -92,14 +92,14 @@ public class IrisJigsawStructure extends IrisRegistrant { private void loadPiece(String p, KList pools, KList pieces) { IrisJigsawPiece piece = getLoader().getJigsawPieceLoader().load(p); - if (piece == null) { + if(piece == null) { Iris.warn("Can't find jigsaw piece: " + p); return; } - for (IrisJigsawPieceConnector i : piece.getConnectors()) { - for (String j : i.getPools()) { - if (pools.addIfMissing(j)) { + for(IrisJigsawPieceConnector i : piece.getConnectors()) { + for(String j : i.getPools()) { + if(pools.addIfMissing(j)) { loadPool(j, pools, pieces); } } @@ -108,16 +108,16 @@ public class IrisJigsawStructure extends IrisRegistrant { public int getMaxDimension() { return maxDimension.aquire(() -> { - if (useMaxPieceSizeForParallaxRadius) { + if(useMaxPieceSizeForParallaxRadius) { int max = 0; KList pools = new KList<>(); KList pieces = new KList<>(); - for (String i : getPieces()) { + for(String i : getPieces()) { loadPiece(i, pools, pieces); } - for (String i : pieces) { + for(String i : pieces) { max = Math.max(max, getLoader().getJigsawPieceLoader().load(i).getMax3dDimension()); } @@ -126,13 +126,13 @@ public class IrisJigsawStructure extends IrisRegistrant { KList pools = new KList<>(); KList pieces = new KList<>(); - for (String i : getPieces()) { + for(String i : getPieces()) { loadPiece(i, pools, pieces); } int avg = 0; - for (String i : pieces) { + for(String i : pieces) { avg += getLoader().getJigsawPieceLoader().load(i).getMax2dDimension(); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLoot.java b/src/main/java/com/volmit/iris/engine/object/IrisLoot.java index d266752b6..28bffbdf2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLoot.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLoot.java @@ -112,29 +112,29 @@ public class IrisLoot { ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount()))); ItemMeta m = is.getItemMeta(); - if (getType().getMaxDurability() > 0 && m instanceof Damageable d) { + if(getType().getMaxDurability() > 0 && m instanceof Damageable d) { int max = getType().getMaxDurability(); d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max)))); } - for (IrisEnchantment i : getEnchantments()) { + for(IrisEnchantment i : getEnchantments()) { i.apply(rng, m); } - for (IrisAttributeModifier i : getAttributes()) { + for(IrisAttributeModifier i : getAttributes()) { i.apply(rng, m); } try { m.setCustomModelData(getCustomModel()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } m.setLocalizedName(C.translateAlternateColorCodes('&', displayName)); m.setDisplayName(C.translateAlternateColorCodes('&', displayName)); m.setUnbreakable(isUnbreakable()); - for (ItemFlag i : getItemFlags()) { + for(ItemFlag i : getItemFlags()) { m.addItemFlags(i); } @@ -144,8 +144,8 @@ public class IrisLoot { { String mf = C.translateAlternateColorCodes('&', i); - if (mf.length() > 24) { - for (String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) { + if(mf.length() > 24) { + for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) { lore.add(g.trim()); } } else { @@ -153,8 +153,8 @@ public class IrisLoot { } }); - if (debug) { - if (lore.isNotEmpty()) { + if(debug) { + if(lore.isNotEmpty()) { lore.add(C.GRAY + "--------------------"); } @@ -163,18 +163,18 @@ public class IrisLoot { m.setLore(lore); - if (getLeatherColor() != null && m instanceof LeatherArmorMeta) { + if(getLeatherColor() != null && m instanceof LeatherArmorMeta) { Color c = Color.decode(getLeatherColor()); ((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue())); } - if (getDyeColor() != null && m instanceof Colorable) { + if(getDyeColor() != null && m instanceof Colorable) { ((Colorable) m).setColor(getDyeColor()); } is.setItemMeta(m); return is; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -183,12 +183,12 @@ public class IrisLoot { } public ItemStack get(boolean debug, boolean giveSomething, IrisLootTable table, RNG rng, int x, int y, int z) { - if (debug) { + if(debug) { chance.reset(); } - if (giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) { - if (getType() == null) { + if(giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) { + if(getType() == null) { Iris.warn("Cant find item type " + type); return null; } @@ -197,22 +197,22 @@ public class IrisLoot { ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount()))); ItemMeta m = is.getItemMeta(); - if (getType().getMaxDurability() > 0 && m instanceof Damageable d) { + if(getType().getMaxDurability() > 0 && m instanceof Damageable d) { int max = getType().getMaxDurability(); d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max)))); } - for (IrisEnchantment i : getEnchantments()) { + for(IrisEnchantment i : getEnchantments()) { i.apply(rng, m); } - for (IrisAttributeModifier i : getAttributes()) { + for(IrisAttributeModifier i : getAttributes()) { i.apply(rng, m); } try { m.setCustomModelData(getCustomModel()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -220,7 +220,7 @@ public class IrisLoot { m.setDisplayName(C.translateAlternateColorCodes('&', displayName)); m.setUnbreakable(isUnbreakable()); - for (ItemFlag i : getItemFlags()) { + for(ItemFlag i : getItemFlags()) { m.addItemFlags(i); } @@ -230,8 +230,8 @@ public class IrisLoot { { String mf = C.translateAlternateColorCodes('&', i); - if (mf.length() > 24) { - for (String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) { + if(mf.length() > 24) { + for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) { lore.add(g.trim()); } } else { @@ -239,8 +239,8 @@ public class IrisLoot { } }); - if (debug) { - if (lore.isNotEmpty()) { + if(debug) { + if(lore.isNotEmpty()) { lore.add(C.GRAY + "--------------------"); } @@ -251,7 +251,7 @@ public class IrisLoot { m.setLore(lore); is.setItemMeta(m); return is; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java b/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java index e7563e091..6448df570 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLootReference.java @@ -54,7 +54,7 @@ public class IrisLootReference { { KList t = new KList<>(); - for (String i : tables) { + for(String i : tables) { t.add(g.getData().getLootLoader().load(i)); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java b/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java index 7fd179c83..8c73721dd 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java @@ -70,15 +70,15 @@ public class IrisLootTable extends IrisRegistrant { int m = 0; int mx = rng.i(getMinPicked(), getMaxPicked()); - while (m < mx) { + while(m < mx) { int num = rng.i(loot.size()); IrisLoot l = loot.get(num); - if (l.getSlotTypes() == slot) { + if(l.getSlotTypes() == slot) { ItemStack item = l.get(debug, false, this, rng, x, y, z); - if (item != null && item.getType() != Material.AIR) { + if(item != null && item.getType() != Material.AIR) { lootf.add(item); m++; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java b/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java index b4133662e..9ca81aa4d 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisMaterialPalette.java @@ -55,11 +55,11 @@ public class IrisMaterialPalette { private KList palette = new KList().qadd(new IrisBlockData("STONE")); public BlockData get(RNG rng, double x, double y, double z, IrisData rdata) { - if (getBlockData(rdata).isEmpty()) { + if(getBlockData(rdata).isEmpty()) { return null; } - if (getBlockData(rdata).size() == 1) { + if(getBlockData(rdata).size() == 1) { return getBlockData(rdata).get(0); } @@ -95,10 +95,10 @@ public class IrisMaterialPalette { return blockData.aquire(() -> { KList blockData = new KList<>(); - for (IrisBlockData ix : palette) { + for(IrisBlockData ix : palette) { BlockData bx = ix.getBlockData(rdata); - if (bx != null) { - for (int i = 0; i < ix.getWeight(); i++) { + if(bx != null) { + for(int i = 0; i < ix.getWeight(); i++) { blockData.add(bx); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java index 5f8dadbfe..27145b909 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisNoiseGenerator.java @@ -95,7 +95,7 @@ public class IrisNoiseGenerator { } public double getNoise(long superSeed, double xv, double zv, IrisData data) { - if (!enabled) { + if(!enabled) { return offsetY; } @@ -103,8 +103,8 @@ public class IrisNoiseGenerator { double z = zv; int g = 33; - for (IrisNoiseGenerator i : fracture) { - if (i.isEnabled()) { + for(IrisNoiseGenerator i : fracture) { + if(i.isEnabled()) { x += i.getNoise(superSeed + seed + g, xv, zv, data) - (opacity / 2D); z -= i.getNoise(superSeed + seed + g, zv, xv, data) - (opacity / 2D); } @@ -126,7 +126,7 @@ public class IrisNoiseGenerator { g.add(this); - for (IrisNoiseGenerator i : getFracture()) { + for(IrisNoiseGenerator i : getFracture()) { g.addAll(i.getAllComposites()); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObject.java b/src/main/java/com/volmit/iris/engine/object/IrisObject.java index a4cfec435..3612f4d28 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObject.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObject.java @@ -79,7 +79,7 @@ public class IrisObject extends IrisRegistrant { protected static final BlockData AIR = B.get("CAVE_AIR"); protected static final BlockData VAIR = B.get("VOID_AIR"); protected static final BlockData VAIR_DEBUG = B.get("COBWEB"); - protected static final BlockData[] SNOW_LAYERS = new BlockData[]{B.get("minecraft:snow[layers=1]"), B.get("minecraft:snow[layers=2]"), B.get("minecraft:snow[layers=3]"), B.get("minecraft:snow[layers=4]"), B.get("minecraft:snow[layers=5]"), B.get("minecraft:snow[layers=6]"), B.get("minecraft:snow[layers=7]"), B.get("minecraft:snow[layers=8]")}; + protected static final BlockData[] SNOW_LAYERS = new BlockData[] {B.get("minecraft:snow[layers=1]"), B.get("minecraft:snow[layers=2]"), B.get("minecraft:snow[layers=3]"), B.get("minecraft:snow[layers=4]"), B.get("minecraft:snow[layers=5]"), B.get("minecraft:snow[layers=6]"), B.get("minecraft:snow[layers=7]"), B.get("minecraft:snow[layers=8]")}; protected transient final IrisLock readLock = new IrisLock("read-conclock"); @Getter @Setter @@ -124,7 +124,7 @@ public class IrisObject extends IrisRegistrant { public static AxisAlignedBB getAABBFor(BlockVector size) { BlockVector center = new BlockVector(size.getX() / 2, size.getY() / 2, size.getZ() / 2); return new AxisAlignedBB(new IrisPosition(new BlockVector(0, 0, 0).subtract(center).toBlockVector()), - new IrisPosition(new BlockVector(size.getX() - 1, size.getY() - 1, size.getZ() - 1).subtract(center).toBlockVector())); + new IrisPosition(new BlockVector(size.getX() - 1, size.getY() - 1, size.getZ() - 1).subtract(center).toBlockVector())); } @SuppressWarnings({"resource", "RedundantSuppression"}) @@ -145,9 +145,9 @@ public class IrisObject extends IrisRegistrant { int topBlockZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()); int bottomBlockZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ()); - for (int x = bottomBlockX; x <= topBlockX; x++) { - for (int z = bottomBlockZ; z <= topBlockZ; z++) { - for (int y = bottomBlockY; y <= topBlockY; y++) { + for(int x = bottomBlockX; x <= topBlockX; x++) { + for(int z = bottomBlockZ; z <= topBlockZ; z++) { + for(int y = bottomBlockY; y <= topBlockY; y++) { locations.add(new BlockVector(x, y, z)); } } @@ -160,7 +160,7 @@ public class IrisObject extends IrisRegistrant { } public void ensureSmartBored(boolean debug) { - if (smartBored) { + if(smartBored) { return; } @@ -168,7 +168,7 @@ public class IrisObject extends IrisRegistrant { BlockData vair = debug ? VAIR_DEBUG : VAIR; lock.lock(); AtomicInteger applied = new AtomicInteger(); - if (getBlocks().isEmpty()) { + if(getBlocks().isEmpty()) { lock.unlock(); Iris.warn("Cannot Smart Bore " + getLoadKey() + " because it has 0 blocks in it."); smartBored = true; @@ -178,7 +178,7 @@ public class IrisObject extends IrisRegistrant { BlockVector max = new BlockVector(Double.MIN_VALUE, Double.MIN_VALUE, Double.MIN_VALUE); BlockVector min = new BlockVector(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { max.setX(Math.max(i.getX(), max.getX())); min.setX(Math.min(i.getX(), min.getX())); max.setY(Math.max(i.getY(), max.getY())); @@ -190,25 +190,25 @@ public class IrisObject extends IrisRegistrant { BurstExecutor burst = MultiBurst.burst.burst(); // Smash X - for (int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) { + for(int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) { int finalRayY = rayY; burst.queue(() -> { - for (int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) { + for(int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) { int start = Integer.MAX_VALUE; int end = Integer.MIN_VALUE; - for (int ray = min.getBlockX(); ray <= max.getBlockX(); ray++) { - if (getBlocks().containsKey(new BlockVector(ray, finalRayY, rayZ))) { + for(int ray = min.getBlockX(); ray <= max.getBlockX(); ray++) { + if(getBlocks().containsKey(new BlockVector(ray, finalRayY, rayZ))) { start = Math.min(ray, start); end = Math.max(ray, end); } } - if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) { - for (int i = start; i <= end; i++) { + if(start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) { + for(int i = start; i <= end; i++) { BlockVector v = new BlockVector(i, finalRayY, rayZ); - if (!B.isAir(getBlocks().get(v))) { + if(!B.isAir(getBlocks().get(v))) { getBlocks().computeIfAbsent(v, (vv) -> vair); applied.getAndIncrement(); } @@ -219,25 +219,25 @@ public class IrisObject extends IrisRegistrant { } // Smash Y - for (int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) { + for(int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) { int finalRayX = rayX; burst.queue(() -> { - for (int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) { + for(int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) { int start = Integer.MAX_VALUE; int end = Integer.MIN_VALUE; - for (int ray = min.getBlockY(); ray <= max.getBlockY(); ray++) { - if (getBlocks().containsKey(new BlockVector(finalRayX, ray, rayZ))) { + for(int ray = min.getBlockY(); ray <= max.getBlockY(); ray++) { + if(getBlocks().containsKey(new BlockVector(finalRayX, ray, rayZ))) { start = Math.min(ray, start); end = Math.max(ray, end); } } - if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) { - for (int i = start; i <= end; i++) { + if(start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) { + for(int i = start; i <= end; i++) { BlockVector v = new BlockVector(finalRayX, i, rayZ); - if (!B.isAir(getBlocks().get(v))) { + if(!B.isAir(getBlocks().get(v))) { getBlocks().computeIfAbsent(v, (vv) -> vair); applied.getAndIncrement(); } @@ -248,25 +248,25 @@ public class IrisObject extends IrisRegistrant { } // Smash Z - for (int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) { + for(int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) { int finalRayX = rayX; burst.queue(() -> { - for (int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) { + for(int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) { int start = Integer.MAX_VALUE; int end = Integer.MIN_VALUE; - for (int ray = min.getBlockZ(); ray <= max.getBlockZ(); ray++) { - if (getBlocks().containsKey(new BlockVector(finalRayX, rayY, ray))) { + for(int ray = min.getBlockZ(); ray <= max.getBlockZ(); ray++) { + if(getBlocks().containsKey(new BlockVector(finalRayX, rayY, ray))) { start = Math.min(ray, start); end = Math.max(ray, end); } } - if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) { - for (int i = start; i <= end; i++) { + if(start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) { + for(int i = start; i <= end; i++) { BlockVector v = new BlockVector(finalRayX, rayY, i); - if (!B.isAir(getBlocks().get(v))) { + if(!B.isAir(getBlocks().get(v))) { getBlocks().computeIfAbsent(v, (vv) -> vair); applied.getAndIncrement(); } @@ -287,11 +287,11 @@ public class IrisObject extends IrisRegistrant { o.setLoadKey(o.getLoadKey()); o.setCenter(getCenter().clone()); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { o.getBlocks().put(i.clone(), Objects.requireNonNull(getBlocks().get(i)).clone()); } - for (BlockVector i : getStates().keySet()) { + for(BlockVector i : getStates().keySet()) { o.getStates().put(i.clone(), Objects.requireNonNull(getStates().get(i)).clone()); } @@ -306,17 +306,17 @@ public class IrisObject extends IrisRegistrant { center = new BlockVector(w / 2, h / 2, d / 2); int s = din.readInt(); - for (int i = 0; i < s; i++) { + for(int i = 0; i < s; i++) { getBlocks().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), B.get(din.readUTF())); } try { int size = din.readInt(); - for (int i = 0; i < size; i++) { + for(int i = 0; i < size; i++) { getStates().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), TileData.read(din)); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -327,7 +327,7 @@ public class IrisObject extends IrisRegistrant { this.w = din.readInt(); this.h = din.readInt(); this.d = din.readInt(); - if (!din.readUTF().equals("Iris V2 IOB;")) { + if(!din.readUTF().equals("Iris V2 IOB;")) { return; } center = new BlockVector(w / 2, h / 2, d / 2); @@ -335,19 +335,19 @@ public class IrisObject extends IrisRegistrant { int i; KList palette = new KList<>(); - for (i = 0; i < s; i++) { + for(i = 0; i < s; i++) { palette.add(din.readUTF()); } s = din.readInt(); - for (i = 0; i < s; i++) { + for(i = 0; i < s; i++) { getBlocks().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), B.get(palette.get(din.readShort()))); } s = din.readInt(); - for (i = 0; i < s; i++) { + for(i = 0; i < s; i++) { getStates().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), TileData.read(din)); } } @@ -360,19 +360,19 @@ public class IrisObject extends IrisRegistrant { dos.writeUTF("Iris V2 IOB;"); KList palette = new KList<>(); - for (BlockData i : getBlocks().values()) { + for(BlockData i : getBlocks().values()) { palette.addIfMissing(i.getAsString()); } dos.writeShort(palette.size()); - for (String i : palette) { + for(String i : palette) { dos.writeUTF(i); } dos.writeInt(getBlocks().size()); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { dos.writeShort(i.getBlockX()); dos.writeShort(i.getBlockY()); dos.writeShort(i.getBlockZ()); @@ -380,7 +380,7 @@ public class IrisObject extends IrisRegistrant { } dos.writeInt(getStates().size()); - for (BlockVector i : getStates().keySet()) { + for(BlockVector i : getStates().keySet()) { dos.writeShort(i.getBlockX()); dos.writeShort(i.getBlockY()); dos.writeShort(i.getBlockZ()); @@ -393,7 +393,7 @@ public class IrisObject extends IrisRegistrant { try { read(fin); fin.close(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); fin.close(); fin = new FileInputStream(file); @@ -403,7 +403,7 @@ public class IrisObject extends IrisRegistrant { } public void write(File file) throws IOException { - if (file == null) { + if(file == null) { return; } @@ -416,7 +416,7 @@ public class IrisObject extends IrisRegistrant { BlockVector min = new BlockVector(); BlockVector max = new BlockVector(); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { min.setX(Math.min(min.getX(), i.getX())); min.setY(Math.min(min.getY(), i.getY())); min.setZ(Math.min(min.getZ(), i.getZ())); @@ -433,17 +433,17 @@ public class IrisObject extends IrisRegistrant { public void clean() { KMap d = new KMap<>(); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i))); } KMap> dx = new KMap<>(); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i))); } - for (BlockVector i : getStates().keySet()) { + for(BlockVector i : getStates().keySet()) { dx.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getStates().get(i))); } @@ -452,7 +452,7 @@ public class IrisObject extends IrisRegistrant { } public BlockVector getSigned(int x, int y, int z) { - if (x >= w || y >= h || z >= d) { + if(x >= w || y >= h || z >= d) { throw new RuntimeException(x + " " + y + " " + z + " exceeds limit of " + w + " " + h + " " + d); } @@ -462,7 +462,7 @@ public class IrisObject extends IrisRegistrant { public void setUnsigned(int x, int y, int z, BlockData block) { BlockVector v = getSigned(x, y, z); - if (block == null) { + if(block == null) { getBlocks().remove(v); getStates().remove(v); } else { @@ -473,14 +473,14 @@ public class IrisObject extends IrisRegistrant { public void setUnsigned(int x, int y, int z, Block block) { BlockVector v = getSigned(x, y, z); - if (block == null) { + if(block == null) { getBlocks().remove(v); getStates().remove(v); } else { BlockData data = block.getBlockData(); getBlocks().put(v, data); TileData state = TileData.getTileState(block); - if (state != null) { + if(state != null) { Iris.info("Saved State " + v); getStates().put(v, state); } @@ -506,7 +506,7 @@ public class IrisObject extends IrisRegistrant { public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer listener, CarveResult c, IrisData rdata) { IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer; - if (config.isSmartBore()) { + if(config.isSmartBore()) { ensureSmartBored(placer.isDebugSmartBore()); } @@ -524,127 +524,127 @@ public class IrisObject extends IrisRegistrant { yrand = yrand > 0 ? rng.i(0, yrand) : yrand < 0 ? rng.i(yrand, 0) : yrand; boolean bail = false; - if (yv < 0) { - if (config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) { + if(yv < 0) { + if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) { y = (c != null ? c.getSurface() : placer.getHighest(x, z, getLoader(), config.isUnderwater())) + rty; - if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) { + if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) { bail = true; } - } else if (config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) { + } else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) { BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); - for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) { - for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) { + for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) { + for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) { int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty; - if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { + if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { bail = true; break; } - if (h > y) { + if(h > y) { y = h; } } } - } else if (config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) { + } else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) { BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); - for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) { - for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) { + for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) { + for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) { int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty; - if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { + if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { bail = true; break; } - if (h > y) { + if(h > y) { y = h; } } } - } else if (config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) { + } else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) { y = 257; BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); - for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) { - for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) { + for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) { + for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) { int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty; - if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { + if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { bail = true; break; } - if (h < y) { + if(h < y) { y = h; } } } - } else if (config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) { + } else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) { y = 257; BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); - for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) { - for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) { + for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) { + for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) { int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty; - if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { + if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { bail = true; break; } - if (h < y) { + if(h < y) { y = h; } } } - } else if (config.getMode().equals(ObjectPlaceMode.PAINT)) { + } else if(config.getMode().equals(ObjectPlaceMode.PAINT)) { y = placer.getHighest(x, z, getLoader(), config.isUnderwater()) + rty; - if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) { + if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) { bail = true; } } } else { y = yv; - if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) { + if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) { bail = true; } } - if (yv >= 0 && config.isBottom()) { + if(yv >= 0 && config.isBottom()) { y += Math.floorDiv(h, 2); bail = placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z); } - if (bail) { + if(bail) { return -1; } - if (yv < 0) { - if (!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z)) { + if(yv < 0) { + if(!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z)) { return -1; } } - if (c != null && Math.max(0, h + yrand + ty) + 1 >= c.getHeight()) { + if(c != null && Math.max(0, h + yrand + ty) + 1 >= c.getHeight()) { return -1; } - if (config.isUnderwater() && y + rty + ty >= placer.getFluidHeight()) { + if(config.isUnderwater() && y + rty + ty >= placer.getFluidHeight()) { return -1; } - if (!config.getClamp().canPlace(y + rty + ty, y - rty + ty)) { + if(!config.getClamp().canPlace(y + rty + ty, y - rty + ty)) { return -1; } - if (config.isBore()) { + if(config.isBore()) { BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); - for (int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) { - for (int j = y - Math.floorDiv(h, 2) - config.getBoreExtendMinY() + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) + config.getBoreExtendMaxY() - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) { - for (int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) { + for(int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) { + for(int j = y - Math.floorDiv(h, 2) - config.getBoreExtendMinY() + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) + config.getBoreExtendMaxY() - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) { + for(int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) { placer.set(i, j, k, AIR); } } @@ -658,34 +658,34 @@ public class IrisObject extends IrisRegistrant { KMap markers = null; try { - if (config.getMarkers().isNotEmpty() && placer.getEngine() != null) { + if(config.getMarkers().isNotEmpty() && placer.getEngine() != null) { markers = new KMap<>(); - for (IrisObjectMarker j : config.getMarkers()) { + for(IrisObjectMarker j : config.getMarkers()) { IrisMarker marker = getLoader().getMarkerLoader().load(j.getMarker()); - if (marker == null) { + if(marker == null) { continue; } int max = j.getMaximumMarkers(); - for (BlockVector i : getBlocks().k().shuffle()) { - if (max <= 0) { + for(BlockVector i : getBlocks().k().shuffle()) { + if(max <= 0) { break; } BlockData data = getBlocks().get(i); - for (BlockData k : j.getMark(rdata)) { - if (max <= 0) { + for(BlockData k : j.getMark(rdata)) { + if(max <= 0) { break; } - if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) { + if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) { boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0)))); boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0)))); - if ((marker.isEmptyAbove() && a && fff) || !marker.isEmptyAbove()) { + if(!marker.isEmptyAbove() || (a && fff)) { markers.put(i, j.getMarker()); max--; } @@ -695,20 +695,20 @@ public class IrisObject extends IrisRegistrant { } } - for (BlockVector g : getBlocks().keySet()) { + for(BlockVector g : getBlocks().keySet()) { BlockData d; TileData tile = null; try { d = getBlocks().get(g); tile = getStates().get(g); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (cme)"); d = AIR; } - if (d == null) { + if(d == null) { Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (null)"); d = AIR; } @@ -718,21 +718,21 @@ public class IrisObject extends IrisRegistrant { i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone(); i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone(); - if (stilting && i.getBlockY() < lowest && !B.isAir(data)) { + if(stilting && i.getBlockY() < lowest && !B.isAir(data)) { lowest = i.getBlockY(); } - if (placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) { + if(placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) { ((Leaves) data).setPersistent(true); } - for (IrisObjectReplace j : config.getEdit()) { - if (rng.chance(j.getChance())) { - for (BlockData k : j.getFind(rdata)) { - if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) { + for(IrisObjectReplace j : config.getEdit()) { + if(rng.chance(j.getChance())) { + for(BlockData k : j.getFind(rdata)) { + if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) { BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone(); - if (newData.getMaterial() == data.getMaterial()) { + if(newData.getMaterial() == data.getMaterial()) { data = data.merge(newData); } else { data = newData; @@ -747,70 +747,70 @@ public class IrisObject extends IrisRegistrant { int yy = y + (int) Math.round(i.getY()); zz = z + (int) Math.round(i.getZ()); - if (warped) { + if(warped) { xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z, getLoader()); zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader()); } - if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) { + if(yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) { yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, getLoader(), config.isUnderwater()); } - if (heightmap != null) { + if(heightmap != null) { Position2 pos = new Position2(xx, zz); - if (!heightmap.containsKey(pos)) { + if(!heightmap.containsKey(pos)) { heightmap.put(pos, yy); } - if (heightmap.get(pos) < yy) { + if(heightmap.get(pos) < yy) { heightmap.put(pos, yy); } } - if (config.isMeld() && !placer.isSolid(xx, yy, zz)) { + if(config.isMeld() && !placer.isSolid(xx, yy, zz)) { continue; } - if (config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) { + if(config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) { ((Waterlogged) data).setWaterlogged(true); } - if (listener != null) { + if(listener != null) { listener.accept(new BlockPosition(xx, yy, zz)); } - if (markers != null && markers.containsKey(g)) { + if(markers != null && markers.containsKey(g)) { placer.getEngine().getMantle().getMantle().set(xx, yy, zz, new MatterMarker(markers.get(g))); } - if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) { + if(!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) { placer.set(xx, yy, zz, data); - if (tile != null) { + if(tile != null) { placer.setTile(xx, yy, zz, tile); } } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } readLock.unlock(); - if (stilting) { + if(stilting) { readLock.lock(); - for (BlockVector g : getBlocks().keySet()) { + for(BlockVector g : getBlocks().keySet()) { BlockData d; try { d = getBlocks().get(g); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt cme)"); d = AIR; } - if (d == null) { + if(d == null) { Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt null)"); d = AIR; } @@ -819,30 +819,30 @@ public class IrisObject extends IrisRegistrant { i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone(); i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone(); - if (i.getBlockY() != lowest) { + if(i.getBlockY() != lowest) { continue; } - if (d == null || B.isAir(d)) { + if(d == null || B.isAir(d)) { continue; } xx = x + (int) Math.round(i.getX()); zz = z + (int) Math.round(i.getZ()); - if (warped) { + if(warped) { xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z, getLoader()); zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader()); } int yg = placer.getHighest(xx, zz, getLoader(), config.isUnderwater()); - if (yv >= 0 && config.isBottom()) { + if(yv >= 0 && config.isBottom()) { y += Math.floorDiv(h, 2); } - for (int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) { + for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) { placer.set(xx, j, zz, d); } } @@ -850,15 +850,15 @@ public class IrisObject extends IrisRegistrant { readLock.unlock(); } - if (heightmap != null) { + if(heightmap != null) { RNG rngx = rng.nextParallelRNG(3468854); - for (Position2 i : heightmap.k()) { + for(Position2 i : heightmap.k()) { int vx = i.getX(); int vy = heightmap.get(i); int vz = i.getZ(); - if (config.getSnow() > 0) { + if(config.getSnow() > 0) { int height = rngx.i(0, (int) (config.getSnow() * 7)); placer.set(vx, vy + 1, vz, SNOW_LAYERS[Math.max(Math.min(height, 7), 0)]); } @@ -877,14 +877,14 @@ public class IrisObject extends IrisRegistrant { public void rotate(IrisObjectRotation r, int spinx, int spiny, int spinz) { KMap d = new KMap<>(); - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { d.put(r.rotate(i.clone(), spinx, spiny, spinz), r.rotate(getBlocks().get(i).clone(), - spinx, spiny, spinz)); + spinx, spiny, spinz)); } KMap> dx = new KMap<>(); - for (BlockVector i : getStates().keySet()) { + for(BlockVector i : getStates().keySet()) { dx.put(r.rotate(i.clone(), spinx, spiny, spinz), getStates().get(i)); } @@ -893,11 +893,11 @@ public class IrisObject extends IrisRegistrant { } public void place(Location at) { - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { Block b = at.clone().add(0, getCenter().getY(), 0).add(i).getBlock(); b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false); - if (getStates().containsKey(i)) { + if(getStates().containsKey(i)) { Iris.info(Objects.requireNonNull(states.get(i)).toString()); BlockState st = b.getState(); Objects.requireNonNull(getStates().get(i)).toBukkitTry(st); @@ -907,11 +907,11 @@ public class IrisObject extends IrisRegistrant { } public void placeCenterY(Location at) { - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { Block b = at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock(); b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false); - if (getStates().containsKey(i)) { + if(getStates().containsKey(i)) { Objects.requireNonNull(getStates().get(i)).toBukkitTry(b.getState()); } } @@ -926,7 +926,7 @@ public class IrisObject extends IrisRegistrant { } public void unplaceCenterY(Location at) { - for (BlockVector i : getBlocks().keySet()) { + for(BlockVector i : getBlocks().keySet()) { at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock().setBlockData(AIR, false); } } @@ -934,7 +934,7 @@ public class IrisObject extends IrisRegistrant { public IrisObject scaled(double scale, IrisObjectPlacementScaleInterpolator interpolation) { Vector sm1 = new Vector(scale - 1, scale - 1, scale - 1); scale = Math.max(0.001, Math.min(50, scale)); - if (scale < 1) { + if(scale < 1) { scale = scale - 0.0001; } @@ -943,28 +943,28 @@ public class IrisObject extends IrisRegistrant { @SuppressWarnings({"unchecked", "rawtypes"}) HashMap placeBlock = new HashMap(); Vector center = getCenter(); - if (getH() == 2) { + if(getH() == 2) { center = center.setY(center.getBlockY() + 0.5); } - if (getW() == 2) { + if(getW() == 2) { center = center.setX(center.getBlockX() + 0.5); } - if (getD() == 2) { + if(getD() == 2) { center = center.setZ(center.getBlockZ() + 0.5); } IrisObject oo = new IrisObject((int) Math.ceil((w * scale) + (scale * 2)), (int) Math.ceil((h * scale) + (scale * 2)), (int) Math.ceil((d * scale) + (scale * 2))); - for (Map.Entry entry : blocks.entrySet()) { + for(Map.Entry entry : blocks.entrySet()) { BlockData bd = entry.getValue(); placeBlock.put(entry.getKey().clone().add(HALF).subtract(center) - .multiply(scale).add(sm1).toBlockVector(), bd); + .multiply(scale).add(sm1).toBlockVector(), bd); } - for (Map.Entry entry : placeBlock.entrySet()) { + for(Map.Entry entry : placeBlock.entrySet()) { BlockVector v = entry.getKey(); - if (scale > 1) { - for (BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) { + if(scale > 1) { + for(BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) { oo.getBlocks().put(vec, entry.getValue()); } } else { @@ -972,8 +972,8 @@ public class IrisObject extends IrisRegistrant { } } - if (scale > 1) { - switch (interpolation) { + if(scale > 1) { + switch(interpolation) { case TRILINEAR -> oo.trilinear((int) Math.round(scale)); case TRICUBIC -> oo.tricubic((int) Math.round(scale)); case TRIHERMITE -> oo.trihermite((int) Math.round(scale)); @@ -989,13 +989,13 @@ public class IrisObject extends IrisRegistrant { BlockVector min = getAABB().minbv(); BlockVector max = getAABB().maxbv(); - for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { - for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { - if (IrisInterpolation.getTrilinear(x, y, z, rad, (xx, yy, zz) -> { + for(int x = min.getBlockX(); x <= max.getBlockX(); x++) { + for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { + for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { + if(IrisInterpolation.getTrilinear(x, y, z, rad, (xx, yy, zz) -> { BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz)); - if (data == null || data.getMaterial().isAir()) { + if(data == null || data.getMaterial().isAir()) { return 0; } @@ -1018,13 +1018,13 @@ public class IrisObject extends IrisRegistrant { BlockVector min = getAABB().minbv(); BlockVector max = getAABB().maxbv(); - for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { - for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { - if (IrisInterpolation.getTricubic(x, y, z, rad, (xx, yy, zz) -> { + for(int x = min.getBlockX(); x <= max.getBlockX(); x++) { + for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { + for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { + if(IrisInterpolation.getTricubic(x, y, z, rad, (xx, yy, zz) -> { BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz)); - if (data == null || data.getMaterial().isAir()) { + if(data == null || data.getMaterial().isAir()) { return 0; } @@ -1051,13 +1051,13 @@ public class IrisObject extends IrisRegistrant { BlockVector min = getAABB().minbv(); BlockVector max = getAABB().maxbv(); - for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { - for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { - if (IrisInterpolation.getTrihermite(x, y, z, rad, (xx, yy, zz) -> { + for(int x = min.getBlockX(); x <= max.getBlockX(); x++) { + for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { + for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { + if(IrisInterpolation.getTrihermite(x, y, z, rad, (xx, yy, zz) -> { BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz)); - if (data == null || data.getMaterial().isAir()) { + if(data == null || data.getMaterial().isAir()) { return 0; } @@ -1078,22 +1078,22 @@ public class IrisObject extends IrisRegistrant { BlockVector vv = new BlockVector(x, y, z); BlockData r = getBlocks().get(vv); - if (r != null && !r.getMaterial().isAir()) { + if(r != null && !r.getMaterial().isAir()) { return r; } double d = Double.MAX_VALUE; - for (Map.Entry entry : blocks.entrySet()) { + for(Map.Entry entry : blocks.entrySet()) { BlockData dat = entry.getValue(); - if (dat.getMaterial().isAir()) { + if(dat.getMaterial().isAir()) { continue; } double dx = entry.getKey().distanceSquared(vv); - if (dx < d) { + if(dx < d) { d = dx; r = dat; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java index d67f603b7..a5957ff9b 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectLoot.java @@ -57,10 +57,10 @@ public class IrisObjectLoot { { KList b = new KList<>(); - for (IrisBlockData i : filter) { + for(IrisBlockData i : filter) { BlockData bx = i.getBlockData(rdata); - if (bx != null) { + if(bx != null) { b.add(bx); } } @@ -70,8 +70,8 @@ public class IrisObjectLoot { } public boolean matchesFilter(IrisData manager, BlockData data) { - for (BlockData filterData : getFilter(manager)) { - if (filterData.matches(data)) return true; + for(BlockData filterData : getFilter(manager)) { + if(filterData.matches(data)) return true; } return false; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectMarker.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectMarker.java index a6424f638..9d7d9c60e 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectMarker.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectMarker.java @@ -66,10 +66,10 @@ public class IrisObjectMarker { { KList b = new KList<>(); - for (IrisBlockData i : mark) { + for(IrisBlockData i : mark) { BlockData bx = i.getBlockData(rdata); - if (bx != null) { + if(bx != null) { b.add(bx); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java index 92cde98c2..533fb1664 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectPlacement.java @@ -158,7 +158,7 @@ public class IrisObjectPlacement { public CNG getSurfaceWarp(RNG rng, IrisData data) { return surfaceWarp.aquire(() -> - getWarp().create(rng, data)); + getWarp().create(rng, data)); } public double warp(RNG rng, double x, double y, double z, IrisData data) { @@ -166,7 +166,7 @@ public class IrisObjectPlacement { } public IrisObject getObject(DataProvider g, RNG random) { - if (place.isEmpty()) { + if(place.isEmpty()) { return null; } @@ -174,8 +174,8 @@ public class IrisObjectPlacement { } public boolean matches(IrisTreeSize size, TreeType type) { - for (IrisTree i : getTrees()) { - if (i.matches(size, type)) { + for(IrisTree i : getTrees()) { + if(i.matches(size, type)) { return true; } } @@ -184,14 +184,14 @@ public class IrisObjectPlacement { } public int getDensity() { - if (densityStyle == null) { + if(densityStyle == null) { return density; } return densityStyle.getMid(); } public int getDensity(RNG rng, double x, double z, IrisData data) { - if (densityStyle == null) { + if(densityStyle == null) { return density; } @@ -202,20 +202,20 @@ public class IrisObjectPlacement { return cache.aquire(() -> { TableCache tc = new TableCache(); - for (IrisObjectLoot loot : getLoot()) { + for(IrisObjectLoot loot : getLoot()) { IrisLootTable table = manager.getLootLoader().load(loot.getName()); - if (table == null) { + if(table == null) { Iris.warn("Couldn't find loot table " + loot.getName()); continue; } - if (loot.getFilter().isEmpty()) //Table applies to all containers + if(loot.getFilter().isEmpty()) //Table applies to all containers { tc.global.put(table, loot.getWeight()); - } else if (!loot.isExact()) //Table is meant to be by type + } else if(!loot.isExact()) //Table is meant to be by type { - for (BlockData filterData : loot.getFilter(manager)) { - if (!tc.basic.containsKey(filterData.getMaterial())) { + for(BlockData filterData : loot.getFilter(manager)) { + if(!tc.basic.containsKey(filterData.getMaterial())) { tc.basic.put(filterData.getMaterial(), new WeightedRandom<>()); } @@ -223,12 +223,12 @@ public class IrisObjectPlacement { } } else //Filter is exact { - for (BlockData filterData : loot.getFilter(manager)) { - if (!tc.exact.containsKey(filterData.getMaterial())) { + for(BlockData filterData : loot.getFilter(manager)) { + if(!tc.exact.containsKey(filterData.getMaterial())) { tc.exact.put(filterData.getMaterial(), new KMap<>()); } - if (!tc.exact.get(filterData.getMaterial()).containsKey(filterData)) { + if(!tc.exact.get(filterData.getMaterial()).containsKey(filterData)) { tc.exact.get(filterData.getMaterial()).put(filterData, new WeightedRandom<>()); } @@ -243,20 +243,22 @@ public class IrisObjectPlacement { /** * Gets the loot table that should be used for the block * - * @param data The block data of the block - * @param dataManager Iris Data Manager + * @param data + * The block data of the block + * @param dataManager + * Iris Data Manager * @return The loot table it should use. */ public IrisLootTable getTable(BlockData data, IrisData dataManager) { TableCache cache = getCache(dataManager); - if (B.isStorageChest(data)) { + if(B.isStorageChest(data)) { IrisLootTable picked = null; - if (cache.exact.containsKey(data.getMaterial()) && cache.exact.containsKey(data)) { + if(cache.exact.containsKey(data.getMaterial()) && cache.exact.containsKey(data)) { picked = cache.exact.get(data.getMaterial()).get(data).pullRandom(); - } else if (cache.basic.containsKey(data.getMaterial())) { + } else if(cache.basic.containsKey(data.getMaterial())) { picked = cache.basic.get(data.getMaterial()).pullRandom(); - } else if (cache.global.getSize() > 0) { + } else if(cache.global.getSize() > 0) { picked = cache.global.pullRandom(); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java index 10bd495de..753fa0b51 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectReplace.java @@ -64,10 +64,10 @@ public class IrisObjectReplace { { KList b = new KList<>(); - for (IrisBlockData i : find) { + for(IrisBlockData i : find) { BlockData bx = i.getBlockData(rdata); - if (bx != null) { + if(bx != null) { b.add(bx); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java index f9742ff64..723832fa4 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectRotation.java @@ -92,7 +92,7 @@ public class IrisObjectRotation { } public IrisObject rotateCopy(IrisObject e) { - if (e == null) { + if(e == null) { return null; } @@ -101,7 +101,7 @@ public class IrisObjectRotation { public IrisJigsawPiece rotateCopy(IrisJigsawPiece v) { IrisJigsawPiece piece = v.copy(); - for (IrisJigsawPieceConnector i : piece.getConnectors()) { + for(IrisJigsawPieceConnector i : piece.getConnectors()) { i.setPosition(rotate(i.getPosition())); i.setDirection(rotate(i.getDirection())); } @@ -119,11 +119,11 @@ public class IrisObjectRotation { } public double getRotation(int spin, IrisAxisRotationClamp clamp) { - if (!enabled) { + if(!enabled) { return 0; } - if (!clamp.isEnabled()) { + if(!clamp.isEnabled()) { return 0; } @@ -135,27 +135,27 @@ public class IrisObjectRotation { int y = (int) Math.round(v.getY()); int z = (int) Math.round(v.getZ()); - if (x == 0 && z == -1) { + if(x == 0 && z == -1) { return BlockFace.NORTH; } - if (x == 0 && z == 1) { + if(x == 0 && z == 1) { return BlockFace.SOUTH; } - if (x == 1 && z == 0) { + if(x == 1 && z == 0) { return BlockFace.EAST; } - if (x == -1 && z == 0) { + if(x == -1 && z == 0) { return BlockFace.WEST; } - if (y > 0) { + if(y > 0) { return BlockFace.UP; } - if (y < 0) { + if(y < 0) { return BlockFace.DOWN; } @@ -167,28 +167,28 @@ public class IrisObjectRotation { int y = v.getBlockY(); int z = v.getBlockZ(); - if (x == 0 && z == -1) return BlockFace.NORTH; - if (x == 1 && z == -2) return BlockFace.NORTH_NORTH_EAST; - if (x == 1 && z == -1) return BlockFace.NORTH_EAST; - if (x == 2 && z == -1) return BlockFace.EAST_NORTH_EAST; - if (x == 1 && z == 0) return BlockFace.EAST; - if (x == 2 && z == 1) return BlockFace.EAST_SOUTH_EAST; - if (x == 1 && z == 1) return BlockFace.SOUTH_EAST; - if (x == 1 && z == 2) return BlockFace.SOUTH_SOUTH_EAST; - if (x == 0 && z == 1) return BlockFace.SOUTH; - if (x == -1 && z == 2) return BlockFace.SOUTH_SOUTH_WEST; - if (x == -1 && z == 1) return BlockFace.SOUTH_WEST; - if (x == -2 && z == 1) return BlockFace.WEST_SOUTH_WEST; - if (x == -1 && z == 0) return BlockFace.WEST; - if (x == -2 && z == -1) return BlockFace.WEST_NORTH_WEST; - if (x == -1 && z == -1) return BlockFace.NORTH_WEST; - if (x == -1 && z == -2) return BlockFace.NORTH_NORTH_WEST; + if(x == 0 && z == -1) return BlockFace.NORTH; + if(x == 1 && z == -2) return BlockFace.NORTH_NORTH_EAST; + if(x == 1 && z == -1) return BlockFace.NORTH_EAST; + if(x == 2 && z == -1) return BlockFace.EAST_NORTH_EAST; + if(x == 1 && z == 0) return BlockFace.EAST; + if(x == 2 && z == 1) return BlockFace.EAST_SOUTH_EAST; + if(x == 1 && z == 1) return BlockFace.SOUTH_EAST; + if(x == 1 && z == 2) return BlockFace.SOUTH_SOUTH_EAST; + if(x == 0 && z == 1) return BlockFace.SOUTH; + if(x == -1 && z == 2) return BlockFace.SOUTH_SOUTH_WEST; + if(x == -1 && z == 1) return BlockFace.SOUTH_WEST; + if(x == -2 && z == 1) return BlockFace.WEST_SOUTH_WEST; + if(x == -1 && z == 0) return BlockFace.WEST; + if(x == -2 && z == -1) return BlockFace.WEST_NORTH_WEST; + if(x == -1 && z == -1) return BlockFace.NORTH_WEST; + if(x == -1 && z == -2) return BlockFace.NORTH_NORTH_WEST; - if (y > 0) { + if(y > 0) { return BlockFace.UP; } - if (y < 0) { + if(y < 0) { return BlockFace.DOWN; } @@ -196,7 +196,7 @@ public class IrisObjectRotation { } public BlockFace faceForAxis(Axis axis) { - return switch (axis) { + return switch(axis) { case X -> BlockFace.EAST; case Y -> BlockFace.UP; case Z -> BlockFace.NORTH; @@ -205,7 +205,7 @@ public class IrisObjectRotation { } public Axis axisFor(BlockFace f) { - return switch (f) { + return switch(f) { case NORTH, SOUTH -> Axis.Z; case EAST, WEST -> Axis.X; default -> Axis.Y; @@ -214,7 +214,7 @@ public class IrisObjectRotation { } public Axis axisFor2D(BlockFace f) { - return switch (f) { + return switch(f) { case EAST, WEST, UP, DOWN -> Axis.X; default -> Axis.Z; }; @@ -228,22 +228,22 @@ public class IrisObjectRotation { int spiny = (int) (90D * (Math.ceil(Math.abs((spinyy % 360D) / 90D)))); int spinz = (int) (90D * (Math.ceil(Math.abs((spinzz % 360D) / 90D)))); - if (!canRotate()) { + if(!canRotate()) { return d; } - if (d instanceof Directional g) { + if(d instanceof Directional g) { BlockFace f = g.getFacing(); BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ()); bv = rotate(bv.clone(), spinx, spiny, spinz); BlockFace t = getFace(bv); - if (g.getFaces().contains(t)) { + if(g.getFaces().contains(t)) { g.setFacing(t); - } else if (!g.getMaterial().isSolid()) { + } else if(!g.getMaterial().isSolid()) { d = null; } - } else if (d instanceof Rotatable g) { + } else if(d instanceof Rotatable g) { BlockFace f = g.getRotation(); BlockVector bv = new BlockVector(f.getModX(), 0, f.getModZ()); @@ -252,36 +252,36 @@ public class IrisObjectRotation { g.setRotation(face); - } else if (d instanceof Orientable) { + } else if(d instanceof Orientable) { BlockFace f = getFace(((Orientable) d).getAxis()); BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ()); bv = rotate(bv.clone(), spinx, spiny, spinz); Axis a = getAxis(bv); - if (!a.equals(((Orientable) d).getAxis()) && ((Orientable) d).getAxes().contains(a)) { + if(!a.equals(((Orientable) d).getAxis()) && ((Orientable) d).getAxes().contains(a)) { ((Orientable) d).setAxis(a); } - } else if (d instanceof MultipleFacing g) { + } else if(d instanceof MultipleFacing g) { List faces = new KList<>(); - for (BlockFace i : g.getFaces()) { + for(BlockFace i : g.getFaces()) { BlockVector bv = new BlockVector(i.getModX(), i.getModY(), i.getModZ()); bv = rotate(bv.clone(), spinx, spiny, spinz); BlockFace r = getFace(bv); - if (g.getAllowedFaces().contains(r)) { + if(g.getAllowedFaces().contains(r)) { faces.add(r); } } - for (BlockFace i : g.getFaces()) { + for(BlockFace i : g.getFaces()) { g.setFace(i, false); } - for (BlockFace i : faces) { + for(BlockFace i : faces) { g.setFace(i, true); } - } else if (d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable g) { + } else if(d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable g) { //TODO: Fucks up logs BlockFace f = faceForAxis(g.getAxis()); BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ()); @@ -290,7 +290,7 @@ public class IrisObjectRotation { Axis a = !g.getAxes().contains(Axis.Y) ? axisFor(t) : axisFor2D(t); ((Orientable) d).setAxis(a); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -299,15 +299,15 @@ public class IrisObjectRotation { } public Axis getAxis(BlockVector v) { - if (Math.abs(v.getBlockX()) > Math.max(Math.abs(v.getBlockY()), Math.abs(v.getBlockZ()))) { + if(Math.abs(v.getBlockX()) > Math.max(Math.abs(v.getBlockY()), Math.abs(v.getBlockZ()))) { return Axis.X; } - if (Math.abs(v.getBlockY()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockZ()))) { + if(Math.abs(v.getBlockY()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockZ()))) { return Axis.Y; } - if (Math.abs(v.getBlockZ()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockY()))) { + if(Math.abs(v.getBlockZ()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockY()))) { return Axis.Z; } @@ -315,7 +315,7 @@ public class IrisObjectRotation { } private BlockFace getFace(Axis axis) { - return switch (axis) { + return switch(axis) { case X -> BlockFace.EAST; case Y -> BlockFace.UP; case Z -> BlockFace.SOUTH; @@ -331,22 +331,22 @@ public class IrisObjectRotation { } public BlockVector rotate(BlockVector b, int spinx, int spiny, int spinz) { - if (!canRotate()) { + if(!canRotate()) { return b; } BlockVector v = b.clone(); - if (canRotateX()) { - if (getXAxis().isLocked()) { - if (Math.abs(getXAxis().getMax()) % 360D == 180D) { + if(canRotateX()) { + if(getXAxis().isLocked()) { + if(Math.abs(getXAxis().getMax()) % 360D == 180D) { v.setZ(-v.getZ()); v.setY(-v.getY()); - } else if (getXAxis().getMax() % 360D == 90D || getXAxis().getMax() % 360D == -270D) { + } else if(getXAxis().getMax() % 360D == 90D || getXAxis().getMax() % 360D == -270D) { double z = v.getZ(); v.setZ(v.getY()); v.setY(-z); - } else if (getXAxis().getMax() == -90D || getXAxis().getMax() % 360D == 270D) { + } else if(getXAxis().getMax() == -90D || getXAxis().getMax() % 360D == 270D) { double z = v.getZ(); v.setZ(-v.getY()); v.setY(z); @@ -358,16 +358,16 @@ public class IrisObjectRotation { } } - if (canRotateZ()) { - if (getZAxis().isLocked()) { - if (Math.abs(getZAxis().getMax()) % 360D == 180D) { + if(canRotateZ()) { + if(getZAxis().isLocked()) { + if(Math.abs(getZAxis().getMax()) % 360D == 180D) { v.setY(-v.getY()); v.setX(-v.getX()); - } else if (getZAxis().getMax() % 360D == 90D || getZAxis().getMax() % 360D == -270D) { + } else if(getZAxis().getMax() % 360D == 90D || getZAxis().getMax() % 360D == -270D) { double y = v.getY(); v.setY(v.getX()); v.setX(-y); - } else if (getZAxis().getMax() == -90D || getZAxis().getMax() % 360D == 270D) { + } else if(getZAxis().getMax() == -90D || getZAxis().getMax() % 360D == 270D) { double y = v.getY(); v.setY(-v.getX()); v.setX(y); @@ -379,16 +379,16 @@ public class IrisObjectRotation { } } - if (canRotateY()) { - if (getYAxis().isLocked()) { - if (Math.abs(getYAxis().getMax()) % 360D == 180D) { + if(canRotateY()) { + if(getYAxis().isLocked()) { + if(Math.abs(getYAxis().getMax()) % 360D == 180D) { v.setX(-v.getX()); v.setZ(-v.getZ()); - } else if (getYAxis().getMax() % 360D == 90D || getYAxis().getMax() % 360D == -270D) { + } else if(getYAxis().getMax() % 360D == 90D || getYAxis().getMax() % 360D == -270D) { double x = v.getX(); v.setX(v.getZ()); v.setZ(-x); - } else if (getYAxis().getMax() == -90D || getYAxis().getMax() % 360D == 270D) { + } else if(getYAxis().getMax() == -90D || getYAxis().getMax() % 360D == 270D) { double x = v.getX(); v.setX(-v.getZ()); v.setZ(x); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java index 4f6bd0529..4a0475145 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectScale.java @@ -38,11 +38,11 @@ import lombok.experimental.Accessors; @Data public class IrisObjectScale { private static transient ConcurrentLinkedHashMap> cache - = new ConcurrentLinkedHashMap.Builder>() - .initialCapacity(64) - .maximumWeightedCapacity(1024) - .concurrencyLevel(32) - .build(); + = new ConcurrentLinkedHashMap.Builder>() + .initialCapacity(64) + .maximumWeightedCapacity(1024) + .concurrencyLevel(32) + .build(); @MinNumber(1) @MaxNumber(32) @Desc("Iris Objects are scaled and cached to speed up placements. Because of this extra memory is used, so we evenly distribute variations across the defined scale range, then pick one randomly. If the differences is small, use a lower number. For more possibilities on the scale spectrum, increase this at the cost of memory.") @@ -69,7 +69,7 @@ public class IrisObjectScale { public double getMaxScale() { double mx = 0; - for (double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) { + for(double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) { mx = i; } @@ -77,13 +77,13 @@ public class IrisObjectScale { } public IrisObject get(RNG rng, IrisObject origin) { - if (shouldScale()) { + if(shouldScale()) { return origin; } return cache.computeIfAbsent(origin, (k) -> { KList c = new KList<>(); - for (double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) { + for(double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) { c.add(origin.scaled(i, getInterpolation())); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java b/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java index f5f0f1f27..f156ede97 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisObjectTranslate.java @@ -62,7 +62,7 @@ public class IrisObjectTranslate { } public BlockVector translate(BlockVector i) { - if (canTranslate()) { + if(canTranslate()) { return (BlockVector) i.clone().add(new BlockVector(x, y, z)); } @@ -70,7 +70,7 @@ public class IrisObjectTranslate { } public BlockVector translate(BlockVector clone, IrisObjectRotation rotation, int sx, int sy, int sz) { - if (canTranslate()) { + if(canTranslate()) { return (BlockVector) clone.clone().add(rotation.rotate(new BlockVector(x, y, z), sx, sy, sz)); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisOreGenerator.java b/src/main/java/com/volmit/iris/engine/object/IrisOreGenerator.java index 1a3cc6f23..afe4fd511 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisOreGenerator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisOreGenerator.java @@ -20,11 +20,9 @@ package com.volmit.iris.engine.object; import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.engine.data.cache.AtomicCache; -import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.object.annotations.Desc; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.noise.CNG; -import jdk.jfr.Description; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -50,21 +48,21 @@ public class IrisOreGenerator { private transient AtomicCache chanceCache = new AtomicCache<>(); - public BlockData generate(int x, int y, int z, RNG rng, IrisData data){ - if(palette.getPalette().isEmpty()){ - return null; + public BlockData generate(int x, int y, int z, RNG rng, IrisData data) { + if(palette.getPalette().isEmpty()) { + return null; } - if(!range.contains(y)){ + if(!range.contains(y)) { return null; } CNG chance = chanceCache.aquire(() -> chanceStyle.create(rng, data)); - if (chance.noise(x,y,z ) > threshold){ + if(chance.noise(x, y, z) > threshold) { return null; } - return palette.get( rng, x,y,z, data); + return palette.get(rng, x, y, z, data); } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java b/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java index f58902864..253e33aef 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisPotionEffect.java @@ -64,19 +64,19 @@ public class IrisPotionEffect { { PotionEffectType t = PotionEffectType.LUCK; - if (getPotionEffect().isEmpty()) { + if(getPotionEffect().isEmpty()) { return t; } try { - for (PotionEffectType i : PotionEffectType.values()) { - if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) { + for(PotionEffectType i : PotionEffectType.values()) { + if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) { t = i; return t; } } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -88,10 +88,10 @@ public class IrisPotionEffect { } public void apply(LivingEntity p) { - if (strength > -1) { - if (p.hasPotionEffect(getRealType())) { + if(strength > -1) { + if(p.hasPotionEffect(getRealType())) { PotionEffect e = p.getPotionEffect(getRealType()); - if (e.getAmplifier() > strength) { + if(e.getAmplifier() > strength) { return; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisPyramid.java b/src/main/java/com/volmit/iris/engine/object/IrisPyramid.java index 4d47602b1..cb7fa5ae6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisPyramid.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisPyramid.java @@ -48,7 +48,7 @@ public class IrisPyramid implements IRare { public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) { writer.setPyramid(x, y, z, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0)), - (int) baseWidth.get(rng, z, y, engine.getData()), true); + (int) baseWidth.get(rng, z, y, engine.getData()), true); } public double maxSize() { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRange.java b/src/main/java/com/volmit/iris/engine/object/IrisRange.java index 28a3243c0..bc70f406a 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRange.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRange.java @@ -40,7 +40,7 @@ public class IrisRange { private double max = 32; public double get(RNG rng) { - if (min == max) { + if(min == max) { return min; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRavine.java b/src/main/java/com/volmit/iris/engine/object/IrisRavine.java index 8a0a1a13e..d2cdfc34c 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRavine.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRavine.java @@ -104,15 +104,15 @@ public class IrisRavine extends IrisRegistrant { int highestWater = Math.max(waterHint, -1); boolean water = false; - if (highestWater == -1) { - for (IrisPosition i : pos) { + if(highestWater == -1) { + for(IrisPosition i : pos) { int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y; int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), i.getX(), i.getZ())); int surface = (int) Math.round(rsurface - depth * 0.45); int yy = surface + depth; int th = engine.getHeight(x, z, true); - if (yy > th && th < engine.getDimension().getFluidHeight()) { + if(yy > th && th < engine.getDimension().getFluidHeight()) { highestWater = Math.max(highestWater, yy); water = true; break; @@ -125,11 +125,11 @@ public class IrisRavine extends IrisRegistrant { MatterCavern c = new MatterCavern(true, customBiome, (byte) (water ? 1 : 0)); MatterCavern l = new MatterCavern(true, customBiome, (byte) 2); - if (pos.size() < nodeThreshold) { + if(pos.size() < nodeThreshold) { return; } - for (IrisPosition p : pos) { + for(IrisPosition p : pos) { int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y; int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), p.getX(), p.getZ())); int width = (int) Math.round(bw.fitDouble(baseWidthStyle.getMin(), baseWidthStyle.getMax(), p.getX(), p.getZ())); @@ -137,19 +137,19 @@ public class IrisRavine extends IrisRegistrant { fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface - depth, surface), p.getZ(), Math.max(highestWater, waterHint)); - for (int i = surface + depth; i >= surface; i--) { - if (i % ribThickness == 0) { + for(int i = surface + depth; i >= surface; i--) { + if(i % ribThickness == 0) { double v = width + ((((surface + depth) - i) * (angle / 360D))); - if (v <= 0.25) { + if(v <= 0.25) { break; } - if (i <= ribThickness + 2) { + if(i <= ribThickness + 2) { break; } - if (lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) { + if(lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) { writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, l); } else { writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c); @@ -157,19 +157,19 @@ public class IrisRavine extends IrisRegistrant { } } - for (int i = surface - depth; i <= surface; i++) { - if (i % ribThickness == 0) { + for(int i = surface - depth; i <= surface; i++) { + if(i % ribThickness == 0) { double v = width - ((((surface - depth) - i) * (angle / 360D))); - if (v <= 0.25) { + if(v <= 0.25) { break; } - if (i <= ribThickness + 2) { + if(i <= ribThickness + 2) { break; } - if (lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) { + if(lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) { writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, l); } else { writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRavinePlacer.java b/src/main/java/com/volmit/iris/engine/object/IrisRavinePlacer.java index bff31b3c2..015ad2dfd 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRavinePlacer.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRavinePlacer.java @@ -64,18 +64,18 @@ public class IrisRavinePlacer implements IRare { } public void generateRavine(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) { - if (fail.get()) { + if(fail.get()) { return; } - if (rng.nextInt(rarity) != 0) { + if(rng.nextInt(rarity) != 0) { return; } IrisData data = engine.getData(); IrisRavine ravine = getRealRavine(data); - if (ravine == null) { + if(ravine == null) { Iris.warn("Unable to locate ravine for generation!"); fail.set(true); return; @@ -85,7 +85,7 @@ public class IrisRavinePlacer implements IRare { int xx = x + rng.nextInt(15); int zz = z + rng.nextInt(15); ravine.generate(mantle, rng, engine, xx, y, zz, waterHint); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); fail.set(true); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisRegion.java b/src/main/java/com/volmit/iris/engine/object/IrisRegion.java index 38c24050a..8e3bca85a 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisRegion.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisRegion.java @@ -182,14 +182,14 @@ public class IrisRegion extends IrisRegistrant implements IRare { private KList ores = new KList<>(); public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) { - if (ores.isEmpty()) { + if(ores.isEmpty()) { return null; } BlockData b = null; - for (IrisOreGenerator i : ores) { + for(IrisOreGenerator i : ores) { - b = i.generate(x,y,z,rng,data); - if(b != null ){ + b = i.generate(x, y, z, rng, data); + if(b != null) { return b; } } @@ -205,8 +205,8 @@ public class IrisRegion extends IrisRegistrant implements IRare { { KList o = getObjects().copy(); - for (IrisObjectPlacement i : o.copy()) { - if (!i.getCarvingSupport().supportsSurface()) { + for(IrisObjectPlacement i : o.copy()) { + if(!i.getCarvingSupport().supportsSurface()) { o.remove(i); } } @@ -220,8 +220,8 @@ public class IrisRegion extends IrisRegistrant implements IRare { { KList o = getObjects().copy(); - for (IrisObjectPlacement i : o.copy()) { - if (!i.getCarvingSupport().supportsCarving()) { + for(IrisObjectPlacement i : o.copy()) { + if(!i.getCarvingSupport().supportsCarving()) { o.remove(i); } } @@ -231,7 +231,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { } public double getBiomeZoom(InferredType t) { - switch (t) { + switch(t) { case CAVE: return caveBiomeZoom; case LAND: @@ -249,7 +249,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { public CNG getShoreHeightGenerator() { return shoreHeightGenerator.aquire(() -> - CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)))); + CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)))); } public double getShoreHeight(double x, double z) { @@ -270,9 +270,9 @@ public class IrisRegion extends IrisRegistrant implements IRare { KMap b = new KMap<>(); KSet names = getAllBiomeIds(); - while (!names.isEmpty()) { - for (String i : new KList<>(names)) { - if (b.containsKey(i)) { + while(!names.isEmpty()) { + for(String i : new KList<>(names)) { + if(b.containsKey(i)) { names.remove(i); continue; } @@ -280,7 +280,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { IrisBiome biome = g.getData().getBiomeLoader().load(i); names.remove(i); - if (biome == null) { + if(biome == null) { continue; } @@ -294,13 +294,13 @@ public class IrisRegion extends IrisRegistrant implements IRare { } public KList getBiomes(DataProvider g, InferredType type) { - if (type.equals(InferredType.LAND)) { + if(type.equals(InferredType.LAND)) { return getRealLandBiomes(g); - } else if (type.equals(InferredType.SEA)) { + } else if(type.equals(InferredType.SEA)) { return getRealSeaBiomes(g); - } else if (type.equals(InferredType.SHORE)) { + } else if(type.equals(InferredType.SHORE)) { return getRealShoreBiomes(g); - } else if (type.equals(InferredType.CAVE)) { + } else if(type.equals(InferredType.CAVE)) { return getRealCaveBiomes(g); } @@ -312,7 +312,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { { KList realCaveBiomes = new KList<>(); - for (String i : getCaveBiomes()) { + for(String i : getCaveBiomes()) { realCaveBiomes.add(g.getData().getBiomeLoader().load(i)); } @@ -325,7 +325,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { { KList realShoreBiomes = new KList<>(); - for (String i : getShoreBiomes()) { + for(String i : getShoreBiomes()) { realShoreBiomes.add(g.getData().getBiomeLoader().load(i)); } @@ -338,7 +338,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { { KList realSeaBiomes = new KList<>(); - for (String i : getSeaBiomes()) { + for(String i : getSeaBiomes()) { realSeaBiomes.add(g.getData().getBiomeLoader().load(i)); } @@ -351,7 +351,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { { KList realLandBiomes = new KList<>(); - for (String i : getLandBiomes()) { + for(String i : getLandBiomes()) { realLandBiomes.add(g.getData().getBiomeLoader().load(i)); } @@ -367,9 +367,9 @@ public class IrisRegion extends IrisRegistrant implements IRare { names.addAll(seaBiomes); names.addAll(shoreBiomes); - while (!names.isEmpty()) { - for (String i : new KList<>(names)) { - if (b.containsKey(i)) { + while(!names.isEmpty()) { + for(String i : new KList<>(names)) { + if(b.containsKey(i)) { names.remove(i); continue; } @@ -377,7 +377,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { IrisBiome biome = IrisData.loadAnyBiome(i); names.remove(i); - if (biome == null) { + if(biome == null) { continue; } @@ -392,17 +392,17 @@ public class IrisRegion extends IrisRegistrant implements IRare { public Color getColor(DataProvider dataProvider, RenderType type) { return this.cacheColor.aquire(() -> { - if (this.color == null) { + if(this.color == null) { Random rand = new Random(getName().hashCode() + getAllBiomeIds().hashCode()); RandomColor randomColor = new RandomColor(rand); KList biomes = getRealLandBiomes(dataProvider); - while (biomes.size() > 0) { + while(biomes.size() > 0) { int index = rand.nextInt(biomes.size()); IrisBiome biome = biomes.get(index); - if (biome.getVanillaDerivative() != null) { + if(biome.getVanillaDerivative() != null) { RandomColor.Color col = VanillaBiomeMap.getColorType(biome.getVanillaDerivative()); RandomColor.Luminosity lum = VanillaBiomeMap.getColorLuminosity(biome.getVanillaDerivative()); RandomColor.SaturationType sat = VanillaBiomeMap.getColorSaturatiom(biome.getVanillaDerivative()); @@ -419,7 +419,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { try { return Color.decode(this.color); - } catch (NumberFormatException e) { + } catch(NumberFormatException e) { Iris.warn("Could not parse color \"" + this.color + "\" for region " + getName()); return Color.WHITE; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisSlopeClip.java b/src/main/java/com/volmit/iris/engine/object/IrisSlopeClip.java index 0c5094a2c..dbd53a46d 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisSlopeClip.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisSlopeClip.java @@ -50,7 +50,7 @@ public class IrisSlopeClip { @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isValid(double slope) { - if (isDefault()) { + if(isDefault()) { return true; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisSpawner.java b/src/main/java/com/volmit/iris/engine/object/IrisSpawner.java index 04ec09c1f..62c97b387 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisSpawner.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisSpawner.java @@ -74,17 +74,17 @@ public class IrisSpawner extends IrisRegistrant { private IrisSpawnGroup group = IrisSpawnGroup.NORMAL; public boolean isValid(IrisBiome biome) { - return switch (group) { - case NORMAL -> switch (biome.getInferredType()) { + return switch(group) { + case NORMAL -> switch(biome.getInferredType()) { case SHORE, SEA, CAVE, DEFER -> false; case LAND -> true; }; case CAVE -> true; - case UNDERWATER -> switch (biome.getInferredType()) { + case UNDERWATER -> switch(biome.getInferredType()) { case SHORE, LAND, CAVE, DEFER -> false; case SEA -> true; }; - case BEACH -> switch (biome.getInferredType()) { + case BEACH -> switch(biome.getInferredType()) { case SHORE -> true; case LAND, CAVE, SEA, DEFER -> false; }; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java b/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java index 1a2e2c8bf..cfe33c2cf 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisStyledRange.java @@ -47,11 +47,11 @@ public class IrisStyledRange { private IrisGeneratorStyle style = new IrisGeneratorStyle(NoiseStyle.STATIC); public double get(RNG rng, double x, double z, IrisData data) { - if (min == max) { + if(min == max) { return min; } - if (style.isFlat()) { + if(style.isFlat()) { return M.lerp(min, max, 0.5); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisSurface.java b/src/main/java/com/volmit/iris/engine/object/IrisSurface.java index d7bbe2bf8..9c29bab8f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisSurface.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisSurface.java @@ -44,23 +44,24 @@ public enum IrisSurface { /** * Check if this Iris surface matches the blockstate provided * - * @param state The blockstate + * @param state + * The blockstate * @return True if it matches */ public boolean matches(Block state) { Material type = state.getType(); - if (type.isSolid()) { + if(type.isSolid()) { return this == LAND || this == OVERWORLD || (this == ANIMAL - && (type == Material.GRASS_BLOCK || type == Material.DIRT - || type == Material.DIRT_PATH || type == Material.COARSE_DIRT - || type == Material.ROOTED_DIRT || type == Material.PODZOL - || type == Material.MYCELIUM || type == Material.SNOW_BLOCK)); + && (type == Material.GRASS_BLOCK || type == Material.DIRT + || type == Material.DIRT_PATH || type == Material.COARSE_DIRT + || type == Material.ROOTED_DIRT || type == Material.PODZOL + || type == Material.MYCELIUM || type == Material.SNOW_BLOCK)); } - if (type == Material.LAVA) return this == LAVA; - if (type == Material.WATER || type == Material.SEAGRASS - || type == Material.TALL_SEAGRASS || type == Material.KELP_PLANT - || type == Material.KELP || - (state instanceof Waterlogged && ((Waterlogged) state).isWaterlogged())) + if(type == Material.LAVA) return this == LAVA; + if(type == Material.WATER || type == Material.SEAGRASS + || type == Material.TALL_SEAGRASS || type == Material.KELP_PLANT + || type == Material.KELP || + (state instanceof Waterlogged && ((Waterlogged) state).isWaterlogged())) return this == WATER || this == OVERWORLD; return false; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisTimeBlock.java b/src/main/java/com/volmit/iris/engine/object/IrisTimeBlock.java index c87d4e7c4..73cfc1d6b 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisTimeBlock.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisTimeBlock.java @@ -38,11 +38,11 @@ public class IrisTimeBlock { } public boolean isWithin(double hour) { - if (startHour == endHour) { + if(startHour == endHour) { return endHour != -1; } - if (startHour > endHour) { + if(startHour > endHour) { return hour >= startHour || hour <= endHour; } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisTree.java b/src/main/java/com/volmit/iris/engine/object/IrisTree.java index e174581ac..8e87e69da 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisTree.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisTree.java @@ -53,7 +53,7 @@ public class IrisTree { private boolean anySize; public boolean matches(IrisTreeSize size, TreeType type) { - if (!matchesSize(size)) { + if(!matchesSize(size)) { return false; } @@ -61,8 +61,8 @@ public class IrisTree { } private boolean matchesSize(IrisTreeSize size) { - for (IrisTreeSize i : getSizes()) { - if ((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) { + for(IrisTreeSize i : getSizes()) { + if((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) { return true; } } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisTreeSize.java b/src/main/java/com/volmit/iris/engine/object/IrisTreeSize.java index cfd751618..16ee2a43a 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisTreeSize.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisTreeSize.java @@ -45,7 +45,8 @@ public class IrisTreeSize { /** * Does the size match * - * @param size the size to check match + * @param size + * the size to check match * @return true if it matches (fits within width and depth) */ public boolean doesMatch(IrisTreeSize size) { diff --git a/src/main/java/com/volmit/iris/engine/object/IrisVillagerOverride.java b/src/main/java/com/volmit/iris/engine/object/IrisVillagerOverride.java index bc1776d78..4abe8611f 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisVillagerOverride.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisVillagerOverride.java @@ -41,27 +41,27 @@ import org.bukkit.inventory.ItemStack; @EqualsAndHashCode(callSuper = false) public class IrisVillagerOverride { @Desc(""" - Disable the trade altogether. - If a cartographer villager gets a new explorer map trade: - If this is enabled -> the trade is removed - If this is disabled -> the trade is replaced with the "override" setting below - Default is true, so if you omit this, trades will be removed.""") + Disable the trade altogether. + If a cartographer villager gets a new explorer map trade: + If this is enabled -> the trade is removed + If this is disabled -> the trade is replaced with the "override" setting below + Default is true, so if you omit this, trades will be removed.""") private boolean disableTrade = true; @DependsOn("disableTrade") @Required @Desc(""" - The items to override the cartographer trade with. - By default, this is: - 3 emeralds + 3 glass blocks -> 1 spyglass. - Can trade 3 to 5 times""") + The items to override the cartographer trade with. + By default, this is: + 3 emeralds + 3 glass blocks -> 1 spyglass. + Can trade 3 to 5 times""") @ArrayType(min = 1, type = IrisVillagerTrade.class) private KList items = new KList<>(new IrisVillagerTrade() - .setIngredient1(new ItemStack(Material.EMERALD, 3)) - .setIngredient2(new ItemStack(Material.GLASS, 3)) - .setResult(new ItemStack(Material.SPYGLASS)) - .setMinTrades(3) - .setMaxTrades(5)); + .setIngredient1(new ItemStack(Material.EMERALD, 3)) + .setIngredient2(new ItemStack(Material.GLASS, 3)) + .setResult(new ItemStack(Material.SPYGLASS)) + .setMinTrades(3) + .setMaxTrades(5)); public KList getValidItems() { KList valid = new KList<>(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisVillagerTrade.java b/src/main/java/com/volmit/iris/engine/object/IrisVillagerTrade.java index 25919b58c..378319d46 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisVillagerTrade.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisVillagerTrade.java @@ -81,39 +81,39 @@ public class IrisVillagerTrade { */ public boolean isValidItems() { KList warnings = new KList<>(); - if (ingredient1 == null) { + if(ingredient1 == null) { warnings.add("Ingredient 1 is null"); } - if (result == null) { + if(result == null) { warnings.add("Result is null"); } - if (minTrades <= 0) { + if(minTrades <= 0) { warnings.add("Negative minimal trades"); } - if (maxTrades <= 0) { + if(maxTrades <= 0) { warnings.add("Negative maximal trades"); } - if (minTrades > maxTrades) { + if(minTrades > maxTrades) { warnings.add("More minimal than maximal trades"); } - if (ingredient1 != null && !ingredient1.getType().isItem()) { + if(ingredient1 != null && !ingredient1.getType().isItem()) { warnings.add("Ingredient 1 is not an item"); } - if (ingredient2 != null && !ingredient2.getType().isItem()) { + if(ingredient2 != null && !ingredient2.getType().isItem()) { warnings.add("Ingredient 2 is not an item"); } - if (result != null && !result.getType().isItem()) { + if(result != null && !result.getType().isItem()) { warnings.add("Result is not an item"); } - if (warnings.isEmpty()) { + if(warnings.isEmpty()) { return true; } else { Iris.warn("Faulty item in cartographer item overrides: " + this); @@ -128,7 +128,7 @@ public class IrisVillagerTrade { * @return The list of 1 or 2 ingredients (depending on if ing2 is null) */ public List getIngredients() { - if (!isValidItems()) { + if(!isValidItems()) { return null; } return ingredient2 == null ? new KList<>(ingredient1) : new KList<>(ingredient1, ingredient2); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisWeather.java b/src/main/java/com/volmit/iris/engine/object/IrisWeather.java index 1e1628a5d..5dc4c82e2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisWeather.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisWeather.java @@ -36,7 +36,7 @@ public enum IrisWeather { ANY; public boolean is(World world) { - return switch (this) { + return switch(this) { case NONE -> world.isClearWeather(); case DOWNFALL -> world.hasStorm(); case DOWNFALL_WITH_THUNDER -> world.hasStorm() && world.isThundering(); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisWorld.java b/src/main/java/com/volmit/iris/engine/object/IrisWorld.java index cdd296bfb..ea4a9ddf4 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisWorld.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisWorld.java @@ -60,11 +60,11 @@ public class IrisWorld { private static IrisWorld bindWorld(IrisWorld iw, World world) { return iw.name(world.getName()) - .worldFolder(world.getWorldFolder()) - .minHeight(world.getMinHeight()) - .maxHeight(world.getMaxHeight()) - .realWorld(world) - .environment(world.getEnvironment()); + .worldFolder(world.getWorldFolder()) + .minHeight(world.getMinHeight()) + .maxHeight(world.getMaxHeight()) + .realWorld(world) + .environment(world.getEnvironment()); } public long getRawWorldSeed() { @@ -76,13 +76,13 @@ public class IrisWorld { } public boolean tryGetRealWorld() { - if (hasRealWorld()) { + if(hasRealWorld()) { return true; } World w = Bukkit.getWorld(name); - if (w != null) { + if(w != null) { realWorld = w; return true; } @@ -96,7 +96,7 @@ public class IrisWorld { public List getPlayers() { - if (hasRealWorld()) { + if(hasRealWorld()) { return realWorld().getPlayers(); } @@ -104,13 +104,13 @@ public class IrisWorld { } public void evacuate() { - if (hasRealWorld()) { + if(hasRealWorld()) { IrisToolbelt.evacuate(realWorld()); } } public void bind(World world) { - if (hasRealWorld()) { + if(hasRealWorld()) { return; } @@ -118,7 +118,7 @@ public class IrisWorld { } public Location spawnLocation() { - if (hasRealWorld()) { + if(hasRealWorld()) { return realWorld().getSpawnLocation(); } @@ -127,7 +127,7 @@ public class IrisWorld { } public Collection getEntitiesByClass(Class t) { - if (hasRealWorld()) { + if(hasRealWorld()) { return realWorld().getEntitiesByClass(t); } diff --git a/src/main/java/com/volmit/iris/engine/object/IrisWorm.java b/src/main/java/com/volmit/iris/engine/object/IrisWorm.java index a3119fa31..a12d418a2 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisWorm.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisWorm.java @@ -60,7 +60,7 @@ public class IrisWorm { @Desc("The thickness of the worms. Each individual worm has the same thickness while traveling however, each spawned worm will vary in thickness.") private IrisStyledRange girth = new IrisStyledRange().setMin(3).setMax(5) - .setStyle(new IrisGeneratorStyle(NoiseStyle.PERLIN)); + .setStyle(new IrisGeneratorStyle(NoiseStyle.PERLIN)); public KList generate(RNG rng, IrisData data, MantleWriter writer, IrisRange verticalRange, int x, int y, int z, Consumer fork) { int itr = maxIterations; @@ -75,12 +75,12 @@ public class IrisWorm { CNG gy = xStyle.getGenerator().createNoCache(new RNG(rng.lmax()), data); CNG gz = xStyle.getGenerator().createNoCache(new RNG(rng.lmax()), data); - while (itr-- > 0) { + while(itr-- > 0) { IrisPosition current = new IrisPosition(Math.round(cx), Math.round(cy), Math.round(cz)); fork.accept(current); pos.add(current); - if (check != null) { + if(check != null) { check.add(current); } @@ -92,19 +92,19 @@ public class IrisWorm { cz += jz; IrisPosition next = new IrisPosition(Math.round(cx), Math.round(cy), Math.round(cz)); - if (verticalRange != null && !verticalRange.contains(next.getY())) { + if(verticalRange != null && !verticalRange.contains(next.getY())) { break; } - if (!writer.isWithin((int) Math.round(cx), verticalRange != null ? (int) Math.round(cy) : 5, (int) Math.round(cz))) { + if(!writer.isWithin((int) Math.round(cx), verticalRange != null ? (int) Math.round(cy) : 5, (int) Math.round(cz))) { break; } - if (next.isLongerThan(start, maxDistance)) { + if(next.isLongerThan(start, maxDistance)) { break; } - if (check != null && check.contains(next)) { + if(check != null && check.contains(next)) { break; } } diff --git a/src/main/java/com/volmit/iris/engine/object/TileBanner.java b/src/main/java/com/volmit/iris/engine/object/TileBanner.java index 7206bcf54..26a80c0b9 100644 --- a/src/main/java/com/volmit/iris/engine/object/TileBanner.java +++ b/src/main/java/com/volmit/iris/engine/object/TileBanner.java @@ -77,7 +77,7 @@ public class TileBanner implements TileData { out.writeShort(id); out.writeByte(baseColor.ordinal()); out.writeByte(patterns.size()); - for (Pattern p : patterns) { + for(Pattern p : patterns) { out.writeByte(p.getColor().ordinal()); out.writeByte(p.getPattern().ordinal()); } @@ -89,7 +89,7 @@ public class TileBanner implements TileData { int listSize = in.readByte(); patterns = new ArrayList<>(); - for (int i = 0; i < listSize; i++) { + for(int i = 0; i < listSize; i++) { DyeColor color = DyeColor.values()[in.readByte()]; PatternType type = PatternType.values()[in.readByte()]; patterns.add(new Pattern(color, type)); @@ -100,7 +100,7 @@ public class TileBanner implements TileData { @Override public void toNBT(CompoundTag tag) { @SuppressWarnings("unchecked") ListTag listTag = (ListTag) ListTag.createUnchecked(CompoundTag.class); - for (Pattern p : patterns) { + for(Pattern p : patterns) { CompoundTag pattern = new CompoundTag(); pattern.putString("Pattern", p.getPattern().getIdentifier()); pattern.putByte("Color", p.getColor().getDyeData()); @@ -110,7 +110,7 @@ public class TileBanner implements TileData { } public boolean isBanner(Material material) { - return switch (material) { + return switch(material) { case RED_BANNER, RED_WALL_BANNER, ORANGE_BANNER, ORANGE_WALL_BANNER, YELLOW_BANNER, YELLOW_WALL_BANNER, LIME_BANNER, LIME_WALL_BANNER, GREEN_BANNER, GREEN_WALL_BANNER, CYAN_BANNER, CYAN_WALL_BANNER, LIGHT_BLUE_BANNER, LIGHT_BLUE_WALL_BANNER, BLUE_BANNER, BLUE_WALL_BANNER, PURPLE_BANNER, PURPLE_WALL_BANNER, MAGENTA_BANNER, MAGENTA_WALL_BANNER, PINK_BANNER, PINK_WALL_BANNER, WHITE_BANNER, WHITE_WALL_BANNER, LIGHT_GRAY_BANNER, LIGHT_GRAY_WALL_BANNER, GRAY_BANNER, GRAY_WALL_BANNER, BLACK_BANNER, BLACK_WALL_BANNER, BROWN_BANNER, BROWN_WALL_BANNER -> true; default -> false; }; diff --git a/src/main/java/com/volmit/iris/engine/object/TileData.java b/src/main/java/com/volmit/iris/engine/object/TileData.java index aa82540a9..1779e58a1 100644 --- a/src/main/java/com/volmit/iris/engine/object/TileData.java +++ b/src/main/java/com/volmit/iris/engine/object/TileData.java @@ -53,21 +53,21 @@ public interface TileData extends Cloneable { } static void setTileState(Block block, TileData data) { - if (data.isApplicable(block.getBlockData())) { + if(data.isApplicable(block.getBlockData())) { data.toBukkitTry(block.getState()); } } static TileData getTileState(Block block) { - for (TileData i : registry) { + for(TileData i : registry) { BlockData data = block.getBlockData(); - if (i.isApplicable(data)) { + if(i.isApplicable(data)) { try { @SuppressWarnings("unchecked") TileData s = i.getClass().getConstructor().newInstance(); s.fromBukkitTry(block.getState()); return s; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -90,7 +90,7 @@ public interface TileData extends Cloneable { //noinspection unchecked toBukkit((T) t); return true; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -103,7 +103,7 @@ public interface TileData extends Cloneable { //noinspection unchecked fromBukkit((T) t); return true; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java b/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java index 968839ef3..8c861e6e8 100644 --- a/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java +++ b/src/main/java/com/volmit/iris/engine/platform/BukkitChunkGenerator.java @@ -97,11 +97,11 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun IrisData data = IrisData.get(dataLocation); IrisDimension dimension = data.getDimensionLoader().load(dimensionKey); - if (dimension == null) { + if(dimension == null) { Iris.error("Oh No! There's no pack in " + data.getDataFolder().getPath() + " or... there's no dimension for the key " + dimensionKey); IrisDimension test = IrisData.loadAnyDimension(dimensionKey); - if (test != null) { + if(test != null) { Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " "); Iris.service(StudioSVC.class).installIntoWorld(Iris.getSender(), dimensionKey, dataLocation.getParentFile().getParentFile()); Iris.warn("Attempted to install into " + data.getDataFolder().getPath()); @@ -109,7 +109,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun data.clearLists(); test = data.getDimensionLoader().load(dimensionKey); - if (test != null) { + if(test != null) { Iris.success("Woo! Patched the Engine!"); dimension = test; } else { @@ -138,20 +138,20 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun loadLock.acquire(); IrisBiomeStorage st = new IrisBiomeStorage(); TerrainChunk tc = TerrainChunk.createUnsafe(world, st); - Hunk blocks = Hunk.view((ChunkData) tc); - Hunk biomes = Hunk.view((BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()); + Hunk blocks = Hunk.view(tc); + Hunk biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()); this.world.bind(world); getEngine().generate(x << 4, z << 4, blocks, biomes, true); Iris.debug("Regenerated " + x + " " + z); int t = 0; - for (int i = getEngine().getHeight() >> 4; i >= 0; i--) { - if (!world.isChunkLoaded(x, z)) { + for(int i = getEngine().getHeight() >> 4; i >= 0; i--) { + if(!world.isChunkLoaded(x, z)) { continue; } Chunk c = world.getChunkAt(x, z); - for (Entity ee : c.getEntities()) { - if (ee instanceof Player) { + for(Entity ee : c.getEntities()) { + if(ee instanceof Player) { continue; } @@ -163,10 +163,10 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun int finalI = i; jobs.accept(() -> { - for (int xx = 0; xx < 16; xx++) { - for (int yy = 0; yy < 16; yy++) { - for (int zz = 0; zz < 16; zz++) { - if (yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0) { + for(int xx = 0; xx < 16; xx++) { + for(int yy = 0; yy < 16; yy++) { + for(int zz = 0; zz < 16; zz++) { + if(yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0) { continue; } @@ -178,7 +178,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun } loadLock.release(); - } catch (Throwable e) { + } catch(Throwable e) { loadLock.release(); Iris.error("======================================"); e.printStackTrace(); @@ -187,8 +187,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun ChunkData d = Bukkit.createChunkData(world); - for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { + for(int i = 0; i < 16; i++) { + for(int j = 0; j < 16; j++) { d.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData()); } } @@ -196,17 +196,17 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun } private Engine getEngine(World world) { - if (setup.get()) { + if(setup.get()) { return getEngine(); } - synchronized (this) { + synchronized(this) { getWorld().setRawWorldSeed(world.getSeed()); setupEngine(); this.hotloader = studio ? new Looper() { @Override protected long loop() { - if (hotloadChecker.flip()) { + if(hotloadChecker.flip()) { folder.check(); } @@ -214,7 +214,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun } } : null; - if (studio) { + if(studio) { hotloader.setPriority(Thread.MIN_PRIORITY); hotloader.start(); hotloader.setName(getTarget().getWorld().name() + " Hotloader"); @@ -229,7 +229,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun @Override public void close() { withExclusiveControl(() -> { - if (isStudio()) { + if(isStudio()) { hotloader.interrupt(); } @@ -247,7 +247,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun @Override public void hotload() { - if (!isStudio()) { + if(!isStudio()) { return; } @@ -260,7 +260,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun loadLock.acquire(LOAD_LOCKS); r.run(); loadLock.release(LOAD_LOCKS); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } }); @@ -280,11 +280,11 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun TerrainChunk tc = TerrainChunk.create(world, biome); this.world.bind(world); - if (studioGenerator != null) { + if(studioGenerator != null) { studioGenerator.generateChunk(getEngine(), tc, x, z); } else { - Hunk blocks = Hunk.view((ChunkData) tc); - Hunk biomes = Hunk.view((BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()); + Hunk blocks = Hunk.view(tc); + Hunk biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()); getEngine().generate(x << 4, z << 4, blocks, biomes, true); } @@ -292,7 +292,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun Iris.debug("Generated " + x + " " + z); loadLock.release(); return c; - } catch (Throwable e) { + } catch(Throwable e) { loadLock.release(); Iris.error("======================================"); e.printStackTrace(); @@ -301,8 +301,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun ChunkData d = Bukkit.createChunkData(world); - for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { + for(int i = 0; i < 16; i++) { + for(int j = 0; j < 16; j++) { d.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData()); } } @@ -312,7 +312,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun } private void computeStudioGenerator() { - if (!getEngine().getDimension().getStudioMode().equals(lastMode)) { + if(!getEngine().getDimension().getStudioMode().equals(lastMode)) { lastMode = getEngine().getDimension().getStudioMode(); getEngine().getDimension().getStudioMode().inject(this); } diff --git a/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java b/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java index e8af96455..b59e903be 100644 --- a/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java +++ b/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java @@ -80,24 +80,24 @@ public class HeadlessGenerator implements PlatformChunkGenerator { int oz = z << 4; com.volmit.iris.util.nbt.mca.Chunk chunk = writer.getChunk(file, x, z); TerrainChunk tc = MCATerrainChunk.builder() - .writer(writer).ox(ox).oz(oz).mcaChunk(chunk) - .minHeight(world.getWorld().minHeight()).maxHeight(world.getWorld().maxHeight()) - .injector((xx, yy, zz, biomeBase) -> chunk.setBiomeAt(ox + xx, yy, oz + zz, - INMS.get().getTrueBiomeBaseId(biomeBase))) - .build(); + .writer(writer).ox(ox).oz(oz).mcaChunk(chunk) + .minHeight(world.getWorld().minHeight()).maxHeight(world.getWorld().maxHeight()) + .injector((xx, yy, zz, biomeBase) -> chunk.setBiomeAt(ox + xx, yy, oz + zz, + INMS.get().getTrueBiomeBaseId(biomeBase))) + .build(); getEngine().generate(x << 4, z << 4, - Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()), - false); + Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()), + false); chunk.cleanupPalettesAndBlockStates(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("======================================"); e.printStackTrace(); Iris.reportErrorChunk(x, z, e, "MCA"); Iris.error("======================================"); com.volmit.iris.util.nbt.mca.Chunk chunk = writer.getChunk(x, z); CompoundTag c = NBTWorld.getCompound(ERROR_BLOCK); - for (int i = 0; i < 16; i++) { - for (int j = 0; j < 16; j++) { + for(int i = 0; i < 16; i++) { + for(int j = 0; j < 16; j++) { chunk.setBlockStateAt(i, 0, j, c, false); } } @@ -119,11 +119,11 @@ public class HeadlessGenerator implements PlatformChunkGenerator { BurstExecutor e = burst.burst(1024); MCAFile f = writer.getMCA(x, z); PregenTask.iterateRegion(x, z, (ii, jj) -> e.queue(() -> { - if (listener != null) { + if(listener != null) { listener.onChunkGenerating(ii, jj); } generateChunk(f, ii, jj); - if (listener != null) { + if(listener != null) { listener.onChunkGenerated(ii, jj); } }), avgLast(x, z)); @@ -132,14 +132,14 @@ public class HeadlessGenerator implements PlatformChunkGenerator { } private Position2 avgLast(int x, int z) { - while (last.size() > 3) { + while(last.size() > 3) { last.remove(0); } double xx = 0; double zz = 0; - for (Position2 i : last) { + for(Position2 i : last) { xx += 27 * (i.getX() - x); zz += 27 * (i.getZ() - z); } @@ -179,7 +179,7 @@ public class HeadlessGenerator implements PlatformChunkGenerator { public KList getChunksInRegion(int x, int z) { try { return MCAUtil.sampleChunkPositions(writer.getRegionFile(x, z)); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/platform/studio/generators/BiomeBuffetGenerator.java b/src/main/java/com/volmit/iris/engine/platform/studio/generators/BiomeBuffetGenerator.java index 8efe14c20..5c29878ef 100644 --- a/src/main/java/com/volmit/iris/engine/platform/studio/generators/BiomeBuffetGenerator.java +++ b/src/main/java/com/volmit/iris/engine/platform/studio/generators/BiomeBuffetGenerator.java @@ -46,11 +46,11 @@ public class BiomeBuffetGenerator extends EnginedStudioGenerator { public void generateChunk(Engine engine, TerrainChunk tc, int x, int z) throws WrongEngineBroException { int id = Cache.to1D(x / biomeSize, 0, z / biomeSize, width, 1); - if (id >= 0 && id < biomes.length) { + if(id >= 0 && id < biomes.length) { IrisBiome biome = biomes[id]; String foc = engine.getDimension().getFocus(); - if (!Objects.equals(foc, biome.getLoadKey())) { + if(!Objects.equals(foc, biome.getLoadKey())) { engine.getDimension().setFocus(biome.getLoadKey()); engine.hotloadComplex(); } diff --git a/src/main/java/com/volmit/iris/util/atomics/AtomicAverage.java b/src/main/java/com/volmit/iris/util/atomics/AtomicAverage.java index d3198af6d..ae01bf277 100644 --- a/src/main/java/com/volmit/iris/util/atomics/AtomicAverage.java +++ b/src/main/java/com/volmit/iris/util/atomics/AtomicAverage.java @@ -40,7 +40,8 @@ public class AtomicAverage { /** * Create an average holder * - * @param size the size of entries to keep + * @param size + * the size of entries to keep */ public AtomicAverage(int size) { values = new AtomicDoubleArray(size); @@ -55,14 +56,15 @@ public class AtomicAverage { /** * Put a value into the average (rolls over if full) * - * @param i the value + * @param i + * the value */ public void put(double i) { try { dirty = true; - if (brandNew) { + if(brandNew) { DoubleArrayUtils.fill(values, i); lastSum = size() * i; brandNew = false; @@ -73,7 +75,7 @@ public class AtomicAverage { lastSum = (lastSum - current) + i; values.set(cursor, i); cursor = cursor + 1 < size() ? cursor + 1 : 0; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -85,7 +87,7 @@ public class AtomicAverage { * @return the average */ public double getAverage() { - if (dirty) { + if(dirty) { calculateAverage(); return getAverage(); } diff --git a/src/main/java/com/volmit/iris/util/atomics/AtomicRollingSequence.java b/src/main/java/com/volmit/iris/util/atomics/AtomicRollingSequence.java index 671eb7345..82e842e23 100644 --- a/src/main/java/com/volmit/iris/util/atomics/AtomicRollingSequence.java +++ b/src/main/java/com/volmit/iris/util/atomics/AtomicRollingSequence.java @@ -40,7 +40,7 @@ public class AtomicRollingSequence extends AtomicAverage { public double addLast(int amt) { double f = 0; - for (int i = 0; i < Math.min(values.length(), amt); i++) { + for(int i = 0; i < Math.min(values.length(), amt); i++) { f += values.get(i); } @@ -56,7 +56,7 @@ public class AtomicRollingSequence extends AtomicAverage { } public double getMin() { - if (dirtyExtremes > (isPrecision() ? 0 : values.length())) { + if(dirtyExtremes > (isPrecision() ? 0 : values.length())) { resetExtremes(); } @@ -64,7 +64,7 @@ public class AtomicRollingSequence extends AtomicAverage { } public double getMax() { - if (dirtyExtremes > (isPrecision() ? 0 : values.length())) { + if(dirtyExtremes > (isPrecision() ? 0 : values.length())) { resetExtremes(); } @@ -72,7 +72,7 @@ public class AtomicRollingSequence extends AtomicAverage { } public double getMedian() { - if (dirtyMedian) { + if(dirtyMedian) { recalculateMedian(); } @@ -88,7 +88,7 @@ public class AtomicRollingSequence extends AtomicAverage { max = Integer.MIN_VALUE; min = Integer.MAX_VALUE; - for (int i = 0; i < values.length(); i++) { + for(int i = 0; i < values.length(); i++) { double v = values.get(i); max = M.max(max, v); min = M.min(min, v); diff --git a/src/main/java/com/volmit/iris/util/board/Board.java b/src/main/java/com/volmit/iris/util/board/Board.java index 52fb11e3b..bd5bf471b 100644 --- a/src/main/java/com/volmit/iris/util/board/Board.java +++ b/src/main/java/com/volmit/iris/util/board/Board.java @@ -79,47 +79,47 @@ public class Board { public void update() { // Checking if we are ready to start updating the Scoreboard. - if (!ready) { + if(!ready) { return; } // Making sure the player is connected. - if (!player.isOnline()) { + if(!player.isOnline()) { remove(); return; } // Making sure the Scoreboard Provider is set. - if (boardSettings == null) { + if(boardSettings == null) { return; } // Getting their Scoreboard display from the Scoreboard Provider. final List entries = boardSettings.getBoardProvider().getLines(player).stream().map(APPLY_COLOR_TRANSLATION).collect(Collectors.toList()); - if (boardSettings.getScoreDirection() == ScoreDirection.UP) { + if(boardSettings.getScoreDirection() == ScoreDirection.UP) { Collections.reverse(entries); } // Setting the Scoreboard title String title = boardSettings.getBoardProvider().getTitle(player); - if (title.length() > 32) { + if(title.length() > 32) { Bukkit.getLogger().warning("The title " + title + " is over 32 characters in length, substringing to prevent errors."); title = title.substring(0, 32); } objective.setDisplayName(C.translateAlternateColorCodes('&', title)); // Clearing previous Scoreboard values if entry sizes don't match. - if (this.getScoreboard().getEntries().size() != entries.size()) + if(this.getScoreboard().getEntries().size() != entries.size()) this.getScoreboard().getEntries().forEach(this::removeEntry); // Setting Scoreboard lines. - for (int i = 0; i < entries.size(); i++) { + for(int i = 0; i < entries.size(); i++) { String str = entries.get(i); BoardEntry entry = BoardEntry.translateToEntry(str); Team team = getScoreboard().getTeam(CACHED_ENTRIES[i]); - if (team == null) { + if(team == null) { team = this.getScoreboard().registerNewTeam(CACHED_ENTRIES[i]); team.addEntry(team.getName()); } @@ -127,7 +127,7 @@ public class Board { team.setPrefix(entry.getPrefix()); team.setSuffix(entry.getSuffix()); - switch (boardSettings.getScoreDirection()) { + switch(boardSettings.getScoreDirection()) { case UP -> objective.getScore(team.getName()).setScore(1 + i); case DOWN -> objective.getScore(team.getName()).setScore(15 - i); } diff --git a/src/main/java/com/volmit/iris/util/board/BoardEntry.java b/src/main/java/com/volmit/iris/util/board/BoardEntry.java index d066eaf0b..7638899d7 100644 --- a/src/main/java/com/volmit/iris/util/board/BoardEntry.java +++ b/src/main/java/com/volmit/iris/util/board/BoardEntry.java @@ -38,16 +38,16 @@ public class BoardEntry { } public static BoardEntry translateToEntry(String input) { - if (input.isEmpty()) { + if(input.isEmpty()) { return new BoardEntry("", ""); } - if (input.length() <= 16) { + if(input.length() <= 16) { return new BoardEntry(input, ""); } else { String prefix = input.substring(0, 16); String suffix = ""; - if (prefix.endsWith("\u00a7")) { + if(prefix.endsWith("\u00a7")) { prefix = prefix.substring(0, prefix.length() - 1); suffix = "\u00a7" + suffix; } diff --git a/src/main/java/com/volmit/iris/util/board/BoardManager.java b/src/main/java/com/volmit/iris/util/board/BoardManager.java index a5356f0bf..f0ff567a0 100644 --- a/src/main/java/com/volmit/iris/util/board/BoardManager.java +++ b/src/main/java/com/volmit/iris/util/board/BoardManager.java @@ -65,7 +65,7 @@ public class BoardManager { public void setup(Player player) { Optional.ofNullable(scoreboards.remove(player.getUniqueId())).ifPresent(Board::resetScoreboard); - if (player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) { + if(player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } scoreboards.put(player.getUniqueId(), new Board(player, boardSettings)); diff --git a/src/main/java/com/volmit/iris/util/collection/GBiset.java b/src/main/java/com/volmit/iris/util/collection/GBiset.java index f2c606042..9bf2a92fc 100644 --- a/src/main/java/com/volmit/iris/util/collection/GBiset.java +++ b/src/main/java/com/volmit/iris/util/collection/GBiset.java @@ -24,8 +24,10 @@ import java.io.Serializable; /** * A Biset * - * @param the first object type - * @param the second object type + * @param + * the first object type + * @param + * the second object type * @author cyberpwn */ @SuppressWarnings("hiding") @@ -37,8 +39,10 @@ public class GBiset implements Serializable { /** * Create a new Biset * - * @param a the first object - * @param b the second object + * @param a + * the first object + * @param b + * the second object */ public GBiset(A a, B b) { this.a = a; @@ -57,7 +61,8 @@ public class GBiset implements Serializable { /** * Set the first object * - * @param a the first object A + * @param a + * the first object A */ public void setA(A a) { this.a = a; diff --git a/src/main/java/com/volmit/iris/util/collection/GListAdapter.java b/src/main/java/com/volmit/iris/util/collection/GListAdapter.java index db83e725c..6d2eb84d5 100644 --- a/src/main/java/com/volmit/iris/util/collection/GListAdapter.java +++ b/src/main/java/com/volmit/iris/util/collection/GListAdapter.java @@ -24,24 +24,27 @@ import java.util.List; /** * Adapts a list of objects into a list of other objects * - * @param the from object in lists (the item INSIDE the list) - * @param the to object in lists (the item INSIDE the list) + * @param + * the from object in lists (the item INSIDE the list) + * @param + * the to object in lists (the item INSIDE the list) * @author cyberpwn */ public abstract class GListAdapter { /** * Adapts a list of FROM to a list of TO * - * @param from the from list + * @param from + * the from list * @return the to list */ public List adapt(List from) { List adapted = new KList<>(); - for (FROM i : from) { + for(FROM i : from) { TO t = onAdapt(i); - if (t != null) { + if(t != null) { adapted.add(onAdapt(i)); } } @@ -52,7 +55,8 @@ public abstract class GListAdapter { /** * Adapts a list object FROM to TO for use with the adapt method * - * @param from the from object + * @param from + * the from object * @return the to object */ public abstract TO onAdapt(FROM from); diff --git a/src/main/java/com/volmit/iris/util/collection/KList.java b/src/main/java/com/volmit/iris/util/collection/KList.java index cd3c8fb62..c2c6891e5 100644 --- a/src/main/java/com/volmit/iris/util/collection/KList.java +++ b/src/main/java/com/volmit/iris/util/collection/KList.java @@ -64,7 +64,7 @@ public class KList extends ArrayList implements List { public static KList fromJSONAny(JSONArray oo) { KList s = new KList(); - for (int i = 0; i < oo.length(); i++) { + for(int i = 0; i < oo.length(); i++) { s.add(oo.get(i).toString()); } @@ -74,7 +74,7 @@ public class KList extends ArrayList implements List { public static KList asStringList(List oo) { KList s = new KList(); - for (Object i : oo) { + for(Object i : oo) { s.add(i.toString()); } @@ -96,13 +96,13 @@ public class KList extends ArrayList implements List { } public void addMultiple(T t, int c) { - for (int i = 0; i < c; i++) { + for(int i = 0; i < c; i++) { add(t); } } private KList add(Enumeration e) { - while (e.hasMoreElements()) { + while(e.hasMoreElements()) { add(e.nextElement()); } @@ -119,8 +119,10 @@ public class KList extends ArrayList implements List { * returned map. You must specify each key for each value in this list. In the * function, returning null will not add the keyval pair. * - * @param the inferred key type - * @param f the function + * @param + * the inferred key type + * @param f + * the function * @return the new map */ public KMap asValues(Function f) { @@ -134,8 +136,10 @@ public class KList extends ArrayList implements List { * returned map. You must specify each value for each key in this list. In the * function, returning null will not add the keyval pair. * - * @param the inferred value type - * @param f the function + * @param + * the inferred value type + * @param f + * the function * @return the new map */ public KMap asKeys(Function f) { @@ -147,7 +151,8 @@ public class KList extends ArrayList implements List { /** * Cut this list into targetCount sublists * - * @param targetCount the target count of sublists + * @param targetCount + * the target count of sublists * @return the list of sublists */ public KList> divide(int targetCount) { @@ -158,7 +163,8 @@ public class KList extends ArrayList implements List { * Split this list into a list of sublists with roughly targetSize elements of T * per sublist * - * @param targetSize the target size + * @param targetSize + * the target size * @return the list of sublists */ public KList> split(int targetSize) { @@ -166,8 +172,8 @@ public class KList extends ArrayList implements List { KList> gg = new KList<>(); KList b = new KList<>(); - for (T i : this) { - if (b.size() >= targetSize) { + for(T i : this) { + if(b.size() >= targetSize) { gg.add(b.copy()); b.clear(); } @@ -175,7 +181,7 @@ public class KList extends ArrayList implements List { b.add(i); } - if (!b.isEmpty()) { + if(!b.isEmpty()) { gg.add(b); } @@ -186,14 +192,15 @@ public class KList extends ArrayList implements List { * Rewrite this list by checking each value and changing the value (or not). * Return null to remove the element in the function * - * @param t the function + * @param t + * the function * @return the same list (not a copy) */ public KList rewrite(Function t) { KList m = copy(); clear(); - for (T i : m) { + for(T i : m) { addNonNull(t.apply(i)); } @@ -262,21 +269,22 @@ public class KList extends ArrayList implements List { /** * Tostring with a seperator for each item in the list * - * @param split the seperator + * @param split + * the seperator * @return the string representing this object */ public String toString(String split) { - if (isEmpty()) { + if(isEmpty()) { return ""; } - if (size() == 1) { + if(size() == 1) { return get(0) + ""; } StringBuilder b = new StringBuilder(); - for (String i : toStringList()) { + for(String i : toStringList()) { b.append(split).append(i == null ? "null" : i); } @@ -295,9 +303,12 @@ public class KList extends ArrayList implements List { /** * Add the contents of the given list (v) into this list using a converter * - * @param the type of the forign list - * @param v the forign (given) list - * @param converter the converter that converts the forign type into this list type + * @param + * the type of the forign list + * @param v + * the forign (given) list + * @param converter + * the converter that converts the forign type into this list type * @return this list (builder) */ public KList addFrom(List v, Function converter) { @@ -308,10 +319,6 @@ public class KList extends ArrayList implements List { /** * Convert this list into another list type. Such as GList to * GList. list.convert((i) -> "" + i); - * - * @param - * @param converter - * @return */ public KList convert(Function converter) { KList v = new KList(); @@ -320,8 +327,8 @@ public class KList extends ArrayList implements List { } public KList removeWhere(Predicate t) { - for (T i : copy()) { - if (t.test(i)) { + for(T i : copy()) { + if(t.test(i)) { remove(i); } } @@ -332,11 +339,12 @@ public class KList extends ArrayList implements List { /** * Adds T to the list, ignores if null * - * @param t the value to add + * @param t + * the value to add * @return the same list */ public KList addNonNull(T t) { - if (t != null) { + if(t != null) { super.add(t); } @@ -347,8 +355,10 @@ public class KList extends ArrayList implements List { * Swaps the values of index a and b. For example "hello", "world", "!" swap(1, * 2) would change the list to "hello", "!", "world" * - * @param a the first index - * @param b the second index + * @param a + * the first index + * @param b + * the second index * @return the same list (builder), not a copy */ public KList swapIndexes(int a, int b) { @@ -364,12 +374,13 @@ public class KList extends ArrayList implements List { /** * Remove a number of elements from the list * - * @param t the elements + * @param t + * the elements * @return this list */ @SuppressWarnings("unchecked") public KList remove(T... t) { - for (T i : t) { + for(T i : t) { super.remove(i); } @@ -379,7 +390,8 @@ public class KList extends ArrayList implements List { /** * Add another glist's contents to this one (addall builder) * - * @param t the list + * @param t + * the list * @return the same list */ public KList add(KList t) { @@ -390,12 +402,13 @@ public class KList extends ArrayList implements List { /** * Add a number of values to this list * - * @param t the list + * @param t + * the list * @return this list */ @SuppressWarnings("unchecked") public KList add(T... t) { - for (T i : t) { + for(T i : t) { super.add(i); } @@ -405,7 +418,8 @@ public class KList extends ArrayList implements List { /** * Check if this list has an index at the given index * - * @param index the given index + * @param index + * the given index * @return true if size > index */ public boolean hasIndex(int index) { @@ -465,7 +479,7 @@ public class KList extends ArrayList implements List { * @return the popped off item or null if the list is empty */ public T pop() { - if (isEmpty()) { + if(isEmpty()) { return null; } @@ -478,7 +492,7 @@ public class KList extends ArrayList implements List { * @return the popped off item or null if the list is empty */ public T popLast() { - if (isEmpty()) { + if(isEmpty()) { return null; } @@ -486,11 +500,11 @@ public class KList extends ArrayList implements List { } public T popRandom() { - if (isEmpty()) { + if(isEmpty()) { return null; } - if (size() == 1) { + if(size() == 1) { return pop(); } @@ -498,11 +512,11 @@ public class KList extends ArrayList implements List { } public T popRandom(RNG rng) { - if (isEmpty()) { + if(isEmpty()) { return null; } - if (size() == 1) { + if(size() == 1) { return pop(); } @@ -512,7 +526,7 @@ public class KList extends ArrayList implements List { public KList sub(int f, int t) { KList g = new KList<>(); - for (int i = f; i < M.min(size(), t); i++) { + for(int i = f; i < M.min(size(), t); i++) { g.add(get(i)); } @@ -522,7 +536,7 @@ public class KList extends ArrayList implements List { public JSONArray toJSONStringArray() { JSONArray j = new JSONArray(); - for (Object i : this) { + for(Object i : this) { j.put(i.toString()); } @@ -531,7 +545,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(Object[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -540,7 +554,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(int[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -549,7 +563,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(double[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -558,7 +572,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(AtomicDoubleArray values) { - for (int i = 0; i < values.length(); i++) { + for(int i = 0; i < values.length(); i++) { add((T) ((Object) values.get(i))); } @@ -567,7 +581,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(float[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -576,7 +590,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(byte[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -585,7 +599,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(short[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -594,7 +608,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(long[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -603,7 +617,7 @@ public class KList extends ArrayList implements List { @SuppressWarnings("unchecked") public KList forceAdd(boolean[] values) { - for (Object i : values) { + for(Object i : values) { add((T) i); } @@ -619,11 +633,11 @@ public class KList extends ArrayList implements List { } public T getRandom() { - if (isEmpty()) { + if(isEmpty()) { return null; } - if (size() == 1) { + if(size() == 1) { return get(0); } @@ -633,8 +647,8 @@ public class KList extends ArrayList implements List { public KList popRandom(RNG rng, int c) { KList m = new KList<>(); - for (int i = 0; i < c; i++) { - if (isEmpty()) { + for(int i = 0; i < c; i++) { + if(isEmpty()) { break; } @@ -645,11 +659,11 @@ public class KList extends ArrayList implements List { } public T getRandom(RNG rng) { - if (isEmpty()) { + if(isEmpty()) { return null; } - if (size() == 1) { + if(size() == 1) { return get(0); } @@ -680,7 +694,7 @@ public class KList extends ArrayList implements List { } public boolean addIfMissing(T t) { - if (!contains(t)) { + if(!contains(t)) { add(t); return true; } @@ -689,8 +703,8 @@ public class KList extends ArrayList implements List { } public void addAllIfMissing(KList t) { - for (T i : t) { - if (!contains(i)) { + for(T i : t) { + if(!contains(i)) { add(i); } } diff --git a/src/main/java/com/volmit/iris/util/collection/KMap.java b/src/main/java/com/volmit/iris/util/collection/KMap.java index 8ca4c9388..1a1106907 100644 --- a/src/main/java/com/volmit/iris/util/collection/KMap.java +++ b/src/main/java/com/volmit/iris/util/collection/KMap.java @@ -43,8 +43,8 @@ public class KMap extends ConcurrentHashMap { } public K getKey(V value) { - for (KeyPair i : keypair()) { - if (i.getV().equals(value)) { + for(KeyPair i : keypair()) { + if(i.getV().equals(value)) { return i.getK(); } } @@ -56,9 +56,12 @@ public class KMap extends ConcurrentHashMap { * Puts a value into a map-value-list based on the key such that if GMap> where V is GList * - * @param the list type in the value type - * @param k the key to look for - * @param vs the values to put into the list of the given key + * @param + * the list type in the value type + * @param k + * the key to look for + * @param vs + * the values to put into the list of the given key * @return the same list (builder) */ @SuppressWarnings("unchecked") @@ -66,12 +69,12 @@ public class KMap extends ConcurrentHashMap { try { KMap> s = (KMap>) this; - if (!s.containsKey(k)) { + if(!s.containsKey(k)) { s.put(k, new KList()); } s.get(k).add(vs); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -96,9 +99,9 @@ public class KMap extends ConcurrentHashMap { } }); - for (V i : v) { - for (K j : k()) { - if (get(j).equals(i)) { + for(V i : v) { + for(K j : k()) { + if(get(j).equals(i)) { k.add(j); } } @@ -128,9 +131,9 @@ public class KMap extends ConcurrentHashMap { } }); - for (V i : v) { - for (K j : k()) { - if (get(j).equals(i)) { + for(V i : v) { + for(K j : k()) { + if(get(j).equals(i)) { k.add(j); } } @@ -143,7 +146,8 @@ public class KMap extends ConcurrentHashMap { /** * Put another map's values into this map * - * @param m the map to insert + * @param m + * the map to insert * @return this map (builder) */ public KMap put(Map m) { @@ -163,13 +167,14 @@ public class KMap extends ConcurrentHashMap { /** * Loop through each keyvalue set (copy of it) with the map parameter * - * @param f the function + * @param f + * the function * @return the same gmap */ public KMap rewrite(Consumer3> f) { KMap m = copy(); - for (K i : m.k()) { + for(K i : m.k()) { f.accept(i, get(i), this); } @@ -179,11 +184,12 @@ public class KMap extends ConcurrentHashMap { /** * Loop through each keyvalue set (copy of it) * - * @param f the function + * @param f + * the function * @return the same gmap */ public KMap each(Consumer2 f) { - for (K i : k()) { + for(K i : k()) { f.accept(i, get(i)); } @@ -199,7 +205,7 @@ public class KMap extends ConcurrentHashMap { KMap> f = flip(); KMap m = new KMap<>(); - for (V i : f.k()) { + for(V i : f.k()) { m.putNonNull(i, m.isEmpty() ? null : m.get(0)); } @@ -214,12 +220,12 @@ public class KMap extends ConcurrentHashMap { public KMap> flip() { KMap> flipped = new KMap>(); - for (K i : keySet()) { - if (i == null) { + for(K i : keySet()) { + if(i == null) { continue; } - if (!flipped.containsKey(get(i))) { + if(!flipped.containsKey(get(i))) { flipped.put(get(i), new KList()); } @@ -245,9 +251,9 @@ public class KMap extends ConcurrentHashMap { } }); - for (K i : k) { - for (V j : v()) { - if (get(i).equals(j)) { + for(K i : k) { + for(V j : v()) { + if(get(i).equals(j)) { v.add(j); } } @@ -268,9 +274,9 @@ public class KMap extends ConcurrentHashMap { } }); - for (K i : k) { - for (V j : v()) { - if (get(i).equals(j)) { + for(K i : k) { + for(V j : v()) { + if(get(i).equals(j)) { v.add(j); } } @@ -288,7 +294,7 @@ public class KMap extends ConcurrentHashMap { KList k = new KList(); Enumeration kk = keys(); - while (kk.hasMoreElements()) { + while(kk.hasMoreElements()) { K kkk = kk.nextElement(); k.add(kkk); } @@ -308,9 +314,10 @@ public class KMap extends ConcurrentHashMap { /** * Still works as it normally should except it returns itself (builder) * - * @param key the key - * @param value the value (single only supported) - * @return + * @param key + * the key + * @param value + * the value (single only supported) */ public KMap qput(K key, V value) { super.put(key, value); @@ -321,12 +328,14 @@ public class KMap extends ConcurrentHashMap { * Works just like put, except it wont put anything unless the key and value are * nonnull * - * @param key the nonnull key - * @param value the nonnull value + * @param key + * the nonnull key + * @param value + * the nonnull value * @return the same map */ public KMap putNonNull(K key, V value) { - if (key != null || value != null) { + if(key != null || value != null) { put(key, value); } @@ -334,7 +343,7 @@ public class KMap extends ConcurrentHashMap { } public V putThen(K key, V valueIfKeyNotPresent) { - if (!containsKey(key)) { + if(!containsKey(key)) { put(key, valueIfKeyNotPresent); } diff --git a/src/main/java/com/volmit/iris/util/collection/KeyPair.java b/src/main/java/com/volmit/iris/util/collection/KeyPair.java index a7113652f..7f1f45bc1 100644 --- a/src/main/java/com/volmit/iris/util/collection/KeyPair.java +++ b/src/main/java/com/volmit/iris/util/collection/KeyPair.java @@ -21,8 +21,10 @@ package com.volmit.iris.util.collection; /** * Represents a keypair * - * @param the key type - * @param the value type + * @param + * the key type + * @param + * the value type * @author cyberpwn */ @SuppressWarnings("hiding") @@ -33,8 +35,10 @@ public class KeyPair { /** * Create a keypair * - * @param k the key - * @param v the value + * @param k + * the key + * @param v + * the value */ public KeyPair(K k, V v) { this.k = k; diff --git a/src/main/java/com/volmit/iris/util/collection/StateList.java b/src/main/java/com/volmit/iris/util/collection/StateList.java index dccace950..2a38a93ba 100644 --- a/src/main/java/com/volmit/iris/util/collection/StateList.java +++ b/src/main/java/com/volmit/iris/util/collection/StateList.java @@ -24,7 +24,7 @@ public class StateList { public StateList(String... states) { this.states = new KList(states); - if (getBits() > 64) { + if(getBits() > 64) { throw new RuntimeException("StateLists cannot exceed 64 bits! You are trying to use " + getBits() + " bits!"); } } @@ -32,7 +32,7 @@ public class StateList { public StateList(Enum... states) { this.states = new KList>().convert(Enum::name); - if (getBits() > 64) { + if(getBits() > 64) { throw new RuntimeException("StateLists cannot exceed 64 bits! You are trying to use " + getBits() + " bits!"); } } @@ -44,8 +44,8 @@ public class StateList { public KList getEnabled(long list) { KList f = new KList<>(); - for (String i : states) { - if (is(list, i)) { + for(String i : states) { + if(is(list, i)) { f.add(i); } } @@ -56,7 +56,7 @@ public class StateList { public long of(String... enabledStates) { long b = 0; - for (String i : enabledStates) { + for(String i : enabledStates) { b |= getBit(i); } @@ -67,9 +67,9 @@ public class StateList { long bit = getBit(state); boolean is = is(list, state); - if (enabled && !is) { + if(enabled && !is) { return list | bit; - } else if (!enabled && is) { + } else if(!enabled && is) { return list ^ bit; } diff --git a/src/main/java/com/volmit/iris/util/context/IrisContext.java b/src/main/java/com/volmit/iris/util/context/IrisContext.java index 06b072715..6621ec381 100644 --- a/src/main/java/com/volmit/iris/util/context/IrisContext.java +++ b/src/main/java/com/volmit/iris/util/context/IrisContext.java @@ -39,20 +39,20 @@ public class IrisContext { } public static void touch(IrisContext c) { - synchronized (context) { + synchronized(context) { context.put(Thread.currentThread(), c); - if (cl.flip()) { + if(cl.flip()) { dereference(); } } } public static void dereference() { - synchronized (context) { - for (Thread i : context.k()) { - if (!i.isAlive() || context.get(i).engine.isClosed()) { - if (context.get(i).engine.isClosed()) { + synchronized(context) { + for(Thread i : context.k()) { + if(!i.isAlive() || context.get(i).engine.isClosed()) { + if(context.get(i).engine.isClosed()) { Iris.debug("Dereferenced Context " + i.getName() + " " + i.getId()); } diff --git a/src/main/java/com/volmit/iris/util/data/B.java b/src/main/java/com/volmit/iris/util/data/B.java index 612bf9df2..698c91bda 100644 --- a/src/main/java/com/volmit/iris/util/data/B.java +++ b/src/main/java/com/volmit/iris/util/data/B.java @@ -38,7 +38,6 @@ import org.bukkit.block.data.type.PointedDripstone; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.locks.ReentrantLock; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -59,34 +58,34 @@ public class B { private static IntSet buildFoliageCache() { IntSet b = new IntOpenHashSet(); - Arrays.stream(new Material[]{ - POPPY, - DANDELION, - CORNFLOWER, - SWEET_BERRY_BUSH, - CRIMSON_ROOTS, - WARPED_ROOTS, - NETHER_SPROUTS, - ALLIUM, - AZURE_BLUET, - BLUE_ORCHID, - OXEYE_DAISY, - LILY_OF_THE_VALLEY, - WITHER_ROSE, - DARK_OAK_SAPLING, - ACACIA_SAPLING, - JUNGLE_SAPLING, - BIRCH_SAPLING, - SPRUCE_SAPLING, - OAK_SAPLING, - ORANGE_TULIP, - PINK_TULIP, - RED_TULIP, - WHITE_TULIP, - FERN, - LARGE_FERN, - GRASS, - TALL_GRASS + Arrays.stream(new Material[] { + POPPY, + DANDELION, + CORNFLOWER, + SWEET_BERRY_BUSH, + CRIMSON_ROOTS, + WARPED_ROOTS, + NETHER_SPROUTS, + ALLIUM, + AZURE_BLUET, + BLUE_ORCHID, + OXEYE_DAISY, + LILY_OF_THE_VALLEY, + WITHER_ROSE, + DARK_OAK_SAPLING, + ACACIA_SAPLING, + JUNGLE_SAPLING, + BIRCH_SAPLING, + SPRUCE_SAPLING, + OAK_SAPLING, + ORANGE_TULIP, + PINK_TULIP, + RED_TULIP, + WHITE_TULIP, + FERN, + LARGE_FERN, + GRASS, + TALL_GRASS }).forEach((i) -> b.add(i.ordinal())); return IntSets.unmodifiable(b); @@ -94,17 +93,17 @@ public class B { private static IntSet buildDeepslateCache() { IntSet b = new IntOpenHashSet(); - Arrays.stream(new Material[]{ - DEEPSLATE, - DEEPSLATE_BRICKS, - DEEPSLATE_BRICK_SLAB, - DEEPSLATE_BRICK_STAIRS, - DEEPSLATE_BRICK_WALL, - DEEPSLATE_TILE_SLAB, - DEEPSLATE_TILES, - DEEPSLATE_TILE_STAIRS, - DEEPSLATE_TILE_WALL, - CRACKED_DEEPSLATE_TILES + Arrays.stream(new Material[] { + DEEPSLATE, + DEEPSLATE_BRICKS, + DEEPSLATE_BRICK_SLAB, + DEEPSLATE_BRICK_STAIRS, + DEEPSLATE_BRICK_WALL, + DEEPSLATE_TILE_SLAB, + DEEPSLATE_TILES, + DEEPSLATE_TILE_STAIRS, + DEEPSLATE_TILE_WALL, + CRACKED_DEEPSLATE_TILES }).forEach((i) -> b.add(i.ordinal())); return IntSets.unmodifiable(b); @@ -142,61 +141,61 @@ public class B { private static IntSet buildDecorantCache() { IntSet b = new IntOpenHashSet(); - Arrays.stream(new Material[]{ - GRASS, - TALL_GRASS, - FERN, - LARGE_FERN, - CORNFLOWER, - SUNFLOWER, - CHORUS_FLOWER, - POPPY, - DANDELION, - OXEYE_DAISY, - ORANGE_TULIP, - PINK_TULIP, - RED_TULIP, - WHITE_TULIP, - LILAC, - DEAD_BUSH, - SWEET_BERRY_BUSH, - ROSE_BUSH, - WITHER_ROSE, - ALLIUM, - BLUE_ORCHID, - LILY_OF_THE_VALLEY, - CRIMSON_FUNGUS, - WARPED_FUNGUS, - RED_MUSHROOM, - BROWN_MUSHROOM, - CRIMSON_ROOTS, - AZURE_BLUET, - WEEPING_VINES, - WEEPING_VINES_PLANT, - WARPED_ROOTS, - NETHER_SPROUTS, - TWISTING_VINES, - TWISTING_VINES_PLANT, - SUGAR_CANE, - WHEAT, - POTATOES, - CARROTS, - BEETROOTS, - NETHER_WART, - SEA_PICKLE, - SEAGRASS, - ACACIA_BUTTON, - BIRCH_BUTTON, - CRIMSON_BUTTON, - DARK_OAK_BUTTON, - JUNGLE_BUTTON, - OAK_BUTTON, - POLISHED_BLACKSTONE_BUTTON, - SPRUCE_BUTTON, - STONE_BUTTON, - WARPED_BUTTON, - TORCH, - SOUL_TORCH + Arrays.stream(new Material[] { + GRASS, + TALL_GRASS, + FERN, + LARGE_FERN, + CORNFLOWER, + SUNFLOWER, + CHORUS_FLOWER, + POPPY, + DANDELION, + OXEYE_DAISY, + ORANGE_TULIP, + PINK_TULIP, + RED_TULIP, + WHITE_TULIP, + LILAC, + DEAD_BUSH, + SWEET_BERRY_BUSH, + ROSE_BUSH, + WITHER_ROSE, + ALLIUM, + BLUE_ORCHID, + LILY_OF_THE_VALLEY, + CRIMSON_FUNGUS, + WARPED_FUNGUS, + RED_MUSHROOM, + BROWN_MUSHROOM, + CRIMSON_ROOTS, + AZURE_BLUET, + WEEPING_VINES, + WEEPING_VINES_PLANT, + WARPED_ROOTS, + NETHER_SPROUTS, + TWISTING_VINES, + TWISTING_VINES_PLANT, + SUGAR_CANE, + WHEAT, + POTATOES, + CARROTS, + BEETROOTS, + NETHER_WART, + SEA_PICKLE, + SEAGRASS, + ACACIA_BUTTON, + BIRCH_BUTTON, + CRIMSON_BUTTON, + DARK_OAK_BUTTON, + JUNGLE_BUTTON, + OAK_BUTTON, + POLISHED_BLACKSTONE_BUTTON, + SPRUCE_BUTTON, + STONE_BUTTON, + WARPED_BUTTON, + TORCH, + SOUL_TORCH }).forEach((i) -> b.add(i.ordinal())); b.addAll(foliageCache); @@ -205,34 +204,34 @@ public class B { private static IntSet buildLitCache() { IntSet b = new IntOpenHashSet(); - Arrays.stream(new Material[]{ - GLOWSTONE, - AMETHYST_CLUSTER, - SMALL_AMETHYST_BUD, - MEDIUM_AMETHYST_BUD, - LARGE_AMETHYST_BUD, - END_ROD, - SOUL_SAND, - TORCH, - REDSTONE_TORCH, - SOUL_TORCH, - REDSTONE_WALL_TORCH, - WALL_TORCH, - SOUL_WALL_TORCH, - LANTERN, - CANDLE, - JACK_O_LANTERN, - REDSTONE_LAMP, - MAGMA_BLOCK, - LIGHT, - SHROOMLIGHT, - SEA_LANTERN, - SOUL_LANTERN, - FIRE, - SOUL_FIRE, - SEA_PICKLE, - BREWING_STAND, - REDSTONE_ORE, + Arrays.stream(new Material[] { + GLOWSTONE, + AMETHYST_CLUSTER, + SMALL_AMETHYST_BUD, + MEDIUM_AMETHYST_BUD, + LARGE_AMETHYST_BUD, + END_ROD, + SOUL_SAND, + TORCH, + REDSTONE_TORCH, + SOUL_TORCH, + REDSTONE_WALL_TORCH, + WALL_TORCH, + SOUL_WALL_TORCH, + LANTERN, + CANDLE, + JACK_O_LANTERN, + REDSTONE_LAMP, + MAGMA_BLOCK, + LIGHT, + SHROOMLIGHT, + SEA_LANTERN, + SOUL_LANTERN, + FIRE, + SOUL_FIRE, + SEA_PICKLE, + BREWING_STAND, + REDSTONE_ORE, }).forEach((i) -> b.add(i.ordinal())); return IntSets.unmodifiable(b); @@ -240,33 +239,33 @@ public class B { private static IntSet buildStorageCache() { IntSet b = new IntOpenHashSet(); - Arrays.stream(new Material[]{ - CHEST, - SMOKER, - TRAPPED_CHEST, - SHULKER_BOX, - WHITE_SHULKER_BOX, - ORANGE_SHULKER_BOX, - MAGENTA_SHULKER_BOX, - LIGHT_BLUE_SHULKER_BOX, - YELLOW_SHULKER_BOX, - LIME_SHULKER_BOX, - PINK_SHULKER_BOX, - GRAY_SHULKER_BOX, - LIGHT_GRAY_SHULKER_BOX, - CYAN_SHULKER_BOX, - PURPLE_SHULKER_BOX, - BLUE_SHULKER_BOX, - BROWN_SHULKER_BOX, - GREEN_SHULKER_BOX, - RED_SHULKER_BOX, - BLACK_SHULKER_BOX, - BARREL, - DISPENSER, - DROPPER, - HOPPER, - FURNACE, - BLAST_FURNACE + Arrays.stream(new Material[] { + CHEST, + SMOKER, + TRAPPED_CHEST, + SHULKER_BOX, + WHITE_SHULKER_BOX, + ORANGE_SHULKER_BOX, + MAGENTA_SHULKER_BOX, + LIGHT_BLUE_SHULKER_BOX, + YELLOW_SHULKER_BOX, + LIME_SHULKER_BOX, + PINK_SHULKER_BOX, + GRAY_SHULKER_BOX, + LIGHT_GRAY_SHULKER_BOX, + CYAN_SHULKER_BOX, + PURPLE_SHULKER_BOX, + BLUE_SHULKER_BOX, + BROWN_SHULKER_BOX, + GREEN_SHULKER_BOX, + RED_SHULKER_BOX, + BLACK_SHULKER_BOX, + BARREL, + DISPENSER, + DROPPER, + HOPPER, + FURNACE, + BLAST_FURNACE }).forEach((i) -> b.add(i.ordinal())); return IntSets.unmodifiable(b); @@ -275,12 +274,12 @@ public class B { public static BlockData toDeepSlateOre(BlockData block, BlockData ore) { int key = ore.getMaterial().ordinal(); - if (isDeepSlate(block)) { - if (normal2DeepslateCache.containsKey(key)) { + if(isDeepSlate(block)) { + if(normal2DeepslateCache.containsKey(key)) { return Material.values()[normal2DeepslateCache.get(key)].createBlockData(); } } else { - if (deepslate2NormalCache.containsKey(key)) { + if(deepslate2NormalCache.containsKey(key)) { return Material.values()[deepslate2NormalCache.get(key)].createBlockData(); } } @@ -306,39 +305,39 @@ public class B { } public static boolean canPlaceOnto(Material mat, Material onto) { - if ((onto.equals(CRIMSON_NYLIUM) || onto.equals(WARPED_NYLIUM)) && - (mat.equals(CRIMSON_FUNGUS) || mat.equals(CRIMSON_ROOTS) ||mat.equals(WARPED_FUNGUS) || mat.equals(WARPED_ROOTS) ) ){ + if((onto.equals(CRIMSON_NYLIUM) || onto.equals(WARPED_NYLIUM)) && + (mat.equals(CRIMSON_FUNGUS) || mat.equals(CRIMSON_ROOTS) || mat.equals(WARPED_FUNGUS) || mat.equals(WARPED_ROOTS))) { return true; } - if (isFoliage(mat)) { - if (!isFoliagePlantable(onto)) { + if(isFoliage(mat)) { + if(!isFoliagePlantable(onto)) { return false; } } - if (onto.equals(Material.AIR) || - onto.equals(B.getMaterial("CAVE_AIR")) - || onto.equals(B.getMaterial("VOID_AIR"))) { + if(onto.equals(Material.AIR) || + onto.equals(B.getMaterial("CAVE_AIR")) + || onto.equals(B.getMaterial("VOID_AIR"))) { return false; } - if (onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH)) { + if(onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH)) { return false; } - if (onto.equals(Material.DIRT_PATH)) { - if (!mat.isSolid()) { + if(onto.equals(Material.DIRT_PATH)) { + if(!mat.isSolid()) { return false; } } - if (onto.equals(Material.ACACIA_LEAVES) - || onto.equals(Material.BIRCH_LEAVES) - || onto.equals(Material.DARK_OAK_LEAVES) - || onto.equals(Material.JUNGLE_LEAVES) - || onto.equals(Material.OAK_LEAVES) - || onto.equals(Material.SPRUCE_LEAVES)) { + if(onto.equals(Material.ACACIA_LEAVES) + || onto.equals(Material.BIRCH_LEAVES) + || onto.equals(Material.DARK_OAK_LEAVES) + || onto.equals(Material.JUNGLE_LEAVES) + || onto.equals(Material.OAK_LEAVES) + || onto.equals(Material.SPRUCE_LEAVES)) { return mat.isSolid(); } @@ -347,25 +346,25 @@ public class B { public static boolean isFoliagePlantable(BlockData d) { return d.getMaterial().equals(Material.GRASS_BLOCK) - || d.getMaterial().equals(Material.ROOTED_DIRT) - || d.getMaterial().equals(Material.DIRT) - || d.getMaterial().equals(Material.COARSE_DIRT) - || d.getMaterial().equals(Material.PODZOL); + || d.getMaterial().equals(Material.ROOTED_DIRT) + || d.getMaterial().equals(Material.DIRT) + || d.getMaterial().equals(Material.COARSE_DIRT) + || d.getMaterial().equals(Material.PODZOL); } public static boolean isFoliagePlantable(Material d) { return d.equals(Material.GRASS_BLOCK) - || d.equals(Material.DIRT) - || d.equals(TALL_GRASS) - || d.equals(TALL_SEAGRASS) - || d.equals(LARGE_FERN) - || d.equals(SUNFLOWER) - || d.equals(PEONY) - || d.equals(LILAC) - || d.equals(ROSE_BUSH) - || d.equals(Material.ROOTED_DIRT) - || d.equals(Material.COARSE_DIRT) - || d.equals(Material.PODZOL); + || d.equals(Material.DIRT) + || d.equals(TALL_GRASS) + || d.equals(TALL_SEAGRASS) + || d.equals(LARGE_FERN) + || d.equals(SUNFLOWER) + || d.equals(PEONY) + || d.equals(LILAC) + || d.equals(ROSE_BUSH) + || d.equals(Material.ROOTED_DIRT) + || d.equals(Material.COARSE_DIRT) + || d.equals(Material.PODZOL); } public static boolean isWater(BlockData b) { @@ -379,9 +378,9 @@ public class B { public static Material getMaterialOrNull(String bdx) { try { return Material.valueOf(bdx.trim().toUpperCase()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (clw.flip()) { + if(clw.flip()) { Iris.warn("Unknown Material: " + bdx); } return null; @@ -391,7 +390,7 @@ public class B { public static Material getMaterial(String bdx) { Material m = getMaterialOrNull(bdx); - if (m == null) { + if(m == null) { return AIR_MATERIAL; } @@ -406,28 +405,28 @@ public class B { try { String bd = bdxf.trim(); - if (bd.startsWith("minecraft:cauldron[level=")) { + if(bd.startsWith("minecraft:cauldron[level=")) { bd = bd.replaceAll("\\Q:cauldron[\\E", ":water_cauldron["); } - if (bd.equals("minecraft:grass_path")) { + if(bd.equals("minecraft:grass_path")) { return DIRT_PATH.createBlockData(); } BlockData bdx = parseBlockData(bd); - if (bdx == null) { - if (clw.flip()) { + if(bdx == null) { + if(clw.flip()) { Iris.warn("Unknown Block Data '" + bd + "'"); } return AIR; } return bdx; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (clw.flip()) { + if(clw.flip()) { Iris.warn("Unknown Block Data '" + bdxf + "'"); } } @@ -438,7 +437,7 @@ public class B { public static BlockData get(String bdxf) { BlockData bd = getOrNull(bdxf); - if (bd != null) { + if(bd != null) { return bd; } @@ -453,84 +452,84 @@ public class B { try { BlockData bx = null; - if (!ix.startsWith("minecraft:")) { - if (ix.startsWith("oraxen:") && Iris.linkOraxen.supported()) { + if(!ix.startsWith("minecraft:")) { + if(ix.startsWith("oraxen:") && Iris.linkOraxen.supported()) { bx = Iris.linkOraxen.getBlockDataFor(ix.split("\\Q:\\E")[1]); } - if (bx == null) { + if(bx == null) { try { - if (ix.contains(":")) { + if(ix.contains(":")) { String[] v = ix.toLowerCase().split("\\Q:\\E"); Supplier b = Iris.service(RegistrySVC.class).getCustomBlockRegistry().resolve(v[0], v[1]); - if (b != null) { + if(b != null) { bx = b.get(); } } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace();// TODO: REMOVE } } } - if (bx == null) { + if(bx == null) { try { bx = createBlockData(ix.toLowerCase()); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } - if (bx == null) { + if(bx == null) { try { bx = createBlockData("minecraft:" + ix.toLowerCase()); - } catch (Throwable e) { + } catch(Throwable e) { } } - if (bx == null) { + if(bx == null) { try { bx = Material.valueOf(ix.toUpperCase()).createBlockData(); - } catch (Throwable e) { + } catch(Throwable e) { } } - if (bx == null) { + if(bx == null) { return null; } - if (bx instanceof Leaves && IrisSettings.get().getGenerator().isPreventLeafDecay()) { + if(bx instanceof Leaves && IrisSettings.get().getGenerator().isPreventLeafDecay()) { ((Leaves) bx).setPersistent(true); - } else if (bx instanceof Leaves) { + } else if(bx instanceof Leaves) { ((Leaves) bx).setPersistent(false); } return bx; - } catch (Throwable e) { - if (clw.flip()) { + } catch(Throwable e) { + if(clw.flip()) { Iris.warn("Unknown Block Data: " + ix); } String block = ix.contains(":") ? ix.split(":")[1].toLowerCase() : ix.toLowerCase(); String state = block.contains("[") ? block.split("\\Q[\\E")[1].split("\\Q]\\E")[0] : ""; Map stateMap = new HashMap<>(); - if (!state.equals("")) { + if(!state.equals("")) { Arrays.stream(state.split(",")).forEach(s -> stateMap.put(s.split("=")[0], s.split("=")[1])); } block = block.split("\\Q[\\E")[0]; - switch (block) { + switch(block) { case "cauldron" -> block = "water_cauldron"; case "grass_path" -> block = "dirt_path"; case "concrete" -> block = "white_concrete"; case "wool" -> block = "white_wool"; case "beetroots" -> { - if (stateMap.containsKey("age")) { + if(stateMap.containsKey("age")) { String updated = stateMap.get("age"); - switch (updated) { + switch(updated) { case "7" -> updated = "3"; case "3", "4", "5" -> updated = "2"; case "1", "2" -> updated = "1"; @@ -541,25 +540,25 @@ public class B { } Map newStates = new HashMap<>(); - for (String key : stateMap.keySet()) { //Iterate through every state and check if its valid + for(String key : stateMap.keySet()) { //Iterate through every state and check if its valid try { String newState = block + "[" + key + "=" + stateMap.get(key) + "]"; createBlockData(newState); newStates.put(key, stateMap.get(key)); - } catch (IllegalArgumentException ignored) { + } catch(IllegalArgumentException ignored) { } } //Combine all the "good" states again state = newStates.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(",")); - if (!state.equals("")) state = "[" + state + "]"; + if(!state.equals("")) state = "[" + state + "]"; String newBlock = block + state; Iris.debug("Converting " + ix + " to " + newBlock); try { return createBlockData(newBlock); - } catch (Throwable e1) { + } catch(Throwable e1) { Iris.reportError(e1); } @@ -581,9 +580,9 @@ public class B { public static boolean isUpdatable(BlockData mat) { return isLit(mat) - || isStorage(mat) - || (mat instanceof PointedDripstone - && ((PointedDripstone) mat).getThickness().equals(PointedDripstone.Thickness.TIP)); + || isStorage(mat) + || (mat instanceof PointedDripstone + && ((PointedDripstone) mat).getThickness().equals(PointedDripstone.Thickness.TIP)); } public static boolean isFoliage(Material d) { @@ -601,10 +600,10 @@ public class B { public static KList get(KList find) { KList b = new KList<>(); - for (String i : find) { + for(String i : find) { BlockData bd = get(i); - if (bd != null) { + if(bd != null) { b.add(bd); } } @@ -621,7 +620,7 @@ public class B { } public static boolean isAir(BlockData d) { - if (d == null) { + if(d == null) { return true; } @@ -632,11 +631,11 @@ public class B { public synchronized static String[] getBlockTypes() { KList bt = new KList<>(); - for (Material i : Material.values()) { - if (i.isBlock()) { + for(Material i : Material.values()) { + if(i.isBlock()) { String v = i.createBlockData().getAsString(true); - if (v.contains("[")) { + if(v.contains("[")) { v = v.split("\\Q[\\E")[0]; } @@ -645,16 +644,16 @@ public class B { } try { - for (String i : Iris.linkOraxen.getItemTypes()) { + for(String i : Iris.linkOraxen.getItemTypes()) { bt.add("oraxen:" + i); } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } try { bt.addAll(Iris.service(RegistrySVC.class).getCustomBlockRegistry().compile()); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -664,7 +663,7 @@ public class B { public static String[] getItemTypes() { KList bt = new KList<>(); - for (Material i : Material.values()) { + for(Material i : Material.values()) { String v = i.name().toLowerCase().trim(); bt.add(v); } diff --git a/src/main/java/com/volmit/iris/util/data/ChunkCache.java b/src/main/java/com/volmit/iris/util/data/ChunkCache.java index 9214f8e20..515b1d3e1 100644 --- a/src/main/java/com/volmit/iris/util/data/ChunkCache.java +++ b/src/main/java/com/volmit/iris/util/data/ChunkCache.java @@ -32,7 +32,7 @@ public class ChunkCache { public T compute(int x, int z, Function2 function) { T t = get(x & 15, z & 15); - if (t == null) { + if(t == null) { t = function.apply(x, z); set(x & 15, z & 15, t); } diff --git a/src/main/java/com/volmit/iris/util/data/Cuboid.java b/src/main/java/com/volmit/iris/util/data/Cuboid.java index 41db33c2c..821c9f693 100644 --- a/src/main/java/com/volmit/iris/util/data/Cuboid.java +++ b/src/main/java/com/volmit/iris/util/data/Cuboid.java @@ -49,11 +49,13 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * Construct a Cuboid given two Location objects which represent any two corners * of the Cuboid. * - * @param l1 one of the corners - * @param l2 the other corner + * @param l1 + * one of the corners + * @param l2 + * the other corner */ public Cuboid(Location l1, Location l2) { - if (!l1.getWorld().equals(l2.getWorld())) { + if(!l1.getWorld().equals(l2.getWorld())) { throw new IllegalArgumentException("locations must be on the same world"); } @@ -69,7 +71,8 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Construct a one-block Cuboid at the given Location of the Cuboid. * - * @param l1 location of the Cuboid + * @param l1 + * location of the Cuboid */ public Cuboid(Location l1) { this(l1, l1); @@ -78,7 +81,8 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Copy constructor. * - * @param other the Cuboid to copy + * @param other + * the Cuboid to copy */ public Cuboid(Cuboid other) { this(other.getWorld().getName(), other.x1, other.y1, other.z1, other.x2, other.y2, other.z2); @@ -87,13 +91,20 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Construct a Cuboid in the given World and xyz co-ordinates * - * @param world the Cuboid's world - * @param x1 X co-ordinate of corner 1 - * @param y1 Y co-ordinate of corner 1 - * @param z1 Z co-ordinate of corner 1 - * @param x2 X co-ordinate of corner 2 - * @param y2 Y co-ordinate of corner 2 - * @param z2 Z co-ordinate of corner 2 + * @param world + * the Cuboid's world + * @param x1 + * X co-ordinate of corner 1 + * @param y1 + * Y co-ordinate of corner 1 + * @param z1 + * Z co-ordinate of corner 1 + * @param x2 + * X co-ordinate of corner 2 + * @param y2 + * Y co-ordinate of corner 2 + * @param z2 + * Z co-ordinate of corner 2 */ public Cuboid(World world, int x1, int y1, int z1, int x2, int y2, int z2) { this.worldName = world.getName(); @@ -108,13 +119,20 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Construct a Cuboid in the given world name and xyz co-ordinates. * - * @param worldName the Cuboid's world name - * @param x1 X co-ordinate of corner 1 - * @param y1 Y co-ordinate of corner 1 - * @param z1 Z co-ordinate of corner 1 - * @param x2 X co-ordinate of corner 2 - * @param y2 Y co-ordinate of corner 2 - * @param z2 Z co-ordinate of corner 2 + * @param worldName + * the Cuboid's world name + * @param x1 + * X co-ordinate of corner 1 + * @param y1 + * Y co-ordinate of corner 1 + * @param z1 + * Z co-ordinate of corner 1 + * @param x2 + * X co-ordinate of corner 2 + * @param y2 + * Y co-ordinate of corner 2 + * @param z2 + * Z co-ordinate of corner 2 */ private Cuboid(String worldName, int x1, int y1, int z1, int x2, int y2, int z2) { this.worldName = worldName; @@ -139,9 +157,9 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ public KList getEntities() { KList en = new KList<>(); - for (Chunk i : getChunks()) { - for (Entity j : i.getEntities()) { - if (contains(j.getLocation())) { + for(Chunk i : getChunks()) { + for(Entity j : i.getEntities()) { + if(contains(j.getLocation())) { en.add(j); } } @@ -153,8 +171,10 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Set the locations * - * @param l1 a - * @param l2 b + * @param l1 + * a + * @param l2 + * b */ public void set(Location l1, Location l2) { x1 = Math.min(l1.getBlockX(), l2.getBlockX()); @@ -218,11 +238,12 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * Get the Cuboid's world. * * @return the World object representing this Cuboid's world - * @throws IllegalStateException if the world is not loaded + * @throws IllegalStateException + * if the world is not loaded */ public World getWorld() { World world = Bukkit.getWorld(worldName); - if (world == null) { + if(world == null) { throw new IllegalStateException("world '" + worldName + "' is not loaded"); } return world; @@ -342,12 +363,14 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * amounts will shrink the Cuboid in the given direction. Shrinking a cuboid's * face past the opposite face is not an error and will return a valid Cuboid. * - * @param dir the direction in which to expand - * @param amount the number of blocks by which to expand + * @param dir + * the direction in which to expand + * @param amount + * the number of blocks by which to expand * @return a new Cuboid expanded by the given direction and amount */ public Cuboid expand(CuboidDirection dir, int amount) { - return switch (dir) { + return switch(dir) { case North -> new Cuboid(worldName, x1 - amount, y1, z1, x2, y2, z2); case South -> new Cuboid(worldName, x1, y1, z1, x2 + amount, y2, z2); case East -> new Cuboid(worldName, x1, y1, z1 - amount, x2, y2, z2); @@ -371,8 +394,10 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Shift the Cuboid in the given direction by the given amount. * - * @param dir the direction in which to shift - * @param amount the number of blocks by which to shift + * @param dir + * the direction in which to shift + * @param amount + * the number of blocks by which to shift * @return a new Cuboid shifted by the given direction and amount */ public Cuboid shift(CuboidDirection dir, int amount) { @@ -382,13 +407,15 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Outset (grow) the Cuboid in the given direction by the given amount. * - * @param dir the direction in which to outset (must be Horizontal, Vertical, or - * Both) - * @param amount the number of blocks by which to outset + * @param dir + * the direction in which to outset (must be Horizontal, Vertical, or + * Both) + * @param amount + * the number of blocks by which to outset * @return a new Cuboid outset by the given direction and amount */ public Cuboid outset(CuboidDirection dir, int amount) { - Cuboid c = switch (dir) { + Cuboid c = switch(dir) { case Horizontal -> expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount); case Vertical -> expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount); case Both -> outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount); @@ -401,9 +428,11 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * Inset (shrink) the Cuboid in the given direction by the given amount. * Equivalent to calling outset() with a negative amount. * - * @param dir the direction in which to inset (must be Horizontal, Vertical, or - * Both) - * @param amount the number of blocks by which to inset + * @param dir + * the direction in which to inset (must be Horizontal, Vertical, or + * Both) + * @param amount + * the number of blocks by which to inset * @return a new Cuboid inset by the given direction and amount */ public Cuboid inset(CuboidDirection dir, int amount) { @@ -413,9 +442,12 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Return true if the point at (x,y,z) is contained within this Cuboid. * - * @param x the X co-ordinate - * @param y the Y co-ordinate - * @param z the Z co-ordinate + * @param x + * the X co-ordinate + * @param y + * the Y co-ordinate + * @param z + * the Z co-ordinate * @return true if the given point is within this Cuboid, false otherwise */ public boolean contains(int x, int y, int z) { @@ -425,7 +457,8 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Check if the given Block is contained within this Cuboid. * - * @param b the Block to check for + * @param b + * the Block to check for * @return true if the Block is within this Cuboid, false otherwise */ public boolean contains(Block b) { @@ -435,7 +468,8 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Check if the given Location is contained within this Cuboid. * - * @param l the Location to check for + * @param l + * the Location to check for * @return true if the Location is within this Cuboid, false otherwise */ public boolean contains(Location l) { @@ -460,8 +494,8 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ public byte averageLightLevel() { long total = 0; int n = 0; - for (Block b : this) { - if (b.isEmpty()) { + for(Block b : this) { + if(b.isEmpty()) { total += b.getLightLevel(); ++n; } @@ -484,44 +518,45 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * no exterior empty space. E.g. a direction of Down will push the top face * downwards as much as possible. * - * @param dir the direction in which to contract + * @param dir + * the direction in which to contract * @return a new Cuboid contracted in the given direction */ public Cuboid contract(CuboidDirection dir) { Cuboid face = getFace(dir.opposite()); - switch (dir) { + switch(dir) { case Down -> { - while (face.containsOnly(Material.AIR) && face.getLowerY() > this.getLowerY()) { + while(face.containsOnly(Material.AIR) && face.getLowerY() > this.getLowerY()) { face = face.shift(CuboidDirection.Down, 1); } return new Cuboid(worldName, x1, y1, z1, x2, face.getUpperY(), z2); } case Up -> { - while (face.containsOnly(Material.AIR) && face.getUpperY() < this.getUpperY()) { + while(face.containsOnly(Material.AIR) && face.getUpperY() < this.getUpperY()) { face = face.shift(CuboidDirection.Up, 1); } return new Cuboid(worldName, x1, face.getLowerY(), z1, x2, y2, z2); } case North -> { - while (face.containsOnly(Material.AIR) && face.getLowerX() > this.getLowerX()) { + while(face.containsOnly(Material.AIR) && face.getLowerX() > this.getLowerX()) { face = face.shift(CuboidDirection.North, 1); } return new Cuboid(worldName, x1, y1, z1, face.getUpperX(), y2, z2); } case South -> { - while (face.containsOnly(Material.AIR) && face.getUpperX() < this.getUpperX()) { + while(face.containsOnly(Material.AIR) && face.getUpperX() < this.getUpperX()) { face = face.shift(CuboidDirection.South, 1); } return new Cuboid(worldName, face.getLowerX(), y1, z1, x2, y2, z2); } case East -> { - while (face.containsOnly(Material.AIR) && face.getLowerZ() > this.getLowerZ()) { + while(face.containsOnly(Material.AIR) && face.getLowerZ() > this.getLowerZ()) { face = face.shift(CuboidDirection.East, 1); } return new Cuboid(worldName, x1, y1, z1, x2, y2, face.getUpperZ()); } case West -> { - while (face.containsOnly(Material.AIR) && face.getUpperZ() < this.getUpperZ()) { + while(face.containsOnly(Material.AIR) && face.getUpperZ() < this.getUpperZ()) { face = face.shift(CuboidDirection.West, 1); } return new Cuboid(worldName, x1, y1, face.getLowerZ(), x2, y2, z2); @@ -534,11 +569,12 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * Get the Cuboid representing the face of this Cuboid. The resulting Cuboid * will be one block thick in the axis perpendicular to the requested face. * - * @param dir which face of the Cuboid to get + * @param dir + * which face of the Cuboid to get * @return the Cuboid representing this Cuboid's requested face */ public Cuboid getFace(CuboidDirection dir) { - return switch (dir) { + return switch(dir) { case Down -> new Cuboid(worldName, x1, y1, z1, x2, y1, z2); case Up -> new Cuboid(worldName, x1, y2, z1, x2, y2, z2); case North -> new Cuboid(worldName, x1, y1, z1, x1, y2, z2); @@ -552,12 +588,13 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Check if the Cuboid contains only blocks of the given type * - * @param material the material to check for + * @param material + * the material to check for * @return true if this Cuboid contains only blocks of the given type */ public boolean containsOnly(Material material) { - for (Block b : this) { - if (b.getType() != material) { + for(Block b : this) { + if(b.getType() != material) { return false; } } @@ -567,11 +604,12 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Get the Cuboid big enough to hold both this Cuboid and the given one. * - * @param other the other Cuboid to include + * @param other + * the other Cuboid to include * @return a new Cuboid large enough to hold this Cuboid and the given Cuboid */ public Cuboid getBoundingCuboid(Cuboid other) { - if (other == null) { + if(other == null) { return this; } @@ -588,9 +626,12 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ /** * Get a block relative to the lower NE point of the Cuboid. * - * @param x the X co-ordinate - * @param y the Y co-ordinate - * @param z the Z co-ordinate + * @param x + * the X co-ordinate + * @param y + * the Y co-ordinate + * @param z + * the Z co-ordinate * @return the block at the given position */ public Block getRelativeBlock(int x, int y, int z) { @@ -602,10 +643,14 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * This version of getRelativeBlock() should be used if being called many times, * to avoid excessive calls to getWorld(). * - * @param w the World - * @param x the X co-ordinate - * @param y the Y co-ordinate - * @param z the Z co-ordinate + * @param w + * the World + * @param x + * the X co-ordinate + * @param y + * the Y co-ordinate + * @param z + * the Z co-ordinate * @return the block at the given position */ public Block getRelativeBlock(World w, int x, int y, int z) { @@ -626,8 +671,8 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ int x2 = getUpperX() & ~0xf; int z1 = getLowerZ() & ~0xf; int z2 = getUpperZ() & ~0xf; - for (int x = x1; x <= x2; x += 16) { - for (int z = z1; z <= z2; z += 16) { + for(int x = x1; x <= x2; x += 16) { + for(int z = z1; z <= z2; z += 16) { res.add(w.getChunkAt(x >> 4, z >> 4)); } } @@ -693,7 +738,7 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ Unknown; public CuboidDirection opposite() { - return switch (this) { + return switch(this) { case North -> South; case East -> West; case South -> North; @@ -737,9 +782,9 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ @Override public Block next() { Block b = w.getBlockAt(baseX + x, baseY + y, baseZ + z); - if (++x >= sizeX) { + if(++x >= sizeX) { x = 0; - if (++y >= sizeY) { + if(++y >= sizeY) { y = 0; ++z; } diff --git a/src/main/java/com/volmit/iris/util/data/DUTF.java b/src/main/java/com/volmit/iris/util/data/DUTF.java index 54ba81a01..dd7e97d2e 100644 --- a/src/main/java/com/volmit/iris/util/data/DUTF.java +++ b/src/main/java/com/volmit/iris/util/data/DUTF.java @@ -18,12 +18,9 @@ package com.volmit.iris.util.data; -import java.io.DataInput; import java.io.DataInputStream; -import java.io.DataOutput; import java.io.DataOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.nio.charset.StandardCharsets; /** diff --git a/src/main/java/com/volmit/iris/util/data/DataPalette.java b/src/main/java/com/volmit/iris/util/data/DataPalette.java index 81687ddf5..1eadfe387 100644 --- a/src/main/java/com/volmit/iris/util/data/DataPalette.java +++ b/src/main/java/com/volmit/iris/util/data/DataPalette.java @@ -39,7 +39,7 @@ public class DataPalette { KList palette = new KList<>(); int s = din.readShort() - Short.MIN_VALUE; - for (int i = 0; i < s; i++) { + for(int i = 0; i < s; i++) { palette.add(adapter.read(din)); } @@ -51,8 +51,8 @@ public class DataPalette { } public T get(int index) { - synchronized (palette) { - if (!palette.hasIndex(index)) { + synchronized(palette) { + if(!palette.hasIndex(index)) { return null; } @@ -63,10 +63,10 @@ public class DataPalette { public int getIndex(T t) { int v = 0; - synchronized (palette) { + synchronized(palette) { v = palette.indexOf(t); - if (v == -1) { + if(v == -1) { v = palette.size(); palette.add(t); } @@ -76,10 +76,10 @@ public class DataPalette { } public void write(IOAdapter adapter, DataOutputStream dos) throws IOException { - synchronized (palette) { + synchronized(palette) { dos.writeShort(getPalette().size() + Short.MIN_VALUE); - for (T t : palette) { + for(T t : palette) { adapter.write(t, dos); } } diff --git a/src/main/java/com/volmit/iris/util/data/Dimension.java b/src/main/java/com/volmit/iris/util/data/Dimension.java index 2a25e6aaf..ddfe1b1e0 100644 --- a/src/main/java/com/volmit/iris/util/data/Dimension.java +++ b/src/main/java/com/volmit/iris/util/data/Dimension.java @@ -31,9 +31,12 @@ public class Dimension { /** * Make a dimension * - * @param width width of this (X) - * @param height the height (Y) - * @param depth the depth (Z) + * @param width + * width of this (X) + * @param height + * the height (Y) + * @param depth + * the depth (Z) */ public Dimension(int width, int height, int depth) { this.width = width; @@ -44,8 +47,10 @@ public class Dimension { /** * Make a dimension * - * @param width width of this (X) - * @param height the height (Y) + * @param width + * width of this (X) + * @param height + * the height (Y) */ public Dimension(int width, int height) { this.width = width; @@ -60,15 +65,15 @@ public class Dimension { * @return the direction of the flat pane or null */ public DimensionFace getPane() { - if (width == 1) { + if(width == 1) { return DimensionFace.X; } - if (height == 1) { + if(height == 1) { return DimensionFace.Y; } - if (depth == 1) { + if(depth == 1) { return DimensionFace.Z; } diff --git a/src/main/java/com/volmit/iris/util/data/DoubleArrayUtils.java b/src/main/java/com/volmit/iris/util/data/DoubleArrayUtils.java index 410f12232..c56f3392c 100644 --- a/src/main/java/com/volmit/iris/util/data/DoubleArrayUtils.java +++ b/src/main/java/com/volmit/iris/util/data/DoubleArrayUtils.java @@ -25,7 +25,7 @@ import java.util.Arrays; public class DoubleArrayUtils { public static void shiftRight(double[] values, double push) { - if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1); + if(values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1); values[0] = push; } @@ -40,7 +40,7 @@ public class DoubleArrayUtils { } public static void fill(AtomicDoubleArray values, double value) { - for (int i = 0; i < values.length(); i++) { + for(int i = 0; i < values.length(); i++) { values.set(i, value); } } diff --git a/src/main/java/com/volmit/iris/util/data/IrisBiomeStorage.java b/src/main/java/com/volmit/iris/util/data/IrisBiomeStorage.java index 75610422a..5a298cc82 100644 --- a/src/main/java/com/volmit/iris/util/data/IrisBiomeStorage.java +++ b/src/main/java/com/volmit/iris/util/data/IrisBiomeStorage.java @@ -54,12 +54,12 @@ public class IrisBiomeStorage implements BiomeGrid { public void inject(BiomeGrid grid) { // TODO: WARNING HEIGHT - for (int i = 0; i < 256; i++) { - for (int j = 0; j < 16; j++) { - for (int k = 0; k < 16; k++) { + for(int i = 0; i < 256; i++) { + for(int j = 0; j < 16; j++) { + for(int k = 0; k < 16; k++) { Biome b = getBiome(j, i, k); - if (b == null || b.equals(Biome.THE_VOID)) { + if(b == null || b.equals(Biome.THE_VOID)) { continue; } diff --git a/src/main/java/com/volmit/iris/util/data/KCache.java b/src/main/java/com/volmit/iris/util/data/KCache.java index 99bf04cd0..10f1e9a10 100644 --- a/src/main/java/com/volmit/iris/util/data/KCache.java +++ b/src/main/java/com/volmit/iris/util/data/KCache.java @@ -44,11 +44,11 @@ public class KCache implements MeteredCache { private LoadingCache create(CacheLoader loader) { return Caffeine - .newBuilder() - .maximumSize(max) - .softValues() - .initialCapacity((int) (max)) - .build((k) -> loader == null ? null : loader.load(k)); + .newBuilder() + .maximumSize(max) + .softValues() + .initialCapacity((int) (max)) + .build((k) -> loader == null ? null : loader.load(k)); } diff --git a/src/main/java/com/volmit/iris/util/data/MaterialBlock.java b/src/main/java/com/volmit/iris/util/data/MaterialBlock.java index d22e0d7c2..1d3b4e2a7 100644 --- a/src/main/java/com/volmit/iris/util/data/MaterialBlock.java +++ b/src/main/java/com/volmit/iris/util/data/MaterialBlock.java @@ -36,8 +36,10 @@ public class MaterialBlock { /** * Create a materialblock * - * @param material the material - * @param data the data + * @param material + * the material + * @param data + * the data */ public MaterialBlock(Material material, Byte data) { this.material = material; @@ -86,7 +88,7 @@ public class MaterialBlock { @Override public String toString() { - if (getData() == 0) { + if(getData() == 0) { return getMaterial().toString(); } @@ -104,21 +106,21 @@ public class MaterialBlock { @Override public boolean equals(Object obj) { - if (this == obj) { + if(this == obj) { return true; } - if (obj == null) { + if(obj == null) { return false; } - if (getClass() != obj.getClass()) { + if(getClass() != obj.getClass()) { return false; } MaterialBlock other = (MaterialBlock) obj; - if (data == null) { - if (other.data != null) { + if(data == null) { + if(other.data != null) { return false; } - } else if (!data.equals(other.data)) { + } else if(!data.equals(other.data)) { return false; } return material == other.material; diff --git a/src/main/java/com/volmit/iris/util/data/NibbleArray.java b/src/main/java/com/volmit/iris/util/data/NibbleArray.java index 8cf0bdacf..fb87e1631 100644 --- a/src/main/java/com/volmit/iris/util/data/NibbleArray.java +++ b/src/main/java/com/volmit/iris/util/data/NibbleArray.java @@ -29,7 +29,7 @@ public class NibbleArray implements Writable { private static final int[] MASKS = new int[8]; static { - for (int i = 0; i < MASKS.length; i++) { + for(int i = 0; i < MASKS.length; i++) { MASKS[i] = maskFor(i); } } @@ -47,7 +47,7 @@ public class NibbleArray implements Writable { } public NibbleArray(int nibbleDepth, int capacity) { - if (nibbleDepth > 8 || nibbleDepth < 1) { + if(nibbleDepth > 8 || nibbleDepth < 1) { throw new IllegalArgumentException(); } @@ -60,7 +60,7 @@ public class NibbleArray implements Writable { } public NibbleArray(int nibbleDepth, int capacity, NibbleArray existing) { - if (nibbleDepth > 8 || nibbleDepth < 1) { + if(nibbleDepth > 8 || nibbleDepth < 1) { throw new IllegalArgumentException(); } @@ -70,7 +70,7 @@ public class NibbleArray implements Writable { data = new byte[(neededBits + neededBits % 8) / 8]; mask = (byte) maskFor(nibbleDepth); - for (int i = 0; i < Math.min(size, existing.size()); i++) { + for(int i = 0; i < Math.min(size, existing.size()); i++) { set(i, existing.get(i)); } } @@ -82,7 +82,7 @@ public class NibbleArray implements Writable { public static int powerOfTwo(int power) { int result = 1; - for (int i = 0; i < power; i++) { + for(int i = 0; i < power; i++) { result *= 2; } @@ -119,13 +119,13 @@ public class NibbleArray implements Writable { } public byte get(int index) { - synchronized (lock) { + synchronized(lock) { bitIndex = index * depth; byteIndex = bitIndex >> 3; bitInByte = bitIndex & 7; int value = data[byteIndex] >> bitInByte; - if (bitInByte + depth > 8) { + if(bitInByte + depth > 8) { value |= data[byteIndex + 1] << bitInByte; } @@ -150,13 +150,13 @@ public class NibbleArray implements Writable { } public void set(int index, byte nybble) { - synchronized (lock) { + synchronized(lock) { bitIndex = index * depth; byteIndex = bitIndex >> 3; bitInByte = bitIndex & 7; data[byteIndex] = (byte) (((~(data[byteIndex] & (mask << bitInByte)) & data[byteIndex]) | ((nybble & mask) << bitInByte)) & 0xff); - if (bitInByte + depth > 8) { + if(bitInByte + depth > 8) { data[byteIndex + 1] = (byte) (((~(data[byteIndex + 1] & MASKS[bitInByte + depth - 8]) & data[byteIndex + 1]) | ((nybble & mask) >> (8 - bitInByte))) & 0xff); } } @@ -169,7 +169,7 @@ public class NibbleArray implements Writable { public String toBitsString(ByteOrder byteOrder) { StringJoiner joiner = new StringJoiner(" "); - for (byte datum : data) { + for(byte datum : data) { joiner.add(binaryString(datum, byteOrder)); } @@ -181,13 +181,13 @@ public class NibbleArray implements Writable { } public void setAll(byte nibble) { - for (int i = 0; i < size; i++) { + for(int i = 0; i < size; i++) { set(i, nibble); } } public void setAll(int nibble) { - for (int i = 0; i < size; i++) { + for(int i = 0; i < size; i++) { set(i, (byte) nibble); } } diff --git a/src/main/java/com/volmit/iris/util/data/NibbleDataPalette.java b/src/main/java/com/volmit/iris/util/data/NibbleDataPalette.java index 1da173193..37ccec2b1 100644 --- a/src/main/java/com/volmit/iris/util/data/NibbleDataPalette.java +++ b/src/main/java/com/volmit/iris/util/data/NibbleDataPalette.java @@ -48,7 +48,7 @@ public abstract class NibbleDataPalette implements Writable { o.writeByte(bpb + Byte.MIN_VALUE); o.writeByte(palette.size() + Byte.MIN_VALUE); - for (T i : palette) { + for(T i : palette) { writeType(i, o); } @@ -61,7 +61,7 @@ public abstract class NibbleDataPalette implements Writable { palette = new KList<>(); int v = i.readByte() - Byte.MIN_VALUE; - for (int j = 0; j < v; j++) { + for(int j = 0; j < v; j++) { palette.add(readType(i)); } @@ -69,7 +69,7 @@ public abstract class NibbleDataPalette implements Writable { } private final void expand() { - if (bpb < 8) { + if(bpb < 8) { changeBitsPerBlock(bpb + 1); } else { throw new IndexOutOfBoundsException("The Data Palette can only handle at most 256 block types per 16x16x16 region. We cannot use more than 8 bits per block!"); @@ -80,8 +80,8 @@ public abstract class NibbleDataPalette implements Writable { int targetBits = bpb; int needed = palette.size(); - for (int i = 1; i < bpb; i++) { - if (Math.pow(2, i) > needed) { + for(int i = 1; i < bpb; i++) { + if(Math.pow(2, i) > needed) { targetBits = i; break; } @@ -106,11 +106,11 @@ public abstract class NibbleDataPalette implements Writable { private final int getPaletteId(T d) { int index = palette.indexOf(d); - if (index == -1) { + if(index == -1) { index = palette.size(); palette.add(d); - if (palette.size() > Math.pow(2, bpb)) { + if(palette.size() > Math.pow(2, bpb)) { expand(); } } diff --git a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java index a6133e4b9..e8b5d5020 100644 --- a/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java +++ b/src/main/java/com/volmit/iris/util/data/VanillaBiomeMap.java @@ -34,67 +34,67 @@ public class VanillaBiomeMap { static { add(Biome.OCEAN, 0x000070, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.PLAINS, 0x8DB360, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.DESERT, 0xFA9418, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.WINDSWEPT_HILLS, 0x606060, Color.MONOCHROME, Luminosity.BRIGHT, null); - add(Biome.FOREST, 0x056621, Color.GREEN, Luminosity.BRIGHT, null); + add(Biome.PLAINS, 0x8DB360, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.DESERT, 0xFA9418, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.WINDSWEPT_HILLS, 0x606060, Color.MONOCHROME, Luminosity.BRIGHT, null); + add(Biome.FOREST, 0x056621, Color.GREEN, Luminosity.BRIGHT, null); add(Biome.TAIGA, 0x0B6659, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SWAMP, 0x07F9B2, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM); + add(Biome.SWAMP, 0x07F9B2, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM); add(Biome.RIVER, 0x0000FF, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.NETHER_WASTES, 0xBF3B3B, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM); - add(Biome.THE_END, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.FROZEN_OCEAN, 0x7070D6, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FROZEN_RIVER, 0xA0A0FF, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_PLAINS, 0xFFFFFF, Color.MONOCHROME, Luminosity.LIGHT, null); - add(Biome.MUSHROOM_FIELDS, 0xFF00FF, Color.PURPLE, Luminosity.BRIGHT, null); - add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.NETHER_WASTES, 0xBF3B3B, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.THE_END, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.FROZEN_OCEAN, 0x7070D6, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_RIVER, 0xA0A0FF, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_PLAINS, 0xFFFFFF, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.MUSHROOM_FIELDS, 0xFF00FF, Color.PURPLE, Luminosity.BRIGHT, null); + add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); add(Biome.SPARSE_JUNGLE, 0x628B17, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null); - add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null); - add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null); + add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null); + add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null); + add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null); add(Biome.BIRCH_FOREST, 0x307444, Color.GREEN, Luminosity.LIGHT, null); add(Biome.DARK_FOREST, 0x40511A, Color.GREEN, Luminosity.DARK, null); - add(Biome.SNOWY_TAIGA, 0x31554A, Color.BLUE, Luminosity.LIGHT, null); - add(Biome.OLD_GROWTH_PINE_TAIGA, 0x596651, Color.ORANGE, Luminosity.LIGHT, null); + add(Biome.SNOWY_TAIGA, 0x31554A, Color.BLUE, Luminosity.LIGHT, null); + add(Biome.OLD_GROWTH_PINE_TAIGA, 0x596651, Color.ORANGE, Luminosity.LIGHT, null); add(Biome.WINDSWEPT_FOREST, 0x507050, Color.MONOCHROME, Luminosity.BRIGHT, null); - add(Biome.SAVANNA, 0xBDB25F, Color.GREEN, Luminosity.LIGHT, null); - add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null); + add(Biome.SAVANNA, 0xBDB25F, Color.GREEN, Luminosity.LIGHT, null); + add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null); add(Biome.BADLANDS, 0xD94515, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM); add(Biome.END_MIDLANDS, 0x8080FF, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM); + add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM); add(Biome.WARM_OCEAN, 0x0000AC, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW); add(Biome.LUKEWARM_OCEAN, 0x000090, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); add(Biome.COLD_OCEAN, 0x202070, Color.BLUE, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM); - add(Biome.DEEP_COLD_OCEAN, 0x202038, Color.BLUE, Luminosity.DARK, SaturationType.HIGH); - add(Biome.DEEP_FROZEN_OCEAN, 0x404090, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.THE_VOID, 0x000000, Color.MONOCHROME, Luminosity.DARK, null); - add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x789878, Color.MONOCHROME, Luminosity.LIGHT, null); - add(Biome.FLOWER_FOREST, 0x2D8E49, Color.RED, Luminosity.LIGHT, SaturationType.LOW); - add(Biome.ICE_SPIKES, 0xB4DCDC, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM); + add(Biome.DEEP_COLD_OCEAN, 0x202038, Color.BLUE, Luminosity.DARK, SaturationType.HIGH); + add(Biome.DEEP_FROZEN_OCEAN, 0x404090, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.THE_VOID, 0x000000, Color.MONOCHROME, Luminosity.DARK, null); + add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x789878, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.FLOWER_FOREST, 0x2D8E49, Color.RED, Luminosity.LIGHT, SaturationType.LOW); + add(Biome.ICE_SPIKES, 0xB4DCDC, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW); add(Biome.OLD_GROWTH_BIRCH_FOREST, 0x589C6C, Color.GREEN, Luminosity.LIGHT, null); - add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x818E79, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH); - add(Biome.WINDSWEPT_SAVANNA, 0xE5DA87, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); - add(Biome.ERODED_BADLANDS, 0xFF6D3D, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); - add(Biome.BAMBOO_JUNGLE, 0x768E14, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); - add(Biome.SOUL_SAND_VALLEY, 0x5E3830, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.CRIMSON_FOREST, 0xDD0808, Color.RED, Luminosity.DARK, SaturationType.HIGH); - add(Biome.WARPED_FOREST, 0x49907B, Color.BLUE, Luminosity.BRIGHT, null); + add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x818E79, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH); + add(Biome.WINDSWEPT_SAVANNA, 0xE5DA87, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); + add(Biome.ERODED_BADLANDS, 0xFF6D3D, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH); + add(Biome.BAMBOO_JUNGLE, 0x768E14, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH); + add(Biome.SOUL_SAND_VALLEY, 0x5E3830, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.CRIMSON_FOREST, 0xDD0808, Color.RED, Luminosity.DARK, SaturationType.HIGH); + add(Biome.WARPED_FOREST, 0x49907B, Color.BLUE, Luminosity.BRIGHT, null); add(Biome.BASALT_DELTAS, 0x403636, Color.MONOCHROME, Luminosity.DARK, null); add(Biome.DRIPSTONE_CAVES, 0xcc6600, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.LUSH_CAVES, 0x003300, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.MEADOW, 0xff00ff, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW); - add(Biome.GROVE, 0x80ff80, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.SNOWY_SLOPES, 0x00ffff, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.FROZEN_PEAKS, 0xA0A0A0, Color.MONOCHROME, Luminosity.LIGHT, null); - add(Biome.JAGGED_PEAKS, 0x3d7bc2, Color.MONOCHROME, Luminosity.BRIGHT, SaturationType.MEDIUM); - add(Biome.STONY_PEAKS, 0x888888, Color.MONOCHROME, Luminosity.LIGHT, null); - add(Biome.CUSTOM, 0xffffff, Color.MONOCHROME, Luminosity.DARK, SaturationType.MONOCHROME); + add(Biome.LUSH_CAVES, 0x003300, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.MEADOW, 0xff00ff, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW); + add(Biome.GROVE, 0x80ff80, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.SNOWY_SLOPES, 0x00ffff, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.FROZEN_PEAKS, 0xA0A0A0, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.JAGGED_PEAKS, 0x3d7bc2, Color.MONOCHROME, Luminosity.BRIGHT, SaturationType.MEDIUM); + add(Biome.STONY_PEAKS, 0x888888, Color.MONOCHROME, Luminosity.LIGHT, null); + add(Biome.CUSTOM, 0xffffff, Color.MONOCHROME, Luminosity.DARK, SaturationType.MONOCHROME); } diff --git a/src/main/java/com/volmit/iris/util/data/Varint.java b/src/main/java/com/volmit/iris/util/data/Varint.java index f04b95969..8c70b0326 100644 --- a/src/main/java/com/volmit/iris/util/data/Varint.java +++ b/src/main/java/com/volmit/iris/util/data/Varint.java @@ -44,9 +44,12 @@ public final class Varint { * encode signed values. If values are known to be nonnegative, * {@link #writeUnsignedVarLong(long, DataOutput)} should be used. * - * @param value value to encode - * @param out to writeNodeData bytes to - * @throws IOException if {@link DataOutput} throws {@link IOException} + * @param value + * value to encode + * @param out + * to writeNodeData bytes to + * @throws IOException + * if {@link DataOutput} throws {@link IOException} */ public static void writeSignedVarLong(long value, DataOutput out) throws IOException { // Great trick from http://code.google.com/apis/protocolbuffers/docs/encoding.html#types @@ -60,12 +63,15 @@ public final class Varint { * If values can be negative, use {@link #writeSignedVarLong(long, DataOutput)} * instead. This method treats negative input as like a large unsigned value. * - * @param value value to encode - * @param out to writeNodeData bytes to - * @throws IOException if {@link DataOutput} throws {@link IOException} + * @param value + * value to encode + * @param out + * to writeNodeData bytes to + * @throws IOException + * if {@link DataOutput} throws {@link IOException} */ public static void writeUnsignedVarLong(long value, DataOutput out) throws IOException { - while ((value & 0xFFFFFFFFFFFFFF80L) != 0L) { + while((value & 0xFFFFFFFFFFFFFF80L) != 0L) { out.writeByte(((int) value & 0x7F) | 0x80); value >>>= 7; } @@ -84,7 +90,7 @@ public final class Varint { * @see #writeUnsignedVarLong(long, DataOutput) */ public static void writeUnsignedVarInt(int value, DataOutput out) throws IOException { - while ((value & 0xFFFFFF80) != 0L) { + while((value & 0xFFFFFF80) != 0L) { out.writeByte((value & 0x7F) | 0x80); value >>>= 7; } @@ -105,24 +111,27 @@ public final class Varint { public static byte[] writeUnsignedVarInt(int value) { byte[] byteArrayList = new byte[10]; int i = 0; - while ((value & 0xFFFFFF80) != 0L) { + while((value & 0xFFFFFF80) != 0L) { byteArrayList[i++] = ((byte) ((value & 0x7F) | 0x80)); value >>>= 7; } byteArrayList[i] = ((byte) (value & 0x7F)); byte[] out = new byte[i + 1]; - for (; i >= 0; i--) { + for(; i >= 0; i--) { out[i] = byteArrayList[i]; } return out; } /** - * @param in to read bytes from + * @param in + * to read bytes from * @return decode value - * @throws IOException if {@link DataInput} throws {@link IOException} - * @throws IllegalArgumentException if variable-length value does not terminate - * after 9 bytes have been read + * @throws IOException + * if {@link DataInput} throws {@link IOException} + * @throws IllegalArgumentException + * if variable-length value does not terminate + * after 9 bytes have been read * @see #writeSignedVarLong(long, DataOutput) */ public static long readSignedVarLong(DataInput in) throws IOException { @@ -136,21 +145,24 @@ public final class Varint { } /** - * @param in to read bytes from + * @param in + * to read bytes from * @return decode value - * @throws IOException if {@link DataInput} throws {@link IOException} - * @throws IllegalArgumentException if variable-length value does not terminate - * after 9 bytes have been read + * @throws IOException + * if {@link DataInput} throws {@link IOException} + * @throws IllegalArgumentException + * if variable-length value does not terminate + * after 9 bytes have been read * @see #writeUnsignedVarLong(long, DataOutput) */ public static long readUnsignedVarLong(DataInput in) throws IOException { long value = 0L; int i = 0; long b; - while (((b = in.readByte()) & 0x80L) != 0) { + while(((b = in.readByte()) & 0x80L) != 0) { value |= (b & 0x7F) << i; i += 7; - if (i > 63) { + if(i > 63) { throw new IllegalArgumentException("Variable length quantity is too long"); } } @@ -158,9 +170,11 @@ public final class Varint { } /** - * @throws IllegalArgumentException if variable-length value does not terminate - * after 5 bytes have been read - * @throws IOException if {@link DataInput} throws {@link IOException} + * @throws IllegalArgumentException + * if variable-length value does not terminate + * after 5 bytes have been read + * @throws IOException + * if {@link DataInput} throws {@link IOException} * @see #readSignedVarLong(DataInput) */ public static int readSignedVarInt(DataInput in) throws IOException { @@ -174,19 +188,21 @@ public final class Varint { } /** - * @throws IllegalArgumentException if variable-length value does not terminate - * after 5 bytes have been read - * @throws IOException if {@link DataInput} throws {@link IOException} + * @throws IllegalArgumentException + * if variable-length value does not terminate + * after 5 bytes have been read + * @throws IOException + * if {@link DataInput} throws {@link IOException} * @see #readUnsignedVarLong(DataInput) */ public static int readUnsignedVarInt(DataInput in) throws IOException { int value = 0; int i = 0; int b; - while (((b = in.readByte()) & 0x80) != 0) { + while(((b = in.readByte()) & 0x80) != 0) { value |= (b & 0x7F) << i; i += 7; - if (i > 35) { + if(i > 35) { throw new IllegalArgumentException("Variable length quantity is too long"); } } @@ -207,14 +223,14 @@ public final class Varint { int value = 0; int i = 0; byte rb = Byte.MIN_VALUE; - for (byte b : bytes) { + for(byte b : bytes) { rb = b; - if ((b & 0x80) == 0) { + if((b & 0x80) == 0) { break; } value |= (b & 0x7f) << i; i += 7; - if (i > 35) { + if(i > 35) { throw new IllegalArgumentException("Variable length quantity is too long"); } } diff --git a/src/main/java/com/volmit/iris/util/data/WeightMap.java b/src/main/java/com/volmit/iris/util/data/WeightMap.java index 5f4db9e6a..1be87f5f2 100644 --- a/src/main/java/com/volmit/iris/util/data/WeightMap.java +++ b/src/main/java/com/volmit/iris/util/data/WeightMap.java @@ -26,7 +26,7 @@ public class WeightMap extends KMap { private double lastWeight = 0; public double getPercentChance(T t) { - if (totalWeight() <= 0) { + if(totalWeight() <= 0) { return 0; } @@ -49,7 +49,7 @@ public class WeightMap extends KMap { } public double totalWeight() { - if (!modified) { + if(!modified) { return lastWeight; } diff --git a/src/main/java/com/volmit/iris/util/data/WeightedRandom.java b/src/main/java/com/volmit/iris/util/data/WeightedRandom.java index 35d7f2d90..7ca18abe5 100644 --- a/src/main/java/com/volmit/iris/util/data/WeightedRandom.java +++ b/src/main/java/com/volmit/iris/util/data/WeightedRandom.java @@ -45,7 +45,7 @@ public class WeightedRandom { public T pullRandom() { int pull = random.nextInt(totalWeight); int index = 0; - while (pull > 0) { + while(pull > 0) { pull -= weightedObjects.get(index).getV(); index++; } diff --git a/src/main/java/com/volmit/iris/util/data/palette/BitStorage.java b/src/main/java/com/volmit/iris/util/data/palette/BitStorage.java index f79fa9a3d..0c5cb1605 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/BitStorage.java +++ b/src/main/java/com/volmit/iris/util/data/palette/BitStorage.java @@ -24,27 +24,27 @@ import java.util.concurrent.atomic.AtomicLongArray; import java.util.function.IntConsumer; public class BitStorage { - private static final int[] MAGIC = new int[]{ - -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, - 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, - 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, - 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, - 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, - 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, - 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, - 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, - 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, - 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, - 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, - 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, - 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, - 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, - 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, - 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, - 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, - 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, - 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, - 0, 5}; + private static final int[] MAGIC = new int[] { + -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, + 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, + 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, + 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, + 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, + 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, + 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, + 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, + 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, + 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, + 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, + 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, + 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, + 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, + 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, + 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, + 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, + 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, + 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, + 0, 5}; private final AtomicLongArray data; private final int bits; @@ -60,12 +60,12 @@ public class BitStorage { } private static AtomicLongArray atomic(long[] data) { - if (data == null) { + if(data == null) { return null; } AtomicLongArray d = new AtomicLongArray(data.length); - for (int i = 0; i < data.length; i++) { + for(int i = 0; i < data.length; i++) { d.set(i, data[i]); } @@ -73,12 +73,12 @@ public class BitStorage { } private static long[] atomic(AtomicLongArray data) { - if (data == null) { + if(data == null) { return null; } long[] d = new long[data.length()]; - for (int i = 0; i < data.length(); i++) { + for(int i = 0; i < data.length(); i++) { d[i] = data.get(i); } @@ -100,8 +100,8 @@ public class BitStorage { this.divideAdd = MAGIC[var3 + 1]; this.divideShift = MAGIC[var3 + 2]; int var4 = (length + this.valuesPerLong - 1) / this.valuesPerLong; - if (data != null) { - if (data.length() != var4) { + if(data != null) { + if(data.length() != var4) { throw new RuntimeException("NO!"); } this.data = data; @@ -159,12 +159,12 @@ public class BitStorage { public void getAll(IntConsumer var0) { int var1 = 0; - for (int i = 0; i < data.length(); i++) { + for(int i = 0; i < data.length(); i++) { long var5 = data.get(i); - for (int var7 = 0; var7 < this.valuesPerLong; var7++) { + for(int var7 = 0; var7 < this.valuesPerLong; var7++) { var0.accept((int) (var5 & this.mask)); var5 >>= this.bits; - if (++var1 >= this.size) + if(++var1 >= this.size) return; } } diff --git a/src/main/java/com/volmit/iris/util/data/palette/CrudeIncrementalIntIdentityHashBiMap.java b/src/main/java/com/volmit/iris/util/data/palette/CrudeIncrementalIntIdentityHashBiMap.java index 49bcf4309..393d3f05e 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/CrudeIncrementalIntIdentityHashBiMap.java +++ b/src/main/java/com/volmit/iris/util/data/palette/CrudeIncrementalIntIdentityHashBiMap.java @@ -48,14 +48,14 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { public K byId(int var0) { - if (var0 < 0 || var0 >= this.byId.length()) { + if(var0 < 0 || var0 >= this.byId.length()) { return null; } return this.byId.get(var0); } private int getValue(int var0) { - if (var0 == -1) { + if(var0 == -1) { return -1; } return this.values.get(var0); @@ -76,7 +76,7 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { } private int nextId() { - while (nextId < byId.length() && byId.get(nextId) != null) { + while(nextId < byId.length() && byId.get(nextId) != null) { nextId++; } return nextId; @@ -90,8 +90,8 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { this.byId = new AtomicReferenceArray<>(var0); this.nextId = 0; this.size = 0; - for (int var3 = 0; var3 < var1.length(); var3++) { - if (var1.get(var3) != null) { + for(int var3 = 0; var3 < var1.length(); var3++) { + if(var1.get(var3) != null) { addMapping(var1.get(var3), var2.get(var3)); } } @@ -99,9 +99,9 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { public void addMapping(K var0, int var1) { int var2 = Math.max(var1, this.size + 1); - if (var2 >= this.keys.length() * 0.8F) { + if(var2 >= this.keys.length() * 0.8F) { int i = this.keys.length() << 1; - while (i < var1) + while(i < var1) i <<= 1; grow(i); } @@ -110,7 +110,7 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { this.values.set(var3, var1); this.byId.set(var1, var0); this.size++; - if (var1 == this.nextId) + if(var1 == this.nextId) this.nextId++; } @@ -120,19 +120,19 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { private int indexOf(K var0, int var1) { int var2; - for (var2 = var1; var2 < this.keys.length(); var2++) { - if (this.keys.get(var2) == null) { + for(var2 = var1; var2 < this.keys.length(); var2++) { + if(this.keys.get(var2) == null) { return 0; } - if (this.keys.get(var2).equals(var0)) + if(this.keys.get(var2).equals(var0)) return var2; - if (this.keys.get(var2) == EMPTY_SLOT) + if(this.keys.get(var2) == EMPTY_SLOT) return -1; } - for (var2 = 0; var2 < var1; var2++) { - if (this.keys.get(var2).equals(var0)) + for(var2 = 0; var2 < var1; var2++) { + if(this.keys.get(var2).equals(var0)) return var2; - if (this.keys.get(var2) == EMPTY_SLOT) + if(this.keys.get(var2) == EMPTY_SLOT) return -1; } return -1; @@ -140,12 +140,12 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { private int findEmpty(int var0) { int var1; - for (var1 = var0; var1 < this.keys.length(); var1++) { - if (this.keys.get(var1) == EMPTY_SLOT) + for(var1 = var0; var1 < this.keys.length(); var1++) { + if(this.keys.get(var1) == EMPTY_SLOT) return var1; } - for (var1 = 0; var1 < var0; var1++) { - if (this.keys.get(var1) == EMPTY_SLOT) + for(var1 = 0; var1 < var0; var1++) { + if(this.keys.get(var1) == EMPTY_SLOT) return var1; } throw new RuntimeException("Overflowed :("); @@ -169,12 +169,12 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { public void clear() { - for (int i = 0; i < Math.max(keys.length(), byId.length()); i++) { - if (i < keys.length() - 1) { + for(int i = 0; i < Math.max(keys.length(), byId.length()); i++) { + if(i < keys.length() - 1) { keys.set(i, null); } - if (i < byId.length() - 1) { + if(i < byId.length() - 1) { byId.set(i, null); } } diff --git a/src/main/java/com/volmit/iris/util/data/palette/GlobalPalette.java b/src/main/java/com/volmit/iris/util/data/palette/GlobalPalette.java index 5f76e0e46..f5556cfec 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/GlobalPalette.java +++ b/src/main/java/com/volmit/iris/util/data/palette/GlobalPalette.java @@ -28,7 +28,7 @@ public class GlobalPalette implements Palette { public GlobalPalette(T... f) { IdMapper mapper = new IdMapper<>(); - for (T i : f) { + for(T i : f) { mapper.add(i); } registry = mapper; diff --git a/src/main/java/com/volmit/iris/util/data/palette/HashMapPalette.java b/src/main/java/com/volmit/iris/util/data/palette/HashMapPalette.java index e01bd848a..1d0ca6e81 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/HashMapPalette.java +++ b/src/main/java/com/volmit/iris/util/data/palette/HashMapPalette.java @@ -37,14 +37,14 @@ public class HashMapPalette implements Palette { } public int idFor(T var0) { - if (var0 == null) { + if(var0 == null) { return 0; } return this.values.computeIfAbsent(var0, (k) -> { int newId = id++; - if (newId >= 1 << this.bits) { + if(newId >= 1 << this.bits) { Iris.info(newId + " to..."); newId = this.resizeHandler.onResize(this.bits + 1, var0); Iris.info(newId + ".."); diff --git a/src/main/java/com/volmit/iris/util/data/palette/IdMapper.java b/src/main/java/com/volmit/iris/util/data/palette/IdMapper.java index a9d840d60..778c5a2b0 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/IdMapper.java +++ b/src/main/java/com/volmit/iris/util/data/palette/IdMapper.java @@ -49,11 +49,11 @@ public class IdMapper implements IdMap { public void addMapping(T var0, int var1) { this.tToId.put(var0, Integer.valueOf(var1)); - while (this.idToT.size() <= var1) { + while(this.idToT.size() <= var1) { this.idToT.add(null); } this.idToT.set(var1, var0); - if (this.nextId <= var1) + if(this.nextId <= var1) this.nextId = var1 + 1; } @@ -67,7 +67,7 @@ public class IdMapper implements IdMap { } public final T byId(int var0) { - if (var0 >= 0 && var0 < this.idToT.size()) { + if(var0 >= 0 && var0 < this.idToT.size()) { return this.idToT.get(var0); } return null; diff --git a/src/main/java/com/volmit/iris/util/data/palette/LinearPalette.java b/src/main/java/com/volmit/iris/util/data/palette/LinearPalette.java index f8dd5ca54..7f529c80b 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/LinearPalette.java +++ b/src/main/java/com/volmit/iris/util/data/palette/LinearPalette.java @@ -35,17 +35,17 @@ public class LinearPalette implements Palette { public int idFor(T var0) { int var1; - for (var1 = 0; var1 < size; var1++) { - if (values.get(var1) == null && var0 == null) { + for(var1 = 0; var1 < size; var1++) { + if(values.get(var1) == null && var0 == null) { return var1; } - if (values.get(var1) != null && values.get(var1).equals(var0)) { + if(values.get(var1) != null && values.get(var1).equals(var0)) { return var1; } } var1 = size; - if (var1 < values.length()) { + if(var1 < values.length()) { values.set(var1, var0); size++; return var1; @@ -54,7 +54,7 @@ public class LinearPalette implements Palette { } public T valueFor(int var0) { - if (var0 >= 0 && var0 < size) { + if(var0 >= 0 && var0 < size) { return this.values.get(var0); } return null; @@ -66,7 +66,7 @@ public class LinearPalette implements Palette { @Override public void read(List fromList) { - for (int i = 0; i < fromList.size(); i++) { + for(int i = 0; i < fromList.size(); i++) { values.set(i, fromList.get(i)); } @@ -75,7 +75,7 @@ public class LinearPalette implements Palette { @Override public void write(List toList) { - for (int i = 0; i < size; i++) { + for(int i = 0; i < size; i++) { T v = values.get(i); toList.add(v); } diff --git a/src/main/java/com/volmit/iris/util/data/palette/Mth.java b/src/main/java/com/volmit/iris/util/data/palette/Mth.java index 62c25608c..efd6f5108 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/Mth.java +++ b/src/main/java/com/volmit/iris/util/data/palette/Mth.java @@ -41,11 +41,11 @@ public class Mth { private static final float[] SIN; private static final Random RANDOM = new Random(); - private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{ - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, - 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, - 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, - 10, 9}; + private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[] { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, + 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, + 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, + 10, 9}; private static final double ONE_SIXTH = 0.16666666666666666D; private static final int FRAC_EXP = 8; private static final int LUT_SIZE = 257; @@ -55,13 +55,13 @@ public class Mth { static { SIN = make(new float[65536], var0 -> { - for (int var1 = 0; var1 < var0.length; var1++) + for(int var1 = 0; var1 < var0.length; var1++) var0[var1] = (float) Math.sin(var1 * Math.PI * 2.0D / 65536.0D); }); } static { - for (int var0 = 0; var0 < 257; var0++) { + for(int var0 = 0; var0 < 257; var0++) { double var1 = var0 / 256.0D; double var3 = Math.asin(var1); COS_TAB[var0] = Math.cos(var3); @@ -132,65 +132,65 @@ public class Mth { } public static byte clamp(byte var0, byte var1, byte var2) { - if (var0 < var1) + if(var0 < var1) return var1; - if (var0 > var2) + if(var0 > var2) return var2; return var0; } public static int clamp(int var0, int var1, int var2) { - if (var0 < var1) + if(var0 < var1) return var1; - if (var0 > var2) + if(var0 > var2) return var2; return var0; } public static long clamp(long var0, long var2, long var4) { - if (var0 < var2) + if(var0 < var2) return var2; - if (var0 > var4) + if(var0 > var4) return var4; return var0; } public static float clamp(float var0, float var1, float var2) { - if (var0 < var1) + if(var0 < var1) return var1; - if (var0 > var2) + if(var0 > var2) return var2; return var0; } public static double clamp(double var0, double var2, double var4) { - if (var0 < var2) + if(var0 < var2) return var2; - if (var0 > var4) + if(var0 > var4) return var4; return var0; } public static double clampedLerp(double var0, double var2, double var4) { - if (var4 < 0.0D) + if(var4 < 0.0D) return var0; - if (var4 > 1.0D) + if(var4 > 1.0D) return var2; return lerp(var4, var0, var2); } public static float clampedLerp(float var0, float var1, float var2) { - if (var2 < 0.0F) + if(var2 < 0.0F) return var0; - if (var2 > 1.0F) + if(var2 > 1.0F) return var1; return lerp(var2, var0, var1); } public static double absMax(double var0, double var2) { - if (var0 < 0.0D) + if(var0 < 0.0D) var0 = -var0; - if (var2 < 0.0D) + if(var2 < 0.0D) var2 = -var2; return (var0 > var2) ? var0 : var2; } @@ -200,26 +200,26 @@ public class Mth { } public static int nextInt(Random var0, int var1, int var2) { - if (var1 >= var2) + if(var1 >= var2) return var1; return var0.nextInt(var2 - var1 + 1) + var1; } public static float nextFloat(Random var0, float var1, float var2) { - if (var1 >= var2) + if(var1 >= var2) return var1; return var0.nextFloat() * (var2 - var1) + var1; } public static double nextDouble(Random var0, double var1, double var3) { - if (var1 >= var3) + if(var1 >= var3) return var1; return var0.nextDouble() * (var3 - var1) + var1; } public static double average(long[] var0) { long var1 = 0L; - for (long var6 : var0) + for(long var6 : var0) var1 += var6; return var1 / var0.length; } @@ -246,27 +246,27 @@ public class Mth { public static int wrapDegrees(int var0) { int var1 = var0 % 360; - if (var1 >= 180) + if(var1 >= 180) var1 -= 360; - if (var1 < -180) + if(var1 < -180) var1 += 360; return var1; } public static float wrapDegrees(float var0) { float var1 = var0 % 360.0F; - if (var1 >= 180.0F) + if(var1 >= 180.0F) var1 -= 360.0F; - if (var1 < -180.0F) + if(var1 < -180.0F) var1 += 360.0F; return var1; } public static double wrapDegrees(double var0) { double var2 = var0 % 360.0D; - if (var2 >= 180.0D) + if(var2 >= 180.0D) var2 -= 360.0D; - if (var2 < -180.0D) + if(var2 < -180.0D) var2 += 360.0D; return var2; } @@ -287,7 +287,7 @@ public class Mth { public static float approach(float var0, float var1, float var2) { var2 = abs(var2); - if (var0 < var1) + if(var0 < var1) return clamp(var0 + var2, var0, var1); return clamp(var0 - var2, var1, var0); } @@ -308,7 +308,7 @@ public class Mth { public static double getDouble(String var0, double var1) { try { return Double.parseDouble(var0); - } catch (Throwable var3) { + } catch(Throwable var3) { return var1; } } @@ -404,16 +404,16 @@ public class Mth { public static double atan2(double var0, double var2) { double var4 = var2 * var2 + var0 * var0; - if (Double.isNaN(var4)) + if(Double.isNaN(var4)) return Double.NaN; boolean var6 = (var0 < 0.0D); - if (var6) + if(var6) var0 = -var0; boolean var7 = (var2 < 0.0D); - if (var7) + if(var7) var2 = -var2; boolean var8 = (var0 > var2); - if (var8) { + if(var8) { double d = var2; var2 = var0; var0 = d; @@ -429,11 +429,11 @@ public class Mth { double var20 = var0 * var16 - var2 * var18; double var22 = (6.0D + var20 * var20) * var20 * 0.16666666666666666D; double var24 = var14 + var22; - if (var8) + if(var8) var24 = 1.5707963267948966D - var24; - if (var7) + if(var7) var24 = Math.PI - var24; - if (var6) + if(var6) var24 = -var24; return var24; } @@ -472,7 +472,7 @@ public class Mth { float var5 = var2 * (1.0F - var1); float var6 = var2 * (1.0F - var4 * var1); float var7 = var2 * (1.0F - (1.0F - var4) * var1); - switch (var3) { + switch(var3) { case 0: var8 = var2; var9 = var7; @@ -545,20 +545,20 @@ public class Mth { public static double[] cumulativeSum(double... var0) { float var1 = 0.0F; - for (double var5 : var0) + for(double var5 : var0) var1 = (float) (var1 + var5); int var2; - for (var2 = 0; var2 < var0.length; var2++) + for(var2 = 0; var2 < var0.length; var2++) var0[var2] = var0[var2] / var1; - for (var2 = 0; var2 < var0.length; var2++) + for(var2 = 0; var2 < var0.length; var2++) var0[var2] = ((var2 == 0) ? 0.0D : var0[var2 - 1]) + var0[var2]; return var0; } public static int getRandomForDistributionIntegral(Random var0, double[] var1) { double var2 = var0.nextDouble(); - for (int var4 = 0; var4 < var1.length; var4++) { - if (var2 < var1[var4]) + for(int var4 = 0; var4 < var1.length; var4++) { + if(var2 < var1[var4]) return var4; } return var1.length; @@ -567,10 +567,10 @@ public class Mth { public static double[] binNormalDistribution(double var0, double var2, double var4, int var6, int var7) { double[] var8 = new double[var7 - var6 + 1]; int var9 = 0; - for (int var10 = var6; var10 <= var7; var10++) { + for(int var10 = var6; var10 <= var7; var10++) { var8[var9] = Math.max(0.0D, var0 * - StrictMath.exp(-(var10 - var4) * (var10 - var4) / 2.0D * var2 * var2)); + StrictMath.exp(-(var10 - var4) * (var10 - var4) / 2.0D * var2 * var2)); var9++; } return var8; @@ -579,11 +579,11 @@ public class Mth { public static double[] binBiModalNormalDistribution(double var0, double var2, double var4, double var6, double var8, double var10, int var12, int var13) { double[] var14 = new double[var13 - var12 + 1]; int var15 = 0; - for (int var16 = var12; var16 <= var13; var16++) { + for(int var16 = var12; var16 <= var13; var16++) { var14[var15] = Math.max(0.0D, var0 * - StrictMath.exp(-(var16 - var4) * (var16 - var4) / 2.0D * var2 * var2) + var6 * - StrictMath.exp(-(var16 - var10) * (var16 - var10) / 2.0D * var8 * var8)); + StrictMath.exp(-(var16 - var4) * (var16 - var4) / 2.0D * var2 * var2) + var6 * + StrictMath.exp(-(var16 - var10) * (var16 - var10) / 2.0D * var8 * var8)); var15++; } return var14; @@ -592,7 +592,7 @@ public class Mth { public static double[] binLogDistribution(double var0, double var2, int var4, int var5) { double[] var6 = new double[var5 - var4 + 1]; int var7 = 0; - for (int var8 = var4; var8 <= var5; var8++) { + for(int var8 = var4; var8 <= var5; var8++) { var6[var7] = Math.max(var0 * StrictMath.log(var8) + var2, 0.0D); var7++; } @@ -610,15 +610,15 @@ public class Mth { public static double lerp2(double var0, double var2, double var4, double var6, double var8, double var10) { return lerp(var2, - lerp(var0, var4, var6), - lerp(var0, var8, var10)); + lerp(var0, var4, var6), + lerp(var0, var8, var10)); } public static double lerp3(double var0, double var2, double var4, double var6, double var8, double var10, double var12, double var14, double var16, double var18, double var20) { return lerp(var4, - lerp2(var0, var2, var6, var8, var10, var12), - lerp2(var0, var2, var14, var16, var18, var20)); + lerp2(var0, var2, var6, var8, var10, var12), + lerp2(var0, var2, var14, var16, var18, var20)); } public static double smoothstep(double var0) { @@ -630,7 +630,7 @@ public class Mth { } public static int sign(double var0) { - if (var0 == 0.0D) + if(var0 == 0.0D) return 0; return (var0 > 0.0D) ? 1 : -1; } @@ -646,18 +646,18 @@ public class Mth { @Deprecated public static float rotlerp(float var0, float var1, float var2) { float var3 = var1 - var0; - while (var3 < -180.0F) + while(var3 < -180.0F) var3 += 360.0F; - while (var3 >= 180.0F) + while(var3 >= 180.0F) var3 -= 360.0F; return var0 + var2 * var3; } @Deprecated public static float rotWrap(double var0) { - while (var0 >= 180.0D) + while(var0 >= 180.0D) var0 -= 360.0D; - while (var0 < -180.0D) + while(var0 < -180.0D) var0 += 360.0D; return (float) var0; } diff --git a/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java b/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java index a7e2eccc0..68d65e7cf 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java +++ b/src/main/java/com/volmit/iris/util/data/palette/PaletteType.java @@ -33,7 +33,7 @@ public interface PaletteType { default void writeList(DataOutputStream dos, List list) throws IOException { Varint.writeUnsignedVarInt(list.size(), dos); - for (T i : list) { + for(T i : list) { writePaletteNode(dos, i); } } @@ -42,7 +42,7 @@ public interface PaletteType { int v = Varint.readUnsignedVarInt(din); List t = new ArrayList<>(); - for (int i = 0; i < v; i++) { + for(int i = 0; i < v; i++) { t.add(readPaletteNode(din)); } diff --git a/src/main/java/com/volmit/iris/util/data/palette/PalettedContainer.java b/src/main/java/com/volmit/iris/util/data/palette/PalettedContainer.java index 075946a32..c3bb36181 100644 --- a/src/main/java/com/volmit/iris/util/data/palette/PalettedContainer.java +++ b/src/main/java/com/volmit/iris/util/data/palette/PalettedContainer.java @@ -43,11 +43,11 @@ public class PalettedContainer implements PaletteResize { } private void setBits(int var0) { - if (var0 == this.bits) { + if(var0 == this.bits) { return; } this.bits = var0; - if (this.bits <= 4) { + if(this.bits <= 4) { this.bits = 4; this.palette = new LinearPalette<>(this.bits, this); } else { @@ -62,9 +62,9 @@ public class PalettedContainer implements PaletteResize { BitStorage var2 = this.storage; Palette var3 = this.palette; setBits(var0); - for (int var4 = 0; var4 < var2.getSize(); var4++) { + for(int var4 = 0; var4 < var2.getSize(); var4++) { T var5 = var3.valueFor(var2.get(var4)); - if (var5 != null) { + if(var5 != null) { set(var4, var5); } } @@ -93,7 +93,7 @@ public class PalettedContainer implements PaletteResize { private void set(int var0, T var1) { int var2 = this.palette.idFor(var1); - if (M.r(0.003)) { + if(M.r(0.003)) { Iris.info("ID for " + var1 + " is " + var2 + " Palette: " + palette.getSize()); } @@ -110,17 +110,17 @@ public class PalettedContainer implements PaletteResize { public void read(List palette, long[] data) { int var2 = Math.max(4, Mth.ceillog2(palette.size())); - if (var2 != this.bits) { + if(var2 != this.bits) { setBits(var2); } this.palette.read(palette); int var3 = data.length * 64 / 4096; - if (var3 == this.bits) { + if(var3 == this.bits) { System.arraycopy(data, 0, this.storage.getRaw(), 0, data.length); } else { BitStorage var4 = new BitStorage(var3, 4096, data); - for (int var5 = 0; var5 < 4096; var5++) { + for(int var5 = 0; var5 < 4096; var5++) { this.storage.set(var5, var4.get(var5)); } } @@ -131,9 +131,9 @@ public class PalettedContainer implements PaletteResize { T var4 = null; int var5 = 0; int[] var6 = new int[4096]; - for (int i = 0; i < 4096; i++) { + for(int i = 0; i < 4096; i++) { T t = get(i); - if (t != var4) { + if(t != var4) { var4 = t; var5 = var3.idFor(t); } @@ -143,7 +143,7 @@ public class PalettedContainer implements PaletteResize { var3.write(toList); int var8 = Math.max(4, Mth.ceillog2(toList.size())); BitStorage var9 = new BitStorage(var8, 4096); - for (int var10 = 0; var10 < var6.length; var10++) { + for(int var10 = 0; var10 < var6.length; var10++) { var9.set(var10, var6[var10]); } return var9.getRaw(); diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeContext.java b/src/main/java/com/volmit/iris/util/decree/DecreeContext.java index 82a9ebdc9..41de8d417 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeContext.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeContext.java @@ -31,12 +31,12 @@ public class DecreeContext { } public static void touch(VolmitSender c) { - synchronized (context) { + synchronized(context) { context.put(Thread.currentThread(), c); - if (cl.flip()) { - for (Thread i : context.k()) { - if (!i.isAlive()) { + if(cl.flip()) { + for(Thread i : context.k()) { + if(!i.isAlive()) { context.remove(i); } } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeContextHandler.java b/src/main/java/com/volmit/iris/util/decree/DecreeContextHandler.java index 27d567102..edcf0019f 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeContextHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeContextHandler.java @@ -30,8 +30,8 @@ public interface DecreeContextHandler { try { Iris.initialize("com.volmit.iris.util.decree.context").forEach((i) - -> contextHandlers.put(((DecreeContextHandler) i).getType(), (DecreeContextHandler) i)); - } catch (Throwable e) { + -> contextHandlers.put(((DecreeContextHandler) i).getType(), (DecreeContextHandler) i)); + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java index 6f2753883..1fb827e12 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java @@ -35,9 +35,9 @@ public interface DecreeExecutor { } default Engine engine() { - if (sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) { + if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) { PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld()); - if (gen != null) { + if(gen != null) { return gen.getEngine(); } } @@ -46,14 +46,14 @@ public interface DecreeExecutor { } default PlatformChunkGenerator access() { - if (sender().isPlayer()) { + if(sender().isPlayer()) { return IrisToolbelt.access(world()); } return null; } default World world() { - if (sender().isPlayer()) { + if(sender().isPlayer()) { return sender().player().getWorld(); } return null; diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeNode.java b/src/main/java/com/volmit/iris/util/decree/DecreeNode.java index 770218c6a..c91581d04 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeNode.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeNode.java @@ -36,7 +36,7 @@ public class DecreeNode { this.instance = instance; this.method = method; this.decree = method.getDeclaredAnnotation(Decree.class); - if (decree == null) { + if(decree == null) { throw new RuntimeException("Cannot instantiate DecreeNode on method " + method.getName() + " in " + method.getDeclaringClass().getCanonicalName() + " not annotated by @Decree"); } } @@ -50,9 +50,9 @@ public class DecreeNode { KList required = new KList<>(); KList optional = new KList<>(); - for (Parameter i : method.getParameters()) { + for(Parameter i : method.getParameters()) { DecreeParameter p = new DecreeParameter(i); - if (p.isRequired()) { + if(p.isRequired()) { required.add(p); } else { optional.add(p); @@ -80,8 +80,8 @@ public class DecreeNode { KList d = new KList<>(); d.add(getName()); - for (String i : decree.aliases()) { - if (i.isEmpty()) { + for(String i : decree.aliases()) { + if(i.isEmpty()) { continue; } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeOrigin.java b/src/main/java/com/volmit/iris/util/decree/DecreeOrigin.java index c234ce59e..05ecb09db 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeOrigin.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeOrigin.java @@ -31,11 +31,12 @@ public enum DecreeOrigin { /** * Check if the origin is valid for a sender * - * @param sender The sender to check + * @param sender + * The sender to check * @return True if valid for origin */ public boolean validFor(VolmitSender sender) { - if (sender.isPlayer()) { + if(sender.isPlayer()) { return this.equals(PLAYER) || this.equals(BOTH); } else { return this.equals(CONSOLE) || this.equals(BOTH); diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java index aaa19c519..53d3a40c3 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java @@ -36,7 +36,7 @@ public class DecreeParameter { public DecreeParameter(Parameter parameter) { this.parameter = parameter; this.param = parameter.getDeclaredAnnotation(Param.class); - if (param == null) { + if(param == null) { throw new RuntimeException("Cannot instantiate DecreeParameter on " + parameter.getName() + " in method " + parameter.getDeclaringExecutable().getName() + "(...) in class " + parameter.getDeclaringExecutable().getDeclaringClass().getCanonicalName() + " not annotated by @Param"); } } @@ -44,12 +44,12 @@ public class DecreeParameter { public DecreeParameterHandler getHandler() { return handlerCache.aquire(() -> { try { - if (param.customHandler().equals(DummyHandler.class)) { + if(param.customHandler().equals(DummyHandler.class)) { return DecreeSystem.getHandler(getType()); } return param.customHandler().getConstructor().newInstance(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -76,8 +76,8 @@ public class DecreeParameter { public KList getNames() { KList d = new KList<>(); - for (String i : param.aliases()) { - if (i.isEmpty()) { + for(String i : param.aliases()) { + if(i.isEmpty()) { continue; } @@ -102,7 +102,7 @@ public class DecreeParameter { KList ff = getHandler().getPossibilities(); ff = ff != null ? ff : new KList<>(); KList f = ff.convert((i) -> getHandler().toStringForce(i)); - if (f.isEmpty()) { + if(f.isEmpty()) { f = new KList<>(); f.add(getHandler().getRandomDefault()); } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeParameterHandler.java b/src/main/java/com/volmit/iris/util/decree/DecreeParameterHandler.java index c2d340e51..0c1f3e6a7 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeParameterHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeParameterHandler.java @@ -38,7 +38,8 @@ public interface DecreeParameterHandler { /** * Converting the type back to a string (inverse of the {@link #parse(String) parse} method) * - * @param t The input of the designated type to convert to a String + * @param t + * The input of the designated type to convert to a String * @return The resulting string */ String toString(T t); @@ -46,7 +47,8 @@ public interface DecreeParameterHandler { /** * Forces conversion to the designated type before converting to a string using {@link #toString(T t)} * - * @param t The object to convert to string (that should be of this type) + * @param t + * The object to convert to string (that should be of this type) * @return The resulting string. */ default String toStringForce(Object t) { @@ -56,9 +58,11 @@ public interface DecreeParameterHandler { /** * Should parse a String into the designated type * - * @param in The string to parse + * @param in + * The string to parse * @return The value extracted from the string, of the designated type - * @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this) + * @throws DecreeParsingException + * Thrown when the parsing fails (ex: "oop" translated to an integer throws this) */ default T parse(String in) throws DecreeParsingException { return parse(in, false); @@ -67,17 +71,21 @@ public interface DecreeParameterHandler { /** * Should parse a String into the designated type. You can force it to not throw a whichexception * - * @param in The string to parse - * @param force force an option instead of throwing decreewhich + * @param in + * The string to parse + * @param force + * force an option instead of throwing decreewhich * @return The value extracted from the string, of the designated type - * @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this) + * @throws DecreeParsingException + * Thrown when the parsing fails (ex: "oop" translated to an integer throws this) */ T parse(String in, boolean force) throws DecreeParsingException; /** * Returns whether a certain type is supported by this handler
* - * @param type The type to check + * @param type + * The type to check * @return True if supported, false if not */ boolean supports(Class type); @@ -85,11 +93,12 @@ public interface DecreeParameterHandler { /** * The possible entries for the inputted string (support for autocomplete on partial entries) * - * @param input The inputted string to check against + * @param input + * The inputted string to check against * @return A {@link KList} of possibilities */ default KList getPossibilities(String input) { - if (input.trim().isEmpty()) { + if(input.trim().isEmpty()) { KList f = getPossibilities(); return f == null ? new KList<>() : f; } @@ -98,23 +107,23 @@ public interface DecreeParameterHandler { KList possible = getPossibilities(); KList matches = new KList<>(); - if (possible == null || possible.isEmpty()) { + if(possible == null || possible.isEmpty()) { return matches; } - if (input.isEmpty()) { + if(input.isEmpty()) { return getPossibilities(); } KList converted = possible.convert(v -> toString(v).trim()); - for (int i = 0; i < converted.size(); i++) { + for(int i = 0; i < converted.size(); i++) { String g = converted.get(i); // if // G == I or // I in G or // G in I - if (g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase())) { + if(g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase())) { matches.add(possible.get(i)); } } @@ -130,28 +139,28 @@ public interface DecreeParameterHandler { double multiplier = 1; String in = g.get(); boolean valid = true; - while (valid) { + while(valid) { boolean trim = false; - if (in.toLowerCase().endsWith("k")) { + if(in.toLowerCase().endsWith("k")) { multiplier *= 1000; trim = true; - } else if (in.toLowerCase().endsWith("m")) { + } else if(in.toLowerCase().endsWith("m")) { multiplier *= 1000000; trim = true; - } else if (in.toLowerCase().endsWith("h")) { + } else if(in.toLowerCase().endsWith("h")) { multiplier *= 100; trim = true; - } else if (in.toLowerCase().endsWith("c")) { + } else if(in.toLowerCase().endsWith("c")) { multiplier *= 16; trim = true; - } else if (in.toLowerCase().endsWith("r")) { + } else if(in.toLowerCase().endsWith("r")) { multiplier *= (16 * 32); trim = true; } else { valid = false; } - if (trim) { + if(trim) { in = in.substring(0, in.length() - 1); } } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java b/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java index 70d1b8688..59d9928d5 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java @@ -47,20 +47,20 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { static KList enhanceArgs(String[] args, boolean trim) { KList a = new KList<>(); - if (args.length == 0) { + if(args.length == 0) { return a; } StringBuilder flat = new StringBuilder(); - for (String i : args) { - if (trim) { - if (i.trim().isEmpty()) { + for(String i : args) { + if(trim) { + if(i.trim().isEmpty()) { continue; } flat.append(" ").append(i.trim()); } else { - if (i.endsWith(" ")) { + if(i.endsWith(" ")) { flat.append(" ").append(i.trim()).append(" "); } } @@ -70,29 +70,29 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { StringBuilder arg = new StringBuilder(); boolean quoting = false; - for (int x = 0; x < flat.length(); x++) { + for(int x = 0; x < flat.length(); x++) { char i = flat.charAt(x); char j = x < flat.length() - 1 ? flat.charAt(x + 1) : i; boolean hasNext = x < flat.length(); - if (i == ' ' && !quoting) { - if (!arg.toString().trim().isEmpty() && trim) { + if(i == ' ' && !quoting) { + if(!arg.toString().trim().isEmpty() && trim) { a.add(arg.toString().trim()); arg = new StringBuilder(); } - } else if (i == '"') { - if (!quoting && (arg.length() == 0)) { + } else if(i == '"') { + if(!quoting && (arg.length() == 0)) { quoting = true; - } else if (quoting) { + } else if(quoting) { quoting = false; - if (hasNext && j == ' ') { - if (!arg.toString().trim().isEmpty() && trim) { + if(hasNext && j == ' ') { + if(!arg.toString().trim().isEmpty() && trim) { a.add(arg.toString().trim()); arg = new StringBuilder(); } - } else if (!hasNext) { - if (!arg.toString().trim().isEmpty() && trim) { + } else if(!hasNext) { + if(!arg.toString().trim().isEmpty() && trim) { a.add(arg.toString().trim()); arg = new StringBuilder(); } @@ -103,7 +103,7 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { } } - if (!arg.toString().trim().isEmpty() && trim) { + if(!arg.toString().trim().isEmpty() && trim) { a.add(arg.toString().trim()); } @@ -113,12 +113,13 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { /** * Get the handler for the specified type * - * @param type The type to handle + * @param type + * The type to handle * @return The corresponding {@link DecreeParameterHandler}, or null */ static DecreeParameterHandler getHandler(Class type) { - for (DecreeParameterHandler i : handlers) { - if (i.supports(type)) { + for(DecreeParameterHandler i : handlers) { + if(i.supports(type)) { return i; } } @@ -128,8 +129,6 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { /** * The root class to start command searching from - * - * @return */ VirtualDecreeCommand getRoot(); @@ -145,8 +144,8 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { KList v = getRoot().tabComplete(enhanced, enhanced.toString(" ")); v.removeDuplicates(); - if (sender instanceof Player) { - if (IrisSettings.get().getGeneral().isCommandSounds()) { + if(sender instanceof Player) { + if(IrisSettings.get().getGeneral().isCommandSounds()) { ((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f)); } } @@ -156,16 +155,16 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { @Override default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (!sender.hasPermission("iris.all")) { + if(!sender.hasPermission("iris.all")) { sender.sendMessage("You lack the Permission 'iris.all'"); return true; } J.aBukkit(() -> { - if (!call(new VolmitSender(sender), args)) { + if(!call(new VolmitSender(sender), args)) { - if (IrisSettings.get().getGeneral().isCommandSounds()) { - if (sender instanceof Player) { + if(IrisSettings.get().getGeneral().isCommandSounds()) { + if(sender instanceof Player) { ((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.25f); ((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.2f, 0.45f); } @@ -173,8 +172,8 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { sender.sendMessage(C.RED + "Unknown Iris Command"); } else { - if (IrisSettings.get().getGeneral().isCommandSounds()) { - if (sender instanceof Player) { + if(IrisSettings.get().getGeneral().isCommandSounds()) { + if(sender instanceof Player) { ((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 1.65f); ((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 0.125f, 2.99f); } diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java b/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java index 847027429..83048e140 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java @@ -63,7 +63,8 @@ public @interface Decree { DecreeOrigin origin() default DecreeOrigin.BOTH; /** - * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))
+ * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of + * method))
* Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})
* If someone uses /plugin foo and you specify alias="f" here, /plugin f will do the exact same. */ diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java index e05a751d5..1fcd66af5 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java @@ -53,7 +53,8 @@ public @interface Param { String defaultValue() default ""; /** - * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))
+ * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of + * method))
* Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})
* If someone uses /plugin foo bar=baz and you specify alias="b" here, /plugin foo b=baz will do the exact same. */ diff --git a/src/main/java/com/volmit/iris/util/decree/context/BiomeContextHandler.java b/src/main/java/com/volmit/iris/util/decree/context/BiomeContextHandler.java index 619500ac9..c433f40b8 100644 --- a/src/main/java/com/volmit/iris/util/decree/context/BiomeContextHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/context/BiomeContextHandler.java @@ -29,9 +29,9 @@ public class BiomeContextHandler implements DecreeContextHandler { } public IrisBiome handle(VolmitSender sender) { - if (sender.isPlayer() - && IrisToolbelt.isIrisWorld(sender.player().getWorld()) - && IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) { + if(sender.isPlayer() + && IrisToolbelt.isIrisWorld(sender.player().getWorld()) + && IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) { return IrisToolbelt.access(sender.player().getWorld()).getEngine().getBiomeOrMantle(sender.player().getLocation()); } diff --git a/src/main/java/com/volmit/iris/util/decree/context/DimensionContextHandler.java b/src/main/java/com/volmit/iris/util/decree/context/DimensionContextHandler.java index 6cff3a013..cfc32d3d3 100644 --- a/src/main/java/com/volmit/iris/util/decree/context/DimensionContextHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/context/DimensionContextHandler.java @@ -29,9 +29,9 @@ public class DimensionContextHandler implements DecreeContextHandler { } public IrisRegion handle(VolmitSender sender) { - if (sender.isPlayer() - && IrisToolbelt.isIrisWorld(sender.player().getWorld()) - && IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) { + if(sender.isPlayer() + && IrisToolbelt.isIrisWorld(sender.player().getWorld()) + && IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) { return IrisToolbelt.access(sender.player().getWorld()).getEngine().getRegion(sender.player().getLocation()); } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java index af0e17512..6d1116a91 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java @@ -35,10 +35,10 @@ public class BiomeHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) { + for(IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -56,18 +56,18 @@ public class BiomeHandler implements DecreeParameterHandler { @Override public IrisBiome parse(String in, boolean force) throws DecreeParsingException { - if (in.equals("null")) { + if(in.equals("null")) { return null; } KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Biome \"" + in + "\""); } try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BlockVectorHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BlockVectorHandler.java index 362e0af3a..6c7dc2ab6 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/BlockVectorHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BlockVectorHandler.java @@ -36,7 +36,7 @@ public class BlockVectorHandler implements DecreeParameterHandler { KList vx = new KList<>(); VolmitSender s = DecreeContext.get(); - if (s.isPlayer()) { + if(s.isPlayer()) { vx.add(s.player().getLocation().toVector().toBlockVector()); } @@ -45,7 +45,7 @@ public class BlockVectorHandler implements DecreeParameterHandler { @Override public String toString(BlockVector v) { - if (v.getY() == 0) { + if(v.getY() == 0) { return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockZ(), 2); } @@ -55,43 +55,43 @@ public class BlockVectorHandler implements DecreeParameterHandler { @Override public BlockVector parse(String in, boolean force) throws DecreeParsingException { try { - if (in.contains(",")) { + if(in.contains(",")) { String[] comp = in.split("\\Q,\\E"); - if (comp.length == 2) { + if(comp.length == 2) { return new BlockVector(Integer.parseInt(comp[0].trim()), 0, Integer.parseInt(comp[1].trim())); - } else if (comp.length == 3) { + } else if(comp.length == 3) { return new BlockVector(Integer.parseInt(comp[0].trim()), - Integer.parseInt(comp[1].trim()), - Integer.parseInt(comp[2].trim())); + Integer.parseInt(comp[1].trim()), + Integer.parseInt(comp[2].trim())); } else { throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3."); } - } else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) { - if (!DecreeContext.get().isPlayer()) { + } else if(in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) { + if(!DecreeContext.get().isPlayer()) { throw new DecreeParsingException("You cannot specify me,self,here as a console."); } return DecreeContext.get().player().getLocation().toVector().toBlockVector(); - } else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) { - if (!DecreeContext.get().isPlayer()) { + } else if(in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) { + if(!DecreeContext.get().isPlayer()) { throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console."); } return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector().toBlockVector(); - } else if (in.trim().toLowerCase().startsWith("player:")) { + } else if(in.trim().toLowerCase().startsWith("player:")) { String v = in.trim().split("\\Q:\\E")[1]; KList px = DecreeSystem.getHandler(Player.class).getPossibilities(v); - if (px != null && px.isNotEmpty()) { + if(px != null && px.isNotEmpty()) { return ((Player) px.get(0)).getLocation().toVector().toBlockVector(); - } else if (px == null || px.isEmpty()) { + } else if(px == null || px.isEmpty()) { throw new DecreeParsingException("Cannot find player: " + v); } } - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e); } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java index 1dba545bd..23fdcd15e 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java @@ -37,11 +37,11 @@ public class BooleanHandler implements DecreeParameterHandler { @Override public Boolean parse(String in, boolean force) throws DecreeParsingException { try { - if (in.equals("null") || in.equals("other") || in.equals("flip")) { + if(in.equals("null") || in.equals("other") || in.equals("flip")) { return null; } return Boolean.parseBoolean(in); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse boolean \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/ByteHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/ByteHandler.java index 8c47798b0..a07ea3ed6 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/ByteHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/ByteHandler.java @@ -38,7 +38,7 @@ public class ByteHandler implements DecreeParameterHandler { public Byte parse(String in, boolean force) throws DecreeParsingException { try { return Byte.parseByte(in); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse byte \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/CaveHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/CaveHandler.java index 491104433..1a9a7b7a3 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/CaveHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/CaveHandler.java @@ -21,8 +21,6 @@ package com.volmit.iris.util.decree.handlers; import com.volmit.iris.Iris; import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.engine.object.IrisCave; -import com.volmit.iris.engine.object.IrisJigsawPiece; -import com.volmit.iris.engine.object.IrisJigsawPool; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.decree.DecreeParameterHandler; @@ -37,10 +35,10 @@ public class CaveHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisCave j : data.getCaveLoader().loadAll(data.getCaveLoader().getPossibleKeys())) { + for(IrisCave j : data.getCaveLoader().loadAll(data.getCaveLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -58,16 +56,17 @@ public class CaveHandler implements DecreeParameterHandler { @Override public IrisCave parse(String in, boolean force) throws DecreeParsingException { - if (in.equals("null")) { + if(in.equals("null")) { return null; } KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Cave \"" + in + "\""); - }try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Cave\"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java index 469f012b8..464a8f28f 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java @@ -35,10 +35,10 @@ public class DimensionHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) { + for(IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -58,11 +58,12 @@ public class DimensionHandler implements DecreeParameterHandler { public IrisDimension parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Dimension \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/DoubleHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/DoubleHandler.java index fea306295..eb3374cab 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/DoubleHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/DoubleHandler.java @@ -38,7 +38,7 @@ public class DoubleHandler implements DecreeParameterHandler { AtomicReference r = new AtomicReference<>(in); double m = getMultiplier(r); return Double.parseDouble(r.get()) * m; - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse double \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java index edb976673..54cd4f1b7 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java @@ -41,10 +41,10 @@ public class EntityHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) { + for(IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -58,7 +58,8 @@ public class EntityHandler implements DecreeParameterHandler { /** * Converting the type back to a string (inverse of the {@link #parse(String) parse} method) * - * @param entity The input of the designated type to convert to a String + * @param entity + * The input of the designated type to convert to a String * @return The resulting string */ @Override @@ -69,19 +70,22 @@ public class EntityHandler implements DecreeParameterHandler { /** * Should parse a String into the designated type * - * @param in The string to parse + * @param in + * The string to parse * @return The value extracted from the string, of the designated type - * @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this) + * @throws DecreeParsingException + * Thrown when the parsing fails (ex: "oop" translated to an integer throws this) */ @Override public IrisEntity parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Entity \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } @@ -89,7 +93,8 @@ public class EntityHandler implements DecreeParameterHandler { /** * Returns whether a certain type is supported by this handler
* - * @param type The type to check + * @param type + * The type to check * @return True if supported, false if not */ @Override diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/FloatHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/FloatHandler.java index 88481b988..d4adfeec2 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/FloatHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/FloatHandler.java @@ -38,7 +38,7 @@ public class FloatHandler implements DecreeParameterHandler { AtomicReference r = new AtomicReference<>(in); double m = getMultiplier(r); return (float) (Float.parseFloat(r.get()) * m); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse float \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java index edba57652..2edb3c3c4 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java @@ -35,10 +35,10 @@ public class GeneratorHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) { + for(IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -58,11 +58,12 @@ public class GeneratorHandler implements DecreeParameterHandler { public IrisGenerator parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Generator \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/IntegerHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/IntegerHandler.java index 846d3921d..a83624e66 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/IntegerHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/IntegerHandler.java @@ -37,7 +37,7 @@ public class IntegerHandler implements DecreeParameterHandler { AtomicReference r = new AtomicReference<>(in); double m = getMultiplier(r); return (int) (Integer.valueOf(r.get()).doubleValue() * m); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse integer \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPieceHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPieceHandler.java index 01f747f59..dc1dda575 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPieceHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPieceHandler.java @@ -35,10 +35,10 @@ public class JigsawPieceHandler implements DecreeParameterHandler p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisJigsawPiece j : data.getJigsawPieceLoader().loadAll(data.getJigsawPieceLoader().getPossibleKeys())) { + for(IrisJigsawPiece j : data.getJigsawPieceLoader().loadAll(data.getJigsawPieceLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -56,16 +56,17 @@ public class JigsawPieceHandler implements DecreeParameterHandler options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Jigsaw Piece \"" + in + "\""); - }try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Jigsaw Piece \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPoolHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPoolHandler.java index d58a5f480..9844383cc 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPoolHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/JigsawPoolHandler.java @@ -20,7 +20,6 @@ package com.volmit.iris.util.decree.handlers; import com.volmit.iris.Iris; import com.volmit.iris.core.loader.IrisData; -import com.volmit.iris.engine.object.IrisJigsawPiece; import com.volmit.iris.engine.object.IrisJigsawPool; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; @@ -36,10 +35,10 @@ public class JigsawPoolHandler implements DecreeParameterHandler KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisJigsawPool j : data.getJigsawPoolLoader().loadAll(data.getJigsawPoolLoader().getPossibleKeys())) { + for(IrisJigsawPool j : data.getJigsawPoolLoader().loadAll(data.getJigsawPoolLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -57,16 +56,17 @@ public class JigsawPoolHandler implements DecreeParameterHandler @Override public IrisJigsawPool parse(String in, boolean force) throws DecreeParsingException { - if (in.equals("null")) { + if(in.equals("null")) { return null; } KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Jigsaw Pool \"" + in + "\""); - }try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Jigsaw Pool \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/JigsawStructureHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/JigsawStructureHandler.java index ac4b4582f..6b1082f1a 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/JigsawStructureHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/JigsawStructureHandler.java @@ -35,10 +35,10 @@ public class JigsawStructureHandler implements DecreeParameterHandler p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisJigsawStructure j : data.getJigsawStructureLoader().loadAll(data.getJigsawStructureLoader().getPossibleKeys())) { + for(IrisJigsawStructure j : data.getJigsawStructureLoader().loadAll(data.getJigsawStructureLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -56,16 +56,17 @@ public class JigsawStructureHandler implements DecreeParameterHandler options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Jigsaw Structure \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Jigsaw Structure \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/LongHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/LongHandler.java index 8c0ef12d2..e3dcbbe4b 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/LongHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/LongHandler.java @@ -37,7 +37,7 @@ public class LongHandler implements DecreeParameterHandler { AtomicReference r = new AtomicReference<>(in); double m = getMultiplier(r); return (long) (Long.valueOf(r.get()).doubleValue() * m); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse long \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/PlayerHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/PlayerHandler.java index fe3ebb3c2..39893fe4f 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/PlayerHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/PlayerHandler.java @@ -42,11 +42,12 @@ public class PlayerHandler implements DecreeParameterHandler { public Player parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Player \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java index 9857fd984..aa85bf85a 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java @@ -35,10 +35,10 @@ public class RegionHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) { + for(IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -56,16 +56,17 @@ public class RegionHandler implements DecreeParameterHandler { @Override public IrisRegion parse(String in, boolean force) throws DecreeParsingException { - if (in.equals("null")) { + if(in.equals("null")) { return null; } KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Region \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java index 79f287806..8c846b99a 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java @@ -35,10 +35,10 @@ public class ScriptHandler implements DecreeParameterHandler { KMap p = new KMap<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); - for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) { + for(IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) { p.putIfAbsent(j.getLoadKey(), j); } @@ -58,11 +58,12 @@ public class ScriptHandler implements DecreeParameterHandler { public IrisScript parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Script \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/ShortHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/ShortHandler.java index b9dfc4c66..a833a3b0b 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/ShortHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/ShortHandler.java @@ -37,7 +37,7 @@ public class ShortHandler implements DecreeParameterHandler { AtomicReference r = new AtomicReference<>(in); double m = getMultiplier(r); return (short) (Short.valueOf(r.get()).doubleValue() * m); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to parse short \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/StringHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/StringHandler.java index 932052ca7..4c972ddd5 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/StringHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/StringHandler.java @@ -49,6 +49,6 @@ public class StringHandler implements DecreeParameterHandler { @Override public String getRandomDefault() { return new KList().qadd("text").qadd("string") - .qadd("blah").qadd("derp").qadd("yolo").getRandom(); + .qadd("blah").qadd("derp").qadd("yolo").getRandom(); } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java index fe4e2ab8e..dd75720f8 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java @@ -32,11 +32,11 @@ import org.bukkit.util.Vector; public class VectorHandler implements DecreeParameterHandler { private static final KList randoms = new KList<>( - "here", - "0,0,0", - "0,0", - "look", - "player:" + "here", + "0,0,0", + "0,0", + "look", + "player:" ); @Override @@ -46,7 +46,7 @@ public class VectorHandler implements DecreeParameterHandler { @Override public String toString(Vector v) { - if (v.getY() == 0) { + if(v.getY() == 0) { return Form.f(v.getX(), 2) + "," + Form.f(v.getZ(), 2); } @@ -56,43 +56,43 @@ public class VectorHandler implements DecreeParameterHandler { @Override public Vector parse(String in, boolean force) throws DecreeParsingException { try { - if (in.contains(",")) { + if(in.contains(",")) { String[] comp = in.split("\\Q,\\E"); - if (comp.length == 2) { + if(comp.length == 2) { return new BlockVector(Double.parseDouble(comp[0].trim()), 0, Double.parseDouble(comp[1].trim())); - } else if (comp.length == 3) { + } else if(comp.length == 3) { return new BlockVector(Double.parseDouble(comp[0].trim()), - Double.parseDouble(comp[1].trim()), - Double.parseDouble(comp[2].trim())); + Double.parseDouble(comp[1].trim()), + Double.parseDouble(comp[2].trim())); } else { throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3."); } - } else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) { - if (!DecreeContext.get().isPlayer()) { + } else if(in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) { + if(!DecreeContext.get().isPlayer()) { throw new DecreeParsingException("You cannot specify me,self,here as a console."); } return DecreeContext.get().player().getLocation().toVector(); - } else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) { - if (!DecreeContext.get().isPlayer()) { + } else if(in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) { + if(!DecreeContext.get().isPlayer()) { throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console."); } return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector(); - } else if (in.trim().toLowerCase().startsWith("player:")) { + } else if(in.trim().toLowerCase().startsWith("player:")) { String v = in.trim().split("\\Q:\\E")[1]; KList px = DecreeSystem.getHandler(Player.class).getPossibilities(v); - if (px != null && px.isNotEmpty()) { + if(px != null && px.isNotEmpty()) { return ((Player) px.get(0)).getLocation().toVector(); - } else if (px == null || px.isEmpty()) { + } else if(px == null || px.isEmpty()) { throw new DecreeParsingException("Cannot find player: " + v); } } - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e); } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java index f8ef462e8..8325f5144 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java @@ -30,8 +30,8 @@ public class WorldHandler implements DecreeParameterHandler { @Override public KList getPossibilities() { KList options = new KList<>(); - for (World world : Bukkit.getWorlds()) { - if (!world.getName().toLowerCase().startsWith("iris/")) { + for(World world : Bukkit.getWorlds()) { + if(!world.getName().toLowerCase().startsWith("iris/")) { options.add(world); } } @@ -47,11 +47,12 @@ public class WorldHandler implements DecreeParameterHandler { public World parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find World \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/specialhandlers/ObjectHandler.java b/src/main/java/com/volmit/iris/util/decree/specialhandlers/ObjectHandler.java index 56b4bbbf2..cf01f8b40 100644 --- a/src/main/java/com/volmit/iris/util/decree/specialhandlers/ObjectHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/specialhandlers/ObjectHandler.java @@ -33,8 +33,8 @@ public class ObjectHandler implements DecreeParameterHandler { KList p = new KList<>(); //noinspection ConstantConditions - for (File i : Iris.instance.getDataFolder("packs").listFiles()) { - if (i.isDirectory()) { + for(File i : Iris.instance.getDataFolder("packs").listFiles()) { + if(i.isDirectory()) { IrisData data = IrisData.get(i); p.add(data.getObjectLoader().getPossibleKeys()); } @@ -52,11 +52,12 @@ public class ObjectHandler implements DecreeParameterHandler { public String parse(String in, boolean force) throws DecreeParsingException { KList options = getPossibilities(in); - if (options.isEmpty()) { + if(options.isEmpty()) { throw new DecreeParsingException("Unable to find Object \"" + in + "\""); - } try { + } + try { return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0); - } catch (Throwable e) { + } catch(Throwable e) { throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\""); } } diff --git a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java index 8f231e48f..f2e6434ef 100644 --- a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java +++ b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java @@ -20,7 +20,6 @@ package com.volmit.iris.util.decree.virtual; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; -import com.volmit.iris.core.service.CommandSVC; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KSet; @@ -28,7 +27,6 @@ import com.volmit.iris.util.decree.DecreeContext; import com.volmit.iris.util.decree.DecreeContextHandler; import com.volmit.iris.util.decree.DecreeNode; import com.volmit.iris.util.decree.DecreeParameter; -import com.volmit.iris.util.decree.DecreeParameterHandler; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.format.C; @@ -38,17 +36,11 @@ import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.J; import lombok.Data; -import org.bukkit.Sound; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; @Data @@ -57,13 +49,13 @@ public class VirtualDecreeCommand { private final VirtualDecreeCommand parent; private final KList nodes; private final DecreeNode node; - String[] gradients = new String[]{ - "", - "", - "", - "", - "", - "" + String[] gradients = new String[] { + "", + "", + "", + "", + "", + "" }; private ChronoLatch cl = new ChronoLatch(1000); @@ -81,19 +73,19 @@ public class VirtualDecreeCommand { public static VirtualDecreeCommand createRoot(VirtualDecreeCommand parent, Object v) throws Throwable { VirtualDecreeCommand c = new VirtualDecreeCommand(v.getClass(), parent, new KList<>(), null); - for (Field i : v.getClass().getDeclaredFields()) { - if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isTransient(i.getModifiers()) || Modifier.isVolatile(i.getModifiers())) { + for(Field i : v.getClass().getDeclaredFields()) { + if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isTransient(i.getModifiers()) || Modifier.isVolatile(i.getModifiers())) { continue; } - if (!i.getType().isAnnotationPresent(Decree.class)) { + if(!i.getType().isAnnotationPresent(Decree.class)) { continue; } i.setAccessible(true); Object childRoot = i.get(v); - if (childRoot == null) { + if(childRoot == null) { childRoot = i.getType().getConstructor().newInstance(); i.set(v, childRoot); } @@ -101,12 +93,12 @@ public class VirtualDecreeCommand { c.getNodes().add(createRoot(c, childRoot)); } - for (Method i : v.getClass().getDeclaredMethods()) { - if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers())) { + for(Method i : v.getClass().getDeclaredMethods()) { + if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers())) { continue; } - if (!i.isAnnotationPresent(Decree.class)) { + if(!i.isAnnotationPresent(Decree.class)) { continue; } @@ -119,11 +111,11 @@ public class VirtualDecreeCommand { public void cacheAll() { VolmitSender sender = new VolmitSender(new CommandDummy()); - if (isNode()) { + if(isNode()) { sender.sendDecreeHelpNode(this); } - for (VirtualDecreeCommand j : nodes) { + for(VirtualDecreeCommand j : nodes) { j.cacheAll(); } } @@ -132,7 +124,7 @@ public class VirtualDecreeCommand { KList n = new KList<>(); VirtualDecreeCommand cursor = this; - while (cursor.getParent() != null) { + while(cursor.getParent() != null) { cursor = cursor.getParent(); n.add(cursor.getName()); } @@ -157,15 +149,15 @@ public class VirtualDecreeCommand { } public KList getNames() { - if (isNode()) { + if(isNode()) { return getNode().getNames(); } Decree dc = getType().getDeclaredAnnotation(Decree.class); KList d = new KList<>(); d.add(dc.name()); - for (String i : dc.aliases()) { - if (i.isEmpty()) { + for(String i : dc.aliases()) { + if(i.isEmpty()) { continue; } @@ -189,27 +181,27 @@ public class VirtualDecreeCommand { } private boolean invokeTabComplete(KList args, KList skip, KList tabs, String raw) { - if (isStudio() && !IrisSettings.get().getStudio().isStudio()) { + if(isStudio() && !IrisSettings.get().getStudio().isStudio()) { return false; } - if (isNode()) { + if(isNode()) { tab(args, tabs); skip.add(hashCode()); return false; } - if (args.isEmpty()) { + if(args.isEmpty()) { tab(args, tabs); return true; } String head = args.get(0); - if (args.size() > 1 || head.endsWith(" ")) { + if(args.size() > 1 || head.endsWith(" ")) { VirtualDecreeCommand match = matchNode(head, skip); - if (match != null) { + if(match != null) { args.pop(); return match.invokeTabComplete(args, skip, tabs, raw); } @@ -228,18 +220,18 @@ public class VirtualDecreeCommand { Runnable la = () -> { }; - for (String a : args) { + for(String a : args) { la.run(); last = a; la = () -> { - if (isNode()) { + if(isNode()) { String sea = a.contains("=") ? a.split("\\Q=\\E")[0] : a; sea = sea.trim(); searching: - for (DecreeParameter i : getNode().getParameters()) { - for (String m : i.getNames()) { - if (m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase())) { + for(DecreeParameter i : getNode().getParameters()) { + for(String m : i.getNames()) { + if(m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase())) { ignore.add(i); continue searching; } @@ -249,37 +241,37 @@ public class VirtualDecreeCommand { }; } - if (last != null) { - if (isNode()) { - for (DecreeParameter i : getNode().getParameters()) { - if (ignore.contains(i)) { + if(last != null) { + if(isNode()) { + for(DecreeParameter i : getNode().getParameters()) { + if(ignore.contains(i)) { continue; } int g = 0; - if (last.contains("=")) { + if(last.contains("=")) { String[] vv = last.trim().split("\\Q=\\E"); String vx = vv.length == 2 ? vv[1] : ""; - for (String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v))) { + for(String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v))) { g++; tabs.add(i.getName() + "=" + f); } } else { - for (String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v))) { + for(String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v))) { g++; tabs.add(i.getName() + "=" + f); } } - if (g == 0) { + if(g == 0) { tabs.add(i.getName() + "="); } } } else { - for (VirtualDecreeCommand i : getNodes()) { + for(VirtualDecreeCommand i : getNodes()) { String m = i.getName(); - if (m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase())) { + if(m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase())) { tabs.addAll(i.getNames()); } } @@ -289,8 +281,11 @@ public class VirtualDecreeCommand { /** * Maps the input a player typed to the parameters of this command - * @param sender The sender - * @param in The input + * + * @param sender + * The sender + * @param in + * The input * @return A map of all the parameter names and their values */ private KMap map(VolmitSender sender, KList in) { @@ -301,7 +296,7 @@ public class VirtualDecreeCommand { KList knownInputs = new KList<>(in.stream().filter(s -> s.contains("=")).collect(Collectors.toList())); //Loop known inputs - for (int x = 0; x < knownInputs.size(); x++) { + for(int x = 0; x < knownInputs.size(); x++) { String stringParam = knownInputs.get(x); int original = in.indexOf(stringParam); @@ -311,9 +306,9 @@ public class VirtualDecreeCommand { DecreeParameter param = null; //Find decree parameter from string param - for (DecreeParameter j : getNode().getParameters()) { - for (String k : j.getNames()) { - if (k.equalsIgnoreCase(key)) { + for(DecreeParameter j : getNode().getParameters()) { + for(String k : j.getNames()) { + if(k.equalsIgnoreCase(key)) { param = j; break; } @@ -321,10 +316,10 @@ public class VirtualDecreeCommand { } //If it failed, see if we can find it by checking if the names contain the param - if (param == null) { - for (DecreeParameter j : getNode().getParameters()) { - for (String k : j.getNames()) { - if (k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase())) { + if(param == null) { + for(DecreeParameter j : getNode().getParameters()) { + for(String k : j.getNames()) { + if(k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase())) { param = j; break; } @@ -333,7 +328,7 @@ public class VirtualDecreeCommand { } //Still failed to find, error them - if (param == null) { + if(param == null) { Iris.debug("Can't find parameter key for " + key + "=" + value + " in " + getPath()); sender.sendMessage(C.YELLOW + "Unknown Parameter: " + key); unknownInputs.add(value); //Add the value to the unknowns and see if we can assume it later @@ -344,7 +339,7 @@ public class VirtualDecreeCommand { try { data.put(key, param.getHandler().parse(value, nowhich.contains(original))); //Parse and put - } catch (DecreeParsingException e) { + } catch(DecreeParsingException e) { Iris.debug("Can't parse parameter value for " + key + "=" + value + " in " + getPath() + " using handler " + param.getHandler().getClass().getSimpleName()); sender.sendMessage(C.RED + "Cannot convert \"" + value + "\" into a " + param.getType().getSimpleName()); e.printStackTrace(); @@ -356,7 +351,7 @@ public class VirtualDecreeCommand { KList decreeParameters = new KList<>(getNode().getParameters().stream().filter(param -> !data.contains(param.getName())).collect(Collectors.toList())); //Loop Unknown inputs - for (int x = 0; x < unknownInputs.size(); x++) { + for(int x = 0; x < unknownInputs.size(); x++) { String stringParam = unknownInputs.get(x); int original = in.indexOf(stringParam); try { @@ -364,13 +359,13 @@ public class VirtualDecreeCommand { try { data.put(par.getName(), par.getHandler().parse(stringParam, nowhich.contains(original))); - } catch (DecreeParsingException e) { + } catch(DecreeParsingException e) { Iris.debug("Can't parse parameter value for " + par.getName() + "=" + stringParam + " in " + getPath() + " using handler " + par.getHandler().getClass().getSimpleName()); sender.sendMessage(C.RED + "Cannot convert \"" + stringParam + "\" into a " + par.getType().getSimpleName()); e.printStackTrace(); return null; } - } catch (IndexOutOfBoundsException e) { + } catch(IndexOutOfBoundsException e) { sender.sendMessage(C.YELLOW + "Unknown Parameter: " + stringParam + " (" + Form.getNumberSuffixThStRd(x + 1) + " argument)"); } } @@ -383,15 +378,15 @@ public class VirtualDecreeCommand { } public boolean invoke(VolmitSender sender, KList args, KList skip) { - if (isStudio() && !IrisSettings.get().getStudio().isStudio()) { + if(isStudio() && !IrisSettings.get().getStudio().isStudio()) { sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)"); return false; } Iris.debug("@ " + getPath() + " with " + args.toString(", ")); - if (isNode()) { + if(isNode()) { Iris.debug("Invoke " + getPath() + "(" + args.toString(",") + ") at "); - if (invokeNode(sender, map(sender, args))) { + if(invokeNode(sender, map(sender, args))) { return true; } @@ -399,13 +394,13 @@ public class VirtualDecreeCommand { return false; } - if (args.isEmpty()) { + if(args.isEmpty()) { sender.sendDecreeHelp(this); return true; - } else if (args.size() == 1) { - for (String i : args) { - if (i.startsWith("help=")) { + } else if(args.size() == 1) { + for(String i : args) { + if(i.startsWith("help=")) { sender.sendDecreeHelp(this, Integer.parseInt(i.split("\\Q=\\E")[1]) - 1); return true; } @@ -415,7 +410,7 @@ public class VirtualDecreeCommand { String head = args.get(0); VirtualDecreeCommand match = matchNode(head, skip); - if (match != null) { + if(match != null) { args.pop(); return match.invoke(sender, args, skip); } @@ -426,33 +421,33 @@ public class VirtualDecreeCommand { } private boolean invokeNode(VolmitSender sender, KMap map) { - if (map == null) { + if(map == null) { return false; } Object[] params = new Object[getNode().getMethod().getParameterCount()]; int vm = 0; - for (DecreeParameter i : getNode().getParameters()) { + for(DecreeParameter i : getNode().getParameters()) { Object value = map.get(i.getName()); try { - if (value == null && i.hasDefault()) { + if(value == null && i.hasDefault()) { value = i.getDefaultValue(); } - } catch (DecreeParsingException e) { + } catch(DecreeParsingException e) { Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i.getParam().defaultValue() + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName()); sender.sendMessage(C.RED + "Cannot convert \"" + i.getParam().defaultValue() + "\" into a " + i.getType().getSimpleName()); return false; } - if (sender.isPlayer() && i.isContextual() && value == null) { + if(sender.isPlayer() && i.isContextual() && value == null) { Iris.debug("Contextual!"); DecreeContextHandler ch = DecreeContextHandler.contextHandlers.get(i.getType()); - if (ch != null) { + if(ch != null) { value = ch.handle(sender); - if (value != null) { + if(value != null) { Iris.debug("Parameter \"" + i.getName() + "\" derived a value of \"" + i.getHandler().toStringForce(value) + "\" from " + ch.getClass().getSimpleName()); } else { Iris.debug("Parameter \"" + i.getName() + "\" could not derive a value from \"" + ch.getClass().getSimpleName()); @@ -462,16 +457,16 @@ public class VirtualDecreeCommand { } } - if (i.hasDefault() && value == null) { + if(i.hasDefault() && value == null) { try { Iris.debug("Parameter \"" + i.getName() + "\" is using default value \"" + i.getParam().defaultValue() + "\""); value = i.getDefaultValue(); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } } - if (i.isRequired() && value == null) { + if(i.isRequired() && value == null) { sender.sendMessage(C.RED + "Missing argument \"" + i.getName() + "\" (" + i.getType().getSimpleName() + ") as the " + Form.getNumberSuffixThStRd(vm + 1) + " argument."); sender.sendDecreeHelpNode(this); return false; @@ -487,13 +482,13 @@ public class VirtualDecreeCommand { DecreeContext.touch(sender); getNode().getMethod().setAccessible(true); getNode().getMethod().invoke(getNode().getInstance(), params); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); throw new RuntimeException("Failed to execute "); // TODO: } }; - if (getNode().isSync()) { + if(getNode().isSync()) { J.s(rx); } else { rx.run(); @@ -505,19 +500,19 @@ public class VirtualDecreeCommand { public KList matchAllNodes(String in) { KList g = new KList<>(); - if (in.trim().isEmpty()) { + if(in.trim().isEmpty()) { g.addAll(nodes); return g; } - for (VirtualDecreeCommand i : nodes) { - if (i.matches(in)) { + for(VirtualDecreeCommand i : nodes) { + if(i.matches(in)) { g.add(i); } } - for (VirtualDecreeCommand i : nodes) { - if (i.deepMatches(in)) { + for(VirtualDecreeCommand i : nodes) { + if(i.deepMatches(in)) { g.add(i); } } @@ -527,26 +522,26 @@ public class VirtualDecreeCommand { } public VirtualDecreeCommand matchNode(String in, KList skip) { - if (in.trim().isEmpty()) { + if(in.trim().isEmpty()) { return null; } - for (VirtualDecreeCommand i : nodes) { - if (skip.contains(i.hashCode())) { + for(VirtualDecreeCommand i : nodes) { + if(skip.contains(i.hashCode())) { continue; } - if (i.matches(in)) { + if(i.matches(in)) { return i; } } - for (VirtualDecreeCommand i : nodes) { - if (skip.contains(i.hashCode())) { + for(VirtualDecreeCommand i : nodes) { + if(skip.contains(i.hashCode())) { continue; } - if (i.deepMatches(in)) { + if(i.deepMatches(in)) { return i; } } @@ -557,8 +552,8 @@ public class VirtualDecreeCommand { public boolean deepMatches(String in) { KList a = getNames(); - for (String i : a) { - if (i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase())) { + for(String i : a) { + if(i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase())) { return true; } } @@ -573,7 +568,7 @@ public class VirtualDecreeCommand { @Override public boolean equals(Object obj) { - if (!(obj instanceof VirtualDecreeCommand)) { + if(!(obj instanceof VirtualDecreeCommand)) { return false; } return this.hashCode() == obj.hashCode(); @@ -582,8 +577,8 @@ public class VirtualDecreeCommand { public boolean matches(String in) { KList a = getNames(); - for (String i : a) { - if (i.equalsIgnoreCase(in)) { + for(String i : a) { + if(i.equalsIgnoreCase(in)) { return true; } } diff --git a/src/main/java/com/volmit/iris/util/format/C.java b/src/main/java/com/volmit/iris/util/format/C.java index cbad69f37..072d55fca 100644 --- a/src/main/java/com/volmit/iris/util/format/C.java +++ b/src/main/java/com/volmit/iris/util/format/C.java @@ -253,9 +253,9 @@ public enum C { * need to dynamically convert colour codes from your custom format. */ public static final char COLOR_CHAR = '\u00A7'; - public final static C[] COLORCYCLE = new C[]{C.GOLD, C.YELLOW, C.GREEN, C.AQUA, C.LIGHT_PURPLE, C.AQUA, C.GREEN, C.YELLOW, C.GOLD, C.RED}; + public final static C[] COLORCYCLE = new C[] {C.GOLD, C.YELLOW, C.GREEN, C.AQUA, C.LIGHT_PURPLE, C.AQUA, C.GREEN, C.YELLOW, C.GOLD, C.RED}; private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]"); - private final static C[] COLORS = new C[]{C.BLACK, C.DARK_BLUE, C.DARK_GREEN, C.DARK_AQUA, C.DARK_RED, C.DARK_PURPLE, C.GOLD, C.GRAY, C.DARK_GRAY, C.BLUE, C.GREEN, C.AQUA, C.RED, C.LIGHT_PURPLE, C.YELLOW, C.WHITE}; + private final static C[] COLORS = new C[] {C.BLACK, C.DARK_BLUE, C.DARK_GREEN, C.DARK_AQUA, C.DARK_RED, C.DARK_PURPLE, C.GOLD, C.GRAY, C.DARK_GRAY, C.BLUE, C.GREEN, C.AQUA, C.RED, C.LIGHT_PURPLE, C.YELLOW, C.WHITE}; @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private final static Map BY_ID = new HashMap<>(); private final static Map BY_CHAR = new HashMap<>(); @@ -316,7 +316,7 @@ public enum C { } static { - for (C color : values()) { + for(C color : values()) { BY_ID.put(color.intCode, color); BY_CHAR.put(color.code, color); } @@ -345,15 +345,15 @@ public enum C { this.token = token.equalsIgnoreCase("^") ? "<" + name().toLowerCase(Locale.ROOT) + ">" : token; this.intCode = intCode; this.isFormat = isFormat; - this.toString = new String(new char[]{COLOR_CHAR, code}); + this.toString = new String(new char[] {COLOR_CHAR, code}); } public static float[] spin(float[] c, int shift) { - return new float[]{spin(c[0], shift), spinc(c[1], shift), spinc(c[2], shift)}; + return new float[] {spin(c[0], shift), spinc(c[1], shift), spinc(c[2], shift)}; } public static float[] spin(float[] c, int a, int b, int d) { - return new float[]{spin(c[0], a), spinc(c[1], b), spinc(c[2], d)}; + return new float[] {spin(c[0], a), spinc(c[1], b), spinc(c[2], d)}; } public static float spin(float c, int shift) { @@ -385,21 +385,21 @@ public enum C { StringBuilder b = new StringBuilder(); boolean c = false; - for (char i : msg.toCharArray()) { - if (c) { + for(char i : msg.toCharArray()) { + if(c) { c = false; C o = C.getByChar(i); - if (hrad != 0 || srad != 0 || vrad != 0) { - if (pulse > 0) { + if(hrad != 0 || srad != 0 || vrad != 0) { + if(pulse > 0) { b.append(VolmitSender.pulse(spinToHex(o, hrad, srad, vrad), spinToHex(o, -hrad, -srad, -vrad), pulse)); } else { b.append(""); + .append(spinToHex(o, hrad, srad, vrad)) + .append(":") + .append(spinToHex(o, -hrad, -srad, -vrad)) + .append(">"); } } else { b.append(C.getByChar(i).token); @@ -408,7 +408,7 @@ public enum C { continue; } - if (i == C.COLOR_CHAR) { + if(i == C.COLOR_CHAR) { c = true; continue; } @@ -426,7 +426,8 @@ public enum C { /** * Gets the color represented by the specified color code * - * @param code Code to check + * @param code + * Code to check * @return Associative {@link org.bukkit.ChatColor} with the given code, or null * if it doesn't exist */ @@ -434,7 +435,7 @@ public enum C { try { C c = BY_CHAR.get(code); return c == null ? C.WHITE : c; - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return C.WHITE; } @@ -443,7 +444,8 @@ public enum C { /** * Gets the color represented by the specified color code * - * @param code Code to check + * @param code + * Code to check * @return Associative {@link org.bukkit.ChatColor} with the given code, or null * if it doesn't exist */ @@ -453,7 +455,7 @@ public enum C { Validate.isTrue(code.length() > 0, "Code must have at least one char"); return BY_CHAR.get(code.charAt(0)); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return C.WHITE; } @@ -462,11 +464,12 @@ public enum C { /** * Strips the given message of all color codes * - * @param input String to strip of color + * @param input + * String to strip of color * @return A copy of the input string, without any coloring */ public static String stripColor(final String input) { - if (input == null) { + if(input == null) { return null; } @@ -476,11 +479,12 @@ public enum C { /** * DyeColor to ChatColor * - * @param dclr the dye color + * @param dclr + * the dye color * @return the color */ public static C dyeToChat(DyeColor dclr) { - if (dyeChatMap.containsKey(dclr)) { + if(dyeChatMap.containsKey(dclr)) { return dyeChatMap.get(dclr); } @@ -488,8 +492,8 @@ public enum C { } public static DyeColor chatToDye(ChatColor color) { - for (Map.Entry entry : dyeChatMap.entrySet()) { - if (entry.getValue().toString().equals(color.toString())) { + for(Map.Entry entry : dyeChatMap.entrySet()) { + if(entry.getValue().toString().equals(color.toString())) { return entry.getKey(); } } @@ -499,7 +503,7 @@ public enum C { @SuppressWarnings("unlikely-arg-type") public static String chatToHex(C clr) { - if (chatHexMap.containsKey(clr)) { + if(chatHexMap.containsKey(clr)) { return chatHexMap.get(clr); } @@ -507,7 +511,7 @@ public enum C { } public static String dyeToHex(DyeColor clr) { - if (dyeHexMap.containsKey(clr)) { + if(dyeHexMap.containsKey(clr)) { return dyeHexMap.get(clr); } @@ -515,20 +519,20 @@ public enum C { } public static Color hexToColor(String hex) { - if (hex.startsWith("#")) { + if(hex.startsWith("#")) { hex = hex.substring(1); } - if (hex.contains("x")) { + if(hex.contains("x")) { hex = hex.substring(hex.indexOf("x")); } - if (hex.length() != 6 && hex.length() != 3) { + if(hex.length() != 6 && hex.length() != 3) { return null; } int sz = hex.length() / 3, mult = 1 << ((2 - sz) * 4), x = 0; - for (int i = 0, z = 0; z < hex.length(); ++i, z += sz) { + for(int i = 0, z = 0; z < hex.length(); ++i, z += sz) { x |= (mult * Integer.parseInt(hex.substring(z, z + sz), 16)) << (i * 8); } @@ -537,13 +541,13 @@ public enum C { public static Color rgbToColor(String rgb) { String[] parts = rgb.split("[^0-9]+"); - if (parts.length < 3) { + if(parts.length < 3) { return null; } int x = 0, i; - for (i = 0; i < 3; ++i) { + for(i = 0; i < 3; ++i) { x |= Integer.parseInt(parts[i]) << (i * 8); } @@ -555,13 +559,13 @@ public enum C { str.append(""); - for (Map.Entry e : chatHexMap.entrySet()) { + for(Map.Entry e : chatHexMap.entrySet()) { str.append(String.format("" + "", e.getKey().name(), e.getValue())); } str.append("
Chat ColorColor
%1$sTest String
"); str.append(""); - for (Map.Entry e : dyeHexMap.entrySet()) { + for(Map.Entry e : dyeHexMap.entrySet()) { str.append(String.format("" + "", e.getKey().name(), e.getValue())); } @@ -576,18 +580,20 @@ public enum C { * alternate color code character will only be replaced if it is immediately * followed by 0-9, A-F, a-f, K-O, k-o, R or r. * - * @param altColorChar The alternate color code character to replace. Ex: {@literal &} - * @param textToTranslate Text containing the alternate color code character. + * @param altColorChar + * The alternate color code character to replace. Ex: {@literal &} + * @param textToTranslate + * Text containing the alternate color code character. * @return Text containing the ChatColor.COLOR_CODE color code character. */ public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) { - if (textToTranslate == null) { + if(textToTranslate == null) { return null; } char[] b = textToTranslate.toCharArray(); - for (int i = 0; i < b.length - 1; i++) { - if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { + for(int i = 0; i < b.length - 1; i++) { + if(b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { b[i] = C.COLOR_CHAR; b[i + 1] = Character.toLowerCase(b[i + 1]); } @@ -596,8 +602,8 @@ public enum C { } public static C fromItemMeta(byte c) { - for (C i : C.values()) { - if (i.getItemMeta() == c) { + for(C i : C.values()) { + if(i.getItemMeta() == c) { return i; } } @@ -612,7 +618,8 @@ public enum C { /** * Gets the ChatColors used at the end of the given input string. * - * @param input Input string to retrieve the colors from. + * @param input + * Input string to retrieve the colors from. * @return Any remaining ChatColors to pass onto the next line. */ public static String getLastColors(String input) { @@ -620,17 +627,17 @@ public enum C { int length = input.length(); // Search backwards from the end as it is faster - for (int index = length - 1; index > -1; index--) { + for(int index = length - 1; index > -1; index--) { char section = input.charAt(index); - if (section == COLOR_CHAR && index < length - 1) { + if(section == COLOR_CHAR && index < length - 1) { char c = input.charAt(index + 1); C color = getByChar(c); - if (color != null) { + if(color != null) { result.insert(0, color); // Once we find a color or reset we can stop searching - if (color.isColor() || color.equals(RESET)) { + if(color.isColor() || color.equals(RESET)) { break; } } @@ -699,7 +706,7 @@ public enum C { } public byte getMeta() { - return switch (this) { + return switch(this) { case AQUA -> (byte) 11; case BLACK -> (byte) 0; case BLUE, DARK_AQUA -> (byte) 9; @@ -721,7 +728,7 @@ public enum C { } public byte getItemMeta() { - return switch (this) { + return switch(this) { case AQUA, DARK_AQUA -> (byte) 9; case BLACK -> (byte) 15; case BLUE -> (byte) 3; diff --git a/src/main/java/com/volmit/iris/util/format/Form.java b/src/main/java/com/volmit/iris/util/format/Form.java index cd53a66b3..5f6f99d8b 100644 --- a/src/main/java/com/volmit/iris/util/format/Form.java +++ b/src/main/java/com/volmit/iris/util/format/Form.java @@ -39,7 +39,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Form { - private static final String[] NAMES = new String[]{"Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion", "Septillion", "Octillion", "Nonillion", "Decillion", "Undecillion", "Duodecillion", "Tredecillion", "Quattuordecillion", "Quindecillion", "Sexdecillion", "Septendecillion", "Octodecillion", "Novemdecillion", "Vigintillion",}; + private static final String[] NAMES = new String[] {"Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion", "Septillion", "Octillion", "Nonillion", "Decillion", "Undecillion", "Duodecillion", "Tredecillion", "Quattuordecillion", "Quindecillion", "Sexdecillion", "Septendecillion", "Octodecillion", "Novemdecillion", "Vigintillion",}; private static final BigInteger THOUSAND = BigInteger.valueOf(1000); private static final NavigableMap MAP; private static NumberFormat NF; @@ -47,16 +47,16 @@ public class Form { static { MAP = new TreeMap<>(); - for (int i = 0; i < NAMES.length; i++) { + for(int i = 0; i < NAMES.length; i++) { MAP.put(THOUSAND.pow(i + 1), NAMES[i]); } } public static String getNumberSuffixThStRd(int day) { - if (day >= 11 && day <= 13) { + if(day >= 11 && day <= 13) { return Form.f(day) + "th"; } - return switch (day % 10) { + return switch(day % 10) { case 1 -> Form.f(day) + "st"; case 2 -> Form.f(day) + "nd"; case 3 -> Form.f(day) + "rd"; @@ -65,7 +65,7 @@ public class Form { } private static void instantiate() { - if (NF == null) { + if(NF == null) { NF = NumberFormat.getInstance(Locale.US); } } @@ -73,9 +73,12 @@ public class Form { /** * Scroll text * - * @param smx the text - * @param viewport the viewport length - * @param time the timeline value + * @param smx + * the text + * @param viewport + * the viewport length + * @param time + * the timeline value */ public static String scroll(String smx, int viewport, long time) { String src = Form.repeat(" ", viewport) + smx + Form.repeat(" ", viewport); @@ -90,15 +93,16 @@ public class Form { /** * Capitalize the first letter * - * @param s the string + * @param s + * the string * @return the capitalized string */ public static String capitalize(String s) { StringBuilder roll = new StringBuilder(); boolean f = true; - for (Character i : s.trim().toCharArray()) { - if (f) { + for(Character i : s.trim().toCharArray()) { + if(f) { roll.append(Character.toUpperCase(i)); f = false; } else { @@ -112,13 +116,14 @@ public class Form { /** * Capitalize all words in the string * - * @param s the string + * @param s + * the string * @return the capitalized string */ public static String capitalizeWords(String s) { StringBuilder rollx = new StringBuilder(); - for (String i : s.trim().split(" ")) { + for(String i : s.trim().split(" ")) { rollx.append(" ").append(capitalize(i.trim())); } @@ -128,8 +133,10 @@ public class Form { /** * Hard word wrap * - * @param s the words - * @param len the length per line + * @param s + * the words + * @param len + * the length per line * @return the wrapped string */ public static String wrap(String s, int len) { @@ -139,8 +146,10 @@ public class Form { /** * Soft Word wrap * - * @param s the string - * @param len the length to wrap + * @param s + * the string + * @param len + * the length to wrap * @return the wrapped string */ public static String wrapWords(String s, int len) { @@ -150,10 +159,14 @@ public class Form { /** * Wrap words * - * @param s the string - * @param len the wrap length - * @param newLineSep the new line seperator - * @param soft should it be soft wrapped or hard wrapped? + * @param s + * the string + * @param len + * the wrap length + * @param newLineSep + * the new line seperator + * @param soft + * should it be soft wrapped or hard wrapped? * @return the wrapped words */ public static String wrap(String s, int len, String newLineSep, boolean soft) { @@ -163,10 +176,8 @@ public class Form { public static String hardWrap(String s, int len) { StringBuilder ss = new StringBuilder(); - for(int i = 0; i < s.length(); i+= len) - { - if(i + len > s.length()) - { + for(int i = 0; i < s.length(); i += len) { + if(i + len > s.length()) { ss.append(s, i, s.length()); break; } @@ -179,10 +190,8 @@ public class Form { public static List hardWrapList(String s, int len) { List l = new ArrayList<>(); - for(int i = 0; i < s.length(); i+= len) - { - if(i + len > s.length()) - { + for(int i = 0; i < s.length(); i += len) { + if(i + len > s.length()) { l.add(s.substring(i)); break; } @@ -197,26 +206,31 @@ public class Form { /** * Wrap words * - * @param s the string - * @param len the length - * @param newLineSep the new line seperator - * @param soft soft or hard wrapping - * @param regex the regex + * @param s + * the string + * @param len + * the length + * @param newLineSep + * the new line seperator + * @param soft + * soft or hard wrapping + * @param regex + * the regex * @return the wrapped string */ public static String wrap(String s, int len, String newLineSep, boolean soft, String regex) { - if (s == null) { + if(s == null) { return null; } else { - if (newLineSep == null) { + if(newLineSep == null) { newLineSep = "\n"; } - if (len < 1) { + if(len < 1) { len = 1; } - if (regex.trim().equals("")) { + if(regex.trim().equals("")) { regex = " "; } @@ -225,11 +239,11 @@ public class Form { int arg6 = 0; StringBuilder arg7 = new StringBuilder(arg5 + 32); - while (arg6 < arg5) { + while(arg6 < arg5) { int arg8 = -1; Matcher arg9 = arg4.matcher(s.substring(arg6, Math.min(arg6 + len + 1, arg5))); - if (arg9.find()) { - if (arg9.start() == 0) { + if(arg9.find()) { + if(arg9.start() == 0) { arg6 += arg9.end(); continue; } @@ -237,29 +251,29 @@ public class Form { arg8 = arg9.start(); } - if (arg5 - arg6 <= len) { + if(arg5 - arg6 <= len) { break; } - while (arg9.find()) { + while(arg9.find()) { arg8 = arg9.start() + arg6; } - if (arg8 >= arg6) { + if(arg8 >= arg6) { arg7.append(s, arg6, arg8); arg7.append(newLineSep); arg6 = arg8 + 1; - } else if (soft) { + } else if(soft) { arg7.append(s, arg6, len + arg6); arg7.append(newLineSep); arg6 += len; } else { arg9 = arg4.matcher(s.substring(arg6 + len)); - if (arg9.find()) { + if(arg9.find()) { arg8 = arg9.start() + arg6 + len; } - if (arg8 >= 0) { + if(arg8 >= 0) { arg7.append(s, arg6, arg8); arg7.append(newLineSep); arg6 = arg8 + 1; @@ -278,7 +292,8 @@ public class Form { /** * Returns a fancy duration up to Years * - * @param duration the duration in ms + * @param duration + * the duration in ms * @return the fancy duration */ public static String duration(RollingSequence rollingSequence, long duration) { @@ -286,36 +301,36 @@ public class Form { double phantom = duration; int div = 1000; - if (phantom > div) { + if(phantom > div) { phantom /= div; suffix = "Second"; div = 60; - if (phantom > div) { + if(phantom > div) { phantom /= div; suffix = "Minute"; - if (phantom > div) { + if(phantom > div) { phantom /= div; suffix = "Hour"; div = 24; - if (phantom > 24) { + if(phantom > 24) { phantom /= div; suffix = "Day"; div = 7; - if (phantom > div) { + if(phantom > div) { phantom /= div; suffix = "Week"; div = 4; - if (phantom > div) { + if(phantom > div) { phantom /= div; suffix = "Month"; div = 12; - if (phantom > div) { + if(phantom > div) { phantom /= div; suffix = "Year"; return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s"); @@ -345,12 +360,13 @@ public class Form { /** * Fixes the minute issue with formatting * - * @param c the calendar + * @param c + * the calendar * @return the minute string */ public static String fmin(Calendar c) { String s = c.get(Calendar.MINUTE) + ""; - if (s.length() == 1) { + if(s.length() == 1) { return "0" + s; } @@ -360,17 +376,18 @@ public class Form { /** * Get a fancy time stamp * - * @param time the stamp in time (ago) + * @param time + * the stamp in time (ago) * @return the fancy stamp in time (ago) */ public static String ago(long time) { long current = M.ms(); - if (time > current - TimeUnit.SECONDS.toMillis(30) && time < current) { + if(time > current - TimeUnit.SECONDS.toMillis(30) && time < current) { return "Just Now"; - } else if (time > current - TimeUnit.SECONDS.toMillis(60) && time < current) { + } else if(time > current - TimeUnit.SECONDS.toMillis(60) && time < current) { return "Seconds Ago"; - } else if (time > current - TimeUnit.MINUTES.toMillis(10) && time < current) { + } else if(time > current - TimeUnit.MINUTES.toMillis(10) && time < current) { return "Minutes Ago"; } else { Calendar now = Calendar.getInstance(); @@ -379,15 +396,15 @@ public class Form { boolean sameYear = now.get(Calendar.YEAR) == c.get(Calendar.YEAR); boolean sameDay = now.get(Calendar.DAY_OF_YEAR) == c.get(Calendar.DAY_OF_YEAR); - if (sameDay) { + if(sameDay) { int h = c.get(Calendar.HOUR); h = h == 0 ? 12 : h; return "Today at " + h + ":" + fmin(c) + " " + (c.get(Calendar.AM_PM) == Calendar.PM ? "PM" : "AM"); - } else if (sameYear) { + } else if(sameYear) { boolean yesterday = now.get(Calendar.DAY_OF_YEAR) - 1 == c.get(Calendar.DAY_OF_YEAR); - if (yesterday) { + if(yesterday) { int h = c.get(Calendar.HOUR); h = h == 0 ? 12 : h; @@ -395,7 +412,7 @@ public class Form { } else { int h = c.get(Calendar.HOUR); h = h == 0 ? 12 : h; - String dow = switch (c.get(Calendar.DAY_OF_WEEK)) { + String dow = switch(c.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY -> "Sunday"; case Calendar.MONDAY -> "Monday"; case Calendar.TUESDAY -> "Tuesday"; @@ -409,7 +426,7 @@ public class Form { String monthName = "Error Month"; int month = c.get(Calendar.MONTH); - switch (month) { + switch(month) { case Calendar.JANUARY -> monthName = "Jan"; case Calendar.FEBRUARY -> monthName = "Feb"; case Calendar.MARCH -> monthName = "Mar"; @@ -432,7 +449,7 @@ public class Form { } else { int h = c.get(Calendar.HOUR); h = h == 0 ? 12 : h; - String dow = switch (c.get(Calendar.DAY_OF_WEEK)) { + String dow = switch(c.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY -> "Sunday"; case Calendar.MONDAY -> "Monday"; case Calendar.TUESDAY -> "Tuesday"; @@ -446,7 +463,7 @@ public class Form { String monthName = "Error Month"; int month = c.get(Calendar.MONTH); - switch (month) { + switch(month) { case Calendar.JANUARY -> monthName = "Jan"; case Calendar.FEBRUARY -> monthName = "Feb"; case Calendar.MARCH -> monthName = "Mar"; @@ -473,12 +490,13 @@ public class Form { /** * Get the suffix for a number i.e. 1st 2nd 3rd * - * @param i the number + * @param i + * the number * @return the suffix */ public static String numberSuffix(int i) { - String[] sufixes = new String[]{"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"}; - return switch (i % 100) { + String[] sufixes = new String[] {"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"}; + return switch(i % 100) { case 11, 12, 13 -> i + "th"; default -> i + sufixes[i % 10]; }; @@ -488,28 +506,30 @@ public class Form { * Get a high accuracy but limited range duration (accurate up to a couple * minutes) * - * @param ms the milliseconds (double) - * @param prec the precision (decimal format) + * @param ms + * the milliseconds (double) + * @param prec + * the precision (decimal format) * @return the formatted string */ public static String duration(double ms, int prec) { - if (ms < 1000.0) { + if(ms < 1000.0) { return Form.f(ms, prec) + "ms"; } - if (ms / 1000.0 < 60.0) { + if(ms / 1000.0 < 60.0) { return Form.f(ms / 1000.0, prec) + "s"; } - if (ms / 1000.0 / 60.0 < 60.0) { + if(ms / 1000.0 / 60.0 < 60.0) { return Form.f(ms / 1000.0 / 60.0, prec) + "m"; } - if (ms / 1000.0 / 60.0 / 60.0 < 24.0) { + if(ms / 1000.0 / 60.0 / 60.0 < 24.0) { return Form.f(ms / 1000.0 / 60.0 / 60.0, prec) + " hours"; } - if (ms / 1000.0 / 60.0 / 60.0 / 24.0 < 7) { + if(ms / 1000.0 / 60.0 / 60.0 / 24.0 < 7) { return Form.f(ms / 1000.0 / 60.0 / 24.0, prec) + " days"; } @@ -523,28 +543,30 @@ public class Form { /** * Get a duration from milliseconds up to days * - * @param ms the ms - * @param prec the precision (decimal format) + * @param ms + * the ms + * @param prec + * the precision (decimal format) * @return the formatted string */ public static String duration(long ms, int prec) { - if (ms < 1000.0) { + if(ms < 1000.0) { return Form.f(ms, prec) + "ms"; } - if (ms / 1000.0 < 60.0) { + if(ms / 1000.0 < 60.0) { return Form.f(ms / 1000.0, prec) + " seconds"; } - if (ms / 1000.0 / 60.0 < 60.0) { + if(ms / 1000.0 / 60.0 < 60.0) { return Form.f(ms / 1000.0 / 60.0, prec) + " minutes"; } - if (ms / 1000.0 / 60.0 / 60.0 < 24.0) { + if(ms / 1000.0 / 60.0 / 60.0 < 24.0) { return Form.f(ms / 1000.0 / 60.0 / 60.0, prec) + " hours"; } - if (ms / 1000.0 / 60.0 / 60.0 / 24.0 < 7) { + if(ms / 1000.0 / 60.0 / 60.0 / 24.0 < 7) { return Form.f(ms / 1000.0 / 60.0 / 24.0, prec) + " days"; } @@ -554,7 +576,8 @@ public class Form { /** * Format a big value * - * @param i the number + * @param i + * the number * @return the full value in string */ public static String b(int i) { @@ -564,7 +587,8 @@ public class Form { /** * Format a big value * - * @param i the number + * @param i + * the number * @return the full value in string */ public static String b(long i) { @@ -574,7 +598,8 @@ public class Form { /** * Format a big value * - * @param i the number + * @param i + * the number * @return the full value in string */ public static String b(double i) { @@ -584,12 +609,13 @@ public class Form { /** * Format a big number * - * @param number the big number + * @param number + * the big number * @return the value in string */ public static String b(BigInteger number) { Entry entry = MAP.floorEntry(number); - if (entry == null) { + if(entry == null) { return "Nearly nothing"; } @@ -599,7 +625,7 @@ public class Form { float f = m.floatValue() / 1000.0f; float rounded = ((int) (f * 100.0)) / 100.0f; - if (rounded % 1 == 0) { + if(rounded % 1 == 0) { return ((int) rounded) + " " + entry.getValue(); } @@ -610,7 +636,8 @@ public class Form { * Calculate a fancy string representation of a file size. Adds a suffix of B, * KB, MB, GB, or TB * - * @param s the size (in bytes) + * @param s + * the size (in bytes) * @return the string */ public static String fileSize(long s) { @@ -620,14 +647,16 @@ public class Form { /** * ":", "a", "b", "c" -> a:b:c * - * @param splitter the splitter that goes in between - * @param strings the strings + * @param splitter + * the splitter that goes in between + * @param strings + * the strings * @return the result */ public static String split(String splitter, String... strings) { StringBuilder b = new StringBuilder(); - for (String i : strings) { + for(String i : strings) { b.append(splitter); b.append(i); } @@ -639,7 +668,8 @@ public class Form { * Calculate a fancy string representation of a file size. Adds a suffix of B, * KB, MB, GB, or TB * - * @param s the size (in bytes) + * @param s + * the size (in bytes) * @return the string */ public static String memSize(long s) { @@ -653,7 +683,8 @@ public class Form { /** * Get the timestamp of the time t (ms since 1970) * - * @param t the time + * @param t + * the time * @return the stamp */ @SuppressWarnings("deprecation") @@ -670,7 +701,7 @@ public class Form { } public static String forceDoubleDigit(int dig) { - if (dig < 10) { + if(dig < 10) { return "0" + dig; } @@ -688,27 +719,29 @@ public class Form { * with a special divisor. The divisor decides how much goes up in the suffix * chain. * - * @param s the size (in bytes) - * @param div the divisor + * @param s + * the size (in bytes) + * @param div + * the divisor * @return the string */ public static String ofSize(long s, int div) { double d = (double) s; String sub = "Bytes"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "KB"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "MB"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "GB"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "TB"; } @@ -716,7 +749,7 @@ public class Form { } } - if (sub.equals("GB") || sub.equals("TB")) { + if(sub.equals("GB") || sub.equals("TB")) { return Form.f(d, 1) + sub; } else { return Form.f(d, 0) + sub; @@ -728,28 +761,31 @@ public class Form { * with a special divisor. The divisor decides how much goes up in the suffix * chain. * - * @param s the size (in bytes) - * @param div the divisor - * @param dec the decimal places + * @param s + * the size (in bytes) + * @param div + * the divisor + * @param dec + * the decimal places * @return the string */ public static String ofSize(long s, int div, int dec) { double d = (double) s; String sub = "Bytes"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "KB"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "MB"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "GB"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "TB"; } @@ -765,32 +801,35 @@ public class Form { * with a special divisor. The divisor decides how much goes up in the suffix * chain. * - * @param s the size (in bytes) - * @param div the divisor - * @param dec the decimal places + * @param s + * the size (in bytes) + * @param div + * the divisor + * @param dec + * the decimal places * @return the string */ public static String ofSizeMetricWeight(long s, int div, int dec) { boolean neg = s < 0; - if (neg) { + if(neg) { s = -s; } double d = (double) s; String sub = "Grams"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "KG"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "MG"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "GG"; - if (d > div - 1) { + if(d > div - 1) { d /= div; sub = "TG"; } @@ -804,12 +843,14 @@ public class Form { /** * Trim a string to a length, then append ... at the end if it extends the limit * - * @param s the string - * @param l the limit + * @param s + * the string + * @param l + * the limit * @return the modified string */ public static String trim(String s, int l) { - if (s.length() <= l) { + if(s.length() <= l) { return s; } @@ -820,21 +861,22 @@ public class Form { * Get a class name into a configuration/filename key For example, * PhantomController.class is converted to phantom-controller * - * @param clazz the class + * @param clazz + * the class * @return the string representation */ public static String cname(String clazz) { StringBuilder codeName = new StringBuilder(); - for (Character i : clazz.toCharArray()) { - if (Character.isUpperCase(i)) { + for(Character i : clazz.toCharArray()) { + if(Character.isUpperCase(i)) { codeName.append("-").append(Character.toLowerCase(i)); } else { codeName.append(i); } } - if (codeName.toString().startsWith("-")) { + if(codeName.toString().startsWith("-")) { codeName = new StringBuilder(codeName.substring(1)); } @@ -844,11 +886,12 @@ public class Form { /** * Get a formatted representation of the memory given in megabytes * - * @param mb the megabytes + * @param mb + * the megabytes * @return the string representation with suffixes */ public static String mem(long mb) { - if (mb < 1024) { + if(mb < 1024) { return f(mb) + " MB"; } else { return f(((double) mb / (double) 1024), 1) + " GB"; @@ -861,12 +904,12 @@ public class Form { * @return the string representation with suffixes */ public static String memx(long kb) { - if (kb < 1024) { + if(kb < 1024) { return fd(kb, 2) + " KB"; } else { double mb = (double) kb / 1024.0; - if (mb < 1024) { + if(mb < 1024) { return fd(mb, 2) + " MB"; } else { double gb = mb / 1024.0; @@ -879,7 +922,8 @@ public class Form { /** * Format a long. Changes -10334 into -10,334 * - * @param i the number + * @param i + * the number * @return the string representation of the number */ public static String f(long i) { @@ -890,7 +934,8 @@ public class Form { /** * Format a number. Changes -10334 into -10,334 * - * @param i the number + * @param i + * the number * @return the string representation of the number */ public static String f(int i) { @@ -901,14 +946,16 @@ public class Form { /** * Formats a double's decimals to a limit * - * @param i the double - * @param p the number of decimal places to use + * @param i + * the double + * @param p + * the number of decimal places to use * @return the formated string */ public static String f(double i, int p) { String form = "#"; - if (p > 0) { + if(p > 0) { form = form + "." + repeat("#", p); } @@ -922,14 +969,16 @@ public class Form { * decimal places that dont need to be placed down. 2.4343 formatted with 6 * decimals gets returned as 2.434300 * - * @param i the double - * @param p the number of decimal places to use + * @param i + * the double + * @param p + * the number of decimal places to use * @return the formated string */ public static String fd(double i, int p) { String form = "0"; - if (p > 0) { + if(p > 0) { form = form + "." + repeat("0", p); } @@ -941,14 +990,16 @@ public class Form { /** * Formats a float's decimals to a limit * - * @param i the float - * @param p the number of decimal places to use + * @param i + * the float + * @param p + * the number of decimal places to use * @return the formated string */ public static String f(float i, int p) { String form = "#"; - if (p > 0) { + if(p > 0) { form = form + "." + repeat("#", p); } @@ -960,7 +1011,8 @@ public class Form { /** * Formats a double's decimals (one decimal point) * - * @param i the double + * @param i + * the double */ public static String f(double i) { return f(i, 1); @@ -969,7 +1021,8 @@ public class Form { /** * Formats a float's decimals (one decimal point) * - * @param i the float + * @param i + * the float */ public static String f(float i) { return f(i, 1); @@ -979,8 +1032,10 @@ public class Form { * Get a percent representation of a double and decimal places (0.53) would * return 53% * - * @param i the double - * @param p the number of decimal points + * @param i + * the double + * @param p + * the number of decimal points * @return a string */ public static String pc(double i, int p) { @@ -991,8 +1046,10 @@ public class Form { * Get a percent representation of a float and decimal places (0.53) would * return 53% * - * @param i the float - * @param p the number of decimal points + * @param i + * the float + * @param p + * the number of decimal points * @return a string */ public static String pc(float i, int p) { @@ -1003,7 +1060,8 @@ public class Form { * Get a percent representation of a double and zero decimal places (0.53) would * return 53% * - * @param i the double + * @param i + * the double * @return a string */ public static String pc(double i) { @@ -1014,7 +1072,8 @@ public class Form { * Get a percent representation of a float and zero decimal places (0.53) would * return 53% * - * @param i the double + * @param i + * the double * @return a string */ public static String pc(float i) { @@ -1024,9 +1083,12 @@ public class Form { /** * Get a percent as the percent of i out of "of" with custom decimal places * - * @param i the percent out of - * @param of of of - * @param p the decimal places + * @param i + * the percent out of + * @param of + * of of + * @param p + * the decimal places * @return the string */ public static String pc(int i, int of, int p) { @@ -1036,8 +1098,10 @@ public class Form { /** * Get a percent as the percent of i out of "of" * - * @param i the percent out of - * @param of of of + * @param i + * the percent out of + * @param of + * of of * @return the string */ public static String pc(int i, int of) { @@ -1047,9 +1111,12 @@ public class Form { /** * Get a percent as the percent of i out of "of" with custom decimal places * - * @param i the percent out of - * @param of of of - * @param p the decimal places + * @param i + * the percent out of + * @param of + * of of + * @param p + * the decimal places * @return the string */ public static String pc(long i, long of, int p) { @@ -1059,8 +1126,10 @@ public class Form { /** * Get a percent as the percent of i out of "of" * - * @param i the percent out of - * @param of of of + * @param i + * the percent out of + * @param of + * of of * @return the string */ public static String pc(long i, long of) { @@ -1070,7 +1139,8 @@ public class Form { /** * Milliseconds to seconds (double) * - * @param ms the milliseconds + * @param ms + * the milliseconds * @return a formatted string to milliseconds */ public static String msSeconds(long ms) { @@ -1080,8 +1150,10 @@ public class Form { /** * Milliseconds to seconds (double) custom decimals * - * @param ms the milliseconds - * @param p number of decimal points + * @param ms + * the milliseconds + * @param p + * number of decimal points * @return a formatted string to milliseconds */ public static String msSeconds(long ms, int p) { @@ -1100,7 +1172,8 @@ public class Form { /** * nanoseconds to seconds (double) custom decimals * - * @param p number of decimal points + * @param p + * number of decimal points * @return a formatted string to nanoseconds */ public static String nsMs(long ns, int p) { @@ -1110,7 +1183,8 @@ public class Form { /** * nanoseconds to seconds (double) custom decimals * - * @param p number of decimal points + * @param p + * number of decimal points * @return a formatted string to nanoseconds */ public static String nsMsd(long ns, int p) { @@ -1120,7 +1194,8 @@ public class Form { /** * Get roman numeral representation of the int * - * @param num the int + * @param num + * the int * @return the numerals */ public static String toRoman(int num) { @@ -1142,7 +1217,7 @@ public class Form { StringBuilder res = new StringBuilder(); - for (Map.Entry entry : roman_numerals.entrySet()) { + for(Map.Entry entry : roman_numerals.entrySet()) { int matches = num / entry.getValue(); res.append(repeat(entry.getKey(), matches)); @@ -1155,65 +1230,66 @@ public class Form { /** * Get the number representation from roman numerals. * - * @param number the roman number + * @param number + * the roman number * @return the int representation */ public static int fromRoman(String number) { - if (number.isEmpty()) { + if(number.isEmpty()) { return 0; } number = number.toUpperCase(); - if (number.startsWith("M")) { + if(number.startsWith("M")) { return 1000 + fromRoman(number.substring(1)); } - if (number.startsWith("CM")) { + if(number.startsWith("CM")) { return 900 + fromRoman(number.substring(2)); } - if (number.startsWith("D")) { + if(number.startsWith("D")) { return 500 + fromRoman(number.substring(1)); } - if (number.startsWith("CD")) { + if(number.startsWith("CD")) { return 400 + fromRoman(number.substring(2)); } - if (number.startsWith("C")) { + if(number.startsWith("C")) { return 100 + fromRoman(number.substring(1)); } - if (number.startsWith("XC")) { + if(number.startsWith("XC")) { return 90 + fromRoman(number.substring(2)); } - if (number.startsWith("L")) { + if(number.startsWith("L")) { return 50 + fromRoman(number.substring(1)); } - if (number.startsWith("XL")) { + if(number.startsWith("XL")) { return 40 + fromRoman(number.substring(2)); } - if (number.startsWith("X")) { + if(number.startsWith("X")) { return 10 + fromRoman(number.substring(1)); } - if (number.startsWith("IX")) { + if(number.startsWith("IX")) { return 9 + fromRoman(number.substring(2)); } - if (number.startsWith("V")) { + if(number.startsWith("V")) { return 5 + fromRoman(number.substring(1)); } - if (number.startsWith("IV")) { + if(number.startsWith("IV")) { return 4 + fromRoman(number.substring(2)); } - if (number.startsWith("I")) { + if(number.startsWith("I")) { return 1 + fromRoman(number.substring(1)); } @@ -1223,19 +1299,21 @@ public class Form { /** * Repeat a string * - * @param s the string - * @param n the amount of times to repeat + * @param s + * the string + * @param n + * the amount of times to repeat * @return the repeated string */ @SuppressWarnings("StringRepeatCanBeUsed") public static String repeat(String s, int n) { - if (s == null) { + if(s == null) { return null; } final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < n; i++) { + for(int i = 0; i < n; i++) { sb.append(s); } diff --git a/src/main/java/com/volmit/iris/util/format/MemoryMonitor.java b/src/main/java/com/volmit/iris/util/format/MemoryMonitor.java index c48147adc..323c6f734 100644 --- a/src/main/java/com/volmit/iris/util/format/MemoryMonitor.java +++ b/src/main/java/com/volmit/iris/util/format/MemoryMonitor.java @@ -77,13 +77,13 @@ public class MemoryMonitor { private void sample() { long used = getVMUse(); - if (usedMemory == -1) { + if(usedMemory == -1) { usedMemory = used; garbageMemory = 0; return; } - if (used < usedMemory) { + if(used < usedMemory) { usedMemory = used; } else { garbageMemory = used - usedMemory; @@ -91,7 +91,7 @@ public class MemoryMonitor { long g = garbageMemory - garbageLast; - if (g >= 0) { + if(g >= 0) { garbageBin += g; garbageLast = garbageMemory; } else { @@ -99,8 +99,8 @@ public class MemoryMonitor { garbageLast = 0; } - if (cl.flip()) { - if (garbageMemory > 0) { + if(cl.flip()) { + if(garbageMemory > 0) { pressure = garbageBin; garbageBin = 0; } else { @@ -117,7 +117,7 @@ public class MemoryMonitor { } public void close() { - if (looper != null) { + if(looper != null) { looper.interrupt(); looper = null; } diff --git a/src/main/java/com/volmit/iris/util/hunk/Hunk.java b/src/main/java/com/volmit/iris/util/hunk/Hunk.java index 3e20715c8..1a2ed0a7c 100644 --- a/src/main/java/com/volmit/iris/util/hunk/Hunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/Hunk.java @@ -78,8 +78,10 @@ public interface Hunk { * Create a hunk view from a source hunk. This view reads and writes through to * the source hunk. Its is not a copy. * - * @param the type - * @param src the source hunk + * @param + * the type + * @param src + * the source hunk * @return the hunk view */ static Hunk view(Hunk src) { @@ -197,9 +199,12 @@ public interface Hunk { /** * Creates a new bounding hunk from the given hunks * - * @param the type - * @param factory the factory that creates a hunk - * @param hunks the hunks + * @param + * the type + * @param factory + * the factory that creates a hunk + * @param hunks + * the hunks * @return the new bounding hunk */ @SafeVarargs @@ -208,7 +213,7 @@ public interface Hunk { int h = 0; int d = 0; - for (Hunk i : hunks) { + for(Hunk i : hunks) { w = Math.max(w, i.getWidth()); h = Math.max(h, i.getHeight()); d = Math.max(d, i.getDepth()); @@ -216,7 +221,7 @@ public interface Hunk { Hunk b = factory.apply(w, h, d); - for (Hunk i : hunks) { + for(Hunk i : hunks) { b.insert(i); } @@ -224,11 +229,11 @@ public interface Hunk { } static void computeDual2D(int parallelism, Hunk a, Hunk b, Consumer5, Hunk> v) { - if (a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) { + if(a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) { throw new RuntimeException("Hunk sizes must match!"); } - if (a.get2DDimension(parallelism) == 1) { + if(a.get2DDimension(parallelism) == 1) { v.accept(0, 0, 0, a, b); return; } @@ -239,7 +244,7 @@ public interface Hunk { { v.accept(xx, yy, zz, ha, hr); - synchronized (rq) { + synchronized(rq) { rq.add(r); } }), (x, y, z, hax, hbx) -> @@ -253,13 +258,13 @@ public interface Hunk { } static void getDualSections2D(int sections, Hunk a, Hunk b, Consumer6, Hunk, Runnable> v, Consumer5, Hunk> inserterAB) { - if (a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) { + if(a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) { throw new RuntimeException("Hunk sizes must match!"); } int dim = a.get2DDimension(sections); - if (sections <= 1) { + if(sections <= 1) { getDualSection(0, 0, 0, a.getWidth(), a.getHeight(), a.getDepth(), a, b, (ha, hr, r) -> v.accept(0, 0, 0, ha, hr, r), inserterAB); return; } @@ -270,10 +275,10 @@ public interface Hunk { int dr = a.getDepth() - (d * dim); int i, j; - for (i = 0; i < a.getWidth(); i += w) { + for(i = 0; i < a.getWidth(); i += w) { int ii = i; - for (j = 0; j < a.getDepth(); j += d) { + for(j = 0; j < a.getDepth(); j += d) { int jj = j; getDualSection(i, 0, j, i + w + (i == 0 ? wr : 0), a.getHeight(), j + d + (j == 0 ? dr : 0), a, b, (ha, hr, r) -> v.accept(ii, 0, jj, ha, hr, r), inserterAB); i = i == 0 ? i + wr : i; @@ -291,37 +296,44 @@ public interface Hunk { /** * Create a hunk that is optimized for specific uses * - * @param w width - * @param h height - * @param d depth - * @param type the class type - * @param packed if the hunk is generally more than 50% full (non-null nodes) - * @param concurrent if this hunk must be thread safe - * @param the type + * @param w + * width + * @param h + * height + * @param d + * depth + * @param type + * the class type + * @param packed + * if the hunk is generally more than 50% full (non-null nodes) + * @param concurrent + * if this hunk must be thread safe + * @param + * the type * @return the hunk */ static Hunk newHunk(int w, int h, int d, Class type, boolean packed, boolean concurrent) { - if (type.equals(Double.class)) { + if(type.equals(Double.class)) { return concurrent ? - packed ? (Hunk) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d) - : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); + packed ? (Hunk) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } - if (type.equals(Integer.class)) { + if(type.equals(Integer.class)) { return concurrent ? - packed ? (Hunk) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d) - : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); + packed ? (Hunk) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } - if (type.equals(Long.class)) { + if(type.equals(Long.class)) { return concurrent ? - packed ? (Hunk) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d) - : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); + packed ? (Hunk) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } return concurrent ? - packed ? newAtomicHunk(w, h, d) : newMappedHunk(w, h, d) - : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); + packed ? newAtomicHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } static IrisPosition rotatedBounding(int w, int h, int d, double x, double y, double z) { @@ -359,15 +371,15 @@ public interface Hunk { } static void rotate(double x, double y, double z, int[] c) { - if (x % 360 != 0) { + if(x % 360 != 0) { rotateAroundX(Math.toRadians(x), c); } - if (y % 360 != 0) { + if(y % 360 != 0) { rotateAroundY(Math.toRadians(y), c); } - if (z % 360 != 0) { + if(z % 360 != 0) { rotateAroundZ(Math.toRadians(z), c); } } @@ -469,14 +481,14 @@ public interface Hunk { } default int filterDimension(int dim) { - if (dim <= 1) { + if(dim <= 1) { return 1; } dim = dim % 2 != 0 ? dim + 1 : dim; - if (dim > getMinimumDimension() / 2) { - if (dim <= 2) { + if(dim > getMinimumDimension() / 2) { + if(dim <= 2) { return 1; } @@ -487,7 +499,7 @@ public interface Hunk { } default int get2DDimension(int sections) { - if (sections <= 1) { + if(sections <= 1) { return 1; } @@ -495,7 +507,7 @@ public interface Hunk { } default int get3DDimension(int sections) { - if (sections <= 1) { + if(sections <= 1) { return 1; } @@ -556,8 +568,10 @@ public interface Hunk { * hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));
* }
* - * @param p the predicate - * @param c the consumer + * @param p + * the predicate + * @param c + * the consumer * @return this */ default Hunk iterateSurfaces2D(Predicate p, Consumer8> c) { @@ -618,9 +632,12 @@ public interface Hunk { * hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));
* }
* - * @param parallelism the ideal threads to use on this - * @param p the predicate - * @param c the consumer + * @param parallelism + * the ideal threads to use on this + * @param p + * the predicate + * @param c + * the consumer * @return this */ default Hunk iterateSurfaces2D(int parallelism, Predicate p, Consumer8> c) { @@ -629,20 +646,20 @@ public interface Hunk { int last = -1; int in = getHeight() - 1; boolean hitting = false; - for (int i = getHeight() - 1; i >= 0; i--) { + for(int i = getHeight() - 1; i >= 0; i--) { boolean solid = p.test(h.get(ax, i, az)); - if (!hitting && solid) { + if(!hitting && solid) { in = i; hitting = true; - } else if (hitting && !solid) { + } else if(hitting && !solid) { hitting = false; c.accept(ax, az, hox, hoz, in, i - 1, last, h); last = i - 1; } } - if (hitting) { + if(hitting) { c.accept(ax, az, hox, hoz, in, 0, last, h); } }); @@ -657,7 +674,8 @@ public interface Hunk { *

* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz)); * - * @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ. + * @param c + * the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ. * @return this */ default Hunk iterate2DTop(Consumer5> c) { @@ -675,15 +693,17 @@ public interface Hunk { *

* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz)); * - * @param parallelism the target parallelism value or 0 to disable - * @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ. + * @param parallelism + * the target parallelism value or 0 to disable + * @param c + * the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ. * @return this */ default Hunk iterate2DTop(int parallelism, Consumer5> c) { compute2D(parallelism, (x, y, z, h) -> { - for (int i = 0; i < h.getWidth(); i++) { - for (int k = 0; k < h.getDepth(); k++) { + for(int i = 0; i < h.getWidth(); i++) { + for(int k = 0; k < h.getDepth(); k++) { c.accept(i, k, x, z, h); } } @@ -699,7 +719,7 @@ public interface Hunk { default Hunk iterate(int parallelism, Predicate p, Consumer3 c) { iterate(parallelism, (x, y, z, t) -> { - if (p.test(t)) { + if(p.test(t)) { c.accept(x, y, z); } }); @@ -714,7 +734,7 @@ public interface Hunk { default Hunk iterate(int parallelism, Predicate p, Consumer4 c) { iterate(parallelism, (x, y, z, t) -> { - if (p.test(t)) { + if(p.test(t)) { c.accept(x, y, z, t); } }); @@ -727,9 +747,9 @@ public interface Hunk { } default Hunk iterateSync(Consumer3 c) { - for (int i = 0; i < getWidth(); i++) { - for (int j = 0; j < getHeight(); j++) { - for (int k = 0; k < getDepth(); k++) { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { + for(int k = 0; k < getDepth(); k++) { c.accept(i, j, k); } } @@ -739,9 +759,9 @@ public interface Hunk { } default Hunk iterateSync(Consumer4 c) { - for (int i = 0; i < getWidth(); i++) { - for (int j = 0; j < getHeight(); j++) { - for (int k = 0; k < getDepth(); k++) { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { + for(int k = 0; k < getDepth(); k++) { c.accept(i, j, k, get(i, j, k)); } } @@ -751,9 +771,9 @@ public interface Hunk { } default Hunk updateSync(Function4 c) { - for (int i = 0; i < getWidth(); i++) { - for (int j = 0; j < getHeight(); j++) { - for (int k = 0; k < getDepth(); k++) { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { + for(int k = 0; k < getDepth(); k++) { set(i, j, k, c.apply(i, j, k, get(i, j, k))); } } @@ -763,9 +783,9 @@ public interface Hunk { } default Hunk iterateSyncIO(Consumer4IO c) throws IOException { - for (int i = 0; i < getWidth(); i++) { - for (int j = 0; j < getHeight(); j++) { - for (int k = 0; k < getDepth(); k++) { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { + for(int k = 0; k < getDepth(); k++) { c.accept(i, j, k, get(i, j, k)); } } @@ -777,9 +797,9 @@ public interface Hunk { default Hunk iterate(int parallelism, Consumer3 c) { compute3D(parallelism, (x, y, z, h) -> { - for (int i = 0; i < h.getWidth(); i++) { - for (int j = 0; j < h.getHeight(); j++) { - for (int k = 0; k < h.getDepth(); k++) { + for(int i = 0; i < h.getWidth(); i++) { + for(int j = 0; j < h.getHeight(); j++) { + for(int k = 0; k < h.getDepth(); k++) { c.accept(i + x, j + y, k + z); } } @@ -796,9 +816,9 @@ public interface Hunk { default Hunk iterate(int parallelism, Consumer4 c) { compute3D(parallelism, (x, y, z, h) -> { - for (int i = 0; i < h.getWidth(); i++) { - for (int j = 0; j < h.getHeight(); j++) { - for (int k = 0; k < h.getDepth(); k++) { + for(int i = 0; i < h.getWidth(); i++) { + for(int j = 0; j < h.getHeight(); j++) { + for(int k = 0; k < h.getDepth(); k++) { c.accept(i + x, j + y, k + z, h.get(i, j, k)); } } @@ -813,14 +833,14 @@ public interface Hunk { } default Hunk compute2D(int parallelism, Consumer4> v) { - if (get2DDimension(parallelism) == 1) { + if(get2DDimension(parallelism) == 1) { v.accept(0, 0, 0, this); return this; } BurstExecutor e = MultiBurst.burst.burst(parallelism); - if (isAtomic()) { + if(isAtomic()) { getSectionsAtomic2D(parallelism, (xx, yy, zz, h) -> e.queue(() -> { v.accept(xx, yy, zz, h); @@ -834,7 +854,7 @@ public interface Hunk { { v.accept(xx, yy, zz, h); - synchronized (rq) { + synchronized(rq) { rq.add(r); } }), this::insert); @@ -847,7 +867,7 @@ public interface Hunk { } default Hunk compute2DYRange(int parallelism, int ymin, int ymax, Consumer4> v) { - if (get2DDimension(parallelism) == 1) { + if(get2DDimension(parallelism) == 1) { v.accept(0, 0, 0, this); return this; } @@ -858,7 +878,7 @@ public interface Hunk { { v.accept(xx, yy, zz, h); - synchronized (rq) { + synchronized(rq) { rq.add(r); } }), this::insert); @@ -872,7 +892,7 @@ public interface Hunk { } default Hunk compute3D(int parallelism, Consumer4> v) { - if (get3DDimension(parallelism) == 1) { + if(get3DDimension(parallelism) == 1) { v.accept(0, 0, 0, this); return this; } @@ -882,7 +902,7 @@ public interface Hunk { getSections3D(parallelism, (xx, yy, zz, h, r) -> e.queue(() -> { v.accept(xx, yy, zz, h); - synchronized (rq) { + synchronized(rq) { rq.add(r); } }), this::insert); @@ -898,7 +918,7 @@ public interface Hunk { default Hunk getSectionsAtomic2D(int sections, Consumer4> v) { int dim = get2DDimension(sections); - if (sections <= 1) { + if(sections <= 1) { getAtomicSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh) -> v.accept(0, 0, 0, hh)); return this; } @@ -909,10 +929,10 @@ public interface Hunk { int dr = getDepth() - (d * dim); int i, j; - for (i = 0; i < getWidth(); i += w) { + for(i = 0; i < getWidth(); i += w) { int ii = i; - for (j = 0; j < getDepth(); j += d) { + for(j = 0; j < getDepth(); j += d) { int jj = j; getAtomicSection(i, 0, j, i + w + (i == 0 ? wr : 0), getHeight(), j + d + (j == 0 ? dr : 0), (h) -> v.accept(ii, 0, jj, h)); i = i == 0 ? i + wr : i; @@ -926,7 +946,7 @@ public interface Hunk { default Hunk getSections2D(int sections, Consumer5, Runnable> v, Consumer4> inserter) { int dim = get2DDimension(sections); - if (sections <= 1) { + if(sections <= 1) { getSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh, r) -> v.accept(0, 0, 0, hh, r), inserter); return this; } @@ -937,10 +957,10 @@ public interface Hunk { int dr = getDepth() - (d * dim); int i, j; - for (i = 0; i < getWidth(); i += w) { + for(i = 0; i < getWidth(); i += w) { int ii = i; - for (j = 0; j < getDepth(); j += d) { + for(j = 0; j < getDepth(); j += d) { int jj = j; getSection(i, 0, j, i + w + (i == 0 ? wr : 0), getHeight(), j + d + (j == 0 ? dr : 0), (h, r) -> v.accept(ii, 0, jj, h, r), inserter); i = i == 0 ? i + wr : i; @@ -954,7 +974,7 @@ public interface Hunk { default Hunk getSections2DYLimit(int sections, int ymin, int ymax, Consumer5, Runnable> v, Consumer4> inserter) { int dim = get2DDimension(sections); - if (sections <= 1) { + if(sections <= 1) { getSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh, r) -> v.accept(0, 0, 0, hh, r), inserter); return this; } @@ -965,10 +985,10 @@ public interface Hunk { int dr = getDepth() - (d * dim); int i, j; - for (i = 0; i < getWidth(); i += w) { + for(i = 0; i < getWidth(); i += w) { int ii = i; - for (j = 0; j < getDepth(); j += d) { + for(j = 0; j < getDepth(); j += d) { int jj = j; getSection(i, ymin, j, i + w + (i == 0 ? wr : 0), ymax, j + d + (j == 0 ? dr : 0), (h, r) -> v.accept(ii, ymin, jj, h, r), inserter); i = i == 0 ? i + wr : i; @@ -986,7 +1006,7 @@ public interface Hunk { default Hunk getSections3D(int sections, Consumer5, Runnable> v, Consumer4> inserter) { int dim = get3DDimension(sections); - if (sections <= 1) { + if(sections <= 1) { getSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh, r) -> v.accept(0, 0, 0, hh, r), inserter); return this; } @@ -999,13 +1019,13 @@ public interface Hunk { int dr = getDepth() - (d * dim); int i, j, k; - for (i = 0; i < getWidth(); i += w) { + for(i = 0; i < getWidth(); i += w) { int ii = i; - for (j = 0; j < getHeight(); j += d) { + for(j = 0; j < getHeight(); j += d) { int jj = j; - for (k = 0; k < getDepth(); k += d) { + for(k = 0; k < getDepth(); k += d) { int kk = k; getSection(ii, jj, kk, i + w + (i == 0 ? wr : 0), j + h + (j == 0 ? hr : 0), k + d + (k == 0 ? dr : 0), (hh, r) -> v.accept(ii, jj, kk, hh, r), inserter); i = i == 0 ? i + wr : i; @@ -1037,20 +1057,26 @@ public interface Hunk { /** * Create a new hunk from a section of this hunk. * - * @param x1 The min x (inclusive) - * @param y1 The min y (inclusive) - * @param z1 The min z (inclusive) - * @param x2 The max x (exclusive) - * @param y2 The max y (exclusive) - * @param z2 The max z (exclusive) + * @param x1 + * The min x (inclusive) + * @param y1 + * The min y (inclusive) + * @param z1 + * The min z (inclusive) + * @param x2 + * The max x (exclusive) + * @param y2 + * The max y (exclusive) + * @param z2 + * The max z (exclusive) * @return the new hunk (x2-x1, y2-y1, z2-z1) */ default ArrayHunk crop(int x1, int y1, int z1, int x2, int y2, int z2) { ArrayHunk h = new ArrayHunk(x2 - x1, y2 - y1, z2 - z1); - for (int i = x1; i < x2; i++) { - for (int j = y1; j < y2; j++) { - for (int k = z1; k < z2; k++) { + for(int i = x1; i < x2; i++) { + for(int j = y1; j < y2; j++) { + for(int k = z1; k < z2; k++) { h.setRaw(i - x1, j - y1, k - z1, getRaw(i, j, k)); } } @@ -1063,12 +1089,18 @@ public interface Hunk { * Create a new view of this same hunk from a section of this hunk. * Modifications are routed to this hunk! * - * @param x1 The min x (inclusive) - * @param y1 The min y (inclusive) - * @param z1 The min z (inclusive) - * @param x2 The max x (exclusive) - * @param y2 The max y (exclusive) - * @param z2 The max z (exclusive) + * @param x1 + * The min x (inclusive) + * @param y1 + * The min y (inclusive) + * @param z1 + * The min z (inclusive) + * @param x2 + * The max x (exclusive) + * @param y2 + * The max y (exclusive) + * @param z2 + * The max z (exclusive) * @return the cropped view of this hunk (x2-x1, y2-y1, z2-z1) */ default Hunk croppedView(int x1, int y1, int z1, int x2, int y2, int z2) { @@ -1093,18 +1125,25 @@ public interface Hunk { /** * Set a region * - * @param x1 inclusive 1st x - * @param y1 inclusive 1st y - * @param z1 inclusive 1st z - * @param x2 inclusive 2nd x - * @param y2 inclusive 2nd y - * @param z2 inclusive 2nd z - * @param t the value to set + * @param x1 + * inclusive 1st x + * @param y1 + * inclusive 1st y + * @param z1 + * inclusive 1st z + * @param x2 + * inclusive 2nd x + * @param y2 + * inclusive 2nd y + * @param z2 + * inclusive 2nd z + * @param t + * the value to set */ default void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) { - for (int i = x1; i <= x2; i++) { - for (int j = y1; j <= y2; j++) { - for (int k = z1; k <= z2; k++) { + for(int i = x1; i <= x2; i++) { + for(int j = y1; j <= y2; j++) { + for(int k = z1; k <= z2; k++) { setRaw(i, j, k, t); } } @@ -1114,9 +1153,12 @@ public interface Hunk { /** * Get the value to the closest valid position * - * @param x the x - * @param y the y - * @param z the z + * @param x + * the x + * @param y + * the y + * @param z + * the z * @return the value closest to the border of the hunk */ default T getClosest(int x, int y, int z) { @@ -1146,11 +1188,12 @@ public interface Hunk { /** * Get a 1 node thick hunk representing the face of this hunk * - * @param f the face + * @param f + * the face * @return the hunk view of this hunk */ default Hunk viewFace(HunkFace f) { - switch (f) { + switch(f) { case BOTTOM: return croppedView(0, 0, 0, getWidth() - 1, 0, getDepth() - 1); case EAST: @@ -1173,11 +1216,12 @@ public interface Hunk { /** * Crop (copy) a 1 node thick hunk representing the face of this hunk * - * @param f the face + * @param f + * the face * @return the hunk copy (face) of this hunk */ default Hunk cropFace(HunkFace f) { - switch (f) { + switch(f) { case BOTTOM: return crop(0, 0, 0, getWidth() - 1, 0, getDepth() - 1); case EAST: @@ -1200,17 +1244,21 @@ public interface Hunk { /** * Set a value at the given position * - * @param x the x - * @param y the y - * @param z the z - * @param t the value + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @param t + * the value */ default void set(int x, int y, int z, T t) { setRaw(x, y, z, t); } default void setIfExists(int x, int y, int z, T t) { - if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) { + if(x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) { return; } @@ -1218,7 +1266,7 @@ public interface Hunk { } default T getIfExists(int x, int y, int z, T t) { - if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) { + if(x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) { return t; } @@ -1232,19 +1280,26 @@ public interface Hunk { /** * Set a value at the given position without checking coordinate bounds * - * @param x the x - * @param y the y - * @param z the z - * @param t the value + * @param x + * the x + * @param y + * the y + * @param z + * the z + * @param t + * the value */ void setRaw(int x, int y, int z, T t); /** * Get a value at the given position without checking coordinate bounds * - * @param x the x - * @param y the y - * @param z the z + * @param x + * the x + * @param y + * the y + * @param z + * the z * @return the value or null */ T getRaw(int x, int y, int z); @@ -1252,9 +1307,12 @@ public interface Hunk { /** * Get a value at the given position * - * @param x the x - * @param y the y - * @param z the z + * @param x + * the x + * @param y + * the y + * @param z + * the z * @return the value or null */ default T get(int x, int y, int z) { @@ -1264,7 +1322,7 @@ public interface Hunk { default T getOr(int x, int y, int z, T t) { T v = getRaw(x, y, z); - if (v == null) { + if(v == null) { return t; } @@ -1274,10 +1332,14 @@ public interface Hunk { /** * Insert a hunk into this one with an offset the inserted hunk * - * @param offX the offset from zero for x - * @param offY the offset from zero for y - * @param offZ the offset from zero for z - * @param hunk the hunk to insert + * @param offX + * the offset from zero for x + * @param offY + * the offset from zero for y + * @param offZ + * the offset from zero for z + * @param hunk + * the hunk to insert */ default void insert(int offX, int offY, int offZ, Hunk hunk) { insert(offX, offY, offZ, hunk, false); @@ -1290,7 +1352,8 @@ public interface Hunk { /** * Insert a hunk into this one * - * @param hunk the hunk to insert + * @param hunk + * the hunk to insert */ default void insert(Hunk hunk) { insert(0, 0, 0, hunk, false); @@ -1310,8 +1373,10 @@ public interface Hunk { /** * Insert a hunk into this one * - * @param hunk the hunk to insert - * @param inverted invert the inserted hunk or not + * @param hunk + * the hunk to insert + * @param inverted + * invert the inserted hunk or not */ default void insert(Hunk hunk, boolean inverted) { insert(0, 0, 0, hunk, inverted); @@ -1321,16 +1386,21 @@ public interface Hunk { * Insert a hunk into this one with an offset and possibly inverting the y of * the inserted hunk * - * @param offX the offset from zero for x - * @param offY the offset from zero for y - * @param offZ the offset from zero for z - * @param hunk the hunk to insert - * @param invertY should the inserted hunk be inverted + * @param offX + * the offset from zero for x + * @param offY + * the offset from zero for y + * @param offZ + * the offset from zero for z + * @param hunk + * the hunk to insert + * @param invertY + * should the inserted hunk be inverted */ default void insert(int offX, int offY, int offZ, Hunk hunk, boolean invertY) { - for (int i = offX; i < offX + hunk.getWidth(); i++) { - for (int j = offY; j < offY + hunk.getHeight(); j++) { - for (int k = offZ; k < offZ + hunk.getDepth(); k++) { + for(int i = offX; i < offX + hunk.getWidth(); i++) { + for(int j = offY; j < offY + hunk.getHeight(); j++) { + for(int k = offZ; k < offZ + hunk.getDepth(); k++) { setRaw(i, j, k, hunk.getRaw(i - offX, j - offY, k - offZ)); } } @@ -1338,20 +1408,26 @@ public interface Hunk { } /** - * Insert a hunk into this one with an offset and possibly inverting the y of. Will never insert a node if its already used + * Insert a hunk into this one with an offset and possibly inverting the y of. Will never insert a node if its + * already used * the inserted hunk * - * @param offX the offset from zero for x - * @param offY the offset from zero for y - * @param offZ the offset from zero for z - * @param hunk the hunk to insert - * @param invertY should the inserted hunk be inverted + * @param offX + * the offset from zero for x + * @param offY + * the offset from zero for y + * @param offZ + * the offset from zero for z + * @param hunk + * the hunk to insert + * @param invertY + * should the inserted hunk be inverted */ default void insertSoftly(int offX, int offY, int offZ, Hunk hunk, boolean invertY, Predicate shouldOverwrite) { - for (int i = offX; i < offX + hunk.getWidth(); i++) { - for (int j = offY; j < offY + hunk.getHeight(); j++) { - for (int k = offZ; k < offZ + hunk.getDepth(); k++) { - if (shouldOverwrite.test(getRaw(i, j, k))) { + for(int i = offX; i < offX + hunk.getWidth(); i++) { + for(int j = offY; j < offY + hunk.getHeight(); j++) { + for(int k = offZ; k < offZ + hunk.getDepth(); k++) { + if(shouldOverwrite.test(getRaw(i, j, k))) { setRaw(i, j, k, hunk.getRaw(i - offX, j - offY, k - offZ)); } } @@ -1362,7 +1438,8 @@ public interface Hunk { /** * Acts like fill, however if used by a mapped hunk, will simply clear it * - * @param b the data to use for fill + * @param b + * the data to use for fill */ default void empty(T b) { fill(b); @@ -1371,21 +1448,24 @@ public interface Hunk { /** * Take a hunk and scale it up using interpolation * - * @param scale the scale - * @param d the interpolation method - * @param interpolated the interpolated value converter + * @param scale + * the scale + * @param d + * the interpolation method + * @param interpolated + * the interpolated value converter * @return the new hunk */ default Hunk interpolate3D(double scale, InterpolationMethod3D d, Interpolated interpolated) { Hunk t = Hunk.newArrayHunk((int) (getWidth() * scale), (int) (getHeight() * scale), (int) (getDepth() * scale)); NoiseProvider3 n3 = (x, y, z) -> interpolated.toDouble( - t.get((int) (x / scale), - (int) (y / scale), - (int) (z / scale))); + t.get((int) (x / scale), + (int) (y / scale), + (int) (z / scale))); - for (int i = 0; i < t.getWidth(); i++) { - for (int j = 0; j < t.getHeight(); j++) { - for (int k = 0; k < t.getDepth(); k++) { + for(int i = 0; i < t.getWidth(); i++) { + for(int j = 0; j < t.getHeight(); j++) { + for(int k = 0; k < t.getDepth(); k++) { t.set(i, j, k, interpolated.fromDouble(IrisInterpolation.getNoise3D(d, i, j, k, scale, n3))); } } @@ -1398,20 +1478,23 @@ public interface Hunk { * Take a hunk and scale it up using interpolation * 2D, (using only x and z) assumes the height is 1 * - * @param scale the scale - * @param d the interpolation method - * @param interpolated the interpolated value converter + * @param scale + * the scale + * @param d + * the interpolation method + * @param interpolated + * the interpolated value converter * @return the new hunk */ default Hunk interpolate2D(double scale, InterpolationMethod d, Interpolated interpolated) { Hunk t = Hunk.newArrayHunk((int) (getWidth() * scale), 1, (int) (getDepth() * scale)); NoiseProvider n2 = (x, z) -> interpolated.toDouble( - t.get((int) (x / scale), - 0, - (int) (z / scale))); + t.get((int) (x / scale), + 0, + (int) (z / scale))); - for (int i = 0; i < t.getWidth(); i++) { - for (int j = 0; j < t.getDepth(); j++) { + for(int i = 0; i < t.getWidth(); i++) { + for(int j = 0; j < t.getDepth(); j++) { t.set(i, 0, j, interpolated.fromDouble(IrisInterpolation.getNoise(d, i, j, scale, n2))); } } @@ -1451,9 +1534,9 @@ public interface Hunk { Hunk r = builder.get(maxX - minX, maxY - minY, maxZ - minZ); int[] cr = {(maxX - minX) / 2, (maxY - minY) / 2, (maxZ - minZ) / 2}; - for (i = 0; i < w; i++) { - for (j = 0; j < h; j++) { - for (k = 0; k < d; k++) { + for(i = 0; i < w; i++) { + for(j = 0; j < h; j++) { + for(k = 0; k < d; k++) { b[0] = i - c[0]; b[1] = j - c[1]; b[2] = k - c[2]; @@ -1461,7 +1544,7 @@ public interface Hunk { try { r.set(b[0] + cr[0], b[1] + cr[1], b[2] + cr[2], get(i, j, k)); - } catch (Throwable e) { + } catch(Throwable e) { } } diff --git a/src/main/java/com/volmit/iris/util/hunk/bits/DataBits.java b/src/main/java/com/volmit/iris/util/hunk/bits/DataBits.java index 3476cac73..cc65f06b6 100644 --- a/src/main/java/com/volmit/iris/util/hunk/bits/DataBits.java +++ b/src/main/java/com/volmit/iris/util/hunk/bits/DataBits.java @@ -18,7 +18,6 @@ package com.volmit.iris.util.hunk.bits; -import com.volmit.iris.Iris; import com.volmit.iris.util.data.Varint; import org.apache.commons.lang3.Validate; @@ -30,27 +29,27 @@ import java.util.concurrent.atomic.AtomicLongArray; import java.util.function.IntConsumer; public class DataBits { - private static final int[] MAGIC = new int[]{ - -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, - 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, - 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, - 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, - 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, - 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, - 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, - 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, - 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, - 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, - 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, - 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, - 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, - 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, - 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, - 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, - 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, - 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, - 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, - 0, 5}; + private static final int[] MAGIC = new int[] { + -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, + 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, + 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, + 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, + 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, + 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, + 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, + 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, + 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, + 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, + 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, + 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, + 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, + 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, + 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, + 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, + 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, + 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, + 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, + 0, 5}; private final AtomicLongArray data; private final int bits; @@ -81,8 +80,8 @@ public class DataBits { this.divideShift = MAGIC[var3 + 2]; int var4 = (length + valuesPerLong - 1) / valuesPerLong; - if (data != null) { - if (data.length() != var4) { + if(data != null) { + if(data.length() != var4) { throw new RuntimeException("NO! Trying to load " + data.length() + " into actual size of " + var4 + " because length: " + length + " (bits: " + bits + ")"); } this.data = data; @@ -102,7 +101,7 @@ public class DataBits { private static AtomicLongArray longs(DataInputStream din, int longSize) throws IOException { AtomicLongArray a = new AtomicLongArray(longSize); - for (int i = 0; i < a.length(); i++) { + for(int i = 0; i < a.length(); i++) { a.set(i, Varint.readUnsignedVarLong(din)); } @@ -110,11 +109,11 @@ public class DataBits { } public DataBits setBits(int newBits) { - if (bits != newBits) { + if(bits != newBits) { DataBits newData = new DataBits(newBits, size); AtomicInteger c = new AtomicInteger(0); - for (int i = 0; i < size; i++) { + for(int i = 0; i < size; i++) { newData.set(i, get(i)); } @@ -175,12 +174,12 @@ public class DataBits { public void getAll(IntConsumer var0) { int var1 = 0; - for (int i = 0; i < data.length(); i++) { + for(int i = 0; i < data.length(); i++) { long var5 = data.get(i); - for (int var7 = 0; var7 < valuesPerLong; var7++) { + for(int var7 = 0; var7 < valuesPerLong; var7++) { var0.accept((int) (var5 & mask)); var5 >>= bits; - if (++var1 >= size) { + if(++var1 >= size) { return; } } @@ -188,7 +187,7 @@ public class DataBits { } public void write(DataOutputStream dos) throws IOException { - for (int i = 0; i < data.length(); i++) { + for(int i = 0; i < data.length(); i++) { Varint.writeUnsignedVarLong(data.get(i), dos); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/bits/DataContainer.java b/src/main/java/com/volmit/iris/util/hunk/bits/DataContainer.java index ca236c6ed..0c5e148cb 100644 --- a/src/main/java/com/volmit/iris/util/hunk/bits/DataContainer.java +++ b/src/main/java/com/volmit/iris/util/hunk/bits/DataContainer.java @@ -18,7 +18,6 @@ package com.volmit.iris.util.hunk.bits; -import com.volmit.iris.Iris; import com.volmit.iris.util.data.Varint; import java.io.ByteArrayOutputStream; @@ -56,8 +55,7 @@ public class DataContainer { this.bits = new AtomicInteger(palette.get().bits()); } - public static String readBitString(DataInputStream din) throws IOException - { + public static String readBitString(DataInputStream din) throws IOException { DataContainer c = new DataContainer<>(din, new Writable() { @Override public Character readNodeData(DataInputStream din) throws IOException { @@ -72,8 +70,7 @@ public class DataContainer { StringBuilder sb = new StringBuilder(); - for(int i = c.size()-1; i >= 0; i--) - { + for(int i = c.size() - 1; i >= 0; i--) { sb.setCharAt(i, c.get(i)); } @@ -93,27 +90,24 @@ public class DataContainer { } }, s.length()); - for(int i = 0; i < s.length(); i++) - { + for(int i = 0; i < s.length(); i++) { c.set(i, s.charAt(i)); } c.writeDos(dos); } - public DataBits getData() - { + public DataBits getData() { return data.get(); } - public Palette getPalette() - { + public Palette getPalette() { return palette.get(); } public String toString() { return "DataContainer <" + length + " x " + bits + " bits> -> Palette<" + palette.get().getClass().getSimpleName().replaceAll("\\QPalette\\E", "") + ">: " + palette.get().size() + - " " + data.get().toString() + " PalBit: " + palette.get().bits(); + " " + data.get().toString() + " PalBit: " + palette.get().bits(); } public byte[] write() throws IOException { @@ -136,13 +130,13 @@ public class DataContainer { private Palette newPalette(DataInputStream din) throws IOException { int paletteSize = Varint.readUnsignedVarInt(din); - Palette d = newPalette(bits(paletteSize+1)); + Palette d = newPalette(bits(paletteSize + 1)); d.from(paletteSize, writer, din); return d; } private Palette newPalette(int bits) { - if (bits <= LINEAR_BITS_LIMIT) { + if(bits <= LINEAR_BITS_LIMIT) { return new LinearPalette<>(LINEAR_INITIAL_LENGTH); } @@ -150,17 +144,16 @@ public class DataContainer { } public void ensurePaletted(T t) { - if (palette.get().id(t) == -1) { + if(palette.get().id(t) == -1) { expandOne(); } } public void set(int position, T t) { - synchronized (this) - { + synchronized(this) { int id = palette.get().id(t); - if (id == -1) { + if(id == -1) { expandOne(); id = palette.get().add(t); } @@ -170,17 +163,16 @@ public class DataContainer { } private void expandOne() { - if (palette.get().size() + 1 >= BIT[bits.get()]) { + if(palette.get().size() + 1 >= BIT[bits.get()]) { setBits(bits.get() + 1); } } public T get(int position) { - synchronized (this) - { + synchronized(this) { int id = data.get().get(position) + 1; - if (id <= 0) { + if(id <= 0) { return null; } @@ -189,8 +181,8 @@ public class DataContainer { } public void setBits(int bits) { - if (this.bits.get() != bits) { - if (this.bits.get() <= LINEAR_BITS_LIMIT != bits <= LINEAR_BITS_LIMIT) { + if(this.bits.get() != bits) { + if(this.bits.get() <= LINEAR_BITS_LIMIT != bits <= LINEAR_BITS_LIMIT) { palette.set(newPalette(bits).from(palette.get())); } @@ -202,7 +194,7 @@ public class DataContainer { private static int[] computeBitLimits() { int[] m = new int[16]; - for (int i = 0; i < m.length; i++) { + for(int i = 0; i < m.length; i++) { m[i] = (int) Math.pow(2, i); } @@ -210,12 +202,12 @@ public class DataContainer { } protected static int bits(int size) { - if (DataContainer.BIT[INITIAL_BITS] >= size) { + if(DataContainer.BIT[INITIAL_BITS] >= size) { return INITIAL_BITS; } - for (int i = 0; i < DataContainer.BIT.length; i++) { - if (DataContainer.BIT[i] >= size) { + for(int i = 0; i < DataContainer.BIT.length; i++) { + if(DataContainer.BIT[i] >= size) { return i; } } diff --git a/src/main/java/com/volmit/iris/util/hunk/bits/HashPalette.java b/src/main/java/com/volmit/iris/util/hunk/bits/HashPalette.java index 16b16a6e9..185cb90d7 100644 --- a/src/main/java/com/volmit/iris/util/hunk/bits/HashPalette.java +++ b/src/main/java/com/volmit/iris/util/hunk/bits/HashPalette.java @@ -38,7 +38,7 @@ public class HashPalette implements Palette { @Override public T get(int id) { - if (id < 0 || id >= size.get()) { + if(id < 0 || id >= size.get()) { return null; } @@ -50,7 +50,7 @@ public class HashPalette implements Palette { int index = size.getAndIncrement(); palette.put(t, index); - if (t != null) { + if(t != null) { lookup.put(index, t); } @@ -59,8 +59,7 @@ public class HashPalette implements Palette { @Override public int id(T t) { - if(t == null) - { + if(t == null) { return 0; } @@ -75,9 +74,8 @@ public class HashPalette implements Palette { @Override public void iterate(Consumer2 c) { - for (T i : palette.keySet()) { - if(i == null) - { + for(T i : palette.keySet()) { + if(i == null) { continue; } diff --git a/src/main/java/com/volmit/iris/util/hunk/bits/LinearPalette.java b/src/main/java/com/volmit/iris/util/hunk/bits/LinearPalette.java index 891f38e64..6ce0f8cc3 100644 --- a/src/main/java/com/volmit/iris/util/hunk/bits/LinearPalette.java +++ b/src/main/java/com/volmit/iris/util/hunk/bits/LinearPalette.java @@ -18,9 +18,7 @@ package com.volmit.iris.util.hunk.bits; -import com.volmit.iris.Iris; import com.volmit.iris.util.function.Consumer2; -import org.bukkit.block.data.BlockData; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -38,7 +36,7 @@ public class LinearPalette implements Palette { @Override public T get(int id) { - if (id < 0 || id >= size.get()) { + if(id < 0 || id >= size.get()) { return null; } @@ -54,10 +52,10 @@ public class LinearPalette implements Palette { } private void grow(int newLength) { - if (newLength > palette.get().length()) { + if(newLength > palette.get().length()) { AtomicReferenceArray a = new AtomicReferenceArray<>(newLength + size.get()); - for (int i = 0; i < palette.get().length(); i++) { + for(int i = 0; i < palette.get().length(); i++) { a.set(i, palette.get().get(i)); } @@ -67,13 +65,12 @@ public class LinearPalette implements Palette { @Override public int id(T t) { - if(t == null) - { + if(t == null) { return 0; } - for (int i = 1; i < size() + 1; i++) { - if (t.equals(palette.get().get(i))) { + for(int i = 1; i < size() + 1; i++) { + if(t.equals(palette.get().get(i))) { return i; } } @@ -83,12 +80,12 @@ public class LinearPalette implements Palette { @Override public int size() { - return size.get()-1; + return size.get() - 1; } @Override public void iterate(Consumer2 c) { - for (int i = 1; i < size()+1; i++) { + for(int i = 1; i < size() + 1; i++) { c.accept(palette.get().get(i), i); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/bits/Palette.java b/src/main/java/com/volmit/iris/util/hunk/bits/Palette.java index f59b4040e..279c933fd 100644 --- a/src/main/java/com/volmit/iris/util/hunk/bits/Palette.java +++ b/src/main/java/com/volmit/iris/util/hunk/bits/Palette.java @@ -35,7 +35,7 @@ public interface Palette { int size(); default int bits() { - return DataContainer.bits(size()+1); + return DataContainer.bits(size() + 1); } void iterate(Consumer2 c); @@ -44,14 +44,14 @@ public interface Palette { iterate((a, b) -> { try { c.accept(a, b); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } }); } default Palette from(int size, Writable writable, DataInputStream in) throws IOException { - for (int i = 0; i < size; i++) { + for(int i = 0; i < size; i++) { add(writable.readNodeData(in)); } diff --git a/src/main/java/com/volmit/iris/util/hunk/bits/TecTest.java b/src/main/java/com/volmit/iris/util/hunk/bits/TecTest.java index 8b840ccec..873dd9680 100644 --- a/src/main/java/com/volmit/iris/util/hunk/bits/TecTest.java +++ b/src/main/java/com/volmit/iris/util/hunk/bits/TecTest.java @@ -22,31 +22,23 @@ import com.volmit.iris.Iris; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.format.Form; -import com.volmit.iris.util.io.IO; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.matter.slices.BlockMatter; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Set; public class TecTest { - public static Set randomBlocks(int max) - { + public static Set randomBlocks(int max) { KSet d = new KSet<>(); - while(d.size() < max) - { + while(d.size() < max) { Material m = Material.values()[RNG.r.i(Material.values().length - 1)]; - if(m.isBlock()) - { + if(m.isBlock()) { d.add(m.createBlockData()); } } @@ -54,23 +46,19 @@ public class TecTest { return d; } - public static void go() - { + public static void go() { } - public static boolean test(int size, int pal) - { - try - { + public static boolean test(int size, int pal) { + try { Iris.info("Test? " + size + " " + pal); KList blocks = new KList<>(randomBlocks(pal)); Iris.info("Fill " + pal + " -> " + size + " Entries"); Writable writer = new BlockMatter(); DataContainer dc = new DataContainer<>(writer, size); - for(int i = 0; i < dc.size(); i++) - { + for(int i = 0; i < dc.size(); i++) { dc.set(i, blocks.getRandom()); } @@ -84,13 +72,9 @@ public class TecTest { if(Arrays.equals(dat, dat2)) { Iris.info("MATCH"); return true; - } - else - { - for(int i = 0; i < dc.size(); i++) - { - if(!dx.get(i).equals(dc.get(i))) - { + } else { + for(int i = 0; i < dc.size(); i++) { + if(!dx.get(i).equals(dc.get(i))) { Iris.info("FAIL Expected " + dc.get(i).getAsString(true) + " but got " + dx.get(i).getAsString(true)); return false; } @@ -99,10 +83,7 @@ public class TecTest { return true; } - } - - catch(Throwable e) - { + } catch(Throwable e) { e.printStackTrace(); return false; } diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java index 4d5d9fba8..7c85b67e2 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java @@ -53,7 +53,7 @@ public class MappedHunk extends StorageHunk implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - if (t == null) { + if(t == null) { data.remove(index(x, y, z)); return; } @@ -69,7 +69,7 @@ public class MappedHunk extends StorageHunk implements Hunk { public synchronized Hunk iterateSync(Consumer4 c) { int idx, z; - for (Map.Entry g : data.entrySet()) { + for(Map.Entry g : data.entrySet()) { idx = g.getKey(); z = idx / (getWidth() * getHeight()); idx -= (z * getWidth() * getHeight()); @@ -83,7 +83,7 @@ public class MappedHunk extends StorageHunk implements Hunk { public synchronized Hunk iterateSyncIO(Consumer4IO c) throws IOException { int idx, z; - for (Map.Entry g : data.entrySet()) { + for(Map.Entry g : data.entrySet()) { idx = g.getKey(); z = idx / (getWidth() * getHeight()); idx -= (z * getWidth() * getHeight()); diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/MappedSyncHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/MappedSyncHunk.java index 55dd06c94..5aa7167d6 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/MappedSyncHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/MappedSyncHunk.java @@ -48,15 +48,15 @@ public class MappedSyncHunk extends StorageHunk implements Hunk { } public boolean isEmpty() { - synchronized (data) { + synchronized(data) { return data.isEmpty(); } } @Override public void setRaw(int x, int y, int z, T t) { - synchronized (data) { - if (t == null) { + synchronized(data) { + if(t == null) { data.remove(index(x, y, z)); return; } @@ -71,10 +71,10 @@ public class MappedSyncHunk extends StorageHunk implements Hunk { @Override public synchronized Hunk iterateSync(Consumer4 c) { - synchronized (data) { + synchronized(data) { int idx, z; - for (Map.Entry g : data.entrySet()) { + for(Map.Entry g : data.entrySet()) { idx = g.getKey(); z = idx / (getWidth() * getHeight()); idx -= (z * getWidth() * getHeight()); @@ -87,10 +87,10 @@ public class MappedSyncHunk extends StorageHunk implements Hunk { @Override public synchronized Hunk iterateSyncIO(Consumer4IO c) throws IOException { - synchronized (data) { + synchronized(data) { int idx, z; - for (Map.Entry g : data.entrySet()) { + for(Map.Entry g : data.entrySet()) { idx = g.getKey(); z = idx / (getWidth() * getHeight()); idx -= (z * getWidth() * getHeight()); @@ -103,14 +103,14 @@ public class MappedSyncHunk extends StorageHunk implements Hunk { @Override public void empty(T b) { - synchronized (data) { + synchronized(data) { data.clear(); } } @Override public T getRaw(int x, int y, int z) { - synchronized (data) { + synchronized(data) { return data.get(index(x, y, z)); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/PaletteHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/PaletteHunk.java index ba30870e4..0620328e8 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/PaletteHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/PaletteHunk.java @@ -27,7 +27,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.IOException; -import java.util.concurrent.locks.ReentrantLock; @SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @@ -54,11 +53,11 @@ public class PaletteHunk extends StorageHunk implements Hunk { @Override public synchronized Hunk iterateSync(Consumer4 c) { - for (int i = 0; i < getWidth(); i++) { - for (int j = 0; j < getHeight(); j++) { - for (int k = 0; k < getDepth(); k++) { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { + for(int k = 0; k < getDepth(); k++) { T t = getRaw(i, j, k); - if (t != null) { + if(t != null) { c.accept(i, j, k, t); } } @@ -69,11 +68,11 @@ public class PaletteHunk extends StorageHunk implements Hunk { @Override public synchronized Hunk iterateSyncIO(Consumer4IO c) throws IOException { - for (int i = 0; i < getWidth(); i++) { - for (int j = 0; j < getHeight(); j++) { - for (int k = 0; k < getDepth(); k++) { + for(int i = 0; i < getWidth(); i++) { + for(int j = 0; j < getHeight(); j++) { + for(int k = 0; k < getDepth(); k++) { T t = getRaw(i, j, k); - if (t != null) { + if(t != null) { c.accept(i, j, k, t); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java index 9843e1b8b..282714487 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/PaletteOrHunk.java @@ -40,7 +40,7 @@ public abstract class PaletteOrHunk extends StorageHunk implements Hunk } public void setPalette(DataContainer c) { - if (isPalette()) { + if(isPalette()) { ((PaletteHunk) hunk).setPalette(c); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/StorageHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/StorageHunk.java index e4cb2c709..d1d805221 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/StorageHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/StorageHunk.java @@ -28,7 +28,7 @@ public abstract class StorageHunk implements Hunk { private final int depth; public StorageHunk(int width, int height, int depth) { - if (width <= 0 || height <= 0 || depth <= 0) { + if(width <= 0 || height <= 0 || depth <= 0) { throw new RuntimeException("Unsupported size " + width + " " + height + " " + depth); } diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/SynchronizedArrayHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/SynchronizedArrayHunk.java index a93e28ee5..bee2dfdad 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/SynchronizedArrayHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/SynchronizedArrayHunk.java @@ -38,14 +38,14 @@ public class SynchronizedArrayHunk extends StorageHunk implements Hunk @Override public void setRaw(int x, int y, int z, T t) { - synchronized (data) { + synchronized(data) { data[index(x, y, z)] = t; } } @Override public T getRaw(int x, int y, int z) { - synchronized (data) { + synchronized(data) { return data[index(x, y, z)]; } } @@ -56,7 +56,7 @@ public class SynchronizedArrayHunk extends StorageHunk implements Hunk @Override public void fill(T t) { - synchronized (data) { + synchronized(data) { Arrays.fill(data, t); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java index 43dcbaf75..ba2840ec2 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/BiomeGridHunkView.java @@ -55,19 +55,19 @@ public class BiomeGridHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, Biome t) { - chunk.setBiome(x, y+minHeight, z, t); + chunk.setBiome(x, y + minHeight, z, t); } @Override public Biome getRaw(int x, int y, int z) { - return chunk.getBiome(x, y+minHeight, z); + return chunk.getBiome(x, y + minHeight, z); } public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) { - if (chunk instanceof LinkedTerrainChunk) { - INMS.get().forceBiomeInto(x, y+minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome()); + if(chunk instanceof LinkedTerrainChunk) { + INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome()); return; } - INMS.get().forceBiomeInto(x, y+minHeight, z, somethingVeryDirty, chunk); + INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, chunk); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/ChunkBiomeHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/ChunkBiomeHunkView.java index fac0d443a..e5a959d43 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/ChunkBiomeHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/ChunkBiomeHunkView.java @@ -49,7 +49,7 @@ public class ChunkBiomeHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, Biome t) { - if (t == null) { + if(t == null) { return; } @@ -59,6 +59,6 @@ public class ChunkBiomeHunkView implements Hunk { @Override public Biome getRaw(int x, int y, int z) { return Iris.service(EditSVC.class) - .getBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16)); + .getBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16)); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java index 8dab96d69..80ab50a5c 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/ChunkDataHunkView.java @@ -47,24 +47,24 @@ public class ChunkDataHunkView implements Hunk { @Override public void set(int x1, int y1, int z1, int x2, int y2, int z2, BlockData t) { - if (t == null) { + if(t == null) { return; } - chunk.setRegion(x1, y1+chunk.getMinHeight(), z1, x2, y2+chunk.getMinHeight(), z2, t); + chunk.setRegion(x1, y1 + chunk.getMinHeight(), z1, x2, y2 + chunk.getMinHeight(), z2, t); } @Override public void setRaw(int x, int y, int z, BlockData t) { - if (t == null) { + if(t == null) { return; } - chunk.setBlock(x, y+chunk.getMinHeight(), z, t); + chunk.setBlock(x, y + chunk.getMinHeight(), z, t); } @Override public BlockData getRaw(int x, int y, int z) { - return chunk.getBlockData(x, y+chunk.getMinHeight(), z); + return chunk.getBlockData(x, y + chunk.getMinHeight(), z); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/ChunkHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/ChunkHunkView.java index ec0f81996..13b029d7f 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/ChunkHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/ChunkHunkView.java @@ -49,7 +49,7 @@ public class ChunkHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, BlockData t) { - if (t == null) { + if(t == null) { return; } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/FunctionalHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/FunctionalHunkView.java index da8b4df13..a3aac40f6 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/FunctionalHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/FunctionalHunkView.java @@ -35,7 +35,7 @@ public class FunctionalHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - if (backConverter == null) { + if(backConverter == null) { throw new UnsupportedOperationException("You cannot writeNodeData to this hunk (Read Only)"); } @@ -44,7 +44,7 @@ public class FunctionalHunkView implements Hunk { @Override public T getRaw(int x, int y, int z) { - if (converter == null) { + if(converter == null) { throw new UnsupportedOperationException("You cannot read this hunk (Write Only)"); } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/RotatedXHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/RotatedXHunkView.java index 6ecf57b70..2637f284e 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/RotatedXHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/RotatedXHunkView.java @@ -36,9 +36,9 @@ public class RotatedXHunkView implements Hunk { int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f)); int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f)); src.setIfExists(x, - (int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc, - (int) Math.round(sin * y - yc + cos * (z - zc)) - zc, - t); + (int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc, + (int) Math.round(sin * y - yc + cos * (z - zc)) - zc, + t); } @Override @@ -46,8 +46,8 @@ public class RotatedXHunkView implements Hunk { int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f)); int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f)); return src.getIfExists(x, - (int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc, - (int) Math.round(sin * y - yc + cos * (z - zc)) - zc + (int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc, + (int) Math.round(sin * y - yc + cos * (z - zc)) - zc ); } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/RotatedYHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/RotatedYHunkView.java index 25cba47cf..626e44a60 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/RotatedYHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/RotatedYHunkView.java @@ -36,9 +36,9 @@ public class RotatedYHunkView implements Hunk { int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f)); int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f)); src.setIfExists((int) - Math.round(cos * (x - xc) + sin * (z - zc)) - xc, - y, - (int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc, t); + Math.round(cos * (x - xc) + sin * (z - zc)) - xc, + y, + (int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc, t); } @Override @@ -46,9 +46,9 @@ public class RotatedYHunkView implements Hunk { int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f)); int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f)); return src.getIfExists( - (int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc, - y, - (int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc + (int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc, + y, + (int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc ); } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/RotatedZHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/RotatedZHunkView.java index dda7c6239..452744589 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/RotatedZHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/RotatedZHunkView.java @@ -43,8 +43,8 @@ public class RotatedZHunkView implements Hunk { int xc = (int) Math.round(cos * (getWidth() / 2f) - sin * (getHeight() / 2f)); int yc = (int) Math.round(sin * (getWidth() / 2f) + cos * (getHeight() / 2f)); return src.getIfExists((int) Math.round(cos * (x - xc) - sin * (y - yc)) - xc, - (int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc - , z); + (int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc + , z); } @Override diff --git a/src/main/java/com/volmit/iris/util/hunk/view/SynchronizedHunkView.java b/src/main/java/com/volmit/iris/util/hunk/view/SynchronizedHunkView.java index e98d6ef77..065f67bf7 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/SynchronizedHunkView.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/SynchronizedHunkView.java @@ -30,7 +30,7 @@ public class SynchronizedHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - synchronized (src) { + synchronized(src) { src.setRaw(x, y, z, t); } } diff --git a/src/main/java/com/volmit/iris/util/hunk/view/WriteTrackHunk.java b/src/main/java/com/volmit/iris/util/hunk/view/WriteTrackHunk.java index 987ac3c1e..8010ac120 100644 --- a/src/main/java/com/volmit/iris/util/hunk/view/WriteTrackHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/view/WriteTrackHunk.java @@ -34,7 +34,7 @@ public class WriteTrackHunk implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - if (!b.get()) { + if(!b.get()) { b.set(true); } diff --git a/src/main/java/com/volmit/iris/util/interpolation/IrisInterpolation.java b/src/main/java/com/volmit/iris/util/interpolation/IrisInterpolation.java index f759244da..59d5f0642 100644 --- a/src/main/java/com/volmit/iris/util/interpolation/IrisInterpolation.java +++ b/src/main/java/com/volmit/iris/util/interpolation/IrisInterpolation.java @@ -69,19 +69,19 @@ public class IrisInterpolation { } public static double blerp(double a, double b, double c, double d, double tx, double ty, InterpolationType type) { - if (type.equals(InterpolationType.LINEAR)) { + if(type.equals(InterpolationType.LINEAR)) { return blerp(a, b, c, d, tx, ty); } - if (type.equals(InterpolationType.BEZIER)) { + if(type.equals(InterpolationType.BEZIER)) { return blerpBezier(a, b, c, d, tx, ty); } - if (type.equals(InterpolationType.PARAMETRIC_2)) { + if(type.equals(InterpolationType.PARAMETRIC_2)) { return blerpParametric(a, b, c, d, tx, ty, 2); } - if (type.equals(InterpolationType.PARAMETRIC_4)) { + if(type.equals(InterpolationType.PARAMETRIC_4)) { return blerpParametric(a, b, c, d, tx, ty, 4); } @@ -111,22 +111,22 @@ public class IrisInterpolation { public static double bihermiteBezier(double p00, double p01, double p02, double p03, double p10, double p11, double p12, double p13, double p20, double p21, double p22, double p23, double p30, double p31, double p32, double p33, double mux, double muy, double tension, double bias) { //@builder return hermiteBezier( - hermiteBezier(p00, p01, p02, p03, muy, tension, bias), - hermiteBezier(p10, p11, p12, p13, muy, tension, bias), - hermiteBezier(p20, p21, p22, p23, muy, tension, bias), - hermiteBezier(p30, p31, p32, p33, muy, tension, bias), - mux, tension, bias); + hermiteBezier(p00, p01, p02, p03, muy, tension, bias), + hermiteBezier(p10, p11, p12, p13, muy, tension, bias), + hermiteBezier(p20, p21, p22, p23, muy, tension, bias), + hermiteBezier(p30, p31, p32, p33, muy, tension, bias), + mux, tension, bias); //@done } public static double bihermiteParametric(double p00, double p01, double p02, double p03, double p10, double p11, double p12, double p13, double p20, double p21, double p22, double p23, double p30, double p31, double p32, double p33, double mux, double muy, double tension, double bias, double a) { //@builder return hermiteParametric( - hermiteParametric(p00, p01, p02, p03, muy, tension, bias, a), - hermiteParametric(p10, p11, p12, p13, muy, tension, bias, a), - hermiteParametric(p20, p21, p22, p23, muy, tension, bias, a), - hermiteParametric(p30, p31, p32, p33, muy, tension, bias, a), - mux, tension, bias, a); + hermiteParametric(p00, p01, p02, p03, muy, tension, bias, a), + hermiteParametric(p10, p11, p12, p13, muy, tension, bias, a), + hermiteParametric(p20, p21, p22, p23, muy, tension, bias, a), + hermiteParametric(p30, p31, p32, p33, muy, tension, bias, a), + mux, tension, bias, a); //@done } @@ -171,49 +171,49 @@ public class IrisInterpolation { public static double bicubic(double p00, double p01, double p02, double p03, double p10, double p11, double p12, double p13, double p20, double p21, double p22, double p23, double p30, double p31, double p32, double p33, double mux, double muy) { //@builder return cubic( - cubic(p00, p01, p02, p03, muy), - cubic(p10, p11, p12, p13, muy), - cubic(p20, p21, p22, p23, muy), - cubic(p30, p31, p32, p33, muy), - mux); + cubic(p00, p01, p02, p03, muy), + cubic(p10, p11, p12, p13, muy), + cubic(p20, p21, p22, p23, muy), + cubic(p30, p31, p32, p33, muy), + mux); //@done } public static double bihermite(double p00, double p01, double p02, double p03, double p10, double p11, double p12, double p13, double p20, double p21, double p22, double p23, double p30, double p31, double p32, double p33, double mux, double muy, double tension, double bias) { //@builder return hermite( - hermite(p00, p01, p02, p03, muy, tension, bias), - hermite(p10, p11, p12, p13, muy, tension, bias), - hermite(p20, p21, p22, p23, muy, tension, bias), - hermite(p30, p31, p32, p33, muy, tension, bias), - mux, tension, bias); + hermite(p00, p01, p02, p03, muy, tension, bias), + hermite(p10, p11, p12, p13, muy, tension, bias), + hermite(p20, p21, p22, p23, muy, tension, bias), + hermite(p30, p31, p32, p33, muy, tension, bias), + mux, tension, bias); //@done } public static double trihermite(double p000, double p001, double p002, double p003, double p010, double p011, double p012, double p013, double p020, double p021, double p022, double p023, double p030, double p031, double p032, double p033, double p100, double p101, double p102, double p103, double p110, double p111, double p112, double p113, double p120, double p121, double p122, double p123, double p130, double p131, double p132, double p133, double p200, double p201, double p202, double p203, double p210, double p211, double p212, double p213, double p220, double p221, double p222, double p223, double p230, double p231, double p232, double p233, double p300, double p301, double p302, double p303, double p310, double p311, double p312, double p313, double p320, double p321, double p322, double p323, double p330, double p331, double p332, double p333, double mux, double muy, double muz, double tension, double bias) { //@builder return hermite( - bihermite(p000, p001, p002, p003, - p010, p011, p012, p013, - p020, p021, p022, p023, - p030, p031, p032, p033, - mux, muy, tension, bias), - bihermite(p100, p101, p102, p103, - p110, p111, p112, p113, - p120, p121, p122, p123, - p130, p131, p132, p133, - mux, muy, tension, bias), - bihermite(p200, p201, p202, p203, - p210, p211, p212, p213, - p220, p221, p222, p223, - p230, p231, p232, p233, - mux, muy, tension, bias), - bihermite(p300, p301, p302, p303, - p310, p311, p312, p313, - p320, p321, p322, p323, - p330, p331, p332, p333, - mux, muy, tension, bias), - muz, tension, bias); + bihermite(p000, p001, p002, p003, + p010, p011, p012, p013, + p020, p021, p022, p023, + p030, p031, p032, p033, + mux, muy, tension, bias), + bihermite(p100, p101, p102, p103, + p110, p111, p112, p113, + p120, p121, p122, p123, + p130, p131, p132, p133, + mux, muy, tension, bias), + bihermite(p200, p201, p202, p203, + p210, p211, p212, p213, + p220, p221, p222, p223, + p230, p231, p232, p233, + mux, muy, tension, bias), + bihermite(p300, p301, p302, p303, + p310, p311, p312, p313, + p320, p321, p322, p323, + p330, p331, p332, p333, + mux, muy, tension, bias), + muz, tension, bias); //@done } @@ -226,27 +226,27 @@ public class IrisInterpolation { double p012, double p013, double p020, double p021, double p022, double p023, double p030, double p031, double p032, double p033, double p100, double p101, double p102, double p103, double p110, double p111, double p112, double p113, double p120, double p121, double p122, double p123, double p130, double p131, double p132, double p133, double p200, double p201, double p202, double p203, double p210, double p211, double p212, double p213, double p220, double p221, double p222, double p223, double p230, double p231, double p232, double p233, double p300, double p301, double p302, double p303, double p310, double p311, double p312, double p313, double p320, double p321, double p322, double p323, double p330, double p331, double p332, double p333, double mux, double muy, double muz) { //@builder return cubic( - bicubic(p000, p001, p002, p003, - p010, p011, p012, p013, - p020, p021, p022, p023, - p030, p031, p032, p033, - mux, muy), - bicubic(p100, p101, p102, p103, - p110, p111, p112, p113, - p120, p121, p122, p123, - p130, p131, p132, p133, - mux, muy), - bicubic(p200, p201, p202, p203, - p210, p211, p212, p213, - p220, p221, p222, p223, - p230, p231, p232, p233, - mux, muy), - bicubic(p300, p301, p302, p303, - p310, p311, p312, p313, - p320, p321, p322, p323, - p330, p331, p332, p333, - mux, muy), - muz); + bicubic(p000, p001, p002, p003, + p010, p011, p012, p013, + p020, p021, p022, p023, + p030, p031, p032, p033, + mux, muy), + bicubic(p100, p101, p102, p103, + p110, p111, p112, p113, + p120, p121, p122, p123, + p130, p131, p132, p133, + mux, muy), + bicubic(p200, p201, p202, p203, + p210, p211, p212, p213, + p220, p221, p222, p223, + p230, p231, p232, p233, + mux, muy), + bicubic(p300, p301, p302, p303, + p310, p311, p312, p313, + p320, p321, p322, p323, + p330, p331, p332, p333, + mux, muy), + muz); //@done } @@ -265,22 +265,22 @@ public class IrisInterpolation { public static double bicubicBezier(double p00, double p01, double p02, double p03, double p10, double p11, double p12, double p13, double p20, double p21, double p22, double p23, double p30, double p31, double p32, double p33, double mux, double muy) { //@builder return cubicBezier( - cubicBezier(p00, p01, p02, p03, muy), - cubicBezier(p10, p11, p12, p13, muy), - cubicBezier(p20, p21, p22, p23, muy), - cubicBezier(p30, p31, p32, p33, muy), - mux); + cubicBezier(p00, p01, p02, p03, muy), + cubicBezier(p10, p11, p12, p13, muy), + cubicBezier(p20, p21, p22, p23, muy), + cubicBezier(p30, p31, p32, p33, muy), + mux); //@done } public static double bicubicParametric(double p00, double p01, double p02, double p03, double p10, double p11, double p12, double p13, double p20, double p21, double p22, double p23, double p30, double p31, double p32, double p33, double mux, double muy, double a) { //@builder return cubicParametric( - cubicParametric(p00, p01, p02, p03, muy, a), - cubicParametric(p10, p11, p12, p13, muy, a), - cubicParametric(p20, p21, p22, p23, muy, a), - cubicParametric(p30, p31, p32, p33, muy, a), - mux, a); + cubicParametric(p00, p01, p02, p03, muy, a), + cubicParametric(p10, p11, p12, p13, muy, a), + cubicParametric(p20, p21, p22, p23, muy, a), + cubicParametric(p30, p31, p32, p33, muy, a), + mux, a); //@done } @@ -296,18 +296,18 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return blerp( - n.noise(x1, z1), - n.noise(x2, z1), - n.noise(x1, z2), - n.noise(x2, z2), - px, pz); + n.noise(x1, z1), + n.noise(x2, z1), + n.noise(x1, z2), + n.noise(x2, z2), + px, pz); //@done } public static void test(String m, Consumer2 f) { PrecisionStopwatch p = PrecisionStopwatch.start(); - for (int i = 0; i < 8192; i++) { + for(int i = 0; i < 8192; i++) { f.accept(i, -i * 234); } @@ -336,12 +336,12 @@ public class IrisInterpolation { StringBuilder fb = new StringBuilder(); StringBuilder sb = new StringBuilder(); - if (array) { + if(array) { fb.append("private static final double[] F" + (int) checks + "A = {"); } sb.append("private static double sc" + (int) checks + "(int x, int z, double r, NoiseProvider n) {\n return ("); - for (int i = 0; i < 360; i += m) { + for(int i = 0; i < 360; i += m) { double sin = Math.sin(Math.toRadians(i)); double cos = Math.cos(Math.toRadians(i)); String cof = new BigDecimal(cos).toPlainString(); @@ -349,7 +349,7 @@ public class IrisInterpolation { String cc = array ? "F" + (int) checks + "A[" + (igx++) + "]" : "F" + (int) checks + "C" + ig; String ss = array ? "F" + (int) checks + "A[" + (igx++) + "]" : "F" + (int) checks + "S" + ig; - if (array) { + if(array) { fb.append((ig > 0 ? (ig % 6 == 0 ? ",\n" : ",") : "") + cof + "," + sif); } else { fb.append("private static final double " + cc + " = " + cof + ";\n"); @@ -360,7 +360,7 @@ public class IrisInterpolation { ig++; } - if (array) { + if(array) { fb.append("};"); } @@ -370,8 +370,8 @@ public class IrisInterpolation { public static double getStarcast3D(int x, int y, int z, double rad, double checks, NoiseProvider3 n) { return (Starcast.starcast(x, z, rad, checks, (xx, zz) -> n.noise(xx, y, zz)) - + Starcast.starcast(x, y, rad, checks, (xx, yy) -> n.noise(xx, yy, z)) - + Starcast.starcast(y, z, rad, checks, (yy, zz) -> n.noise(x, yy, zz))) / 3D; + + Starcast.starcast(x, y, rad, checks, (xx, yy) -> n.noise(xx, yy, z)) + + Starcast.starcast(y, z, rad, checks, (yy, zz) -> n.noise(x, yy, zz))) / 3D; } public static double getBilinearBezierNoise(int x, int z, double rad, NoiseProvider n) { @@ -385,11 +385,11 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return blerpBezier( - n.noise(x1, z1), - n.noise(x2, z1), - n.noise(x1, z2), - n.noise(x2, z2), - px, pz); + n.noise(x1, z1), + n.noise(x2, z1), + n.noise(x1, z2), + n.noise(x2, z2), + px, pz); //@done } @@ -404,11 +404,11 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return blerpParametric( - n.noise(x1, z1), - n.noise(x2, z1), - n.noise(x1, z2), - n.noise(x2, z2), - px, pz, a); + n.noise(x1, z1), + n.noise(x2, z1), + n.noise(x1, z2), + n.noise(x2, z2), + px, pz, a); //@done } @@ -431,15 +431,15 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return trilerp( - n.noise(x1, y1, z1), - n.noise(x2, y1, z1), - n.noise(x1, y2, z1), - n.noise(x2, y2, z1), - n.noise(x1, y1, z2), - n.noise(x2, y1, z2), - n.noise(x1, y2, z2), - n.noise(x2, y2, z2), - px, py, pz); + n.noise(x1, y1, z1), + n.noise(x2, y1, z1), + n.noise(x1, y2, z1), + n.noise(x2, y2, z1), + n.noise(x1, y1, z2), + n.noise(x2, y1, z2), + n.noise(x1, y2, z2), + n.noise(x2, y2, z2), + px, py, pz); //@done } @@ -470,71 +470,71 @@ public class IrisInterpolation { //!!!!!!!!!!!!!!!!!! 2 1 3 return tricubic( - n.noise(x0, y0, z0), - n.noise(x0, y1, z0), - n.noise(x0, y2, z0), - n.noise(x0, y3, z0), - n.noise(x1, y0, z0), - n.noise(x1, y1, z0), - n.noise(x1, y2, z0), - n.noise(x1, y3, z0), - n.noise(x2, y0, z0), - n.noise(x2, y1, z0), - n.noise(x2, y2, z0), - n.noise(x2, y3, z0), - n.noise(x3, y0, z0), - n.noise(x3, y1, z0), - n.noise(x3, y2, z0), - n.noise(x3, y3, z0), - n.noise(x0, y0, z1), - n.noise(x0, y1, z1), - n.noise(x0, y2, z1), - n.noise(x0, y3, z1), - n.noise(x1, y0, z1), - n.noise(x1, y1, z1), - n.noise(x1, y2, z1), - n.noise(x1, y3, z1), - n.noise(x2, y0, z1), - n.noise(x2, y1, z1), - n.noise(x2, y2, z1), - n.noise(x2, y3, z1), - n.noise(x3, y0, z1), - n.noise(x3, y1, z1), - n.noise(x3, y2, z1), - n.noise(x3, y3, z1), - n.noise(x0, y0, z2), - n.noise(x0, y1, z2), - n.noise(x0, y2, z2), - n.noise(x0, y3, z2), - n.noise(x1, y0, z2), - n.noise(x1, y1, z2), - n.noise(x1, y2, z2), - n.noise(x1, y3, z2), - n.noise(x2, y0, z2), - n.noise(x2, y1, z2), - n.noise(x2, y2, z2), - n.noise(x2, y3, z2), - n.noise(x3, y0, z2), - n.noise(x3, y1, z2), - n.noise(x3, y2, z2), - n.noise(x3, y3, z2), - n.noise(x0, y0, z3), - n.noise(x0, y1, z3), - n.noise(x0, y2, z3), - n.noise(x0, y3, z3), - n.noise(x1, y0, z3), - n.noise(x1, y1, z3), - n.noise(x1, y2, z3), - n.noise(x1, y3, z3), - n.noise(x2, y0, z3), - n.noise(x2, y1, z3), - n.noise(x2, y2, z3), - n.noise(x2, y3, z3), - n.noise(x3, y0, z3), - n.noise(x3, y1, z3), - n.noise(x3, y2, z3), - n.noise(x3, y3, z3), - px, py, pz); + n.noise(x0, y0, z0), + n.noise(x0, y1, z0), + n.noise(x0, y2, z0), + n.noise(x0, y3, z0), + n.noise(x1, y0, z0), + n.noise(x1, y1, z0), + n.noise(x1, y2, z0), + n.noise(x1, y3, z0), + n.noise(x2, y0, z0), + n.noise(x2, y1, z0), + n.noise(x2, y2, z0), + n.noise(x2, y3, z0), + n.noise(x3, y0, z0), + n.noise(x3, y1, z0), + n.noise(x3, y2, z0), + n.noise(x3, y3, z0), + n.noise(x0, y0, z1), + n.noise(x0, y1, z1), + n.noise(x0, y2, z1), + n.noise(x0, y3, z1), + n.noise(x1, y0, z1), + n.noise(x1, y1, z1), + n.noise(x1, y2, z1), + n.noise(x1, y3, z1), + n.noise(x2, y0, z1), + n.noise(x2, y1, z1), + n.noise(x2, y2, z1), + n.noise(x2, y3, z1), + n.noise(x3, y0, z1), + n.noise(x3, y1, z1), + n.noise(x3, y2, z1), + n.noise(x3, y3, z1), + n.noise(x0, y0, z2), + n.noise(x0, y1, z2), + n.noise(x0, y2, z2), + n.noise(x0, y3, z2), + n.noise(x1, y0, z2), + n.noise(x1, y1, z2), + n.noise(x1, y2, z2), + n.noise(x1, y3, z2), + n.noise(x2, y0, z2), + n.noise(x2, y1, z2), + n.noise(x2, y2, z2), + n.noise(x2, y3, z2), + n.noise(x3, y0, z2), + n.noise(x3, y1, z2), + n.noise(x3, y2, z2), + n.noise(x3, y3, z2), + n.noise(x0, y0, z3), + n.noise(x0, y1, z3), + n.noise(x0, y2, z3), + n.noise(x0, y3, z3), + n.noise(x1, y0, z3), + n.noise(x1, y1, z3), + n.noise(x1, y2, z3), + n.noise(x1, y3, z3), + n.noise(x2, y0, z3), + n.noise(x2, y1, z3), + n.noise(x2, y2, z3), + n.noise(x2, y3, z3), + n.noise(x3, y0, z3), + n.noise(x3, y1, z3), + n.noise(x3, y2, z3), + n.noise(x3, y3, z3), + px, py, pz); //@done } @@ -573,71 +573,71 @@ public class IrisInterpolation { //!!!!!!!!!!!!!!!!!! 2 1 3 return trihermite( - n.noise(x0, y0, z0), - n.noise(x0, y1, z0), - n.noise(x0, y2, z0), - n.noise(x0, y3, z0), - n.noise(x1, y0, z0), - n.noise(x1, y1, z0), - n.noise(x1, y2, z0), - n.noise(x1, y3, z0), - n.noise(x2, y0, z0), - n.noise(x2, y1, z0), - n.noise(x2, y2, z0), - n.noise(x2, y3, z0), - n.noise(x3, y0, z0), - n.noise(x3, y1, z0), - n.noise(x3, y2, z0), - n.noise(x3, y3, z0), - n.noise(x0, y0, z1), - n.noise(x0, y1, z1), - n.noise(x0, y2, z1), - n.noise(x0, y3, z1), - n.noise(x1, y0, z1), - n.noise(x1, y1, z1), - n.noise(x1, y2, z1), - n.noise(x1, y3, z1), - n.noise(x2, y0, z1), - n.noise(x2, y1, z1), - n.noise(x2, y2, z1), - n.noise(x2, y3, z1), - n.noise(x3, y0, z1), - n.noise(x3, y1, z1), - n.noise(x3, y2, z1), - n.noise(x3, y3, z1), - n.noise(x0, y0, z2), - n.noise(x0, y1, z2), - n.noise(x0, y2, z2), - n.noise(x0, y3, z2), - n.noise(x1, y0, z2), - n.noise(x1, y1, z2), - n.noise(x1, y2, z2), - n.noise(x1, y3, z2), - n.noise(x2, y0, z2), - n.noise(x2, y1, z2), - n.noise(x2, y2, z2), - n.noise(x2, y3, z2), - n.noise(x3, y0, z2), - n.noise(x3, y1, z2), - n.noise(x3, y2, z2), - n.noise(x3, y3, z2), - n.noise(x0, y0, z3), - n.noise(x0, y1, z3), - n.noise(x0, y2, z3), - n.noise(x0, y3, z3), - n.noise(x1, y0, z3), - n.noise(x1, y1, z3), - n.noise(x1, y2, z3), - n.noise(x1, y3, z3), - n.noise(x2, y0, z3), - n.noise(x2, y1, z3), - n.noise(x2, y2, z3), - n.noise(x2, y3, z3), - n.noise(x3, y0, z3), - n.noise(x3, y1, z3), - n.noise(x3, y2, z3), - n.noise(x3, y3, z3), - px, py, pz, tension, bias); + n.noise(x0, y0, z0), + n.noise(x0, y1, z0), + n.noise(x0, y2, z0), + n.noise(x0, y3, z0), + n.noise(x1, y0, z0), + n.noise(x1, y1, z0), + n.noise(x1, y2, z0), + n.noise(x1, y3, z0), + n.noise(x2, y0, z0), + n.noise(x2, y1, z0), + n.noise(x2, y2, z0), + n.noise(x2, y3, z0), + n.noise(x3, y0, z0), + n.noise(x3, y1, z0), + n.noise(x3, y2, z0), + n.noise(x3, y3, z0), + n.noise(x0, y0, z1), + n.noise(x0, y1, z1), + n.noise(x0, y2, z1), + n.noise(x0, y3, z1), + n.noise(x1, y0, z1), + n.noise(x1, y1, z1), + n.noise(x1, y2, z1), + n.noise(x1, y3, z1), + n.noise(x2, y0, z1), + n.noise(x2, y1, z1), + n.noise(x2, y2, z1), + n.noise(x2, y3, z1), + n.noise(x3, y0, z1), + n.noise(x3, y1, z1), + n.noise(x3, y2, z1), + n.noise(x3, y3, z1), + n.noise(x0, y0, z2), + n.noise(x0, y1, z2), + n.noise(x0, y2, z2), + n.noise(x0, y3, z2), + n.noise(x1, y0, z2), + n.noise(x1, y1, z2), + n.noise(x1, y2, z2), + n.noise(x1, y3, z2), + n.noise(x2, y0, z2), + n.noise(x2, y1, z2), + n.noise(x2, y2, z2), + n.noise(x2, y3, z2), + n.noise(x3, y0, z2), + n.noise(x3, y1, z2), + n.noise(x3, y2, z2), + n.noise(x3, y3, z2), + n.noise(x0, y0, z3), + n.noise(x0, y1, z3), + n.noise(x0, y2, z3), + n.noise(x0, y3, z3), + n.noise(x1, y0, z3), + n.noise(x1, y1, z3), + n.noise(x1, y2, z3), + n.noise(x1, y3, z3), + n.noise(x2, y0, z3), + n.noise(x2, y1, z3), + n.noise(x2, y2, z3), + n.noise(x2, y3, z3), + n.noise(x3, y0, z3), + n.noise(x3, y1, z3), + n.noise(x3, y2, z3), + n.noise(x3, y3, z3), + px, py, pz, tension, bias); //@done } @@ -652,11 +652,11 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return blerpSinCenter( - n.noise(x1, z1), - n.noise(x2, z1), - n.noise(x1, z2), - n.noise(x2, z2), - px, pz); + n.noise(x1, z1), + n.noise(x2, z1), + n.noise(x1, z2), + n.noise(x2, z2), + px, pz); //@done } @@ -675,23 +675,23 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return bicubic( - n.noise(x0, z0), - n.noise(x0, z1), - n.noise(x0, z2), - n.noise(x0, z3), - n.noise(x1, z0), - n.noise(x1, z1), - n.noise(x1, z2), - n.noise(x1, z3), - n.noise(x2, z0), - n.noise(x2, z1), - n.noise(x2, z2), - n.noise(x2, z3), - n.noise(x3, z0), - n.noise(x3, z1), - n.noise(x3, z2), - n.noise(x3, z3), - px, pz); + n.noise(x0, z0), + n.noise(x0, z1), + n.noise(x0, z2), + n.noise(x0, z3), + n.noise(x1, z0), + n.noise(x1, z1), + n.noise(x1, z2), + n.noise(x1, z3), + n.noise(x2, z0), + n.noise(x2, z1), + n.noise(x2, z2), + n.noise(x2, z3), + n.noise(x3, z0), + n.noise(x3, z1), + n.noise(x3, z2), + n.noise(x3, z3), + px, pz); //@done } @@ -710,23 +710,23 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return bicubicBezier( - n.noise(x0, z0), - n.noise(x0, z1), - n.noise(x0, z2), - n.noise(x0, z3), - n.noise(x1, z0), - n.noise(x1, z1), - n.noise(x1, z2), - n.noise(x1, z3), - n.noise(x2, z0), - n.noise(x2, z1), - n.noise(x2, z2), - n.noise(x2, z3), - n.noise(x3, z0), - n.noise(x3, z1), - n.noise(x3, z2), - n.noise(x3, z3), - px, pz); + n.noise(x0, z0), + n.noise(x0, z1), + n.noise(x0, z2), + n.noise(x0, z3), + n.noise(x1, z0), + n.noise(x1, z1), + n.noise(x1, z2), + n.noise(x1, z3), + n.noise(x2, z0), + n.noise(x2, z1), + n.noise(x2, z2), + n.noise(x2, z3), + n.noise(x3, z0), + n.noise(x3, z1), + n.noise(x3, z2), + n.noise(x3, z3), + px, pz); //@done } @@ -745,23 +745,23 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return bicubicParametric( - n.noise(x0, z0), - n.noise(x0, z1), - n.noise(x0, z2), - n.noise(x0, z3), - n.noise(x1, z0), - n.noise(x1, z1), - n.noise(x1, z2), - n.noise(x1, z3), - n.noise(x2, z0), - n.noise(x2, z1), - n.noise(x2, z2), - n.noise(x2, z3), - n.noise(x3, z0), - n.noise(x3, z1), - n.noise(x3, z2), - n.noise(x3, z3), - px, pz, a); + n.noise(x0, z0), + n.noise(x0, z1), + n.noise(x0, z2), + n.noise(x0, z3), + n.noise(x1, z0), + n.noise(x1, z1), + n.noise(x1, z2), + n.noise(x1, z3), + n.noise(x2, z0), + n.noise(x2, z1), + n.noise(x2, z2), + n.noise(x2, z3), + n.noise(x3, z0), + n.noise(x3, z1), + n.noise(x3, z2), + n.noise(x3, z3), + px, pz, a); //@done } @@ -792,23 +792,23 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return bihermite( - n.noise(x0, z0), - n.noise(x0, z1), - n.noise(x0, z2), - n.noise(x0, z3), - n.noise(x1, z0), - n.noise(x1, z1), - n.noise(x1, z2), - n.noise(x1, z3), - n.noise(x2, z0), - n.noise(x2, z1), - n.noise(x2, z2), - n.noise(x2, z3), - n.noise(x3, z0), - n.noise(x3, z1), - n.noise(x3, z2), - n.noise(x3, z3), - px, pz, t, b); + n.noise(x0, z0), + n.noise(x0, z1), + n.noise(x0, z2), + n.noise(x0, z3), + n.noise(x1, z0), + n.noise(x1, z1), + n.noise(x1, z2), + n.noise(x1, z3), + n.noise(x2, z0), + n.noise(x2, z1), + n.noise(x2, z2), + n.noise(x2, z3), + n.noise(x3, z0), + n.noise(x3, z1), + n.noise(x3, z2), + n.noise(x3, z3), + px, pz, t, b); //@done } @@ -827,23 +827,23 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return bihermiteBezier( - n.noise(x0, z0), - n.noise(x0, z1), - n.noise(x0, z2), - n.noise(x0, z3), - n.noise(x1, z0), - n.noise(x1, z1), - n.noise(x1, z2), - n.noise(x1, z3), - n.noise(x2, z0), - n.noise(x2, z1), - n.noise(x2, z2), - n.noise(x2, z3), - n.noise(x3, z0), - n.noise(x3, z1), - n.noise(x3, z2), - n.noise(x3, z3), - px, pz, t, b); + n.noise(x0, z0), + n.noise(x0, z1), + n.noise(x0, z2), + n.noise(x0, z3), + n.noise(x1, z0), + n.noise(x1, z1), + n.noise(x1, z2), + n.noise(x1, z3), + n.noise(x2, z0), + n.noise(x2, z1), + n.noise(x2, z2), + n.noise(x2, z3), + n.noise(x3, z0), + n.noise(x3, z1), + n.noise(x3, z2), + n.noise(x3, z3), + px, pz, t, b); //@done } @@ -862,23 +862,23 @@ public class IrisInterpolation { double pz = rangeScale(0, 1, z1, z2, z); //@builder return bihermiteParametric( - n.noise(x0, z0), - n.noise(x0, z1), - n.noise(x0, z2), - n.noise(x0, z3), - n.noise(x1, z0), - n.noise(x1, z1), - n.noise(x1, z2), - n.noise(x1, z3), - n.noise(x2, z0), - n.noise(x2, z1), - n.noise(x2, z2), - n.noise(x2, z3), - n.noise(x3, z0), - n.noise(x3, z1), - n.noise(x3, z2), - n.noise(x3, z3), - px, pz, t, b, a); + n.noise(x0, z0), + n.noise(x0, z1), + n.noise(x0, z2), + n.noise(x0, z3), + n.noise(x1, z0), + n.noise(x1, z1), + n.noise(x1, z2), + n.noise(x1, z3), + n.noise(x2, z0), + n.noise(x2, z1), + n.noise(x2, z2), + n.noise(x2, z3), + n.noise(x3, z0), + n.noise(x3, z1), + n.noise(x3, z2), + n.noise(x3, z3), + px, pz, t, b, a); //@done } @@ -888,7 +888,7 @@ public class IrisInterpolation { AtomicDouble accessZ = new AtomicDouble(); NoiseProvider np = (x1, z1) -> { double d = Math.max(Math.abs(x1), Math.abs(z1)); - if (d > rad.get()) { + if(d > rad.get()) { rad.set(d); } return 0; @@ -898,7 +898,7 @@ public class IrisInterpolation { } public static double getNoise3D(InterpolationMethod3D method, int x, int y, int z, double radx, double rady, double radz, NoiseProvider3 n) { - return switch (method) { + return switch(method) { case TRILINEAR -> getTrilinear(x, y, z, radx, rady, radz, n); case TRICUBIC -> getTricubic(x, y, z, radx, rady, radz, n); case TRIHERMITE -> getTrihermite(x, y, z, radx, rady, radz, n); @@ -921,17 +921,28 @@ public class IrisInterpolation { /** * Get the interpolated 3D noise within a given cuboid size with offsets * - * @param method the interpolation method to use - * @param xo the x offset for noise - * @param yo the y offset for noise - * @param zo the z offset for noise - * @param w the width of the result - * @param h the height of the result - * @param d the depth of the result - * @param radX the interpolation radius for the x axis - * @param radY the interpolation radius for the y axis - * @param radZ the interpolation radius for the z axis - * @param n the noise provider + * @param method + * the interpolation method to use + * @param xo + * the x offset for noise + * @param yo + * the y offset for noise + * @param zo + * the z offset for noise + * @param w + * the width of the result + * @param h + * the height of the result + * @param d + * the depth of the result + * @param radX + * the interpolation radius for the x axis + * @param radY + * the interpolation radius for the y axis + * @param radZ + * the interpolation radius for the z axis + * @param n + * the noise provider * @return the resulting hunk of noise */ public static Hunk getNoise3D(InterpolationMethod3D method, int xo, int yo, int zo, int w, int h, int d, double radX, double radY, double radZ, NoiseProvider3 n) { @@ -939,15 +950,15 @@ public class IrisInterpolation { HashMap cache = new HashMap<>(); int i, j, k; - for (i = 0; i < w; i++) { + for(i = 0; i < w; i++) { int fi = i; - for (j = 0; j < h; j++) { + for(j = 0; j < h; j++) { int fj = j; - for (k = 0; k < d; k++) { + for(k = 0; k < d; k++) { int fk = k; hunk.set(i, j, k, cache.computeIfAbsent((k * w * h) + (j * w) + i, (p) - -> getNoise3D(method, fi + xo, fj + yo, fk + zo, - radX, radY, radZ, n))); + -> getNoise3D(method, fi + xo, fj + yo, fk + zo, + radX, radY, radZ, n))); } } } @@ -960,57 +971,57 @@ public class IrisInterpolation { } public static double getNoise(InterpolationMethod method, int x, int z, double h, NoiseProvider n) { - if (method.equals(InterpolationMethod.BILINEAR)) { + if(method.equals(InterpolationMethod.BILINEAR)) { return getBilinearNoise(x, z, h, n); - } else if (method.equals(InterpolationMethod.STARCAST_3)) { + } else if(method.equals(InterpolationMethod.STARCAST_3)) { return Starcast.starcast(x, z, h, 3D, n); - } else if (method.equals(InterpolationMethod.STARCAST_6)) { + } else if(method.equals(InterpolationMethod.STARCAST_6)) { return Starcast.starcast(x, z, h, 6D, n); - } else if (method.equals(InterpolationMethod.STARCAST_9)) { + } else if(method.equals(InterpolationMethod.STARCAST_9)) { return Starcast.starcast(x, z, h, 9D, n); - } else if (method.equals(InterpolationMethod.STARCAST_12)) { + } else if(method.equals(InterpolationMethod.STARCAST_12)) { return Starcast.starcast(x, z, h, 12D, n); - } else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_3)) { + } else if(method.equals(InterpolationMethod.BILINEAR_STARCAST_3)) { return Starcast.starcast(x, z, h, 3D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n)); - } else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_6)) { + } else if(method.equals(InterpolationMethod.BILINEAR_STARCAST_6)) { return Starcast.starcast(x, z, h, 6D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n)); - } else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_9)) { + } else if(method.equals(InterpolationMethod.BILINEAR_STARCAST_9)) { return Starcast.starcast(x, z, h, 9D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n)); - } else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_12)) { + } else if(method.equals(InterpolationMethod.BILINEAR_STARCAST_12)) { return Starcast.starcast(x, z, h, 12D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n)); - } else if (method.equals(InterpolationMethod.HERMITE_STARCAST_3)) { + } else if(method.equals(InterpolationMethod.HERMITE_STARCAST_3)) { return Starcast.starcast(x, z, h, 3D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D)); - } else if (method.equals(InterpolationMethod.HERMITE_STARCAST_6)) { + } else if(method.equals(InterpolationMethod.HERMITE_STARCAST_6)) { return Starcast.starcast(x, z, h, 6D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D)); - } else if (method.equals(InterpolationMethod.HERMITE_STARCAST_9)) { + } else if(method.equals(InterpolationMethod.HERMITE_STARCAST_9)) { return Starcast.starcast(x, z, h, 9D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D)); - } else if (method.equals(InterpolationMethod.HERMITE_STARCAST_12)) { + } else if(method.equals(InterpolationMethod.HERMITE_STARCAST_12)) { return Starcast.starcast(x, z, h, 12D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D)); - } else if (method.equals(InterpolationMethod.BILINEAR_BEZIER)) { + } else if(method.equals(InterpolationMethod.BILINEAR_BEZIER)) { return getBilinearBezierNoise(x, z, h, n); - } else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_2)) { + } else if(method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_2)) { return getBilinearParametricNoise(x, z, h, n, 2); - } else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_4)) { + } else if(method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_4)) { return getBilinearParametricNoise(x, z, h, n, 4); - } else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_1_5)) { + } else if(method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_1_5)) { return getBilinearParametricNoise(x, z, h, n, 1.5); - } else if (method.equals(InterpolationMethod.BICUBIC)) { + } else if(method.equals(InterpolationMethod.BICUBIC)) { return getBilinearNoise(x, z, h, n); - } else if (method.equals(InterpolationMethod.HERMITE)) { + } else if(method.equals(InterpolationMethod.HERMITE)) { return getHermiteNoise(x, z, h, n); - } else if (method.equals(InterpolationMethod.HERMITE_TENSE)) { + } else if(method.equals(InterpolationMethod.HERMITE_TENSE)) { return getHermiteNoise(x, z, h, n, 0.8D, 0D); - } else if (method.equals(InterpolationMethod.CATMULL_ROM_SPLINE)) { + } else if(method.equals(InterpolationMethod.CATMULL_ROM_SPLINE)) { return getHermiteNoise(x, z, h, n, 1D, 0D); - } else if (method.equals(InterpolationMethod.HERMITE_LOOSE)) { + } else if(method.equals(InterpolationMethod.HERMITE_LOOSE)) { return getHermiteNoise(x, z, h, n, 0D, 0D); - } else if (method.equals(InterpolationMethod.HERMITE_LOOSE_HALF_NEGATIVE_BIAS)) { + } else if(method.equals(InterpolationMethod.HERMITE_LOOSE_HALF_NEGATIVE_BIAS)) { return getHermiteNoise(x, z, h, n, 0D, -0.5D); - } else if (method.equals(InterpolationMethod.HERMITE_LOOSE_HALF_POSITIVE_BIAS)) { + } else if(method.equals(InterpolationMethod.HERMITE_LOOSE_HALF_POSITIVE_BIAS)) { return getHermiteNoise(x, z, h, n, 0D, 0.5D); - } else if (method.equals(InterpolationMethod.HERMITE_LOOSE_FULL_NEGATIVE_BIAS)) { + } else if(method.equals(InterpolationMethod.HERMITE_LOOSE_FULL_NEGATIVE_BIAS)) { return getHermiteNoise(x, z, h, n, 0D, -1D); - } else if (method.equals(InterpolationMethod.HERMITE_LOOSE_FULL_POSITIVE_BIAS)) { + } else if(method.equals(InterpolationMethod.HERMITE_LOOSE_FULL_POSITIVE_BIAS)) { return getHermiteNoise(x, z, h, n, 0D, 1D); } diff --git a/src/main/java/com/volmit/iris/util/interpolation/Starcast.java b/src/main/java/com/volmit/iris/util/interpolation/Starcast.java index 16456b425..25296635e 100644 --- a/src/main/java/com/volmit/iris/util/interpolation/Starcast.java +++ b/src/main/java/com/volmit/iris/util/interpolation/Starcast.java @@ -22,23 +22,23 @@ import com.volmit.iris.util.function.NoiseProvider; public class Starcast { public static double starcast(int x, int z, double r, double checks, boolean optimized, NoiseProvider n) { - if (optimized) { - if (checks == 3) return sc3(x, z, r, n); - else if (checks == 5) return sc5(x, z, r, n); - else if (checks == 6) return sc6(x, z, r, n); - else if (checks == 7) return sc7(x, z, r, n); - else if (checks == 9) return sc9(x, z, r, n); - else if (checks == 12) return sc12(x, z, r, n); - else if (checks == 24) return sc24(x, z, r, n); - else if (checks == 32) return sc32(x, z, r, n); - else if (checks == 48) return sc48(x, z, r, n); - else if (checks == 64) return sc64(x, z, r, n); + if(optimized) { + if(checks == 3) return sc3(x, z, r, n); + else if(checks == 5) return sc5(x, z, r, n); + else if(checks == 6) return sc6(x, z, r, n); + else if(checks == 7) return sc7(x, z, r, n); + else if(checks == 9) return sc9(x, z, r, n); + else if(checks == 12) return sc12(x, z, r, n); + else if(checks == 24) return sc24(x, z, r, n); + else if(checks == 32) return sc32(x, z, r, n); + else if(checks == 48) return sc48(x, z, r, n); + else if(checks == 64) return sc64(x, z, r, n); } double m = 360D / checks; double v = 0; - for (int i = 0; i < 360; i += m) { + for(int i = 0; i < 360; i += m) { double sin = Math.sin(Math.toRadians(i)); double cos = Math.cos(Math.toRadians(i)); double cx = x + ((r * cos) - (r * sin)); @@ -62,8 +62,8 @@ public class Starcast { private static double sc3(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F3C0) - (r * F3S0)), z + ((r * F3S0) + (r * F3C0))) - + n.noise(x + ((r * F3C1) - (r * F3S1)), z + ((r * F3S1) + (r * F3C1))) - + n.noise(x + ((r * F3C2) - (r * F3S2)), z + ((r * F3S2) + (r * F3C2)))) / 3.0D; + + n.noise(x + ((r * F3C1) - (r * F3S1)), z + ((r * F3S1) + (r * F3C1))) + + n.noise(x + ((r * F3C2) - (r * F3S2)), z + ((r * F3S2) + (r * F3C2)))) / 3.0D; } private static final double F5C0 = 1; @@ -79,10 +79,10 @@ public class Starcast { private static double sc5(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F5C0) - (r * F5S0)), z + ((r * F5S0) + (r * F5C0))) - + n.noise(x + ((r * F5C1) - (r * F5S1)), z + ((r * F5S1) + (r * F5C1))) - + n.noise(x + ((r * F5C2) - (r * F5S2)), z + ((r * F5S2) + (r * F5C2))) - + n.noise(x + ((r * F5C3) - (r * F5S3)), z + ((r * F5S3) + (r * F5C3))) - + n.noise(x + ((r * F5C4) - (r * F5S4)), z + ((r * F5S4) + (r * F5C4)))) / 5.0D; + + n.noise(x + ((r * F5C1) - (r * F5S1)), z + ((r * F5S1) + (r * F5C1))) + + n.noise(x + ((r * F5C2) - (r * F5S2)), z + ((r * F5S2) + (r * F5C2))) + + n.noise(x + ((r * F5C3) - (r * F5S3)), z + ((r * F5S3) + (r * F5C3))) + + n.noise(x + ((r * F5C4) - (r * F5S4)), z + ((r * F5S4) + (r * F5C4)))) / 5.0D; } private static final double F6C0 = 1; @@ -100,11 +100,11 @@ public class Starcast { private static double sc6(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F6C0) - (r * F6S0)), z + ((r * F6S0) + (r * F6C0))) - + n.noise(x + ((r * F6C1) - (r * F6S1)), z + ((r * F6S1) + (r * F6C1))) - + n.noise(x + ((r * F6C2) - (r * F6S2)), z + ((r * F6S2) + (r * F6C2))) - + n.noise(x + ((r * F6C3) - (r * F6S3)), z + ((r * F6S3) + (r * F6C3))) - + n.noise(x + ((r * F6C4) - (r * F6S4)), z + ((r * F6S4) + (r * F6C4))) - + n.noise(x + ((r * F6C5) - (r * F6S5)), z + ((r * F6S5) + (r * F6C5)))) / 6.0D; + + n.noise(x + ((r * F6C1) - (r * F6S1)), z + ((r * F6S1) + (r * F6C1))) + + n.noise(x + ((r * F6C2) - (r * F6S2)), z + ((r * F6S2) + (r * F6C2))) + + n.noise(x + ((r * F6C3) - (r * F6S3)), z + ((r * F6S3) + (r * F6C3))) + + n.noise(x + ((r * F6C4) - (r * F6S4)), z + ((r * F6S4) + (r * F6C4))) + + n.noise(x + ((r * F6C5) - (r * F6S5)), z + ((r * F6S5) + (r * F6C5)))) / 6.0D; } private static final double F7C0 = 1; @@ -126,13 +126,13 @@ public class Starcast { private static double sc7(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F7C0) - (r * F7S0)), z + ((r * F7S0) + (r * F7C0))) - + n.noise(x + ((r * F7C1) - (r * F7S1)), z + ((r * F7S1) + (r * F7C1))) - + n.noise(x + ((r * F7C2) - (r * F7S2)), z + ((r * F7S2) + (r * F7C2))) - + n.noise(x + ((r * F7C3) - (r * F7S3)), z + ((r * F7S3) + (r * F7C3))) - + n.noise(x + ((r * F7C4) - (r * F7S4)), z + ((r * F7S4) + (r * F7C4))) - + n.noise(x + ((r * F7C5) - (r * F7S5)), z + ((r * F7S5) + (r * F7C5))) - + n.noise(x + ((r * F7C6) - (r * F7S6)), z + ((r * F7S6) + (r * F7C6))) - + n.noise(x + ((r * F7C7) - (r * F7S7)), z + ((r * F7S7) + (r * F7C7)))) / 7.0D; + + n.noise(x + ((r * F7C1) - (r * F7S1)), z + ((r * F7S1) + (r * F7C1))) + + n.noise(x + ((r * F7C2) - (r * F7S2)), z + ((r * F7S2) + (r * F7C2))) + + n.noise(x + ((r * F7C3) - (r * F7S3)), z + ((r * F7S3) + (r * F7C3))) + + n.noise(x + ((r * F7C4) - (r * F7S4)), z + ((r * F7S4) + (r * F7C4))) + + n.noise(x + ((r * F7C5) - (r * F7S5)), z + ((r * F7S5) + (r * F7C5))) + + n.noise(x + ((r * F7C6) - (r * F7S6)), z + ((r * F7S6) + (r * F7C6))) + + n.noise(x + ((r * F7C7) - (r * F7S7)), z + ((r * F7S7) + (r * F7C7)))) / 7.0D; } private static final double F9C0 = 1; @@ -156,14 +156,14 @@ public class Starcast { private static double sc9(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F9C0) - (r * F9S0)), z + ((r * F9S0) + (r * F9C0))) - + n.noise(x + ((r * F9C1) - (r * F9S1)), z + ((r * F9S1) + (r * F9C1))) - + n.noise(x + ((r * F9C2) - (r * F9S2)), z + ((r * F9S2) + (r * F9C2))) - + n.noise(x + ((r * F9C3) - (r * F9S3)), z + ((r * F9S3) + (r * F9C3))) - + n.noise(x + ((r * F9C4) - (r * F9S4)), z + ((r * F9S4) + (r * F9C4))) - + n.noise(x + ((r * F9C5) - (r * F9S5)), z + ((r * F9S5) + (r * F9C5))) - + n.noise(x + ((r * F9C6) - (r * F9S6)), z + ((r * F9S6) + (r * F9C6))) - + n.noise(x + ((r * F9C7) - (r * F9S7)), z + ((r * F9S7) + (r * F9C7))) - + n.noise(x + ((r * F9C8) - (r * F9S8)), z + ((r * F9S8) + (r * F9C8)))) / 9.0D; + + n.noise(x + ((r * F9C1) - (r * F9S1)), z + ((r * F9S1) + (r * F9C1))) + + n.noise(x + ((r * F9C2) - (r * F9S2)), z + ((r * F9S2) + (r * F9C2))) + + n.noise(x + ((r * F9C3) - (r * F9S3)), z + ((r * F9S3) + (r * F9C3))) + + n.noise(x + ((r * F9C4) - (r * F9S4)), z + ((r * F9S4) + (r * F9C4))) + + n.noise(x + ((r * F9C5) - (r * F9S5)), z + ((r * F9S5) + (r * F9C5))) + + n.noise(x + ((r * F9C6) - (r * F9S6)), z + ((r * F9S6) + (r * F9C6))) + + n.noise(x + ((r * F9C7) - (r * F9S7)), z + ((r * F9S7) + (r * F9C7))) + + n.noise(x + ((r * F9C8) - (r * F9S8)), z + ((r * F9S8) + (r * F9C8)))) / 9.0D; } private static final double F12C0 = 1; @@ -193,17 +193,17 @@ public class Starcast { private static double sc12(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F12C0) - (r * F12S0)), z + ((r * F12S0) + (r * F12C0))) - + n.noise(x + ((r * F12C1) - (r * F12S1)), z + ((r * F12S1) + (r * F12C1))) - + n.noise(x + ((r * F12C2) - (r * F12S2)), z + ((r * F12S2) + (r * F12C2))) - + n.noise(x + ((r * F12C3) - (r * F12S3)), z + ((r * F12S3) + (r * F12C3))) - + n.noise(x + ((r * F12C4) - (r * F12S4)), z + ((r * F12S4) + (r * F12C4))) - + n.noise(x + ((r * F12C5) - (r * F12S5)), z + ((r * F12S5) + (r * F12C5))) - + n.noise(x + ((r * F12C6) - (r * F12S6)), z + ((r * F12S6) + (r * F12C6))) - + n.noise(x + ((r * F12C7) - (r * F12S7)), z + ((r * F12S7) + (r * F12C7))) - + n.noise(x + ((r * F12C8) - (r * F12S8)), z + ((r * F12S8) + (r * F12C8))) - + n.noise(x + ((r * F12C9) - (r * F12S9)), z + ((r * F12S9) + (r * F12C9))) - + n.noise(x + ((r * F12C10) - (r * F12S10)), z + ((r * F12S10) + (r * F12C10))) - + n.noise(x + ((r * F12C11) - (r * F12S11)), z + ((r * F12S11) + (r * F12C11)))) / 12.0D; + + n.noise(x + ((r * F12C1) - (r * F12S1)), z + ((r * F12S1) + (r * F12C1))) + + n.noise(x + ((r * F12C2) - (r * F12S2)), z + ((r * F12S2) + (r * F12C2))) + + n.noise(x + ((r * F12C3) - (r * F12S3)), z + ((r * F12S3) + (r * F12C3))) + + n.noise(x + ((r * F12C4) - (r * F12S4)), z + ((r * F12S4) + (r * F12C4))) + + n.noise(x + ((r * F12C5) - (r * F12S5)), z + ((r * F12S5) + (r * F12C5))) + + n.noise(x + ((r * F12C6) - (r * F12S6)), z + ((r * F12S6) + (r * F12C6))) + + n.noise(x + ((r * F12C7) - (r * F12S7)), z + ((r * F12S7) + (r * F12C7))) + + n.noise(x + ((r * F12C8) - (r * F12S8)), z + ((r * F12S8) + (r * F12C8))) + + n.noise(x + ((r * F12C9) - (r * F12S9)), z + ((r * F12S9) + (r * F12C9))) + + n.noise(x + ((r * F12C10) - (r * F12S10)), z + ((r * F12S10) + (r * F12C10))) + + n.noise(x + ((r * F12C11) - (r * F12S11)), z + ((r * F12S11) + (r * F12C11)))) / 12.0D; } private static final double F24C0 = 1; @@ -257,29 +257,29 @@ public class Starcast { private static double sc24(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F24C0) - (r * F24S0)), z + ((r * F24S0) + (r * F24C0))) - + n.noise(x + ((r * F24C1) - (r * F24S1)), z + ((r * F24S1) + (r * F24C1))) - + n.noise(x + ((r * F24C2) - (r * F24S2)), z + ((r * F24S2) + (r * F24C2))) - + n.noise(x + ((r * F24C3) - (r * F24S3)), z + ((r * F24S3) + (r * F24C3))) - + n.noise(x + ((r * F24C4) - (r * F24S4)), z + ((r * F24S4) + (r * F24C4))) - + n.noise(x + ((r * F24C5) - (r * F24S5)), z + ((r * F24S5) + (r * F24C5))) - + n.noise(x + ((r * F24C6) - (r * F24S6)), z + ((r * F24S6) + (r * F24C6))) - + n.noise(x + ((r * F24C7) - (r * F24S7)), z + ((r * F24S7) + (r * F24C7))) - + n.noise(x + ((r * F24C8) - (r * F24S8)), z + ((r * F24S8) + (r * F24C8))) - + n.noise(x + ((r * F24C9) - (r * F24S9)), z + ((r * F24S9) + (r * F24C9))) - + n.noise(x + ((r * F24C10) - (r * F24S10)), z + ((r * F24S10) + (r * F24C10))) - + n.noise(x + ((r * F24C11) - (r * F24S11)), z + ((r * F24S11) + (r * F24C11))) - + n.noise(x + ((r * F24C12) - (r * F24S12)), z + ((r * F24S12) + (r * F24C12))) - + n.noise(x + ((r * F24C13) - (r * F24S13)), z + ((r * F24S13) + (r * F24C13))) - + n.noise(x + ((r * F24C14) - (r * F24S14)), z + ((r * F24S14) + (r * F24C14))) - + n.noise(x + ((r * F24C15) - (r * F24S15)), z + ((r * F24S15) + (r * F24C15))) - + n.noise(x + ((r * F24C16) - (r * F24S16)), z + ((r * F24S16) + (r * F24C16))) - + n.noise(x + ((r * F24C17) - (r * F24S17)), z + ((r * F24S17) + (r * F24C17))) - + n.noise(x + ((r * F24C18) - (r * F24S18)), z + ((r * F24S18) + (r * F24C18))) - + n.noise(x + ((r * F24C19) - (r * F24S19)), z + ((r * F24S19) + (r * F24C19))) - + n.noise(x + ((r * F24C20) - (r * F24S20)), z + ((r * F24S20) + (r * F24C20))) - + n.noise(x + ((r * F24C21) - (r * F24S21)), z + ((r * F24S21) + (r * F24C21))) - + n.noise(x + ((r * F24C22) - (r * F24S22)), z + ((r * F24S22) + (r * F24C22))) - + n.noise(x + ((r * F24C23) - (r * F24S23)), z + ((r * F24S23) + (r * F24C23)))) / 24.0D; + + n.noise(x + ((r * F24C1) - (r * F24S1)), z + ((r * F24S1) + (r * F24C1))) + + n.noise(x + ((r * F24C2) - (r * F24S2)), z + ((r * F24S2) + (r * F24C2))) + + n.noise(x + ((r * F24C3) - (r * F24S3)), z + ((r * F24S3) + (r * F24C3))) + + n.noise(x + ((r * F24C4) - (r * F24S4)), z + ((r * F24S4) + (r * F24C4))) + + n.noise(x + ((r * F24C5) - (r * F24S5)), z + ((r * F24S5) + (r * F24C5))) + + n.noise(x + ((r * F24C6) - (r * F24S6)), z + ((r * F24S6) + (r * F24C6))) + + n.noise(x + ((r * F24C7) - (r * F24S7)), z + ((r * F24S7) + (r * F24C7))) + + n.noise(x + ((r * F24C8) - (r * F24S8)), z + ((r * F24S8) + (r * F24C8))) + + n.noise(x + ((r * F24C9) - (r * F24S9)), z + ((r * F24S9) + (r * F24C9))) + + n.noise(x + ((r * F24C10) - (r * F24S10)), z + ((r * F24S10) + (r * F24C10))) + + n.noise(x + ((r * F24C11) - (r * F24S11)), z + ((r * F24S11) + (r * F24C11))) + + n.noise(x + ((r * F24C12) - (r * F24S12)), z + ((r * F24S12) + (r * F24C12))) + + n.noise(x + ((r * F24C13) - (r * F24S13)), z + ((r * F24S13) + (r * F24C13))) + + n.noise(x + ((r * F24C14) - (r * F24S14)), z + ((r * F24S14) + (r * F24C14))) + + n.noise(x + ((r * F24C15) - (r * F24S15)), z + ((r * F24S15) + (r * F24C15))) + + n.noise(x + ((r * F24C16) - (r * F24S16)), z + ((r * F24S16) + (r * F24C16))) + + n.noise(x + ((r * F24C17) - (r * F24S17)), z + ((r * F24S17) + (r * F24C17))) + + n.noise(x + ((r * F24C18) - (r * F24S18)), z + ((r * F24S18) + (r * F24C18))) + + n.noise(x + ((r * F24C19) - (r * F24S19)), z + ((r * F24S19) + (r * F24C19))) + + n.noise(x + ((r * F24C20) - (r * F24S20)), z + ((r * F24S20) + (r * F24C20))) + + n.noise(x + ((r * F24C21) - (r * F24S21)), z + ((r * F24S21) + (r * F24C21))) + + n.noise(x + ((r * F24C22) - (r * F24S22)), z + ((r * F24S22) + (r * F24C22))) + + n.noise(x + ((r * F24C23) - (r * F24S23)), z + ((r * F24S23) + (r * F24C23)))) / 24.0D; } private static final double F32C0 = 1; @@ -351,38 +351,38 @@ public class Starcast { private static double sc32(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F32C0) - (r * F32S0)), z + ((r * F32S0) + (r * F32C0))) - + n.noise(x + ((r * F32C1) - (r * F32S1)), z + ((r * F32S1) + (r * F32C1))) - + n.noise(x + ((r * F32C2) - (r * F32S2)), z + ((r * F32S2) + (r * F32C2))) - + n.noise(x + ((r * F32C3) - (r * F32S3)), z + ((r * F32S3) + (r * F32C3))) - + n.noise(x + ((r * F32C4) - (r * F32S4)), z + ((r * F32S4) + (r * F32C4))) - + n.noise(x + ((r * F32C5) - (r * F32S5)), z + ((r * F32S5) + (r * F32C5))) - + n.noise(x + ((r * F32C6) - (r * F32S6)), z + ((r * F32S6) + (r * F32C6))) - + n.noise(x + ((r * F32C7) - (r * F32S7)), z + ((r * F32S7) + (r * F32C7))) - + n.noise(x + ((r * F32C8) - (r * F32S8)), z + ((r * F32S8) + (r * F32C8))) - + n.noise(x + ((r * F32C9) - (r * F32S9)), z + ((r * F32S9) + (r * F32C9))) - + n.noise(x + ((r * F32C10) - (r * F32S10)), z + ((r * F32S10) + (r * F32C10))) - + n.noise(x + ((r * F32C11) - (r * F32S11)), z + ((r * F32S11) + (r * F32C11))) - + n.noise(x + ((r * F32C12) - (r * F32S12)), z + ((r * F32S12) + (r * F32C12))) - + n.noise(x + ((r * F32C13) - (r * F32S13)), z + ((r * F32S13) + (r * F32C13))) - + n.noise(x + ((r * F32C14) - (r * F32S14)), z + ((r * F32S14) + (r * F32C14))) - + n.noise(x + ((r * F32C15) - (r * F32S15)), z + ((r * F32S15) + (r * F32C15))) - + n.noise(x + ((r * F32C16) - (r * F32S16)), z + ((r * F32S16) + (r * F32C16))) - + n.noise(x + ((r * F32C17) - (r * F32S17)), z + ((r * F32S17) + (r * F32C17))) - + n.noise(x + ((r * F32C18) - (r * F32S18)), z + ((r * F32S18) + (r * F32C18))) - + n.noise(x + ((r * F32C19) - (r * F32S19)), z + ((r * F32S19) + (r * F32C19))) - + n.noise(x + ((r * F32C20) - (r * F32S20)), z + ((r * F32S20) + (r * F32C20))) - + n.noise(x + ((r * F32C21) - (r * F32S21)), z + ((r * F32S21) + (r * F32C21))) - + n.noise(x + ((r * F32C22) - (r * F32S22)), z + ((r * F32S22) + (r * F32C22))) - + n.noise(x + ((r * F32C23) - (r * F32S23)), z + ((r * F32S23) + (r * F32C23))) - + n.noise(x + ((r * F32C24) - (r * F32S24)), z + ((r * F32S24) + (r * F32C24))) - + n.noise(x + ((r * F32C25) - (r * F32S25)), z + ((r * F32S25) + (r * F32C25))) - + n.noise(x + ((r * F32C26) - (r * F32S26)), z + ((r * F32S26) + (r * F32C26))) - + n.noise(x + ((r * F32C27) - (r * F32S27)), z + ((r * F32S27) + (r * F32C27))) - + n.noise(x + ((r * F32C28) - (r * F32S28)), z + ((r * F32S28) + (r * F32C28))) - + n.noise(x + ((r * F32C29) - (r * F32S29)), z + ((r * F32S29) + (r * F32C29))) - + n.noise(x + ((r * F32C30) - (r * F32S30)), z + ((r * F32S30) + (r * F32C30))) - + n.noise(x + ((r * F32C31) - (r * F32S31)), z + ((r * F32S31) + (r * F32C31))) - + n.noise(x + ((r * F32C32) - (r * F32S32)), z + ((r * F32S32) + (r * F32C32)))) / 32.0D; + + n.noise(x + ((r * F32C1) - (r * F32S1)), z + ((r * F32S1) + (r * F32C1))) + + n.noise(x + ((r * F32C2) - (r * F32S2)), z + ((r * F32S2) + (r * F32C2))) + + n.noise(x + ((r * F32C3) - (r * F32S3)), z + ((r * F32S3) + (r * F32C3))) + + n.noise(x + ((r * F32C4) - (r * F32S4)), z + ((r * F32S4) + (r * F32C4))) + + n.noise(x + ((r * F32C5) - (r * F32S5)), z + ((r * F32S5) + (r * F32C5))) + + n.noise(x + ((r * F32C6) - (r * F32S6)), z + ((r * F32S6) + (r * F32C6))) + + n.noise(x + ((r * F32C7) - (r * F32S7)), z + ((r * F32S7) + (r * F32C7))) + + n.noise(x + ((r * F32C8) - (r * F32S8)), z + ((r * F32S8) + (r * F32C8))) + + n.noise(x + ((r * F32C9) - (r * F32S9)), z + ((r * F32S9) + (r * F32C9))) + + n.noise(x + ((r * F32C10) - (r * F32S10)), z + ((r * F32S10) + (r * F32C10))) + + n.noise(x + ((r * F32C11) - (r * F32S11)), z + ((r * F32S11) + (r * F32C11))) + + n.noise(x + ((r * F32C12) - (r * F32S12)), z + ((r * F32S12) + (r * F32C12))) + + n.noise(x + ((r * F32C13) - (r * F32S13)), z + ((r * F32S13) + (r * F32C13))) + + n.noise(x + ((r * F32C14) - (r * F32S14)), z + ((r * F32S14) + (r * F32C14))) + + n.noise(x + ((r * F32C15) - (r * F32S15)), z + ((r * F32S15) + (r * F32C15))) + + n.noise(x + ((r * F32C16) - (r * F32S16)), z + ((r * F32S16) + (r * F32C16))) + + n.noise(x + ((r * F32C17) - (r * F32S17)), z + ((r * F32S17) + (r * F32C17))) + + n.noise(x + ((r * F32C18) - (r * F32S18)), z + ((r * F32S18) + (r * F32C18))) + + n.noise(x + ((r * F32C19) - (r * F32S19)), z + ((r * F32S19) + (r * F32C19))) + + n.noise(x + ((r * F32C20) - (r * F32S20)), z + ((r * F32S20) + (r * F32C20))) + + n.noise(x + ((r * F32C21) - (r * F32S21)), z + ((r * F32S21) + (r * F32C21))) + + n.noise(x + ((r * F32C22) - (r * F32S22)), z + ((r * F32S22) + (r * F32C22))) + + n.noise(x + ((r * F32C23) - (r * F32S23)), z + ((r * F32S23) + (r * F32C23))) + + n.noise(x + ((r * F32C24) - (r * F32S24)), z + ((r * F32S24) + (r * F32C24))) + + n.noise(x + ((r * F32C25) - (r * F32S25)), z + ((r * F32S25) + (r * F32C25))) + + n.noise(x + ((r * F32C26) - (r * F32S26)), z + ((r * F32S26) + (r * F32C26))) + + n.noise(x + ((r * F32C27) - (r * F32S27)), z + ((r * F32S27) + (r * F32C27))) + + n.noise(x + ((r * F32C28) - (r * F32S28)), z + ((r * F32S28) + (r * F32C28))) + + n.noise(x + ((r * F32C29) - (r * F32S29)), z + ((r * F32S29) + (r * F32C29))) + + n.noise(x + ((r * F32C30) - (r * F32S30)), z + ((r * F32S30) + (r * F32C30))) + + n.noise(x + ((r * F32C31) - (r * F32S31)), z + ((r * F32S31) + (r * F32C31))) + + n.noise(x + ((r * F32C32) - (r * F32S32)), z + ((r * F32S32) + (r * F32C32)))) / 32.0D; } private static final double F48C0 = 1; @@ -492,57 +492,57 @@ public class Starcast { private static double sc48(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F48C0) - (r * F48S0)), z + ((r * F48S0) + (r * F48C0))) - + n.noise(x + ((r * F48C1) - (r * F48S1)), z + ((r * F48S1) + (r * F48C1))) - + n.noise(x + ((r * F48C2) - (r * F48S2)), z + ((r * F48S2) + (r * F48C2))) - + n.noise(x + ((r * F48C3) - (r * F48S3)), z + ((r * F48S3) + (r * F48C3))) - + n.noise(x + ((r * F48C4) - (r * F48S4)), z + ((r * F48S4) + (r * F48C4))) - + n.noise(x + ((r * F48C5) - (r * F48S5)), z + ((r * F48S5) + (r * F48C5))) - + n.noise(x + ((r * F48C6) - (r * F48S6)), z + ((r * F48S6) + (r * F48C6))) - + n.noise(x + ((r * F48C7) - (r * F48S7)), z + ((r * F48S7) + (r * F48C7))) - + n.noise(x + ((r * F48C8) - (r * F48S8)), z + ((r * F48S8) + (r * F48C8))) - + n.noise(x + ((r * F48C9) - (r * F48S9)), z + ((r * F48S9) + (r * F48C9))) - + n.noise(x + ((r * F48C10) - (r * F48S10)), z + ((r * F48S10) + (r * F48C10))) - + n.noise(x + ((r * F48C11) - (r * F48S11)), z + ((r * F48S11) + (r * F48C11))) - + n.noise(x + ((r * F48C12) - (r * F48S12)), z + ((r * F48S12) + (r * F48C12))) - + n.noise(x + ((r * F48C13) - (r * F48S13)), z + ((r * F48S13) + (r * F48C13))) - + n.noise(x + ((r * F48C14) - (r * F48S14)), z + ((r * F48S14) + (r * F48C14))) - + n.noise(x + ((r * F48C15) - (r * F48S15)), z + ((r * F48S15) + (r * F48C15))) - + n.noise(x + ((r * F48C16) - (r * F48S16)), z + ((r * F48S16) + (r * F48C16))) - + n.noise(x + ((r * F48C17) - (r * F48S17)), z + ((r * F48S17) + (r * F48C17))) - + n.noise(x + ((r * F48C18) - (r * F48S18)), z + ((r * F48S18) + (r * F48C18))) - + n.noise(x + ((r * F48C19) - (r * F48S19)), z + ((r * F48S19) + (r * F48C19))) - + n.noise(x + ((r * F48C20) - (r * F48S20)), z + ((r * F48S20) + (r * F48C20))) - + n.noise(x + ((r * F48C21) - (r * F48S21)), z + ((r * F48S21) + (r * F48C21))) - + n.noise(x + ((r * F48C22) - (r * F48S22)), z + ((r * F48S22) + (r * F48C22))) - + n.noise(x + ((r * F48C23) - (r * F48S23)), z + ((r * F48S23) + (r * F48C23))) - + n.noise(x + ((r * F48C24) - (r * F48S24)), z + ((r * F48S24) + (r * F48C24))) - + n.noise(x + ((r * F48C25) - (r * F48S25)), z + ((r * F48S25) + (r * F48C25))) - + n.noise(x + ((r * F48C26) - (r * F48S26)), z + ((r * F48S26) + (r * F48C26))) - + n.noise(x + ((r * F48C27) - (r * F48S27)), z + ((r * F48S27) + (r * F48C27))) - + n.noise(x + ((r * F48C28) - (r * F48S28)), z + ((r * F48S28) + (r * F48C28))) - + n.noise(x + ((r * F48C29) - (r * F48S29)), z + ((r * F48S29) + (r * F48C29))) - + n.noise(x + ((r * F48C30) - (r * F48S30)), z + ((r * F48S30) + (r * F48C30))) - + n.noise(x + ((r * F48C31) - (r * F48S31)), z + ((r * F48S31) + (r * F48C31))) - + n.noise(x + ((r * F48C32) - (r * F48S32)), z + ((r * F48S32) + (r * F48C32))) - + n.noise(x + ((r * F48C33) - (r * F48S33)), z + ((r * F48S33) + (r * F48C33))) - + n.noise(x + ((r * F48C34) - (r * F48S34)), z + ((r * F48S34) + (r * F48C34))) - + n.noise(x + ((r * F48C35) - (r * F48S35)), z + ((r * F48S35) + (r * F48C35))) - + n.noise(x + ((r * F48C36) - (r * F48S36)), z + ((r * F48S36) + (r * F48C36))) - + n.noise(x + ((r * F48C37) - (r * F48S37)), z + ((r * F48S37) + (r * F48C37))) - + n.noise(x + ((r * F48C38) - (r * F48S38)), z + ((r * F48S38) + (r * F48C38))) - + n.noise(x + ((r * F48C39) - (r * F48S39)), z + ((r * F48S39) + (r * F48C39))) - + n.noise(x + ((r * F48C40) - (r * F48S40)), z + ((r * F48S40) + (r * F48C40))) - + n.noise(x + ((r * F48C41) - (r * F48S41)), z + ((r * F48S41) + (r * F48C41))) - + n.noise(x + ((r * F48C42) - (r * F48S42)), z + ((r * F48S42) + (r * F48C42))) - + n.noise(x + ((r * F48C43) - (r * F48S43)), z + ((r * F48S43) + (r * F48C43))) - + n.noise(x + ((r * F48C44) - (r * F48S44)), z + ((r * F48S44) + (r * F48C44))) - + n.noise(x + ((r * F48C45) - (r * F48S45)), z + ((r * F48S45) + (r * F48C45))) - + n.noise(x + ((r * F48C46) - (r * F48S46)), z + ((r * F48S46) + (r * F48C46))) - + n.noise(x + ((r * F48C47) - (r * F48S47)), z + ((r * F48S47) + (r * F48C47))) - + n.noise(x + ((r * F48C48) - (r * F48S48)), z + ((r * F48S48) + (r * F48C48))) - + n.noise(x + ((r * F48C49) - (r * F48S49)), z + ((r * F48S49) + (r * F48C49))) - + n.noise(x + ((r * F48C50) - (r * F48S50)), z + ((r * F48S50) + (r * F48C50))) - + n.noise(x + ((r * F48C51) - (r * F48S51)), z + ((r * F48S51) + (r * F48C51)))) / 48.0D; + + n.noise(x + ((r * F48C1) - (r * F48S1)), z + ((r * F48S1) + (r * F48C1))) + + n.noise(x + ((r * F48C2) - (r * F48S2)), z + ((r * F48S2) + (r * F48C2))) + + n.noise(x + ((r * F48C3) - (r * F48S3)), z + ((r * F48S3) + (r * F48C3))) + + n.noise(x + ((r * F48C4) - (r * F48S4)), z + ((r * F48S4) + (r * F48C4))) + + n.noise(x + ((r * F48C5) - (r * F48S5)), z + ((r * F48S5) + (r * F48C5))) + + n.noise(x + ((r * F48C6) - (r * F48S6)), z + ((r * F48S6) + (r * F48C6))) + + n.noise(x + ((r * F48C7) - (r * F48S7)), z + ((r * F48S7) + (r * F48C7))) + + n.noise(x + ((r * F48C8) - (r * F48S8)), z + ((r * F48S8) + (r * F48C8))) + + n.noise(x + ((r * F48C9) - (r * F48S9)), z + ((r * F48S9) + (r * F48C9))) + + n.noise(x + ((r * F48C10) - (r * F48S10)), z + ((r * F48S10) + (r * F48C10))) + + n.noise(x + ((r * F48C11) - (r * F48S11)), z + ((r * F48S11) + (r * F48C11))) + + n.noise(x + ((r * F48C12) - (r * F48S12)), z + ((r * F48S12) + (r * F48C12))) + + n.noise(x + ((r * F48C13) - (r * F48S13)), z + ((r * F48S13) + (r * F48C13))) + + n.noise(x + ((r * F48C14) - (r * F48S14)), z + ((r * F48S14) + (r * F48C14))) + + n.noise(x + ((r * F48C15) - (r * F48S15)), z + ((r * F48S15) + (r * F48C15))) + + n.noise(x + ((r * F48C16) - (r * F48S16)), z + ((r * F48S16) + (r * F48C16))) + + n.noise(x + ((r * F48C17) - (r * F48S17)), z + ((r * F48S17) + (r * F48C17))) + + n.noise(x + ((r * F48C18) - (r * F48S18)), z + ((r * F48S18) + (r * F48C18))) + + n.noise(x + ((r * F48C19) - (r * F48S19)), z + ((r * F48S19) + (r * F48C19))) + + n.noise(x + ((r * F48C20) - (r * F48S20)), z + ((r * F48S20) + (r * F48C20))) + + n.noise(x + ((r * F48C21) - (r * F48S21)), z + ((r * F48S21) + (r * F48C21))) + + n.noise(x + ((r * F48C22) - (r * F48S22)), z + ((r * F48S22) + (r * F48C22))) + + n.noise(x + ((r * F48C23) - (r * F48S23)), z + ((r * F48S23) + (r * F48C23))) + + n.noise(x + ((r * F48C24) - (r * F48S24)), z + ((r * F48S24) + (r * F48C24))) + + n.noise(x + ((r * F48C25) - (r * F48S25)), z + ((r * F48S25) + (r * F48C25))) + + n.noise(x + ((r * F48C26) - (r * F48S26)), z + ((r * F48S26) + (r * F48C26))) + + n.noise(x + ((r * F48C27) - (r * F48S27)), z + ((r * F48S27) + (r * F48C27))) + + n.noise(x + ((r * F48C28) - (r * F48S28)), z + ((r * F48S28) + (r * F48C28))) + + n.noise(x + ((r * F48C29) - (r * F48S29)), z + ((r * F48S29) + (r * F48C29))) + + n.noise(x + ((r * F48C30) - (r * F48S30)), z + ((r * F48S30) + (r * F48C30))) + + n.noise(x + ((r * F48C31) - (r * F48S31)), z + ((r * F48S31) + (r * F48C31))) + + n.noise(x + ((r * F48C32) - (r * F48S32)), z + ((r * F48S32) + (r * F48C32))) + + n.noise(x + ((r * F48C33) - (r * F48S33)), z + ((r * F48S33) + (r * F48C33))) + + n.noise(x + ((r * F48C34) - (r * F48S34)), z + ((r * F48S34) + (r * F48C34))) + + n.noise(x + ((r * F48C35) - (r * F48S35)), z + ((r * F48S35) + (r * F48C35))) + + n.noise(x + ((r * F48C36) - (r * F48S36)), z + ((r * F48S36) + (r * F48C36))) + + n.noise(x + ((r * F48C37) - (r * F48S37)), z + ((r * F48S37) + (r * F48C37))) + + n.noise(x + ((r * F48C38) - (r * F48S38)), z + ((r * F48S38) + (r * F48C38))) + + n.noise(x + ((r * F48C39) - (r * F48S39)), z + ((r * F48S39) + (r * F48C39))) + + n.noise(x + ((r * F48C40) - (r * F48S40)), z + ((r * F48S40) + (r * F48C40))) + + n.noise(x + ((r * F48C41) - (r * F48S41)), z + ((r * F48S41) + (r * F48C41))) + + n.noise(x + ((r * F48C42) - (r * F48S42)), z + ((r * F48S42) + (r * F48C42))) + + n.noise(x + ((r * F48C43) - (r * F48S43)), z + ((r * F48S43) + (r * F48C43))) + + n.noise(x + ((r * F48C44) - (r * F48S44)), z + ((r * F48S44) + (r * F48C44))) + + n.noise(x + ((r * F48C45) - (r * F48S45)), z + ((r * F48S45) + (r * F48C45))) + + n.noise(x + ((r * F48C46) - (r * F48S46)), z + ((r * F48S46) + (r * F48C46))) + + n.noise(x + ((r * F48C47) - (r * F48S47)), z + ((r * F48S47) + (r * F48C47))) + + n.noise(x + ((r * F48C48) - (r * F48S48)), z + ((r * F48S48) + (r * F48C48))) + + n.noise(x + ((r * F48C49) - (r * F48S49)), z + ((r * F48S49) + (r * F48C49))) + + n.noise(x + ((r * F48C50) - (r * F48S50)), z + ((r * F48S50) + (r * F48C50))) + + n.noise(x + ((r * F48C51) - (r * F48S51)), z + ((r * F48S51) + (r * F48C51)))) / 48.0D; } private static final double F64C0 = 1; @@ -692,76 +692,76 @@ public class Starcast { private static double sc64(int x, int z, double r, NoiseProvider n) { return (n.noise(x + ((r * F64C0) - (r * F64S0)), z + ((r * F64S0) + (r * F64C0))) - + n.noise(x + ((r * F64C1) - (r * F64S1)), z + ((r * F64S1) + (r * F64C1))) - + n.noise(x + ((r * F64C2) - (r * F64S2)), z + ((r * F64S2) + (r * F64C2))) - + n.noise(x + ((r * F64C3) - (r * F64S3)), z + ((r * F64S3) + (r * F64C3))) - + n.noise(x + ((r * F64C4) - (r * F64S4)), z + ((r * F64S4) + (r * F64C4))) - + n.noise(x + ((r * F64C5) - (r * F64S5)), z + ((r * F64S5) + (r * F64C5))) - + n.noise(x + ((r * F64C6) - (r * F64S6)), z + ((r * F64S6) + (r * F64C6))) - + n.noise(x + ((r * F64C7) - (r * F64S7)), z + ((r * F64S7) + (r * F64C7))) - + n.noise(x + ((r * F64C8) - (r * F64S8)), z + ((r * F64S8) + (r * F64C8))) - + n.noise(x + ((r * F64C9) - (r * F64S9)), z + ((r * F64S9) + (r * F64C9))) - + n.noise(x + ((r * F64C10) - (r * F64S10)), z + ((r * F64S10) + (r * F64C10))) - + n.noise(x + ((r * F64C11) - (r * F64S11)), z + ((r * F64S11) + (r * F64C11))) - + n.noise(x + ((r * F64C12) - (r * F64S12)), z + ((r * F64S12) + (r * F64C12))) - + n.noise(x + ((r * F64C13) - (r * F64S13)), z + ((r * F64S13) + (r * F64C13))) - + n.noise(x + ((r * F64C14) - (r * F64S14)), z + ((r * F64S14) + (r * F64C14))) - + n.noise(x + ((r * F64C15) - (r * F64S15)), z + ((r * F64S15) + (r * F64C15))) - + n.noise(x + ((r * F64C16) - (r * F64S16)), z + ((r * F64S16) + (r * F64C16))) - + n.noise(x + ((r * F64C17) - (r * F64S17)), z + ((r * F64S17) + (r * F64C17))) - + n.noise(x + ((r * F64C18) - (r * F64S18)), z + ((r * F64S18) + (r * F64C18))) - + n.noise(x + ((r * F64C19) - (r * F64S19)), z + ((r * F64S19) + (r * F64C19))) - + n.noise(x + ((r * F64C20) - (r * F64S20)), z + ((r * F64S20) + (r * F64C20))) - + n.noise(x + ((r * F64C21) - (r * F64S21)), z + ((r * F64S21) + (r * F64C21))) - + n.noise(x + ((r * F64C22) - (r * F64S22)), z + ((r * F64S22) + (r * F64C22))) - + n.noise(x + ((r * F64C23) - (r * F64S23)), z + ((r * F64S23) + (r * F64C23))) - + n.noise(x + ((r * F64C24) - (r * F64S24)), z + ((r * F64S24) + (r * F64C24))) - + n.noise(x + ((r * F64C25) - (r * F64S25)), z + ((r * F64S25) + (r * F64C25))) - + n.noise(x + ((r * F64C26) - (r * F64S26)), z + ((r * F64S26) + (r * F64C26))) - + n.noise(x + ((r * F64C27) - (r * F64S27)), z + ((r * F64S27) + (r * F64C27))) - + n.noise(x + ((r * F64C28) - (r * F64S28)), z + ((r * F64S28) + (r * F64C28))) - + n.noise(x + ((r * F64C29) - (r * F64S29)), z + ((r * F64S29) + (r * F64C29))) - + n.noise(x + ((r * F64C30) - (r * F64S30)), z + ((r * F64S30) + (r * F64C30))) - + n.noise(x + ((r * F64C31) - (r * F64S31)), z + ((r * F64S31) + (r * F64C31))) - + n.noise(x + ((r * F64C32) - (r * F64S32)), z + ((r * F64S32) + (r * F64C32))) - + n.noise(x + ((r * F64C33) - (r * F64S33)), z + ((r * F64S33) + (r * F64C33))) - + n.noise(x + ((r * F64C34) - (r * F64S34)), z + ((r * F64S34) + (r * F64C34))) - + n.noise(x + ((r * F64C35) - (r * F64S35)), z + ((r * F64S35) + (r * F64C35))) - + n.noise(x + ((r * F64C36) - (r * F64S36)), z + ((r * F64S36) + (r * F64C36))) - + n.noise(x + ((r * F64C37) - (r * F64S37)), z + ((r * F64S37) + (r * F64C37))) - + n.noise(x + ((r * F64C38) - (r * F64S38)), z + ((r * F64S38) + (r * F64C38))) - + n.noise(x + ((r * F64C39) - (r * F64S39)), z + ((r * F64S39) + (r * F64C39))) - + n.noise(x + ((r * F64C40) - (r * F64S40)), z + ((r * F64S40) + (r * F64C40))) - + n.noise(x + ((r * F64C41) - (r * F64S41)), z + ((r * F64S41) + (r * F64C41))) - + n.noise(x + ((r * F64C42) - (r * F64S42)), z + ((r * F64S42) + (r * F64C42))) - + n.noise(x + ((r * F64C43) - (r * F64S43)), z + ((r * F64S43) + (r * F64C43))) - + n.noise(x + ((r * F64C44) - (r * F64S44)), z + ((r * F64S44) + (r * F64C44))) - + n.noise(x + ((r * F64C45) - (r * F64S45)), z + ((r * F64S45) + (r * F64C45))) - + n.noise(x + ((r * F64C46) - (r * F64S46)), z + ((r * F64S46) + (r * F64C46))) - + n.noise(x + ((r * F64C47) - (r * F64S47)), z + ((r * F64S47) + (r * F64C47))) - + n.noise(x + ((r * F64C48) - (r * F64S48)), z + ((r * F64S48) + (r * F64C48))) - + n.noise(x + ((r * F64C49) - (r * F64S49)), z + ((r * F64S49) + (r * F64C49))) - + n.noise(x + ((r * F64C50) - (r * F64S50)), z + ((r * F64S50) + (r * F64C50))) - + n.noise(x + ((r * F64C51) - (r * F64S51)), z + ((r * F64S51) + (r * F64C51))) - + n.noise(x + ((r * F64C52) - (r * F64S52)), z + ((r * F64S52) + (r * F64C52))) - + n.noise(x + ((r * F64C53) - (r * F64S53)), z + ((r * F64S53) + (r * F64C53))) - + n.noise(x + ((r * F64C54) - (r * F64S54)), z + ((r * F64S54) + (r * F64C54))) - + n.noise(x + ((r * F64C55) - (r * F64S55)), z + ((r * F64S55) + (r * F64C55))) - + n.noise(x + ((r * F64C56) - (r * F64S56)), z + ((r * F64S56) + (r * F64C56))) - + n.noise(x + ((r * F64C57) - (r * F64S57)), z + ((r * F64S57) + (r * F64C57))) - + n.noise(x + ((r * F64C58) - (r * F64S58)), z + ((r * F64S58) + (r * F64C58))) - + n.noise(x + ((r * F64C59) - (r * F64S59)), z + ((r * F64S59) + (r * F64C59))) - + n.noise(x + ((r * F64C60) - (r * F64S60)), z + ((r * F64S60) + (r * F64C60))) - + n.noise(x + ((r * F64C61) - (r * F64S61)), z + ((r * F64S61) + (r * F64C61))) - + n.noise(x + ((r * F64C62) - (r * F64S62)), z + ((r * F64S62) + (r * F64C62))) - + n.noise(x + ((r * F64C63) - (r * F64S63)), z + ((r * F64S63) + (r * F64C63))) - + n.noise(x + ((r * F64C64) - (r * F64S64)), z + ((r * F64S64) + (r * F64C64))) - + n.noise(x + ((r * F64C65) - (r * F64S65)), z + ((r * F64S65) + (r * F64C65))) - + n.noise(x + ((r * F64C66) - (r * F64S66)), z + ((r * F64S66) + (r * F64C66))) - + n.noise(x + ((r * F64C67) - (r * F64S67)), z + ((r * F64S67) + (r * F64C67))) - + n.noise(x + ((r * F64C68) - (r * F64S68)), z + ((r * F64S68) + (r * F64C68))) - + n.noise(x + ((r * F64C69) - (r * F64S69)), z + ((r * F64S69) + (r * F64C69))) - + n.noise(x + ((r * F64C70) - (r * F64S70)), z + ((r * F64S70) + (r * F64C70))) - + n.noise(x + ((r * F64C71) - (r * F64S71)), z + ((r * F64S71) + (r * F64C71)))) / 64.0D; + + n.noise(x + ((r * F64C1) - (r * F64S1)), z + ((r * F64S1) + (r * F64C1))) + + n.noise(x + ((r * F64C2) - (r * F64S2)), z + ((r * F64S2) + (r * F64C2))) + + n.noise(x + ((r * F64C3) - (r * F64S3)), z + ((r * F64S3) + (r * F64C3))) + + n.noise(x + ((r * F64C4) - (r * F64S4)), z + ((r * F64S4) + (r * F64C4))) + + n.noise(x + ((r * F64C5) - (r * F64S5)), z + ((r * F64S5) + (r * F64C5))) + + n.noise(x + ((r * F64C6) - (r * F64S6)), z + ((r * F64S6) + (r * F64C6))) + + n.noise(x + ((r * F64C7) - (r * F64S7)), z + ((r * F64S7) + (r * F64C7))) + + n.noise(x + ((r * F64C8) - (r * F64S8)), z + ((r * F64S8) + (r * F64C8))) + + n.noise(x + ((r * F64C9) - (r * F64S9)), z + ((r * F64S9) + (r * F64C9))) + + n.noise(x + ((r * F64C10) - (r * F64S10)), z + ((r * F64S10) + (r * F64C10))) + + n.noise(x + ((r * F64C11) - (r * F64S11)), z + ((r * F64S11) + (r * F64C11))) + + n.noise(x + ((r * F64C12) - (r * F64S12)), z + ((r * F64S12) + (r * F64C12))) + + n.noise(x + ((r * F64C13) - (r * F64S13)), z + ((r * F64S13) + (r * F64C13))) + + n.noise(x + ((r * F64C14) - (r * F64S14)), z + ((r * F64S14) + (r * F64C14))) + + n.noise(x + ((r * F64C15) - (r * F64S15)), z + ((r * F64S15) + (r * F64C15))) + + n.noise(x + ((r * F64C16) - (r * F64S16)), z + ((r * F64S16) + (r * F64C16))) + + n.noise(x + ((r * F64C17) - (r * F64S17)), z + ((r * F64S17) + (r * F64C17))) + + n.noise(x + ((r * F64C18) - (r * F64S18)), z + ((r * F64S18) + (r * F64C18))) + + n.noise(x + ((r * F64C19) - (r * F64S19)), z + ((r * F64S19) + (r * F64C19))) + + n.noise(x + ((r * F64C20) - (r * F64S20)), z + ((r * F64S20) + (r * F64C20))) + + n.noise(x + ((r * F64C21) - (r * F64S21)), z + ((r * F64S21) + (r * F64C21))) + + n.noise(x + ((r * F64C22) - (r * F64S22)), z + ((r * F64S22) + (r * F64C22))) + + n.noise(x + ((r * F64C23) - (r * F64S23)), z + ((r * F64S23) + (r * F64C23))) + + n.noise(x + ((r * F64C24) - (r * F64S24)), z + ((r * F64S24) + (r * F64C24))) + + n.noise(x + ((r * F64C25) - (r * F64S25)), z + ((r * F64S25) + (r * F64C25))) + + n.noise(x + ((r * F64C26) - (r * F64S26)), z + ((r * F64S26) + (r * F64C26))) + + n.noise(x + ((r * F64C27) - (r * F64S27)), z + ((r * F64S27) + (r * F64C27))) + + n.noise(x + ((r * F64C28) - (r * F64S28)), z + ((r * F64S28) + (r * F64C28))) + + n.noise(x + ((r * F64C29) - (r * F64S29)), z + ((r * F64S29) + (r * F64C29))) + + n.noise(x + ((r * F64C30) - (r * F64S30)), z + ((r * F64S30) + (r * F64C30))) + + n.noise(x + ((r * F64C31) - (r * F64S31)), z + ((r * F64S31) + (r * F64C31))) + + n.noise(x + ((r * F64C32) - (r * F64S32)), z + ((r * F64S32) + (r * F64C32))) + + n.noise(x + ((r * F64C33) - (r * F64S33)), z + ((r * F64S33) + (r * F64C33))) + + n.noise(x + ((r * F64C34) - (r * F64S34)), z + ((r * F64S34) + (r * F64C34))) + + n.noise(x + ((r * F64C35) - (r * F64S35)), z + ((r * F64S35) + (r * F64C35))) + + n.noise(x + ((r * F64C36) - (r * F64S36)), z + ((r * F64S36) + (r * F64C36))) + + n.noise(x + ((r * F64C37) - (r * F64S37)), z + ((r * F64S37) + (r * F64C37))) + + n.noise(x + ((r * F64C38) - (r * F64S38)), z + ((r * F64S38) + (r * F64C38))) + + n.noise(x + ((r * F64C39) - (r * F64S39)), z + ((r * F64S39) + (r * F64C39))) + + n.noise(x + ((r * F64C40) - (r * F64S40)), z + ((r * F64S40) + (r * F64C40))) + + n.noise(x + ((r * F64C41) - (r * F64S41)), z + ((r * F64S41) + (r * F64C41))) + + n.noise(x + ((r * F64C42) - (r * F64S42)), z + ((r * F64S42) + (r * F64C42))) + + n.noise(x + ((r * F64C43) - (r * F64S43)), z + ((r * F64S43) + (r * F64C43))) + + n.noise(x + ((r * F64C44) - (r * F64S44)), z + ((r * F64S44) + (r * F64C44))) + + n.noise(x + ((r * F64C45) - (r * F64S45)), z + ((r * F64S45) + (r * F64C45))) + + n.noise(x + ((r * F64C46) - (r * F64S46)), z + ((r * F64S46) + (r * F64C46))) + + n.noise(x + ((r * F64C47) - (r * F64S47)), z + ((r * F64S47) + (r * F64C47))) + + n.noise(x + ((r * F64C48) - (r * F64S48)), z + ((r * F64S48) + (r * F64C48))) + + n.noise(x + ((r * F64C49) - (r * F64S49)), z + ((r * F64S49) + (r * F64C49))) + + n.noise(x + ((r * F64C50) - (r * F64S50)), z + ((r * F64S50) + (r * F64C50))) + + n.noise(x + ((r * F64C51) - (r * F64S51)), z + ((r * F64S51) + (r * F64C51))) + + n.noise(x + ((r * F64C52) - (r * F64S52)), z + ((r * F64S52) + (r * F64C52))) + + n.noise(x + ((r * F64C53) - (r * F64S53)), z + ((r * F64S53) + (r * F64C53))) + + n.noise(x + ((r * F64C54) - (r * F64S54)), z + ((r * F64S54) + (r * F64C54))) + + n.noise(x + ((r * F64C55) - (r * F64S55)), z + ((r * F64S55) + (r * F64C55))) + + n.noise(x + ((r * F64C56) - (r * F64S56)), z + ((r * F64S56) + (r * F64C56))) + + n.noise(x + ((r * F64C57) - (r * F64S57)), z + ((r * F64S57) + (r * F64C57))) + + n.noise(x + ((r * F64C58) - (r * F64S58)), z + ((r * F64S58) + (r * F64C58))) + + n.noise(x + ((r * F64C59) - (r * F64S59)), z + ((r * F64S59) + (r * F64C59))) + + n.noise(x + ((r * F64C60) - (r * F64S60)), z + ((r * F64S60) + (r * F64C60))) + + n.noise(x + ((r * F64C61) - (r * F64S61)), z + ((r * F64S61) + (r * F64C61))) + + n.noise(x + ((r * F64C62) - (r * F64S62)), z + ((r * F64S62) + (r * F64C62))) + + n.noise(x + ((r * F64C63) - (r * F64S63)), z + ((r * F64S63) + (r * F64C63))) + + n.noise(x + ((r * F64C64) - (r * F64S64)), z + ((r * F64S64) + (r * F64C64))) + + n.noise(x + ((r * F64C65) - (r * F64S65)), z + ((r * F64S65) + (r * F64C65))) + + n.noise(x + ((r * F64C66) - (r * F64S66)), z + ((r * F64S66) + (r * F64C66))) + + n.noise(x + ((r * F64C67) - (r * F64S67)), z + ((r * F64S67) + (r * F64C67))) + + n.noise(x + ((r * F64C68) - (r * F64S68)), z + ((r * F64S68) + (r * F64C68))) + + n.noise(x + ((r * F64C69) - (r * F64S69)), z + ((r * F64S69) + (r * F64C69))) + + n.noise(x + ((r * F64C70) - (r * F64S70)), z + ((r * F64S70) + (r * F64C70))) + + n.noise(x + ((r * F64C71) - (r * F64S71)), z + ((r * F64S71) + (r * F64C71)))) / 64.0D; } } diff --git a/src/main/java/com/volmit/iris/util/inventorygui/RandomColor.java b/src/main/java/com/volmit/iris/util/inventorygui/RandomColor.java index dfa7f04b0..6380ec99d 100644 --- a/src/main/java/com/volmit/iris/util/inventorygui/RandomColor.java +++ b/src/main/java/com/volmit/iris/util/inventorygui/RandomColor.java @@ -74,12 +74,12 @@ public class RandomColor { } public int[] randomColor(int count) { - if (count <= 0) { + if(count <= 0) { throw new IllegalArgumentException("count must be greater than 0"); } int[] colors = new int[count]; - for (int i = 0; i < count; i++) { + for(int i = 0; i < count; i++) { colors[i] = randomColor(); } @@ -96,12 +96,12 @@ public class RandomColor { } public int[] random(Color color, int count) { - if (count <= 0) { + if(count <= 0) { throw new IllegalArgumentException("count must be greater than 0"); } int[] colors = new int[count]; - for (int i = 0; i < count; i++) { + for(int i = 0; i < count; i++) { colors[i] = randomColor(color); } @@ -118,7 +118,7 @@ public class RandomColor { // Instead of storing red as two seperate ranges, // we group them, using negative numbers - if (hue < 0) { + if(hue < 0) { hue = 360 + hue; } @@ -131,7 +131,7 @@ public class RandomColor { } private Range getHueRange(int number) { - if (number < 360 && number > 0) { + if(number < 360 && number > 0) { return new Range(number, number); } @@ -139,7 +139,7 @@ public class RandomColor { } private Range getHueRange(String name) { - if (colors.containsKey(name)) { + if(colors.containsKey(name)) { return colors.get(name).getHueRange(); } @@ -156,8 +156,8 @@ public class RandomColor { } private int pickSaturation(ColorInfo colorInfo, SaturationType saturationType, Luminosity luminosity) { - if (saturationType != null) { - switch (saturationType) { + if(saturationType != null) { + switch(saturationType) { case RANDOM: return randomWithin(new Range(0, 100)); case MONOCHROME: @@ -171,7 +171,7 @@ public class RandomColor { } } - if (colorInfo == null) { + if(colorInfo == null) { return 0; } @@ -180,8 +180,8 @@ public class RandomColor { int min = saturationRange.start; int max = saturationRange.end; - if (luminosity != null) { - switch (luminosity) { + if(luminosity != null) { + switch(luminosity) { case LIGHT: min = 55; break; @@ -211,10 +211,10 @@ public class RandomColor { private int pickBrightness(ColorInfo colorInfo, int saturation, Luminosity luminosity) { int min = getMinimumBrightness(colorInfo, saturation), - max = 100; + max = 100; - if (luminosity != null) { - switch (luminosity) { + if(luminosity != null) { + switch(luminosity) { case DARK: max = min + 20; @@ -235,26 +235,26 @@ public class RandomColor { } private int getMinimumBrightness(ColorInfo colorInfo, int saturation) { - if (colorInfo == null) { + if(colorInfo == null) { return 0; } List lowerBounds = colorInfo.getLowerBounds(); - for (int i = 0; i < lowerBounds.size() - 1; i++) { + for(int i = 0; i < lowerBounds.size() - 1; i++) { int s1 = lowerBounds.get(i).start, - v1 = lowerBounds.get(i).end; + v1 = lowerBounds.get(i).end; - if (i == lowerBounds.size() - 1) { + if(i == lowerBounds.size() - 1) { break; } int s2 = lowerBounds.get(i + 1).start, - v2 = lowerBounds.get(i + 1).end; + v2 = lowerBounds.get(i + 1).end; - if (saturation >= s1 && saturation <= s2) { + if(saturation >= s1 && saturation <= s2) { float m = (v2 - v1) / (float) (s2 - s1), - b = v1 - m * s1; + b = v1 - m * s1; return (int) (m * saturation + b); } @@ -266,13 +266,13 @@ public class RandomColor { private ColorInfo getColorInfo(int hue) { // Maps red colors to make picking hue easier - if (hue >= 334 && hue <= 360) { + if(hue >= 334 && hue <= 360) { hue -= 360; } - for (String key : colors.keySet()) { + for(String key : colors.keySet()) { ColorInfo colorInfo = colors.get(key); - if (colorInfo.getHueRange() != null && colorInfo.getHueRange().contain(hue)) { + if(colorInfo.getHueRange() != null && colorInfo.getHueRange().contain(hue)) { return colorInfo; } } @@ -298,9 +298,9 @@ public class RandomColor { lowerBounds1.add(new Range(0, 0)); lowerBounds1.add(new Range(100, 0)); defineColor( - Color.MONOCHROME.name(), - new Range(0, 0), - lowerBounds1 + Color.MONOCHROME.name(), + new Range(0, 0), + lowerBounds1 ); List lowerBounds2 = new ArrayList<>(); @@ -314,9 +314,9 @@ public class RandomColor { lowerBounds2.add(new Range(90, 55)); lowerBounds2.add(new Range(100, 50)); defineColor( - Color.RED.name(), - new Range(-26, 18), - lowerBounds2 + Color.RED.name(), + new Range(-26, 18), + lowerBounds2 ); List lowerBounds3 = new ArrayList(); @@ -328,9 +328,9 @@ public class RandomColor { lowerBounds3.add(new Range(70, 70)); lowerBounds3.add(new Range(100, 70)); defineColor( - Color.ORANGE.name(), - new Range(19, 46), - lowerBounds3 + Color.ORANGE.name(), + new Range(19, 46), + lowerBounds3 ); List lowerBounds4 = new ArrayList<>(); @@ -344,9 +344,9 @@ public class RandomColor { lowerBounds4.add(new Range(100, 75)); defineColor( - Color.YELLOW.name(), - new Range(47, 62), - lowerBounds4 + Color.YELLOW.name(), + new Range(47, 62), + lowerBounds4 ); List lowerBounds5 = new ArrayList<>(); @@ -360,9 +360,9 @@ public class RandomColor { lowerBounds5.add(new Range(100, 40)); defineColor( - Color.GREEN.name(), - new Range(63, 178), - lowerBounds5 + Color.GREEN.name(), + new Range(63, 178), + lowerBounds5 ); List lowerBounds6 = new ArrayList<>(); @@ -377,9 +377,9 @@ public class RandomColor { lowerBounds6.add(new Range(100, 35)); defineColor( - Color.BLUE.name(), - new Range(179, 257), - lowerBounds6 + Color.BLUE.name(), + new Range(179, 257), + lowerBounds6 ); List lowerBounds7 = new ArrayList<>(); @@ -394,9 +394,9 @@ public class RandomColor { lowerBounds7.add(new Range(100, 42)); defineColor( - Color.PURPLE.name(), - new Range(258, 282), - lowerBounds7 + Color.PURPLE.name(), + new Range(258, 282), + lowerBounds7 ); List lowerBounds8 = new ArrayList<>(); @@ -409,9 +409,9 @@ public class RandomColor { lowerBounds8.add(new Range(100, 73)); defineColor( - Color.PINK.name(), - new Range(283, 334), - lowerBounds8 + Color.PINK.name(), + new Range(283, 334), + lowerBounds8 ); } diff --git a/src/main/java/com/volmit/iris/util/inventorygui/UIElement.java b/src/main/java/com/volmit/iris/util/inventorygui/UIElement.java index 331122202..466b8c829 100644 --- a/src/main/java/com/volmit/iris/util/inventorygui/UIElement.java +++ b/src/main/java/com/volmit/iris/util/inventorygui/UIElement.java @@ -137,7 +137,7 @@ public class UIElement implements Element { @Override public Element call(ElementEvent event, Element context) { try { - switch (event) { + switch(event) { case DRAG_INTO -> { eDraggedInto.run(context); return this; @@ -163,10 +163,10 @@ public class UIElement implements Element { return this; } } - } catch (NullPointerException e) { + } catch(NullPointerException e) { Iris.reportError(e); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -211,13 +211,13 @@ public class UIElement implements Element { im.setDisplayName(getName()); im.setLore(getLore().copy()); - if (isEnchanted()) { + if(isEnchanted()) { im.addEnchant(Enchantment.DURABILITY, 1, true); } is.setItemMeta(im); return is; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -238,7 +238,7 @@ public class UIElement implements Element { @Override public short getEffectiveDurability() { - if (getMaterial().getMaterial().getMaxDurability() == 0) { + if(getMaterial().getMaterial().getMaxDurability() == 0) { return 0; } else { int prog = (int) ((double) getMaterial().getMaterial().getMaxDurability() * (1D - getProgress())); diff --git a/src/main/java/com/volmit/iris/util/inventorygui/UIWindow.java b/src/main/java/com/volmit/iris/util/inventorygui/UIWindow.java index 45824aa91..25d59b1cd 100644 --- a/src/main/java/com/volmit/iris/util/inventorygui/UIWindow.java +++ b/src/main/java/com/volmit/iris/util/inventorygui/UIWindow.java @@ -63,31 +63,31 @@ public class UIWindow implements Window, Listener { @EventHandler public void on(InventoryClickEvent e) { - if (!e.getWhoClicked().equals(viewer)) { + if(!e.getWhoClicked().equals(viewer)) { return; } - if (!isVisible()) { + if(!isVisible()) { return; } // 1.14 bukkit api change, removed getTitle() and getName() from Inventory.class - if (!viewer.getOpenInventory().getTitle().equals(title)) { + if(!viewer.getOpenInventory().getTitle().equals(title)) { return; } - if (e.getClickedInventory() == null) { + if(e.getClickedInventory() == null) { return; } - if (!e.getView().getType().equals(getResolution().getType())) { + if(!e.getView().getType().equals(getResolution().getType())) { return; } - if (e.getClickedInventory().getType().equals(getResolution().getType())) { + if(e.getClickedInventory().getType().equals(getResolution().getType())) { Element element = getElement(getLayoutPosition(e.getSlot()), getLayoutRow(e.getSlot())); - switch (e.getAction()) { + switch(e.getAction()) { case CLONE_STACK: case UNKNOWN: case SWAP_WITH_CURSOR: @@ -110,7 +110,7 @@ public class UIWindow implements Window, Listener { break; } - switch (e.getClick()) { + switch(e.getClick()) { case DOUBLE_CLICK: doubleclicked = true; break; @@ -118,21 +118,21 @@ public class UIWindow implements Window, Listener { clickcheck++; - if (clickcheck == 1) { + if(clickcheck == 1) { J.s(() -> { - if (clickcheck == 1) { + if(clickcheck == 1) { clickcheck = 0; - if (element != null) { + if(element != null) { element.call(ElementEvent.LEFT, element); } } }); - } else if (clickcheck == 2) { + } else if(clickcheck == 2) { J.s(() -> { - if (doubleclicked) { + if(doubleclicked) { doubleclicked = false; } else { scroll(1); @@ -144,19 +144,19 @@ public class UIWindow implements Window, Listener { break; case RIGHT: - if (element != null) { + if(element != null) { element.call(ElementEvent.RIGHT, element); } else { scroll(-1); } break; case SHIFT_LEFT: - if (element != null) { + if(element != null) { element.call(ElementEvent.SHIFT_LEFT, element); } break; case SHIFT_RIGHT: - if (element != null) { + if(element != null) { element.call(ElementEvent.SHIFT_RIGHT, element); } break; @@ -180,15 +180,15 @@ public class UIWindow implements Window, Listener { @EventHandler public void on(InventoryCloseEvent e) { - if (!e.getPlayer().equals(viewer)) { + if(!e.getPlayer().equals(viewer)) { return; } - if (!e.getPlayer().getOpenInventory().getTitle().equals(title)) { + if(!e.getPlayer().getOpenInventory().getTitle().equals(title)) { return; } - if (isVisible()) { + if(isVisible()) { close(); callClosed(); } @@ -224,14 +224,14 @@ public class UIWindow implements Window, Listener { @Override public UIWindow setVisible(boolean visible) { - if (isVisible() == visible) { + if(isVisible() == visible) { return this; } - if (visible) { + if(visible) { Bukkit.getPluginManager().registerEvents(this, Iris.instance); - if (getResolution().getType().equals(InventoryType.CHEST)) { + if(getResolution().getType().equals(InventoryType.CHEST)) { inventory = Bukkit.createInventory(null, getViewportHeight() * 9, getTitle()); } else { inventory = Bukkit.createInventory(null, getResolution().getType(), getTitle()); @@ -286,7 +286,7 @@ public class UIWindow implements Window, Listener { public UIWindow setViewportHeight(int height) { viewportSize = (int) clip(height, 1, getResolution().getMaxHeight()).doubleValue(); - if (isVisible()) { + if(isVisible()) { reopen(); } @@ -302,7 +302,7 @@ public class UIWindow implements Window, Listener { public UIWindow setTitle(String title) { this.title = title; - if (isVisible()) { + if(isVisible()) { reopen(); } @@ -311,7 +311,7 @@ public class UIWindow implements Window, Listener { @Override public UIWindow setElement(int position, int row, Element e) { - if (row > highestRow) { + if(row > highestRow) { highestRow = row; } @@ -373,7 +373,7 @@ public class UIWindow implements Window, Listener { @Override public Window callClosed() { - if (eClose != null) { + if(eClose != null) { eClose.run(this); } @@ -412,23 +412,23 @@ public class UIWindow implements Window, Listener { @Override public Window updateInventory() { - if (isVisible()) { + if(isVisible()) { ItemStack[] is = inventory.getContents(); @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") KSet isf = new KSet<>(); - for (int i = 0; i < is.length; i++) { + for(int i = 0; i < is.length; i++) { ItemStack isc = is[i]; ItemStack isx = computeItemStack(i); int layoutRow = getLayoutRow(i); int layoutPosition = getLayoutPosition(i); - if (isx != null && !hasElement(layoutPosition, layoutRow)) { + if(isx != null && !hasElement(layoutPosition, layoutRow)) { ItemStack gg = isx.clone(); gg.setAmount(gg.getAmount() + 1); isf.add(gg); } - if (((isc == null) != (isx == null)) || isx != null && isc != null && !isc.equals(isx)) { + if(((isc == null) != (isx == null)) || isx != null && isc != null && !isc.equals(isx)) { inventory.setItem(i, isx); } } @@ -443,7 +443,7 @@ public class UIWindow implements Window, Listener { int layoutPosition = getLayoutPosition(viewportSlot); Element e = hasElement(layoutPosition, layoutRow) ? getElement(layoutPosition, layoutRow) : getDecorator().onDecorateBackground(this, layoutPosition, layoutRow); - if (e != null) { + if(e != null) { return e.computeItemStack(); } diff --git a/src/main/java/com/volmit/iris/util/io/FileWatcher.java b/src/main/java/com/volmit/iris/util/io/FileWatcher.java index 79f90f8b5..358826ba5 100644 --- a/src/main/java/com/volmit/iris/util/io/FileWatcher.java +++ b/src/main/java/com/volmit/iris/util/io/FileWatcher.java @@ -43,7 +43,7 @@ public class FileWatcher { boolean mod = false; readProperties(); - if (lastModified != m || g != size) { + if(lastModified != m || g != size) { mod = true; } diff --git a/src/main/java/com/volmit/iris/util/io/FolderWatcher.java b/src/main/java/com/volmit/iris/util/io/FolderWatcher.java index a99253fa7..0129b87a8 100644 --- a/src/main/java/com/volmit/iris/util/io/FolderWatcher.java +++ b/src/main/java/com/volmit/iris/util/io/FolderWatcher.java @@ -34,22 +34,22 @@ public class FolderWatcher extends FileWatcher { } protected void readProperties() { - if (watchers == null) { + if(watchers == null) { watchers = new KMap<>(); changed = new KList<>(); created = new KList<>(); deleted = new KList<>(); } - if (file.isDirectory()) { - for (File i : file.listFiles()) { - if (!watchers.containsKey(i)) { + if(file.isDirectory()) { + for(File i : file.listFiles()) { + if(!watchers.containsKey(i)) { watchers.put(i, new FolderWatcher(i)); } } - for (File i : watchers.k()) { - if (!i.exists()) { + for(File i : watchers.k()) { + if(!i.exists()) { watchers.remove(i); } } @@ -63,22 +63,22 @@ public class FolderWatcher extends FileWatcher { created.clear(); deleted.clear(); - if (file.isDirectory()) { + if(file.isDirectory()) { KMap w = watchers.copy(); readProperties(); - for (File i : w.keySet()) { - if (!watchers.containsKey(i)) { + for(File i : w.keySet()) { + if(!watchers.containsKey(i)) { deleted.add(i); } } - for (File i : watchers.keySet()) { - if (!w.containsKey(i)) { + for(File i : watchers.keySet()) { + if(!w.containsKey(i)) { created.add(i); } else { FolderWatcher fw = watchers.get(i); - if (fw.checkModified()) { + if(fw.checkModified()) { changed.add(fw.file); } @@ -95,7 +95,7 @@ public class FolderWatcher extends FileWatcher { } public boolean checkModifiedFast() { - if (watchers == null || watchers.isEmpty()) { + if(watchers == null || watchers.isEmpty()) { return checkModified(); } @@ -103,10 +103,10 @@ public class FolderWatcher extends FileWatcher { created.clear(); deleted.clear(); - if (file.isDirectory()) { - for (File i : watchers.keySet()) { + if(file.isDirectory()) { + for(File i : watchers.keySet()) { FolderWatcher fw = watchers.get(i); - if (fw.checkModifiedFast()) { + if(fw.checkModifiedFast()) { changed.add(fw.file); } diff --git a/src/main/java/com/volmit/iris/util/io/IO.java b/src/main/java/com/volmit/iris/util/io/IO.java index ae909a00c..ab2c18540 100644 --- a/src/main/java/com/volmit/iris/util/io/IO.java +++ b/src/main/java/com/volmit/iris/util/io/IO.java @@ -129,7 +129,7 @@ public class IO { try { MessageDigest d = MessageDigest.getInstance("SHA-256"); return bytesToHex(d.digest(b.getBytes(StandardCharsets.UTF_8))); - } catch (NoSuchAlgorithmException e) { + } catch(NoSuchAlgorithmException e) { Iris.reportError(e); e.printStackTrace(); } @@ -144,7 +144,7 @@ public class IO { fullTransfer(din, new VoidOutputStream(), 8192); din.close(); return bytesToHex(din.getMessageDigest().digest()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } @@ -154,7 +154,7 @@ public class IO { public static String bytesToHex(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; - for (int j = 0; j < bytes.length; j++) { + for(int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; @@ -170,7 +170,7 @@ public class IO { public static String longsToHex(long[] bytes) { byte[] v = new byte[bytes.length * 8]; - for (int i = 0; i < bytes.length; i++) { + for(int i = 0; i < bytes.length; i++) { v[i * 8] = (byte) (bytes[i] >>> 56); v[(i * 8) + 1] = (byte) (bytes[i] >>> 48); v[(i * 8) + 2] = (byte) (bytes[i] >>> 40); @@ -188,15 +188,18 @@ public class IO { * Transfers the length of the buffer amount of data from the input stream to * the output stream * - * @param in the input - * @param out the output + * @param in + * the input + * @param out + * the output * @return the actual transfered amount - * @throws IOException shit happens + * @throws IOException + * shit happens */ public static int transfer(InputStream in, OutputStream out, byte[] buffer) throws IOException { int r = in.read(buffer); - if (r != -1) { + if(r != -1) { out.write(buffer, 0, r); } @@ -207,12 +210,17 @@ public class IO { * Transfers the length of the buffer amount of data from the input stream to * the output stream * - * @param in the input - * @param out the output - * @param targetBuffer the buffer and size to use - * @param totalSize the total amount to transfer + * @param in + * the input + * @param out + * the output + * @param targetBuffer + * the buffer and size to use + * @param totalSize + * the total amount to transfer * @return the actual transfered amount - * @throws IOException shit happens + * @throws IOException + * shit happens */ public static long transfer(InputStream in, OutputStream out, int targetBuffer, long totalSize) throws IOException { long total = totalSize; @@ -220,12 +228,12 @@ public class IO { byte[] buf = new byte[targetBuffer]; int r = 0; - while ((r = in.read(buf, 0, (int) (total < targetBuffer ? total : targetBuffer))) != -1) { + while((r = in.read(buf, 0, (int) (total < targetBuffer ? total : targetBuffer))) != -1) { total -= r; out.write(buf, 0, r); wrote += r; - if (total <= 0) { + if(total <= 0) { break; } } @@ -237,20 +245,17 @@ public class IO { * Fully move data from a finite inputstream to an output stream using a buffer * size of 8192. This does NOT close streams. * - * @param in - * @param out * @return total size transfered - * @throws IOException */ public static long fillTransfer(InputStream in, OutputStream out) throws IOException { return fullTransfer(in, out, 8192); } public static void deleteUp(File f) { - if (f.exists()) { + if(f.exists()) { f.delete(); - if (f.getParentFile().list().length == 0) { + if(f.getParentFile().list().length == 0) { deleteUp(f.getParentFile()); } } @@ -260,18 +265,22 @@ public class IO { * Fully move data from a finite inputstream to an output stream using a given * buffer size. This does NOT close streams. * - * @param in the input stream to read from - * @param out the output stream to writeNodeData to - * @param bufferSize the target buffer size + * @param in + * the input stream to read from + * @param out + * the output stream to writeNodeData to + * @param bufferSize + * the target buffer size * @return total size transfered - * @throws IOException shit happens + * @throws IOException + * shit happens */ public static long fullTransfer(InputStream in, OutputStream out, int bufferSize) throws IOException { long wrote = 0; byte[] buf = new byte[bufferSize]; int r = 0; - while ((r = in.read(buf)) != -1) { + while((r = in.read(buf)) != -1) { out.write(buf, 0, r); wrote += r; } @@ -282,15 +291,16 @@ public class IO { /** * Recursive delete (deleting folders) * - * @param f the file to delete (and subfiles if folder) + * @param f + * the file to delete (and subfiles if folder) */ public static void delete(File f) { - if (f == null || !f.exists()) { + if(f == null || !f.exists()) { return; } - if (f.isDirectory()) { - for (File i : f.listFiles()) { + if(f.isDirectory()) { + for(File i : f.listFiles()) { delete(i); } } @@ -301,9 +311,9 @@ public class IO { public static long size(File file) { long s = 0; - if (file.exists()) { - if (file.isDirectory()) { - for (File i : file.listFiles()) { + if(file.exists()) { + if(file.isDirectory()) { + for(File i : file.listFiles()) { s += size(i); } } else { @@ -317,9 +327,9 @@ public class IO { public static long count(File file) { long s = 0; - if (file.exists()) { - if (file.isDirectory()) { - for (File i : file.listFiles()) { + if(file.exists()) { + if(file.isDirectory()) { + for(File i : file.listFiles()) { s += count(i); } } else { @@ -335,12 +345,12 @@ public class IO { long wrote = 0; int r = 0; - while ((r = in.read(buf, 0, (int) (total < buf.length ? total : buf.length))) != -1) { + while((r = in.read(buf, 0, (int) (total < buf.length ? total : buf.length))) != -1) { total -= r; out.write(buf, 0, r); wrote += r; - if (total <= 0) { + if(total <= 0) { break; } } @@ -354,22 +364,22 @@ public class IO { try { Enumeration entries = file.entries(); - while (entries.hasMoreElements()) { + while(entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); - if (entryname.equals(entry.getName())) { + if(entryname.equals(entry.getName())) { InputStream in = file.getInputStream(entry); v.accept(in); } } - } catch (Exception ex) { + } catch(Exception ex) { Iris.reportError(ex); x = ex.getCause(); } finally { file.close(); } - if (x != null) { + if(x != null) { throw new IOException("Failed to read zip entry, however it has been closed safely.", x); } } @@ -377,7 +387,7 @@ public class IO { public static void writeAll(File f, Object c) throws IOException { try { f.getParentFile().mkdirs(); - } catch (Throwable ignored) { + } catch(Throwable ignored) { } @@ -397,7 +407,7 @@ public class IO { FileReader fr; try { fr = new FileReader(f); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); throw e; } @@ -405,7 +415,7 @@ public class IO { StringBuilder c = new StringBuilder(); String l = ""; - while ((l = bu.readLine()) != null) { + while((l = bu.readLine()) != null) { c.append(l).append("\n"); } @@ -419,7 +429,7 @@ public class IO { StringBuilder c = new StringBuilder(); String l = ""; - while ((l = bu.readLine()) != null) { + while((l = bu.readLine()) != null) { c.append(l).append("\n"); } @@ -433,11 +443,13 @@ public class IO { * new file with size 0 or, if the file exists already, it is opened and closed * without modifying it, but updating the file date and time. * - * @param file the File to touch - * @throws IOException If an I/O problem occurs + * @param file + * the File to touch + * @throws IOException + * If an I/O problem occurs */ public static void touch(File file) throws IOException { - if (!file.exists()) { + if(!file.exists()) { OutputStream out = new FileOutputStream(file); out.close(); } @@ -452,11 +464,16 @@ public class IO { * does not exist. If the destination file exists, then this method will * overwrite it. * - * @param srcFile an existing file to copy, must not be null - * @param destFile the new file, must not be null - * @throws NullPointerException if source or destination is null - * @throws IOException if source or destination is invalid - * @throws IOException if an IO error occurs during copying + * @param srcFile + * an existing file to copy, must not be null + * @param destFile + * the new file, must not be null + * @throws NullPointerException + * if source or destination is null + * @throws IOException + * if source or destination is invalid + * @throws IOException + * if an IO error occurs during copying */ public static void copyFile(File srcFile, File destFile) throws IOException { copyFile(srcFile, destFile, true); @@ -470,36 +487,42 @@ public class IO { * does not exist. If the destination file exists, then this method will * overwrite it. * - * @param srcFile an existing file to copy, must not be null - * @param destFile the new file, must not be null - * @param preserveFileDate true if the file date of the copy should be the same as the - * original - * @throws NullPointerException if source or destination is null - * @throws IOException if source or destination is invalid - * @throws IOException if an IO error occurs during copying + * @param srcFile + * an existing file to copy, must not be null + * @param destFile + * the new file, must not be null + * @param preserveFileDate + * true if the file date of the copy should be the same as the + * original + * @throws NullPointerException + * if source or destination is null + * @throws IOException + * if source or destination is invalid + * @throws IOException + * if an IO error occurs during copying */ public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException { - if (srcFile == null) { + if(srcFile == null) { throw new NullPointerException("Source must not be null"); } - if (destFile == null) { + if(destFile == null) { throw new NullPointerException("Destination must not be null"); } - if (!srcFile.exists()) { + if(!srcFile.exists()) { throw new FileNotFoundException("Source '" + srcFile + "' does not exist"); } - if (srcFile.isDirectory()) { + if(srcFile.isDirectory()) { throw new IOException("Source '" + srcFile + "' exists but is a directory"); } - if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) { + if(srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) { throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same"); } - if (destFile.getParentFile() != null && !destFile.getParentFile().exists()) { - if (!destFile.getParentFile().mkdirs()) { + if(destFile.getParentFile() != null && !destFile.getParentFile().exists()) { + if(!destFile.getParentFile().mkdirs()) { throw new IOException("Destination '" + destFile + "' directory cannot be created"); } } - if (destFile.exists() && !destFile.canWrite()) { + if(destFile.exists() && !destFile.canWrite()) { throw new IOException("Destination '" + destFile + "' exists but is read-only"); } doCopyFile(srcFile, destFile, preserveFileDate); @@ -510,13 +533,17 @@ public class IO { /** * Internal copy file method. * - * @param srcFile the validated source file, not null - * @param destFile the validated destination file, not null - * @param preserveFileDate whether to preserve the file date - * @throws IOException if an error occurs + * @param srcFile + * the validated source file, not null + * @param destFile + * the validated destination file, not null + * @param preserveFileDate + * whether to preserve the file date + * @throws IOException + * if an error occurs */ private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException { - if (destFile.exists() && destFile.isDirectory()) { + if(destFile.exists() && destFile.isDirectory()) { throw new IOException("Destination '" + destFile + "' exists but is a directory"); } @@ -532,10 +559,10 @@ public class IO { input.close(); } - if (srcFile.length() != destFile.length()) { + if(srcFile.length() != destFile.length()) { throw new IOException("Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'"); } - if (preserveFileDate) { + if(preserveFileDate) { destFile.setLastModified(srcFile.lastModified()); } } @@ -546,14 +573,15 @@ public class IO { * Equivalent to {@link Reader#close()}, except any exceptions will be ignored. * This is typically used in finally blocks. * - * @param input the Reader to close, may be null or already closed + * @param input + * the Reader to close, may be null or already closed */ public static void closeQuietly(Reader input) { try { - if (input != null) { + if(input != null) { input.close(); } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); // ignore } @@ -565,14 +593,15 @@ public class IO { * Equivalent to {@link Writer#close()}, except any exceptions will be ignored. * This is typically used in finally blocks. * - * @param output the Writer to close, may be null or already closed + * @param output + * the Writer to close, may be null or already closed */ public static void closeQuietly(Writer output) { try { - if (output != null) { + if(output != null) { output.close(); } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); // ignore } @@ -584,14 +613,15 @@ public class IO { * Equivalent to {@link InputStream#close()}, except any exceptions will be * ignored. This is typically used in finally blocks. * - * @param input the InputStream to close, may be null or already closed + * @param input + * the InputStream to close, may be null or already closed */ public static void closeQuietly(InputStream input) { try { - if (input != null) { + if(input != null) { input.close(); } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); // ignore } @@ -606,14 +636,15 @@ public class IO { * Equivalent to {@link OutputStream#close()}, except any exceptions will be * ignored. This is typically used in finally blocks. * - * @param output the OutputStream to close, may be null or already closed + * @param output + * the OutputStream to close, may be null or already closed */ public static void closeQuietly(OutputStream output) { try { - if (output != null) { + if(output != null) { output.close(); } - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); // ignore } @@ -625,10 +656,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param input the InputStream to read from + * @param input + * the InputStream to read from * @return the requested byte array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs */ public static byte[] toByteArray(InputStream input) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -643,10 +677,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedReader. * - * @param input the Reader to read from + * @param input + * the Reader to read from * @return the requested byte array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs */ public static byte[] toByteArray(Reader input) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -664,11 +701,15 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedReader. * - * @param input the Reader to read from - * @param encoding the encoding to use, null means platform default + * @param input + * the Reader to read from + * @param encoding + * the encoding to use, null means platform default * @return the requested byte array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static byte[] toByteArray(Reader input, String encoding) throws IOException { @@ -686,7 +727,8 @@ public class IO { *

* This method uses {@link String#String(byte[])}. * - * @param data the byte array to writeNodeData, do not modify during output, null ignored - * @param output the Writer to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the byte array to writeNodeData, do not modify during output, null ignored + * @param output + * the Writer to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(byte[] data, Writer output) throws IOException { - if (data != null) { + if(data != null) { output.write(new String(data)); } } @@ -1003,16 +1092,21 @@ public class IO { *

* This method uses {@link String#String(byte[], String)}. * - * @param data the byte array to writeNodeData, do not modify during output, null ignored - * @param output the Writer to writeNodeData to - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the byte array to writeNodeData, do not modify during output, null ignored + * @param output + * the Writer to writeNodeData to + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(byte[] data, Writer output, String encoding) throws IOException { - if (data != null) { - if (encoding == null) { + if(data != null) { + if(encoding == null) { write(data, output); } else { output.write(new String(data, encoding)); @@ -1024,14 +1118,18 @@ public class IO { * Writes chars from a char[] to a Writer using the * default character encoding of the platform. * - * @param data the char array to writeNodeData, do not modify during output, null ignored - * @param output the Writer to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the char array to writeNodeData, do not modify during output, null ignored + * @param output + * the Writer to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(char[] data, Writer output) throws IOException { - if (data != null) { + if(data != null) { output.write(data); } } @@ -1042,14 +1140,18 @@ public class IO { *

* This method uses {@link String#String(char[])} and {@link String#getBytes()}. * - * @param data the char array to writeNodeData, do not modify during output, null ignored - * @param output the OutputStream to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the char array to writeNodeData, do not modify during output, null ignored + * @param output + * the OutputStream to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(char[] data, OutputStream output) throws IOException { - if (data != null) { + if(data != null) { output.write(new String(data).getBytes()); } } @@ -1067,16 +1169,21 @@ public class IO { * This method uses {@link String#String(char[])} and * {@link String#getBytes(String)}. * - * @param data the char array to writeNodeData, do not modify during output, null ignored - * @param output the OutputStream to writeNodeData to - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the char array to writeNodeData, do not modify during output, null ignored + * @param output + * the OutputStream to writeNodeData to + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(char[] data, OutputStream output, String encoding) throws IOException { - if (data != null) { - if (encoding == null) { + if(data != null) { + if(encoding == null) { write(data, output); } else { output.write(new String(data).getBytes(encoding)); @@ -1087,14 +1194,18 @@ public class IO { /** * Writes chars from a String to a Writer. * - * @param data the String to writeNodeData, null ignored - * @param output the Writer to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the String to writeNodeData, null ignored + * @param output + * the Writer to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(String data, Writer output) throws IOException { - if (data != null) { + if(data != null) { output.write(data); } } @@ -1106,14 +1217,18 @@ public class IO { *

* This method uses {@link String#getBytes()}. * - * @param data the String to writeNodeData, null ignored - * @param output the OutputStream to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the String to writeNodeData, null ignored + * @param output + * the OutputStream to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(String data, OutputStream output) throws IOException { - if (data != null) { + if(data != null) { output.write(data.getBytes()); } } @@ -1130,16 +1245,21 @@ public class IO { *

* This method uses {@link String#getBytes(String)}. * - * @param data the String to writeNodeData, null ignored - * @param output the OutputStream to writeNodeData to - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the String to writeNodeData, null ignored + * @param output + * the OutputStream to writeNodeData to + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(String data, OutputStream output, String encoding) throws IOException { - if (data != null) { - if (encoding == null) { + if(data != null) { + if(encoding == null) { write(data, output); } else { output.write(data.getBytes(encoding)); @@ -1150,14 +1270,18 @@ public class IO { /** * Writes chars from a StringBuffer to a Writer. * - * @param data the StringBuffer to writeNodeData, null ignored - * @param output the Writer to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the StringBuffer to writeNodeData, null ignored + * @param output + * the Writer to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(StringBuffer data, Writer output) throws IOException { - if (data != null) { + if(data != null) { output.write(data.toString()); } } @@ -1169,14 +1293,18 @@ public class IO { *

* This method uses {@link String#getBytes()}. * - * @param data the StringBuffer to writeNodeData, null ignored - * @param output the OutputStream to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the StringBuffer to writeNodeData, null ignored + * @param output + * the OutputStream to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(StringBuffer data, OutputStream output) throws IOException { - if (data != null) { + if(data != null) { output.write(data.toString().getBytes()); } } @@ -1193,16 +1321,21 @@ public class IO { *

* This method uses {@link String#getBytes(String)}. * - * @param data the StringBuffer to writeNodeData, null ignored - * @param output the OutputStream to writeNodeData to - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the StringBuffer to writeNodeData, null ignored + * @param output + * the OutputStream to writeNodeData to + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException { - if (data != null) { - if (encoding == null) { + if(data != null) { + if(encoding == null) { write(data, output); } else { output.write(data.toString().getBytes(encoding)); @@ -1215,23 +1348,28 @@ public class IO { * OutputStream line by line, using the default character encoding * of the platform and the specified line ending. * - * @param lines the lines to writeNodeData, null entries produce blank lines - * @param lineEnding the line separator to use, null is system default - * @param output the OutputStream to writeNodeData to, not null, not closed - * @throws NullPointerException if the output is null - * @throws IOException if an I/O error occurs + * @param lines + * the lines to writeNodeData, null entries produce blank lines + * @param lineEnding + * the line separator to use, null is system default + * @param output + * the OutputStream to writeNodeData to, not null, not closed + * @throws NullPointerException + * if the output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void writeLines(Collection lines, String lineEnding, OutputStream output) throws IOException { - if (lines == null) { + if(lines == null) { return; } - if (lineEnding == null) { + if(lineEnding == null) { lineEnding = LINE_SEPARATOR; } - for (Iterator it = lines.iterator(); it.hasNext(); ) { + for(Iterator it = lines.iterator(); it.hasNext(); ) { Object line = it.next(); - if (line != null) { + if(line != null) { output.write(line.toString().getBytes()); } output.write(lineEnding.getBytes()); @@ -1246,27 +1384,33 @@ public class IO { * Character encoding names can be found at * IANA. * - * @param lines the lines to writeNodeData, null entries produce blank lines - * @param lineEnding the line separator to use, null is system default - * @param output the OutputStream to writeNodeData to, not null, not closed - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if the output is null - * @throws IOException if an I/O error occurs + * @param lines + * the lines to writeNodeData, null entries produce blank lines + * @param lineEnding + * the line separator to use, null is system default + * @param output + * the OutputStream to writeNodeData to, not null, not closed + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if the output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void writeLines(Collection lines, String lineEnding, OutputStream output, String encoding) throws IOException { - if (encoding == null) { + if(encoding == null) { writeLines(lines, lineEnding, output); } else { - if (lines == null) { + if(lines == null) { return; } - if (lineEnding == null) { + if(lineEnding == null) { lineEnding = LINE_SEPARATOR; } - for (Iterator it = lines.iterator(); it.hasNext(); ) { + for(Iterator it = lines.iterator(); it.hasNext(); ) { Object line = it.next(); - if (line != null) { + if(line != null) { output.write(line.toString().getBytes(encoding)); } output.write(lineEnding.getBytes(encoding)); @@ -1281,23 +1425,28 @@ public class IO { * Writes the toString() value of each item in a collection to a * Writer line by line, using the specified line ending. * - * @param lines the lines to writeNodeData, null entries produce blank lines - * @param lineEnding the line separator to use, null is system default - * @param writer the Writer to writeNodeData to, not null, not closed - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @param lines + * the lines to writeNodeData, null entries produce blank lines + * @param lineEnding + * the line separator to use, null is system default + * @param writer + * the Writer to writeNodeData to, not null, not closed + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void writeLines(Collection lines, String lineEnding, Writer writer) throws IOException { - if (lines == null) { + if(lines == null) { return; } - if (lineEnding == null) { + if(lineEnding == null) { lineEnding = LINE_SEPARATOR; } - for (Iterator it = lines.iterator(); it.hasNext(); ) { + for(Iterator it = lines.iterator(); it.hasNext(); ) { Object line = it.next(); - if (line != null) { + if(line != null) { writer.write(line.toString()); } writer.write(lineEnding); @@ -1315,17 +1464,22 @@ public class IO { * returned as an int. For large streams use the * copyLarge(InputStream, OutputStream) method. * - * @param input the InputStream to read from - * @param output the OutputStream to writeNodeData to + * @param input + * the InputStream to read from + * @param output + * the OutputStream to writeNodeData to * @return the number of bytes copied - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs - * @throws ArithmeticException if the byte count is too large + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs + * @throws ArithmeticException + * if the byte count is too large * @since Commons IO 1.1 */ public static int copy(InputStream input, OutputStream output) throws IOException { long count = copyLarge(input, output); - if (count > Integer.MAX_VALUE) { + if(count > Integer.MAX_VALUE) { return -1; } return (int) count; @@ -1338,18 +1492,22 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param input the InputStream to read from - * @param output the OutputStream to writeNodeData to + * @param input + * the InputStream to read from + * @param output + * the OutputStream to writeNodeData to * @return the number of bytes copied - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.3 */ public static long copyLarge(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; long count = 0; int n = 0; - while (-1 != (n = input.read(buffer))) { + while(-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } @@ -1365,10 +1523,14 @@ public class IO { *

* This method uses {@link InputStreamReader}. * - * @param input the InputStream to read from - * @param output the Writer to writeNodeData to - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs + * @param input + * the InputStream to read from + * @param output + * the Writer to writeNodeData to + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void copy(InputStream input, Writer output) throws IOException { @@ -1391,15 +1553,20 @@ public class IO { *

* This method uses {@link InputStreamReader}. * - * @param input the InputStream to read from - * @param output the Writer to writeNodeData to - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs + * @param input + * the InputStream to read from + * @param output + * the Writer to writeNodeData to + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void copy(InputStream input, Writer output, String encoding) throws IOException { - if (encoding == null) { + if(encoding == null) { copy(input, output); } else { InputStreamReader in = new InputStreamReader(input, encoding); @@ -1418,17 +1585,22 @@ public class IO { * returned as an int. For large streams use the * copyLarge(Reader, Writer) method. * - * @param input the Reader to read from - * @param output the Writer to writeNodeData to + * @param input + * the Reader to read from + * @param output + * the Writer to writeNodeData to * @return the number of characters copied - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs - * @throws ArithmeticException if the character count is too large + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs + * @throws ArithmeticException + * if the character count is too large * @since Commons IO 1.1 */ public static int copy(Reader input, Writer output) throws IOException { long count = copyLarge(input, output); - if (count > Integer.MAX_VALUE) { + if(count > Integer.MAX_VALUE) { return -1; } return (int) count; @@ -1441,18 +1613,22 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedReader. * - * @param input the Reader to read from - * @param output the Writer to writeNodeData to + * @param input + * the Reader to read from + * @param output + * the Writer to writeNodeData to * @return the number of characters copied - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.3 */ public static long copyLarge(Reader input, Writer output) throws IOException { char[] buffer = new char[DEFAULT_BUFFER_SIZE]; long count = 0; int n = 0; - while (-1 != (n = input.read(buffer))) { + while(-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } @@ -1472,10 +1648,14 @@ public class IO { *

* This method uses {@link OutputStreamWriter}. * - * @param input the Reader to read from - * @param output the OutputStream to writeNodeData to - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs + * @param input + * the Reader to read from + * @param output + * the OutputStream to writeNodeData to + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void copy(Reader input, OutputStream output) throws IOException { @@ -1504,15 +1684,20 @@ public class IO { *

* This method uses {@link OutputStreamWriter}. * - * @param input the Reader to read from - * @param output the OutputStream to writeNodeData to - * @param encoding the encoding to use, null means platform default - * @throws NullPointerException if the input or output is null - * @throws IOException if an I/O error occurs + * @param input + * the Reader to read from + * @param output + * the OutputStream to writeNodeData to + * @param encoding + * the encoding to use, null means platform default + * @throws NullPointerException + * if the input or output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void copy(Reader input, OutputStream output, String encoding) throws IOException { - if (encoding == null) { + if(encoding == null) { copy(input, output); } else { OutputStreamWriter out = new OutputStreamWriter(output, encoding); @@ -1528,25 +1713,29 @@ public class IO { * This method buffers the input internally using * BufferedInputStream if they are not already buffered. * - * @param input1 the first stream - * @param input2 the second stream + * @param input1 + * the first stream + * @param input2 + * the second stream * @return true if the content of the streams are equal or they both don't * exist, false otherwise - * @throws NullPointerException if either input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if either input is null + * @throws IOException + * if an I/O error occurs */ public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException { - if (!(input1 instanceof BufferedInputStream)) { + if(!(input1 instanceof BufferedInputStream)) { input1 = new BufferedInputStream(input1); } - if (!(input2 instanceof BufferedInputStream)) { + if(!(input2 instanceof BufferedInputStream)) { input2 = new BufferedInputStream(input2); } int ch = input1.read(); - while (-1 != ch) { + while(-1 != ch) { int ch2 = input2.read(); - if (ch != ch2) { + if(ch != ch2) { return false; } ch = input1.read(); @@ -1562,26 +1751,30 @@ public class IO { * This method buffers the input internally using BufferedReader if * they are not already buffered. * - * @param input1 the first reader - * @param input2 the second reader + * @param input1 + * the first reader + * @param input2 + * the second reader * @return true if the content of the readers are equal or they both don't * exist, false otherwise - * @throws NullPointerException if either input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if either input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static boolean contentEquals(Reader input1, Reader input2) throws IOException { - if (!(input1 instanceof BufferedReader)) { + if(!(input1 instanceof BufferedReader)) { input1 = new BufferedReader(input1); } - if (!(input2 instanceof BufferedReader)) { + if(!(input2 instanceof BufferedReader)) { input2 = new BufferedReader(input2); } int ch = input1.read(); - while (-1 != ch) { + while(-1 != ch) { int ch2 = input2.read(); - if (ch != ch2) { + if(ch != ch2) { return false; } ch = input1.read(); diff --git a/src/main/java/com/volmit/iris/util/io/InstanceState.java b/src/main/java/com/volmit/iris/util/io/InstanceState.java index 3267ce475..2c4f1bf24 100644 --- a/src/main/java/com/volmit/iris/util/io/InstanceState.java +++ b/src/main/java/com/volmit/iris/util/io/InstanceState.java @@ -27,7 +27,7 @@ public class InstanceState { public static int getInstanceId() { try { return Integer.parseInt(IO.readAll(instanceFile()).trim()); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -37,7 +37,7 @@ public class InstanceState { public static void updateInstanceId() { try { IO.writeAll(instanceFile(), RNG.r.imax() + ""); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } } diff --git a/src/main/java/com/volmit/iris/util/io/JarScanner.java b/src/main/java/com/volmit/iris/util/io/JarScanner.java index 44b146188..395c4a9a9 100644 --- a/src/main/java/com/volmit/iris/util/io/JarScanner.java +++ b/src/main/java/com/volmit/iris/util/io/JarScanner.java @@ -35,7 +35,8 @@ public class JarScanner { /** * Create a scanner * - * @param jar the path to the jar + * @param jar + * the path to the jar */ public JarScanner(File jar, String superPackage) { this.jar = jar; @@ -46,26 +47,27 @@ public class JarScanner { /** * Scan the jar * - * @throws IOException bad things happen + * @throws IOException + * bad things happen */ public void scan() throws IOException { classes.clear(); FileInputStream fin = new FileInputStream(jar); ZipInputStream zip = new ZipInputStream(fin); - for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { - if (!entry.isDirectory() && entry.getName().endsWith(".class")) { - if (entry.getName().contains("$")) { + for(ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { + if(!entry.isDirectory() && entry.getName().endsWith(".class")) { + if(entry.getName().contains("$")) { continue; } String c = entry.getName().replaceAll("/", ".").replace(".class", ""); - if (c.startsWith(superPackage)) { + if(c.startsWith(superPackage)) { try { Class clazz = Class.forName(c); classes.add(clazz); - } catch (ClassNotFoundException e) { + } catch(ClassNotFoundException e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/io/ReactiveFolder.java b/src/main/java/com/volmit/iris/util/io/ReactiveFolder.java index 5f23da5dd..646f06d48 100644 --- a/src/main/java/com/volmit/iris/util/io/ReactiveFolder.java +++ b/src/main/java/com/volmit/iris/util/io/ReactiveFolder.java @@ -44,10 +44,10 @@ public class ReactiveFolder { checkCycle++; boolean modified = false; - if (checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) { - for (File i : fw.getCreated()) { - if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { - if (i.getPath().contains(".iris")) { + if(checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) { + for(File i : fw.getCreated()) { + if(i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { + if(i.getPath().contains(".iris")) { continue; } @@ -56,26 +56,26 @@ public class ReactiveFolder { } } - if (!modified) { - for (File i : fw.getChanged()) { - if (i.getPath().contains(".iris")) { + if(!modified) { + for(File i : fw.getChanged()) { + if(i.getPath().contains(".iris")) { continue; } - if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { + if(i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { modified = true; break; } } } - if (!modified) { - for (File i : fw.getDeleted()) { - if (i.getPath().contains(".iris")) { + if(!modified) { + for(File i : fw.getDeleted()) { + if(i.getPath().contains(".iris")) { continue; } - if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { + if(i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { modified = true; break; } @@ -83,7 +83,7 @@ public class ReactiveFolder { } } - if (modified) { + if(modified) { hotload.accept(fw.getCreated(), fw.getChanged(), fw.getDeleted()); } diff --git a/src/main/java/com/volmit/iris/util/json/HTTP.java b/src/main/java/com/volmit/iris/util/json/HTTP.java index f4ec8ad70..71dd322ab 100644 --- a/src/main/java/com/volmit/iris/util/json/HTTP.java +++ b/src/main/java/com/volmit/iris/util/json/HTTP.java @@ -78,7 +78,8 @@ public class HTTP { * It does no further checking or conversion. It does not parse dates. It * does not do '%' transforms on URLs. * - * @param string An HTTP header string. + * @param string + * An HTTP header string. * @return A JSONObject containing the elements and attributes of the XML * string. */ @@ -88,7 +89,7 @@ public class HTTP { String token; token = x.nextToken(); - if (token.toUpperCase().startsWith("HTTP")) { + if(token.toUpperCase().startsWith("HTTP")) { // Response @@ -108,7 +109,7 @@ public class HTTP { // Fields - while (x.more()) { + while(x.more()) { String name = x.nextTo(':'); x.next(':'); jo.put(name, x.nextTo('\0')); @@ -141,21 +142,23 @@ public class HTTP { * Any other members of the JSONObject will be output as HTTP fields. The * result will end with two CRLF pairs. * - * @param jo A JSONObject + * @param jo + * A JSONObject * @return An HTTP header string. - * @throws JSONException if the object does not contain enough information. + * @throws JSONException + * if the object does not contain enough information. */ public static String toString(JSONObject jo) throws JSONException { Iterator keys = jo.keys(); String string; StringBuilder sb = new StringBuilder(); - if (jo.has("Status-Code") && jo.has("Reason-Phrase")) { + if(jo.has("Status-Code") && jo.has("Reason-Phrase")) { sb.append(jo.getString("HTTP-Version")); sb.append(' '); sb.append(jo.getString("Status-Code")); sb.append(' '); sb.append(jo.getString("Reason-Phrase")); - } else if (jo.has("Method") && jo.has("Request-URI")) { + } else if(jo.has("Method") && jo.has("Request-URI")) { sb.append(jo.getString("Method")); sb.append(' '); sb.append('"'); @@ -167,9 +170,9 @@ public class HTTP { throw new JSONException("Not enough material for an HTTP header."); } sb.append(CRLF); - while (keys.hasNext()) { + while(keys.hasNext()) { string = keys.next(); - if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) && !"Reason-Phrase".equals(string) && !"Method".equals(string) && !"Request-URI".equals(string) && !jo.isNull(string)) { + if(!"HTTP-Version".equals(string) && !"Status-Code".equals(string) && !"Reason-Phrase".equals(string) && !"Method".equals(string) && !"Request-URI".equals(string) && !jo.isNull(string)) { sb.append(string); sb.append(": "); sb.append(jo.getString(string)); diff --git a/src/main/java/com/volmit/iris/util/json/HTTPTokener.java b/src/main/java/com/volmit/iris/util/json/HTTPTokener.java index 8f140893b..3ecc1a3cb 100644 --- a/src/main/java/com/volmit/iris/util/json/HTTPTokener.java +++ b/src/main/java/com/volmit/iris/util/json/HTTPTokener.java @@ -31,7 +31,8 @@ public class HTTPTokener extends JSONTokener { /** * Construct an HTTPTokener from a string. * - * @param string A source string. + * @param string + * A source string. */ public HTTPTokener(String string) { super(string); @@ -48,22 +49,22 @@ public class HTTPTokener extends JSONTokener { StringBuilder sb = new StringBuilder(); do { c = next(); - } while (Character.isWhitespace(c)); - if (c == '"' || c == '\'') { + } while(Character.isWhitespace(c)); + if(c == '"' || c == '\'') { q = c; - for (; ; ) { + for(; ; ) { c = next(); - if (c < ' ') { + if(c < ' ') { throw syntaxError("Unterminated string."); } - if (c == q) { + if(c == q) { return sb.toString(); } sb.append(c); } } - for (; ; ) { - if (c == 0 || Character.isWhitespace(c)) { + for(; ; ) { + if(c == 0 || Character.isWhitespace(c)) { return sb.toString(); } sb.append(c); diff --git a/src/main/java/com/volmit/iris/util/json/JSONArray.java b/src/main/java/com/volmit/iris/util/json/JSONArray.java index 170f9c547..42a08de11 100644 --- a/src/main/java/com/volmit/iris/util/json/JSONArray.java +++ b/src/main/java/com/volmit/iris/util/json/JSONArray.java @@ -94,27 +94,29 @@ public class JSONArray implements Iterable { /** * Construct a JSONArray from a JSONTokener. * - * @param x A JSONTokener - * @throws JSONException If there is a syntax error. + * @param x + * A JSONTokener + * @throws JSONException + * If there is a syntax error. */ public JSONArray(JSONTokener x) throws JSONException { this(); - if (x.nextClean() != '[') { + if(x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); } - if (x.nextClean() != ']') { + if(x.nextClean() != ']') { x.back(); - for (; ; ) { - if (x.nextClean() == ',') { + for(; ; ) { + if(x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); } else { x.back(); this.myArrayList.add(x.nextValue()); } - switch (x.nextClean()) { + switch(x.nextClean()) { case ',': - if (x.nextClean() == ']') { + if(x.nextClean() == ']') { return; } x.back(); @@ -131,10 +133,12 @@ public class JSONArray implements Iterable { /** * Construct a JSONArray from a source JSON text. * - * @param source A string that begins with [ (left - * bracket) and ends with ]   - * (right bracket). - * @throws JSONException If there is a syntax error. + * @param source + * A string that begins with [ (left + * bracket) and ends with ]   + * (right bracket). + * @throws JSONException + * If there is a syntax error. */ public JSONArray(String source) throws JSONException { this(new JSONTokener(source)); @@ -143,13 +147,14 @@ public class JSONArray implements Iterable { /** * Construct a JSONArray from a Collection. * - * @param collection A Collection. + * @param collection + * A Collection. */ public JSONArray(Collection collection) { this.myArrayList = new ArrayList(); - if (collection != null) { + if(collection != null) { Iterator iter = collection.iterator(); - while (iter.hasNext()) { + while(iter.hasNext()) { this.myArrayList.add(JSONObject.wrap(iter.next())); } } @@ -158,13 +163,14 @@ public class JSONArray implements Iterable { /** * Construct a JSONArray from an array * - * @throws JSONException If not an array. + * @throws JSONException + * If not an array. */ public JSONArray(Object array) throws JSONException { this(); - if (array.getClass().isArray()) { + if(array.getClass().isArray()) { int length = Array.getLength(array); - for (int i = 0; i < length; i += 1) { + for(int i = 0; i < length; i += 1) { this.put(JSONObject.wrap(Array.get(array, i))); } } else { @@ -180,13 +186,15 @@ public class JSONArray implements Iterable { /** * Get the object value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return An object value. - * @throws JSONException If there is no value for the index. + * @throws JSONException + * If there is no value for the index. */ public Object get(int index) throws JSONException { Object object = this.opt(index); - if (object == null) { + if(object == null) { throw new JSONException("JSONArray[" + index + "] not found."); } return object; @@ -196,16 +204,18 @@ public class JSONArray implements Iterable { * Get the boolean value associated with an index. The string values "true" * and "false" are converted to boolean. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The truth. - * @throws JSONException If there is no value for the index or if the value is not - * convertible to boolean. + * @throws JSONException + * If there is no value for the index or if the value is not + * convertible to boolean. */ public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); - if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object).equalsIgnoreCase("false"))) { + if(object.equals(Boolean.FALSE) || (object instanceof String && ((String) object).equalsIgnoreCase("false"))) { return false; - } else if (object.equals(Boolean.TRUE) || (object instanceof String && ((String) object).equalsIgnoreCase("true"))) { + } else if(object.equals(Boolean.TRUE) || (object instanceof String && ((String) object).equalsIgnoreCase("true"))) { return true; } throw new JSONException("JSONArray[" + index + "] is not a boolean."); @@ -214,16 +224,18 @@ public class JSONArray implements Iterable { /** * Get the double value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. - * @throws JSONException If the key is not found or if the value cannot be converted - * to a number. + * @throws JSONException + * If the key is not found or if the value cannot be converted + * to a number. */ public double getDouble(int index) throws JSONException { Object object = this.get(index); try { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONArray[" + index + "] is not a number."); } @@ -232,15 +244,18 @@ public class JSONArray implements Iterable { /** * Get the enum value associated with an index. * - * @param clazz The type of enum to retrieve. - * @param index The index must be between 0 and length() - 1. + * @param clazz + * The type of enum to retrieve. + * @param index + * The index must be between 0 and length() - 1. * @return The enum value at the index location - * @throws JSONException if the key is not found or if the value cannot be converted - * to an enum. + * @throws JSONException + * if the key is not found or if the value cannot be converted + * to an enum. */ public > E getEnum(Class clazz, int index) throws JSONException { E val = optEnum(clazz, index); - if (val == null) { + if(val == null) { // JSONException should really take a throwable argument. // If it did, I would re-implement this with the Enum.valueOf // method and place any thrown exception in the JSONException @@ -252,16 +267,18 @@ public class JSONArray implements Iterable { /** * Get the BigDecimal value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. - * @throws JSONException If the key is not found or if the value cannot be converted - * to a BigDecimal. + * @throws JSONException + * If the key is not found or if the value cannot be converted + * to a BigDecimal. */ public BigDecimal getBigDecimal(int index) throws JSONException { Object object = this.get(index); try { return new BigDecimal(object.toString()); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONArray[" + index + "] could not convert to BigDecimal."); } @@ -270,16 +287,18 @@ public class JSONArray implements Iterable { /** * Get the BigInteger value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. - * @throws JSONException If the key is not found or if the value cannot be converted - * to a BigInteger. + * @throws JSONException + * If the key is not found or if the value cannot be converted + * to a BigInteger. */ public BigInteger getBigInteger(int index) throws JSONException { Object object = this.get(index); try { return new BigInteger(object.toString()); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONArray[" + index + "] could not convert to BigInteger."); } @@ -288,15 +307,17 @@ public class JSONArray implements Iterable { /** * Get the int value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. - * @throws JSONException If the key is not found or if the value is not a number. + * @throws JSONException + * If the key is not found or if the value is not a number. */ public int getInt(int index) throws JSONException { Object object = this.get(index); try { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONArray[" + index + "] is not a number."); } @@ -305,14 +326,16 @@ public class JSONArray implements Iterable { /** * Get the JSONArray associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return A JSONArray value. - * @throws JSONException If there is no value for the index. or if the value is not a - * JSONArray + * @throws JSONException + * If there is no value for the index. or if the value is not a + * JSONArray */ public JSONArray getJSONArray(int index) throws JSONException { Object object = this.get(index); - if (object instanceof JSONArray) { + if(object instanceof JSONArray) { return (JSONArray) object; } throw new JSONException("JSONArray[" + index + "] is not a JSONArray."); @@ -321,14 +344,16 @@ public class JSONArray implements Iterable { /** * Get the JSONObject associated with an index. * - * @param index subscript + * @param index + * subscript * @return A JSONObject value. - * @throws JSONException If there is no value for the index or if the value is not a - * JSONObject + * @throws JSONException + * If there is no value for the index or if the value is not a + * JSONObject */ public JSONObject getJSONObject(int index) throws JSONException { Object object = this.get(index); - if (object instanceof JSONObject) { + if(object instanceof JSONObject) { return (JSONObject) object; } throw new JSONException("JSONArray[" + index + "] is not a JSONObject."); @@ -337,16 +362,18 @@ public class JSONArray implements Iterable { /** * Get the long value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. - * @throws JSONException If the key is not found or if the value cannot be converted - * to a number. + * @throws JSONException + * If the key is not found or if the value cannot be converted + * to a number. */ public long getLong(int index) throws JSONException { Object object = this.get(index); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONArray[" + index + "] is not a number."); } @@ -355,13 +382,15 @@ public class JSONArray implements Iterable { /** * Get the string associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return A string value. - * @throws JSONException If there is no string value for the index. + * @throws JSONException + * If there is no string value for the index. */ public String getString(int index) throws JSONException { Object object = this.get(index); - if (object instanceof String) { + if(object instanceof String) { return (String) object; } throw new JSONException("JSONArray[" + index + "] not a string."); @@ -370,7 +399,8 @@ public class JSONArray implements Iterable { /** * Determine if the value is null. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return true if the value at the index is null, or if there is no value. */ public boolean isNull(int index) { @@ -382,16 +412,18 @@ public class JSONArray implements Iterable { * separator string is inserted between each element. Warning: * This method assumes that the data structure is acyclical. * - * @param separator A string that will be inserted between the elements. + * @param separator + * A string that will be inserted between the elements. * @return a string. - * @throws JSONException If the array contains an invalid number. + * @throws JSONException + * If the array contains an invalid number. */ public String join(String separator) throws JSONException { int len = this.length(); StringBuilder sb = new StringBuilder(); - for (int i = 0; i < len; i += 1) { - if (i > 0) { + for(int i = 0; i < len; i += 1) { + if(i > 0) { sb.append(separator); } sb.append(JSONObject.valueToString(this.myArrayList.get(i))); @@ -411,7 +443,8 @@ public class JSONArray implements Iterable { /** * Get the optional object value associated with an index. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return An object value, or null if there is no object at that index. */ public Object opt(int index) { @@ -423,7 +456,8 @@ public class JSONArray implements Iterable { * if there is no value at that index, or if the value is not Boolean.TRUE * or the String "true". * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The truth. */ public boolean optBoolean(int index) { @@ -435,14 +469,16 @@ public class JSONArray implements Iterable { * defaultValue if there is no value at that index or if it is not a Boolean * or the String "true" or "false" (case insensitive). * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue A boolean default. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * A boolean default. * @return The truth. */ public boolean optBoolean(int index, boolean defaultValue) { try { return this.getBoolean(index); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -453,7 +489,8 @@ public class JSONArray implements Iterable { * if there is no value for the index, or if the value is not a number and * cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. */ public double optDouble(int index) { @@ -465,14 +502,16 @@ public class JSONArray implements Iterable { * is returned if there is no value for the index, or if the value is not a * number and cannot be converted to a number. * - * @param index subscript - * @param defaultValue The default value. + * @param index + * subscript + * @param defaultValue + * The default value. * @return The value. */ public double optDouble(int index, double defaultValue) { try { return this.getDouble(index); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -483,7 +522,8 @@ public class JSONArray implements Iterable { * there is no value for the index, or if the value is not a number and * cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. */ public int optInt(int index) { @@ -495,14 +535,16 @@ public class JSONArray implements Iterable { * returned if there is no value for the index, or if the value is not a * number and cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * The default value. * @return The value. */ public int optInt(int index, int defaultValue) { try { return this.getInt(index); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -511,8 +553,10 @@ public class JSONArray implements Iterable { /** * Get the enum value associated with a key. * - * @param clazz The type of enum to retrieve. - * @param index The index must be between 0 and length() - 1. + * @param clazz + * The type of enum to retrieve. + * @param index + * The index must be between 0 and length() - 1. * @return The enum value at the index location or null if not found */ public > E optEnum(Class clazz, int index) { @@ -522,29 +566,32 @@ public class JSONArray implements Iterable { /** * Get the enum value associated with a key. * - * @param clazz The type of enum to retrieve. - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default in case the value is not found + * @param clazz + * The type of enum to retrieve. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * The default in case the value is not found * @return The enum value at the index location or defaultValue if the value * is not found or cannot be assigned to clazz */ public > E optEnum(Class clazz, int index, E defaultValue) { try { Object val = this.opt(index); - if (JSONObject.NULL.equals(val)) { + if(JSONObject.NULL.equals(val)) { return defaultValue; } - if (clazz.isAssignableFrom(val.getClass())) { + if(clazz.isAssignableFrom(val.getClass())) { // we just checked it! @SuppressWarnings("unchecked") E myE = (E) val; return myE; } return Enum.valueOf(clazz, val.toString()); - } catch (IllegalArgumentException e) { + } catch(IllegalArgumentException e) { Iris.reportError(e); return defaultValue; - } catch (NullPointerException e) { + } catch(NullPointerException e) { Iris.reportError(e); return defaultValue; } @@ -555,14 +602,16 @@ public class JSONArray implements Iterable { * defaultValue is returned if there is no value for the index, or if the * value is not a number and cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * The default value. * @return The value. */ public BigInteger optBigInteger(int index, BigInteger defaultValue) { try { return this.getBigInteger(index); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -573,14 +622,16 @@ public class JSONArray implements Iterable { * defaultValue is returned if there is no value for the index, or if the * value is not a number and cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * The default value. * @return The value. */ public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) { try { return this.getBigDecimal(index); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -589,7 +640,8 @@ public class JSONArray implements Iterable { /** * Get the optional JSONArray associated with an index. * - * @param index subscript + * @param index + * subscript * @return A JSONArray value, or null if the index has no value, or if the * value is not a JSONArray. */ @@ -603,7 +655,8 @@ public class JSONArray implements Iterable { * the key is not found, or null if the index has no value, or if the value * is not a JSONObject. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return A JSONObject value. */ public JSONObject optJSONObject(int index) { @@ -616,7 +669,8 @@ public class JSONArray implements Iterable { * there is no value for the index, or if the value is not a number and * cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return The value. */ public long optLong(int index) { @@ -628,14 +682,16 @@ public class JSONArray implements Iterable { * returned if there is no value for the index, or if the value is not a * number and cannot be converted to a number. * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * The default value. * @return The value. */ public long optLong(int index, long defaultValue) { try { return this.getLong(index); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -646,7 +702,8 @@ public class JSONArray implements Iterable { * empty string if there is no value at that index. If the value is not a * string and is not null, then it is coverted to a string. * - * @param index The index must be between 0 and length() - 1. + * @param index + * The index must be between 0 and length() - 1. * @return A String value. */ public String optString(int index) { @@ -657,8 +714,10 @@ public class JSONArray implements Iterable { * Get the optional string associated with an index. The defaultValue is * returned if the key is not found. * - * @param index The index must be between 0 and length() - 1. - * @param defaultValue The default value. + * @param index + * The index must be between 0 and length() - 1. + * @param defaultValue + * The default value. * @return A String value. */ public String optString(int index, String defaultValue) { @@ -669,7 +728,8 @@ public class JSONArray implements Iterable { /** * Append a boolean value. This increases the array's length by one. * - * @param value A boolean value. + * @param value + * A boolean value. * @return this. */ public JSONArray put(boolean value) { @@ -681,7 +741,8 @@ public class JSONArray implements Iterable { * Put a value in the JSONArray, where the value will be a JSONArray which * is produced from a Collection. * - * @param value A Collection value. + * @param value + * A Collection value. * @return this. */ public JSONArray put(Collection value) { @@ -692,9 +753,11 @@ public class JSONArray implements Iterable { /** * Append a double value. This increases the array's length by one. * - * @param value A double value. + * @param value + * A double value. * @return this. - * @throws JSONException if the value is not finite. + * @throws JSONException + * if the value is not finite. */ public JSONArray put(double value) throws JSONException { Double d = Double.valueOf(value); @@ -706,7 +769,8 @@ public class JSONArray implements Iterable { /** * Append an int value. This increases the array's length by one. * - * @param value An int value. + * @param value + * An int value. * @return this. */ public JSONArray put(int value) { @@ -717,7 +781,8 @@ public class JSONArray implements Iterable { /** * Append an long value. This increases the array's length by one. * - * @param value A long value. + * @param value + * A long value. * @return this. */ public JSONArray put(long value) { @@ -729,7 +794,8 @@ public class JSONArray implements Iterable { * Put a value in the JSONArray, where the value will be a JSONObject which * is produced from a Map. * - * @param value A Map value. + * @param value + * A Map value. * @return this. */ public JSONArray put(Map value) { @@ -740,9 +806,10 @@ public class JSONArray implements Iterable { /** * Append an object value. This increases the array's length by one. * - * @param value An object value. The value should be a Boolean, Double, - * Integer, JSONArray, JSONObject, Long, or String, or the - * JSONObject.NULL object. + * @param value + * An object value. The value should be a Boolean, Double, + * Integer, JSONArray, JSONObject, Long, or String, or the + * JSONObject.NULL object. * @return this. */ public JSONArray put(Object value) { @@ -755,10 +822,13 @@ public class JSONArray implements Iterable { * than the length of the JSONArray, then null elements will be added as * necessary to pad it out. * - * @param index The subscript. - * @param value A boolean value. + * @param index + * The subscript. + * @param value + * A boolean value. * @return this. - * @throws JSONException If the index is negative. + * @throws JSONException + * If the index is negative. */ public JSONArray put(int index, boolean value) throws JSONException { this.put(index, value ? Boolean.TRUE : Boolean.FALSE); @@ -769,10 +839,13 @@ public class JSONArray implements Iterable { * Put a value in the JSONArray, where the value will be a JSONArray which * is produced from a Collection. * - * @param index The subscript. - * @param value A Collection value. + * @param index + * The subscript. + * @param value + * A Collection value. * @return this. - * @throws JSONException If the index is negative or if the value is not finite. + * @throws JSONException + * If the index is negative or if the value is not finite. */ public JSONArray put(int index, Collection value) throws JSONException { this.put(index, new JSONArray(value)); @@ -784,10 +857,13 @@ public class JSONArray implements Iterable { * the JSONArray, then null elements will be added as necessary to pad it * out. * - * @param index The subscript. - * @param value A double value. + * @param index + * The subscript. + * @param value + * A double value. * @return this. - * @throws JSONException If the index is negative or if the value is not finite. + * @throws JSONException + * If the index is negative or if the value is not finite. */ public JSONArray put(int index, double value) throws JSONException { this.put(index, Double.valueOf(value)); @@ -799,10 +875,13 @@ public class JSONArray implements Iterable { * the JSONArray, then null elements will be added as necessary to pad it * out. * - * @param index The subscript. - * @param value An int value. + * @param index + * The subscript. + * @param value + * An int value. * @return this. - * @throws JSONException If the index is negative. + * @throws JSONException + * If the index is negative. */ public JSONArray put(int index, int value) throws JSONException { this.put(index, Integer.valueOf(value)); @@ -814,10 +893,13 @@ public class JSONArray implements Iterable { * the JSONArray, then null elements will be added as necessary to pad it * out. * - * @param index The subscript. - * @param value A long value. + * @param index + * The subscript. + * @param value + * A long value. * @return this. - * @throws JSONException If the index is negative. + * @throws JSONException + * If the index is negative. */ public JSONArray put(int index, long value) throws JSONException { this.put(index, Long.valueOf(value)); @@ -828,11 +910,14 @@ public class JSONArray implements Iterable { * Put a value in the JSONArray, where the value will be a JSONObject that * is produced from a Map. * - * @param index The subscript. - * @param value The Map value. + * @param index + * The subscript. + * @param value + * The Map value. * @return this. - * @throws JSONException If the index is negative or if the the value is an invalid - * number. + * @throws JSONException + * If the index is negative or if the the value is an invalid + * number. */ public JSONArray put(int index, Map value) throws JSONException { this.put(index, new JSONObject(value)); @@ -844,23 +929,26 @@ public class JSONArray implements Iterable { * than the length of the JSONArray, then null elements will be added as * necessary to pad it out. * - * @param index The subscript. - * @param value The value to put into the array. The value should be a - * Boolean, Double, Integer, JSONArray, JSONObject, Long, or - * String, or the JSONObject.NULL object. + * @param index + * The subscript. + * @param value + * The value to put into the array. The value should be a + * Boolean, Double, Integer, JSONArray, JSONObject, Long, or + * String, or the JSONObject.NULL object. * @return this. - * @throws JSONException If the index is negative or if the the value is an invalid - * number. + * @throws JSONException + * If the index is negative or if the the value is an invalid + * number. */ public JSONArray put(int index, Object value) throws JSONException { JSONObject.testValidity(value); - if (index < 0) { + if(index < 0) { throw new JSONException("JSONArray[" + index + "] not found."); } - if (index < this.length()) { + if(index < this.length()) { this.myArrayList.set(index, value); } else { - while (index != this.length()) { + while(index != this.length()) { this.put(JSONObject.NULL); } this.put(value); @@ -871,7 +959,8 @@ public class JSONArray implements Iterable { /** * Remove an index and close the hole. * - * @param index The index of the element to be removed. + * @param index + * The index of the element to be removed. * @return The value that was associated with the index, or null if there * was no value. */ @@ -883,30 +972,31 @@ public class JSONArray implements Iterable { * Determine if two JSONArrays are similar. They must contain similar * sequences. * - * @param other The other JSONArray + * @param other + * The other JSONArray * @return true if they are equal */ @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean similar(Object other) { - if (!(other instanceof JSONArray)) { + if(!(other instanceof JSONArray)) { return false; } int len = this.length(); - if (len != ((JSONArray) other).length()) { + if(len != ((JSONArray) other).length()) { return false; } - for (int i = 0; i < len; i += 1) { + for(int i = 0; i < len; i += 1) { Object valueThis = this.get(i); Object valueOther = ((JSONArray) other).get(i); - if (valueThis instanceof JSONObject) { - if (!((JSONObject) valueThis).similar(valueOther)) { + if(valueThis instanceof JSONObject) { + if(!((JSONObject) valueThis).similar(valueOther)) { return false; } - } else if (valueThis instanceof JSONArray) { - if (!((JSONArray) valueThis).similar(valueOther)) { + } else if(valueThis instanceof JSONArray) { + if(!((JSONArray) valueThis).similar(valueOther)) { return false; } - } else if (!valueThis.equals(valueOther)) { + } else if(!valueThis.equals(valueOther)) { return false; } } @@ -917,18 +1007,20 @@ public class JSONArray implements Iterable { * Produce a JSONObject by combining a JSONArray of names with the values of * this JSONArray. * - * @param names A JSONArray containing a list of key strings. These will be - * paired with the values. + * @param names + * A JSONArray containing a list of key strings. These will be + * paired with the values. * @return A JSONObject, or null if there are no names or if this JSONArray * has no values. - * @throws JSONException If any of the names are null. + * @throws JSONException + * If any of the names are null. */ public JSONObject toJSONObject(JSONArray names) throws JSONException { - if (names == null || names.length() == 0 || this.length() == 0) { + if(names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); - for (int i = 0; i < names.length(); i += 1) { + for(int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this.opt(i)); } return jo; @@ -949,7 +1041,7 @@ public class JSONArray implements Iterable { public String toString() { try { return this.toString(0); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return null; } @@ -959,16 +1051,16 @@ public class JSONArray implements Iterable { * Make a prettyprinted JSON text of this JSONArray. Warning: This method * assumes that the data structure is acyclical. * - * @param indentFactor The number of spaces to add to each level of indentation. + * @param indentFactor + * The number of spaces to add to each level of indentation. * @return a printable, displayable, transmittable representation of the * object, beginning with [ (left * bracket) and ending with ]   * (right bracket). - * @throws JSONException */ public String toString(int indentFactor) throws JSONException { StringWriter sw = new StringWriter(); - synchronized (sw.getBuffer()) { + synchronized(sw.getBuffer()) { return this.write(sw, indentFactor, 0).toString(); } } @@ -980,7 +1072,6 @@ public class JSONArray implements Iterable { * Warning: This method assumes that the data structure is acyclical. * * @return The writer. - * @throws JSONException */ public Writer write(Writer writer) throws JSONException { return this.write(writer, 0, 0); @@ -992,10 +1083,11 @@ public class JSONArray implements Iterable { *

* Warning: This method assumes that the data structure is acyclical. * - * @param indentFactor The number of spaces to add to each level of indentation. - * @param indent The indention of the top level. + * @param indentFactor + * The number of spaces to add to each level of indentation. + * @param indent + * The indention of the top level. * @return The writer. - * @throws JSONException */ Writer write(Writer writer, int indentFactor, int indent) throws JSONException { try { @@ -1003,30 +1095,30 @@ public class JSONArray implements Iterable { int length = this.length(); writer.write('['); - if (length == 1) { + if(length == 1) { JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent); - } else if (length != 0) { + } else if(length != 0) { final int newindent = indent + indentFactor; - for (int i = 0; i < length; i += 1) { - if (commanate) { + for(int i = 0; i < length; i += 1) { + if(commanate) { writer.write(','); } - if (indentFactor > 0) { + if(indentFactor > 0) { writer.write('\n'); } JSONObject.indent(writer, newindent); JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, newindent); commanate = true; } - if (indentFactor > 0) { + if(indentFactor > 0) { writer.write('\n'); } JSONObject.indent(writer, indent); } writer.write(']'); return writer; - } catch (IOException e) { + } catch(IOException e) { throw new JSONException(e); } } diff --git a/src/main/java/com/volmit/iris/util/json/JSONException.java b/src/main/java/com/volmit/iris/util/json/JSONException.java index bde53e98c..ac13f0f97 100644 --- a/src/main/java/com/volmit/iris/util/json/JSONException.java +++ b/src/main/java/com/volmit/iris/util/json/JSONException.java @@ -32,7 +32,8 @@ public class JSONException extends RuntimeException { /** * Constructs a JSONException with an explanatory message. * - * @param message Detail about the reason for the exception. + * @param message + * Detail about the reason for the exception. */ public JSONException(String message) { super(message); @@ -41,7 +42,8 @@ public class JSONException extends RuntimeException { /** * Constructs a new JSONException with the specified cause. * - * @param cause The cause. + * @param cause + * The cause. */ public JSONException(Throwable cause) { super(cause.getMessage()); diff --git a/src/main/java/com/volmit/iris/util/json/JSONML.java b/src/main/java/com/volmit/iris/util/json/JSONML.java index 339c0434c..ec84a3020 100644 --- a/src/main/java/com/volmit/iris/util/json/JSONML.java +++ b/src/main/java/com/volmit/iris/util/json/JSONML.java @@ -34,10 +34,13 @@ public class JSONML { /** * Parse XML values and store them in a JSONArray. * - * @param x The XMLTokener containing the source string. - * @param arrayForm true if array form, false if object form. - * @param ja The JSONArray that is containing the current tag or null if we - * are at the outermost level. + * @param x + * The XMLTokener containing the source string. + * @param arrayForm + * true if array form, false if object form. + * @param ja + * The JSONArray that is containing the current tag or null if we + * are at the outermost level. * @return A JSONArray if the value is the outermost tag, otherwise null. */ private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException { @@ -56,41 +59,41 @@ public class JSONML { // // - while (true) { - if (!x.more()) { + while(true) { + if(!x.more()) { throw x.syntaxError("Bad XML"); } token = x.nextContent(); - if (token == XML.LT) { + if(token == XML.LT) { token = x.nextToken(); - if (token instanceof Character) { - if (token == XML.SLASH) { + if(token instanceof Character) { + if(token == XML.SLASH) { // Close tag "); } else { x.back(); } - } else if (c == '[') { + } else if(c == '[') { token = x.nextToken(); - if (token.equals("CDATA") && x.next() == '[') { - if (ja != null) { + if(token.equals("CDATA") && x.next() == '[') { + if(ja != null) { ja.put(x.nextCDATA()); } } else { @@ -100,16 +103,16 @@ public class JSONML { i = 1; do { token = x.nextMeta(); - if (token == null) { + if(token == null) { throw x.syntaxError("Missing '>' after ' 0); + } while(i > 0); } - } else if (token == XML.QUEST) { + } else if(token == XML.QUEST) { // 0) { + if(arrayForm && newjo.length() > 0) { newja.put(newjo); } // Empty tag <.../> - if (token == XML.SLASH) { - if (x.nextToken() != XML.GT) { + if(token == XML.SLASH) { + if(x.nextToken() != XML.GT) { throw x.syntaxError("Misshaped tag"); } - if (ja == null) { - if (arrayForm) { + if(ja == null) { + if(arrayForm) { return newja; } else { return newjo; @@ -189,20 +192,20 @@ public class JSONML { // Content, between <...> and } else { - if (token != XML.GT) { + if(token != XML.GT) { throw x.syntaxError("Misshaped tag"); } closeTag = (String) parse(x, arrayForm, newja); - if (closeTag != null) { - if (!closeTag.equals(tagName)) { + if(closeTag != null) { + if(!closeTag.equals(tagName)) { throw x.syntaxError("Mismatched '" + tagName + "' and '" + closeTag + "'"); } tagName = null; - if (!arrayForm && newja.length() > 0) { + if(!arrayForm && newja.length() > 0) { newjo.put("childNodes", newja); } - if (ja == null) { - if (arrayForm) { + if(ja == null) { + if(arrayForm) { return newja; } else { return newjo; @@ -212,7 +215,7 @@ public class JSONML { } } } else { - if (ja != null) { + if(ja != null) { ja.put(token instanceof String ? XML.stringToValue((String) token) : token); } } @@ -228,7 +231,8 @@ public class JSONML { * JSONArrays will represent the child tags. Comments, prologs, DTDs, and * <[ [ ]]> are ignored. * - * @param string The source string. + * @param string + * The source string. * @return A JSONArray containing the structured data from the XML string. */ public static JSONArray toJSONArray(String string) throws JSONException { @@ -244,7 +248,8 @@ public class JSONML { * JSONArrays will represent the child content and tags. Comments, prologs, * DTDs, and <[ [ ]]> are ignored. * - * @param x An XMLTokener. + * @param x + * An XMLTokener. * @return A JSONArray containing the structured data from the XML string. */ public static JSONArray toJSONArray(XMLTokener x) throws JSONException { @@ -261,7 +266,8 @@ public class JSONML { *

* Comments, prologs, DTDs, and <[ [ ]]> are ignored. * - * @param x An XMLTokener of the XML source text. + * @param x + * An XMLTokener of the XML source text. * @return A JSONObject containing the structured data from the XML string. */ public static JSONObject toJSONObject(XMLTokener x) throws JSONException { @@ -278,7 +284,8 @@ public class JSONML { *

* Comments, prologs, DTDs, and <[ [ ]]> are ignored. * - * @param string The XML source text. + * @param string + * The XML source text. * @return A JSONObject containing the structured data from the XML string. */ public static JSONObject toJSONObject(String string) throws JSONException { @@ -288,7 +295,8 @@ public class JSONML { /** * Reverse the JSONML transformation, making an XML text from a JSONArray. * - * @param ja A JSONArray. + * @param ja + * A JSONArray. * @return An XML string. */ public static String toString(JSONArray ja) throws JSONException { @@ -311,18 +319,18 @@ public class JSONML { sb.append(tagName); object = ja.opt(1); - if (object instanceof JSONObject) { + if(object instanceof JSONObject) { i = 2; jo = (JSONObject) object; // Emit the attributes keys = jo.keys(); - while (keys.hasNext()) { + while(keys.hasNext()) { key = keys.next(); XML.noSpace(key); value = jo.optString(key); - if (value != null) { + if(value != null) { sb.append(' '); sb.append(XML.escape(key)); sb.append('='); @@ -338,25 +346,25 @@ public class JSONML { // Emit content in body length = ja.length(); - if (i >= length) { + if(i >= length) { sb.append('/'); } else { sb.append('>'); do { object = ja.get(i); i += 1; - if (object != null) { - if (object instanceof String) { + if(object != null) { + if(object instanceof String) { sb.append(XML.escape(object.toString())); - } else if (object instanceof JSONObject) { + } else if(object instanceof JSONObject) { sb.append(toString((JSONObject) object)); - } else if (object instanceof JSONArray) { + } else if(object instanceof JSONArray) { sb.append(toString((JSONArray) object)); } else { sb.append(object); } } - } while (i < length); + } while(i < length); sb.append('<'); sb.append('/'); sb.append(tagName); @@ -371,7 +379,8 @@ public class JSONML { * then it must have a "childNodes" property containing an array of objects. * The other properties are attributes with string values. * - * @param jo A JSONObject. + * @param jo + * A JSONObject. * @return An XML string. */ public static String toString(JSONObject jo) throws JSONException { @@ -388,7 +397,7 @@ public class JSONML { // Emit '); length = ja.length(); - for (i = 0; i < length; i += 1) { + for(i = 0; i < length; i += 1) { object = ja.get(i); - if (object != null) { - if (object instanceof String) { + if(object != null) { + if(object instanceof String) { sb.append(XML.escape(object.toString())); - } else if (object instanceof JSONObject) { + } else if(object instanceof JSONObject) { sb.append(toString((JSONObject) object)); - } else if (object instanceof JSONArray) { + } else if(object instanceof JSONArray) { sb.append(toString((JSONArray) object)); } else { sb.append(object); diff --git a/src/main/java/com/volmit/iris/util/json/JSONObject.java b/src/main/java/com/volmit/iris/util/json/JSONObject.java index 87b502b5c..b7cb52a43 100644 --- a/src/main/java/com/volmit/iris/util/json/JSONObject.java +++ b/src/main/java/com/volmit/iris/util/json/JSONObject.java @@ -114,18 +114,20 @@ public class JSONObject { * strings is used to identify the keys that should be copied. Missing keys * are ignored. * - * @param jo A JSONObject. - * @param names An array of strings. + * @param jo + * A JSONObject. + * @param names + * An array of strings. * @throws JSONException - * @throws JSONException If a value is a non-finite number or if a name is - * duplicated. + * If a value is a non-finite number or if a name is + * duplicated. */ public JSONObject(JSONObject jo, String[] names) { this(); - for (int i = 0; i < names.length; i += 1) { + for(int i = 0; i < names.length; i += 1) { try { this.putOnce(names[i], jo.opt(names[i])); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); } } @@ -134,21 +136,23 @@ public class JSONObject { /** * Construct a JSONObject from a JSONTokener. * - * @param x A JSONTokener object containing the source string. - * @throws JSONException If there is a syntax error in the source string or a - * duplicated key. + * @param x + * A JSONTokener object containing the source string. + * @throws JSONException + * If there is a syntax error in the source string or a + * duplicated key. */ public JSONObject(JSONTokener x) throws JSONException { this(); char c; String key; - if (x.nextClean() != '{') { + if(x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); } - for (; ; ) { + for(; ; ) { c = x.nextClean(); - switch (c) { + switch(c) { case 0: throw x.syntaxError("A JSONObject text must end with '}'"); case '}': @@ -161,17 +165,17 @@ public class JSONObject { // The key is followed by ':'. c = x.nextClean(); - if (c != ':') { + if(c != ':') { throw x.syntaxError("Expected a ':' after a key"); } this.putOnce(key, x.nextValue()); // Pairs are separated by ','. - switch (x.nextClean()) { + switch(x.nextClean()) { case ';': case ',': - if (x.nextClean() == '}') { + if(x.nextClean() == '}') { return; } x.back(); @@ -187,18 +191,18 @@ public class JSONObject { /** * Construct a JSONObject from a Map. * - * @param map A map object that can be used to initialize the contents of - * the JSONObject. - * @throws JSONException + * @param map + * A map object that can be used to initialize the contents of + * the JSONObject. */ public JSONObject(Map map) { this.map = new LinkedHashMap<>(); - if (map != null) { + if(map != null) { Iterator> i = map.entrySet().iterator(); - while (i.hasNext()) { + while(i.hasNext()) { Entry entry = i.next(); Object value = entry.getValue(); - if (value != null) { + if(value != null) { this.map.put(entry.getKey(), wrap(value)); } } @@ -222,8 +226,9 @@ public class JSONObject { * "Larry Fine", then the JSONObject will contain * "name": "Larry Fine". * - * @param bean An object that has getter methods that should be used to make - * a JSONObject. + * @param bean + * An object that has getter methods that should be used to make + * a JSONObject. */ public JSONObject(Object bean) { this(); @@ -237,19 +242,21 @@ public class JSONObject { * those keys in the object. If a key is not found or not visible, then it * will not be copied into the new JSONObject. * - * @param object An object that has fields that should be used to make a - * JSONObject. - * @param names An array of strings, the names of the fields to be obtained - * from the object. + * @param object + * An object that has fields that should be used to make a + * JSONObject. + * @param names + * An array of strings, the names of the fields to be obtained + * from the object. */ public JSONObject(Object object, String[] names) { this(); Class c = object.getClass(); - for (int i = 0; i < names.length; i += 1) { + for(int i = 0; i < names.length; i += 1) { String name = names[i]; try { this.putOpt(name, c.getField(name).get(object)); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); } } @@ -259,11 +266,13 @@ public class JSONObject { * Construct a JSONObject from a source JSON text string. This is the most * commonly used JSONObject constructor. * - * @param source A string beginning with { (left - * brace) and ending with }   - * (right brace). - * @throws JSONException If there is a syntax error in the source string or a - * duplicated key. + * @param source + * A string beginning with { (left + * brace) and ending with }   + * (right brace). + * @throws JSONException + * If there is a syntax error in the source string or a + * duplicated key. */ public JSONObject(String source) throws JSONException { this(new JSONTokener(source)); @@ -272,9 +281,12 @@ public class JSONObject { /** * Construct a JSONObject from a ResourceBundle. * - * @param baseName The ResourceBundle base name. - * @param locale The Locale to load the ResourceBundle for. - * @throws JSONException If any JSONExceptions are detected. + * @param baseName + * The ResourceBundle base name. + * @param locale + * The Locale to load the ResourceBundle for. + * @throws JSONException + * If any JSONExceptions are detected. */ public JSONObject(String baseName, Locale locale) throws JSONException { this(); @@ -283,9 +295,9 @@ public class JSONObject { // Iterate through the keys in the bundle. Enumeration keys = bundle.getKeys(); - while (keys.hasMoreElements()) { + while(keys.hasMoreElements()) { Object key = keys.nextElement(); - if (key != null) { + if(key != null) { // Go through the path, ensuring that there is a nested // JSONObject for each @@ -296,10 +308,10 @@ public class JSONObject { String[] path = ((String) key).split("\\."); int last = path.length - 1; JSONObject target = this; - for (int i = 0; i < last; i += 1) { + for(int i = 0; i < last; i += 1) { String segment = path[i]; JSONObject nextTarget = target.optJSONObject(segment); - if (nextTarget == null) { + if(nextTarget == null) { nextTarget = new JSONObject(); target.put(segment, nextTarget); } @@ -314,22 +326,23 @@ public class JSONObject { * Produce a string from a double. The string "null" will be returned if the * number is not finite. * - * @param d A double. + * @param d + * A double. * @return A String. */ public static String doubleToString(double d) { - if (Double.isInfinite(d) || Double.isNaN(d)) { + if(Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); - if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { - while (string.endsWith("0")) { + if(string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { + while(string.endsWith("0")) { string = string.substring(0, string.length() - 1); } - if (string.endsWith(".")) { + if(string.endsWith(".")) { string = string.substring(0, string.length() - 1); } } @@ -343,13 +356,13 @@ public class JSONObject { */ public static String[] getNames(JSONObject jo) { int length = jo.length(); - if (length == 0) { + if(length == 0) { return null; } Iterator iterator = jo.keys(); String[] names = new String[length]; int i = 0; - while (iterator.hasNext()) { + while(iterator.hasNext()) { names[i] = iterator.next(); i += 1; } @@ -362,17 +375,17 @@ public class JSONObject { * @return An array of field names, or null if there are no names. */ public static String[] getNames(Object object) { - if (object == null) { + if(object == null) { return null; } Class klass = object.getClass(); Field[] fields = klass.getFields(); int length = fields.length; - if (length == 0) { + if(length == 0) { return null; } String[] names = new String[length]; - for (int i = 0; i < length; i += 1) { + for(int i = 0; i < length; i += 1) { names[i] = fields[i].getName(); } return names; @@ -381,12 +394,14 @@ public class JSONObject { /** * Produce a string from a Number. * - * @param number A Number + * @param number + * A Number * @return A String. - * @throws JSONException If n is a non-finite number. + * @throws JSONException + * If n is a non-finite number. */ public static String numberToString(Number number) throws JSONException { - if (number == null) { + if(number == null) { throw new JSONException("Null pointer"); } testValidity(number); @@ -394,11 +409,11 @@ public class JSONObject { // Shave off trailing zeros and decimal point, if possible. String string = number.toString(); - if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { - while (string.endsWith("0")) { + if(string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { + while(string.endsWith("0")) { string = string.substring(0, string.length() - 1); } - if (string.endsWith(".")) { + if(string.endsWith(".")) { string = string.substring(0, string.length() - 1); } } @@ -411,15 +426,16 @@ public class JSONObject { * allowing JSON text to be delivered in HTML. In JSON text, a string cannot * contain a control character or an unescaped quote or backslash. * - * @param string A String + * @param string + * A String * @return A String correctly formatted for insertion in a JSON text. */ public static String quote(String string) { StringWriter sw = new StringWriter(); - synchronized (sw.getBuffer()) { + synchronized(sw.getBuffer()) { try { return quote(string, sw).toString(); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); // will never happen - we are writing to a string writer return ""; @@ -428,7 +444,7 @@ public class JSONObject { } public static Writer quote(String string, Writer w) throws IOException { - if (string == null || string.length() == 0) { + if(string == null || string.length() == 0) { w.write("\"\""); return w; } @@ -440,17 +456,17 @@ public class JSONObject { int len = string.length(); w.write('"'); - for (i = 0; i < len; i += 1) { + for(i = 0; i < len; i += 1) { b = c; c = string.charAt(i); - switch (c) { + switch(c) { case '\\': case '"': w.write('\\'); w.write(c); break; case '/': - if (b == '<') { + if(b == '<') { w.write('\\'); } w.write(c); @@ -471,7 +487,7 @@ public class JSONObject { w.write("\\r"); break; default: - if (c < ' ' || (c >= '\u0080' && c < '\u00a0') || (c >= '\u2000' && c < '\u2100')) { + if(c < ' ' || (c >= '\u0080' && c < '\u00a0') || (c >= '\u2000' && c < '\u2100')) { w.write("\\u"); hhhh = Integer.toHexString(c); w.write("0000", 0, 4 - hhhh.length()); @@ -489,21 +505,22 @@ public class JSONObject { * Try to convert a string into a number, boolean, or null. If the string * can't be converted, return the string. * - * @param string A String. + * @param string + * A String. * @return A simple JSON value. */ public static Object stringToValue(String string) { Double d; - if (string.equals("")) { + if(string.equals("")) { return string; } - if (string.equalsIgnoreCase("true")) { + if(string.equalsIgnoreCase("true")) { return Boolean.TRUE; } - if (string.equalsIgnoreCase("false")) { + if(string.equalsIgnoreCase("false")) { return Boolean.FALSE; } - if (string.equalsIgnoreCase("null")) { + if(string.equalsIgnoreCase("null")) { return JSONObject.NULL; } @@ -513,24 +530,24 @@ public class JSONObject { */ char b = string.charAt(0); - if ((b >= '0' && b <= '9') || b == '-') { + if((b >= '0' && b <= '9') || b == '-') { try { - if (string.indexOf('.') > -1 || string.indexOf('e') > -1 || string.indexOf('E') > -1) { + if(string.indexOf('.') > -1 || string.indexOf('e') > -1 || string.indexOf('E') > -1) { d = Double.valueOf(string); - if (!d.isInfinite() && !d.isNaN()) { + if(!d.isInfinite() && !d.isNaN()) { return d; } } else { Long myLong = Long.valueOf(string); - if (string.equals(myLong.toString())) { - if (myLong == myLong.intValue()) { + if(string.equals(myLong.toString())) { + if(myLong == myLong.intValue()) { return myLong.intValue(); } else { return myLong; } } } - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); } } @@ -540,17 +557,19 @@ public class JSONObject { /** * Throw an exception if the object is a NaN or infinite number. * - * @param o The object to test. - * @throws JSONException If o is a non-finite number. + * @param o + * The object to test. + * @throws JSONException + * If o is a non-finite number. */ public static void testValidity(Object o) throws JSONException { - if (o != null) { - if (o instanceof Double) { - if (((Double) o).isInfinite() || ((Double) o).isNaN()) { + if(o != null) { + if(o instanceof Double) { + if(((Double) o).isInfinite() || ((Double) o).isNaN()) { throw new JSONException("JSON does not allow non-finite numbers."); } - } else if (o instanceof Float) { - if (((Float) o).isInfinite() || ((Float) o).isNaN()) { + } else if(o instanceof Float) { + if(((Float) o).isInfinite() || ((Float) o).isNaN()) { throw new JSONException("JSON does not allow non-finite numbers."); } } @@ -572,47 +591,49 @@ public class JSONObject { *

* Warning: This method assumes that the data structure is acyclical. * - * @param value The value to be serialized. + * @param value + * The value to be serialized. * @return a printable, displayable, transmittable representation of the * object, beginning with { (left * brace) and ending with } (right * brace). - * @throws JSONException If the value is or contains an invalid number. + * @throws JSONException + * If the value is or contains an invalid number. */ public static String valueToString(Object value) throws JSONException { - if (value == null || value.equals(null)) { + if(value == null || value.equals(null)) { return "null"; } - if (value instanceof JSONString) { + if(value instanceof JSONString) { Object object; try { object = ((JSONString) value).toJSONString(); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException(e); } - if (object instanceof String) { + if(object instanceof String) { return (String) object; } throw new JSONException("Bad value from toJSONString: " + object); } - if (value instanceof Number) { + if(value instanceof Number) { return numberToString((Number) value); } - if (value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray) { + if(value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray) { return value.toString(); } - if (value instanceof Map) { + if(value instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) value; return new JSONObject(map).toString(); } - if (value instanceof Collection) { + if(value instanceof Collection) { @SuppressWarnings("unchecked") Collection coll = (Collection) value; return new JSONArray(coll).toString(); } - if (value.getClass().isArray()) { + if(value.getClass().isArray()) { return new JSONArray(value).toString(); } return quote(value.toString()); @@ -626,69 +647,70 @@ public class JSONObject { * one of the java packages, turn it into a string. And if it doesn't, try * to wrap it in a JSONObject. If the wrapping fails, then null is returned. * - * @param object The object to wrap + * @param object + * The object to wrap * @return The wrapped value */ public static Object wrap(Object object) { try { - if (object == null) { + if(object == null) { return NULL; } - if (object instanceof JSONObject || object instanceof JSONArray || NULL.equals(object) || object instanceof JSONString || object instanceof Byte || object instanceof Character || object instanceof Short || object instanceof Integer || object instanceof Long || object instanceof Boolean || object instanceof Float || object instanceof Double || object instanceof String || object instanceof BigInteger || object instanceof BigDecimal) { + if(object instanceof JSONObject || object instanceof JSONArray || NULL.equals(object) || object instanceof JSONString || object instanceof Byte || object instanceof Character || object instanceof Short || object instanceof Integer || object instanceof Long || object instanceof Boolean || object instanceof Float || object instanceof Double || object instanceof String || object instanceof BigInteger || object instanceof BigDecimal) { return object; } - if (object instanceof Collection) { + if(object instanceof Collection) { @SuppressWarnings("unchecked") Collection coll = (Collection) object; return new JSONArray(coll); } - if (object.getClass().isArray()) { + if(object.getClass().isArray()) { return new JSONArray(object); } - if (object instanceof Map) { + if(object instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) object; return new JSONObject(map); } Package objectPackage = object.getClass().getPackage(); String objectPackageName = objectPackage != null ? objectPackage.getName() : ""; - if (objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || object.getClass().getClassLoader() == null) { + if(objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || object.getClass().getClassLoader() == null) { return object.toString(); } return new JSONObject(object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return null; } } static final Writer writeValue(Writer writer, Object value, int indentFactor, int indent) throws JSONException, IOException { - if (value == null || value.equals(null)) { + if(value == null || value.equals(null)) { writer.write("null"); - } else if (value instanceof JSONObject) { + } else if(value instanceof JSONObject) { ((JSONObject) value).write(writer, indentFactor, indent); - } else if (value instanceof JSONArray) { + } else if(value instanceof JSONArray) { ((JSONArray) value).write(writer, indentFactor, indent); - } else if (value instanceof Map) { + } else if(value instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) value; new JSONObject(map).write(writer, indentFactor, indent); - } else if (value instanceof Collection) { + } else if(value instanceof Collection) { @SuppressWarnings("unchecked") Collection coll = (Collection) value; new JSONArray(coll).write(writer, indentFactor, indent); - } else if (value.getClass().isArray()) { + } else if(value.getClass().isArray()) { new JSONArray(value).write(writer, indentFactor, indent); - } else if (value instanceof Number) { + } else if(value instanceof Number) { writer.write(numberToString((Number) value)); - } else if (value instanceof Boolean) { + } else if(value instanceof Boolean) { writer.write(value.toString()); - } else if (value instanceof JSONString) { + } else if(value instanceof JSONString) { Object o; try { o = ((JSONString) value).toJSONString(); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException(e); } @@ -700,7 +722,7 @@ public class JSONObject { } static final void indent(Writer writer, int indent) throws IOException { - for (int i = 0; i < indent; i += 1) { + for(int i = 0; i < indent; i += 1) { writer.write(' '); } } @@ -716,17 +738,20 @@ public class JSONObject { * will be the same as using put. But if multiple values are accumulated, * then the result will be like append. * - * @param key A key string. - * @param value An object to be accumulated under the key. + * @param key + * A key string. + * @param value + * An object to be accumulated under the key. * @return this. - * @throws JSONException If the value is an invalid number or if the key is null. + * @throws JSONException + * If the value is an invalid number or if the key is null. */ public JSONObject accumulate(String key, Object value) throws JSONException { testValidity(value); Object object = this.opt(key); - if (object == null) { + if(object == null) { this.put(key, value instanceof JSONArray ? new JSONArray().put(value) : value); - } else if (object instanceof JSONArray) { + } else if(object instanceof JSONArray) { ((JSONArray) object).put(value); } else { this.put(key, new JSONArray().put(object).put(value)); @@ -740,18 +765,21 @@ public class JSONObject { * JSONArray containing the value parameter. If the key was already * associated with a JSONArray, then the value parameter is appended to it. * - * @param key A key string. - * @param value An object to be accumulated under the key. + * @param key + * A key string. + * @param value + * An object to be accumulated under the key. * @return this. - * @throws JSONException If the key is null or if the current value associated with - * the key is not a JSONArray. + * @throws JSONException + * If the key is null or if the current value associated with + * the key is not a JSONArray. */ public JSONObject append(String key, Object value) throws JSONException { testValidity(value); Object object = this.opt(key); - if (object == null) { + if(object == null) { this.put(key, new JSONArray().put(value)); - } else if (object instanceof JSONArray) { + } else if(object instanceof JSONArray) { this.put(key, ((JSONArray) object).put(value)); } else { throw new JSONException("JSONObject[" + key + "] is not a JSONArray."); @@ -762,16 +790,18 @@ public class JSONObject { /** * Get the value object associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The object associated with the key. - * @throws JSONException if the key is not found. + * @throws JSONException + * if the key is not found. */ public Object get(String key) throws JSONException { - if (key == null) { + if(key == null) { throw new JSONException("Null key."); } Object object = this.opt(key); - if (object == null) { + if(object == null) { throw new JSONException("JSONObject[" + quote(key) + "] not found."); } return object; @@ -780,15 +810,18 @@ public class JSONObject { /** * Get the enum value associated with a key. * - * @param clazz The type of enum to retrieve. - * @param key A key string. + * @param clazz + * The type of enum to retrieve. + * @param key + * A key string. * @return The enum value associated with the key - * @throws JSONException if the key is not found or if the value cannot be converted - * to an enum. + * @throws JSONException + * if the key is not found or if the value cannot be converted + * to an enum. */ public > E getEnum(Class clazz, String key) throws JSONException { E val = optEnum(clazz, key); - if (val == null) { + if(val == null) { // JSONException should really take a throwable argument. // If it did, I would re-implement this with the Enum.valueOf // method and place any thrown exception in the JSONException @@ -800,16 +833,18 @@ public class JSONObject { /** * Get the boolean value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The truth. - * @throws JSONException if the value is not a Boolean or the String "true" or - * "false". + * @throws JSONException + * if the value is not a Boolean or the String "true" or + * "false". */ public boolean getBoolean(String key) throws JSONException { Object object = this.get(key); - if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object).equalsIgnoreCase("false"))) { + if(object.equals(Boolean.FALSE) || (object instanceof String && ((String) object).equalsIgnoreCase("false"))) { return false; - } else if (object.equals(Boolean.TRUE) || (object instanceof String && ((String) object).equalsIgnoreCase("true"))) { + } else if(object.equals(Boolean.TRUE) || (object instanceof String && ((String) object).equalsIgnoreCase("true"))) { return true; } throw new JSONException("JSONObject[" + quote(key) + "] is not a Boolean."); @@ -818,16 +853,18 @@ public class JSONObject { /** * Get the BigInteger value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The numeric value. - * @throws JSONException if the key is not found or if the value cannot be converted - * to BigInteger. + * @throws JSONException + * if the key is not found or if the value cannot be converted + * to BigInteger. */ public BigInteger getBigInteger(String key) throws JSONException { Object object = this.get(key); try { return new BigInteger(object.toString()); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigInteger."); } @@ -836,16 +873,18 @@ public class JSONObject { /** * Get the BigDecimal value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The numeric value. - * @throws JSONException if the key is not found or if the value cannot be converted - * to BigDecimal. + * @throws JSONException + * if the key is not found or if the value cannot be converted + * to BigDecimal. */ public BigDecimal getBigDecimal(String key) throws JSONException { Object object = this.get(key); try { return new BigDecimal(object.toString()); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigDecimal."); } @@ -854,16 +893,18 @@ public class JSONObject { /** * Get the double value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The numeric value. - * @throws JSONException if the key is not found or if the value is not a Number - * object and cannot be converted to a number. + * @throws JSONException + * if the key is not found or if the value is not a Number + * object and cannot be converted to a number. */ public double getDouble(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONObject[" + quote(key) + "] is not a number."); } @@ -872,16 +913,18 @@ public class JSONObject { /** * Get the int value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The integer value. - * @throws JSONException if the key is not found or if the value cannot be converted - * to an integer. + * @throws JSONException + * if the key is not found or if the value cannot be converted + * to an integer. */ public int getInt(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONObject[" + quote(key) + "] is not an int."); } @@ -890,13 +933,15 @@ public class JSONObject { /** * Get the JSONArray value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return A JSONArray which is the value. - * @throws JSONException if the key is not found or if the value is not a JSONArray. + * @throws JSONException + * if the key is not found or if the value is not a JSONArray. */ public JSONArray getJSONArray(String key) throws JSONException { Object object = this.get(key); - if (object instanceof JSONArray) { + if(object instanceof JSONArray) { return (JSONArray) object; } throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONArray."); @@ -905,13 +950,15 @@ public class JSONObject { /** * Get the JSONObject value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return A JSONObject which is the value. - * @throws JSONException if the key is not found or if the value is not a JSONObject. + * @throws JSONException + * if the key is not found or if the value is not a JSONObject. */ public JSONObject getJSONObject(String key) throws JSONException { Object object = this.get(key); - if (object instanceof JSONObject) { + if(object instanceof JSONObject) { return (JSONObject) object; } throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONObject."); @@ -920,16 +967,18 @@ public class JSONObject { /** * Get the long value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return The long value. - * @throws JSONException if the key is not found or if the value cannot be converted - * to a long. + * @throws JSONException + * if the key is not found or if the value cannot be converted + * to a long. */ public long getLong(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); throw new JSONException("JSONObject[" + quote(key) + "] is not a long."); } @@ -938,13 +987,15 @@ public class JSONObject { /** * Get the string associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return A string which is the value. - * @throws JSONException if there is no string value for the key. + * @throws JSONException + * if there is no string value for the key. */ public String getString(String key) throws JSONException { Object object = this.get(key); - if (object instanceof String) { + if(object instanceof String) { return (String) object; } throw new JSONException("JSONObject[" + quote(key) + "] not a string."); @@ -953,7 +1004,8 @@ public class JSONObject { /** * Determine if the JSONObject contains a specific key. * - * @param key A key string. + * @param key + * A key string. * @return true if the key exists in the JSONObject. */ public boolean has(String key) { @@ -965,26 +1017,28 @@ public class JSONObject { * create one with a value of 1. If there is such a property, and if it is * an Integer, Long, Double, or Float, then add one to it. * - * @param key A key string. + * @param key + * A key string. * @return this. - * @throws JSONException If there is already a property with this name that is not an - * Integer, Long, Double, or Float. + * @throws JSONException + * If there is already a property with this name that is not an + * Integer, Long, Double, or Float. */ public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); - if (value == null) { + if(value == null) { this.put(key, 1); - } else if (value instanceof BigInteger) { + } else if(value instanceof BigInteger) { this.put(key, ((BigInteger) value).add(BigInteger.ONE)); - } else if (value instanceof BigDecimal) { + } else if(value instanceof BigDecimal) { this.put(key, ((BigDecimal) value).add(BigDecimal.ONE)); - } else if (value instanceof Integer) { + } else if(value instanceof Integer) { this.put(key, (Integer) value + 1); - } else if (value instanceof Long) { + } else if(value instanceof Long) { this.put(key, (Long) value + 1); - } else if (value instanceof Double) { + } else if(value instanceof Double) { this.put(key, (Double) value + 1); - } else if (value instanceof Float) { + } else if(value instanceof Float) { this.put(key, (Float) value + 1); } else { throw new JSONException("Unable to increment [" + quote(key) + "]."); @@ -996,7 +1050,8 @@ public class JSONObject { * Determine if the value associated with the key is null or if there is no * value. * - * @param key A key string. + * @param key + * A key string. * @return true if there is no value associated with the key or if the value * is the JSONObject.NULL object. */ @@ -1041,7 +1096,7 @@ public class JSONObject { public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = this.keys(); - while (keys.hasNext()) { + while(keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; @@ -1050,7 +1105,8 @@ public class JSONObject { /** * Get an optional value associated with a key. * - * @param key A key string. + * @param key + * A key string. * @return An object which is the value, or null if there is no value. */ public Object opt(String key) { @@ -1060,8 +1116,10 @@ public class JSONObject { /** * Get the enum value associated with a key. * - * @param clazz The type of enum to retrieve. - * @param key A key string. + * @param clazz + * The type of enum to retrieve. + * @param key + * A key string. * @return The enum value associated with the key or null if not found */ public > E optEnum(Class clazz, String key) { @@ -1071,29 +1129,32 @@ public class JSONObject { /** * Get the enum value associated with a key. * - * @param clazz The type of enum to retrieve. - * @param key A key string. - * @param defaultValue The default in case the value is not found + * @param clazz + * The type of enum to retrieve. + * @param key + * A key string. + * @param defaultValue + * The default in case the value is not found * @return The enum value associated with the key or defaultValue if the * value is not found or cannot be assigned to clazz */ public > E optEnum(Class clazz, String key, E defaultValue) { try { Object val = this.opt(key); - if (NULL.equals(val)) { + if(NULL.equals(val)) { return defaultValue; } - if (clazz.isAssignableFrom(val.getClass())) { + if(clazz.isAssignableFrom(val.getClass())) { // we just checked it! @SuppressWarnings("unchecked") E myE = (E) val; return myE; } return Enum.valueOf(clazz, val.toString()); - } catch (IllegalArgumentException e) { + } catch(IllegalArgumentException e) { Iris.reportError(e); return defaultValue; - } catch (NullPointerException e) { + } catch(NullPointerException e) { Iris.reportError(e); return defaultValue; } @@ -1103,7 +1164,8 @@ public class JSONObject { * Get an optional boolean associated with a key. It returns false if there * is no such key, or if the value is not Boolean.TRUE or the String "true". * - * @param key A key string. + * @param key + * A key string. * @return The truth. */ public boolean optBoolean(String key) { @@ -1115,14 +1177,16 @@ public class JSONObject { * defaultValue if there is no such key, or if it is not a Boolean or the * String "true" or "false" (case insensitive). * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return The truth. */ public boolean optBoolean(String key, boolean defaultValue) { try { return this.getBoolean(key); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -1133,7 +1197,8 @@ public class JSONObject { * key or if its value is not a number. If the value is a string, an attempt * will be made to evaluate it as a number. * - * @param key A string which is the key. + * @param key + * A string which is the key. * @return An object which is the value. */ public double optDouble(String key) { @@ -1145,14 +1210,16 @@ public class JSONObject { * there is no such key or if its value is not a number. If the value is a * string, an attempt will be made to evaluate it as a number. * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return An object which is the value. */ public BigInteger optBigInteger(String key, BigInteger defaultValue) { try { return this.getBigInteger(key); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -1163,14 +1230,16 @@ public class JSONObject { * there is no such key or if its value is not a number. If the value is a * string, an attempt will be made to evaluate it as a number. * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return An object which is the value. */ public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) { try { return this.getBigDecimal(key); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -1181,14 +1250,16 @@ public class JSONObject { * there is no such key or if its value is not a number. If the value is a * string, an attempt will be made to evaluate it as a number. * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return An object which is the value. */ public double optDouble(String key, double defaultValue) { try { return this.getDouble(key); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -1199,7 +1270,8 @@ public class JSONObject { * such key or if the value is not a number. If the value is a string, an * attempt will be made to evaluate it as a number. * - * @param key A key string. + * @param key + * A key string. * @return An object which is the value. */ public int optInt(String key) { @@ -1211,14 +1283,16 @@ public class JSONObject { * is no such key or if the value is not a number. If the value is a string, * an attempt will be made to evaluate it as a number. * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return An object which is the value. */ public int optInt(String key, int defaultValue) { try { return this.getInt(key); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -1228,7 +1302,8 @@ public class JSONObject { * Get an optional JSONArray associated with a key. It returns null if there * is no such key, or if its value is not a JSONArray. * - * @param key A key string. + * @param key + * A key string. * @return A JSONArray which is the value. */ public JSONArray optJSONArray(String key) { @@ -1240,7 +1315,8 @@ public class JSONObject { * Get an optional JSONObject associated with a key. It returns null if * there is no such key, or if its value is not a JSONObject. * - * @param key A key string. + * @param key + * A key string. * @return A JSONObject which is the value. */ public JSONObject optJSONObject(String key) { @@ -1253,7 +1329,8 @@ public class JSONObject { * such key or if the value is not a number. If the value is a string, an * attempt will be made to evaluate it as a number. * - * @param key A key string. + * @param key + * A key string. * @return An object which is the value. */ public long optLong(String key) { @@ -1265,14 +1342,16 @@ public class JSONObject { * is no such key or if the value is not a number. If the value is a string, * an attempt will be made to evaluate it as a number. * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return An object which is the value. */ public long optLong(String key, long defaultValue) { try { return this.getLong(key); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return defaultValue; } @@ -1283,7 +1362,8 @@ public class JSONObject { * if there is no such key. If the value is not a string and is not null, * then it is converted to a string. * - * @param key A key string. + * @param key + * A key string. * @return A string which is the value. */ public String optString(String key) { @@ -1294,8 +1374,10 @@ public class JSONObject { * Get an optional string associated with a key. It returns the defaultValue * if there is no such key. * - * @param key A key string. - * @param defaultValue The default. + * @param key + * A key string. + * @param defaultValue + * The default. * @return A string which is the value. */ public String optString(String key, String defaultValue) { @@ -1311,35 +1393,35 @@ public class JSONObject { boolean includeSuperClass = klass.getClassLoader() != null; Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i += 1) { + for(int i = 0; i < methods.length; i += 1) { try { Method method = methods[i]; - if (Modifier.isPublic(method.getModifiers())) { + if(Modifier.isPublic(method.getModifiers())) { String name = method.getName(); String key = ""; - if (name.startsWith("get")) { - if ("getClass".equals(name) || "getDeclaringClass".equals(name)) { + if(name.startsWith("get")) { + if("getClass".equals(name) || "getDeclaringClass".equals(name)) { key = ""; } else { key = name.substring(3); } - } else if (name.startsWith("is")) { + } else if(name.startsWith("is")) { key = name.substring(2); } - if (key.length() > 0 && Character.isUpperCase(key.charAt(0)) && method.getParameterTypes().length == 0) { - if (key.length() == 1) { + if(key.length() > 0 && Character.isUpperCase(key.charAt(0)) && method.getParameterTypes().length == 0) { + if(key.length() == 1) { key = key.toLowerCase(); - } else if (!Character.isUpperCase(key.charAt(1))) { + } else if(!Character.isUpperCase(key.charAt(1))) { key = key.substring(0, 1).toLowerCase() + key.substring(1); } Object result = method.invoke(bean, (Object[]) null); - if (result != null) { + if(result != null) { this.map.put(key, wrap(result)); } } } - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); } } @@ -1348,10 +1430,13 @@ public class JSONObject { /** * Put a key/boolean pair in the JSONObject. * - * @param key A key string. - * @param value A boolean which is the value. + * @param key + * A key string. + * @param value + * A boolean which is the value. * @return this. - * @throws JSONException If the key is null. + * @throws JSONException + * If the key is null. */ public JSONObject put(String key, boolean value) throws JSONException { this.put(key, value ? Boolean.TRUE : Boolean.FALSE); @@ -1362,10 +1447,11 @@ public class JSONObject { * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection. * - * @param key A key string. - * @param value A Collection value. + * @param key + * A key string. + * @param value + * A Collection value. * @return this. - * @throws JSONException */ public JSONObject put(String key, Collection value) throws JSONException { this.put(key, new JSONArray(value)); @@ -1375,10 +1461,13 @@ public class JSONObject { /** * Put a key/double pair in the JSONObject. * - * @param key A key string. - * @param value A double which is the value. + * @param key + * A key string. + * @param value + * A double which is the value. * @return this. - * @throws JSONException If the key is null or if the number is invalid. + * @throws JSONException + * If the key is null or if the number is invalid. */ public JSONObject put(String key, double value) throws JSONException { this.put(key, Double.valueOf(value)); @@ -1388,10 +1477,13 @@ public class JSONObject { /** * Put a key/int pair in the JSONObject. * - * @param key A key string. - * @param value An int which is the value. + * @param key + * A key string. + * @param value + * An int which is the value. * @return this. - * @throws JSONException If the key is null. + * @throws JSONException + * If the key is null. */ public JSONObject put(String key, int value) throws JSONException { this.put(key, Integer.valueOf(value)); @@ -1401,10 +1493,13 @@ public class JSONObject { /** * Put a key/long pair in the JSONObject. * - * @param key A key string. - * @param value A long which is the value. + * @param key + * A key string. + * @param value + * A long which is the value. * @return this. - * @throws JSONException If the key is null. + * @throws JSONException + * If the key is null. */ public JSONObject put(String key, long value) throws JSONException { this.put(key, Long.valueOf(value)); @@ -1415,10 +1510,11 @@ public class JSONObject { * Put a key/value pair in the JSONObject, where the value will be a * JSONObject which is produced from a Map. * - * @param key A key string. - * @param value A Map value. + * @param key + * A key string. + * @param value + * A Map value. * @return this. - * @throws JSONException */ public JSONObject put(String key, Map value) throws JSONException { this.put(key, new JSONObject(value)); @@ -1429,18 +1525,21 @@ public class JSONObject { * Put a key/value pair in the JSONObject. If the value is null, then the * key will be removed from the JSONObject if it is present. * - * @param key A key string. - * @param value An object which is the value. It should be of one of these - * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, - * String, or the JSONObject.NULL object. + * @param key + * A key string. + * @param value + * An object which is the value. It should be of one of these + * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, + * String, or the JSONObject.NULL object. * @return this. - * @throws JSONException If the value is non-finite number or if the key is null. + * @throws JSONException + * If the value is non-finite number or if the key is null. */ public JSONObject put(String key, Object value) throws JSONException { - if (key == null) { + if(key == null) { throw new NullPointerException("Null key."); } - if (value != null) { + if(value != null) { testValidity(value); this.map.put(key, value); } else { @@ -1454,14 +1553,17 @@ public class JSONObject { * are both non-null, and only if there is not already a member with that * name. * - * @param key string - * @param value object + * @param key + * string + * @param value + * object * @return this. - * @throws JSONException if the key is a duplicate + * @throws JSONException + * if the key is a duplicate */ public JSONObject putOnce(String key, Object value) throws JSONException { - if (key != null && value != null) { - if (this.opt(key) != null) { + if(key != null && value != null) { + if(this.opt(key) != null) { throw new JSONException("Duplicate key \"" + key + "\""); } this.put(key, value); @@ -1473,15 +1575,18 @@ public class JSONObject { * Put a key/value pair in the JSONObject, but only if the key and the value * are both non-null. * - * @param key A key string. - * @param value An object which is the value. It should be of one of these - * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, - * String, or the JSONObject.NULL object. + * @param key + * A key string. + * @param value + * An object which is the value. It should be of one of these + * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, + * String, or the JSONObject.NULL object. * @return this. - * @throws JSONException If the value is a non-finite number. + * @throws JSONException + * If the value is a non-finite number. */ public JSONObject putOpt(String key, Object value) throws JSONException { - if (key != null && value != null) { + if(key != null && value != null) { this.put(key, value); } return this; @@ -1490,7 +1595,8 @@ public class JSONObject { /** * Remove a name and its value, if present. * - * @param key The name to be removed. + * @param key + * The name to be removed. * @return The value that was associated with the name, or null if there was * no value. */ @@ -1502,38 +1608,39 @@ public class JSONObject { * Determine if two JSONObjects are similar. They must contain the same set * of names which must be associated with similar values. * - * @param other The other JSONObject + * @param other + * The other JSONObject * @return true if they are equal */ @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean similar(Object other) { try { - if (!(other instanceof JSONObject)) { + if(!(other instanceof JSONObject)) { return false; } Set set = this.keySet(); - if (!set.equals(((JSONObject) other).keySet())) { + if(!set.equals(((JSONObject) other).keySet())) { return false; } Iterator iterator = set.iterator(); - while (iterator.hasNext()) { + while(iterator.hasNext()) { String name = iterator.next(); Object valueThis = this.get(name); Object valueOther = ((JSONObject) other).get(name); - if (valueThis instanceof JSONObject) { - if (!((JSONObject) valueThis).similar(valueOther)) { + if(valueThis instanceof JSONObject) { + if(!((JSONObject) valueThis).similar(valueOther)) { return false; } - } else if (valueThis instanceof JSONArray) { - if (!((JSONArray) valueThis).similar(valueOther)) { + } else if(valueThis instanceof JSONArray) { + if(!((JSONArray) valueThis).similar(valueOther)) { return false; } - } else if (!valueThis.equals(valueOther)) { + } else if(!valueThis.equals(valueOther)) { return false; } } return true; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); return false; } @@ -1543,17 +1650,19 @@ public class JSONObject { * Produce a JSONArray containing the values of the members of this * JSONObject. * - * @param names A JSONArray containing a list of key strings. This determines - * the sequence of the values in the result. + * @param names + * A JSONArray containing a list of key strings. This determines + * the sequence of the values in the result. * @return A JSONArray of values. - * @throws JSONException If any of the values are non-finite numbers. + * @throws JSONException + * If any of the values are non-finite numbers. */ public JSONArray toJSONArray(JSONArray names) throws JSONException { - if (names == null || names.length() == 0) { + if(names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); - for (int i = 0; i < names.length(); i += 1) { + for(int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } return ja; @@ -1574,7 +1683,7 @@ public class JSONObject { public String toString() { try { return this.toString(0); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); return null; } @@ -1585,16 +1694,18 @@ public class JSONObject { *

* Warning: This method assumes that the data structure is acyclical. * - * @param indentFactor The number of spaces to add to each level of indentation. + * @param indentFactor + * The number of spaces to add to each level of indentation. * @return a printable, displayable, portable, transmittable representation * of the object, beginning with { (left * brace) and ending with } (right * brace). - * @throws JSONException If the object contains an invalid number. + * @throws JSONException + * If the object contains an invalid number. */ public String toString(int indentFactor) throws JSONException { StringWriter w = new StringWriter(); - synchronized (w.getBuffer()) { + synchronized(w.getBuffer()) { return this.write(w, indentFactor, 0).toString(); } } @@ -1606,7 +1717,6 @@ public class JSONObject { * Warning: This method assumes that the data structure is acyclical. * * @return The writer. - * @throws JSONException */ public Writer write(Writer writer) throws JSONException { return this.write(writer, 0, 0); @@ -1619,7 +1729,6 @@ public class JSONObject { * Warning: This method assumes that the data structure is acyclical. * * @return The writer. - * @throws JSONException */ Writer write(Writer writer, int indentFactor, int indent) throws JSONException { try { @@ -1628,41 +1737,41 @@ public class JSONObject { Iterator keys = this.keys(); writer.write('{'); - if (length == 1) { + if(length == 1) { Object key = keys.next(); writer.write(quote(key.toString())); writer.write(':'); - if (indentFactor > 0) { + if(indentFactor > 0) { writer.write(' '); } writeValue(writer, this.map.get(key), indentFactor, indent); - } else if (length != 0) { + } else if(length != 0) { final int newindent = indent + indentFactor; - while (keys.hasNext()) { + while(keys.hasNext()) { Object key = keys.next(); - if (commanate) { + if(commanate) { writer.write(','); } - if (indentFactor > 0) { + if(indentFactor > 0) { writer.write('\n'); } indent(writer, newindent); writer.write(quote(key.toString())); writer.write(':'); - if (indentFactor > 0) { + if(indentFactor > 0) { writer.write(' '); } writeValue(writer, this.map.get(key), indentFactor, newindent); commanate = true; } - if (indentFactor > 0) { + if(indentFactor > 0) { writer.write('\n'); } indent(writer, indent); } writer.write('}'); return writer; - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); throw new JSONException(e); } @@ -1689,7 +1798,8 @@ public class JSONObject { /** * A Null object is equal to the null value and to itself. * - * @param object An object to test for nullness. + * @param object + * An object to test for nullness. * @return true if the object parameter is the JSONObject.NULL object or * null. */ diff --git a/src/main/java/com/volmit/iris/util/json/JSONTokener.java b/src/main/java/com/volmit/iris/util/json/JSONTokener.java index 2753cf173..6e86be75d 100644 --- a/src/main/java/com/volmit/iris/util/json/JSONTokener.java +++ b/src/main/java/com/volmit/iris/util/json/JSONTokener.java @@ -50,7 +50,8 @@ public class JSONTokener { /** * Construct a JSONTokener from a Reader. * - * @param reader A reader. + * @param reader + * A reader. */ public JSONTokener(Reader reader) { this.reader = reader.markSupported() ? reader : new BufferedReader(reader); @@ -65,7 +66,8 @@ public class JSONTokener { /** * Construct a JSONTokener from an InputStream. * - * @param inputStream The source. + * @param inputStream + * The source. */ public JSONTokener(InputStream inputStream) throws JSONException { this(new InputStreamReader(inputStream)); @@ -74,7 +76,8 @@ public class JSONTokener { /** * Construct a JSONTokener from a string. * - * @param s A source string. + * @param s + * A source string. */ public JSONTokener(String s) { this(new StringReader(s)); @@ -83,18 +86,19 @@ public class JSONTokener { /** * Get the hex value of a character (base16). * - * @param c A character between '0' and '9' or between 'A' and 'F' or - * between 'a' and 'f'. + * @param c + * A character between '0' and '9' or between 'A' and 'F' or + * between 'a' and 'f'. * @return An int between 0 and 15, or -1 if c was not a hex digit. */ public static int dehexchar(char c) { - if (c >= '0' && c <= '9') { + if(c >= '0' && c <= '9') { return c - '0'; } - if (c >= 'A' && c <= 'F') { + if(c >= 'A' && c <= 'F') { return c - ('A' - 10); } - if (c >= 'a' && c <= 'f') { + if(c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; @@ -106,7 +110,7 @@ public class JSONTokener { * next number or identifier. */ public void back() throws JSONException { - if (this.usePrevious || this.index <= 0) { + if(this.usePrevious || this.index <= 0) { throw new JSONException("Stepping back two steps is not supported"); } this.index -= 1; @@ -127,7 +131,7 @@ public class JSONTokener { */ public boolean more() throws JSONException { this.next(); - if (this.end()) { + if(this.end()) { return false; } this.back(); @@ -141,27 +145,27 @@ public class JSONTokener { */ public char next() throws JSONException { int c; - if (this.usePrevious) { + if(this.usePrevious) { this.usePrevious = false; c = this.previous; } else { try { c = this.reader.read(); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); throw new JSONException(e); } - if (c <= 0) { // End of stream + if(c <= 0) { // End of stream this.eof = true; c = 0; } } this.index += 1; - if (this.previous == '\r') { + if(this.previous == '\r') { this.line += 1; this.character = c == '\n' ? 0 : 1; - } else if (c == '\n') { + } else if(c == '\n') { this.line += 1; this.character = 0; } else { @@ -175,13 +179,15 @@ public class JSONTokener { * Consume the next character, and check that it matches a specified * character. * - * @param c The character to match. + * @param c + * The character to match. * @return The character. - * @throws JSONException if the character does not match. + * @throws JSONException + * if the character does not match. */ public char next(char c) throws JSONException { char n = this.next(); - if (n != c) { + if(n != c) { throw this.syntaxError("Expected '" + c + "' and instead saw '" + n + "'"); } return n; @@ -190,22 +196,24 @@ public class JSONTokener { /** * Get the next n characters. * - * @param n The number of characters to take. + * @param n + * The number of characters to take. * @return A string of n characters. - * @throws JSONException Substring bounds error if there are not n characters - * remaining in the source string. + * @throws JSONException + * Substring bounds error if there are not n characters + * remaining in the source string. */ public String next(int n) throws JSONException { - if (n == 0) { + if(n == 0) { return ""; } char[] chars = new char[n]; int pos = 0; - while (pos < n) { + while(pos < n) { chars[pos] = this.next(); - if (this.end()) { + if(this.end()) { throw this.syntaxError("Substring bounds error"); } pos += 1; @@ -217,12 +225,11 @@ public class JSONTokener { * Get the next char in the string, skipping whitespace. * * @return A character, or 0 if there are no more characters. - * @throws JSONException */ public char nextClean() throws JSONException { - for (; ; ) { + for(; ; ) { char c = this.next(); - if (c == 0 || c > ' ') { + if(c == 0 || c > ' ') { return c; } } @@ -233,25 +240,27 @@ public class JSONTokener { * processing is done. The formal JSON format does not allow strings in * single quotes, but an implementation is allowed to accept them. * - * @param quote The quoting character, either "  - * (double quote) or '  - * (single quote). + * @param quote + * The quoting character, either "  + * (double quote) or '  + * (single quote). * @return A String. - * @throws JSONException Unterminated string. + * @throws JSONException + * Unterminated string. */ public String nextString(char quote) throws JSONException { char c; StringBuilder sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { c = this.next(); - switch (c) { + switch(c) { case 0: case '\n': case '\r': throw this.syntaxError("Unterminated string"); case '\\': c = this.next(); - switch (c) { + switch(c) { case 'b': sb.append('\b'); break; @@ -281,7 +290,7 @@ public class JSONTokener { } break; default: - if (c == quote) { + if(c == quote) { return sb.toString(); } sb.append(c); @@ -293,15 +302,16 @@ public class JSONTokener { * Get the text up but not including the specified character or the end of * line, whichever comes first. * - * @param delimiter A delimiter character. + * @param delimiter + * A delimiter character. * @return A string. */ public String nextTo(char delimiter) throws JSONException { StringBuilder sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { char c = this.next(); - if (c == delimiter || c == 0 || c == '\n' || c == '\r') { - if (c != 0) { + if(c == delimiter || c == 0 || c == '\n' || c == '\r') { + if(c != 0) { this.back(); } return sb.toString().trim(); @@ -314,16 +324,17 @@ public class JSONTokener { * Get the text up but not including one of the specified delimiter * characters or the end of line, whichever comes first. * - * @param delimiters A set of delimiter characters. + * @param delimiters + * A set of delimiter characters. * @return A string, trimmed. */ public String nextTo(String delimiters) throws JSONException { char c; StringBuilder sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { c = this.next(); - if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') { - if (c != 0) { + if(delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') { + if(c != 0) { this.back(); } return sb.toString().trim(); @@ -337,13 +348,14 @@ public class JSONTokener { * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object. * * @return An object. - * @throws JSONException If syntax error. + * @throws JSONException + * If syntax error. */ public Object nextValue() throws JSONException { char c = this.nextClean(); String string; - switch (c) { + switch(c) { case '"': case '\'': return this.nextString(c); @@ -365,14 +377,14 @@ public class JSONTokener { */ StringBuilder sb = new StringBuilder(); - while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { + while(c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { sb.append(c); c = this.next(); } this.back(); string = sb.toString().trim(); - if ("".equals(string)) { + if("".equals(string)) { throw this.syntaxError("Missing value"); } return JSONObject.stringToValue(string); @@ -382,7 +394,8 @@ public class JSONTokener { * Skip characters until the next character is the requested character. If * the requested character is not found, no characters are skipped. * - * @param to A character to skip to. + * @param to + * A character to skip to. * @return The requested character, or zero if the requested character is * not found. */ @@ -395,15 +408,15 @@ public class JSONTokener { this.reader.mark(1000000); do { c = this.next(); - if (c == 0) { + if(c == 0) { this.reader.reset(); this.index = startIndex; this.character = startCharacter; this.line = startLine; return c; } - } while (c != to); - } catch (IOException e) { + } while(c != to); + } catch(IOException e) { Iris.reportError(e); throw new JSONException(e); } @@ -414,7 +427,8 @@ public class JSONTokener { /** * Make a JSONException to signal a syntax error. * - * @param message The error message. + * @param message + * The error message. * @return A JSONException object, suitable for throwing */ public JSONException syntaxError(String message) { diff --git a/src/main/java/com/volmit/iris/util/json/JSONWriter.java b/src/main/java/com/volmit/iris/util/json/JSONWriter.java index 737ea7956..57fe58b98 100644 --- a/src/main/java/com/volmit/iris/util/json/JSONWriter.java +++ b/src/main/java/com/volmit/iris/util/json/JSONWriter.java @@ -96,25 +96,27 @@ public class JSONWriter { /** * Append a value. * - * @param string A string value. + * @param string + * A string value. * @return this - * @throws JSONException If the value is out of sequence. + * @throws JSONException + * If the value is out of sequence. */ private JSONWriter append(String string) throws JSONException { - if (string == null) { + if(string == null) { throw new JSONException("Null pointer"); } - if (this.mode == 'o' || this.mode == 'a') { + if(this.mode == 'o' || this.mode == 'a') { try { - if (this.comma && this.mode == 'a') { + if(this.comma && this.mode == 'a') { this.writer.write(','); } this.writer.write(string); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); throw new JSONException(e); } - if (this.mode == 'o') { + if(this.mode == 'o') { this.mode = 'k'; } this.comma = true; @@ -129,12 +131,13 @@ public class JSONWriter { * endArray method must be called to mark the array's end. * * @return this - * @throws JSONException If the nesting is too deep, or if the object is started in - * the wrong place (for example as a key or after the end of the - * outermost array or object). + * @throws JSONException + * If the nesting is too deep, or if the object is started in + * the wrong place (for example as a key or after the end of the + * outermost array or object). */ public JSONWriter array() throws JSONException { - if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { + if(this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { this.push(null); this.append("["); this.comma = false; @@ -146,19 +149,22 @@ public class JSONWriter { /** * End something. * - * @param mode Mode - * @param c Closing character + * @param mode + * Mode + * @param c + * Closing character * @return this - * @throws JSONException If unbalanced. + * @throws JSONException + * If unbalanced. */ private JSONWriter end(char mode, char c) throws JSONException { - if (this.mode != mode) { + if(this.mode != mode) { throw new JSONException(mode == 'a' ? "Misplaced endArray." : "Misplaced endObject."); } this.pop(mode); try { this.writer.write(c); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); throw new JSONException(e); } @@ -171,7 +177,8 @@ public class JSONWriter { * array. * * @return this - * @throws JSONException If incorrectly nested. + * @throws JSONException + * If incorrectly nested. */ public JSONWriter endArray() throws JSONException { return this.end('a', ']'); @@ -182,7 +189,8 @@ public class JSONWriter { * object. * * @return this - * @throws JSONException If incorrectly nested. + * @throws JSONException + * If incorrectly nested. */ public JSONWriter endObject() throws JSONException { return this.end('k', '}'); @@ -192,19 +200,21 @@ public class JSONWriter { * Append a key. The key will be associated with the next value. In an * object, every value must be preceded by a key. * - * @param string A key string. + * @param string + * A key string. * @return this - * @throws JSONException If the key is out of place. For example, keys do not belong - * in arrays or if the key is null. + * @throws JSONException + * If the key is out of place. For example, keys do not belong + * in arrays or if the key is null. */ public JSONWriter key(String string) throws JSONException { - if (string == null) { + if(string == null) { throw new JSONException("Null key."); } - if (this.mode == 'k') { + if(this.mode == 'k') { try { this.stack[this.top - 1].putOnce(string, Boolean.TRUE); - if (this.comma) { + if(this.comma) { this.writer.write(','); } this.writer.write(JSONObject.quote(string)); @@ -212,7 +222,7 @@ public class JSONWriter { this.comma = false; this.mode = 'o'; return this; - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); throw new JSONException(e); } @@ -226,15 +236,16 @@ public class JSONWriter { * endObject method must be called to mark the object's end. * * @return this - * @throws JSONException If the nesting is too deep, or if the object is started in - * the wrong place (for example as a key or after the end of the - * outermost array or object). + * @throws JSONException + * If the nesting is too deep, or if the object is started in + * the wrong place (for example as a key or after the end of the + * outermost array or object). */ public JSONWriter object() throws JSONException { - if (this.mode == 'i') { + if(this.mode == 'i') { this.mode = 'o'; } - if (this.mode == 'o' || this.mode == 'a') { + if(this.mode == 'o' || this.mode == 'a') { this.append("{"); this.push(new JSONObject()); this.comma = false; @@ -247,15 +258,17 @@ public class JSONWriter { /** * Pop an array or object scope. * - * @param c The scope to close. - * @throws JSONException If nesting is wrong. + * @param c + * The scope to close. + * @throws JSONException + * If nesting is wrong. */ private void pop(char c) throws JSONException { - if (this.top <= 0) { + if(this.top <= 0) { throw new JSONException("Nesting error."); } char m = this.stack[this.top - 1] == null ? 'a' : 'k'; - if (m != c) { + if(m != c) { throw new JSONException("Nesting error."); } this.top -= 1; @@ -265,11 +278,13 @@ public class JSONWriter { /** * Push an array or object scope. * - * @param jo The scope to open. - * @throws JSONException If nesting is too deep. + * @param jo + * The scope to open. + * @throws JSONException + * If nesting is too deep. */ private void push(JSONObject jo) throws JSONException { - if (this.top >= maxdepth) { + if(this.top >= maxdepth) { throw new JSONException("Nesting too deep."); } this.stack[this.top] = jo; @@ -281,7 +296,8 @@ public class JSONWriter { * Append either the value true or the value false * . * - * @param b A boolean. + * @param b + * A boolean. * @return this */ public JSONWriter value(boolean b) throws JSONException { @@ -291,9 +307,11 @@ public class JSONWriter { /** * Append a double value. * - * @param d A double. + * @param d + * A double. * @return this - * @throws JSONException If the number is not finite. + * @throws JSONException + * If the number is not finite. */ public JSONWriter value(double d) throws JSONException { return this.value(Double.valueOf(d)); @@ -302,7 +320,8 @@ public class JSONWriter { /** * Append a long value. * - * @param l A long. + * @param l + * A long. * @return this */ public JSONWriter value(long l) throws JSONException { @@ -312,11 +331,13 @@ public class JSONWriter { /** * Append an object value. * - * @param object The object to append. It can be null, or a Boolean, Number, - * String, JSONObject, or JSONArray, or an object that implements - * JSONString. + * @param object + * The object to append. It can be null, or a Boolean, Number, + * String, JSONObject, or JSONArray, or an object that implements + * JSONString. * @return this - * @throws JSONException If the value is out of sequence. + * @throws JSONException + * If the value is out of sequence. */ public JSONWriter value(Object object) throws JSONException { return this.append(JSONObject.valueToString(object)); diff --git a/src/main/java/com/volmit/iris/util/json/XML.java b/src/main/java/com/volmit/iris/util/json/XML.java index 50be36dc8..8a24663ea 100644 --- a/src/main/java/com/volmit/iris/util/json/XML.java +++ b/src/main/java/com/volmit/iris/util/json/XML.java @@ -87,14 +87,15 @@ public class XML { * " (double quote) is replaced by &quot; * * - * @param string The string to be escaped. + * @param string + * The string to be escaped. * @return The escaped string. */ public static String escape(String string) { StringBuilder sb = new StringBuilder(string.length()); - for (int i = 0, length = string.length(); i < length; i++) { + for(int i = 0, length = string.length(); i < length; i++) { char c = string.charAt(i); - switch (c) { + switch(c) { case '&' -> sb.append("&"); case '<' -> sb.append("<"); case '>' -> sb.append(">"); @@ -110,15 +111,16 @@ public class XML { * Throw an exception if the string contains whitespace. Whitespace is not * allowed in tagNames and attributes. * - * @param string A string. + * @param string + * A string. */ public static void noSpace(String string) throws JSONException { int i, length = string.length(); - if (length == 0) { + if(length == 0) { throw new JSONException("Empty string."); } - for (i = 0; i < length; i += 1) { - if (Character.isWhitespace(string.charAt(i))) { + for(i = 0; i < length; i += 1) { + if(Character.isWhitespace(string.charAt(i))) { throw new JSONException("'" + string + "' contains a space character."); } } @@ -127,9 +129,12 @@ public class XML { /** * Scan the content following the named tag, attaching it to the context. * - * @param x The XMLTokener containing the source string. - * @param context The JSONObject that will include the new material. - * @param name The tag name. + * @param x + * The XMLTokener containing the source string. + * @param context + * The JSONObject that will include the new material. + * @param name + * The tag name. * @return true if the close tag is processed. */ private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException { @@ -154,20 +159,20 @@ public class XML { // "); return false; } x.back(); - } else if (c == '[') { + } else if(c == '[') { token = x.nextToken(); - if ("CDATA".equals(token)) { - if (x.next() == '[') { + if("CDATA".equals(token)) { + if(x.next() == '[') { string = x.nextCDATA(); - if (string.length() > 0) { + if(string.length() > 0) { context.accumulate("content", string); } return false; @@ -178,38 +183,38 @@ public class XML { i = 1; do { token = x.nextMeta(); - if (token == null) { + if(token == null) { throw x.syntaxError("Missing '>' after ' 0); + } while(i > 0); return false; - } else if (token == QUEST) { + } else if(token == QUEST) { // "); return false; - } else if (token == SLASH) { + } else if(token == SLASH) { // Close tag - } else if (token == SLASH) { - if (x.nextToken() != GT) { + } else if(token == SLASH) { + if(x.nextToken() != GT) { throw x.syntaxError("Misshaped tag"); } - if (jsonobject.length() > 0) { + if(jsonobject.length() > 0) { context.accumulate(tagName, jsonobject); } else { context.accumulate(tagName, ""); @@ -254,27 +259,27 @@ public class XML { // Content, between <...> and - } else if (token == GT) { - for (; ; ) { + } else if(token == GT) { + for(; ; ) { token = x.nextContent(); - if (token == null) { - if (tagName != null) { + if(token == null) { + if(tagName != null) { throw x.syntaxError("Unclosed tag " + tagName); } return false; - } else if (token instanceof String) { + } else if(token instanceof String) { string = (String) token; - if (string.length() > 0) { + if(string.length() > 0) { jsonobject.accumulate("content", XML.stringToValue(string)); } // Nested element - } else if (token == LT) { - if (parse(x, jsonobject, tagName)) { - if (jsonobject.length() == 0) { + } else if(token == LT) { + if(parse(x, jsonobject, tagName)) { + if(jsonobject.length() == 0) { context.accumulate(tagName, ""); - } else if (jsonobject.length() == 1 && jsonobject.opt("content") != null) { + } else if(jsonobject.length() == 1 && jsonobject.opt("content") != null) { context.accumulate(tagName, jsonobject.opt("content")); } else { context.accumulate(tagName, jsonobject); @@ -297,17 +302,18 @@ public class XML { * convert plus forms, octal forms, hex forms, or E forms lacking decimal * points. * - * @param string A String. + * @param string + * A String. * @return A simple JSON value. */ public static Object stringToValue(String string) { - if ("true".equalsIgnoreCase(string)) { + if("true".equalsIgnoreCase(string)) { return Boolean.TRUE; } - if ("false".equalsIgnoreCase(string)) { + if("false".equalsIgnoreCase(string)) { return Boolean.FALSE; } - if ("null".equalsIgnoreCase(string)) { + if("null".equalsIgnoreCase(string)) { return JSONObject.NULL; } @@ -317,20 +323,20 @@ public class XML { try { char initial = string.charAt(0); - if (initial == '-' || (initial >= '0' && initial <= '9')) { + if(initial == '-' || (initial >= '0' && initial <= '9')) { Long value = Long.valueOf(string); - if (value.toString().equals(string)) { + if(value.toString().equals(string)) { return value; } } - } catch (Exception ignore) { + } catch(Exception ignore) { Iris.reportError(ignore); try { Double value = Double.valueOf(string); - if (value.toString().equals(string)) { + if(value.toString().equals(string)) { return value; } - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); } } @@ -348,13 +354,14 @@ public class XML { * "content" member. Comments, prologs, DTDs, and <[ [ ]]> * are ignored. * - * @param string The source string. + * @param string + * The source string. * @return A JSONObject containing the structured data from the XML string. */ public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); XMLTokener x = new XMLTokener(string); - while (x.more() && x.skipPast("<")) { + while(x.more() && x.skipPast("<")) { parse(x, jo, null); } return jo; @@ -363,7 +370,8 @@ public class XML { /** * Convert a JSONObject into a well-formed, element-normal XML string. * - * @param object A JSONObject. + * @param object + * A JSONObject. * @return A string. */ public static String toString(Object object) throws JSONException { @@ -373,8 +381,10 @@ public class XML { /** * Convert a JSONObject into a well-formed, element-normal XML string. * - * @param object A JSONObject. - * @param tagName The optional name of the enclosing tag. + * @param object + * A JSONObject. + * @param tagName + * The optional name of the enclosing tag. * @return A string. */ public static String toString(Object object, String tagName) throws JSONException { @@ -387,11 +397,11 @@ public class XML { int length; String string; Object value; - if (object instanceof JSONObject) { + if(object instanceof JSONObject) { // Emit - if (tagName != null) { + if(tagName != null) { sb.append('<'); sb.append(tagName); sb.append('>'); @@ -401,22 +411,22 @@ public class XML { jo = (JSONObject) object; keys = jo.keys(); - while (keys.hasNext()) { + while(keys.hasNext()) { key = keys.next(); value = jo.opt(key); - if (value == null) { + if(value == null) { value = ""; } string = value instanceof String ? (String) value : null; // Emit content in body - if ("content".equals(key)) { - if (value instanceof JSONArray) { + if("content".equals(key)) { + if(value instanceof JSONArray) { ja = (JSONArray) value; length = ja.length(); - for (i = 0; i < length; i += 1) { - if (i > 0) { + for(i = 0; i < length; i += 1) { + if(i > 0) { sb.append('\n'); } sb.append(escape(ja.get(i).toString())); @@ -427,12 +437,12 @@ public class XML { // Emit an array of similar keys - } else if (value instanceof JSONArray) { + } else if(value instanceof JSONArray) { ja = (JSONArray) value; length = ja.length(); - for (i = 0; i < length; i += 1) { + for(i = 0; i < length; i += 1) { value = ja.get(i); - if (value instanceof JSONArray) { + if(value instanceof JSONArray) { sb.append('<'); sb.append(key); sb.append('>'); @@ -444,7 +454,7 @@ public class XML { sb.append(toString(value, key)); } } - } else if ("".equals(value)) { + } else if("".equals(value)) { sb.append('<'); sb.append(key); sb.append("/>"); @@ -455,7 +465,7 @@ public class XML { sb.append(toString(value, key)); } } - if (tagName != null) { + if(tagName != null) { // Emit the close tag @@ -470,13 +480,13 @@ public class XML { // where XML is lacking, synthesize an element. } else { - if (object.getClass().isArray()) { + if(object.getClass().isArray()) { object = new JSONArray(object); } - if (object instanceof JSONArray) { + if(object instanceof JSONArray) { ja = (JSONArray) object; length = ja.length(); - for (i = 0; i < length; i += 1) { + for(i = 0; i < length; i += 1) { sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName)); } return sb.toString(); diff --git a/src/main/java/com/volmit/iris/util/json/XMLTokener.java b/src/main/java/com/volmit/iris/util/json/XMLTokener.java index 31fd117fe..49a538aab 100644 --- a/src/main/java/com/volmit/iris/util/json/XMLTokener.java +++ b/src/main/java/com/volmit/iris/util/json/XMLTokener.java @@ -46,7 +46,8 @@ public class XMLTokener extends JSONTokener { /** * Construct an XMLTokener from a string. * - * @param s A source string. + * @param s + * A source string. */ public XMLTokener(String s) { super(s); @@ -56,20 +57,21 @@ public class XMLTokener extends JSONTokener { * Get the text in the CDATA block. * * @return The string up to the ]]>. - * @throws JSONException If the ]]> is not found. + * @throws JSONException + * If the ]]> is not found. */ public String nextCDATA() throws JSONException { char c; int i; StringBuilder sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { c = next(); - if (end()) { + if(end()) { throw syntaxError("Unclosed CDATA"); } sb.append(c); i = sb.length() - 3; - if (i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') { + if(i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') { sb.setLength(i); return sb.toString(); } @@ -89,20 +91,20 @@ public class XMLTokener extends JSONTokener { StringBuilder sb; do { c = next(); - } while (Character.isWhitespace(c)); - if (c == 0) { + } while(Character.isWhitespace(c)); + if(c == 0) { return null; } - if (c == '<') { + if(c == '<') { return XML.LT; } sb = new StringBuilder(); - for (; ; ) { - if (c == '<' || c == 0) { + for(; ; ) { + if(c == '<' || c == 0) { back(); return sb.toString().trim(); } - if (c == '&') { + if(c == '&') { sb.append(nextEntity(c)); } else { sb.append(c); @@ -115,17 +117,19 @@ public class XMLTokener extends JSONTokener { * Return the next entity. These entities are translated to Characters: * & ' > < ". * - * @param ampersand An ampersand character. + * @param ampersand + * An ampersand character. * @return A Character or an entity String if the entity is not recognized. - * @throws JSONException If missing ';' in XML entity. + * @throws JSONException + * If missing ';' in XML entity. */ public Object nextEntity(char ampersand) throws JSONException { StringBuilder sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { char c = next(); - if (Character.isLetterOrDigit(c) || c == '#') { + if(Character.isLetterOrDigit(c) || c == '#') { sb.append(Character.toLowerCase(c)); - } else if (c == ';') { + } else if(c == ';') { break; } else { throw syntaxError("Missing ';' in XML entity: &" + sb); @@ -143,16 +147,17 @@ public class XMLTokener extends JSONTokener { * @return Syntax characters (< > / = ! ?) are returned as * Character, and strings and names are returned as Boolean. We * don't care what the values actually are. - * @throws JSONException If a string is not properly closed or if the XML is badly - * structured. + * @throws JSONException + * If a string is not properly closed or if the XML is badly + * structured. */ public Object nextMeta() throws JSONException { char c; char q; do { c = next(); - } while (Character.isWhitespace(c)); - switch (c) { + } while(Character.isWhitespace(c)); + switch(c) { case 0: throw syntaxError("Misshaped meta tag"); case '<': @@ -170,22 +175,22 @@ public class XMLTokener extends JSONTokener { case '"': case '\'': q = c; - for (; ; ) { + for(; ; ) { c = next(); - if (c == 0) { + if(c == 0) { throw syntaxError("Unterminated string"); } - if (c == q) { + if(c == q) { return Boolean.TRUE; } } default: - for (; ; ) { + for(; ; ) { c = next(); - if (Character.isWhitespace(c)) { + if(Character.isWhitespace(c)) { return Boolean.TRUE; } - switch (c) { + switch(c) { case 0, '<', '>', '/', '=', '!', '?', '"', '\'' -> { back(); return Boolean.TRUE; @@ -201,7 +206,8 @@ public class XMLTokener extends JSONTokener { * string wrapped in single quotes or double quotes, or it may be a name. * * @return a String or a Character. - * @throws JSONException If the XML is not well formed. + * @throws JSONException + * If the XML is not well formed. */ public Object nextToken() throws JSONException { char c; @@ -209,8 +215,8 @@ public class XMLTokener extends JSONTokener { StringBuilder sb; do { c = next(); - } while (Character.isWhitespace(c)); - switch (c) { + } while(Character.isWhitespace(c)); + switch(c) { case 0: throw syntaxError("Misshaped element"); case '<': @@ -232,15 +238,15 @@ public class XMLTokener extends JSONTokener { case '\'': q = c; sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { c = next(); - if (c == 0) { + if(c == 0) { throw syntaxError("Unterminated string"); } - if (c == q) { + if(c == q) { return sb.toString(); } - if (c == '&') { + if(c == '&') { sb.append(nextEntity(c)); } else { sb.append(c); @@ -251,13 +257,13 @@ public class XMLTokener extends JSONTokener { // Name sb = new StringBuilder(); - for (; ; ) { + for(; ; ) { sb.append(c); c = next(); - if (Character.isWhitespace(c)) { + if(Character.isWhitespace(c)) { return sb.toString(); } - switch (c) { + switch(c) { case 0: return sb.toString(); case '>': @@ -282,7 +288,8 @@ public class XMLTokener extends JSONTokener { * Skip characters until past the requested string. If it is not found, we * are left at the end of the source with a result of false. * - * @param to A string to skip past. + * @param to + * A string to skip past. */ public boolean skipPast(String to) throws JSONException { boolean b; @@ -298,9 +305,9 @@ public class XMLTokener extends JSONTokener { * string. If we reach an early end, bail. */ - for (i = 0; i < length; i += 1) { + for(i = 0; i < length; i += 1) { c = next(); - if (c == 0) { + if(c == 0) { return false; } circle[i] = c; @@ -308,26 +315,26 @@ public class XMLTokener extends JSONTokener { /* We will loop, possibly for all of the remaining characters. */ - for (; ; ) { + for(; ; ) { j = offset; b = true; /* Compare the circle buffer with the to string. */ - for (i = 0; i < length; i += 1) { - if (circle[j] != to.charAt(i)) { + for(i = 0; i < length; i += 1) { + if(circle[j] != to.charAt(i)) { b = false; break; } j += 1; - if (j >= length) { + if(j >= length) { j -= length; } } /* If we exit the loop with b intact, then victory is ours. */ - if (b) { + if(b) { return true; } @@ -336,7 +343,7 @@ public class XMLTokener extends JSONTokener { */ c = next(); - if (c == 0) { + if(c == 0) { return false; } /* @@ -345,7 +352,7 @@ public class XMLTokener extends JSONTokener { */ circle[offset] = c; offset += 1; - if (offset >= length) { + if(offset >= length) { offset -= length; } } diff --git a/src/main/java/com/volmit/iris/util/mantle/Mantle.java b/src/main/java/com/volmit/iris/util/mantle/Mantle.java index 7e593927c..c7df6b686 100644 --- a/src/main/java/com/volmit/iris/util/mantle/Mantle.java +++ b/src/main/java/com/volmit/iris/util/mantle/Mantle.java @@ -68,8 +68,10 @@ public class Mantle { /** * Create a new mantle * - * @param dataFolder the data folder - * @param worldHeight the world's height (in blocks) + * @param dataFolder + * the data folder + * @param worldHeight + * the world's height (in blocks) */ @BlockCoordinates public Mantle(File dataFolder, int worldHeight) { @@ -89,9 +91,12 @@ public class Mantle { /** * Get the file for a region * - * @param folder the folder - * @param x the x coord - * @param z the z coord + * @param folder + * the folder + * @param x + * the x coord + * @param z + * the z coord * @return the file */ public static File fileForRegion(File folder, int x, int z) { @@ -101,13 +106,15 @@ public class Mantle { /** * Get the file for the given region * - * @param folder the data folder - * @param key the region key + * @param folder + * the data folder + * @param key + * the region key * @return the file */ public static File fileForRegion(File folder, Long key) { File f = new File(folder, "p." + key + ".ttp"); - if (!f.getParentFile().exists()) { + if(!f.getParentFile().exists()) { f.getParentFile().mkdirs(); } return f; @@ -116,8 +123,10 @@ public class Mantle { /** * Get the long value representing a chunk or region coordinate * - * @param x the x - * @param z the z + * @param x + * the x + * @param z + * the z * @return the value */ public static Long key(int x, int z) { @@ -127,14 +136,18 @@ public class Mantle { /** * Raise a flag if it is lowered currently, If the flag was raised, execute the runnable * - * @param x the chunk x - * @param z the chunk z - * @param flag the flag to raise - * @param r the runnable to fire if the flag is now raised (and was previously lowered) + * @param x + * the chunk x + * @param z + * the chunk z + * @param flag + * the flag to raise + * @param r + * the runnable to fire if the flag is now raised (and was previously lowered) */ @ChunkCoordinates public void raiseFlag(int x, int z, MantleFlag flag, Runnable r) { - if (!hasFlag(x, z, flag)) { + if(!hasFlag(x, z, flag)) { flag(x, z, flag, true); r.run(); } @@ -144,9 +157,12 @@ public class Mantle { * Obtain a cached writer which only contains cached chunks. * This avoids locking on regions when writing to lots of chunks * - * @param x the x chunk - * @param z the z chunk - * @param radius the radius chunks + * @param x + * the x chunk + * @param z + * the z chunk + * @param radius + * the radius chunks * @return the writer */ @ChunkCoordinates @@ -157,14 +173,18 @@ public class Mantle { /** * Lower a flag if it is raised. If the flag was lowered (meaning it was previously raised), execute the runnable * - * @param x the chunk x - * @param z the chunk z - * @param flag the flag to lower - * @param r the runnable that is fired if the flag was raised but is now lowered + * @param x + * the chunk x + * @param z + * the chunk z + * @param flag + * the flag to lower + * @param r + * the runnable that is fired if the flag was raised but is now lowered */ @ChunkCoordinates public void lowerFlag(int x, int z, MantleFlag flag, Runnable r) { - if (hasFlag(x, z, flag)) { + if(hasFlag(x, z, flag)) { flag(x, z, flag, false); r.run(); } @@ -178,10 +198,14 @@ public class Mantle { /** * Flag or unflag a chunk * - * @param x the chunk x - * @param z the chunk z - * @param flag the flag - * @param flagged should it be set to flagged or not + * @param x + * the chunk x + * @param z + * the chunk z + * @param flag + * the flag + * @param flagged + * should it be set to flagged or not */ @ChunkCoordinates public void flag(int x, int z, MantleFlag flag, boolean flagged) { @@ -195,8 +219,10 @@ public class Mantle { /** * Check very quickly if a tectonic plate exists via cached or the file system * - * @param x the x region coordinate - * @param z the z region coordinate + * @param x + * the x region coordinate + * @param z + * the z region coordinate * @return true if it exists */ @RegionCoordinates @@ -208,15 +234,20 @@ public class Mantle { /** * Iterate data in a chunk * - * @param x the chunk x - * @param z the chunk z - * @param type the type of data to iterate - * @param iterator the iterator (x,y,z,data) -> do stuff - * @param the type of data to iterate + * @param x + * the chunk x + * @param z + * the chunk z + * @param type + * the type of data to iterate + * @param iterator + * the iterator (x,y,z,data) -> do stuff + * @param + * the type of data to iterate */ @ChunkCoordinates public void iterateChunk(int x, int z, Class type, Consumer4 iterator) { - if (!hasTectonicPlate(x >> 5, z >> 5)) { + if(!hasTectonicPlate(x >> 5, z >> 5)) { return; } @@ -226,14 +257,17 @@ public class Mantle { /** * Does this chunk have a flag on it? * - * @param x the x - * @param z the z - * @param flag the flag to test + * @param x + * the x + * @param z + * the z + * @param flag + * the flag to test * @return true if it's flagged */ @ChunkCoordinates public boolean hasFlag(int x, int z, MantleFlag flag) { - if (!hasTectonicPlate(x >> 5, z >> 5)) { + if(!hasTectonicPlate(x >> 5, z >> 5)) { return false; } @@ -248,44 +282,49 @@ public class Mantle { * reading & writing other regions. Hyperlocks are slow sync, but in multicore * environments, they drastically speed up loading & saving large counts of plates * - * @param x the block's x coordinate - * @param y the block's y coordinate - * @param z the block's z coordinate - * @param t the data to set at the block - * @param the type of data (generic method) + * @param x + * the block's x coordinate + * @param y + * the block's y coordinate + * @param z + * the block's z coordinate + * @param t + * the data to set at the block + * @param + * the type of data (generic method) */ @BlockCoordinates public void set(int x, int y, int z, T t) { - if (closed.get()) { + if(closed.get()) { throw new RuntimeException("The Mantle is closed"); } - if (y < 0 || y >= worldHeight) { + if(y < 0 || y >= worldHeight) { return; } Matter matter = get((x >> 4) >> 5, (z >> 4) >> 5) - .getOrCreate((x >> 4) & 31, (z >> 4) & 31) - .getOrCreate(y >> 4); + .getOrCreate((x >> 4) & 31, (z >> 4) & 31) + .getOrCreate(y >> 4); matter.slice(matter.getClass(t)) - .set(x & 15, y & 15, z & 15, t); + .set(x & 15, y & 15, z & 15, t); } @BlockCoordinates public void remove(int x, int y, int z, Class t) { - if (closed.get()) { + if(closed.get()) { throw new RuntimeException("The Mantle is closed"); } - if (y < 0 || y >= worldHeight) { + if(y < 0 || y >= worldHeight) { return; } Matter matter = get((x >> 4) >> 5, (z >> 4) >> 5) - .getOrCreate((x >> 4) & 31, (z >> 4) & 31) - .getOrCreate(y >> 4); + .getOrCreate((x >> 4) & 31, (z >> 4) & 31) + .getOrCreate(y >> 4); matter.slice(t) - .set(x & 15, y & 15, z & 15, null); + .set(x & 15, y & 15, z & 15, null); } /** @@ -296,32 +335,37 @@ public class Mantle { * reading & writing other regions. Hyperlocks are slow sync, but in multicore * environments, they drastically speed up loading & saving large counts of plates * - * @param x the block's x coordinate - * @param y the block's y coordinate - * @param z the block's z coordinate - * @param t the class representing the type of data being requested - * @param the type assumed from the provided class + * @param x + * the block's x coordinate + * @param y + * the block's y coordinate + * @param z + * the block's z coordinate + * @param t + * the class representing the type of data being requested + * @param + * the type assumed from the provided class * @return the returned result (or null) if it doesnt exist */ @SuppressWarnings("unchecked") @BlockCoordinates public T get(int x, int y, int z, Class t) { - if (closed.get()) { + if(closed.get()) { throw new RuntimeException("The Mantle is closed"); } - if (!hasTectonicPlate((x >> 4) >> 5, (z >> 4) >> 5)) { + if(!hasTectonicPlate((x >> 4) >> 5, (z >> 4) >> 5)) { return null; } - if (y < 0 || y >= worldHeight) { + if(y < 0 || y >= worldHeight) { return null; } return (T) get((x >> 4) >> 5, (z >> 4) >> 5) - .getOrCreate((x >> 4) & 31, (z >> 4) & 31) - .getOrCreate(y >> 4).slice(t) - .get(x & 15, y & 15, z & 15); + .getOrCreate((x >> 4) & 31, (z >> 4) & 31) + .getOrCreate(y >> 4).slice(t) + .get(x & 15, y & 15, z & 15); } /** @@ -340,17 +384,17 @@ public class Mantle { */ public synchronized void close() { Iris.debug("Closing The Mantle " + C.DARK_AQUA + dataFolder.getAbsolutePath()); - if (closed.get()) { + if(closed.get()) { return; } closed.set(true); BurstExecutor b = ioBurst.burst(loadedRegions.size()); - for (Long i : loadedRegions.keySet()) { + for(Long i : loadedRegions.keySet()) { b.queue(() -> { try { loadedRegions.get(i).write(fileForRegion(dataFolder, i)); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } }); @@ -358,7 +402,7 @@ public class Mantle { try { b.complete(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -370,10 +414,11 @@ public class Mantle { * Save & unload regions that have not been used for more than the * specified amount of milliseconds * - * @param idleDuration the duration + * @param idleDuration + * the duration */ public synchronized void trim(long idleDuration) { - if (closed.get()) { + if(closed.get()) { throw new RuntimeException("The Mantle is closed"); } @@ -381,22 +426,22 @@ public class Mantle { Iris.debug("Trimming Tectonic Plates older than " + Form.duration((double) idleDuration, 0)); unload.clear(); - for (Long i : lastUse.keySet()) { + for(Long i : lastUse.keySet()) { hyperLock.withLong(i, () -> { - if (M.ms() - lastUse.get(i) >= idleDuration) { + if(M.ms() - lastUse.get(i) >= idleDuration) { unload.add(i); } }); } - for (Long i : unload) { + for(Long i : unload) { hyperLock.withLong(i, () -> { TectonicPlate m = loadedRegions.remove(i); lastUse.remove(i); try { m.write(fileForRegion(dataFolder, i)); - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } @@ -410,34 +455,36 @@ public class Mantle { * This retreives a future of the Tectonic Plate at the given coordinates. * All methods accessing tectonic plates should go through this method * - * @param x the region x - * @param z the region z + * @param x + * the region x + * @param z + * the region z * @return the future of a tectonic plate. */ @RegionCoordinates private TectonicPlate get(int x, int z) { - if (io.get()) { + if(io.get()) { try { return getSafe(x, z).get(); - } catch (InterruptedException e) { + } catch(InterruptedException e) { e.printStackTrace(); - } catch (ExecutionException e) { + } catch(ExecutionException e) { e.printStackTrace(); } } TectonicPlate p = loadedRegions.get(key(x, z)); - if (p != null) { + if(p != null) { return p; } try { return getSafe(x, z).get(); - } catch (InterruptedException e) { + } catch(InterruptedException e) { Iris.warn("Failed to get Tectonic Plate " + x + " " + z + " Due to a thread intterruption (hotload?)"); Iris.reportError(e); - } catch (ExecutionException e) { + } catch(ExecutionException e) { Iris.warn("Failed to get Tectonic Plate " + x + " " + z + " Due to a thread execution exception (engine close?)"); Iris.reportError(e); } @@ -450,8 +497,10 @@ public class Mantle { * This retreives a future of the Tectonic Plate at the given coordinates. * All methods accessing tectonic plates should go through this method * - * @param x the region x - * @param z the region z + * @param x + * the region x + * @param z + * the region z * @return the future of a tectonic plate. */ @RegionCoordinates @@ -459,7 +508,7 @@ public class Mantle { Long k = key(x, z); TectonicPlate p = loadedRegions.get(k); - if (p != null) { + if(p != null) { lastUse.put(k, M.ms()); return CompletableFuture.completedFuture(p); } @@ -468,24 +517,24 @@ public class Mantle { lastUse.put(k, M.ms()); TectonicPlate region = loadedRegions.get(k); - if (region != null) { + if(region != null) { return region; } File file = fileForRegion(dataFolder, x, z); - if (file.exists()) { + if(file.exists()) { try { Iris.addPanic("reading.tectonic-plate", file.getAbsolutePath()); region = TectonicPlate.read(worldHeight, file); - if (region.getX() != x || region.getZ() != z) { + if(region.getX() != x || region.getZ() != z) { Iris.warn("Loaded Tectonic Plate " + x + "," + z + " but read it as " + region.getX() + "," + region.getZ() + "... Assuming " + x + "," + z); } loadedRegions.put(k, region); Iris.debug("Loaded Tectonic Plate " + C.DARK_GREEN + x + " " + z + C.DARK_AQUA + " " + file.getName()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead."); Iris.reportError(e); e.printStackTrace(); @@ -526,7 +575,7 @@ public class Mantle { } public void set(int x, int y, int z, MatterSlice slice) { - if (slice.isEmpty()) { + if(slice.isEmpty()) { return; } diff --git a/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java b/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java index f7123e7d3..614d13c68 100644 --- a/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java +++ b/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java @@ -19,7 +19,6 @@ package com.volmit.iris.util.mantle; import com.volmit.iris.Iris; -import com.volmit.iris.engine.EnginePanic; import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.function.Consumer4; import com.volmit.iris.util.matter.IrisMatter; @@ -48,7 +47,8 @@ public class MantleChunk { /** * Create a mantle chunk * - * @param sectionHeight the height of the world in sections (blocks >> 4) + * @param sectionHeight + * the height of the world in sections (blocks >> 4) */ @ChunkCoordinates public MantleChunk(int sectionHeight, int x, int z) { @@ -57,7 +57,7 @@ public class MantleChunk { this.x = x; this.z = z; - for (int i = 0; i < flags.length(); i++) { + for(int i = 0; i < flags.length(); i++) { flags.set(i, 0); } } @@ -65,22 +65,26 @@ public class MantleChunk { /** * Load a mantle chunk from a data stream * - * @param sectionHeight the height of the world in sections (blocks >> 4) - * @param din the data input - * @throws IOException shit happens - * @throws ClassNotFoundException shit happens + * @param sectionHeight + * the height of the world in sections (blocks >> 4) + * @param din + * the data input + * @throws IOException + * shit happens + * @throws ClassNotFoundException + * shit happens */ public MantleChunk(int sectionHeight, DataInputStream din) throws IOException, ClassNotFoundException { this(sectionHeight, din.readByte(), din.readByte()); int s = din.readByte(); - for (int i = 0; i < flags.length(); i++) { + for(int i = 0; i < flags.length(); i++) { flags.set(i, din.readBoolean() ? 1 : 0); } - for (int i = 0; i < s; i++) { + for(int i = 0; i < s; i++) { Iris.addPanic("read.section", "Section[" + i + "]"); - if (din.readBoolean()) { + if(din.readBoolean()) { sections.set(i, Matter.readDin(din)); } } @@ -91,7 +95,7 @@ public class MantleChunk { } public void raiseFlag(MantleFlag flag, Runnable r) { - if (!isFlagged(flag)) { + if(!isFlagged(flag)) { flag(flag, true); r.run(); } @@ -104,7 +108,8 @@ public class MantleChunk { /** * Check if a section exists (same as get(section) != null) * - * @param section the section (0 - (worldHeight >> 4)) + * @param section + * the section (0 - (worldHeight >> 4)) * @return true if it exists */ @ChunkCoordinates @@ -115,7 +120,8 @@ public class MantleChunk { /** * Get thje matter at the given section or null if it doesnt exist * - * @param section the section (0 - (worldHeight >> 4)) + * @param section + * the section (0 - (worldHeight >> 4)) * @return the matter or null if it doesnt exist */ @ChunkCoordinates @@ -127,7 +133,7 @@ public class MantleChunk { * Clear all matter from this chunk */ public void clear() { - for (int i = 0; i < sections.length(); i++) { + for(int i = 0; i < sections.length(); i++) { delete(i); } } @@ -135,7 +141,8 @@ public class MantleChunk { /** * Delete the matter from the given section * - * @param section the section (0 - (worldHeight >> 4)) + * @param section + * the section (0 - (worldHeight >> 4)) */ @ChunkCoordinates public void delete(int section) { @@ -145,14 +152,15 @@ public class MantleChunk { /** * Get or create a new matter section at the given section * - * @param section the section (0 - (worldHeight >> 4)) + * @param section + * the section (0 - (worldHeight >> 4)) * @return the matter */ @ChunkCoordinates public Matter getOrCreate(int section) { Matter matter = get(section); - if (matter == null) { + if(matter == null) { matter = new IrisMatter(16, 16, 16); sections.set(section, matter); } @@ -163,22 +171,24 @@ public class MantleChunk { /** * Write this chunk to a data stream * - * @param dos the stream - * @throws IOException shit happens + * @param dos + * the stream + * @throws IOException + * shit happens */ public void write(DataOutputStream dos) throws IOException { dos.writeByte(x); dos.writeByte(z); dos.writeByte(sections.length()); - for (int i = 0; i < flags.length(); i++) { + for(int i = 0; i < flags.length(); i++) { dos.writeBoolean(flags.get(i) == 1); } - for (int i = 0; i < sections.length(); i++) { + for(int i = 0; i < sections.length(); i++) { trimSlice(i); - if (exists(i)) { + if(exists(i)) { dos.writeBoolean(true); Matter matter = get(i); matter.writeDos(dos); @@ -189,14 +199,14 @@ public class MantleChunk { } private void trimSlice(int i) { - if (exists(i)) { + if(exists(i)) { Matter m = get(i); - if (m.getSliceMap().isEmpty()) { + if(m.getSliceMap().isEmpty()) { sections.set(i, null); } else { m.trimSlices(); - if (m.getSliceMap().isEmpty()) { + if(m.getSliceMap().isEmpty()) { sections.set(i, null); } } @@ -204,14 +214,14 @@ public class MantleChunk { } public void iterate(Class type, Consumer4 iterator) { - for (int i = 0; i < sections.length(); i++) { + for(int i = 0; i < sections.length(); i++) { int bs = (i << 4); Matter matter = get(i); - if (matter != null) { + if(matter != null) { MatterSlice t = matter.getSlice(type); - if (t != null) { + if(t != null) { t.iterateSync((a, b, c, f) -> iterator.accept(a, b + bs, c, f)); } } @@ -219,17 +229,17 @@ public class MantleChunk { } public void deleteSlices(Class c) { - for (int i = 0; i < sections.length(); i++) { + for(int i = 0; i < sections.length(); i++) { Matter m = sections.get(i); - if (m != null && m.hasSlice(c)) { + if(m != null && m.hasSlice(c)) { m.deleteSlice(c); } } } public void trimSlices() { - for (int i = 0; i < sections.length(); i++) { - if (exists(i)) { + for(int i = 0; i < sections.length(); i++) { + if(exists(i)) { trimSlice(i); } } diff --git a/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java b/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java index d404710a6..11950adc5 100644 --- a/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java +++ b/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java @@ -54,7 +54,8 @@ public class TectonicPlate { /** * Create a new tectonic plate * - * @param worldHeight the height of the world + * @param worldHeight + * the height of the world */ public TectonicPlate(int worldHeight, int x, int z) { this.sectionHeight = worldHeight >> 4; @@ -66,15 +67,19 @@ public class TectonicPlate { /** * Load a tectonic plate from a data stream * - * @param worldHeight the height of the world - * @param din the data input - * @throws IOException shit happens yo - * @throws ClassNotFoundException real shit bro + * @param worldHeight + * the height of the world + * @param din + * the data input + * @throws IOException + * shit happens yo + * @throws ClassNotFoundException + * real shit bro */ public TectonicPlate(int worldHeight, DataInputStream din) throws IOException, ClassNotFoundException { this(worldHeight, din.readInt(), din.readInt()); - for (int i = 0; i < chunks.length(); i++) { - if (din.readBoolean()) { + for(int i = 0; i < chunks.length(); i++) { + if(din.readBoolean()) { Iris.addPanic("read-chunk", "Chunk[" + i + "]"); chunks.set(i, new MantleChunk(sectionHeight, din)); EnginePanic.saveLast(); @@ -95,8 +100,10 @@ public class TectonicPlate { /** * Check if a chunk exists in this plate or not (same as get(x, z) != null) * - * @param x the chunk relative x (0-31) - * @param z the chunk relative z (0-31) + * @param x + * the chunk relative x (0-31) + * @param z + * the chunk relative z (0-31) * @return true if the chunk exists */ @ChunkCoordinates @@ -107,8 +114,10 @@ public class TectonicPlate { /** * Get a chunk at the given coordinates or null if it doesnt exist * - * @param x the chunk relative x (0-31) - * @param z the chunk relative z (0-31) + * @param x + * the chunk relative x (0-31) + * @param z + * the chunk relative z (0-31) * @return the chunk or null if it doesnt exist */ @ChunkCoordinates @@ -120,7 +129,7 @@ public class TectonicPlate { * Clear all chunks from this tectonic plate */ public void clear() { - for (int i = 0; i < chunks.length(); i++) { + for(int i = 0; i < chunks.length(); i++) { chunks.set(i, null); } } @@ -128,8 +137,10 @@ public class TectonicPlate { /** * Delete a chunk from this tectonic plate * - * @param x the chunk relative x (0-31) - * @param z the chunk relative z (0-31) + * @param x + * the chunk relative x (0-31) + * @param z + * the chunk relative z (0-31) */ @ChunkCoordinates public void delete(int x, int z) { @@ -139,15 +150,17 @@ public class TectonicPlate { /** * Get a tectonic plate, or create one and insert it & return it if it diddnt exist * - * @param x the chunk relative x (0-31) - * @param z the chunk relative z (0-31) + * @param x + * the chunk relative x (0-31) + * @param z + * the chunk relative z (0-31) * @return the chunk (read or created & inserted) */ @ChunkCoordinates public MantleChunk getOrCreate(int x, int z) { MantleChunk chunk = get(x, z); - if (chunk == null) { + if(chunk == null) { chunk = new MantleChunk(sectionHeight, x & 31, z & 31); chunks.set(index(x, z), chunk); } @@ -163,8 +176,10 @@ public class TectonicPlate { /** * Write this tectonic plate to file * - * @param file the file to writeNodeData it to - * @throws IOException shit happens + * @param file + * the file to writeNodeData it to + * @throws IOException + * shit happens */ public void write(File file) throws IOException { PrecisionStopwatch p = PrecisionStopwatch.start(); @@ -179,17 +194,19 @@ public class TectonicPlate { /** * Write this tectonic plate to a data stream * - * @param dos the data output - * @throws IOException shit happens + * @param dos + * the data output + * @throws IOException + * shit happens */ public void write(DataOutputStream dos) throws IOException { dos.writeInt(x); dos.writeInt(z); - for (int i = 0; i < chunks.length(); i++) { + for(int i = 0; i < chunks.length(); i++) { MantleChunk chunk = chunks.get(i); - if (chunk != null) { + if(chunk != null) { dos.writeBoolean(true); chunk.write(dos); } else { diff --git a/src/main/java/com/volmit/iris/util/math/Average.java b/src/main/java/com/volmit/iris/util/math/Average.java index d68d6c0c4..125f57873 100644 --- a/src/main/java/com/volmit/iris/util/math/Average.java +++ b/src/main/java/com/volmit/iris/util/math/Average.java @@ -38,7 +38,8 @@ public class Average { /** * Create an average holder * - * @param size the size of entries to keep + * @param size + * the size of entries to keep */ public Average(int size) { values = new double[size]; @@ -53,13 +54,14 @@ public class Average { /** * Put a value into the average (rolls over if full) * - * @param i the value + * @param i + * the value */ public void put(double i) { dirty = true; - if (brandNew) { + if(brandNew) { DoubleArrayUtils.fill(values, i); lastSum = size() * i; brandNew = false; @@ -78,7 +80,7 @@ public class Average { * @return the average */ public double getAverage() { - if (dirty) { + if(dirty) { calculateAverage(); return getAverage(); } diff --git a/src/main/java/com/volmit/iris/util/math/BlockPosition.java b/src/main/java/com/volmit/iris/util/math/BlockPosition.java index 3d8a886ff..743d245e4 100644 --- a/src/main/java/com/volmit/iris/util/math/BlockPosition.java +++ b/src/main/java/com/volmit/iris/util/math/BlockPosition.java @@ -57,11 +57,11 @@ public class BlockPosition { } public boolean equals(Object o) { - if (o == null) { + if(o == null) { return false; } - if (o instanceof BlockPosition ot) { + if(o instanceof BlockPosition ot) { return ot.x == x && ot.y == y && ot.z == z; } diff --git a/src/main/java/com/volmit/iris/util/math/CDou.java b/src/main/java/com/volmit/iris/util/math/CDou.java index 2cce3ab4c..4d449d905 100644 --- a/src/main/java/com/volmit/iris/util/math/CDou.java +++ b/src/main/java/com/volmit/iris/util/math/CDou.java @@ -51,7 +51,7 @@ public class CDou { } public void circ() { - if (number < 0) { + if(number < 0) { number = max - (Math.abs(number) > max ? max : Math.abs(number)); } diff --git a/src/main/java/com/volmit/iris/util/math/Direction.java b/src/main/java/com/volmit/iris/util/math/Direction.java index 103495c1b..ed9559d6b 100644 --- a/src/main/java/com/volmit/iris/util/math/Direction.java +++ b/src/main/java/com/volmit/iris/util/math/Direction.java @@ -56,7 +56,7 @@ public enum Direction { } public static Direction getDirection(BlockFace f) { - return switch (f) { + return switch(f) { case DOWN -> D; case EAST, EAST_SOUTH_EAST, EAST_NORTH_EAST -> E; case NORTH, NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST, NORTH_EAST -> N; @@ -71,11 +71,11 @@ public enum Direction { double m = Double.MAX_VALUE; Direction s = null; - for (Direction i : values()) { + for(Direction i : values()) { Vector x = i.toVector(); double g = x.dot(v); - if (g < m) { + if(g < m) { m = g; s = i; } @@ -88,11 +88,11 @@ public enum Direction { double m = Double.MAX_VALUE; Direction s = null; - for (Direction i : d) { + for(Direction i : d) { Vector x = i.toVector(); double g = x.distance(v); - if (g < m) { + if(g < m) { m = g; s = i; } @@ -105,11 +105,11 @@ public enum Direction { double m = Double.MAX_VALUE; Direction s = null; - for (Direction i : d) { + for(Direction i : d) { Vector x = i.toVector(); double g = x.distance(v); - if (g < m) { + if(g < m) { m = g; s = i; } @@ -125,8 +125,8 @@ public enum Direction { public static Direction getDirection(Vector v) { Vector k = VectorMath.triNormalize(v.clone().normalize()); - for (Direction i : udnews()) { - if (i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) { + for(Direction i : udnews()) { + if(i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) { return i; } } @@ -142,24 +142,25 @@ public enum Direction { * Get the directional value from the given byte from common directional blocks * (MUST BE BETWEEN 0 and 5 INCLUSIVE) * - * @param b the byte + * @param b + * the byte * @return the direction or null if the byte is outside of the inclusive range * 0-5 */ public static Direction fromByte(byte b) { - if (b > 5 || b < 0) { + if(b > 5 || b < 0) { return null; } - if (b == 0) { + if(b == 0) { return D; - } else if (b == 1) { + } else if(b == 1) { return U; - } else if (b == 2) { + } else if(b == 2) { return N; - } else if (b == 3) { + } else if(b == 3) { return S; - } else if (b == 4) { + } else if(b == 4) { return W; } else { return E; @@ -167,25 +168,25 @@ public enum Direction { } public static void calculatePermutations() { - if (permute != null) { + if(permute != null) { return; } permute = new KMap<>(); - for (Direction i : udnews()) { - for (Direction j : udnews()) { + for(Direction i : udnews()) { + for(Direction j : udnews()) { GBiset b = new GBiset<>(i, j); - if (i.equals(j)) { + if(i.equals(j)) { permute.put(b, new DOP("DIRECT") { @Override public Vector op(Vector v) { return v; } }); - } else if (i.reverse().equals(j)) { - if (i.isVertical()) { + } else if(i.reverse().equals(j)) { + if(i.isVertical()) { permute.put(b, new DOP("R180CCZ") { @Override public Vector op(Vector v) { @@ -200,42 +201,42 @@ public enum Direction { } }); } - } else if (getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CX") { @Override public Vector op(Vector v) { return VectorMath.rotate90CX(v); } }); - } else if (getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CCX") { @Override public Vector op(Vector v) { return VectorMath.rotate90CCX(v); } }); - } else if (getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CY") { @Override public Vector op(Vector v) { return VectorMath.rotate90CY(v); } }); - } else if (getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CCY") { @Override public Vector op(Vector v) { return VectorMath.rotate90CCY(v); } }); - } else if (getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CZ") { @Override public Vector op(Vector v) { return VectorMath.rotate90CZ(v); } }); - } else if (getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) { + } else if(getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) { permute.put(b, new DOP("R90CCZ") { @Override public Vector op(Vector v) { @@ -256,7 +257,7 @@ public enum Direction { @Override public String toString() { - return switch (this) { + return switch(this) { case D -> "Down"; case E -> "East"; case N -> "North"; @@ -276,7 +277,7 @@ public enum Direction { } public boolean isCrooked(Direction to) { - if (equals(to.reverse())) { + if(equals(to.reverse())) { return false; } @@ -286,9 +287,9 @@ public enum Direction { public Vector angle(Vector initial, Direction d) { calculatePermutations(); - for (Map.Entry, DOP> entry : permute.entrySet()) { + for(Map.Entry, DOP> entry : permute.entrySet()) { GBiset i = entry.getKey(); - if (i.getA().equals(this) && i.getB().equals(d)) { + if(i.getA().equals(this) && i.getB().equals(d)) { return entry.getValue().op(initial); } } @@ -297,7 +298,7 @@ public enum Direction { } public Direction reverse() { - switch (this) { + switch(this) { case D: return U; case E: @@ -339,7 +340,7 @@ public enum Direction { * @return the byte value */ public byte byteValue() { - switch (this) { + switch(this) { case D: return 0; case E: @@ -360,7 +361,7 @@ public enum Direction { } public BlockFace getFace() { - return switch (this) { + return switch(this) { case D -> BlockFace.DOWN; case E -> BlockFace.EAST; case N -> BlockFace.NORTH; @@ -372,7 +373,7 @@ public enum Direction { } public Axis getAxis() { - return switch (this) { + return switch(this) { case D, U -> Axis.Y; case E, W -> Axis.X; case N, S -> Axis.Z; diff --git a/src/main/java/com/volmit/iris/util/math/FinalInteger.java b/src/main/java/com/volmit/iris/util/math/FinalInteger.java index 59da2d41f..adb5b076c 100644 --- a/src/main/java/com/volmit/iris/util/math/FinalInteger.java +++ b/src/main/java/com/volmit/iris/util/math/FinalInteger.java @@ -33,7 +33,8 @@ public class FinalInteger extends Wrapper { /** * Add to this value * - * @param i the number to add to this value (value = value + i) + * @param i + * the number to add to this value (value = value + i) */ public void add(int i) { set(get() + i); @@ -42,7 +43,8 @@ public class FinalInteger extends Wrapper { /** * Subtract from this value * - * @param i the number to subtract from this value (value = value - i) + * @param i + * the number to subtract from this value (value = value - i) */ public void sub(int i) { set(get() - i); diff --git a/src/main/java/com/volmit/iris/util/math/IrisMathHelper.java b/src/main/java/com/volmit/iris/util/math/IrisMathHelper.java index b26ac688f..4b1c2e754 100644 --- a/src/main/java/com/volmit/iris/util/math/IrisMathHelper.java +++ b/src/main/java/com/volmit/iris/util/math/IrisMathHelper.java @@ -33,11 +33,11 @@ public class IrisMathHelper { static { a = c(2.0f); c = new Random(); - d = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; + d = new int[] {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; e = Double.longBitsToDouble(4805340802404319232L); f = new double[257]; g = new double[257]; - for (int var2 = 0; var2 < 257; ++var2) { + for(int var2 = 0; var2 < 257; ++var2) { final double var3 = var2 / 256.0; final double var4 = Math.asin(var3); IrisMathHelper.g[var2] = Math.cos(var4); @@ -87,41 +87,41 @@ public class IrisMathHelper { } public static int clamp(final int var0, final int var1, final int var2) { - if (var0 < var1) { + if(var0 < var1) { return var1; } return Math.min(var0, var2); } public static float a(final float var0, final float var1, final float var2) { - if (var0 < var1) { + if(var0 < var1) { return var1; } return Math.min(var0, var2); } public static double a(final double var0, final double var2, final double var4) { - if (var0 < var2) { + if(var0 < var2) { return var2; } return Math.min(var0, var4); } public static double b(final double var0, final double var2, final double var4) { - if (var4 < 0.0) { + if(var4 < 0.0) { return var0; } - if (var4 > 1.0) { + if(var4 > 1.0) { return var2; } return d(var4, var0, var2); } public static double a(double var0, double var2) { - if (var0 < 0.0) { + if(var0 < 0.0) { var0 = -var0; } - if (var2 < 0.0) { + if(var2 < 0.0) { var2 = -var2; } return Math.max(var0, var2); @@ -132,21 +132,21 @@ public class IrisMathHelper { } public static int nextInt(final Random var0, final int var1, final int var2) { - if (var1 >= var2) { + if(var1 >= var2) { return var1; } return var0.nextInt(var2 - var1 + 1) + var1; } public static float a(final Random var0, final float var1, final float var2) { - if (var1 >= var2) { + if(var1 >= var2) { return var1; } return var0.nextFloat() * (var2 - var1) + var1; } public static double a(final Random var0, final double var1, final double var3) { - if (var1 >= var3) { + if(var1 >= var3) { return var1; } return var0.nextDouble() * (var3 - var1) + var1; @@ -154,7 +154,7 @@ public class IrisMathHelper { public static double a(final long[] var0) { long var = 0L; - for (final long var2 : var0) { + for(final long var2 : var0) { var += var2; } return var / (double) var0.length; @@ -170,10 +170,10 @@ public class IrisMathHelper { public static float g(final float var0) { float var = var0 % 360.0f; - if (var >= 180.0f) { + if(var >= 180.0f) { var -= 360.0f; } - if (var < -180.0f) { + if(var < -180.0f) { var += 360.0f; } return var; @@ -181,10 +181,10 @@ public class IrisMathHelper { public static double g(final double var0) { double var = var0 % 360.0; - if (var >= 180.0) { + if(var >= 180.0) { var -= 360.0; } - if (var < -180.0) { + if(var < -180.0) { var += 360.0; } return var; @@ -206,7 +206,7 @@ public class IrisMathHelper { public static float c(final float var0, final float var1, float var2) { var2 = e(var2); - if (var0 < var1) { + if(var0 < var1) { return a(var0 + var2, var0, var1); } return a(var0 - var2, var1, var0); @@ -241,17 +241,17 @@ public class IrisMathHelper { } public static int c(final int var0, int var1) { - if (var1 == 0) { + if(var1 == 0) { return 0; } - if (var0 == 0) { + if(var0 == 0) { return var1; } - if (var0 < 0) { + if(var0 < 0) { var1 *= -1; } final int var2 = var0 % var1; - if (var2 == 0) { + if(var2 == 0) { return var0; } return var0 + var1 - var2; @@ -287,19 +287,19 @@ public class IrisMathHelper { public static double d(double var0, double var2) { final double var3 = var2 * var2 + var0 * var0; - if (Double.isNaN(var3)) { + if(Double.isNaN(var3)) { return Double.NaN; } final boolean var4 = var0 < 0.0; - if (var4) { + if(var4) { var0 = -var0; } final boolean var5 = var2 < 0.0; - if (var5) { + if(var5) { var2 = -var2; } final boolean var6 = var0 > var2; - if (var6) { + if(var6) { final double var7 = var2; var2 = var0; var0 = var7; @@ -315,13 +315,13 @@ public class IrisMathHelper { final double var13 = var0 * var11 - var2 * var12; final double var14 = (6.0 + var13 * var13) * var13 * 0.16666666666666666; double var15 = var10 + var14; - if (var6) { + if(var6) { var15 = 1.5707963267948966 - var15; } - if (var5) { + if(var5) { var15 = 3.141592653589793 - var15; } - if (var4) { + if(var4) { var15 = -var15; } return var15; @@ -345,7 +345,7 @@ public class IrisMathHelper { float var8 = 0.0f; float var9 = 0.0f; float var10 = 0.0f; - switch (var3) { + switch(var3) { case 0 -> { var8 = var2; var9 = var7; @@ -397,10 +397,10 @@ public class IrisMathHelper { public static int a(int var0, final int var1, final IntPredicate var2) { int var3 = var1 - var0; - while (var3 > 0) { + while(var3 > 0) { final int var4 = var3 / 2; final int var5 = var0 + var4; - if (var2.test(var5)) { + if(var2.test(var5)) { var3 = var4; } else { var0 = var5 + 1; @@ -431,7 +431,7 @@ public class IrisMathHelper { } public static int k(final double var0) { - if (var0 == 0.0) { + if(var0 == 0.0) { return 0; } return (var0 > 0.0) ? 1 : -1; @@ -440,9 +440,9 @@ public class IrisMathHelper { @Deprecated public static float j(final float var0, final float var1, final float var2) { float var3; - for (var3 = var1 - var0; var3 < -180.0f; var3 += 360.0f) { + for(var3 = var1 - var0; var3 < -180.0f; var3 += 360.0f) { } - while (var3 >= 180.0f) { + while(var3 >= 180.0f) { var3 -= 360.0f; } return var0 + var2 * var3; diff --git a/src/main/java/com/volmit/iris/util/math/KochanekBartelsInterpolation.java b/src/main/java/com/volmit/iris/util/math/KochanekBartelsInterpolation.java index ba0b2190f..57c9ccce8 100644 --- a/src/main/java/com/volmit/iris/util/math/KochanekBartelsInterpolation.java +++ b/src/main/java/com/volmit/iris/util/math/KochanekBartelsInterpolation.java @@ -49,7 +49,7 @@ public class KochanekBartelsInterpolation implements PathInterpolation { coeffC = new Vector[nNodes]; coeffD = new Vector[nNodes]; - if (nNodes == 0) { + if(nNodes == 0) { return; } @@ -57,12 +57,12 @@ public class KochanekBartelsInterpolation implements PathInterpolation { double tensionB = nodeB.getTension(); double biasB = nodeB.getBias(); double continuityB = nodeB.getContinuity(); - for (int i = 0; i < nNodes; ++i) { + for(int i = 0; i < nNodes; ++i) { final double tensionA = tensionB; final double biasA = biasB; final double continuityA = continuityB; - if (i + 1 < nNodes) { + if(i + 1 < nNodes) { nodeB = nodes.get(i + 1); tensionB = nodeB.getTension(); biasB = nodeB.getBias(); @@ -88,11 +88,16 @@ public class KochanekBartelsInterpolation implements PathInterpolation { /** * Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex. * - * @param baseIndex node index - * @param f1 coefficient for baseIndex-1 - * @param f2 coefficient for baseIndex - * @param f3 coefficient for baseIndex+1 - * @param f4 coefficient for baseIndex+2 + * @param baseIndex + * node index + * @param f1 + * coefficient for baseIndex-1 + * @param f2 + * coefficient for baseIndex + * @param f3 + * coefficient for baseIndex+1 + * @param f4 + * coefficient for baseIndex+2 * @return linear combination of nodes[n-1..n+2] with f1..4 */ private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) { @@ -107,15 +112,16 @@ public class KochanekBartelsInterpolation implements PathInterpolation { /** * Retrieves a node. Indexes are clamped to the valid range. * - * @param index node index to retrieve + * @param index + * node index to retrieve * @return nodes[clamp(0, nodes.length - 1)] */ private Vector retrieve(int index) { - if (index < 0) { + if(index < 0) { return fastRetrieve(0); } - if (index >= nodes.size()) { + if(index >= nodes.size()) { return fastRetrieve(nodes.size() - 1); } @@ -128,11 +134,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation { @Override public Vector getPosition(double position) { - if (coeffA == null) { + if(coeffA == null) { throw new IllegalStateException("Must call setNodes first."); } - if (position > 1) { + if(position > 1) { return null; } @@ -151,11 +157,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation { @Override public Vector get1stDerivative(double position) { - if (coeffA == null) { + if(coeffA == null) { throw new IllegalStateException("Must call setNodes first."); } - if (position > 1) { + if(position > 1) { return null; } @@ -173,11 +179,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation { @Override public double arcLength(double positionA, double positionB) { - if (coeffA == null) { + if(coeffA == null) { throw new IllegalStateException("Must call setNodes first."); } - if (positionA > positionB) { + if(positionA > positionB) { return arcLength(positionB, positionA); } @@ -197,18 +203,18 @@ public class KochanekBartelsInterpolation implements PathInterpolation { * Assumes a < b. */ private double arcLengthRecursive(int indexLeft, double remainderLeft, int indexRight, double remainderRight) { - switch (indexRight - indexLeft) { + switch(indexRight - indexLeft) { case 0: return arcLengthRecursive(indexLeft, remainderLeft, remainderRight); case 1: // This case is merely a speed-up for a very common case return arcLengthRecursive(indexLeft, remainderLeft, 1.0) - + arcLengthRecursive(indexRight, 0.0, remainderRight); + + arcLengthRecursive(indexRight, 0.0, remainderRight); default: return arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0) - + arcLengthRecursive(indexRight, 0.0, remainderRight); + + arcLengthRecursive(indexRight, 0.0, remainderRight); } } @@ -220,7 +226,7 @@ public class KochanekBartelsInterpolation implements PathInterpolation { final int nPoints = 8; double accum = a.multiply(remainderLeft).add(b).multiply(remainderLeft).add(c).length() / 2.0; - for (int i = 1; i < nPoints - 1; ++i) { + for(int i = 1; i < nPoints - 1; ++i) { double t = ((double) i) / nPoints; t = (remainderRight - remainderLeft) * t + remainderLeft; accum += a.multiply(t).add(b).multiply(t).add(c).length(); @@ -232,11 +238,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation { @Override public int getSegment(double position) { - if (coeffA == null) { + if(coeffA == null) { throw new IllegalStateException("Must call setNodes first."); } - if (position > 1) { + if(position > 1) { return Integer.MAX_VALUE; } diff --git a/src/main/java/com/volmit/iris/util/math/M.java b/src/main/java/com/volmit/iris/util/math/M.java index 6e25a5571..3277eb808 100644 --- a/src/main/java/com/volmit/iris/util/math/M.java +++ b/src/main/java/com/volmit/iris/util/math/M.java @@ -35,7 +35,7 @@ public class M { public static int tick = 0; static { - for (int i = 0; i < sin.length; i++) { + for(int i = 0; i < sin.length; i++) { sin[i] = (float) Math.sin((i * Math.PI) / (precision * 180)); } } @@ -52,11 +52,16 @@ public class M { *
* would return 10 * - * @param amin the resulting minimum - * @param amax the resulting maximum - * @param bmin the initial minimum - * @param bmax the initial maximum - * @param b the initial value + * @param amin + * the resulting minimum + * @param amax + * the resulting maximum + * @param bmin + * the initial minimum + * @param bmax + * the initial maximum + * @param b + * the initial value * @return the resulting value */ public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) { @@ -68,9 +73,12 @@ public class M { *

* If from = 0 and to = 100 and at = 25 then it would return 0.25 * - * @param from the from - * @param to the to - * @param at the at + * @param from + * the from + * @param to + * the to + * @param at + * the at * @return the percent */ public static double lerpInverse(double from, double to, double at) { @@ -80,9 +88,12 @@ public class M { /** * Linear interpolation from a to b where f is the percent across * - * @param a the first pos (0) - * @param b the second pos (1) - * @param f the percent + * @param a + * the first pos (0) + * @param b + * the second pos (1) + * @param f + * the percent * @return the value */ public static double lerp(double a, double b, double f) { @@ -92,10 +103,14 @@ public class M { /** * Bilinear interpolation * - * @param a the first point (0, 0) - * @param b the second point (1, 0) - * @param c the third point (0, 1) - * @param d the fourth point (1, 1) + * @param a + * the first point (0, 0) + * @param b + * the second point (1, 0) + * @param c + * the third point (0, 1) + * @param d + * the fourth point (1, 1) * @return the bilerped value */ public static double bilerp(double a, double b, double c, double d, double x, double y) { @@ -105,17 +120,28 @@ public class M { /** * Trilinear interpolation * - * @param a the first point (0, 0, 0) - * @param b the second point (1, 0, 0) - * @param c the third point (0, 0, 1) - * @param d the fourth point (1, 0, 1) - * @param e the fifth point (0, 1, 0) - * @param f the sixth point (1, 1, 0) - * @param g the seventh point (0, 1, 1) - * @param h the eighth point (1, 1, 1) - * @param x the x - * @param y the y - * @param z the z + * @param a + * the first point (0, 0, 0) + * @param b + * the second point (1, 0, 0) + * @param c + * the third point (0, 0, 1) + * @param d + * the fourth point (1, 0, 1) + * @param e + * the fifth point (0, 1, 0) + * @param f + * the sixth point (1, 1, 0) + * @param g + * the seventh point (0, 1, 1) + * @param h + * the eighth point (1, 1, 1) + * @param x + * the x + * @param y + * the y + * @param z + * the z * @return the trilerped value */ public static double trilerp(double a, double b, double c, double d, double e, double f, double g, double h, double x, double y, double z) { @@ -125,9 +151,12 @@ public class M { /** * Clip a value * - * @param value the value - * @param min the min - * @param max the max + * @param value + * the value + * @param min + * the min + * @param max + * the max * @return the clipped value */ @SuppressWarnings("unchecked") @@ -138,12 +167,13 @@ public class M { /** * Get true or false based on random percent * - * @param d between 0 and 1 + * @param d + * between 0 and 1 * @return true if true */ public static boolean r(Double d) { //noinspection ReplaceNullCheck - if (d == null) { + if(d == null) { return Math.random() < 0.5; } @@ -154,8 +184,10 @@ public class M { * Get the ticks per second from a time in nanoseconds, the rad can be used for * multiple ticks * - * @param ns the time in nanoseconds - * @param rad the radius of the time + * @param ns + * the time in nanoseconds + * @param rad + * the radius of the time * @return the ticks per second in double form */ public static double tps(long ns, int rad) { @@ -165,7 +197,8 @@ public class M { /** * Get the number of ticks from a time in nanoseconds * - * @param ns the nanoseconds + * @param ns + * the nanoseconds * @return the amount of ticks */ public static double ticksFromNS(long ns) { @@ -175,8 +208,10 @@ public class M { /** * Get a random int from to (inclusive) * - * @param f the from - * @param t the to + * @param f + * the from + * @param t + * the to * @return the value */ public static int irand(int f, int t) { @@ -186,8 +221,10 @@ public class M { /** * Get a random float from to (inclusive) * - * @param f the from - * @param t the to + * @param f + * the from + * @param t + * the to * @return the value */ public static float frand(float f, float t) { @@ -197,8 +234,10 @@ public class M { /** * Get a random double from to (inclusive) * - * @param f the from - * @param t the to + * @param f + * the from + * @param t + * the to * @return the value */ public static double drand(double f, double t) { @@ -226,7 +265,8 @@ public class M { /** * Fast sin function * - * @param a the number + * @param a + * the number * @return the sin */ public static float sin(float a) { @@ -236,7 +276,8 @@ public class M { /** * Fast cos function * - * @param a the number + * @param a + * the number * @return the cos */ public static float cos(float a) { @@ -246,7 +287,8 @@ public class M { /** * Fast tan function * - * @param a the number + * @param a + * the number * @return the tan */ public static float tan(float a) { @@ -263,8 +305,8 @@ public class M { public static T max(T... doubles) { double max = Double.MIN_VALUE; - for (T i : doubles) { - if (i.doubleValue() > max) { + for(T i : doubles) { + if(i.doubleValue() > max) { max = i.doubleValue(); } } @@ -275,15 +317,16 @@ public class M { /** * Smallest number * - * @param doubles the numbers + * @param doubles + * the numbers * @return the smallest one */ @SuppressWarnings("unchecked") public static T min(T... doubles) { double min = Double.MAX_VALUE; - for (T i : doubles) { - if (i.doubleValue() < min) { + for(T i : doubles) { + if(i.doubleValue() < min) { min = i.doubleValue(); } } @@ -298,17 +341,21 @@ public class M { * makes the expression (4x1)/2 == 2. Keep note that you must use 0-9, you * cannot skip, or start at a number other than 0. * - * @param expression the expression with variables - * @param args the arguments/variables + * @param expression + * the expression with variables + * @param args + * the arguments/variables * @return the resulting double value - * @throws ScriptException ... gg - * @throws IndexOutOfBoundsException learn to count + * @throws ScriptException + * ... gg + * @throws IndexOutOfBoundsException + * learn to count */ public static double evaluate(String expression, Double... args) throws ScriptException, IndexOutOfBoundsException { - for (int i = 0; i < args.length; i++) { + for(int i = 0; i < args.length; i++) { String current = "$" + i; - if (expression.contains(current)) { + if(expression.contains(current)) { expression = expression.replaceAll(Matcher.quoteReplacement(current), args[i] + ""); } } @@ -319,9 +366,11 @@ public class M { /** * Evaluates an expression using javascript engine and returns the double * - * @param expression the mathimatical expression + * @param expression + * the mathimatical expression * @return the double result - * @throws ScriptException ... gg + * @throws ScriptException + * ... gg */ public static double evaluate(String expression) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManager(); @@ -333,9 +382,12 @@ public class M { /** * is the number "is" within from-to * - * @param from the lower end - * @param to the upper end - * @param is the check + * @param from + * the lower end + * @param to + * the upper end + * @param is + * the check * @return true if its within */ public static boolean within(int from, int to, int is) { @@ -354,7 +406,8 @@ public class M { /** * Get the amount of days past since the epoch time (1970 jan 1 utc) * - * @param ms the time in milliseconds + * @param ms + * the time in milliseconds * @return the epoch days */ private static long epochDays(long ms) { diff --git a/src/main/java/com/volmit/iris/util/math/MathHelper.java b/src/main/java/com/volmit/iris/util/math/MathHelper.java index 74960cbe2..5709c1377 100644 --- a/src/main/java/com/volmit/iris/util/math/MathHelper.java +++ b/src/main/java/com/volmit/iris/util/math/MathHelper.java @@ -38,7 +38,7 @@ public class MathHelper { private static final long m = -9223372036854775808L; private static final float n = 10430.378F; private static final Random p = new Random(); - private static final int[] q = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; + private static final int[] q = new int[] {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; private static final double r = 0.16666666666666666D; private static final int s = 8; private static final int t = 257; @@ -47,7 +47,7 @@ public class MathHelper { private static final double[] w = new double[257]; static { - for (int var0 = 0; var0 < 257; ++var0) { + for(int var0 = 0; var0 < 257; ++var0) { double var1 = (double) var0 / 256.0D; double var3 = Math.asin(var1); w[var0] = Math.cos(var3); @@ -105,7 +105,7 @@ public class MathHelper { } public static byte a(byte var0, byte var1, byte var2) { - if (var0 < var1) { + if(var0 < var1) { return var1; } else { return var0 > var2 ? var2 : var0; @@ -113,7 +113,7 @@ public class MathHelper { } public static int clamp(int var0, int var1, int var2) { - if (var0 < var1) { + if(var0 < var1) { return var1; } else { return var0 > var2 ? var2 : var0; @@ -121,7 +121,7 @@ public class MathHelper { } public static long a(long var0, long var2, long var4) { - if (var0 < var2) { + if(var0 < var2) { return var2; } else { return var0 > var4 ? var4 : var0; @@ -129,7 +129,7 @@ public class MathHelper { } public static float a(float var0, float var1, float var2) { - if (var0 < var1) { + if(var0 < var1) { return var1; } else { return var0 > var2 ? var2 : var0; @@ -137,7 +137,7 @@ public class MathHelper { } public static double a(double var0, double var2, double var4) { - if (var0 < var2) { + if(var0 < var2) { return var2; } else { return var0 > var4 ? var4 : var0; @@ -145,7 +145,7 @@ public class MathHelper { } public static double b(double var0, double var2, double var4) { - if (var4 < 0.0D) { + if(var4 < 0.0D) { return var0; } else { return var4 > 1.0D ? var2 : d(var4, var0, var2); @@ -153,7 +153,7 @@ public class MathHelper { } public static float b(float var0, float var1, float var2) { - if (var2 < 0.0F) { + if(var2 < 0.0F) { return var0; } else { return var2 > 1.0F ? var1 : h(var2, var0, var1); @@ -161,11 +161,11 @@ public class MathHelper { } public static double a(double var0, double var2) { - if (var0 < 0.0D) { + if(var0 < 0.0D) { var0 = -var0; } - if (var2 < 0.0D) { + if(var2 < 0.0D) { var2 = -var2; } @@ -193,7 +193,7 @@ public class MathHelper { long[] var3 = var0; int var4 = var0.length; - for (int var5 = 0; var5 < var4; ++var5) { + for(int var5 = 0; var5 < var4; ++var5) { long var6 = var3[var5]; var1 += var6; } @@ -223,11 +223,11 @@ public class MathHelper { public static int b(int var0) { int var1 = var0 % 360; - if (var1 >= 180) { + if(var1 >= 180) { var1 -= 360; } - if (var1 < -180) { + if(var1 < -180) { var1 += 360; } @@ -236,11 +236,11 @@ public class MathHelper { public static float g(float var0) { float var1 = var0 % 360.0F; - if (var1 >= 180.0F) { + if(var1 >= 180.0F) { var1 -= 360.0F; } - if (var1 < -180.0F) { + if(var1 < -180.0F) { var1 += 360.0F; } @@ -249,11 +249,11 @@ public class MathHelper { public static double f(double var0) { double var2 = var0 % 360.0D; - if (var2 >= 180.0D) { + if(var2 >= 180.0D) { var2 -= 360.0D; } - if (var2 < -180.0D) { + if(var2 < -180.0D) { var2 += 360.0D; } @@ -287,7 +287,7 @@ public class MathHelper { public static double a(String var0, double var1) { try { return Double.parseDouble(var0); - } catch (Throwable var4) { + } catch(Throwable var4) { return var1; } } @@ -382,22 +382,22 @@ public class MathHelper { public static double d(double var0, double var2) { double var4 = var2 * var2 + var0 * var0; - if (Double.isNaN(var4)) { + if(Double.isNaN(var4)) { return 0.0D / 0.0; } else { boolean var6 = var0 < 0.0D; - if (var6) { + if(var6) { var0 = -var0; } boolean var7 = var2 < 0.0D; - if (var7) { + if(var7) { var2 = -var2; } boolean var8 = var0 > var2; double var9; - if (var8) { + if(var8) { var9 = var2; var2 = var0; var0 = var9; @@ -414,15 +414,15 @@ public class MathHelper { double var20 = var0 * var16 - var2 * var18; double var22 = (6.0D + var20 * var20) * var20 * 0.16666666666666666D; double var24 = var14 + var22; - if (var8) { + if(var8) { var24 = 1.5707963267948966D - var24; } - if (var7) { + if(var7) { var24 = 3.141592653589793D - var24; } - if (var6) { + if(var6) { var24 = -var24; } @@ -466,7 +466,7 @@ public class MathHelper { float var8; float var9; float var10; - switch (var3) { + switch(var3) { case 0: var8 = var2; var9 = var7; @@ -530,17 +530,17 @@ public class MathHelper { double[] var2f = var0; int var3 = var0.length; - for (int var4 = 0; var4 < var3; ++var4) { + for(int var4 = 0; var4 < var3; ++var4) { double var5 = var2f[var4]; var1 = (float) ((double) var1 + var5); } int var2; - for (var2 = 0; var2 < var0.length; ++var2) { + for(var2 = 0; var2 < var0.length; ++var2) { var0[var2] /= var1; } - for (var2 = 0; var2 < var0.length; ++var2) { + for(var2 = 0; var2 < var0.length; ++var2) { var0[var2] += var2 == 0 ? 0.0D : var0[var2 - 1]; } @@ -550,8 +550,8 @@ public class MathHelper { public static int a(Random var0, double[] var1) { double var2 = var0.nextDouble(); - for (int var4 = 0; var4 < var1.length; ++var4) { - if (var2 < var1[var4]) { + for(int var4 = 0; var4 < var1.length; ++var4) { + if(var2 < var1[var4]) { return var4; } } @@ -563,7 +563,7 @@ public class MathHelper { double[] var8 = new double[var7 - var6 + 1]; int var9 = 0; - for (int var10 = var6; var10 <= var7; ++var10) { + for(int var10 = var6; var10 <= var7; ++var10) { var8[var9] = Math.max(0.0D, var0 * StrictMath.exp(-((double) var10 - var4) * ((double) var10 - var4) / (2.0D * var2 * var2))); ++var9; } @@ -575,7 +575,7 @@ public class MathHelper { double[] var14 = new double[var13 - var12 + 1]; int var15 = 0; - for (int var16 = var12; var16 <= var13; ++var16) { + for(int var16 = var12; var16 <= var13; ++var16) { var14[var15] = Math.max(0.0D, var0 * StrictMath.exp(-((double) var16 - var4) * ((double) var16 - var4) / (2.0D * var2 * var2)) + var6 * StrictMath.exp(-((double) var16 - var10) * ((double) var16 - var10) / (2.0D * var8 * var8))); ++var15; } @@ -587,7 +587,7 @@ public class MathHelper { double[] var6 = new double[var5 - var4 + 1]; int var7 = 0; - for (int var8 = var4; var8 <= var5; ++var8) { + for(int var8 = var4; var8 <= var5; ++var8) { var6[var7] = Math.max(var0 * StrictMath.log(var8) + var2, 0.0D); ++var7; } @@ -598,10 +598,10 @@ public class MathHelper { public static int a(int var0, int var1, IntPredicate var2) { int var3 = var1 - var0; - while (var3 > 0) { + while(var3 > 0) { int var4 = var3 / 2; int var5 = var0 + var4; - if (var2.test(var5)) { + if(var2.test(var5)) { var3 = var4; } else { var0 = var5 + 1; @@ -637,7 +637,7 @@ public class MathHelper { } public static int k(double var0) { - if (var0 == 0.0D) { + if(var0 == 0.0D) { return 0; } else { return var0 > 0.0D ? 1 : -1; @@ -655,10 +655,10 @@ public class MathHelper { @Deprecated public static float k(float var0, float var1, float var2) { float var3; - for (var3 = var1 - var0; var3 < -180.0F; var3 += 360.0F) { + for(var3 = var1 - var0; var3 < -180.0F; var3 += 360.0F) { } - while (var3 >= 180.0F) { + while(var3 >= 180.0F) { var3 -= 360.0F; } @@ -667,11 +667,11 @@ public class MathHelper { @Deprecated public static float l(double var0) { - while (var0 >= 180.0D) { + while(var0 >= 180.0D) { var0 -= 360.0D; } - while (var0 < -180.0D) { + while(var0 < -180.0D) { var0 += 360.0D; } diff --git a/src/main/java/com/volmit/iris/util/math/PathInterpolation.java b/src/main/java/com/volmit/iris/util/math/PathInterpolation.java index b352230bf..8260511fd 100644 --- a/src/main/java/com/volmit/iris/util/math/PathInterpolation.java +++ b/src/main/java/com/volmit/iris/util/math/PathInterpolation.java @@ -28,14 +28,16 @@ public interface PathInterpolation { * Sets nodes to be used by subsequent calls to * {@link #getPosition(double)} and the other methods. * - * @param nodes the nodes + * @param nodes + * the nodes */ void setNodes(List nodes); /** * Gets the result of f(position). * - * @param position the position to interpolate + * @param position + * the position to interpolate * @return the result */ Vector getPosition(double position); @@ -43,7 +45,8 @@ public interface PathInterpolation { /** * Gets the result of f'(position). * - * @param position the position to interpolate + * @param position + * the position to interpolate * @return the result */ Vector get1stDerivative(double position); @@ -53,8 +56,10 @@ public interface PathInterpolation { * That means it calculates the arc length (in meters) between positionA * and positionB. * - * @param positionA lower limit - * @param positionB upper limit + * @param positionA + * lower limit + * @param positionB + * upper limit * @return the arc length */ double arcLength(double positionA, double positionB); @@ -62,7 +67,8 @@ public interface PathInterpolation { /** * Get the segment position. * - * @param position the position + * @param position + * the position * @return the segment position */ int getSegment(double position); diff --git a/src/main/java/com/volmit/iris/util/math/Point3d.java b/src/main/java/com/volmit/iris/util/math/Point3d.java index af158a7cb..d50716d20 100644 --- a/src/main/java/com/volmit/iris/util/math/Point3d.java +++ b/src/main/java/com/volmit/iris/util/math/Point3d.java @@ -30,9 +30,12 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Point3d from the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public Point3d(double x, double y, double z) { super(x, y, z); @@ -42,7 +45,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Point3d from the array of length 3. * - * @param p the array of length 3 containing xyz in order + * @param p + * the array of length 3 containing xyz in order */ public Point3d(double[] p) { super(p); @@ -52,7 +56,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Point3d from the specified Point3d. * - * @param p1 the Point3d containing the initialization x y z data + * @param p1 + * the Point3d containing the initialization x y z data */ public Point3d(Point3d p1) { super(p1); @@ -62,7 +67,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Point3d from the specified Point3f. * - * @param p1 the Point3f containing the initialization x y z data + * @param p1 + * the Point3f containing the initialization x y z data */ public Point3d(Point3f p1) { super(p1); @@ -72,7 +78,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Point3d from the specified Tuple3f. * - * @param t1 the Tuple3f containing the initialization x y z data + * @param t1 + * the Tuple3f containing the initialization x y z data */ public Point3d(Tuple3f t1) { super(t1); @@ -82,7 +89,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Point3d from the specified Tuple3d. * - * @param t1 the Tuple3d containing the initialization x y z data + * @param t1 + * the Tuple3d containing the initialization x y z data */ public Point3d(Tuple3d t1) { super(t1); @@ -100,7 +108,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Returns the square of the distance between this point and point p1. * - * @param p1 the other point + * @param p1 + * the other point * @return the square of the distance */ public final double distanceSquared(Point3d p1) { @@ -116,7 +125,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { /** * Returns the distance between this point and point p1. * - * @param p1 the other point + * @param p1 + * the other point * @return the distance */ public final double distance(Point3d p1) { @@ -134,12 +144,13 @@ public class Point3d extends Tuple3d implements java.io.Serializable { * point p1. The L-1 distance is equal to: * abs(x1-x2) + abs(y1-y2) + abs(z1-z2). * - * @param p1 the other point + * @param p1 + * the other point * @return the L-1 distance */ public final double distanceL1(Point3d p1) { return Math.abs(this.x - p1.x) + Math.abs(this.y - p1.y) + - Math.abs(this.z - p1.z); + Math.abs(this.z - p1.z); } @@ -148,7 +159,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { * point p1. The L-infinite distance is equal to * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. * - * @param p1 the other point + * @param p1 + * the other point * @return the L-infinite distance */ public final double distanceLinf(Point3d p1) { @@ -163,7 +175,8 @@ public class Point3d extends Tuple3d implements java.io.Serializable { * Multiplies each of the x,y,z components of the Point4d parameter * by 1/w and places the projected values into this point. * - * @param p1 the source Point4d, which is not modified + * @param p1 + * the source Point4d, which is not modified */ public final void project(Point4d p1) { double oneOw; diff --git a/src/main/java/com/volmit/iris/util/math/Point3f.java b/src/main/java/com/volmit/iris/util/math/Point3f.java index 898479e5f..4dc08976e 100644 --- a/src/main/java/com/volmit/iris/util/math/Point3f.java +++ b/src/main/java/com/volmit/iris/util/math/Point3f.java @@ -31,9 +31,12 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Point3f from the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public Point3f(float x, float y, float z) { super(x, y, z); @@ -43,7 +46,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Point3f from the array of length 3. * - * @param p the array of length 3 containing xyz in order + * @param p + * the array of length 3 containing xyz in order */ public Point3f(float[] p) { super(p); @@ -53,7 +57,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Point3f from the specified Point3f. * - * @param p1 the Point3f containing the initialization x y z data + * @param p1 + * the Point3f containing the initialization x y z data */ public Point3f(Point3f p1) { super(p1); @@ -63,7 +68,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Point3f from the specified Point3d. * - * @param p1 the Point3d containing the initialization x y z data + * @param p1 + * the Point3d containing the initialization x y z data */ public Point3f(Point3d p1) { super(p1); @@ -73,7 +79,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Point3f from the specified Tuple3f. * - * @param t1 the Tuple3f containing the initialization x y z data + * @param t1 + * the Tuple3f containing the initialization x y z data */ public Point3f(Tuple3f t1) { super(t1); @@ -83,7 +90,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Point3f from the specified Tuple3d. * - * @param t1 the Tuple3d containing the initialization x y z data + * @param t1 + * the Tuple3d containing the initialization x y z data */ public Point3f(Tuple3d t1) { super(t1); @@ -102,7 +110,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { * Computes the square of the distance between this point and * point p1. * - * @param p1 the other point + * @param p1 + * the other point * @return the square of the distance */ public final float distanceSquared(Point3f p1) { @@ -118,7 +127,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { /** * Computes the distance between this point and point p1. * - * @param p1 the other point + * @param p1 + * the other point * @return the distance */ public final float distance(Point3f p1) { @@ -136,7 +146,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { * point p1. The L-1 distance is equal to: * abs(x1-x2) + abs(y1-y2) + abs(z1-z2). * - * @param p1 the other point + * @param p1 + * the other point * @return the L-1 distance */ public final float distanceL1(Point3f p1) { @@ -149,7 +160,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { * point p1. The L-infinite distance is equal to * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. * - * @param p1 the other point + * @param p1 + * the other point * @return the L-infinite distance */ public final float distanceLinf(Point3f p1) { @@ -164,7 +176,8 @@ public class Point3f extends Tuple3f implements java.io.Serializable { * Multiplies each of the x,y,z components of the Point4f parameter * by 1/w and places the projected values into this point. * - * @param p1 the source Point4f, which is not modified + * @param p1 + * the source Point4f, which is not modified */ public final void project(Point4f p1) { float oneOw; diff --git a/src/main/java/com/volmit/iris/util/math/Point4d.java b/src/main/java/com/volmit/iris/util/math/Point4d.java index 165d1049e..7fecb8f12 100644 --- a/src/main/java/com/volmit/iris/util/math/Point4d.java +++ b/src/main/java/com/volmit/iris/util/math/Point4d.java @@ -31,10 +31,14 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Constructs and initializes a Point4d from the specified xyzw coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param w the w coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate + * @param w + * the w coordinate */ public Point4d(double x, double y, double z, double w) { super(x, y, z, w); @@ -44,7 +48,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * Constructs and initializes a Point4d from the coordinates contained * in the array. * - * @param p the array of length 4 containing xyzw in order + * @param p + * the array of length 4 containing xyzw in order */ public Point4d(double[] p) { super(p); @@ -54,7 +59,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Constructs and initializes a Point4d from the specified Point4d. * - * @param p1 the Point4d containing the initialization x y z w data + * @param p1 + * the Point4d containing the initialization x y z w data */ public Point4d(Point4d p1) { super(p1); @@ -64,7 +70,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Constructs and initializes a Point4d from the specified Point4f. * - * @param p1 the Point4f containing the initialization x y z w data + * @param p1 + * the Point4f containing the initialization x y z w data */ public Point4d(Point4f p1) { super(p1); @@ -74,7 +81,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Constructs and initializes a Point4d from the specified Tuple4f. * - * @param t1 the Tuple4f containing the initialization x y z w data + * @param t1 + * the Tuple4f containing the initialization x y z w data */ public Point4d(Tuple4f t1) { super(t1); @@ -84,7 +92,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Constructs and initializes a Point4d from the specified Tuple4d. * - * @param t1 the Tuple4d containing the initialization x y z w data + * @param t1 + * the Tuple4d containing the initialization x y z w data */ public Point4d(Tuple4d t1) { super(t1); @@ -97,7 +106,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * components of tuple t1. The w component of this point * is set to 1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied * @since vecmath 1.2 */ public Point4d(Tuple3d t1) { @@ -118,7 +128,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * components of tuple t1. The w component of this point * is set to 1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied * @since vecmath 1.2 */ public final void set(Tuple3d t1) { @@ -132,7 +143,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Returns the square of the distance between this point and point p1. * - * @param p1 the first point + * @param p1 + * the first point * @return the square of distance between this point and point p1 */ public final double distanceSquared(Point4d p1) { @@ -149,7 +161,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { /** * Returns the distance between this point and point p1. * - * @param p1 the first point + * @param p1 + * the first point * @return the distance between these this point and point p1. */ public final double distance(Point4d p1) { @@ -168,12 +181,13 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * point p1. The L-1 distance is equal to: * abs(x1-x2) + abs(y1-y2) + abs(z1-z2) + abs(w1-w2). * - * @param p1 the other point + * @param p1 + * the other point * @return the L-1 distance */ public final double distanceL1(Point4d p1) { return Math.abs(this.x - p1.x) + Math.abs(this.y - p1.y) + - Math.abs(this.z - p1.z) + Math.abs(this.w - p1.w); + Math.abs(this.z - p1.z) + Math.abs(this.w - p1.w); } /** @@ -181,7 +195,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * point p1. The L-infinite distance is equal to * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)]. * - * @param p1 the other point + * @param p1 + * the other point * @return the L-infinite distance */ public final double distanceLinf(Point4d p1) { @@ -197,7 +212,8 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * by 1/w, places the projected values into this point, and places * a 1 as the w parameter of this point. * - * @param p1 the source Point4d, which is not modified + * @param p1 + * the source Point4d, which is not modified */ public final void project(Point4d p1) { double oneOw; diff --git a/src/main/java/com/volmit/iris/util/math/Point4f.java b/src/main/java/com/volmit/iris/util/math/Point4f.java index 2da6546c5..8ae9477f2 100644 --- a/src/main/java/com/volmit/iris/util/math/Point4f.java +++ b/src/main/java/com/volmit/iris/util/math/Point4f.java @@ -31,10 +31,14 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Constructs and initializes a Point4f from the specified xyzw coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param w the w coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate + * @param w + * the w coordinate */ public Point4f(float x, float y, float z, float w) { super(x, y, z, w); @@ -44,7 +48,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Constructs and initializes a Point4f from the array of length 4. * - * @param p the array of length 4 containing xyzw in order + * @param p + * the array of length 4 containing xyzw in order */ public Point4f(float[] p) { super(p); @@ -54,7 +59,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Constructs and initializes a Point4f from the specified Point4f. * - * @param p1 the Point4f containing the initialization x y z w data + * @param p1 + * the Point4f containing the initialization x y z w data */ public Point4f(Point4f p1) { super(p1); @@ -64,7 +70,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Constructs and initializes a Point4f from the specified Point4d. * - * @param p1 the Point4d containing the initialization x y z w data + * @param p1 + * the Point4d containing the initialization x y z w data */ public Point4f(Point4d p1) { super(p1); @@ -74,7 +81,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Constructs and initializes a Point4f from the specified Tuple4f. * - * @param t1 the Tuple4f containing the initialization x y z w data + * @param t1 + * the Tuple4f containing the initialization x y z w data */ public Point4f(Tuple4f t1) { super(t1); @@ -84,7 +92,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Constructs and initializes a Point4f from the specified Tuple4d. * - * @param t1 the Tuple4d containing the initialization x y z w data + * @param t1 + * the Tuple4d containing the initialization x y z w data */ public Point4f(Tuple4d t1) { super(t1); @@ -97,7 +106,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * components of tuple t1. The w component of this point * is set to 1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied * @since vecmath 1.2 */ public Point4f(Tuple3f t1) { @@ -118,7 +128,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * components of tuple t1. The w component of this point * is set to 1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied * @since vecmath 1.2 */ public final void set(Tuple3f t1) { @@ -132,7 +143,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Computes the square of the distance between this point and point p1. * - * @param p1 the other point + * @param p1 + * the other point * @return the square of distance between these two points as a float */ public final float distanceSquared(Point4f p1) { @@ -149,7 +161,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { /** * Computes the distance between this point and point p1. * - * @param p1 the other point + * @param p1 + * the other point * @return the distance between the two points */ public final float distance(Point4f p1) { @@ -168,7 +181,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * point p1. The L-1 distance is equal to: * abs(x1-x2) + abs(y1-y2) + abs(z1-z2) + abs(w1-w2). * - * @param p1 the other point + * @param p1 + * the other point * @return the L-1 distance */ public final float distanceL1(Point4f p1) { @@ -181,7 +195,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * point p1. The L-infinite distance is equal to * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)]. * - * @param p1 the other point + * @param p1 + * the other point * @return the L-infinite distance */ public final float distanceLinf(Point4f p1) { @@ -198,7 +213,8 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * by 1/w, places the projected values into this point, and places * a 1 as the w parameter of this point. * - * @param p1 the source Point4f, which is not modified + * @param p1 + * the source Point4f, which is not modified */ public final void project(Point4f p1) { float oneOw; diff --git a/src/main/java/com/volmit/iris/util/math/Position2.java b/src/main/java/com/volmit/iris/util/math/Position2.java index 279d5076f..82de97333 100644 --- a/src/main/java/com/volmit/iris/util/math/Position2.java +++ b/src/main/java/com/volmit/iris/util/math/Position2.java @@ -70,10 +70,10 @@ public class Position2 { @Override public boolean equals(Object obj) { - if (this == obj) { + if(this == obj) { return true; } - if (!(obj instanceof Position2 other)) { + if(!(obj instanceof Position2 other)) { return false; } return x == other.x && z == other.z; diff --git a/src/main/java/com/volmit/iris/util/math/RNG.java b/src/main/java/com/volmit/iris/util/math/RNG.java index 901d64868..4d1208432 100644 --- a/src/main/java/com/volmit/iris/util/math/RNG.java +++ b/src/main/java/com/volmit/iris/util/math/RNG.java @@ -42,7 +42,8 @@ public class RNG extends Random { /** * Creates a seed (long) from the hash of the seed string * - * @param seed the seed (string) + * @param seed + * the seed (string) */ public RNG(String seed) { this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() + UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() + (seed.length() * 32564L)); @@ -59,7 +60,7 @@ public class RNG extends Random { public String s(int length) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length; i++) { + for(int i = 0; i < length; i++) { sb.append(c()); } @@ -73,7 +74,8 @@ public class RNG extends Random { /** * Pick a random enum * - * @param t the enum class + * @param t + * the enum class * @return the enum */ public T e(Class t) { @@ -114,7 +116,7 @@ public class RNG extends Random { } public double d(double lowerBound, double upperBound) { - if (lowerBound > upperBound) { + if(lowerBound > upperBound) { return M.lerp(upperBound, lowerBound, nextDouble()); } @@ -170,11 +172,11 @@ public class RNG extends Random { } public T pick(List pieces) { - if (pieces.isEmpty()) { + if(pieces.isEmpty()) { return null; } - if (pieces.size() == 1) { + if(pieces.size() == 1) { return pieces.get(0); } diff --git a/src/main/java/com/volmit/iris/util/math/RollingSequence.java b/src/main/java/com/volmit/iris/util/math/RollingSequence.java index 76bebd524..a4356edc4 100644 --- a/src/main/java/com/volmit/iris/util/math/RollingSequence.java +++ b/src/main/java/com/volmit/iris/util/math/RollingSequence.java @@ -39,7 +39,7 @@ public class RollingSequence extends Average { public double addLast(int amt) { double f = 0; - for (int i = 0; i < Math.min(values.length, amt); i++) { + for(int i = 0; i < Math.min(values.length, amt); i++) { f += values[i]; } @@ -55,7 +55,7 @@ public class RollingSequence extends Average { } public double getMin() { - if (dirtyExtremes > (isPrecision() ? 0 : values.length)) { + if(dirtyExtremes > (isPrecision() ? 0 : values.length)) { resetExtremes(); } @@ -63,7 +63,7 @@ public class RollingSequence extends Average { } public double getMax() { - if (dirtyExtremes > (isPrecision() ? 0 : values.length)) { + if(dirtyExtremes > (isPrecision() ? 0 : values.length)) { resetExtremes(); } @@ -71,7 +71,7 @@ public class RollingSequence extends Average { } public double getMedian() { - if (dirtyMedian) { + if(dirtyMedian) { recalculateMedian(); } @@ -87,7 +87,7 @@ public class RollingSequence extends Average { max = Integer.MIN_VALUE; min = Integer.MAX_VALUE; - for (double i : values) { + for(double i : values) { max = M.max(max, i); min = M.min(min, i); } diff --git a/src/main/java/com/volmit/iris/util/math/Spiral.java b/src/main/java/com/volmit/iris/util/math/Spiral.java index df1fdf3ef..6f314ebc5 100644 --- a/src/main/java/com/volmit/iris/util/math/Spiral.java +++ b/src/main/java/com/volmit/iris/util/math/Spiral.java @@ -41,20 +41,20 @@ public class Spiral implements Iterable { int ax = Math.abs(x); int az = Math.abs(z); - if (x == 0 && z == 0) { + if(x == 0 && z == 0) { return p.add(1, 0); } - if (ax == az) { - if (x > 0 && z > 0) return left(p); - else if (x < 0 && z > 0) return down(p); - else if (x < 0 && z < 0) return right(p); - else if (x > 0 && z < 0) return up(p); + if(ax == az) { + if(x > 0 && z > 0) return left(p); + else if(x < 0 && z > 0) return down(p); + else if(x < 0 && z < 0) return right(p); + else if(x > 0 && z < 0) return up(p); } else { - if (x > z && ax > az) return up(p); - else if (x < z && ax < az) return left(p); - else if (x < z && ax > az) return down(p); - else if (x > z && ax < az) return right(p); + if(x > z && ax > az) return up(p); + else if(x < z && ax < az) return left(p); + else if(x < z && ax > az) return down(p); + else if(x > z && ax < az) return right(p); } return p; diff --git a/src/main/java/com/volmit/iris/util/math/Spiraler.java b/src/main/java/com/volmit/iris/util/math/Spiraler.java index 9166218a4..58604d966 100644 --- a/src/main/java/com/volmit/iris/util/math/Spiraler.java +++ b/src/main/java/com/volmit/iris/util/math/Spiraler.java @@ -36,7 +36,7 @@ public class Spiraler { } public void drain() { - while (hasNext()) { + while(hasNext()) { next(); } } @@ -62,11 +62,11 @@ public class Spiraler { } public void next() { - if ((-sizeX / 2 <= x) && (x <= sizeX / 2) && (-sizeZ / 2 <= z) && (z <= sizeZ / 2)) { + if((-sizeX / 2 <= x) && (x <= sizeX / 2) && (-sizeZ / 2 <= z) && (z <= sizeZ / 2)) { spiraled.on(x + ox, z + ox); } - if ((x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1 - z))) { + if((x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1 - z))) { t = dx; dx = -dz; dz = t; diff --git a/src/main/java/com/volmit/iris/util/math/Tuple2d.java b/src/main/java/com/volmit/iris/util/math/Tuple2d.java index 403df9b0c..94a59d31a 100644 --- a/src/main/java/com/volmit/iris/util/math/Tuple2d.java +++ b/src/main/java/com/volmit/iris/util/math/Tuple2d.java @@ -42,8 +42,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2d from the specified xy coordinates. * - * @param x the x coordinate - * @param y the y coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate */ public Tuple2d(double x, double y) { this.x = x; @@ -54,7 +56,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2d from the specified array. * - * @param t the array of length 2 containing xy in order + * @param t + * the array of length 2 containing xy in order */ public Tuple2d(double[] t) { this.x = t[0]; @@ -65,7 +68,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2d from the specified Tuple2d. * - * @param t1 the Tuple2d containing the initialization x y data + * @param t1 + * the Tuple2d containing the initialization x y data */ public Tuple2d(Tuple2d t1) { this.x = t1.x; @@ -76,7 +80,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2d from the specified Tuple2f. * - * @param t1 the Tuple2f containing the initialization x y data + * @param t1 + * the Tuple2f containing the initialization x y data */ public Tuple2d(Tuple2f t1) { this.x = t1.x; @@ -95,8 +100,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xy coordinates. * - * @param x the x coordinate - * @param y the y coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate */ public final void set(double x, double y) { this.x = x; @@ -108,7 +115,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple from the 2 values specified in * the array. * - * @param t the array of length 2 containing xy in order + * @param t + * the array of length 2 containing xy in order */ public final void set(double[] t) { this.x = t[0]; @@ -119,7 +127,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of the Tuple2d argument. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple2d t1) { this.x = t1.x; @@ -130,7 +139,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of Tuple2f t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple2f t1) { this.x = t1.x; @@ -140,7 +150,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Copies the value of the elements of this tuple into the array t. * - * @param t the array that will contain the values of the vector + * @param t + * the array that will contain the values of the vector */ public final void get(double[] t) { t[0] = this.x; @@ -151,8 +162,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the vector sum of tuples t1 and t2. * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void add(Tuple2d t1, Tuple2d t2) { this.x = t1.x + t2.x; @@ -163,7 +176,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the vector sum of itself and tuple t1. * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void add(Tuple2d t1) { this.x += t1.x; @@ -175,8 +189,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the vector difference of * tuple t1 and t2 (this = t1 - t2). * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void sub(Tuple2d t1, Tuple2d t2) { this.x = t1.x - t2.x; @@ -188,7 +204,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the vector difference of * itself and tuple t1 (this = this - t1). * - * @param t1 the other vector + * @param t1 + * the other vector */ public final void sub(Tuple2d t1) { this.x -= t1.x; @@ -199,7 +216,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the negation of tuple t1. * - * @param t1 the source vector + * @param t1 + * the source vector */ public final void negate(Tuple2d t1) { this.x = -t1.x; @@ -220,8 +238,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1. * - * @param s the scalar value - * @param t1 the source tuple + * @param s + * the scalar value + * @param t1 + * the source tuple */ public final void scale(double s, Tuple2d t1) { this.x = s * t1.x; @@ -233,7 +253,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself. * - * @param s the scalar value + * @param s + * the scalar value */ public final void scale(double s) { this.x *= s; @@ -245,9 +266,12 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1 and then adds tuple t2 (this = s*t1 + t2). * - * @param s the scalar value - * @param t1 the tuple to be multipled - * @param t2 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be multipled + * @param t2 + * the tuple to be added */ public final void scaleAdd(double s, Tuple2d t1, Tuple2d t2) { this.x = s * t1.x + t2.x; @@ -259,8 +283,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself and then adds tuple t1 (this = s*this + t1). * - * @param s the scalar value - * @param t1 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be added */ public final void scaleAdd(double s, Tuple2d t1) { this.x = s * this.x + t1.x; @@ -289,13 +315,14 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Returns true if all of the data members of Tuple2d t1 are * equal to the corresponding data members in this Tuple2d. * - * @param t1 the vector with which the comparison is made + * @param t1 + * the vector with which the comparison is made * @return true or false */ public boolean equals(Tuple2d t1) { try { return (this.x == t1.x && this.y == t1.y); - } catch (NullPointerException e2) { + } catch(NullPointerException e2) { Iris.reportError(e2); return false; } @@ -307,14 +334,15 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple2d. * - * @param t1 the object with which the comparison is made + * @param t1 + * the object with which the comparison is made * @return true or false */ public boolean equals(Object t1) { try { Tuple2d t2 = (Tuple2d) t1; return (this.x == t2.x && this.y == t2.y); - } catch (NullPointerException | ClassCastException e2) { + } catch(NullPointerException | ClassCastException e2) { Iris.reportError(e2); return false; } @@ -327,19 +355,21 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * otherwise returns false. The L-infinite * distance is equal to MAX[abs(x1-x2), abs(y1-y2)]. * - * @param t1 the tuple to be compared to this tuple - * @param epsilon the threshold value + * @param t1 + * the tuple to be compared to this tuple + * @param epsilon + * the threshold value * @return true or false */ public boolean epsilonEquals(Tuple2d t1, double epsilon) { double diff; diff = x - t1.x; - if (Double.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Double.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = y - t1.y; - if (Double.isNaN(diff)) return false; + if(Double.isNaN(diff)) return false; return !((diff < 0 ? -diff : diff) > epsilon); } @@ -358,16 +388,19 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Clamps the tuple parameter to the range [low, high] and * places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clamp(double min, double max, Tuple2d t) { - if (t.x > max) { + if(t.x > max) { x = max; } else x = Math.max(t.x, min); - if (t.y > max) { + if(t.y > max) { y = max; } else y = Math.max(t.y, min); @@ -378,8 +411,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Clamps the minimum value of the tuple parameter to the min * parameter and places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMin(double min, Tuple2d t) { x = Math.max(t.x, min); @@ -393,8 +428,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Clamps the maximum value of the tuple parameter to the max * parameter and places the values into this tuple. * - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMax(double max, Tuple2d t) { x = Math.min(t.x, max); @@ -408,7 +445,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Sets each component of the tuple parameter to its absolute * value and places the modified values into this tuple. * - * @param t the source tuple, which will not be modified + * @param t + * the source tuple, which will not be modified */ public final void absolute(Tuple2d t) { x = Math.abs(t.x); @@ -419,19 +457,21 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Clamps this tuple to the range [low, high]. * - * @param min the lowest value in this tuple after clamping - * @param max the highest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping + * @param max + * the highest value in this tuple after clamping */ public final void clamp(double min, double max) { - if (x > max) { + if(x > max) { x = max; - } else if (x < min) { + } else if(x < min) { x = min; } - if (y > max) { + if(y > max) { y = max; - } else if (y < min) { + } else if(y < min) { y = min; } @@ -441,22 +481,24 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Clamps the minimum value of this tuple to the min parameter. * - * @param min the lowest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping */ public final void clampMin(double min) { - if (x < min) x = min; - if (y < min) y = min; + if(x < min) x = min; + if(y < min) y = min; } /** * Clamps the maximum value of this tuple to the max parameter. * - * @param max the highest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping */ public final void clampMax(double max) { - if (x > max) x = max; - if (y > max) y = max; + if(x > max) x = max; + if(y > max) y = max; } @@ -473,9 +515,12 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Linearly interpolates between tuples t1 and t2 and places the * result into this tuple: this = (1-alpha)*t1 + alpha*t2. * - * @param t1 the first tuple - * @param t2 the second tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param t2 + * the second tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple2d t1, Tuple2d t2, double alpha) { this.x = (1 - alpha) * t1.x + alpha * t2.x; @@ -487,8 +532,10 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Linearly interpolates between this tuple and tuple t1 and * places the result into this tuple: this = (1-alpha)*this + alpha*t1. * - * @param t1 the first tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple2d t1, double alpha) { this.x = (1 - alpha) * this.x + alpha * t1.x; @@ -500,7 +547,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * Creates a new object of the same class as this object. * * @return a clone of this instance. - * @throws OutOfMemoryError if there is not enough memory. + * @throws OutOfMemoryError + * if there is not enough memory. * @see java.lang.Cloneable * @since vecmath 1.3 */ @@ -508,7 +556,7 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { // Since there are no arrays we can just use Object.clone() try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch(CloneNotSupportedException e) { Iris.reportError(e); // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -530,7 +578,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Set the x coordinate. * - * @param x value to x coordinate. + * @param x + * value to x coordinate. * @since vecmath 1.5 */ public final void setX(double x) { @@ -552,7 +601,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { /** * Set the y coordinate. * - * @param y value to y coordinate. + * @param y + * value to y coordinate. * @since vecmath 1.5 */ public final void setY(double y) { diff --git a/src/main/java/com/volmit/iris/util/math/Tuple2f.java b/src/main/java/com/volmit/iris/util/math/Tuple2f.java index 243fbc8c7..202c02dde 100644 --- a/src/main/java/com/volmit/iris/util/math/Tuple2f.java +++ b/src/main/java/com/volmit/iris/util/math/Tuple2f.java @@ -42,8 +42,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2f from the specified xy coordinates. * - * @param x the x coordinate - * @param y the y coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate */ public Tuple2f(float x, float y) { this.x = x; @@ -54,7 +56,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2f from the specified array. * - * @param t the array of length 2 containing xy in order + * @param t + * the array of length 2 containing xy in order */ public Tuple2f(float[] t) { this.x = t[0]; @@ -65,7 +68,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2f from the specified Tuple2f. * - * @param t1 the Tuple2f containing the initialization x y data + * @param t1 + * the Tuple2f containing the initialization x y data */ public Tuple2f(Tuple2f t1) { this.x = t1.x; @@ -76,7 +80,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple2f from the specified Tuple2d. * - * @param t1 the Tuple2d containing the initialization x y data + * @param t1 + * the Tuple2d containing the initialization x y data */ public Tuple2f(Tuple2d t1) { this.x = (float) t1.x; @@ -96,8 +101,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xy coordinates. * - * @param x the x coordinate - * @param y the y coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate */ public final void set(float x, float y) { this.x = x; @@ -109,7 +116,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple from the 2 values specified in * the array. * - * @param t the array of length 2 containing xy in order + * @param t + * the array of length 2 containing xy in order */ public final void set(float[] t) { this.x = t[0]; @@ -120,7 +128,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of the Tuple2f argument. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple2f t1) { this.x = t1.x; @@ -131,7 +140,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of the Tuple2d argument. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple2d t1) { this.x = (float) t1.x; @@ -142,7 +152,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Copies the value of the elements of this tuple into the array t. * - * @param t the array that will contain the values of the vector + * @param t + * the array that will contain the values of the vector */ public final void get(float[] t) { t[0] = this.x; @@ -153,8 +164,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the vector sum of tuples t1 and t2. * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void add(Tuple2f t1, Tuple2f t2) { this.x = t1.x + t2.x; @@ -165,7 +178,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the vector sum of itself and tuple t1. * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void add(Tuple2f t1) { this.x += t1.x; @@ -177,8 +191,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the vector difference of * tuple t1 and t2 (this = t1 - t2). * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void sub(Tuple2f t1, Tuple2f t2) { this.x = t1.x - t2.x; @@ -190,7 +206,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the vector difference of * itself and tuple t1 (this = this - t1). * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void sub(Tuple2f t1) { this.x -= t1.x; @@ -201,7 +218,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the negation of tuple t1. * - * @param t1 the source tuple + * @param t1 + * the source tuple */ public final void negate(Tuple2f t1) { this.x = -t1.x; @@ -222,8 +240,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1. * - * @param s the scalar value - * @param t1 the source tuple + * @param s + * the scalar value + * @param t1 + * the source tuple */ public final void scale(float s, Tuple2f t1) { this.x = s * t1.x; @@ -235,7 +255,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself. * - * @param s the scalar value + * @param s + * the scalar value */ public final void scale(float s) { this.x *= s; @@ -247,9 +268,12 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1 and then adds tuple t2 (this = s*t1 + t2). * - * @param s the scalar value - * @param t1 the tuple to be multipled - * @param t2 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be multipled + * @param t2 + * the tuple to be added */ public final void scaleAdd(float s, Tuple2f t1, Tuple2f t2) { this.x = s * t1.x + t2.x; @@ -261,8 +285,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself and then adds tuple t1 (this = s*this + t1). * - * @param s the scalar value - * @param t1 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be added */ public final void scaleAdd(float s, Tuple2f t1) { this.x = s * this.x + t1.x; @@ -291,13 +317,14 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Returns true if all of the data members of Tuple2f t1 are * equal to the corresponding data members in this Tuple2f. * - * @param t1 the vector with which the comparison is made + * @param t1 + * the vector with which the comparison is made * @return true or false */ public boolean equals(Tuple2f t1) { try { return (this.x == t1.x && this.y == t1.y); - } catch (NullPointerException e2) { + } catch(NullPointerException e2) { Iris.reportError(e2); return false; } @@ -309,14 +336,15 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple2f. * - * @param t1 the object with which the comparison is made + * @param t1 + * the object with which the comparison is made * @return true or false */ public boolean equals(Object t1) { try { Tuple2f t2 = (Tuple2f) t1; return (this.x == t2.x && this.y == t2.y); - } catch (NullPointerException | ClassCastException e2) { + } catch(NullPointerException | ClassCastException e2) { Iris.reportError(e2); return false; } @@ -329,19 +357,21 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * otherwise returns false. The L-infinite * distance is equal to MAX[abs(x1-x2), abs(y1-y2)]. * - * @param t1 the tuple to be compared to this tuple - * @param epsilon the threshold value + * @param t1 + * the tuple to be compared to this tuple + * @param epsilon + * the threshold value * @return true or false */ public boolean epsilonEquals(Tuple2f t1, float epsilon) { float diff; diff = x - t1.x; - if (Float.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Float.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = y - t1.y; - if (Float.isNaN(diff)) return false; + if(Float.isNaN(diff)) return false; return !((diff < 0 ? -diff : diff) > epsilon); } @@ -360,16 +390,19 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Clamps the tuple parameter to the range [low, high] and * places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clamp(float min, float max, Tuple2f t) { - if (t.x > max) { + if(t.x > max) { x = max; } else x = Math.max(t.x, min); - if (t.y > max) { + if(t.y > max) { y = max; } else y = Math.max(t.y, min); @@ -380,8 +413,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Clamps the minimum value of the tuple parameter to the min * parameter and places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMin(float min, Tuple2f t) { x = Math.max(t.x, min); @@ -395,8 +430,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Clamps the maximum value of the tuple parameter to the max * parameter and places the values into this tuple. * - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMax(float max, Tuple2f t) { x = Math.min(t.x, max); @@ -410,7 +447,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Sets each component of the tuple parameter to its absolute * value and places the modified values into this tuple. * - * @param t the source tuple, which will not be modified + * @param t + * the source tuple, which will not be modified */ public final void absolute(Tuple2f t) { x = Math.abs(t.x); @@ -421,19 +459,21 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Clamps this tuple to the range [low, high]. * - * @param min the lowest value in this tuple after clamping - * @param max the highest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping + * @param max + * the highest value in this tuple after clamping */ public final void clamp(float min, float max) { - if (x > max) { + if(x > max) { x = max; - } else if (x < min) { + } else if(x < min) { x = min; } - if (y > max) { + if(y > max) { y = max; - } else if (y < min) { + } else if(y < min) { y = min; } @@ -443,22 +483,24 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Clamps the minimum value of this tuple to the min parameter. * - * @param min the lowest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping */ public final void clampMin(float min) { - if (x < min) x = min; - if (y < min) y = min; + if(x < min) x = min; + if(y < min) y = min; } /** * Clamps the maximum value of this tuple to the max parameter. * - * @param max the highest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping */ public final void clampMax(float max) { - if (x > max) x = max; - if (y > max) y = max; + if(x > max) x = max; + if(y > max) y = max; } @@ -475,9 +517,12 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Linearly interpolates between tuples t1 and t2 and places the * result into this tuple: this = (1-alpha)*t1 + alpha*t2. * - * @param t1 the first tuple - * @param t2 the second tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param t2 + * the second tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple2f t1, Tuple2f t2, float alpha) { this.x = (1 - alpha) * t1.x + alpha * t2.x; @@ -490,8 +535,10 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Linearly interpolates between this tuple and tuple t1 and * places the result into this tuple: this = (1-alpha)*this + alpha*t1. * - * @param t1 the first tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple2f t1, float alpha) { @@ -504,7 +551,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * Creates a new object of the same class as this object. * * @return a clone of this instance. - * @throws OutOfMemoryError if there is not enough memory. + * @throws OutOfMemoryError + * if there is not enough memory. * @see java.lang.Cloneable * @since vecmath 1.3 */ @@ -512,7 +560,7 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { // Since there are no arrays we can just use Object.clone() try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch(CloneNotSupportedException e) { Iris.reportError(e); // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -534,7 +582,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Set the x coordinate. * - * @param x value to x coordinate. + * @param x + * value to x coordinate. * @since vecmath 1.5 */ public final void setX(float x) { @@ -556,7 +605,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { /** * Set the y coordinate. * - * @param y value to y coordinate. + * @param y + * value to y coordinate. * @since vecmath 1.5 */ public final void setY(float y) { diff --git a/src/main/java/com/volmit/iris/util/math/Tuple3d.java b/src/main/java/com/volmit/iris/util/math/Tuple3d.java index 3138e1d7c..2b7bbe74a 100644 --- a/src/main/java/com/volmit/iris/util/math/Tuple3d.java +++ b/src/main/java/com/volmit/iris/util/math/Tuple3d.java @@ -47,9 +47,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3d from the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public Tuple3d(double x, double y, double z) { this.x = x; @@ -60,7 +63,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3d from the array of length 3. * - * @param t the array of length 3 containing xyz in order + * @param t + * the array of length 3 containing xyz in order */ public Tuple3d(double[] t) { this.x = t[0]; @@ -71,7 +75,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3d from the specified Tuple3d. * - * @param t1 the Tuple3d containing the initialization x y z data + * @param t1 + * the Tuple3d containing the initialization x y z data */ public Tuple3d(Tuple3d t1) { this.x = t1.x; @@ -82,7 +87,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3d from the specified Tuple3f. * - * @param t1 the Tuple3f containing the initialization x y z data + * @param t1 + * the Tuple3f containing the initialization x y z data */ public Tuple3d(Tuple3f t1) { this.x = t1.x; @@ -102,9 +108,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public final void set(double x, double y, double z) { this.x = x; @@ -116,7 +125,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the value of the xyz coordinates * located in the array of length 3. * - * @param t the array of length 3 containing xyz in order + * @param t + * the array of length 3 containing xyz in order */ public final void set(double[] t) { this.x = t[0]; @@ -127,7 +137,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple3d t1) { this.x = t1.x; @@ -138,7 +149,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple3f t1) { this.x = t1.x; @@ -150,7 +162,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Copies the x,y,z coordinates of this tuple into the array t * of length 3. * - * @param t the target array + * @param t + * the target array */ public final void get(double[] t) { t[0] = this.x; @@ -162,7 +175,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Copies the x,y,z coordinates of this tuple into the tuple t. * - * @param t the Tuple3d object into which the values of this object are copied + * @param t + * the Tuple3d object into which the values of this object are copied */ public final void get(Tuple3d t) { t.x = this.x; @@ -174,8 +188,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the sum of tuples t1 and t2. * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void add(Tuple3d t1, Tuple3d t2) { this.x = t1.x + t2.x; @@ -187,7 +203,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the sum of itself and t1. * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void add(Tuple3d t1) { this.x += t1.x; @@ -199,8 +216,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the difference of tuples * t1 and t2 (this = t1 - t2). * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void sub(Tuple3d t1, Tuple3d t2) { this.x = t1.x - t2.x; @@ -212,7 +231,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the difference * of itself and t1 (this = this - t1). * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void sub(Tuple3d t1) { this.x -= t1.x; @@ -224,7 +244,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the negation of tuple t1. * - * @param t1 the source tuple + * @param t1 + * the source tuple */ public final void negate(Tuple3d t1) { this.x = -t1.x; @@ -247,8 +268,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1. * - * @param s the scalar value - * @param t1 the source tuple + * @param s + * the scalar value + * @param t1 + * the source tuple */ public final void scale(double s, Tuple3d t1) { this.x = s * t1.x; @@ -261,7 +284,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself. * - * @param s the scalar value + * @param s + * the scalar value */ public final void scale(double s) { this.x *= s; @@ -274,9 +298,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1 and then adds tuple t2 (this = s*t1 + t2). * - * @param s the scalar value - * @param t1 the tuple to be multipled - * @param t2 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be multipled + * @param t2 + * the tuple to be added */ public final void scaleAdd(double s, Tuple3d t1, Tuple3d t2) { this.x = s * t1.x + t2.x; @@ -298,8 +325,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself and then adds tuple t1 (this = s*this + t1). * - * @param s the scalar value - * @param t1 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be added */ public final void scaleAdd(double s, Tuple3d t1) { this.x = s * this.x + t1.x; @@ -341,13 +370,14 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Returns true if all of the data members of Tuple3d t1 are * equal to the corresponding data members in this Tuple3d. * - * @param t1 the tuple with which the comparison is made + * @param t1 + * the tuple with which the comparison is made * @return true or false */ public boolean equals(Tuple3d t1) { try { return (this.x == t1.x && this.y == t1.y && this.z == t1.z); - } catch (NullPointerException e2) { + } catch(NullPointerException e2) { Iris.reportError(e2); return false; } @@ -358,14 +388,15 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple3d. * - * @param t1 the Object with which the comparison is made + * @param t1 + * the Object with which the comparison is made * @return true or false */ public boolean equals(Object t1) { try { Tuple3d t2 = (Tuple3d) t1; return (this.x == t2.x && this.y == t2.y && this.z == t2.z); - } catch (ClassCastException | NullPointerException e1) { + } catch(ClassCastException | NullPointerException e1) { Iris.reportError(e1); return false; } @@ -378,23 +409,25 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * otherwise returns false. The L-infinite * distance is equal to MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. * - * @param t1 the tuple to be compared to this tuple - * @param epsilon the threshold value + * @param t1 + * the tuple to be compared to this tuple + * @param epsilon + * the threshold value * @return true or false */ public boolean epsilonEquals(Tuple3d t1, double epsilon) { double diff; diff = x - t1.x; - if (Double.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Double.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = y - t1.y; - if (Double.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Double.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = z - t1.z; - if (Double.isNaN(diff)) return false; + if(Double.isNaN(diff)) return false; return !((diff < 0 ? -diff : diff) > epsilon); } @@ -413,20 +446,23 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Clamps the tuple parameter to the range [low, high] and * places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clamp(double min, double max, Tuple3d t) { - if (t.x > max) { + if(t.x > max) { x = max; } else x = Math.max(t.x, min); - if (t.y > max) { + if(t.y > max) { y = max; } else y = Math.max(t.y, min); - if (t.z > max) { + if(t.z > max) { z = max; } else z = Math.max(t.z, min); @@ -446,8 +482,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Clamps the minimum value of the tuple parameter to the min * parameter and places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMin(double min, Tuple3d t) { x = Math.max(t.x, min); @@ -472,8 +510,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Clamps the maximum value of the tuple parameter to the max * parameter and places the values into this tuple. * - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMax(double max, Tuple3d t) { x = Math.min(t.x, max); @@ -489,7 +529,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Sets each component of the tuple parameter to its absolute * value and places the modified values into this tuple. * - * @param t the source tuple, which will not be modified + * @param t + * the source tuple, which will not be modified */ public final void absolute(Tuple3d t) { x = Math.abs(t.x); @@ -511,25 +552,27 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Clamps this tuple to the range [low, high]. * - * @param min the lowest value in this tuple after clamping - * @param max the highest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping + * @param max + * the highest value in this tuple after clamping */ public final void clamp(double min, double max) { - if (x > max) { + if(x > max) { x = max; - } else if (x < min) { + } else if(x < min) { x = min; } - if (y > max) { + if(y > max) { y = max; - } else if (y < min) { + } else if(y < min) { y = min; } - if (z > max) { + if(z > max) { z = max; - } else if (z < min) { + } else if(z < min) { z = min; } @@ -548,12 +591,13 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Clamps the minimum value of this tuple to the min parameter. * - * @param min the lowest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping */ public final void clampMin(double min) { - if (x < min) x = min; - if (y < min) y = min; - if (z < min) z = min; + if(x < min) x = min; + if(y < min) y = min; + if(z < min) z = min; } @@ -569,12 +613,13 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Clamps the maximum value of this tuple to the max parameter. * - * @param max the highest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping */ public final void clampMax(double max) { - if (x > max) x = max; - if (y > max) y = max; - if (z > max) z = max; + if(x > max) x = max; + if(y > max) y = max; + if(z > max) z = max; } @@ -601,9 +646,12 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Linearly interpolates between tuples t1 and t2 and places the * result into this tuple: this = (1-alpha)*t1 + alpha*t2. * - * @param t1 the first tuple - * @param t2 the second tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param t2 + * the second tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple3d t1, Tuple3d t2, double alpha) { this.x = (1 - alpha) * t1.x + alpha * t2.x; @@ -625,8 +673,10 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Linearly interpolates between this tuple and tuple t1 and * places the result into this tuple: this = (1-alpha)*this + alpha*t1. * - * @param t1 the first tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple3d t1, double alpha) { this.x = (1 - alpha) * this.x + alpha * t1.x; @@ -638,7 +688,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * Creates a new object of the same class as this object. * * @return a clone of this instance. - * @throws OutOfMemoryError if there is not enough memory. + * @throws OutOfMemoryError + * if there is not enough memory. * @see java.lang.Cloneable * @since vecmath 1.3 */ @@ -646,7 +697,7 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { // Since there are no arrays we can just use Object.clone() try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch(CloneNotSupportedException e) { Iris.reportError(e); // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -667,7 +718,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Set the x coordinate. * - * @param x value to x coordinate. + * @param x + * value to x coordinate. * @since vecmath 1.5 */ public final void setX(double x) { @@ -689,7 +741,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Set the y coordinate. * - * @param y value to y coordinate. + * @param y + * value to y coordinate. * @since vecmath 1.5 */ public final void setY(double y) { @@ -710,7 +763,8 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { /** * Set the z coordinate. * - * @param z value to z coordinate. + * @param z + * value to z coordinate. * @since vecmath 1.5 */ public final void setZ(double z) { diff --git a/src/main/java/com/volmit/iris/util/math/Tuple3f.java b/src/main/java/com/volmit/iris/util/math/Tuple3f.java index 59d8bb60f..f1a17fdd0 100644 --- a/src/main/java/com/volmit/iris/util/math/Tuple3f.java +++ b/src/main/java/com/volmit/iris/util/math/Tuple3f.java @@ -47,9 +47,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3f from the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public Tuple3f(float x, float y, float z) { this.x = x; @@ -61,7 +64,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3f from the array of length 3. * - * @param t the array of length 3 containing xyz in order + * @param t + * the array of length 3 containing xyz in order */ public Tuple3f(float[] t) { this.x = t[0]; @@ -73,7 +77,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3f from the specified Tuple3f. * - * @param t1 the Tuple3f containing the initialization x y z data + * @param t1 + * the Tuple3f containing the initialization x y z data */ public Tuple3f(Tuple3f t1) { this.x = t1.x; @@ -85,7 +90,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple3f from the specified Tuple3d. * - * @param t1 the Tuple3d containing the initialization x y z data + * @param t1 + * the Tuple3d containing the initialization x y z data */ public Tuple3f(Tuple3d t1) { this.x = (float) t1.x; @@ -118,9 +124,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public final void set(float x, float y, float z) { this.x = x; @@ -133,7 +142,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the xyz coordinates specified in * the array of length 3. * - * @param t the array of length 3 containing xyz in order + * @param t + * the array of length 3 containing xyz in order */ public final void set(float[] t) { this.x = t[0]; @@ -145,7 +155,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple3f t1) { this.x = t1.x; @@ -157,7 +168,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple3d t1) { this.x = (float) t1.x; @@ -169,7 +181,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Gets the value of this tuple and copies the values into t. * - * @param t the array of length 3 into which the values are copied + * @param t + * the array of length 3 into which the values are copied */ public final void get(float[] t) { t[0] = this.x; @@ -181,7 +194,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Gets the value of this tuple and copies the values into t. * - * @param t the Tuple3f object into which the values of this object are copied + * @param t + * the Tuple3f object into which the values of this object are copied */ public final void get(Tuple3f t) { t.x = this.x; @@ -193,8 +207,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the vector sum of tuples t1 and t2. * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void add(Tuple3f t1, Tuple3f t2) { this.x = t1.x + t2.x; @@ -206,7 +222,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the vector sum of itself and tuple t1. * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void add(Tuple3f t1) { this.x += t1.x; @@ -219,8 +236,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the vector difference * of tuples t1 and t2 (this = t1 - t2). * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void sub(Tuple3f t1, Tuple3f t2) { this.x = t1.x - t2.x; @@ -233,7 +252,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the vector difference of * itself and tuple t1 (this = this - t1) . * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void sub(Tuple3f t1) { this.x -= t1.x; @@ -245,7 +265,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the negation of tuple t1. * - * @param t1 the source tuple + * @param t1 + * the source tuple */ public final void negate(Tuple3f t1) { this.x = -t1.x; @@ -268,8 +289,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this vector to the scalar multiplication * of tuple t1. * - * @param s the scalar value - * @param t1 the source tuple + * @param s + * the scalar value + * @param t1 + * the source tuple */ public final void scale(float s, Tuple3f t1) { this.x = s * t1.x; @@ -282,7 +305,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of the scale factor with this. * - * @param s the scalar value + * @param s + * the scalar value */ public final void scale(float s) { this.x *= s; @@ -295,9 +319,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1 and then adds tuple t2 (this = s*t1 + t2). * - * @param s the scalar value - * @param t1 the tuple to be scaled and added - * @param t2 the tuple to be added without a scale + * @param s + * the scalar value + * @param t1 + * the tuple to be scaled and added + * @param t2 + * the tuple to be added without a scale */ public final void scaleAdd(float s, Tuple3f t1, Tuple3f t2) { this.x = s * t1.x + t2.x; @@ -310,8 +337,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself and then adds tuple t1 (this = s*this + t1). * - * @param s the scalar value - * @param t1 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be added */ public final void scaleAdd(float s, Tuple3f t1) { this.x = s * this.x + t1.x; @@ -325,13 +354,14 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple3f. * - * @param t1 the vector with which the comparison is made + * @param t1 + * the vector with which the comparison is made * @return true or false */ public boolean equals(Tuple3f t1) { try { return (this.x == t1.x && this.y == t1.y && this.z == t1.z); - } catch (NullPointerException e2) { + } catch(NullPointerException e2) { Iris.reportError(e2); return false; } @@ -342,14 +372,15 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple3f. * - * @param t1 the Object with which the comparison is made + * @param t1 + * the Object with which the comparison is made * @return true or false */ public boolean equals(Object t1) { try { Tuple3f t2 = (Tuple3f) t1; return (this.x == t2.x && this.y == t2.y && this.z == t2.z); - } catch (NullPointerException | ClassCastException e2) { + } catch(NullPointerException | ClassCastException e2) { Iris.reportError(e2); return false; } @@ -362,23 +393,25 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * otherwise returns false. The L-infinite * distance is equal to MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. * - * @param t1 the tuple to be compared to this tuple - * @param epsilon the threshold value + * @param t1 + * the tuple to be compared to this tuple + * @param epsilon + * the threshold value * @return true or false */ public boolean epsilonEquals(Tuple3f t1, float epsilon) { float diff; diff = x - t1.x; - if (Float.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Float.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = y - t1.y; - if (Float.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Float.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = z - t1.z; - if (Float.isNaN(diff)) return false; + if(Float.isNaN(diff)) return false; return !((diff < 0 ? -diff : diff) > epsilon); } @@ -406,20 +439,23 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Clamps the tuple parameter to the range [low, high] and * places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clamp(float min, float max, Tuple3f t) { - if (t.x > max) { + if(t.x > max) { x = max; } else x = Math.max(t.x, min); - if (t.y > max) { + if(t.y > max) { y = max; } else y = Math.max(t.y, min); - if (t.z > max) { + if(t.z > max) { z = max; } else z = Math.max(t.z, min); @@ -430,8 +466,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Clamps the minimum value of the tuple parameter to the min * parameter and places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMin(float min, Tuple3f t) { x = Math.max(t.x, min); @@ -447,8 +485,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Clamps the maximum value of the tuple parameter to the max * parameter and places the values into this tuple. * - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMax(float max, Tuple3f t) { x = Math.min(t.x, max); @@ -464,7 +504,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Sets each component of the tuple parameter to its absolute * value and places the modified values into this tuple. * - * @param t the source tuple, which will not be modified + * @param t + * the source tuple, which will not be modified */ public final void absolute(Tuple3f t) { x = Math.abs(t.x); @@ -476,25 +517,27 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Clamps this tuple to the range [low, high]. * - * @param min the lowest value in this tuple after clamping - * @param max the highest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping + * @param max + * the highest value in this tuple after clamping */ public final void clamp(float min, float max) { - if (x > max) { + if(x > max) { x = max; - } else if (x < min) { + } else if(x < min) { x = min; } - if (y > max) { + if(y > max) { y = max; - } else if (y < min) { + } else if(y < min) { y = min; } - if (z > max) { + if(z > max) { z = max; - } else if (z < min) { + } else if(z < min) { z = min; } @@ -504,12 +547,13 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Clamps the minimum value of this tuple to the min parameter. * - * @param min the lowest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping */ public final void clampMin(float min) { - if (x < min) x = min; - if (y < min) y = min; - if (z < min) z = min; + if(x < min) x = min; + if(y < min) y = min; + if(z < min) z = min; } @@ -517,12 +561,13 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Clamps the maximum value of this tuple to the max parameter. * - * @param max the highest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping */ public final void clampMax(float max) { - if (x > max) x = max; - if (y > max) y = max; - if (z > max) z = max; + if(x > max) x = max; + if(y > max) y = max; + if(z > max) z = max; } @@ -542,9 +587,12 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Linearly interpolates between tuples t1 and t2 and places the * result into this tuple: this = (1-alpha)*t1 + alpha*t2. * - * @param t1 the first tuple - * @param t2 the second tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param t2 + * the second tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple3f t1, Tuple3f t2, float alpha) { this.x = (1 - alpha) * t1.x + alpha * t2.x; @@ -559,8 +607,10 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Linearly interpolates between this tuple and tuple t1 and * places the result into this tuple: this = (1-alpha)*this + alpha*t1. * - * @param t1 the first tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param alpha + * the alpha interpolation parameter */ public final void interpolate(Tuple3f t1, float alpha) { this.x = (1 - alpha) * this.x + alpha * t1.x; @@ -574,7 +624,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * Creates a new object of the same class as this object. * * @return a clone of this instance. - * @throws OutOfMemoryError if there is not enough memory. + * @throws OutOfMemoryError + * if there is not enough memory. * @see java.lang.Cloneable * @since vecmath 1.3 */ @@ -582,7 +633,7 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { // Since there are no arrays we can just use Object.clone() try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch(CloneNotSupportedException e) { Iris.reportError(e); // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -604,7 +655,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Set the x coordinate. * - * @param x value to x coordinate. + * @param x + * value to x coordinate. * @since vecmath 1.5 */ public final void setX(float x) { @@ -626,7 +678,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Set the y coordinate. * - * @param y value to y coordinate. + * @param y + * value to y coordinate. * @since vecmath 1.5 */ public final void setY(float y) { @@ -647,7 +700,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { /** * Set the Z coordinate. * - * @param z value to z coordinate. + * @param z + * value to z coordinate. * @since vecmath 1.5 */ public final void setZ(float z) { diff --git a/src/main/java/com/volmit/iris/util/math/Tuple4d.java b/src/main/java/com/volmit/iris/util/math/Tuple4d.java index 16d288205..e7ac607ff 100644 --- a/src/main/java/com/volmit/iris/util/math/Tuple4d.java +++ b/src/main/java/com/volmit/iris/util/math/Tuple4d.java @@ -52,10 +52,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4d from the specified xyzw coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param w the w coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate + * @param w + * the w coordinate */ public Tuple4d(double x, double y, double z, double w) { this.x = x; @@ -69,7 +73,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Constructs and initializes a Tuple4d from the coordinates contained * in the array. * - * @param t the array of length 4 containing xyzw in order + * @param t + * the array of length 4 containing xyzw in order */ public Tuple4d(double[] t) { this.x = t[0]; @@ -82,7 +87,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4d from the specified Tuple4d. * - * @param t1 the Tuple4d containing the initialization x y z w data + * @param t1 + * the Tuple4d containing the initialization x y z w data */ public Tuple4d(Tuple4d t1) { this.x = t1.x; @@ -95,7 +101,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4d from the specified Tuple4f. * - * @param t1 the Tuple4f containing the initialization x y z w data + * @param t1 + * the Tuple4f containing the initialization x y z w data */ public Tuple4d(Tuple4f t1) { this.x = t1.x; @@ -119,10 +126,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xyzw coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param w the w coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate + * @param w + * the w coordinate */ public final void set(double x, double y, double z, double w) { this.x = x; @@ -135,7 +146,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xyzw coordinates. * - * @param t the array of length 4 containing xyzw in order + * @param t + * the array of length 4 containing xyzw in order */ public final void set(double[] t) { this.x = t[0]; @@ -148,7 +160,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple4d t1) { this.x = t1.x; @@ -161,7 +174,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple4f t1) { this.x = t1.x; @@ -175,7 +189,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Gets the value of this tuple and places it into the array t of * length four in x,y,z,w order. * - * @param t the array of length four + * @param t + * the array of length four */ public final void get(double[] t) { t[0] = this.x; @@ -190,7 +205,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * argument of * length four in x,y,z,w order. * - * @param t the Tuple into which the values will be copied + * @param t + * the Tuple into which the values will be copied */ public final void get(Tuple4d t) { t.x = this.x; @@ -203,8 +219,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the tuple sum of tuples t1 and t2. * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void add(Tuple4d t1, Tuple4d t2) { this.x = t1.x + t2.x; @@ -217,7 +235,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the sum of itself and tuple t1. * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void add(Tuple4d t1) { this.x += t1.x; @@ -231,8 +250,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the difference * of tuples t1 and t2 (this = t1 - t2). * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void sub(Tuple4d t1, Tuple4d t2) { this.x = t1.x - t2.x; @@ -246,7 +267,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the difference of itself * and tuple t1 (this = this - t1). * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void sub(Tuple4d t1) { this.x -= t1.x; @@ -259,7 +281,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the negation of tuple t1. * - * @param t1 the source tuple + * @param t1 + * the source tuple */ public final void negate(Tuple4d t1) { this.x = -t1.x; @@ -284,8 +307,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of the scale factor with the tuple t1. * - * @param s the scalar value - * @param t1 the source tuple + * @param s + * the scalar value + * @param t1 + * the source tuple */ public final void scale(double s, Tuple4d t1) { this.x = s * t1.x; @@ -299,7 +324,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of the scale factor with this. * - * @param s the scalar value + * @param s + * the scalar value */ public final void scale(double s) { this.x *= s; @@ -313,9 +339,12 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication by s * of tuple t1 plus tuple t2 (this = s*t1 + t2). * - * @param s the scalar value - * @param t1 the tuple to be multipled - * @param t2 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be multipled + * @param t2 + * the tuple to be added */ public final void scaleAdd(double s, Tuple4d t1, Tuple4d t2) { this.x = s * t1.x + t2.x; @@ -338,8 +367,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself and then adds tuple t1 (this = s*this + t1). * - * @param s the scalar value - * @param t1 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be added */ public final void scaleAdd(double s, Tuple4d t1) { this.x = s * this.x + t1.x; @@ -364,14 +395,15 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Returns true if all of the data members of Tuple4d t1 are * equal to the corresponding data members in this Tuple4d. * - * @param t1 the tuple with which the comparison is made + * @param t1 + * the tuple with which the comparison is made * @return true or false */ public boolean equals(Tuple4d t1) { try { return (this.x == t1.x && this.y == t1.y && this.z == t1.z - && this.w == t1.w); - } catch (NullPointerException e2) { + && this.w == t1.w); + } catch(NullPointerException e2) { Iris.reportError(e2); return false; } @@ -382,7 +414,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple4d. * - * @param t1 the object with which the comparison is made + * @param t1 + * the object with which the comparison is made * @return true or false */ public boolean equals(Object t1) { @@ -390,8 +423,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { Tuple4d t2 = (Tuple4d) t1; return (this.x == t2.x && this.y == t2.y && - this.z == t2.z && this.w == t2.w); - } catch (NullPointerException | ClassCastException e2) { + this.z == t2.z && this.w == t2.w); + } catch(NullPointerException | ClassCastException e2) { Iris.reportError(e2); return false; } @@ -405,27 +438,29 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * distance is equal to * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)]. * - * @param t1 the tuple to be compared to this tuple - * @param epsilon the threshold value + * @param t1 + * the tuple to be compared to this tuple + * @param epsilon + * the threshold value * @return true or false */ public boolean epsilonEquals(Tuple4d t1, double epsilon) { double diff; diff = x - t1.x; - if (Double.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Double.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = y - t1.y; - if (Double.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Double.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = z - t1.z; - if (Double.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Double.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = w - t1.w; - if (Double.isNaN(diff)) return false; + if(Double.isNaN(diff)) return false; return !((diff < 0 ? -diff : diff) > epsilon); } @@ -463,24 +498,27 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Clamps the tuple parameter to the range [low, high] and * places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clamp(double min, double max, Tuple4d t) { - if (t.x > max) { + if(t.x > max) { x = max; } else x = Math.max(t.x, min); - if (t.y > max) { + if(t.y > max) { y = max; } else y = Math.max(t.y, min); - if (t.z > max) { + if(t.z > max) { z = max; } else z = Math.max(t.z, min); - if (t.w > max) { + if(t.w > max) { w = max; } else w = Math.max(t.w, min); @@ -500,8 +538,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Clamps the minimum value of the tuple parameter to the min * parameter and places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMin(double min, Tuple4d t) { x = Math.max(t.x, min); @@ -528,8 +568,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Clamps the maximum value of the tuple parameter to the max * parameter and places the values into this tuple. * - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMax(double max, Tuple4d t) { x = Math.min(t.x, max); @@ -538,7 +580,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { z = Math.min(t.z, max); - if (t.w > max) { + if(t.w > max) { w = max; } else { w = t.z; @@ -551,7 +593,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Sets each component of the tuple parameter to its absolute * value and places the modified values into this tuple. * - * @param t the source tuple, which will not be modified + * @param t + * the source tuple, which will not be modified */ public final void absolute(Tuple4d t) { x = Math.abs(t.x); @@ -574,31 +617,33 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Clamps this tuple to the range [low, high]. * - * @param min the lowest value in this tuple after clamping - * @param max the highest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping + * @param max + * the highest value in this tuple after clamping */ public final void clamp(double min, double max) { - if (x > max) { + if(x > max) { x = max; - } else if (x < min) { + } else if(x < min) { x = min; } - if (y > max) { + if(y > max) { y = max; - } else if (y < min) { + } else if(y < min) { y = min; } - if (z > max) { + if(z > max) { z = max; - } else if (z < min) { + } else if(z < min) { z = min; } - if (w > max) { + if(w > max) { w = max; - } else if (w < min) { + } else if(w < min) { w = min; } @@ -617,13 +662,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Clamps the minimum value of this tuple to the min parameter. * - * @param min the lowest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping */ public final void clampMin(double min) { - if (x < min) x = min; - if (y < min) y = min; - if (z < min) z = min; - if (w < min) w = min; + if(x < min) x = min; + if(y < min) y = min; + if(z < min) z = min; + if(w < min) w = min; } @@ -639,13 +685,14 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Clamps the maximum value of this tuple to the max parameter. * - * @param max the highest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping */ public final void clampMax(double max) { - if (x > max) x = max; - if (y > max) y = max; - if (z > max) z = max; - if (w > max) w = max; + if(x > max) x = max; + if(y > max) y = max; + if(z > max) z = max; + if(w > max) w = max; } @@ -675,9 +722,12 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Linearly interpolates between tuples t1 and t2 and places the * result into this tuple: this = (1-alpha)*t1 + alpha*t2. * - * @param t1 the first tuple - * @param t2 the second tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param t2 + * the second tuple + * @param alpha + * the alpha interpolation parameter */ public void interpolate(Tuple4d t1, Tuple4d t2, double alpha) { this.x = (1 - alpha) * t1.x + alpha * t2.x; @@ -700,8 +750,10 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Linearly interpolates between this tuple and tuple t1 and * places the result into this tuple: this = (1-alpha)*this + alpha*t1. * - * @param t1 the first tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param alpha + * the alpha interpolation parameter */ public void interpolate(Tuple4d t1, double alpha) { this.x = (1 - alpha) * this.x + alpha * t1.x; @@ -714,7 +766,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * Creates a new object of the same class as this object. * * @return a clone of this instance. - * @throws OutOfMemoryError if there is not enough memory. + * @throws OutOfMemoryError + * if there is not enough memory. * @see java.lang.Cloneable * @since vecmath 1.3 */ @@ -722,7 +775,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { // Since there are no arrays we can just use Object.clone() try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch(CloneNotSupportedException e) { Iris.reportError(e); // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -743,7 +796,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Set the x coordinate. * - * @param x value to x coordinate. + * @param x + * value to x coordinate. * @since vecmath 1.5 */ public final void setX(double x) { @@ -765,7 +819,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Set the y coordinate. * - * @param y value to y coordinate. + * @param y + * value to y coordinate. * @since vecmath 1.5 */ public final void setY(double y) { @@ -786,7 +841,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Set the z coordinate. * - * @param z value to z coordinate. + * @param z + * value to z coordinate. * @since vecmath 1.5 */ public final void setZ(double z) { @@ -808,7 +864,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { /** * Set the w coordinate. * - * @param w value to w coordinate. + * @param w + * value to w coordinate. * @since vecmath 1.5 */ public final void setW(double w) { diff --git a/src/main/java/com/volmit/iris/util/math/Tuple4f.java b/src/main/java/com/volmit/iris/util/math/Tuple4f.java index 4675cfd89..b34ed1af2 100644 --- a/src/main/java/com/volmit/iris/util/math/Tuple4f.java +++ b/src/main/java/com/volmit/iris/util/math/Tuple4f.java @@ -52,10 +52,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4f from the specified xyzw coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param w the w coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate + * @param w + * the w coordinate */ public Tuple4f(float x, float y, float z, float w) { this.x = x; @@ -68,7 +72,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4f from the array of length 4. * - * @param t the array of length 4 containing xyzw in order + * @param t + * the array of length 4 containing xyzw in order */ public Tuple4f(float[] t) { this.x = t[0]; @@ -81,7 +86,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4f from the specified Tuple4f. * - * @param t1 the Tuple4f containing the initialization x y z w data + * @param t1 + * the Tuple4f containing the initialization x y z w data */ public Tuple4f(Tuple4f t1) { this.x = t1.x; @@ -94,7 +100,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Constructs and initializes a Tuple4f from the specified Tuple4d. * - * @param t1 the Tuple4d containing the initialization x y z w data + * @param t1 + * the Tuple4d containing the initialization x y z w data */ public Tuple4f(Tuple4d t1) { this.x = (float) t1.x; @@ -118,10 +125,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the specified xyzw coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param w the w coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate + * @param w + * the w coordinate */ public final void set(float x, float y, float z, float w) { this.x = x; @@ -135,7 +146,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the specified coordinates in the * array of length 4. * - * @param t the array of length 4 containing xyzw in order + * @param t + * the array of length 4 containing xyzw in order */ public final void set(float[] t) { this.x = t[0]; @@ -148,7 +160,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple4f t1) { this.x = t1.x; @@ -161,7 +174,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the value of tuple t1. * - * @param t1 the tuple to be copied + * @param t1 + * the tuple to be copied */ public final void set(Tuple4d t1) { this.x = (float) t1.x; @@ -174,7 +188,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Copies the values of this tuple into the array t. * - * @param t the array + * @param t + * the array */ public final void get(float[] t) { t[0] = this.x; @@ -187,7 +202,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Copies the values of this tuple into the tuple t. * - * @param t the target tuple + * @param t + * the target tuple */ public final void get(Tuple4f t) { t.x = this.x; @@ -200,8 +216,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the sum of tuples t1 and t2. * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void add(Tuple4f t1, Tuple4f t2) { this.x = t1.x + t2.x; @@ -214,7 +232,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the sum of itself and t1. * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void add(Tuple4f t1) { this.x += t1.x; @@ -228,8 +247,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the difference * of tuples t1 and t2 (this = t1 - t2). * - * @param t1 the first tuple - * @param t2 the second tuple + * @param t1 + * the first tuple + * @param t2 + * the second tuple */ public final void sub(Tuple4f t1, Tuple4f t2) { this.x = t1.x - t2.x; @@ -243,7 +264,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the difference * of itself and t1 (this = this - t1). * - * @param t1 the other tuple + * @param t1 + * the other tuple */ public final void sub(Tuple4f t1) { this.x -= t1.x; @@ -256,7 +278,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Sets the value of this tuple to the negation of tuple t1. * - * @param t1 the source tuple + * @param t1 + * the source tuple */ public final void negate(Tuple4f t1) { this.x = -t1.x; @@ -281,8 +304,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1. * - * @param s the scalar value - * @param t1 the source tuple + * @param s + * the scalar value + * @param t1 + * the source tuple */ public final void scale(float s, Tuple4f t1) { this.x = s * t1.x; @@ -296,7 +321,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of the scale factor with this. * - * @param s the scalar value + * @param s + * the scalar value */ public final void scale(float s) { this.x *= s; @@ -310,9 +336,12 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of tuple t1 plus tuple t2 (this = s*t1 + t2). * - * @param s the scalar value - * @param t1 the tuple to be multipled - * @param t2 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be multipled + * @param t2 + * the tuple to be added */ public final void scaleAdd(float s, Tuple4f t1, Tuple4f t2) { this.x = s * t1.x + t2.x; @@ -326,8 +355,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets the value of this tuple to the scalar multiplication * of itself and then adds tuple t1 (this = s*this + t1). * - * @param s the scalar value - * @param t1 the tuple to be added + * @param s + * the scalar value + * @param t1 + * the tuple to be added */ public final void scaleAdd(float s, Tuple4f t1) { this.x = s * this.x + t1.x; @@ -351,14 +382,15 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Returns true if all of the data members of Tuple4f t1 are * equal to the corresponding data members in this Tuple4f. * - * @param t1 the vector with which the comparison is made + * @param t1 + * the vector with which the comparison is made * @return true or false */ public boolean equals(Tuple4f t1) { try { return (this.x == t1.x && this.y == t1.y && this.z == t1.z - && this.w == t1.w); - } catch (NullPointerException e2) { + && this.w == t1.w); + } catch(NullPointerException e2) { Iris.reportError(e2); return false; } @@ -369,15 +401,16 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * data members of t1 are equal to the corresponding data members in * this Tuple4f. * - * @param t1 the object with which the comparison is made + * @param t1 + * the object with which the comparison is made * @return true or false */ public boolean equals(Object t1) { try { Tuple4f t2 = (Tuple4f) t1; return (this.x == t2.x && this.y == t2.y && - this.z == t2.z && this.w == t2.w); - } catch (NullPointerException | ClassCastException e2) { + this.z == t2.z && this.w == t2.w); + } catch(NullPointerException | ClassCastException e2) { Iris.reportError(e2); return false; } @@ -391,27 +424,29 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * distance is equal to * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2), abs(w1-w2)]. * - * @param t1 the tuple to be compared to this tuple - * @param epsilon the threshold value + * @param t1 + * the tuple to be compared to this tuple + * @param epsilon + * the threshold value * @return true or false */ public boolean epsilonEquals(Tuple4f t1, float epsilon) { float diff; diff = x - t1.x; - if (Float.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Float.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = y - t1.y; - if (Float.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Float.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = z - t1.z; - if (Float.isNaN(diff)) return false; - if ((diff < 0 ? -diff : diff) > epsilon) return false; + if(Float.isNaN(diff)) return false; + if((diff < 0 ? -diff : diff) > epsilon) return false; diff = w - t1.w; - if (Float.isNaN(diff)) return false; + if(Float.isNaN(diff)) return false; return !((diff < 0 ? -diff : diff) > epsilon); } @@ -439,24 +474,27 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Clamps the tuple parameter to the range [low, high] and * places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clamp(float min, float max, Tuple4f t) { - if (t.x > max) { + if(t.x > max) { x = max; } else x = Math.max(t.x, min); - if (t.y > max) { + if(t.y > max) { y = max; } else y = Math.max(t.y, min); - if (t.z > max) { + if(t.z > max) { z = max; } else z = Math.max(t.z, min); - if (t.w > max) { + if(t.w > max) { w = max; } else w = Math.max(t.w, min); @@ -467,8 +505,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Clamps the minimum value of the tuple parameter to the min * parameter and places the values into this tuple. * - * @param min the lowest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param min + * the lowest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMin(float min, Tuple4f t) { x = Math.max(t.x, min); @@ -487,8 +527,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Clamps the maximum value of the tuple parameter to the max * parameter and places the values into this tuple. * - * @param max the highest value in the tuple after clamping - * @param t the source tuple, which will not be modified + * @param max + * the highest value in the tuple after clamping + * @param t + * the source tuple, which will not be modified */ public final void clampMax(float max, Tuple4f t) { x = Math.min(t.x, max); @@ -497,7 +539,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { z = Math.min(t.z, max); - if (t.w > max) { + if(t.w > max) { w = max; } else { w = t.z; @@ -510,7 +552,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Sets each component of the tuple parameter to its absolute * value and places the modified values into this tuple. * - * @param t the source tuple, which will not be modified + * @param t + * the source tuple, which will not be modified */ public final void absolute(Tuple4f t) { x = Math.abs(t.x); @@ -523,31 +566,33 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Clamps this tuple to the range [low, high]. * - * @param min the lowest value in this tuple after clamping - * @param max the highest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping + * @param max + * the highest value in this tuple after clamping */ public final void clamp(float min, float max) { - if (x > max) { + if(x > max) { x = max; - } else if (x < min) { + } else if(x < min) { x = min; } - if (y > max) { + if(y > max) { y = max; - } else if (y < min) { + } else if(y < min) { y = min; } - if (z > max) { + if(z > max) { z = max; - } else if (z < min) { + } else if(z < min) { z = min; } - if (w > max) { + if(w > max) { w = max; - } else if (w < min) { + } else if(w < min) { w = min; } @@ -557,13 +602,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Clamps the minimum value of this tuple to the min parameter. * - * @param min the lowest value in this tuple after clamping + * @param min + * the lowest value in this tuple after clamping */ public final void clampMin(float min) { - if (x < min) x = min; - if (y < min) y = min; - if (z < min) z = min; - if (w < min) w = min; + if(x < min) x = min; + if(y < min) y = min; + if(z < min) z = min; + if(w < min) w = min; } @@ -571,13 +617,14 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Clamps the maximum value of this tuple to the max parameter. * - * @param max the highest value in the tuple after clamping + * @param max + * the highest value in the tuple after clamping */ public final void clampMax(float max) { - if (x > max) x = max; - if (y > max) y = max; - if (z > max) z = max; - if (w > max) w = max; + if(x > max) x = max; + if(y > max) y = max; + if(z > max) z = max; + if(w > max) w = max; } @@ -597,9 +644,12 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Linearly interpolates between tuples t1 and t2 and places the * result into this tuple: this = (1-alpha)*t1 + alpha*t2. * - * @param t1 the first tuple - * @param t2 the second tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param t2 + * the second tuple + * @param alpha + * the alpha interpolation parameter */ public void interpolate(Tuple4f t1, Tuple4f t2, float alpha) { this.x = (1 - alpha) * t1.x + alpha * t2.x; @@ -614,8 +664,10 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Linearly interpolates between this tuple and tuple t1 and * places the result into this tuple: this = (1-alpha)*this + alpha*t1. * - * @param t1 the first tuple - * @param alpha the alpha interpolation parameter + * @param t1 + * the first tuple + * @param alpha + * the alpha interpolation parameter */ public void interpolate(Tuple4f t1, float alpha) { this.x = (1 - alpha) * this.x + alpha * t1.x; @@ -629,7 +681,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * Creates a new object of the same class as this object. * * @return a clone of this instance. - * @throws OutOfMemoryError if there is not enough memory. + * @throws OutOfMemoryError + * if there is not enough memory. * @see java.lang.Cloneable * @since vecmath 1.3 */ @@ -637,7 +690,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { // Since there are no arrays we can just use Object.clone() try { return super.clone(); - } catch (CloneNotSupportedException e) { + } catch(CloneNotSupportedException e) { Iris.reportError(e); // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -658,7 +711,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Set the x coordinate. * - * @param x value to x coordinate. + * @param x + * value to x coordinate. * @since vecmath 1.5 */ public final void setX(float x) { @@ -680,7 +734,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Set the y coordinate. * - * @param y value to y coordinate. + * @param y + * value to y coordinate. * @since vecmath 1.5 */ public final void setY(float y) { @@ -701,7 +756,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Set the z coordinate. * - * @param z value to z coordinate. + * @param z + * value to z coordinate. * @since vecmath 1.5 */ public final void setZ(float z) { @@ -723,7 +779,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { /** * Set the w coordinate. * - * @param w value to w coordinate. + * @param w + * value to w coordinate. * @since vecmath 1.5 */ public final void setW(float w) { diff --git a/src/main/java/com/volmit/iris/util/math/VecMathUtil.java b/src/main/java/com/volmit/iris/util/math/VecMathUtil.java index fd1f6a61d..b44489b34 100644 --- a/src/main/java/com/volmit/iris/util/math/VecMathUtil.java +++ b/src/main/java/com/volmit/iris/util/math/VecMathUtil.java @@ -44,13 +44,14 @@ class VecMathUtil { * which has a field with a value of -0.0f and the other of which * has a cooresponding field with a value of 0.0f. * - * @param f an input floating-point number + * @param f + * an input floating-point number * @return the integer bits representing that floating-point * number, after first mapping -0.0f to 0.0f */ static int floatToIntBits(float f) { // Check for +0 or -0 - if (f == 0.0f) { + if(f == 0.0f) { return 0; } else { return Float.floatToIntBits(f); @@ -72,13 +73,14 @@ class VecMathUtil { * which has a field with a value of -0.0 and the other of which * has a cooresponding field with a value of 0.0. * - * @param d an input double precision floating-point number + * @param d + * an input double precision floating-point number * @return the integer bits representing that floating-point * number, after first mapping -0.0f to 0.0f */ static long doubleToLongBits(double d) { // Check for +0 or -0 - if (d == 0.0) { + if(d == 0.0) { return 0L; } else { return Double.doubleToLongBits(d); diff --git a/src/main/java/com/volmit/iris/util/math/Vector2d.java b/src/main/java/com/volmit/iris/util/math/Vector2d.java index 6d1122774..263eb2daa 100644 --- a/src/main/java/com/volmit/iris/util/math/Vector2d.java +++ b/src/main/java/com/volmit/iris/util/math/Vector2d.java @@ -30,8 +30,10 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Constructs and initializes a Vector2d from the specified xy coordinates. * - * @param x the x coordinate - * @param y the y coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate */ public Vector2d(double x, double y) { super(x, y); @@ -41,7 +43,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Constructs and initializes a Vector2d from the specified array. * - * @param v the array of length 2 containing xy in order + * @param v + * the array of length 2 containing xy in order */ public Vector2d(double[] v) { super(v); @@ -51,7 +54,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Constructs and initializes a Vector2d from the specified Vector2d. * - * @param v1 the Vector2d containing the initialization x y data + * @param v1 + * the Vector2d containing the initialization x y data */ public Vector2d(Vector2d v1) { super(v1); @@ -61,7 +65,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Constructs and initializes a Vector2d from the specified Vector2f. * - * @param v1 the Vector2f containing the initialization x y data + * @param v1 + * the Vector2f containing the initialization x y data */ public Vector2d(Vector2f v1) { super(v1); @@ -71,7 +76,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Constructs and initializes a Vector2d from the specified Tuple2d. * - * @param t1 the Tuple2d containing the initialization x y data + * @param t1 + * the Tuple2d containing the initialization x y data */ public Vector2d(Tuple2d t1) { super(t1); @@ -81,7 +87,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Constructs and initializes a Vector2d from the specified Tuple2f. * - * @param t1 the Tuple2f containing the initialization x y data + * @param t1 + * the Tuple2f containing the initialization x y data */ public Vector2d(Tuple2f t1) { super(t1); @@ -99,7 +106,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Computes the dot product of the this vector and vector v1. * - * @param v1 the other vector + * @param v1 + * the other vector */ public final double dot(Vector2d v1) { return (this.x * v1.x + this.y * v1.y); @@ -127,7 +135,8 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { /** * Sets the value of this vector to the normalization of vector v1. * - * @param v1 the un-normalized vector + * @param v1 + * the un-normalized vector */ public final void normalize(Vector2d v1) { double norm; @@ -153,13 +162,14 @@ public class Vector2d extends Tuple2d implements java.io.Serializable { * Returns the angle in radians between this vector and the vector * parameter; the return value is constrained to the range [0,PI]. * - * @param v1 the other vector + * @param v1 + * the other vector * @return the angle in radians in the range [0,PI] */ public final double angle(Vector2d v1) { double vDot = this.dot(v1) / (this.length() * v1.length()); - if (vDot < -1.0) vDot = -1.0; - if (vDot > 1.0) vDot = 1.0; + if(vDot < -1.0) vDot = -1.0; + if(vDot > 1.0) vDot = 1.0; return Math.acos(vDot); } diff --git a/src/main/java/com/volmit/iris/util/math/Vector2f.java b/src/main/java/com/volmit/iris/util/math/Vector2f.java index 76d55d76a..169487733 100644 --- a/src/main/java/com/volmit/iris/util/math/Vector2f.java +++ b/src/main/java/com/volmit/iris/util/math/Vector2f.java @@ -30,8 +30,10 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Constructs and initializes a Vector2f from the specified xy coordinates. * - * @param x the x coordinate - * @param y the y coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate */ public Vector2f(float x, float y) { super(x, y); @@ -41,7 +43,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Constructs and initializes a Vector2f from the specified array. * - * @param v the array of length 2 containing xy in order + * @param v + * the array of length 2 containing xy in order */ public Vector2f(float[] v) { super(v); @@ -51,7 +54,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Constructs and initializes a Vector2f from the specified Vector2f. * - * @param v1 the Vector2f containing the initialization x y data + * @param v1 + * the Vector2f containing the initialization x y data */ public Vector2f(Vector2f v1) { super(v1); @@ -61,7 +65,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Constructs and initializes a Vector2f from the specified Vector2d. * - * @param v1 the Vector2d containing the initialization x y data + * @param v1 + * the Vector2d containing the initialization x y data */ public Vector2f(Vector2d v1) { super(v1); @@ -71,7 +76,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Constructs and initializes a Vector2f from the specified Tuple2f. * - * @param t1 the Tuple2f containing the initialization x y data + * @param t1 + * the Tuple2f containing the initialization x y data */ public Vector2f(Tuple2f t1) { super(t1); @@ -81,7 +87,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Constructs and initializes a Vector2f from the specified Tuple2d. * - * @param t1 the Tuple2d containing the initialization x y data + * @param t1 + * the Tuple2d containing the initialization x y data */ public Vector2f(Tuple2d t1) { super(t1); @@ -99,7 +106,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Computes the dot product of the this vector and vector v1. * - * @param v1 the other vector + * @param v1 + * the other vector */ public final float dot(Vector2f v1) { return (this.x * v1.x + this.y * v1.y); @@ -127,7 +135,8 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { /** * Sets the value of this vector to the normalization of vector v1. * - * @param v1 the un-normalized vector + * @param v1 + * the un-normalized vector */ public final void normalize(Vector2f v1) { float norm; @@ -144,7 +153,7 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { float norm; norm = (float) - (1.0 / Math.sqrt(this.x * this.x + this.y * this.y)); + (1.0 / Math.sqrt(this.x * this.x + this.y * this.y)); this.x *= norm; this.y *= norm; } @@ -154,13 +163,14 @@ public class Vector2f extends Tuple2f implements java.io.Serializable { * Returns the angle in radians between this vector and the vector * parameter; the return value is constrained to the range [0,PI]. * - * @param v1 the other vector + * @param v1 + * the other vector * @return the angle in radians in the range [0,PI] */ public final float angle(Vector2f v1) { double vDot = this.dot(v1) / (this.length() * v1.length()); - if (vDot < -1.0) vDot = -1.0; - if (vDot > 1.0) vDot = 1.0; + if(vDot < -1.0) vDot = -1.0; + if(vDot > 1.0) vDot = 1.0; return ((float) (Math.acos(vDot))); } diff --git a/src/main/java/com/volmit/iris/util/math/Vector3d.java b/src/main/java/com/volmit/iris/util/math/Vector3d.java index f0f748983..f7c49d482 100644 --- a/src/main/java/com/volmit/iris/util/math/Vector3d.java +++ b/src/main/java/com/volmit/iris/util/math/Vector3d.java @@ -31,9 +31,12 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Vector3d from the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public Vector3d(double x, double y, double z) { super(x, y, z); @@ -43,7 +46,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Vector3d from the array of length 3. * - * @param v the array of length 3 containing xyz in order + * @param v + * the array of length 3 containing xyz in order */ public Vector3d(double[] v) { super(v); @@ -53,7 +57,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Vector3d from the specified Vector3d. * - * @param v1 the Vector3d containing the initialization x y z data + * @param v1 + * the Vector3d containing the initialization x y z data */ public Vector3d(Vector3d v1) { super(v1); @@ -63,7 +68,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Vector3d from the specified Vector3f. * - * @param v1 the Vector3f containing the initialization x y z data + * @param v1 + * the Vector3f containing the initialization x y z data */ public Vector3d(Vector3f v1) { super(v1); @@ -73,7 +79,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Vector3d from the specified Tuple3f. * - * @param t1 the Tuple3f containing the initialization x y z data + * @param t1 + * the Tuple3f containing the initialization x y z data */ public Vector3d(Tuple3f t1) { super(t1); @@ -83,7 +90,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Constructs and initializes a Vector3d from the specified Tuple3d. * - * @param t1 the Tuple3d containing the initialization x y z data + * @param t1 + * the Tuple3d containing the initialization x y z data */ public Vector3d(Tuple3d t1) { super(t1); @@ -101,8 +109,10 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Sets this vector to the vector cross product of vectors v1 and v2. * - * @param v1 the first vector - * @param v2 the second vector + * @param v1 + * the first vector + * @param v2 + * the second vector */ public final void cross(Vector3d v1, Vector3d v2) { double x, y; @@ -118,7 +128,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Sets the value of this vector to the normalization of vector v1. * - * @param v1 the un-normalized vector + * @param v1 + * the un-normalized vector */ public final void normalize(Vector3d v1) { double norm; @@ -146,7 +157,8 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { /** * Returns the dot product of this vector and vector v1. * - * @param v1 the other vector + * @param v1 + * the other vector * @return the dot product of this and v1 */ public final double dot(Vector3d v1) { @@ -178,13 +190,14 @@ public class Vector3d extends Tuple3d implements java.io.Serializable { * Returns the angle in radians between this vector and the vector * parameter; the return value is constrained to the range [0,PI]. * - * @param v1 the other vector + * @param v1 + * the other vector * @return the angle in radians in the range [0,PI] */ public final double angle(Vector3d v1) { double vDot = this.dot(v1) / (this.length() * v1.length()); - if (vDot < -1.0) vDot = -1.0; - if (vDot > 1.0) vDot = 1.0; + if(vDot < -1.0) vDot = -1.0; + if(vDot > 1.0) vDot = 1.0; return Math.acos(vDot); } diff --git a/src/main/java/com/volmit/iris/util/math/Vector3f.java b/src/main/java/com/volmit/iris/util/math/Vector3f.java index bc961a8e2..29220842d 100644 --- a/src/main/java/com/volmit/iris/util/math/Vector3f.java +++ b/src/main/java/com/volmit/iris/util/math/Vector3f.java @@ -31,9 +31,12 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Vector3f from the specified xyz coordinates. * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate + * @param x + * the x coordinate + * @param y + * the y coordinate + * @param z + * the z coordinate */ public Vector3f(float x, float y, float z) { super(x, y, z); @@ -43,7 +46,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Vector3f from the array of length 3. * - * @param v the array of length 3 containing xyz in order + * @param v + * the array of length 3 containing xyz in order */ public Vector3f(float[] v) { super(v); @@ -53,7 +57,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Vector3f from the specified Vector3f. * - * @param v1 the Vector3f containing the initialization x y z data + * @param v1 + * the Vector3f containing the initialization x y z data */ public Vector3f(Vector3f v1) { super(v1); @@ -63,7 +68,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Vector3f from the specified Vector3d. * - * @param v1 the Vector3d containing the initialization x y z data + * @param v1 + * the Vector3d containing the initialization x y z data */ public Vector3f(Vector3d v1) { super(v1); @@ -73,7 +79,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Vector3f from the specified Tuple3f. * - * @param t1 the Tuple3f containing the initialization x y z data + * @param t1 + * the Tuple3f containing the initialization x y z data */ public Vector3f(Tuple3f t1) { super(t1); @@ -83,7 +90,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Constructs and initializes a Vector3f from the specified Tuple3d. * - * @param t1 the Tuple3d containing the initialization x y z data + * @param t1 + * the Tuple3d containing the initialization x y z data */ public Vector3f(Tuple3d t1) { super(t1); @@ -114,15 +122,17 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { */ public final float length() { return (float) - Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } /** * Sets this vector to be the vector cross product of vectors v1 and v2. * - * @param v1 the first vector - * @param v2 the second vector + * @param v1 + * the first vector + * @param v2 + * the second vector */ public final void cross(Vector3f v1, Vector3f v2) { float x, y; @@ -137,7 +147,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Computes the dot product of this vector and vector v1. * - * @param v1 the other vector + * @param v1 + * the other vector * @return the dot product of this vector and v1 */ public final float dot(Vector3f v1) { @@ -147,7 +158,8 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { /** * Sets the value of this vector to the normalization of vector v1. * - * @param v1 the un-normalized vector + * @param v1 + * the un-normalized vector */ public final void normalize(Vector3f v1) { float norm; @@ -165,7 +177,7 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { float norm; norm = (float) - (1.0 / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z)); + (1.0 / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z)); this.x *= norm; this.y *= norm; this.z *= norm; @@ -176,13 +188,14 @@ public class Vector3f extends Tuple3f implements java.io.Serializable { * Returns the angle in radians between this vector and the vector * parameter; the return value is constrained to the range [0,PI]. * - * @param v1 the other vector + * @param v1 + * the other vector * @return the angle in radians in the range [0,PI] */ public final float angle(Vector3f v1) { double vDot = this.dot(v1) / (this.length() * v1.length()); - if (vDot < -1.0) vDot = -1.0; - if (vDot > 1.0) vDot = 1.0; + if(vDot < -1.0) vDot = -1.0; + if(vDot > 1.0) vDot = 1.0; return ((float) (Math.acos(vDot))); } diff --git a/src/main/java/com/volmit/iris/util/math/VectorMath.java b/src/main/java/com/volmit/iris/util/math/VectorMath.java index 072035d45..cd93cf6b0 100644 --- a/src/main/java/com/volmit/iris/util/math/VectorMath.java +++ b/src/main/java/com/volmit/iris/util/math/VectorMath.java @@ -35,7 +35,7 @@ import org.bukkit.util.Vector; */ public class VectorMath { public static Vector scaleStatic(Axis x, Vector v, double amt) { - return switch (x) { + return switch(x) { case X -> scaleX(v, amt); case Y -> scaleY(v, amt); case Z -> scaleZ(v, amt); @@ -84,10 +84,10 @@ public class VectorMath { } public static Vector rotate(Direction current, Direction to, Vector v) { - if (current.equals(to)) { + if(current.equals(to)) { return v; - } else if (current.equals(to.reverse())) { - if (current.isVertical()) { + } else if(current.equals(to.reverse())) { + if(current.isVertical()) { return new Vector(v.getX(), -v.getY(), v.getZ()); } else { return new Vector(-v.getX(), v.getY(), -v.getZ()); @@ -95,20 +95,20 @@ public class VectorMath { } else { Vector c = current.toVector().clone().add(to.toVector()); - if (c.getX() == 0) { - if (c.getY() != c.getZ()) { + if(c.getX() == 0) { + if(c.getY() != c.getZ()) { return rotate90CX(v); } return rotate90CCX(v); - } else if (c.getY() == 0) { - if (c.getX() != c.getZ()) { + } else if(c.getY() == 0) { + if(c.getX() != c.getZ()) { return rotate90CY(v); } return rotate90CCY(v); - } else if (c.getZ() == 0) { - if (c.getX() != c.getY()) { + } else if(c.getZ() == 0) { + if(c.getX() != c.getY()) { return rotate90CZ(v); } @@ -126,10 +126,10 @@ public class VectorMath { // 0 Z X 0 public static Vector rotate(Direction current, Direction to, Vector v, int w, int h, int d) { - if (current.equals(to)) { + if(current.equals(to)) { return v; - } else if (current.equals(to.reverse())) { - if (current.isVertical()) { + } else if(current.equals(to.reverse())) { + if(current.isVertical()) { return new Vector(v.getX(), -v.getY() + h, v.getZ()); } else { return new Vector(-v.getX() + w, v.getY(), -v.getZ() + d); @@ -137,20 +137,20 @@ public class VectorMath { } else { Vector c = current.toVector().clone().add(to.toVector()); - if (c.getX() == 0) { - if (c.getY() != c.getZ()) { + if(c.getX() == 0) { + if(c.getY() != c.getZ()) { return rotate90CX(v, d); } return rotate90CCX(v, h); - } else if (c.getY() == 0) { - if (c.getX() != c.getZ()) { + } else if(c.getY() == 0) { + if(c.getX() != c.getZ()) { return rotate90CY(v, d); } return rotate90CCY(v, w); - } else if (c.getZ() == 0) { - if (c.getX() != c.getY()) { + } else if(c.getZ() == 0) { + if(c.getX() != c.getY()) { return rotate90CZ(v, w); } @@ -210,11 +210,11 @@ public class VectorMath { } public static Vector getAxis(Direction current, Direction to) { - if (current.equals(Direction.U) || current.equals(Direction.D)) { - if (to.equals(Direction.U) || to.equals(Direction.D)) { + if(current.equals(Direction.U) || current.equals(Direction.D)) { + if(to.equals(Direction.U) || to.equals(Direction.D)) { return new Vector(1, 0, 0); } else { - if (current.equals(Direction.N) || current.equals(Direction.S)) { + if(current.equals(Direction.N) || current.equals(Direction.S)) { return Direction.E.toVector(); } else { return Direction.S.toVector(); @@ -258,13 +258,14 @@ public class VectorMath { * Get all SIMPLE block faces from a more specific block face (SOUTH_EAST) = * (south, east) * - * @param f the block face + * @param f + * the block face * @return multiple faces, or one if the face is already simple */ public static KList split(BlockFace f) { KList faces = new KList<>(); - switch (f) { + switch(f) { case DOWN: faces.add(BlockFace.DOWN); break; @@ -352,8 +353,10 @@ public class VectorMath { /** * Get a normalized vector going from a location to another * - * @param from from here - * @param to to here + * @param from + * from here + * @param to + * to here * @return the normalized vector direction */ public static Vector direction(Location from, Location to) { @@ -367,8 +370,10 @@ public class VectorMath { /** * Get the vector direction from the yaw and pitch * - * @param yaw the yaw - * @param pitch the pitch + * @param yaw + * the yaw + * @param pitch + * the pitch * @return the vector */ public static Vector toVector(float yaw, float pitch) { @@ -378,8 +383,10 @@ public class VectorMath { /** * Add an impulse (force) to an entity * - * @param e the entity - * @param v the vector + * @param e + * the entity + * @param v + * the vector */ public static void impulse(Entity e, Vector v) { impulse(e, v, 1.0); @@ -388,9 +395,12 @@ public class VectorMath { /** * Add an impulse (force) on an entity * - * @param e the entity - * @param v the vector - * @param effectiveness the effectiveness + * @param e + * the entity + * @param v + * the vector + * @param effectiveness + * the effectiveness */ public static void impulse(Entity e, Vector v, double effectiveness) { Vector vx = e.getVelocity(); @@ -401,19 +411,20 @@ public class VectorMath { /** * Reverse a direction * - * @param v the direction + * @param v + * the direction * @return the reversed direction */ public static Vector reverse(Vector v) { - if (v.getX() != 0) { + if(v.getX() != 0) { v.setX(-v.getX()); } - if (v.getY() != 0) { + if(v.getY() != 0) { v.setY(-v.getY()); } - if (v.getZ() != 0) { + if(v.getZ() != 0) { v.setZ(-v.getZ()); } @@ -423,7 +434,8 @@ public class VectorMath { /** * Get a speed value from a vector (velocity) * - * @param v the vector + * @param v + * the vector * @return the speed */ public static double getSpeed(Vector v) { @@ -436,8 +448,10 @@ public class VectorMath { /** * Shift all vectors based on the given vector * - * @param vector the vector direction to shift the vectors - * @param vectors the vectors to be shifted + * @param vector + * the vector direction to shift the vectors + * @param vectors + * the vectors to be shifted * @return the shifted vectors */ public static KList shift(Vector vector, KList vectors) { @@ -452,38 +466,39 @@ public class VectorMath { /** * Attempt to get the blockFace for the vector (will be tri-normalized) * - * @param v the vector + * @param v + * the vector * @return the block face or null */ public static BlockFace getBlockFace(Vector v) { Vector p = triNormalize(v); - for (BlockFace i : BlockFace.values()) { - if (p.getX() == i.getModX() && p.getY() == i.getModY() && p.getZ() == i.getModZ()) { + for(BlockFace i : BlockFace.values()) { + if(p.getX() == i.getModX() && p.getY() == i.getModY() && p.getZ() == i.getModZ()) { return i; } } - for (BlockFace i : BlockFace.values()) { - if (p.getX() == i.getModX() && p.getZ() == i.getModZ()) { + for(BlockFace i : BlockFace.values()) { + if(p.getX() == i.getModX() && p.getZ() == i.getModZ()) { return i; } } - for (BlockFace i : BlockFace.values()) { - if (p.getY() == i.getModY() && p.getZ() == i.getModZ()) { + for(BlockFace i : BlockFace.values()) { + if(p.getY() == i.getModY() && p.getZ() == i.getModZ()) { return i; } } - for (BlockFace i : BlockFace.values()) { - if (p.getX() == i.getModX() || p.getY() == i.getModY()) { + for(BlockFace i : BlockFace.values()) { + if(p.getX() == i.getModX() || p.getY() == i.getModY()) { return i; } } - for (BlockFace i : BlockFace.values()) { - if (p.getX() == i.getModX() || p.getY() == i.getModY() || p.getZ() == i.getModZ()) { + for(BlockFace i : BlockFace.values()) { + if(p.getX() == i.getModX() || p.getY() == i.getModY() || p.getZ() == i.getModZ()) { return i; } } @@ -494,8 +509,10 @@ public class VectorMath { /** * Angle the vector in a self relative direction * - * @param v the initial direction - * @param amt the amount to shift in the direction + * @param v + * the initial direction + * @param amt + * the amount to shift in the direction * @return the shifted direction */ public static Vector angleLeft(Vector v, float amt) { @@ -517,8 +534,10 @@ public class VectorMath { /** * Angle the vector in a self relative direction * - * @param v the initial direction - * @param amt the amount to shift in the direction + * @param v + * the initial direction + * @param amt + * the amount to shift in the direction * @return the shifted direction */ public static Vector angleRight(Vector v, float amt) { @@ -540,8 +559,10 @@ public class VectorMath { /** * Angle the vector in a self relative direction * - * @param v the initial direction - * @param amt the amount to shift in the direction + * @param v + * the initial direction + * @param amt + * the amount to shift in the direction * @return the shifted direction */ public static Vector angleUp(Vector v, float amt) { @@ -560,8 +581,10 @@ public class VectorMath { /** * Angle the vector in a self relative direction * - * @param v the initial direction - * @param amt the amount to shift in the direction + * @param v + * the initial direction + * @param amt + * the amount to shift in the direction * @return the shifted direction */ public static Vector angleDown(Vector v, float amt) { @@ -581,32 +604,33 @@ public class VectorMath { * (clone) Force normalize the vector into three points, 1, 0, or -1. If the * value is > 0.333 (1) if the value is less than -0.333 (-1) else 0 * - * @param direction the direction + * @param direction + * the direction * @return the vector */ public static Vector triNormalize(Vector direction) { Vector v = direction.clone(); v.normalize(); - if (v.getX() > 0.333) { + if(v.getX() > 0.333) { v.setX(1); - } else if (v.getX() < -0.333) { + } else if(v.getX() < -0.333) { v.setX(-1); } else { v.setX(0); } - if (v.getY() > 0.333) { + if(v.getY() > 0.333) { v.setY(1); - } else if (v.getY() < -0.333) { + } else if(v.getY() < -0.333) { v.setY(-1); } else { v.setY(0); } - if (v.getZ() > 0.333) { + if(v.getZ() > 0.333) { v.setZ(1); - } else if (v.getZ() < -0.333) { + } else if(v.getZ() < -0.333) { v.setZ(-1); } else { v.setZ(0); diff --git a/src/main/java/com/volmit/iris/util/matter/IrisMatter.java b/src/main/java/com/volmit/iris/util/matter/IrisMatter.java index 1e4893192..337bce147 100644 --- a/src/main/java/com/volmit/iris/util/matter/IrisMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/IrisMatter.java @@ -44,8 +44,7 @@ public class IrisMatter extends IrisRegistrant implements Matter { private final KMap, MatterSlice> sliceMap; public IrisMatter(int width, int height, int depth) { - if(width < 1 || height < 1 || depth < 1) - { + if(width < 1 || height < 1 || depth < 1) { throw new RuntimeException("Invalid Matter Size " + width + "x" + height + "x" + depth); } @@ -58,7 +57,7 @@ public class IrisMatter extends IrisRegistrant implements Matter { private static KMap, MatterSlice> buildSlicers() { KMap, MatterSlice> c = new KMap<>(); - for (Object i : Iris.initialize("com.volmit.iris.util.matter.slices", Sliced.class)) { + for(Object i : Iris.initialize("com.volmit.iris.util.matter.slices", Sliced.class)) { MatterSlice s = (MatterSlice) i; c.put(s.getType(), s); } @@ -70,13 +69,13 @@ public class IrisMatter extends IrisRegistrant implements Matter { public MatterSlice createSlice(Class type, Matter m) { MatterSlice slice = slicers.get(type); - if (slice == null) { + if(slice == null) { return null; } try { return slice.getClass().getConstructor(int.class, int.class, int.class).newInstance(getWidth(), getHeight(), getDepth()); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/matter/Matter.java b/src/main/java/com/volmit/iris/util/matter/Matter.java index 1254822cb..50413e69c 100644 --- a/src/main/java/com/volmit/iris/util/matter/Matter.java +++ b/src/main/java/com/volmit/iris/util/matter/Matter.java @@ -22,7 +22,6 @@ import com.volmit.iris.Iris; import com.volmit.iris.engine.object.IrisObject; import com.volmit.iris.engine.object.IrisPosition; import com.volmit.iris.util.collection.KSet; -import com.volmit.iris.util.data.Varint; import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.math.BlockPosition; import org.bukkit.World; @@ -66,13 +65,13 @@ public interface Matter { BlockVector min = new BlockVector(); Matter m = new IrisMatter(object.getW(), object.getH(), object.getD()); - for (BlockVector i : object.getBlocks().keySet()) { + for(BlockVector i : object.getBlocks().keySet()) { min.setX(Math.min(min.getX(), i.getX())); min.setY(Math.min(min.getY(), i.getY())); min.setZ(Math.min(min.getZ(), i.getZ())); } - for (BlockVector i : object.getBlocks().keySet()) { + for(BlockVector i : object.getBlocks().keySet()) { m.slice(BlockData.class).set(i.getBlockX() - min.getBlockX(), i.getBlockY() - min.getBlockY(), i.getBlockZ() - min.getBlockZ(), object.getBlocks().get(i)); } @@ -104,10 +103,13 @@ public interface Matter { * Reads the input stream into a matter object using a matter factory. * Does not close the input stream. Be a man, close it yourself. * - * @param in the input stream - * @param matterFactory the matter factory (size) -> new MatterImpl(size); + * @param in + * the input stream + * @param matterFactory + * the matter factory (size) -> new MatterImpl(size); * @return the matter object - * @throws IOException shit happens yo + * @throws IOException + * shit happens yo */ static Matter read(InputStream in, Function matterFactory) throws IOException, ClassNotFoundException { return readDin(new DataInputStream(in), matterFactory); @@ -115,9 +117,9 @@ public interface Matter { static Matter readDin(DataInputStream din, Function matterFactory) throws IOException, ClassNotFoundException { Matter matter = matterFactory.apply(new BlockPosition( - din.readInt(), - din.readInt(), - din.readInt())); + din.readInt(), + din.readInt(), + din.readInt())); Iris.addPanic("read.matter.size", matter.getWidth() + "x" + matter.getHeight() + "x" + matter.getDepth()); int sliceCount = din.readByte(); Iris.addPanic("read.matter.slicecount", sliceCount + ""); @@ -125,8 +127,7 @@ public interface Matter { matter.getHeader().read(din); Iris.addPanic("read.matter.header", matter.getHeader().toString()); - for(int i = 0; i < sliceCount; i++) - { + for(int i = 0; i < sliceCount; i++) { Iris.addPanic("read.matter.slice", i + ""); String cn = din.readUTF(); Iris.addPanic("read.matter.slice.class", cn); @@ -135,7 +136,7 @@ public interface Matter { MatterSlice slice = matter.createSlice(type, matter); slice.read(din); matter.putSlice(type, slice); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); throw new IOException("Can't read class '" + cn + "' (slice count reverse at " + sliceCount + ")"); } @@ -184,9 +185,12 @@ public interface Matter { /** * Create a slice from the given type (full is false) * - * @param type the type class - * @param matter the matter this slice will go into (size provider) - * @param the type + * @param type + * the type class + * @param matter + * the matter this slice will go into (size provider) + * @param + * the type * @return the slice (or null if not supported) */ MatterSlice createSlice(Class type, Matter matter); @@ -230,8 +234,10 @@ public interface Matter { /** * Return the slice for the given type * - * @param t the type class - * @param the type + * @param t + * the type class + * @param + * the type * @return the slice or null */ default MatterSlice getSlice(Class t) { @@ -241,8 +247,10 @@ public interface Matter { /** * Delete the slice for the given type * - * @param c the type class - * @param the type + * @param c + * the type class + * @param + * the type * @return the deleted slice, or null if it diddn't exist */ default MatterSlice deleteSlice(Class c) { @@ -252,9 +260,12 @@ public interface Matter { /** * Put a given slice type * - * @param c the slice type class - * @param slice the slice to assign to the type - * @param the slice type + * @param c + * the slice type class + * @param slice + * the slice to assign to the type + * @param + * the slice type * @return the overwritten slice if there was an existing slice of that type */ default MatterSlice putSlice(Class c, MatterSlice slice) { @@ -264,11 +275,11 @@ public interface Matter { default Class getClass(Object w) { Class c = w.getClass(); - if (w instanceof World) { + if(w instanceof World) { c = World.class; - } else if (w instanceof BlockData) { + } else if(w instanceof BlockData) { c = BlockData.class; - } else if (w instanceof Entity) { + } else if(w instanceof Entity) { c = Entity.class; } @@ -277,13 +288,13 @@ public interface Matter { default MatterSlice slice(Class c) { MatterSlice slice = (MatterSlice) getSlice(c); - if (slice == null) { + if(slice == null) { slice = (MatterSlice) createSlice(c, this); - if (slice == null) { + if(slice == null) { try { throw new RuntimeException("Bad slice " + c.getCanonicalName()); - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); } @@ -299,9 +310,12 @@ public interface Matter { /** * Rotate a matter object into a new object * - * @param x the x rotation (degrees) - * @param y the y rotation (degrees) - * @param z the z rotation (degrees) + * @param x + * the x rotation (degrees) + * @param y + * the y rotation (degrees) + * @param z + * the z rotation (degrees) * @return the new rotated matter object */ default Matter rotate(double x, double y, double z) { @@ -310,7 +324,7 @@ public interface Matter { n.getHeader().setAuthor(getHeader().getAuthor()); n.getHeader().setCreatedAt(getHeader().getCreatedAt()); - for (Class i : getSliceTypes()) { + for(Class i : getSliceTypes()) { getSlice(i).rotateSliceInto(n, x, y, z); } @@ -320,7 +334,8 @@ public interface Matter { /** * Check if a slice exists for a given type * - * @param c the slice class type + * @param c + * the slice class type * @return true if it exists */ default boolean hasSlice(Class c) { @@ -362,9 +377,9 @@ public interface Matter { default void trimSlices() { Set> drop = null; - for (Class i : getSliceTypes()) { - if (getSlice(i).getEntryCount() == 0) { - if (drop == null) { + for(Class i : getSliceTypes()) { + if(getSlice(i).getEntryCount() == 0) { + if(drop == null) { drop = new KSet<>(); } @@ -372,8 +387,8 @@ public interface Matter { } } - if (drop != null) { - for (Class i : drop) { + if(drop != null) { + for(Class i : drop) { deleteSlice(i); } } @@ -383,8 +398,10 @@ public interface Matter { * Writes the data to the output stream. The data will be flushed to the provided output * stream however the provided stream will NOT BE CLOSED, so be sure to actually close it * - * @param out the output stream - * @throws IOException shit happens yo + * @param out + * the output stream + * @throws IOException + * shit happens yo */ default void write(OutputStream out) throws IOException { writeDos(new DataOutputStream(out)); @@ -398,7 +415,7 @@ public interface Matter { dos.writeByte(getSliceTypes().size()); getHeader().write(dos); - for (Class i : getSliceTypes()) { + for(Class i : getSliceTypes()) { getSlice(i).write(dos); } } @@ -406,7 +423,7 @@ public interface Matter { default int getTotalCount() { int m = 0; - for (MatterSlice i : getSliceMap().values()) { + for(MatterSlice i : getSliceMap().values()) { m += i.getEntryCount(); } diff --git a/src/main/java/com/volmit/iris/util/matter/MatterHeader.java b/src/main/java/com/volmit/iris/util/matter/MatterHeader.java index d6852eb1b..600b9f24b 100644 --- a/src/main/java/com/volmit/iris/util/matter/MatterHeader.java +++ b/src/main/java/com/volmit/iris/util/matter/MatterHeader.java @@ -18,7 +18,6 @@ package com.volmit.iris.util.matter; -import com.volmit.iris.util.data.Varint; import com.volmit.iris.util.math.M; import lombok.Data; diff --git a/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java b/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java index e04a426be..c85008b02 100644 --- a/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java +++ b/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java @@ -34,7 +34,7 @@ public interface MatterPlacer { } default void set(int x, int y, int z, Matter matter) { - for (MatterSlice i : matter.getSliceMap().values()) { + for(MatterSlice i : matter.getSliceMap().values()) { set(x, y, z, i); } } diff --git a/src/main/java/com/volmit/iris/util/matter/MatterSlice.java b/src/main/java/com/volmit/iris/util/matter/MatterSlice.java index 24c8c5b48..b729846be 100644 --- a/src/main/java/com/volmit/iris/util/matter/MatterSlice.java +++ b/src/main/java/com/volmit/iris/util/matter/MatterSlice.java @@ -18,7 +18,6 @@ package com.volmit.iris.util.matter; -import com.volmit.iris.Iris; import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.util.data.Varint; import com.volmit.iris.util.data.palette.Palette; @@ -85,11 +84,11 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { default Class getClass(Object w) { Class c = w.getClass(); - if (w instanceof World) { + if(w instanceof World) { c = World.class; - } else if (w instanceof BlockData) { + } else if(w instanceof BlockData) { c = BlockData.class; - } else if (w instanceof Entity) { + } else if(w instanceof Entity) { c = Entity.class; } @@ -103,7 +102,7 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { default boolean writeInto(W w, int x, int y, int z) { MatterWriter injector = (MatterWriter) writeInto(getClass(w)); - if (injector == null) { + if(injector == null) { return false; } @@ -119,16 +118,16 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { default boolean readFrom(W w, int x, int y, int z) { MatterReader ejector = (MatterReader) readFrom(getClass(w)); - if (ejector == null) { + if(ejector == null) { return false; } - for (int i = x; i < x + getWidth(); i++) { - for (int j = y; j < y + getHeight(); j++) { - for (int k = z; k < z + getDepth(); k++) { + for(int i = x; i < x + getWidth(); i++) { + for(int j = y; j < y + getHeight(); j++) { + for(int k = z; k < z + getDepth(); k++) { T v = ejector.readMatter(w, i, j, k); - if (v != null) { + if(v != null) { set(i - x, j - y, k - z, v); } } @@ -148,8 +147,8 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { default int getBitsPer(int needed) { int target = 1; - for (int i = 1; i < 8; i++) { - if (Math.pow(2, i) > needed) { + for(int i = 1; i < 8; i++) { + if(Math.pow(2, i) > needed) { target = i; break; } @@ -161,7 +160,7 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { default void write(DataOutputStream dos) throws IOException { dos.writeUTF(getType().getCanonicalName()); - if ((this instanceof PaletteOrHunk f && f.isPalette())) { + if((this instanceof PaletteOrHunk f && f.isPalette())) { f.palette().writeDos(dos); return; } @@ -173,7 +172,7 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { palette.writePalette(dos); dos.writeBoolean(isMapped()); - if (isMapped()) { + if(isMapped()) { Varint.writeUnsignedVarInt(getEntryCount(), dos); iterateSyncIO((x, y, z, b) -> { Varint.writeUnsignedVarInt(Cache.to1D(x, y, z, w, h), dos); @@ -185,7 +184,7 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { } default void read(DataInputStream din) throws IOException { - if ((this instanceof PaletteOrHunk f && f.isPalette())) { + if((this instanceof PaletteOrHunk f && f.isPalette())) { f.setPalette(new DataContainer<>(din, this)); return; } @@ -193,11 +192,11 @@ public interface MatterSlice extends Hunk, PaletteType, Writable { int w = getWidth(); int h = getHeight(); MatterPalette palette = new MatterPalette(this, din); - if (din.readBoolean()) { + if(din.readBoolean()) { int nodes = Varint.readUnsignedVarInt(din); int[] pos; - while (nodes-- > 0) { + while(nodes-- > 0) { pos = Cache.to3D(Varint.readUnsignedVarInt(din), w, h); setRaw(pos[0], pos[1], pos[2], palette.readNode(din)); } diff --git a/src/main/java/com/volmit/iris/util/matter/WorldMatter.java b/src/main/java/com/volmit/iris/util/matter/WorldMatter.java index 7edc6255b..f3e3fd515 100644 --- a/src/main/java/com/volmit/iris/util/matter/WorldMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/WorldMatter.java @@ -25,15 +25,15 @@ import org.bukkit.block.data.BlockData; public class WorldMatter { public static void placeMatter(Matter matter, Location at) { - if (matter.hasSlice(BlockData.class)) { + if(matter.hasSlice(BlockData.class)) { matter.slice(BlockData.class).writeInto(at); } - if (matter.hasSlice(MatterEntityGroup.class)) { + if(matter.hasSlice(MatterEntityGroup.class)) { matter.slice(MatterEntityGroup.class).writeInto(at); } - if (matter.hasSlice(MatterTile.class)) { + if(matter.hasSlice(MatterTile.class)) { matter.slice(MatterTile.class).writeInto(at); } } diff --git a/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java index 51612897e..f66b8bb40 100644 --- a/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java @@ -18,7 +18,6 @@ package com.volmit.iris.util.matter.slices; -import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.palette.Palette; import com.volmit.iris.util.matter.Sliced; import org.bukkit.Bukkit; diff --git a/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java index 8f446ace6..ba58f69db 100644 --- a/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java @@ -56,7 +56,7 @@ public class EntityMatter extends RawMatter { public EntityMatter(int width, int height, int depth) { super(width, height, depth, MatterEntityGroup.class); registerWriter(World.class, ((w, d, x, y, z) -> { - for (MatterEntity i : d.getEntities()) { + for(MatterEntity i : d.getEntities()) { Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff()); INMS.get().deserializeEntity(i.getEntityData(), realPosition); } @@ -65,13 +65,13 @@ public class EntityMatter extends RawMatter { IrisPosition pos = new IrisPosition(x, y, z); KList entities = entityCache.get(pos); MatterEntityGroup g = new MatterEntityGroup(); - if (entities != null) { - for (Entity i : entities) { + if(entities != null) { + for(Entity i : entities) { g.getEntities().add(new MatterEntity( - Math.abs(i.getLocation().getX()) - Math.abs(i.getLocation().getBlockX()), - Math.abs(i.getLocation().getY()) - Math.abs(i.getLocation().getBlockY()), - Math.abs(i.getLocation().getZ()) - Math.abs(i.getLocation().getBlockZ()), - INMS.get().serializeEntity(i) + Math.abs(i.getLocation().getX()) - Math.abs(i.getLocation().getBlockX()), + Math.abs(i.getLocation().getY()) - Math.abs(i.getLocation().getBlockY()), + Math.abs(i.getLocation().getZ()) - Math.abs(i.getLocation().getBlockZ()), + INMS.get().serializeEntity(i) )); } @@ -88,36 +88,41 @@ public class EntityMatter extends RawMatter { * block position with a list of entities within that block, and directly feed * the reader with the entities we capture. * - * @param w the world - * @param x the x offset - * @param y the y offset - * @param z the z offset - * @param the type + * @param w + * the world + * @param x + * the x offset + * @param y + * the y offset + * @param z + * the z offset + * @param + * the type * @return true if we read */ @Override public synchronized boolean readFrom(W w, int x, int y, int z) { - if (!(w instanceof World)) { + if(!(w instanceof World)) { return super.readFrom(w, x, y, z); } MatterReader reader = (MatterReader) readFrom(World.class); - if (reader == null) { + if(reader == null) { return false; } entityCache = new KMap<>(); - for (Entity i : ((World) w).getNearbyEntities(new BoundingBox(x, y, z, x + getWidth(), y + getHeight(), z + getHeight()))) { + for(Entity i : ((World) w).getNearbyEntities(new BoundingBox(x, y, z, x + getWidth(), y + getHeight(), z + getHeight()))) { entityCache.computeIfAbsent(new IrisPosition(i.getLocation()), - k -> new KList<>()).add(i); + k -> new KList<>()).add(i); } - for (IrisPosition i : entityCache.keySet()) { + for(IrisPosition i : entityCache.keySet()) { MatterEntityGroup g = reader.readMatter(w, i.getX(), i.getY(), i.getZ()); - if (g != null) { + if(g != null) { set(i.getX() - x, i.getY() - y, i.getZ() - z, g); } } @@ -130,7 +135,7 @@ public class EntityMatter extends RawMatter { @Override public void writeNode(MatterEntityGroup b, DataOutputStream dos) throws IOException { Varint.writeUnsignedVarInt(b.getEntities().size(), dos); - for (MatterEntity i : b.getEntities()) { + for(MatterEntity i : b.getEntities()) { dos.writeByte((int) (i.getXOff() * 255) + Byte.MIN_VALUE); dos.writeByte((int) (i.getYOff() * 255) + Byte.MIN_VALUE); dos.writeByte((int) (i.getZOff() * 255) + Byte.MIN_VALUE); @@ -143,12 +148,12 @@ public class EntityMatter extends RawMatter { MatterEntityGroup g = new MatterEntityGroup(); int c = Varint.readUnsignedVarInt(din); - while (c-- > 0) { + while(c-- > 0) { g.getEntities().add(new MatterEntity( - ((int) din.readByte() - Byte.MIN_VALUE) / 255F, - ((int) din.readByte() - Byte.MIN_VALUE) / 255F, - ((int) din.readByte() - Byte.MIN_VALUE) / 255F, - (CompoundTag) NBTUtil.read(din, false).getTag())); + ((int) din.readByte() - Byte.MIN_VALUE) / 255F, + ((int) din.readByte() - Byte.MIN_VALUE) / 255F, + ((int) din.readByte() - Byte.MIN_VALUE) / 255F, + (CompoundTag) NBTUtil.read(din, false).getTag())); } return g; diff --git a/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java index 43b2b44bb..2b2d6e92c 100644 --- a/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java @@ -49,10 +49,10 @@ public class TileMatter extends RawMatter { registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z)))); registerReader(World.class, (w, x, y, z) -> { Location l = new Location(w, x, y, z); - if (INMS.get().hasTile(l)) { + if(INMS.get().hasTile(l)) { CompoundTag tag = INMS.get().serializeTile(l); - if (tag != null) { + if(tag != null) { return new MatterTile(tag); } } diff --git a/src/main/java/com/volmit/iris/util/nbt/io/NBTDeserializer.java b/src/main/java/com/volmit/iris/util/nbt/io/NBTDeserializer.java index 1a72e75db..b4d2fb305 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/NBTDeserializer.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/NBTDeserializer.java @@ -40,7 +40,7 @@ public class NBTDeserializer implements Deserializer { @Override public NamedTag fromStream(InputStream stream) throws IOException { NBTInputStream nbtIn; - if (compressed) { + if(compressed) { nbtIn = new NBTInputStream(new GZIPInputStream(stream)); } else { nbtIn = new NBTInputStream(stream); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/NBTInputStream.java b/src/main/java/com/volmit/iris/util/nbt/io/NBTInputStream.java index 59e12d1e9..ce52811d2 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/NBTInputStream.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/NBTInputStream.java @@ -109,7 +109,7 @@ public class NBTInputStream extends DataInputStream implements MaxDepthIO { int l = in.readInt(); int[] data = new int[l]; IntArrayTag iat = new IntArrayTag(data); - for (int i = 0; i < l; i++) { + for(int i = 0; i < l; i++) { data[i] = in.readInt(); } return iat; @@ -119,7 +119,7 @@ public class NBTInputStream extends DataInputStream implements MaxDepthIO { int l = in.readInt(); long[] data = new long[l]; LongArrayTag iat = new LongArrayTag(data); - for (int i = 0; i < l; i++) { + for(int i = 0; i < l; i++) { data[i] = in.readLong(); } return iat; @@ -129,10 +129,10 @@ public class NBTInputStream extends DataInputStream implements MaxDepthIO { byte listType = in.readByte(); ListTag list = ListTag.createUnchecked(idClassMapping.get(listType)); int length = in.readInt(); - if (length < 0) { + if(length < 0) { length = 0; } - for (int i = 0; i < length; i++) { + for(int i = 0; i < length; i++) { list.addUnchecked(in.readTag(listType, in.decrementMaxDepth(maxDepth))); } return list; @@ -140,7 +140,7 @@ public class NBTInputStream extends DataInputStream implements MaxDepthIO { private static CompoundTag readCompound(NBTInputStream in, int maxDepth) throws IOException { CompoundTag comp = new CompoundTag(); - for (int id = in.readByte() & 0xFF; id != 0; id = in.readByte() & 0xFF) { + for(int id = in.readByte() & 0xFF; id != 0; id = in.readByte() & 0xFF) { String key = in.readUTF(); Tag element = in.readTag((byte) id, in.decrementMaxDepth(maxDepth)); comp.put(key, element); @@ -160,7 +160,7 @@ public class NBTInputStream extends DataInputStream implements MaxDepthIO { private Tag readTag(byte type, int maxDepth) throws IOException { ExceptionBiFunction, IOException> f; - if ((f = readers.get(type)) == null) { + if((f = readers.get(type)) == null) { throw new IOException("invalid tag id \"" + type + "\""); } return f.accept(this, maxDepth); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/NBTOutputStream.java b/src/main/java/com/volmit/iris/util/nbt/io/NBTOutputStream.java index fe6fdc6e9..0f7679d89 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/NBTOutputStream.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/NBTOutputStream.java @@ -74,7 +74,7 @@ public class NBTOutputStream extends DataOutputStream implements MaxDepthIO { static byte idFromClass(Class clazz) { Byte id = classIdMapping.get(clazz); - if (id == null) { + if(id == null) { throw new IllegalArgumentException("unknown Tag class " + clazz.getName()); } return id; @@ -115,14 +115,14 @@ public class NBTOutputStream extends DataOutputStream implements MaxDepthIO { private static void writeIntArray(NBTOutputStream out, Tag tag) throws IOException { out.writeInt(((IntArrayTag) tag).length()); - for (int i : ((IntArrayTag) tag).getValue()) { + for(int i : ((IntArrayTag) tag).getValue()) { out.writeInt(i); } } private static void writeLongArray(NBTOutputStream out, Tag tag) throws IOException { out.writeInt(((LongArrayTag) tag).length()); - for (long l : ((LongArrayTag) tag).getValue()) { + for(long l : ((LongArrayTag) tag).getValue()) { out.writeLong(l); } } @@ -130,14 +130,14 @@ public class NBTOutputStream extends DataOutputStream implements MaxDepthIO { private static void writeList(NBTOutputStream out, Tag tag, int maxDepth) throws IOException { out.writeByte(idFromClass(((ListTag) tag).getTypeClass())); out.writeInt(((ListTag) tag).size()); - for (Tag t : ((ListTag) tag)) { + for(Tag t : ((ListTag) tag)) { out.writeRawTag(t, out.decrementMaxDepth(maxDepth)); } } private static void writeCompound(NBTOutputStream out, Tag tag, int maxDepth) throws IOException { - for (Map.Entry> entry : (CompoundTag) tag) { - if (entry.getValue().getID() == 0) { + for(Map.Entry> entry : (CompoundTag) tag) { + if(entry.getValue().getID() == 0) { throw new IOException("end tag not allowed"); } out.writeByte(entry.getValue().getID()); @@ -149,7 +149,7 @@ public class NBTOutputStream extends DataOutputStream implements MaxDepthIO { public void writeTag(NamedTag tag, int maxDepth) throws IOException { writeByte(tag.getTag().getID()); - if (tag.getTag().getID() != 0) { + if(tag.getTag().getID() != 0) { writeUTF(tag.getName() == null ? "" : tag.getName()); } writeRawTag(tag.getTag(), maxDepth); @@ -157,7 +157,7 @@ public class NBTOutputStream extends DataOutputStream implements MaxDepthIO { public void writeTag(Tag tag, int maxDepth) throws IOException { writeByte(tag.getID()); - if (tag.getID() != 0) { + if(tag.getID() != 0) { writeUTF(""); } writeRawTag(tag, maxDepth); @@ -165,7 +165,7 @@ public class NBTOutputStream extends DataOutputStream implements MaxDepthIO { public void writeRawTag(Tag tag, int maxDepth) throws IOException { ExceptionTriConsumer, Integer, IOException> f; - if ((f = writers.get(tag.getID())) == null) { + if((f = writers.get(tag.getID())) == null) { throw new IOException("invalid tag \"" + tag.getID() + "\""); } f.accept(this, tag, maxDepth); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/NBTSerializer.java b/src/main/java/com/volmit/iris/util/nbt/io/NBTSerializer.java index c4f3dd963..22f79ebda 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/NBTSerializer.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/NBTSerializer.java @@ -40,7 +40,7 @@ public class NBTSerializer implements Serializer { @Override public void toStream(NamedTag object, OutputStream out) throws IOException { NBTOutputStream nbtOut; - if (compressed) { + if(compressed) { nbtOut = new NBTOutputStream(new GZIPOutputStream(out, true)); } else { nbtOut = new NBTOutputStream(out); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/NBTUtil.java b/src/main/java/com/volmit/iris/util/nbt/io/NBTUtil.java index 66458a911..41cfb6fe4 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/NBTUtil.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/NBTUtil.java @@ -35,7 +35,7 @@ public final class NBTUtil { } public static void write(NamedTag tag, File file, boolean compressed) throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { + try(FileOutputStream fos = new FileOutputStream(file)) { new NBTSerializer(compressed).toStream(tag, fos); } } @@ -77,7 +77,7 @@ public final class NBTUtil { } public static NamedTag read(File file, boolean compressed) throws IOException { - try (FileInputStream fis = new FileInputStream(file)) { + try(FileInputStream fis = new FileInputStream(file)) { return new NBTDeserializer(compressed).fromStream(fis); } } @@ -91,7 +91,7 @@ public final class NBTUtil { } public static NamedTag read(File file) throws IOException { - try (FileInputStream fis = new FileInputStream(file)) { + try(FileInputStream fis = new FileInputStream(file)) { return new NBTDeserializer(false).fromStream(detectDecompression(fis)); } } @@ -105,7 +105,7 @@ public final class NBTUtil { int signature = (pbis.read() & 0xFF) + (pbis.read() << 8); pbis.unread(signature >> 8); pbis.unread(signature & 0xFF); - if (signature == GZIPInputStream.GZIP_MAGIC) { + if(signature == GZIPInputStream.GZIP_MAGIC) { return new GZIPInputStream(pbis); } return pbis; diff --git a/src/main/java/com/volmit/iris/util/nbt/io/ParseException.java b/src/main/java/com/volmit/iris/util/nbt/io/ParseException.java index 4502739f7..b3924332c 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/ParseException.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/ParseException.java @@ -33,7 +33,7 @@ public class ParseException extends IOException { private static String formatError(String value, int index) { StringBuilder builder = new StringBuilder(); int i = Math.min(value.length(), index); - if (i > 35) { + if(i > 35) { builder.append("..."); } builder.append(value, Math.max(0, i - 35), i); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/SNBTDeserializer.java b/src/main/java/com/volmit/iris/util/nbt/io/SNBTDeserializer.java index 8c128c92f..28499cee6 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/SNBTDeserializer.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/SNBTDeserializer.java @@ -35,7 +35,7 @@ public class SNBTDeserializer implements StringDeserializer> { public Tag fromReader(Reader reader, int maxDepth) throws IOException { BufferedReader bufferedReader; - if (reader instanceof BufferedReader) { + if(reader instanceof BufferedReader) { bufferedReader = (BufferedReader) reader; } else { bufferedReader = new BufferedReader(reader); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/SNBTParser.java b/src/main/java/com/volmit/iris/util/nbt/io/SNBTParser.java index affecc4e1..f7ae6a390 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/SNBTParser.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/SNBTParser.java @@ -43,14 +43,14 @@ import java.util.regex.Pattern; public final class SNBTParser implements MaxDepthIO { private static final Pattern - FLOAT_LITERAL_PATTERN = Pattern.compile("^[-+]?(?:\\d+\\.?|\\d*\\.\\d+)(?:e[-+]?\\d+)?f$", Pattern.CASE_INSENSITIVE), - DOUBLE_LITERAL_PATTERN = Pattern.compile("^[-+]?(?:\\d+\\.?|\\d*\\.\\d+)(?:e[-+]?\\d+)?d$", Pattern.CASE_INSENSITIVE), - DOUBLE_LITERAL_NO_SUFFIX_PATTERN = Pattern.compile("^[-+]?(?:\\d+\\.|\\d*\\.\\d+)(?:e[-+]?\\d+)?$", Pattern.CASE_INSENSITIVE), - BYTE_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+b$", Pattern.CASE_INSENSITIVE), - SHORT_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+s$", Pattern.CASE_INSENSITIVE), - INT_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+$", Pattern.CASE_INSENSITIVE), - LONG_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+l$", Pattern.CASE_INSENSITIVE), - NUMBER_PATTERN = Pattern.compile("^[-+]?\\d+$"); + FLOAT_LITERAL_PATTERN = Pattern.compile("^[-+]?(?:\\d+\\.?|\\d*\\.\\d+)(?:e[-+]?\\d+)?f$", Pattern.CASE_INSENSITIVE), + DOUBLE_LITERAL_PATTERN = Pattern.compile("^[-+]?(?:\\d+\\.?|\\d*\\.\\d+)(?:e[-+]?\\d+)?d$", Pattern.CASE_INSENSITIVE), + DOUBLE_LITERAL_NO_SUFFIX_PATTERN = Pattern.compile("^[-+]?(?:\\d+\\.|\\d*\\.\\d+)(?:e[-+]?\\d+)?$", Pattern.CASE_INSENSITIVE), + BYTE_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+b$", Pattern.CASE_INSENSITIVE), + SHORT_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+s$", Pattern.CASE_INSENSITIVE), + INT_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+$", Pattern.CASE_INSENSITIVE), + LONG_LITERAL_PATTERN = Pattern.compile("^[-+]?\\d+l$", Pattern.CASE_INSENSITIVE), + NUMBER_PATTERN = Pattern.compile("^[-+]?\\d+$"); private final StringPointer ptr; @@ -62,7 +62,7 @@ public final class SNBTParser implements MaxDepthIO { SNBTParser parser = new SNBTParser(string); Tag tag = parser.parseAnything(maxDepth); parser.ptr.skipWhitespace(); - if (parser.ptr.hasNext()) { + if(parser.ptr.hasNext()) { throw parser.ptr.parseException("invalid characters after end of snbt"); } return tag; @@ -74,11 +74,11 @@ public final class SNBTParser implements MaxDepthIO { private Tag parseAnything(int maxDepth) throws ParseException { ptr.skipWhitespace(); - switch (ptr.currentChar()) { + switch(ptr.currentChar()) { case '{': return parseCompoundTag(maxDepth); case '[': - if (ptr.hasCharsLeft(2) && ptr.lookAhead(1) != '"' && ptr.lookAhead(2) == ';') { + if(ptr.hasCharsLeft(2) && ptr.lookAhead(1) != '"' && ptr.lookAhead(2) == ';') { return parseNumArray(); } return parseListTag(maxDepth); @@ -88,50 +88,50 @@ public final class SNBTParser implements MaxDepthIO { private Tag parseStringOrLiteral() throws ParseException { ptr.skipWhitespace(); - if (ptr.currentChar() == '"') { + if(ptr.currentChar() == '"') { return new StringTag(ptr.parseQuotedString()); } String s = ptr.parseSimpleString(); - if (s.isEmpty()) { + if(s.isEmpty()) { throw new ParseException("expected non empty value"); } - if (FLOAT_LITERAL_PATTERN.matcher(s).matches()) { + if(FLOAT_LITERAL_PATTERN.matcher(s).matches()) { return new FloatTag(Float.parseFloat(s.substring(0, s.length() - 1))); - } else if (BYTE_LITERAL_PATTERN.matcher(s).matches()) { + } else if(BYTE_LITERAL_PATTERN.matcher(s).matches()) { try { return new ByteTag(Byte.parseByte(s.substring(0, s.length() - 1))); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("byte not in range: \"" + s.substring(0, s.length() - 1) + "\""); } - } else if (SHORT_LITERAL_PATTERN.matcher(s).matches()) { + } else if(SHORT_LITERAL_PATTERN.matcher(s).matches()) { try { return new ShortTag(Short.parseShort(s.substring(0, s.length() - 1))); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("short not in range: \"" + s.substring(0, s.length() - 1) + "\""); } - } else if (LONG_LITERAL_PATTERN.matcher(s).matches()) { + } else if(LONG_LITERAL_PATTERN.matcher(s).matches()) { try { return new LongTag(Long.parseLong(s.substring(0, s.length() - 1))); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("long not in range: \"" + s.substring(0, s.length() - 1) + "\""); } - } else if (INT_LITERAL_PATTERN.matcher(s).matches()) { + } else if(INT_LITERAL_PATTERN.matcher(s).matches()) { try { return new IntTag(Integer.parseInt(s)); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("int not in range: \"" + s.substring(0, s.length() - 1) + "\""); } - } else if (DOUBLE_LITERAL_PATTERN.matcher(s).matches()) { + } else if(DOUBLE_LITERAL_PATTERN.matcher(s).matches()) { return new DoubleTag(Double.parseDouble(s.substring(0, s.length() - 1))); - } else if (DOUBLE_LITERAL_NO_SUFFIX_PATTERN.matcher(s).matches()) { + } else if(DOUBLE_LITERAL_NO_SUFFIX_PATTERN.matcher(s).matches()) { return new DoubleTag(Double.parseDouble(s)); - } else if ("true".equalsIgnoreCase(s)) { + } else if("true".equalsIgnoreCase(s)) { return new ByteTag(true); - } else if ("false".equalsIgnoreCase(s)) { + } else if("false".equalsIgnoreCase(s)) { return new ByteTag(false); } return new StringTag(s); @@ -143,17 +143,17 @@ public final class SNBTParser implements MaxDepthIO { CompoundTag compoundTag = new CompoundTag(); ptr.skipWhitespace(); - while (ptr.hasNext() && ptr.currentChar() != '}') { + while(ptr.hasNext() && ptr.currentChar() != '}') { ptr.skipWhitespace(); String key = ptr.currentChar() == '"' ? ptr.parseQuotedString() : ptr.parseSimpleString(); - if (key.isEmpty()) { + if(key.isEmpty()) { throw new ParseException("empty keys are not allowed"); } ptr.expectChar(':'); compoundTag.put(key, parseAnything(decrementMaxDepth(maxDepth))); - if (!ptr.nextArrayElement()) { + if(!ptr.nextArrayElement()) { break; } } @@ -165,15 +165,15 @@ public final class SNBTParser implements MaxDepthIO { ptr.expectChar('['); ptr.skipWhitespace(); ListTag list = ListTag.createUnchecked(EndTag.class); - while (ptr.currentChar() != ']') { + while(ptr.currentChar() != ']') { Tag element = parseAnything(decrementMaxDepth(maxDepth)); try { list.addUnchecked(element); - } catch (IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { Iris.reportError(ex); throw ptr.parseException(ex.getMessage()); } - if (!ptr.nextArrayElement()) { + if(!ptr.nextArrayElement()) { break; } } @@ -186,7 +186,7 @@ public final class SNBTParser implements MaxDepthIO { char arrayType = ptr.next(); ptr.expectChar(';'); ptr.skipWhitespace(); - switch (arrayType) { + switch(arrayType) { case 'B': return parseByteArrayTag(); case 'I': @@ -199,26 +199,26 @@ public final class SNBTParser implements MaxDepthIO { private ByteArrayTag parseByteArrayTag() throws ParseException { List byteList = new ArrayList<>(); - while (ptr.currentChar() != ']') { + while(ptr.currentChar() != ']') { String s = ptr.parseSimpleString(); ptr.skipWhitespace(); - if (NUMBER_PATTERN.matcher(s).matches()) { + if(NUMBER_PATTERN.matcher(s).matches()) { try { byteList.add(Byte.parseByte(s)); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("byte not in range: \"" + s + "\""); } } else { throw ptr.parseException("invalid byte in ByteArrayTag: \"" + s + "\""); } - if (!ptr.nextArrayElement()) { + if(!ptr.nextArrayElement()) { break; } } ptr.expectChar(']'); byte[] bytes = new byte[byteList.size()]; - for (int i = 0; i < byteList.size(); i++) { + for(int i = 0; i < byteList.size(); i++) { bytes[i] = byteList.get(i); } return new ByteArrayTag(bytes); @@ -226,20 +226,20 @@ public final class SNBTParser implements MaxDepthIO { private IntArrayTag parseIntArrayTag() throws ParseException { List intList = new ArrayList<>(); - while (ptr.currentChar() != ']') { + while(ptr.currentChar() != ']') { String s = ptr.parseSimpleString(); ptr.skipWhitespace(); - if (NUMBER_PATTERN.matcher(s).matches()) { + if(NUMBER_PATTERN.matcher(s).matches()) { try { intList.add(Integer.parseInt(s)); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("int not in range: \"" + s + "\""); } } else { throw ptr.parseException("invalid int in IntArrayTag: \"" + s + "\""); } - if (!ptr.nextArrayElement()) { + if(!ptr.nextArrayElement()) { break; } } @@ -249,20 +249,20 @@ public final class SNBTParser implements MaxDepthIO { private LongArrayTag parseLongArrayTag() throws ParseException { List longList = new ArrayList<>(); - while (ptr.currentChar() != ']') { + while(ptr.currentChar() != ']') { String s = ptr.parseSimpleString(); ptr.skipWhitespace(); - if (NUMBER_PATTERN.matcher(s).matches()) { + if(NUMBER_PATTERN.matcher(s).matches()) { try { longList.add(Long.parseLong(s)); - } catch (NumberFormatException ex) { + } catch(NumberFormatException ex) { Iris.reportError(ex); throw ptr.parseException("long not in range: \"" + s + "\""); } } else { throw ptr.parseException("invalid long in LongArrayTag: \"" + s + "\""); } - if (!ptr.nextArrayElement()) { + if(!ptr.nextArrayElement()) { break; } } diff --git a/src/main/java/com/volmit/iris/util/nbt/io/SNBTWriter.java b/src/main/java/com/volmit/iris/util/nbt/io/SNBTWriter.java index 2d0f44f63..c694e1dd7 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/SNBTWriter.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/SNBTWriter.java @@ -63,12 +63,12 @@ public final class SNBTWriter implements MaxDepthIO { } public static String escapeString(String s) { - if (!NON_QUOTE_PATTERN.matcher(s).matches()) { + if(!NON_QUOTE_PATTERN.matcher(s).matches()) { StringBuilder sb = new StringBuilder(); sb.append('"'); - for (int i = 0; i < s.length(); i++) { + for(int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (c == '\\' || c == '"') { + if(c == '\\' || c == '"') { sb.append('\\'); } sb.append(c); @@ -80,7 +80,7 @@ public final class SNBTWriter implements MaxDepthIO { } private void writeAnything(Tag tag, int maxDepth) throws IOException { - switch (tag.getID()) { + switch(tag.getID()) { case EndTag.ID: //do nothing break; @@ -110,7 +110,7 @@ public final class SNBTWriter implements MaxDepthIO { break; case ListTag.ID: writer.write('['); - for (int i = 0; i < ((ListTag) tag).size(); i++) { + for(int i = 0; i < ((ListTag) tag).size(); i++) { writer.write(i == 0 ? "" : ","); writeAnything(((ListTag) tag).get(i), decrementMaxDepth(maxDepth)); } @@ -119,7 +119,7 @@ public final class SNBTWriter implements MaxDepthIO { case CompoundTag.ID: writer.write('{'); boolean first = true; - for (Map.Entry> entry : (CompoundTag) tag) { + for(Map.Entry> entry : (CompoundTag) tag) { writer.write(first ? "" : ","); writer.append(escapeString(entry.getKey())).write(':'); writeAnything(entry.getValue(), decrementMaxDepth(maxDepth)); @@ -140,7 +140,7 @@ public final class SNBTWriter implements MaxDepthIO { private void writeArray(Object array, int length, String prefix) throws IOException { writer.append('[').append(prefix).write(';'); - for (int i = 0; i < length; i++) { + for(int i = 0; i < length; i++) { writer.append(i == 0 ? "" : ",").write(Array.get(array, i).toString()); } writer.write(']'); diff --git a/src/main/java/com/volmit/iris/util/nbt/io/StringPointer.java b/src/main/java/com/volmit/iris/util/nbt/io/StringPointer.java index 02227d9f6..698fedaa0 100644 --- a/src/main/java/com/volmit/iris/util/nbt/io/StringPointer.java +++ b/src/main/java/com/volmit/iris/util/nbt/io/StringPointer.java @@ -29,17 +29,17 @@ public class StringPointer { private static boolean isSimpleChar(char c) { return c >= 'a' && c <= 'z' - || c >= 'A' && c <= 'Z' - || c >= '0' && c <= '9' - || c == '-' - || c == '+' - || c == '.' - || c == '_'; + || c >= 'A' && c <= 'Z' + || c >= '0' && c <= '9' + || c == '-' + || c == '+' + || c == '.' + || c == '_'; } public String parseSimpleString() { int oldIndex = index; - while (hasNext() && isSimpleChar(currentChar())) { + while(hasNext() && isSimpleChar(currentChar())) { index++; } return value.substring(oldIndex, index); @@ -49,27 +49,27 @@ public class StringPointer { int oldIndex = ++index; //ignore beginning quotes StringBuilder sb = null; boolean escape = false; - while (hasNext()) { + while(hasNext()) { char c = next(); - if (escape) { - if (c != '\\' && c != '"') { + if(escape) { + if(c != '\\' && c != '"') { throw parseException("invalid escape of '" + c + "'"); } escape = false; } else { - if (c == '\\') { //escape + if(c == '\\') { //escape escape = true; - if (sb != null) { + if(sb != null) { continue; } sb = new StringBuilder(value.substring(oldIndex, index - 1)); continue; } - if (c == '"') { + if(c == '"') { return sb == null ? value.substring(oldIndex, index - 1) : sb.toString(); } } - if (sb != null) { + if(sb != null) { sb.append(c); } } @@ -79,7 +79,7 @@ public class StringPointer { @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean nextArrayElement() { skipWhitespace(); - if (hasNext() && currentChar() == ',') { + if(hasNext() && currentChar() == ',') { index++; skipWhitespace(); return true; @@ -90,7 +90,7 @@ public class StringPointer { public void expectChar(char c) throws ParseException { skipWhitespace(); boolean hasNext = hasNext(); - if (hasNext && currentChar() == c) { + if(hasNext && currentChar() == c) { index++; return; } @@ -98,7 +98,7 @@ public class StringPointer { } public void skipWhitespace() { - while (hasNext() && Character.isWhitespace(currentChar())) { + while(hasNext() && Character.isWhitespace(currentChar())) { index++; } } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java b/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java index 29373637c..4ba38653b 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java @@ -67,7 +67,8 @@ public class Chunk { /** * Create a new chunk based on raw base data from a region file. * - * @param data The raw base data to be used. + * @param data + * The raw base data to be used. */ public Chunk(CompoundTag data) { this.data = data; @@ -93,61 +94,61 @@ public class Chunk { } private void initReferences(long loadFlags) { - if (data == null) { + if(data == null) { throw new NullPointerException("data cannot be null"); } CompoundTag level; - if ((level = data.getCompoundTag("Level")) == null) { + if((level = data.getCompoundTag("Level")) == null) { throw new IllegalArgumentException("data does not contain \"Level\" tag"); } dataVersion = data.getInt("DataVersion"); inhabitedTime = level.getLong("InhabitedTime"); lastUpdate = level.getLong("LastUpdate"); - if ((loadFlags & BIOMES) != 0) { + if((loadFlags & BIOMES) != 0) { biomes = INMS.get().newBiomeContainer(0, 256, level.getIntArray("Biomes")); } - if ((loadFlags & HEIGHTMAPS) != 0) { + if((loadFlags & HEIGHTMAPS) != 0) { heightMaps = level.getCompoundTag("Heightmaps"); } - if ((loadFlags & CARVING_MASKS) != 0) { + if((loadFlags & CARVING_MASKS) != 0) { carvingMasks = level.getCompoundTag("CarvingMasks"); } - if ((loadFlags & ENTITIES) != 0) { + if((loadFlags & ENTITIES) != 0) { entities = level.containsKey("Entities") ? level.getListTag("Entities").asCompoundTagList() : null; } - if ((loadFlags & TILE_ENTITIES) != 0) { + if((loadFlags & TILE_ENTITIES) != 0) { tileEntities = level.containsKey("TileEntities") ? level.getListTag("TileEntities").asCompoundTagList() : null; } - if ((loadFlags & TILE_TICKS) != 0) { + if((loadFlags & TILE_TICKS) != 0) { tileTicks = level.containsKey("TileTicks") ? level.getListTag("TileTicks").asCompoundTagList() : null; } - if ((loadFlags & LIQUID_TICKS) != 0) { + if((loadFlags & LIQUID_TICKS) != 0) { liquidTicks = level.containsKey("LiquidTicks") ? level.getListTag("LiquidTicks").asCompoundTagList() : null; } - if ((loadFlags & LIGHTS) != 0) { + if((loadFlags & LIGHTS) != 0) { lights = level.containsKey("Lights") ? level.getListTag("Lights").asListTagList() : null; } - if ((loadFlags & LIQUIDS_TO_BE_TICKED) != 0) { + if((loadFlags & LIQUIDS_TO_BE_TICKED) != 0) { liquidsToBeTicked = level.containsKey("LiquidsToBeTicked") ? level.getListTag("LiquidsToBeTicked").asListTagList() : null; } - if ((loadFlags & TO_BE_TICKED) != 0) { + if((loadFlags & TO_BE_TICKED) != 0) { toBeTicked = level.containsKey("ToBeTicked") ? level.getListTag("ToBeTicked").asListTagList() : null; } - if ((loadFlags & POST_PROCESSING) != 0) { + if((loadFlags & POST_PROCESSING) != 0) { postProcessing = level.containsKey("PostProcessing") ? level.getListTag("PostProcessing").asListTagList() : null; } status = level.getString("Status"); - if ((loadFlags & STRUCTURES) != 0) { + if((loadFlags & STRUCTURES) != 0) { structures = level.getCompoundTag("Structures"); } - if ((loadFlags & (BLOCK_LIGHTS | BLOCK_STATES | SKY_LIGHT)) != 0 && level.containsKey("Sections")) { - for (CompoundTag section : level.getListTag("Sections").asCompoundTagList()) { + if((loadFlags & (BLOCK_LIGHTS | BLOCK_STATES | SKY_LIGHT)) != 0 && level.containsKey("Sections")) { + for(CompoundTag section : level.getListTag("Sections").asCompoundTagList()) { int sectionIndex = section.getByte("Y"); - if (sectionIndex > 15 || sectionIndex < 0) { + if(sectionIndex > 15 || sectionIndex < 0) { continue; } Section newSection = new Section(section, dataVersion, loadFlags); - if (newSection.isEmpty()) { + if(newSection.isEmpty()) { continue; } sections.set(sectionIndex, newSection); @@ -155,7 +156,7 @@ public class Chunk { } // If we haven't requested the full set of data we can drop the underlying raw data to let the GC handle it. - if (loadFlags != ALL_DATA) { + if(loadFlags != ALL_DATA) { data = null; partial = true; } else { @@ -166,19 +167,24 @@ public class Chunk { /** * Serializes this chunk to a RandomAccessFile. * - * @param raf The RandomAccessFile to be written to. - * @param xPos The x-coordinate of the chunk. - * @param zPos The z-coodrinate of the chunk. + * @param raf + * The RandomAccessFile to be written to. + * @param xPos + * The x-coordinate of the chunk. + * @param zPos + * The z-coodrinate of the chunk. * @return The amount of bytes written to the RandomAccessFile. - * @throws UnsupportedOperationException When something went wrong during writing. - * @throws IOException When something went wrong during writing. + * @throws UnsupportedOperationException + * When something went wrong during writing. + * @throws IOException + * When something went wrong during writing. */ public int serialize(RandomAccessFile raf, int xPos, int zPos) throws IOException { - if (partial) { + if(partial) { throw new UnsupportedOperationException("Partially loaded chunks cannot be serialized"); } ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); - try (BufferedOutputStream nbtOut = new BufferedOutputStream(CompressionType.ZLIB.compress(baos))) { + try(BufferedOutputStream nbtOut = new BufferedOutputStream(CompressionType.ZLIB.compress(baos))) { new NBTSerializer(false).toStream(new NamedTag(null, updateHandle(xPos, zPos)), nbtOut); } @@ -192,8 +198,10 @@ public class Chunk { /** * Reads chunk data from a RandomAccessFile. The RandomAccessFile must already be at the correct position. * - * @param raf The RandomAccessFile to read the chunk data from. - * @throws IOException When something went wrong during reading. + * @param raf + * The RandomAccessFile to read the chunk data from. + * @throws IOException + * When something went wrong during reading. */ public void deserialize(RandomAccessFile raf) throws IOException { deserialize(raf, ALL_DATA); @@ -202,19 +210,22 @@ public class Chunk { /** * Reads chunk data from a RandomAccessFile. The RandomAccessFile must already be at the correct position. * - * @param raf The RandomAccessFile to read the chunk data from. - * @param loadFlags A logical or of {@link LoadFlags} constants indicating what data should be loaded - * @throws IOException When something went wrong during reading. + * @param raf + * The RandomAccessFile to read the chunk data from. + * @param loadFlags + * A logical or of {@link LoadFlags} constants indicating what data should be loaded + * @throws IOException + * When something went wrong during reading. */ public void deserialize(RandomAccessFile raf, long loadFlags) throws IOException { byte compressionTypeByte = raf.readByte(); CompressionType compressionType = CompressionType.getFromID(compressionTypeByte); - if (compressionType == null) { + if(compressionType == null) { throw new IOException("invalid compression type " + compressionTypeByte); } BufferedInputStream dis = new BufferedInputStream(compressionType.decompress(new FileInputStream(raf.getFD()))); NamedTag tag = new NBTDeserializer(false).fromStream(dis); - if (tag != null && tag.getTag() instanceof CompoundTag) { + if(tag != null && tag.getTag() instanceof CompoundTag) { data = (CompoundTag) tag.getTag(); initReferences(loadFlags); } else { @@ -226,9 +237,12 @@ public class Chunk { * Fetches a biome id at a specific block in this chunk. * The coordinates can be absolute coordinates or relative to the region or chunk. * - * @param blockX The x-coordinate of the block. - * @param blockY The y-coordinate of the block. - * @param blockZ The z-coordinate of the block. + * @param blockX + * The x-coordinate of the block. + * @param blockY + * The y-coordinate of the block. + * @param blockZ + * The z-coordinate of the block. * @return The biome id or -1 if the biomes are not correctly initialized. */ public synchronized int getBiomeAt(int blockX, int blockY, int blockZ) { @@ -239,10 +253,13 @@ public class Chunk { * Sets a biome id at a specific block column. * The coordinates can be absolute coordinates or relative to the region or chunk. * - * @param blockX The x-coordinate of the block column. - * @param blockZ The z-coordinate of the block column. - * @param biomeID The biome id to be set. - * When set to a negative number, Minecraft will replace it with the block column's default biome. + * @param blockX + * The x-coordinate of the block column. + * @param blockZ + * The z-coordinate of the block column. + * @param biomeID + * The biome id to be set. + * When set to a negative number, Minecraft will replace it with the block column's default biome. */ public synchronized void setBiomeAt(int blockX, int blockY, int blockZ, int biomeID) { biomes.setBiome(blockX, blockY, blockZ, biomeID); @@ -255,12 +272,12 @@ public class Chunk { public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) { int s = MCAUtil.blockToChunk(blockY); - if (sections.length() <= s) { + if(sections.length() <= s) { return null; } Section section = sections.get(s); - if (section == null) { + if(section == null) { return null; } return section.getBlockStateAt(blockX, blockY, blockZ); @@ -270,23 +287,28 @@ public class Chunk { * Sets a block state at a specific location. * The block coordinates can be absolute or relative to the region or chunk. * - * @param blockX The x-coordinate of the block. - * @param blockY The y-coordinate of the block. - * @param blockZ The z-coordinate of the block. - * @param state The block state to be set. - * @param cleanup When true, it will cleanup all palettes of this chunk. - * This option should only be used moderately to avoid unnecessary recalculation of the palette indices. - * Recalculating the Palette should only be executed once right before saving the Chunk to file. + * @param blockX + * The x-coordinate of the block. + * @param blockY + * The y-coordinate of the block. + * @param blockZ + * The z-coordinate of the block. + * @param state + * The block state to be set. + * @param cleanup + * When true, it will cleanup all palettes of this chunk. + * This option should only be used moderately to avoid unnecessary recalculation of the palette indices. + * Recalculating the Palette should only be executed once right before saving the Chunk to file. */ public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) { int sectionIndex = MCAUtil.blockToChunk(blockY); - if (sections.length() <= sectionIndex) { + if(sections.length() <= sectionIndex) { return; } Section section = sections.get(sectionIndex); - if (section == null) { + if(section == null) { section = Section.newSection(); sections.set(sectionIndex, section); } @@ -304,7 +326,8 @@ public class Chunk { * Sets the DataVersion of this chunk. This does not check if the data of this chunk conforms * to that DataVersion, that is the responsibility of the developer. * - * @param dataVersion The DataVersion to be set. + * @param dataVersion + * The DataVersion to be set. */ public void setDataVersion(int dataVersion) { this.dataVersion = dataVersion; @@ -320,7 +343,8 @@ public class Chunk { /** * Sets the timestamp when this region file was last updated in seconds since 1970-01-01. * - * @param lastMCAUpdate The time in seconds since 1970-01-01. + * @param lastMCAUpdate + * The time in seconds since 1970-01-01. */ public void setLastMCAUpdate(int lastMCAUpdate) { this.lastMCAUpdate = lastMCAUpdate; @@ -336,7 +360,8 @@ public class Chunk { /** * Sets the generation status of this chunk. * - * @param status The generation status of this chunk. + * @param status + * The generation status of this chunk. */ public void setStatus(String status) { this.status = status; @@ -345,7 +370,8 @@ public class Chunk { /** * Fetches the section at the given y-coordinate. * - * @param sectionY The y-coordinate of the section in this chunk ranging from 0 to 15. + * @param sectionY + * The y-coordinate of the section in this chunk ranging from 0 to 15. * @return The Section. */ public Section getSection(int sectionY) { @@ -355,8 +381,10 @@ public class Chunk { /** * Sets a section at a givesn y-coordinate * - * @param sectionY The y-coordinate of the section in this chunk ranging from 0 to 15. - * @param section The section to be set. + * @param sectionY + * The y-coordinate of the section in this chunk ranging from 0 to 15. + * @param section + * The section to be set. */ public void setSection(int sectionY, Section section) { sections.set(sectionY, section); @@ -372,7 +400,8 @@ public class Chunk { /** * Sets the time when this chunk was last updated as a UNIX timestamp. * - * @param lastUpdate The UNIX timestamp. + * @param lastUpdate + * The UNIX timestamp. */ public void setLastUpdate(long lastUpdate) { this.lastUpdate = lastUpdate; @@ -388,7 +417,8 @@ public class Chunk { /** * Sets the cumulative amount of time players have spent in this chunk in ticks. * - * @param inhabitedTime The time in ticks. + * @param inhabitedTime + * The time in ticks. */ public void setInhabitedTime(long inhabitedTime) { this.inhabitedTime = inhabitedTime; @@ -404,7 +434,8 @@ public class Chunk { /** * Sets the height maps of this chunk. * - * @param heightMaps The height maps. + * @param heightMaps + * The height maps. */ public void setHeightMaps(CompoundTag heightMaps) { this.heightMaps = heightMaps; @@ -420,7 +451,8 @@ public class Chunk { /** * Sets the carving masks of this chunk. * - * @param carvingMasks The carving masks. + * @param carvingMasks + * The carving masks. */ public void setCarvingMasks(CompoundTag carvingMasks) { this.carvingMasks = carvingMasks; @@ -436,7 +468,8 @@ public class Chunk { /** * Sets the entities of this chunk. * - * @param entities The entities. + * @param entities + * The entities. */ public void setEntities(ListTag entities) { this.entities = entities; @@ -452,7 +485,8 @@ public class Chunk { /** * Sets the tile entities of this chunk. * - * @param tileEntities The tile entities of this chunk. + * @param tileEntities + * The tile entities of this chunk. */ public void setTileEntities(ListTag tileEntities) { this.tileEntities = tileEntities; @@ -468,7 +502,8 @@ public class Chunk { /** * Sets the tile ticks of this chunk. * - * @param tileTicks Thee tile ticks. + * @param tileTicks + * Thee tile ticks. */ public void setTileTicks(ListTag tileTicks) { this.tileTicks = tileTicks; @@ -484,7 +519,8 @@ public class Chunk { /** * Sets the liquid ticks of this chunk. * - * @param liquidTicks The liquid ticks. + * @param liquidTicks + * The liquid ticks. */ public void setLiquidTicks(ListTag liquidTicks) { this.liquidTicks = liquidTicks; @@ -500,7 +536,8 @@ public class Chunk { /** * Sets the light sources in this chunk. * - * @param lights The light sources. + * @param lights + * The light sources. */ public void setLights(ListTag> lights) { this.lights = lights; @@ -516,7 +553,8 @@ public class Chunk { /** * Sets the liquids to be ticked in this chunk. * - * @param liquidsToBeTicked The liquids to be ticked. + * @param liquidsToBeTicked + * The liquids to be ticked. */ public void setLiquidsToBeTicked(ListTag> liquidsToBeTicked) { this.liquidsToBeTicked = liquidsToBeTicked; @@ -532,7 +570,8 @@ public class Chunk { /** * Sets stuff to be ticked in this chunk. * - * @param toBeTicked The stuff to be ticked. + * @param toBeTicked + * The stuff to be ticked. */ public void setToBeTicked(ListTag> toBeTicked) { this.toBeTicked = toBeTicked; @@ -548,7 +587,8 @@ public class Chunk { /** * Sets things to be post processed in this chunk. * - * @param postProcessing The things to be post processed. + * @param postProcessing + * The things to be post processed. */ public void setPostProcessing(ListTag> postProcessing) { this.postProcessing = postProcessing; @@ -564,7 +604,8 @@ public class Chunk { /** * Sets data about structures in this chunk. * - * @param structures The data about structures. + * @param structures + * The data about structures. */ public void setStructures(CompoundTag structures) { this.structures = structures; @@ -575,9 +616,9 @@ public class Chunk { } public void cleanupPalettesAndBlockStates() { - for (int i = 0; i < sections.length(); i++) { + for(int i = 0; i < sections.length(); i++) { Section section = sections.get(i); - if (section != null) { + if(section != null) { section.cleanupPaletteAndBlockStates(); } } @@ -591,21 +632,21 @@ public class Chunk { level.putLong("LastUpdate", lastUpdate); level.putLong("InhabitedTime", inhabitedTime); level.putIntArray("Biomes", biomes.getData()); - if (heightMaps != null) level.put("Heightmaps", heightMaps); - if (carvingMasks != null) level.put("CarvingMasks", carvingMasks); - if (entities != null) level.put("Entities", entities); - if (tileEntities != null) level.put("TileEntities", tileEntities); - if (tileTicks != null) level.put("TileTicks", tileTicks); - if (liquidTicks != null) level.put("LiquidTicks", liquidTicks); - if (lights != null) level.put("Lights", lights); - if (liquidsToBeTicked != null) level.put("LiquidsToBeTicked", liquidsToBeTicked); - if (toBeTicked != null) level.put("ToBeTicked", toBeTicked); - if (postProcessing != null) level.put("PostProcessing", postProcessing); + if(heightMaps != null) level.put("Heightmaps", heightMaps); + if(carvingMasks != null) level.put("CarvingMasks", carvingMasks); + if(entities != null) level.put("Entities", entities); + if(tileEntities != null) level.put("TileEntities", tileEntities); + if(tileTicks != null) level.put("TileTicks", tileTicks); + if(liquidTicks != null) level.put("LiquidTicks", liquidTicks); + if(lights != null) level.put("Lights", lights); + if(liquidsToBeTicked != null) level.put("LiquidsToBeTicked", liquidsToBeTicked); + if(toBeTicked != null) level.put("ToBeTicked", toBeTicked); + if(postProcessing != null) level.put("PostProcessing", postProcessing); level.putString("Status", status); - if (structures != null) level.put("Structures", structures); + if(structures != null) level.put("Structures", structures); ListTag sections = new ListTag<>(CompoundTag.class); - for (int i = 0; i < this.sections.length(); i++) { - if (this.sections.get(i) != null) { + for(int i = 0; i < this.sections.length(); i++) { + if(this.sections.get(i) != null) { sections.add(this.sections.get(i).updateHandle(i)); } } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/CompressionType.java b/src/main/java/com/volmit/iris/util/nbt/mca/CompressionType.java index e73480c5d..be986e63f 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/CompressionType.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/CompressionType.java @@ -45,8 +45,8 @@ public enum CompressionType { } public static CompressionType getFromID(byte id) { - for (CompressionType c : CompressionType.values()) { - if (c.id == id) { + for(CompressionType c : CompressionType.values()) { + if(c.id == id) { return c; } } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/MCAFile.java b/src/main/java/com/volmit/iris/util/nbt/mca/MCAFile.java index 295369c25..eee4c5760 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/MCAFile.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/MCAFile.java @@ -47,8 +47,10 @@ public class MCAFile { * This constructor needs the x- and z-coordinates of the stored region, * which can usually be taken from the file name {@code r.x.z.mca} * - * @param regionX The x-coordinate of this region. - * @param regionZ The z-coordinate of this region. + * @param regionX + * The x-coordinate of this region. + * @param regionZ + * The z-coordinate of this region. */ public MCAFile(int regionX, int regionZ) { this.regionX = regionX; @@ -60,8 +62,10 @@ public class MCAFile { * Calculates the index of a chunk from its x- and z-coordinates in this region. * This works with absolute and relative coordinates. * - * @param chunkX The x-coordinate of the chunk. - * @param chunkZ The z-coordinate of the chunk. + * @param chunkX + * The x-coordinate of the chunk. + * @param chunkZ + * The z-coordinate of the chunk. * @return The index of this chunk. */ public static int getChunkIndex(int chunkX, int chunkZ) { @@ -72,8 +76,10 @@ public class MCAFile { * Reads an .mca file from a {@code RandomAccessFile} into this object. * This method does not perform any cleanups on the data. * - * @param raf The {@code RandomAccessFile} to read from. - * @throws IOException If something went wrong during deserialization. + * @param raf + * The {@code RandomAccessFile} to read from. + * @throws IOException + * If something went wrong during deserialization. */ public void deserialize(RandomAccessFile raf) throws IOException { deserialize(raf, LoadFlags.ALL_DATA); @@ -83,18 +89,21 @@ public class MCAFile { * Reads an .mca file from a {@code RandomAccessFile} into this object. * This method does not perform any cleanups on the data. * - * @param raf The {@code RandomAccessFile} to read from. - * @param loadFlags A logical or of {@link LoadFlags} constants indicating what data should be loaded - * @throws IOException If something went wrong during deserialization. + * @param raf + * The {@code RandomAccessFile} to read from. + * @param loadFlags + * A logical or of {@link LoadFlags} constants indicating what data should be loaded + * @throws IOException + * If something went wrong during deserialization. */ public void deserialize(RandomAccessFile raf, long loadFlags) throws IOException { chunks = new AtomicReferenceArray<>(1024); - for (int i = 0; i < 1024; i++) { + for(int i = 0; i < 1024; i++) { raf.seek(i * 4); int offset = raf.read() << 16; offset |= (raf.read() & 0xFF) << 8; offset |= raf.read() & 0xFF; - if (raf.readByte() == 0) { + if(raf.readByte() == 0) { continue; } raf.seek(4096 + i * 4); @@ -111,7 +120,7 @@ public class MCAFile { chunks = new AtomicReferenceArray<>(1024); int x = 0; int z = 0; - for (int i = 0; i < 1024; i++) { + for(int i = 0; i < 1024; i++) { x++; z++; @@ -119,7 +128,7 @@ public class MCAFile { int offset = raf.read() << 16; offset |= (raf.read() & 0xFF) << 8; offset |= raf.read() & 0xFF; - if (raf.readByte() == 0) { + if(raf.readByte() == 0) { continue; } p2.add(new Position2(x & 31, (z / 31) & 31)); @@ -134,9 +143,11 @@ public class MCAFile { /** * Calls {@link MCAFile#serialize(RandomAccessFile, boolean)} without updating any timestamps. * - * @param raf The {@code RandomAccessFile} to writeNodeData to. + * @param raf + * The {@code RandomAccessFile} to writeNodeData to. * @return The amount of chunks written to the file. - * @throws IOException If something went wrong during serialization. + * @throws IOException + * If something went wrong during serialization. * @see MCAFile#serialize(RandomAccessFile, boolean) */ public int serialize(RandomAccessFile raf) throws IOException { @@ -147,11 +158,14 @@ public class MCAFile { * Serializes this object to an .mca file. * This method does not perform any cleanups on the data. * - * @param raf The {@code RandomAccessFile} to writeNodeData to. - * @param changeLastUpdate Whether it should update all timestamps that show - * when this file was last updated. + * @param raf + * The {@code RandomAccessFile} to writeNodeData to. + * @param changeLastUpdate + * Whether it should update all timestamps that show + * when this file was last updated. * @return The amount of chunks written to the file. - * @throws IOException If something went wrong during serialization. + * @throws IOException + * If something went wrong during serialization. */ public int serialize(RandomAccessFile raf, boolean changeLastUpdate) throws IOException { int globalOffset = 2; @@ -161,21 +175,21 @@ public class MCAFile { int chunkXOffset = MCAUtil.regionToChunk(regionX); int chunkZOffset = MCAUtil.regionToChunk(regionZ); - if (chunks == null) { + if(chunks == null) { return 0; } - for (int cx = 0; cx < 32; cx++) { - for (int cz = 0; cz < 32; cz++) { + for(int cx = 0; cx < 32; cx++) { + for(int cz = 0; cz < 32; cz++) { int index = getChunkIndex(cx, cz); Chunk chunk = chunks.get(index); - if (chunk == null) { + if(chunk == null) { continue; } raf.seek(4096L * globalOffset); lastWritten = chunk.serialize(raf, chunkXOffset + cx, chunkZOffset + cz); - if (lastWritten == 0) { + if(lastWritten == 0) { continue; } @@ -198,7 +212,7 @@ public class MCAFile { } // padding - if (lastWritten % 4096 != 0) { + if(lastWritten % 4096 != 0) { raf.seek(globalOffset * 4096L - 1); raf.write(0); } @@ -213,13 +227,16 @@ public class MCAFile { /** * Set a specific Chunk at a specific index. The index must be in range of 0 - 1023. * - * @param index The index of the Chunk. - * @param chunk The Chunk to be set. - * @throws IndexOutOfBoundsException If index is not in the range. + * @param index + * The index of the Chunk. + * @param chunk + * The Chunk to be set. + * @throws IndexOutOfBoundsException + * If index is not in the range. */ public void setChunk(int index, Chunk chunk) { checkIndex(index); - if (chunks == null) { + if(chunks == null) { chunks = new AtomicReferenceArray<>(1024); } chunks.set(index, chunk); @@ -229,9 +246,12 @@ public class MCAFile { * Set a specific Chunk at a specific chunk location. * The x- and z-value can be absolute chunk coordinates or they can be relative to the region origin. * - * @param chunkX The x-coordinate of the Chunk. - * @param chunkZ The z-coordinate of the Chunk. - * @param chunk The chunk to be set. + * @param chunkX + * The x-coordinate of the Chunk. + * @param chunkZ + * The z-coordinate of the Chunk. + * @param chunk + * The chunk to be set. */ public void setChunk(int chunkX, int chunkZ, Chunk chunk) { setChunk(getChunkIndex(chunkX, chunkZ), chunk); @@ -240,12 +260,13 @@ public class MCAFile { /** * Returns the chunk data of a chunk at a specific index in this file. * - * @param index The index of the chunk in this file. + * @param index + * The index of the chunk in this file. * @return The chunk data. */ public Chunk getChunk(int index) { checkIndex(index); - if (chunks == null) { + if(chunks == null) { return null; } return chunks.get(index); @@ -254,8 +275,10 @@ public class MCAFile { /** * Returns the chunk data of a chunk in this file. * - * @param chunkX The x-coordinate of the chunk. - * @param chunkZ The z-coordinate of the chunk. + * @param chunkX + * The x-coordinate of the chunk. + * @param chunkZ + * The z-coordinate of the chunk. * @return The chunk data. */ public Chunk getChunk(int chunkX, int chunkZ) { @@ -267,7 +290,7 @@ public class MCAFile { } private int checkIndex(int index) { - if (index < 0 || index > 1023) { + if(index < 0 || index > 1023) { throw new IndexOutOfBoundsException(); } return index; @@ -276,7 +299,7 @@ public class MCAFile { private Chunk createChunkIfMissing(int blockX, int blockZ) { int chunkX = MCAUtil.blockToChunk(blockX), chunkZ = MCAUtil.blockToChunk(blockZ); Chunk chunk = getChunk(chunkX, chunkZ); - if (chunk == null) { + if(chunk == null) { chunk = Chunk.newChunk(); setChunk(getChunkIndex(chunkX, chunkZ), chunk); } @@ -290,15 +313,18 @@ public class MCAFile { /** * Fetches the biome id at a specific block. * - * @param blockX The x-coordinate of the block. - * @param blockY The y-coordinate of the block. - * @param blockZ The z-coordinate of the block. + * @param blockX + * The x-coordinate of the block. + * @param blockY + * The y-coordinate of the block. + * @param blockZ + * The z-coordinate of the block. * @return The biome id if the chunk exists and the chunk has biomes, otherwise -1. */ public int getBiomeAt(int blockX, int blockY, int blockZ) { int chunkX = MCAUtil.blockToChunk(blockX), chunkZ = MCAUtil.blockToChunk(blockZ); Chunk chunk = getChunk(getChunkIndex(chunkX, chunkZ)); - if (chunk == null) { + if(chunk == null) { return -1; } return chunk.getBiomeAt(blockX, blockY, blockZ); @@ -308,11 +334,16 @@ public class MCAFile { * Set a block state at a specific block location. * The block coordinates can be absolute coordinates or they can be relative to the region. * - * @param blockX The x-coordinate of the block. - * @param blockY The y-coordinate of the block. - * @param blockZ The z-coordinate of the block. - * @param state The block state to be set. - * @param cleanup Whether the Palette and the BLockStates should be recalculated after adding the block state. + * @param blockX + * The x-coordinate of the block. + * @param blockY + * The y-coordinate of the block. + * @param blockZ + * The z-coordinate of the block. + * @param state + * The block state to be set. + * @param cleanup + * Whether the Palette and the BLockStates should be recalculated after adding the block state. */ public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) { createChunkIfMissing(blockX, blockZ).setBlockStateAt(blockX, blockY, blockZ, state, cleanup); @@ -322,15 +353,18 @@ public class MCAFile { * Fetches a block state at a specific block location. * The block coordinates can be absolute coordinates or they can be relative to the region. * - * @param blockX The x-coordinate of the block. - * @param blockY The y-coordinate of the block. - * @param blockZ The z-coordinate of the block. + * @param blockX + * The x-coordinate of the block. + * @param blockY + * The y-coordinate of the block. + * @param blockZ + * The z-coordinate of the block. * @return The block state or null if the chunk or the section do not exist. */ public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) { int chunkX = MCAUtil.blockToChunk(blockX), chunkZ = MCAUtil.blockToChunk(blockZ); Chunk chunk = getChunk(chunkX, chunkZ); - if (chunk == null) { + if(chunk == null) { return null; } return chunk.getBlockStateAt(blockX, blockY, blockZ); diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/MCAUtil.java b/src/main/java/com/volmit/iris/util/nbt/mca/MCAUtil.java index eb6f61f1c..13ce60895 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/MCAUtil.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/MCAUtil.java @@ -41,9 +41,11 @@ public final class MCAUtil { } /** - * @param file The file to read the data from. + * @param file + * The file to read the data from. * @return An in-memory representation of the MCA file with decompressed chunk data. - * @throws IOException if something during deserialization goes wrong. + * @throws IOException + * if something during deserialization goes wrong. * @see MCAUtil#read(File) */ public static MCAFile read(String file) throws IOException { @@ -53,19 +55,24 @@ public final class MCAUtil { /** * Reads an MCA file and loads all of its chunks. * - * @param file The file to read the data from. + * @param file + * The file to read the data from. * @return An in-memory representation of the MCA file with decompressed chunk data. - * @throws IOException if something during deserialization goes wrong. + * @throws IOException + * if something during deserialization goes wrong. */ public static MCAFile read(File file) throws IOException { return read(file, LoadFlags.ALL_DATA); } /** - * @param file The file to read the data from. - * @param loadFlags A logical or of {@link LoadFlags} constants indicating what data should be loaded + * @param file + * The file to read the data from. + * @param loadFlags + * A logical or of {@link LoadFlags} constants indicating what data should be loaded * @return An in-memory representation of the MCA file with decompressed chunk data. - * @throws IOException if something during deserialization goes wrong. + * @throws IOException + * if something during deserialization goes wrong. * @see MCAUtil#read(File) */ public static MCAFile read(String file, long loadFlags) throws IOException { @@ -75,14 +82,17 @@ public final class MCAUtil { /** * Reads an MCA file and loads all of its chunks. * - * @param file The file to read the data from. - * @param loadFlags A logical or of {@link LoadFlags} constants indicating what data should be loaded + * @param file + * The file to read the data from. + * @param loadFlags + * A logical or of {@link LoadFlags} constants indicating what data should be loaded * @return An in-memory representation of the MCA file with decompressed chunk data - * @throws IOException if something during deserialization goes wrong. + * @throws IOException + * if something during deserialization goes wrong. */ public static MCAFile read(File file, long loadFlags) throws IOException { MCAFile mcaFile = newMCAFile(file); - try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { + try(RandomAccessFile raf = new RandomAccessFile(file, "r")) { mcaFile.deserialize(raf, loadFlags); return mcaFile; } @@ -90,7 +100,7 @@ public final class MCAUtil { public static KList sampleChunkPositions(File file) throws IOException { MCAFile mcaFile = newMCAFile(file); - try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { + try(RandomAccessFile raf = new RandomAccessFile(file, "r")) { return mcaFile.samplePositions(raf); } } @@ -98,10 +108,13 @@ public final class MCAUtil { /** * Calls {@link MCAUtil#write(MCAFile, File, boolean)} without changing the timestamps. * - * @param file The file to writeNodeData to. - * @param mcaFile The data of the MCA file to writeNodeData. + * @param file + * The file to writeNodeData to. + * @param mcaFile + * The data of the MCA file to writeNodeData. * @return The amount of chunks written to the file. - * @throws IOException If something goes wrong during serialization. + * @throws IOException + * If something goes wrong during serialization. * @see MCAUtil#write(MCAFile, File, boolean) */ public static int write(MCAFile mcaFile, String file) throws IOException { @@ -111,10 +124,13 @@ public final class MCAUtil { /** * Calls {@link MCAUtil#write(MCAFile, File, boolean)} without changing the timestamps. * - * @param file The file to writeNodeData to. - * @param mcaFile The data of the MCA file to writeNodeData. + * @param file + * The file to writeNodeData to. + * @param mcaFile + * The data of the MCA file to writeNodeData. * @return The amount of chunks written to the file. - * @throws IOException If something goes wrong during serialization. + * @throws IOException + * If something goes wrong during serialization. * @see MCAUtil#write(MCAFile, File, boolean) */ public static int write(MCAFile mcaFile, File file) throws IOException { @@ -122,11 +138,15 @@ public final class MCAUtil { } /** - * @param file The file to writeNodeData to. - * @param mcaFile The data of the MCA file to writeNodeData. - * @param changeLastUpdate Whether to adjust the timestamps of when the file was saved. + * @param file + * The file to writeNodeData to. + * @param mcaFile + * The data of the MCA file to writeNodeData. + * @param changeLastUpdate + * Whether to adjust the timestamps of when the file was saved. * @return The amount of chunks written to the file. - * @throws IOException If something goes wrong during serialization. + * @throws IOException + * If something goes wrong during serialization. * @see MCAUtil#write(MCAFile, File, boolean) */ public static int write(MCAFile mcaFile, String file, boolean changeLastUpdate) throws IOException { @@ -139,27 +159,31 @@ public final class MCAUtil { * the value set by either loading an already existing MCA file or setting them manually.
* If the file already exists, it is completely overwritten by the new file (no modification). * - * @param file The file to writeNodeData to. - * @param mcaFile The data of the MCA file to writeNodeData. - * @param changeLastUpdate Whether to adjust the timestamps of when the file was saved. + * @param file + * The file to writeNodeData to. + * @param mcaFile + * The data of the MCA file to writeNodeData. + * @param changeLastUpdate + * Whether to adjust the timestamps of when the file was saved. * @return The amount of chunks written to the file. - * @throws IOException If something goes wrong during serialization. + * @throws IOException + * If something goes wrong during serialization. */ public static int write(MCAFile mcaFile, File file, boolean changeLastUpdate) throws IOException { - if (mcaFile == null) { + if(mcaFile == null) { return 0; } File to = file; - if (file.exists()) { + if(file.exists()) { to = File.createTempFile(to.getName(), null); } int chunks; - try (RandomAccessFile raf = new RandomAccessFile(to, "rw")) { + try(RandomAccessFile raf = new RandomAccessFile(to, "rw")) { chunks = mcaFile.serialize(raf, changeLastUpdate); } - if (chunks > 0 && to != file) { + if(chunks > 0 && to != file) { Files.move(to.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING); } @@ -170,8 +194,10 @@ public final class MCAUtil { * Turns the chunks coordinates into region coordinates and calls * {@link MCAUtil#createNameFromRegionLocation(int, int)} * - * @param chunkX The x-value of the location of the chunk. - * @param chunkZ The z-value of the location of the chunk. + * @param chunkX + * The x-value of the location of the chunk. + * @param chunkZ + * The z-value of the location of the chunk. * @return A mca filename in the format "r.{regionX}.{regionZ}.mca" */ public static String createNameFromChunkLocation(int chunkX, int chunkZ) { @@ -182,8 +208,10 @@ public final class MCAUtil { * Turns the block coordinates into region coordinates and calls * {@link MCAUtil#createNameFromRegionLocation(int, int)} * - * @param blockX The x-value of the location of the block. - * @param blockZ The z-value of the location of the block. + * @param blockX + * The x-value of the location of the block. + * @param blockZ + * The z-value of the location of the block. * @return A mca filename in the format "r.{regionX}.{regionZ}.mca" */ public static String createNameFromBlockLocation(int blockX, int blockZ) { @@ -193,8 +221,10 @@ public final class MCAUtil { /** * Creates a filename string from provided chunk coordinates. * - * @param regionX The x-value of the location of the region. - * @param regionZ The z-value of the location of the region. + * @param regionX + * The x-value of the location of the region. + * @param regionZ + * The z-value of the location of the region. * @return A mca filename in the format "r.{regionX}.{regionZ}.mca" */ public static String createNameFromRegionLocation(int regionX, int regionZ) { @@ -204,7 +234,8 @@ public final class MCAUtil { /** * Turns a block coordinate value into a chunk coordinate value. * - * @param block The block coordinate value. + * @param block + * The block coordinate value. * @return The chunk coordinate value. */ public static int blockToChunk(int block) { @@ -214,7 +245,8 @@ public final class MCAUtil { /** * Turns a block coordinate value into a region coordinate value. * - * @param block The block coordinate value. + * @param block + * The block coordinate value. * @return The region coordinate value. */ public static int blockToRegion(int block) { @@ -224,7 +256,8 @@ public final class MCAUtil { /** * Turns a chunk coordinate value into a region coordinate value. * - * @param chunk The chunk coordinate value. + * @param chunk + * The chunk coordinate value. * @return The region coordinate value. */ public static int chunkToRegion(int chunk) { @@ -234,7 +267,8 @@ public final class MCAUtil { /** * Turns a region coordinate value into a chunk coordinate value. * - * @param region The region coordinate value. + * @param region + * The region coordinate value. * @return The chunk coordinate value. */ public static int regionToChunk(int region) { @@ -244,7 +278,8 @@ public final class MCAUtil { /** * Turns a region coordinate value into a block coordinate value. * - * @param region The region coordinate value. + * @param region + * The region coordinate value. * @return The block coordinate value. */ public static int regionToBlock(int region) { @@ -254,7 +289,8 @@ public final class MCAUtil { /** * Turns a chunk coordinate value into a block coordinate value. * - * @param chunk The chunk coordinate value. + * @param chunk + * The chunk coordinate value. * @return The block coordinate value. */ public static int chunkToBlock(int chunk) { @@ -263,7 +299,7 @@ public final class MCAUtil { public static MCAFile newMCAFile(File file) { Matcher m = mcaFilePattern.matcher(file.getName()); - if (m.find()) { + if(m.find()) { return new MCAFile(Integer.parseInt(m.group("regionX")), Integer.parseInt(m.group("regionZ"))); } throw new IllegalArgumentException("invalid mca file name: " + file.getName()); diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/NBTWorld.java b/src/main/java/com/volmit/iris/util/nbt/mca/NBTWorld.java index 11a51ea63..0e3e3239b 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/NBTWorld.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/NBTWorld.java @@ -49,11 +49,11 @@ public class NBTWorld { NamespacedKey key = blockData.getMaterial().getKey(); s.putString("Name", key.getNamespace() + ":" + key.getKey()); - if (data.contains("[")) { + if(data.contains("[")) { String raw = data.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", ""); CompoundTag props = new CompoundTag(); - if (raw.contains(",")) { - for (String i : raw.split("\\Q,\\E")) { + if(raw.contains(",")) { + for(String i : raw.split("\\Q,\\E")) { String[] m = i.split("\\Q=\\E"); String k = m[0]; String v = m[1]; @@ -90,17 +90,17 @@ public class NBTWorld { } public static BlockData getBlockData(CompoundTag tag) { - if (tag == null) { + if(tag == null) { return B.getAir(); } StringBuilder p = new StringBuilder(tag.getString("Name")); - if (tag.containsKey("Properties")) { + if(tag.containsKey("Properties")) { CompoundTag props = tag.getCompoundTag("Properties"); p.append('['); - for (String i : props.keySet()) { + for(String i : props.keySet()) { p.append(i).append('=').append(props.getString(i)).append(','); } @@ -109,7 +109,7 @@ public class NBTWorld { BlockData b = B.getOrNull(p.toString()); - if (b == null) { + if(b == null) { return B.getAir(); } @@ -123,8 +123,8 @@ public class NBTWorld { private static Map computeBiomeIDs() { Map biomeIds = new KMap<>(); - for (Biome biome : Biome.values()) { - if (!biome.name().equals("CUSTOM")) { + for(Biome biome : Biome.values()) { + if(!biome.name().equals("CUSTOM")) { biomeIds.put(biome, INMS.get().getBiomeId(biome)); } } @@ -134,22 +134,22 @@ public class NBTWorld { public void close() { - for (Long i : loadedRegions.k()) { + for(Long i : loadedRegions.k()) { queueSaveUnload(Cache.keyX(i), Cache.keyZ(i)); } saveQueue.shutdown(); try { - while (!saveQueue.awaitTermination(3, TimeUnit.SECONDS)) { + while(!saveQueue.awaitTermination(3, TimeUnit.SECONDS)) { Iris.info("Still Waiting to save MCA Files..."); } - } catch (InterruptedException e) { + } catch(InterruptedException e) { e.printStackTrace(); } } public void flushNow() { - for (Long i : loadedRegions.k()) { + for(Long i : loadedRegions.k()) { doSaveUnload(Cache.keyX(i), Cache.keyZ(i)); } } @@ -160,7 +160,7 @@ public class NBTWorld { public void doSaveUnload(int x, int z) { MCAFile f = getMCAOrNull(x, z); - if (f != null) { + if(f != null) { unloadRegion(x, z); } @@ -170,15 +170,15 @@ public class NBTWorld { public void save() { boolean saving = true; - for (Long i : loadedRegions.k()) { + for(Long i : loadedRegions.k()) { int x = Cache.keyX(i); int z = Cache.keyZ(i); - if (!lastUse.containsKey(i)) { + if(!lastUse.containsKey(i)) { lastUse.put(i, M.ms()); } - if (shouldUnload(x, z)) { + if(shouldUnload(x, z)) { queueSaveUnload(x, z); } } @@ -203,7 +203,7 @@ public class NBTWorld { try { MCAUtil.write(mca, getRegionFile(x, z), true); Iris.debug("Saved Region " + C.GOLD + x + " " + z); - } catch (IOException e) { + } catch(IOException e) { Iris.error("Failed to save region " + getRegionFile(x, z).getPath()); e.printStackTrace(); } @@ -213,7 +213,7 @@ public class NBTWorld { try { MCAUtil.write(mca, getRegionFile(x, z), true); Iris.debug("Saved Region " + C.GOLD + x + " " + z); - } catch (IOException e) { + } catch(IOException e) { Iris.error("Failed to save region " + getRegionFile(x, z).getPath()); e.printStackTrace(); } @@ -231,12 +231,12 @@ public class NBTWorld { try { CompoundTag tag = getChunkSection(x >> 4, y >> 4, z >> 4).getBlockStateAt(x & 15, y & 15, z & 15); - if (tag == null) { + if(tag == null) { return AIR; } return getBlockData(tag); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -259,7 +259,7 @@ public class NBTWorld { Chunk c = getChunk(x, z); Section s = c.getSection(y); - if (s == null) { + if(s == null) { s = Section.newSection(); c.setSection(y, s); } @@ -274,7 +274,7 @@ public class NBTWorld { public Chunk getChunk(MCAFile mca, int x, int z) { Chunk c = mca.getChunk(x & 31, z & 31); - if (c == null) { + if(c == null) { c = Chunk.newChunk(); mca.setChunk(x & 31, z & 31, c); } @@ -304,7 +304,7 @@ public class NBTWorld { MCAFile mcaf = loadedRegions.get(key); - if (mcaf == null) { + if(mcaf == null) { mcaf = new MCAFile(x, z); loadedRegions.put(key, mcaf); } @@ -317,7 +317,7 @@ public class NBTWorld { long key = Cache.key(x, z); return hyperLock.withResult(x, z, () -> { - if (loadedRegions.containsKey(key)) { + if(loadedRegions.containsKey(key)) { lastUse.put(key, M.ms()); return loadedRegions.get(key); } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/Section.java b/src/main/java/com/volmit/iris/util/nbt/mca/Section.java index 6372d42b5..6c7726aca 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/Section.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/Section.java @@ -40,7 +40,7 @@ public class Section { data = sectionRoot; this.dataVersion = dataVersion; ListTag rawPalette = sectionRoot.getListTag("Palette"); - if (rawPalette == null) { + if(rawPalette == null) { return; } palette = INMS.get().createPalette(); @@ -79,13 +79,16 @@ public class Section { * Fetches a block state based on a block location from this section. * The coordinates represent the location of the block inside of this Section. * - * @param blockX The x-coordinate of the block in this Section - * @param blockY The y-coordinate of the block in this Section - * @param blockZ The z-coordinate of the block in this Section + * @param blockX + * The x-coordinate of the block in this Section + * @param blockY + * The y-coordinate of the block in this Section + * @param blockZ + * The z-coordinate of the block in this Section * @return The block state data of this block. */ public synchronized CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) { - synchronized (palette) { + synchronized(palette) { return palette.getBlock(blockX & 15, blockY & 15, blockZ & 15); } } @@ -93,13 +96,17 @@ public class Section { /** * Attempts to add a block state for a specific block location in this Section. * - * @param blockX The x-coordinate of the block in this Section - * @param blockY The y-coordinate of the block in this Section - * @param blockZ The z-coordinate of the block in this Section - * @param state The block state to be set + * @param blockX + * The x-coordinate of the block in this Section + * @param blockY + * The y-coordinate of the block in this Section + * @param blockZ + * The z-coordinate of the block in this Section + * @param state + * The block state to be set */ public synchronized void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) { - synchronized (palette) { + synchronized(palette) { palette.setBlock(blockX & 15, blockY & 15, blockZ & 15, state); } } @@ -123,11 +130,13 @@ public class Section { /** * Sets the block light array for this section. * - * @param blockLight The block light array - * @throws IllegalArgumentException When the length of the array is not 2048 + * @param blockLight + * The block light array + * @throws IllegalArgumentException + * When the length of the array is not 2048 */ public synchronized void setBlockLight(byte[] blockLight) { - if (blockLight != null && blockLight.length != 2048) { + if(blockLight != null && blockLight.length != 2048) { throw new IllegalArgumentException("BlockLight array must have a length of 2048"); } this.blockLight = blockLight; @@ -143,11 +152,13 @@ public class Section { /** * Sets the sky light values of this section. * - * @param skyLight The custom sky light values - * @throws IllegalArgumentException If the length of the array is not 2048 + * @param skyLight + * The custom sky light values + * @throws IllegalArgumentException + * If the length of the array is not 2048 */ public synchronized void setSkyLight(byte[] skyLight) { - if (skyLight != null && skyLight.length != 2048) { + if(skyLight != null && skyLight.length != 2048) { throw new IllegalArgumentException("SkyLight array must have a length of 2048"); } this.skyLight = skyLight; @@ -158,21 +169,22 @@ public class Section { * This must be called before saving a Section to disk if the Section was manually created * to set the Y of this Section. * - * @param y The Y-value of this Section + * @param y + * The Y-value of this Section * @return A reference to the raw CompoundTag this Section is based on */ public synchronized CompoundTag updateHandle(int y) { data.putByte("Y", (byte) y); - if (palette != null) { - synchronized (palette) { + if(palette != null) { + synchronized(palette) { palette.writeToSection(data); } } - if (blockLight != null) { + if(blockLight != null) { data.putByteArray("BlockLight", blockLight); } - if (skyLight != null) { + if(skyLight != null) { data.putByteArray("SkyLight", skyLight); } return data; diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCABitStorage.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCABitStorage.java index 9f849a31e..1444d2503 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCABitStorage.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCABitStorage.java @@ -23,27 +23,27 @@ import org.apache.commons.lang3.Validate; import java.util.function.IntConsumer; public class MCABitStorage { - private static final int[] MAGIC = new int[]{ - -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, - 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, - 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, - 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, - 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, - 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, - 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, - 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, - 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, - 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, - 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, - 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, - 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, - 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, - 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, - 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, - 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, - 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, - 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, - 0, 5}; + private static final int[] MAGIC = new int[] { + -1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE, + 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, + 0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, + 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, + 306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135, + 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, + 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, + 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, + 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, + 138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567, + 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, + 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, + 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, + 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, + 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, + 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, + 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, + 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, + 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE, + 0, 5}; private final long[] data; @@ -76,8 +76,8 @@ public class MCABitStorage { this.divideAdd = MAGIC[var3 + 1]; this.divideShift = MAGIC[var3 + 2]; int var4 = (length + this.valuesPerLong - 1) / this.valuesPerLong; - if (data != null) { - if (data.length != var4) + if(data != null) { + if(data.length != var4) throw new RuntimeException("NO!"); this.data = data; } else { @@ -133,11 +133,11 @@ public class MCABitStorage { public void getAll(IntConsumer var0) { int var1 = 0; - for (long var5 : this.data) { - for (int var7 = 0; var7 < this.valuesPerLong; var7++) { + for(long var5 : this.data) { + for(int var7 = 0; var7 < this.valuesPerLong; var7++) { var0.accept((int) (var5 & this.mask)); var5 >>= this.bits; - if (++var1 >= this.size) + if(++var1 >= this.size) return; } } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAChunkBiomeContainer.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAChunkBiomeContainer.java index 5ba6d4693..7514f4ad2 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAChunkBiomeContainer.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAChunkBiomeContainer.java @@ -54,18 +54,18 @@ public class MCAChunkBiomeContainer { public MCAChunkBiomeContainer(MCAIdMap registry, int minHeight, int maxHeight, int[] aint) { this(registry, minHeight, maxHeight, (T[]) new Object[aint.length]); int i = -1; - for (int j = 0; j < this.biomes.length; j++) { + for(int j = 0; j < this.biomes.length; j++) { int k = aint[j]; T biomebase = registry.byId(k); - if (biomebase == null) { - if (i == -1) + if(biomebase == null) { + if(i == -1) i = j; this.biomes[j] = registry.byId(0); } else { this.biomes[j] = biomebase; } } - if (i != -1) + if(i != -1) LOGGER.warn("Invalid biome data received, starting from {}: {}", Integer.valueOf(i), Arrays.toString(aint)); } @@ -75,7 +75,7 @@ public class MCAChunkBiomeContainer { public int[] writeBiomes() { int[] aint = new int[this.biomes.length]; - for (int i = 0; i < this.biomes.length; i++) + for(int i = 0; i < this.biomes.length; i++) aint[i] = this.biomeRegistry.getId(this.biomes[i]); return aint; } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCACrudeIncrementalIntIdentityHashBiMap.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCACrudeIncrementalIntIdentityHashBiMap.java index 5695ece3d..769bf86ef 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCACrudeIncrementalIntIdentityHashBiMap.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCACrudeIncrementalIntIdentityHashBiMap.java @@ -54,13 +54,13 @@ public class MCACrudeIncrementalIntIdentityHashBiMap implements MCAIdMap { public K byId(int var0) { - if (var0 < 0 || var0 >= this.byId.length) + if(var0 < 0 || var0 >= this.byId.length) return null; return this.byId[var0]; } private int getValue(int var0) { - if (var0 == -1) + if(var0 == -1) return -1; return this.values[var0]; } @@ -80,7 +80,7 @@ public class MCACrudeIncrementalIntIdentityHashBiMap implements MCAIdMap { } private int nextId() { - while (this.nextId < this.byId.length && this.byId[this.nextId] != null) + while(this.nextId < this.byId.length && this.byId[this.nextId] != null) this.nextId++; return this.nextId; } @@ -93,17 +93,17 @@ public class MCACrudeIncrementalIntIdentityHashBiMap implements MCAIdMap { this.byId = (K[]) new Object[var0]; this.nextId = 0; this.size = 0; - for (int var3 = 0; var3 < var1.length; var3++) { - if (var1[var3] != null) + for(int var3 = 0; var3 < var1.length; var3++) { + if(var1[var3] != null) addMapping(var1[var3], var2[var3]); } } public void addMapping(K var0, int var1) { int var2 = Math.max(var1, this.size + 1); - if (var2 >= this.keys.length * 0.8F) { + if(var2 >= this.keys.length * 0.8F) { int i = this.keys.length << 1; - while (i < var1) + while(i < var1) i <<= 1; grow(i); } @@ -112,7 +112,7 @@ public class MCACrudeIncrementalIntIdentityHashBiMap implements MCAIdMap { this.values[var3] = var1; this.byId[var1] = var0; this.size++; - if (var1 == this.nextId) + if(var1 == this.nextId) this.nextId++; } @@ -122,16 +122,16 @@ public class MCACrudeIncrementalIntIdentityHashBiMap implements MCAIdMap { private int indexOf(K var0, int var1) { int var2; - for (var2 = var1; var2 < this.keys.length; var2++) { - if (this.keys[var2] == var0) + for(var2 = var1; var2 < this.keys.length; var2++) { + if(this.keys[var2] == var0) return var2; - if (this.keys[var2] == EMPTY_SLOT) + if(this.keys[var2] == EMPTY_SLOT) return -1; } - for (var2 = 0; var2 < var1; var2++) { - if (this.keys[var2] == var0) + for(var2 = 0; var2 < var1; var2++) { + if(this.keys[var2] == var0) return var2; - if (this.keys[var2] == EMPTY_SLOT) + if(this.keys[var2] == EMPTY_SLOT) return -1; } return -1; @@ -139,12 +139,12 @@ public class MCACrudeIncrementalIntIdentityHashBiMap implements MCAIdMap { private int findEmpty(int var0) { int var1; - for (var1 = var0; var1 < this.keys.length; var1++) { - if (this.keys[var1] == EMPTY_SLOT) + for(var1 = var0; var1 < this.keys.length; var1++) { + if(this.keys[var1] == EMPTY_SLOT) return var1; } - for (var1 = 0; var1 < var0; var1++) { - if (this.keys[var1] == EMPTY_SLOT) + for(var1 = 0; var1 < var0; var1++) { + if(this.keys[var1] == EMPTY_SLOT) return var1; } throw new RuntimeException("Overflowed :("); diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAHashMapPalette.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAHashMapPalette.java index 9bdfacd44..2eaf5460d 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAHashMapPalette.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAHashMapPalette.java @@ -48,17 +48,17 @@ public class MCAHashMapPalette implements MCAPalette { public int idFor(T var0) { int var1 = this.values.getId(var0); - if (var1 == -1) { + if(var1 == -1) { var1 = this.values.add(var0); - if (var1 >= 1 << this.bits) + if(var1 >= 1 << this.bits) var1 = this.resizeHandler.onResize(this.bits + 1, var0); } return var1; } public boolean maybeHas(Predicate var0) { - for (int var1 = 0; var1 < getSize(); var1++) { - if (var0.test(this.values.byId(var1))) + for(int var1 = 0; var1 < getSize(); var1++) { + if(var0.test(this.values.byId(var1))) return true; } return false; @@ -74,12 +74,12 @@ public class MCAHashMapPalette implements MCAPalette { public void read(ListTag var0) { this.values.clear(); - for (int var1 = 0; var1 < var0.size(); var1++) + for(int var1 = 0; var1 < var0.size(); var1++) this.values.add(this.reader.apply((CompoundTag) var0.get(var1))); } public void write(ListTag var0) { - for (int var1 = 0; var1 < getSize(); var1++) + for(int var1 = 0; var1 < getSize(); var1++) var0.add(this.writer.apply(this.values.byId(var1))); } } \ No newline at end of file diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java index b0d78e843..b1e5ddc2f 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAIdMapper.java @@ -21,14 +21,10 @@ package com.volmit.iris.util.nbt.mca.palette; import com.google.common.base.Predicates; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap; -import net.kyori.adventure.identity.Identity; -import net.minecraft.Util; -import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; @@ -55,10 +51,10 @@ public class MCAIdMapper implements MCAIdMap { public void addMapping(T var0, int var1) { this.tToId.put(var0, Integer.valueOf(var1)); - while (this.idToT.size() <= var1) + while(this.idToT.size() <= var1) this.idToT.add(null); this.idToT.set(var1, var0); - if (this.nextId <= var1) + if(this.nextId <= var1) this.nextId = var1 + 1; } @@ -72,7 +68,7 @@ public class MCAIdMapper implements MCAIdMap { } public final T byId(int var0) { - if (var0 >= 0 && var0 < this.idToT.size()) + if(var0 >= 0 && var0 < this.idToT.size()) return this.idToT.get(var0); return null; } @@ -89,10 +85,10 @@ public class MCAIdMapper implements MCAIdMap { return this.tToId.size(); } - static enum IdentityStrategy implements Hash.Strategy { + enum IdentityStrategy implements Hash.Strategy { INSTANCE; - private IdentityStrategy() { + IdentityStrategy() { } public int hashCode(Object var0) { diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java index 05dbb427e..cfb97c5ff 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCALinearPalette.java @@ -47,12 +47,12 @@ public class MCALinearPalette implements MCAPalette { public int idFor(T var0) { int var1; - for (var1 = 0; var1 < this.size; var1++) { - if (this.values[var1] == var0) + for(var1 = 0; var1 < this.size; var1++) { + if(this.values[var1] == var0) return var1; } var1 = this.size; - if (var1 < this.values.length) { + if(var1 < this.values.length) { this.values[var1] = var0; this.size++; return var1; @@ -61,15 +61,15 @@ public class MCALinearPalette implements MCAPalette { } public boolean maybeHas(Predicate var0) { - for (int var1 = 0; var1 < this.size; var1++) { - if (var0.test(this.values[var1])) + for(int var1 = 0; var1 < this.size; var1++) { + if(var0.test(this.values[var1])) return true; } return false; } public T valueFor(int var0) { - if (var0 >= 0 && var0 < this.size) + if(var0 >= 0 && var0 < this.size) return this.values[var0]; return null; } @@ -79,7 +79,7 @@ public class MCALinearPalette implements MCAPalette { } public void read(ListTag var0) { - for (int var1 = 0; var1 < var0.size(); var1++) { + for(int var1 = 0; var1 < var0.size(); var1++) { this.values[var1] = this.reader.apply((CompoundTag) var0.get(var1)); } this.size = var0.size(); diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAMth.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAMth.java index 31b2cb697..142ca27fa 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAMth.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAMth.java @@ -41,11 +41,11 @@ public class MCAMth { private static final float[] SIN; private static final Random RANDOM = new Random(); - private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{ - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, - 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, - 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, - 10, 9}; + private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[] { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, + 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, + 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, + 10, 9}; private static final double ONE_SIXTH = 0.16666666666666666D; private static final int FRAC_EXP = 8; private static final int LUT_SIZE = 257; @@ -55,13 +55,13 @@ public class MCAMth { static { SIN = make(new float[65536], var0 -> { - for (int var1 = 0; var1 < var0.length; var1++) + for(int var1 = 0; var1 < var0.length; var1++) var0[var1] = (float) Math.sin(var1 * Math.PI * 2.0D / 65536.0D); }); } static { - for (int var0 = 0; var0 < 257; var0++) { + for(int var0 = 0; var0 < 257; var0++) { double var1 = var0 / 256.0D; double var3 = Math.asin(var1); COS_TAB[var0] = Math.cos(var3); @@ -132,65 +132,65 @@ public class MCAMth { } public static byte clamp(byte var0, byte var1, byte var2) { - if (var0 < var1) + if(var0 < var1) return var1; - if (var0 > var2) + if(var0 > var2) return var2; return var0; } public static int clamp(int var0, int var1, int var2) { - if (var0 < var1) + if(var0 < var1) return var1; - if (var0 > var2) + if(var0 > var2) return var2; return var0; } public static long clamp(long var0, long var2, long var4) { - if (var0 < var2) + if(var0 < var2) return var2; - if (var0 > var4) + if(var0 > var4) return var4; return var0; } public static float clamp(float var0, float var1, float var2) { - if (var0 < var1) + if(var0 < var1) return var1; - if (var0 > var2) + if(var0 > var2) return var2; return var0; } public static double clamp(double var0, double var2, double var4) { - if (var0 < var2) + if(var0 < var2) return var2; - if (var0 > var4) + if(var0 > var4) return var4; return var0; } public static double clampedLerp(double var0, double var2, double var4) { - if (var4 < 0.0D) + if(var4 < 0.0D) return var0; - if (var4 > 1.0D) + if(var4 > 1.0D) return var2; return lerp(var4, var0, var2); } public static float clampedLerp(float var0, float var1, float var2) { - if (var2 < 0.0F) + if(var2 < 0.0F) return var0; - if (var2 > 1.0F) + if(var2 > 1.0F) return var1; return lerp(var2, var0, var1); } public static double absMax(double var0, double var2) { - if (var0 < 0.0D) + if(var0 < 0.0D) var0 = -var0; - if (var2 < 0.0D) + if(var2 < 0.0D) var2 = -var2; return (var0 > var2) ? var0 : var2; } @@ -200,26 +200,26 @@ public class MCAMth { } public static int nextInt(Random var0, int var1, int var2) { - if (var1 >= var2) + if(var1 >= var2) return var1; return var0.nextInt(var2 - var1 + 1) + var1; } public static float nextFloat(Random var0, float var1, float var2) { - if (var1 >= var2) + if(var1 >= var2) return var1; return var0.nextFloat() * (var2 - var1) + var1; } public static double nextDouble(Random var0, double var1, double var3) { - if (var1 >= var3) + if(var1 >= var3) return var1; return var0.nextDouble() * (var3 - var1) + var1; } public static double average(long[] var0) { long var1 = 0L; - for (long var6 : var0) + for(long var6 : var0) var1 += var6; return var1 / var0.length; } @@ -246,27 +246,27 @@ public class MCAMth { public static int wrapDegrees(int var0) { int var1 = var0 % 360; - if (var1 >= 180) + if(var1 >= 180) var1 -= 360; - if (var1 < -180) + if(var1 < -180) var1 += 360; return var1; } public static float wrapDegrees(float var0) { float var1 = var0 % 360.0F; - if (var1 >= 180.0F) + if(var1 >= 180.0F) var1 -= 360.0F; - if (var1 < -180.0F) + if(var1 < -180.0F) var1 += 360.0F; return var1; } public static double wrapDegrees(double var0) { double var2 = var0 % 360.0D; - if (var2 >= 180.0D) + if(var2 >= 180.0D) var2 -= 360.0D; - if (var2 < -180.0D) + if(var2 < -180.0D) var2 += 360.0D; return var2; } @@ -287,7 +287,7 @@ public class MCAMth { public static float approach(float var0, float var1, float var2) { var2 = abs(var2); - if (var0 < var1) + if(var0 < var1) return clamp(var0 + var2, var0, var1); return clamp(var0 - var2, var1, var0); } @@ -308,7 +308,7 @@ public class MCAMth { public static double getDouble(String var0, double var1) { try { return Double.parseDouble(var0); - } catch (Throwable var3) { + } catch(Throwable var3) { return var1; } } @@ -404,16 +404,16 @@ public class MCAMth { public static double atan2(double var0, double var2) { double var4 = var2 * var2 + var0 * var0; - if (Double.isNaN(var4)) + if(Double.isNaN(var4)) return Double.NaN; boolean var6 = (var0 < 0.0D); - if (var6) + if(var6) var0 = -var0; boolean var7 = (var2 < 0.0D); - if (var7) + if(var7) var2 = -var2; boolean var8 = (var0 > var2); - if (var8) { + if(var8) { double d = var2; var2 = var0; var0 = d; @@ -429,11 +429,11 @@ public class MCAMth { double var20 = var0 * var16 - var2 * var18; double var22 = (6.0D + var20 * var20) * var20 * 0.16666666666666666D; double var24 = var14 + var22; - if (var8) + if(var8) var24 = 1.5707963267948966D - var24; - if (var7) + if(var7) var24 = Math.PI - var24; - if (var6) + if(var6) var24 = -var24; return var24; } @@ -472,7 +472,7 @@ public class MCAMth { float var5 = var2 * (1.0F - var1); float var6 = var2 * (1.0F - var4 * var1); float var7 = var2 * (1.0F - (1.0F - var4) * var1); - switch (var3) { + switch(var3) { case 0: var8 = var2; var9 = var7; @@ -545,20 +545,20 @@ public class MCAMth { public static double[] cumulativeSum(double... var0) { float var1 = 0.0F; - for (double var5 : var0) + for(double var5 : var0) var1 = (float) (var1 + var5); int var2; - for (var2 = 0; var2 < var0.length; var2++) + for(var2 = 0; var2 < var0.length; var2++) var0[var2] = var0[var2] / var1; - for (var2 = 0; var2 < var0.length; var2++) + for(var2 = 0; var2 < var0.length; var2++) var0[var2] = ((var2 == 0) ? 0.0D : var0[var2 - 1]) + var0[var2]; return var0; } public static int getRandomForDistributionIntegral(Random var0, double[] var1) { double var2 = var0.nextDouble(); - for (int var4 = 0; var4 < var1.length; var4++) { - if (var2 < var1[var4]) + for(int var4 = 0; var4 < var1.length; var4++) { + if(var2 < var1[var4]) return var4; } return var1.length; @@ -567,10 +567,10 @@ public class MCAMth { public static double[] binNormalDistribution(double var0, double var2, double var4, int var6, int var7) { double[] var8 = new double[var7 - var6 + 1]; int var9 = 0; - for (int var10 = var6; var10 <= var7; var10++) { + for(int var10 = var6; var10 <= var7; var10++) { var8[var9] = Math.max(0.0D, var0 * - StrictMath.exp(-(var10 - var4) * (var10 - var4) / 2.0D * var2 * var2)); + StrictMath.exp(-(var10 - var4) * (var10 - var4) / 2.0D * var2 * var2)); var9++; } return var8; @@ -579,11 +579,11 @@ public class MCAMth { public static double[] binBiModalNormalDistribution(double var0, double var2, double var4, double var6, double var8, double var10, int var12, int var13) { double[] var14 = new double[var13 - var12 + 1]; int var15 = 0; - for (int var16 = var12; var16 <= var13; var16++) { + for(int var16 = var12; var16 <= var13; var16++) { var14[var15] = Math.max(0.0D, var0 * - StrictMath.exp(-(var16 - var4) * (var16 - var4) / 2.0D * var2 * var2) + var6 * - StrictMath.exp(-(var16 - var10) * (var16 - var10) / 2.0D * var8 * var8)); + StrictMath.exp(-(var16 - var4) * (var16 - var4) / 2.0D * var2 * var2) + var6 * + StrictMath.exp(-(var16 - var10) * (var16 - var10) / 2.0D * var8 * var8)); var15++; } return var14; @@ -592,7 +592,7 @@ public class MCAMth { public static double[] binLogDistribution(double var0, double var2, int var4, int var5) { double[] var6 = new double[var5 - var4 + 1]; int var7 = 0; - for (int var8 = var4; var8 <= var5; var8++) { + for(int var8 = var4; var8 <= var5; var8++) { var6[var7] = Math.max(var0 * StrictMath.log(var8) + var2, 0.0D); var7++; } @@ -610,15 +610,15 @@ public class MCAMth { public static double lerp2(double var0, double var2, double var4, double var6, double var8, double var10) { return lerp(var2, - lerp(var0, var4, var6), - lerp(var0, var8, var10)); + lerp(var0, var4, var6), + lerp(var0, var8, var10)); } public static double lerp3(double var0, double var2, double var4, double var6, double var8, double var10, double var12, double var14, double var16, double var18, double var20) { return lerp(var4, - lerp2(var0, var2, var6, var8, var10, var12), - lerp2(var0, var2, var14, var16, var18, var20)); + lerp2(var0, var2, var6, var8, var10, var12), + lerp2(var0, var2, var14, var16, var18, var20)); } public static double smoothstep(double var0) { @@ -630,7 +630,7 @@ public class MCAMth { } public static int sign(double var0) { - if (var0 == 0.0D) + if(var0 == 0.0D) return 0; return (var0 > 0.0D) ? 1 : -1; } @@ -646,18 +646,18 @@ public class MCAMth { @Deprecated public static float rotlerp(float var0, float var1, float var2) { float var3 = var1 - var0; - while (var3 < -180.0F) + while(var3 < -180.0F) var3 += 360.0F; - while (var3 >= 180.0F) + while(var3 >= 180.0F) var3 -= 360.0F; return var0 + var2 * var3; } @Deprecated public static float rotWrap(double var0) { - while (var0 >= 180.0D) + while(var0 >= 180.0D) var0 -= 360.0D; - while (var0 < -180.0D) + while(var0 < -180.0D) var0 += 360.0D; return (float) var0; } diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAPalettedContainer.java b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAPalettedContainer.java index 6eb410940..0d39d6465 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAPalettedContainer.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/palette/MCAPalettedContainer.java @@ -61,13 +61,13 @@ public class MCAPalettedContainer implements MCAPaletteResize { } private void setBits(int var0) { - if (var0 == this.bits) + if(var0 == this.bits) return; this.bits = var0; - if (this.bits <= 4) { + if(this.bits <= 4) { this.bits = 4; this.palette = new MCALinearPalette<>(this.registry, this.bits, this, this.reader); - } else if (this.bits < 9) { + } else if(this.bits < 9) { this.palette = new MCAHashMapPalette<>(this.registry, this.bits, this, this.reader, this.writer); } else { this.palette = this.globalPalette; @@ -81,9 +81,9 @@ public class MCAPalettedContainer implements MCAPaletteResize { MCABitStorage var2 = this.storage; MCAPalette var3 = this.palette; setBits(var0); - for (int var4 = 0; var4 < var2.getSize(); var4++) { + for(int var4 = 0; var4 < var2.getSize(); var4++) { T var5 = var3.valueFor(var2.get(var4)); - if (var5 != null) + if(var5 != null) set(var4, var5); } return this.palette.idFor(var1); @@ -124,21 +124,21 @@ public class MCAPalettedContainer implements MCAPaletteResize { public void read(ListTag var0, long[] var1) { int var2 = Math.max(4, MCAMth.ceillog2(var0.size())); - if (var2 != this.bits) + if(var2 != this.bits) setBits(var2); this.palette.read(var0); int var3 = var1.length * 64 / 4096; - if (this.palette == this.globalPalette) { + if(this.palette == this.globalPalette) { MCAPalette var4 = new MCAHashMapPalette<>(this.registry, var2, this.dummyPaletteResize, this.reader, this.writer); var4.read(var0); MCABitStorage var5 = new MCABitStorage(var2, 4096, var1); - for (int var6 = 0; var6 < 4096; var6++) + for(int var6 = 0; var6 < 4096; var6++) this.storage.set(var6, this.globalPalette.idFor(var4.valueFor(var5.get(var6)))); - } else if (var3 == this.bits) { + } else if(var3 == this.bits) { System.arraycopy(var1, 0, this.storage.getRaw(), 0, var1.length); } else { MCABitStorage var4 = new MCABitStorage(var3, 4096, var1); - for (int var5 = 0; var5 < 4096; var5++) + for(int var5 = 0; var5 < 4096; var5++) this.storage.set(var5, var4.get(var5)); } } @@ -148,9 +148,9 @@ public class MCAPalettedContainer implements MCAPaletteResize { T var4 = this.defaultValue; int var5 = var3.idFor(this.defaultValue); int[] var6 = new int[4096]; - for (int i = 0; i < 4096; i++) { + for(int i = 0; i < 4096; i++) { T t = get(i); - if (t != var4) { + if(t != var4) { var4 = t; var5 = var3.idFor(t); } @@ -161,7 +161,7 @@ public class MCAPalettedContainer implements MCAPaletteResize { var0.put(var1, paletteList); int var8 = Math.max(4, MCAMth.ceillog2(paletteList.size())); MCABitStorage var9 = new MCABitStorage(var8, 4096); - for (int var10 = 0; var10 < var6.length; var10++) { + for(int var10 = 0; var10 < var6.length; var10++) { var9.set(var10, var6[var10]); } var0.putLongArray(var2, var9.getRaw()); diff --git a/src/main/java/com/volmit/iris/util/nbt/tag/ArrayTag.java b/src/main/java/com/volmit/iris/util/nbt/tag/ArrayTag.java index b1ff6da74..afde40621 100644 --- a/src/main/java/com/volmit/iris/util/nbt/tag/ArrayTag.java +++ b/src/main/java/com/volmit/iris/util/nbt/tag/ArrayTag.java @@ -24,13 +24,14 @@ import java.lang.reflect.Array; * ArrayTag is an abstract representation of any NBT array tag. * For implementations see {@link ByteArrayTag}, {@link IntArrayTag}, {@link LongArrayTag}. * - * @param The array type. + * @param + * The array type. */ public abstract class ArrayTag extends Tag { public ArrayTag(T value) { super(value); - if (!value.getClass().isArray()) { + if(!value.getClass().isArray()) { throw new UnsupportedOperationException("type of array tag must be an array"); } } @@ -56,7 +57,7 @@ public abstract class ArrayTag extends Tag { protected String arrayToString(@SuppressWarnings("SameParameterValue") String prefix, @SuppressWarnings("SameParameterValue") String suffix) { StringBuilder sb = new StringBuilder("[").append(prefix).append("".equals(prefix) ? "" : ";"); - for (int i = 0; i < length(); i++) { + for(int i = 0; i < length(); i++) { sb.append(i == 0 ? "" : ",").append(Array.get(getValue(), i)).append(suffix); } sb.append("]"); diff --git a/src/main/java/com/volmit/iris/util/nbt/tag/CompoundTag.java b/src/main/java/com/volmit/iris/util/nbt/tag/CompoundTag.java index 68bd945cf..86d7277b5 100644 --- a/src/main/java/com/volmit/iris/util/nbt/tag/CompoundTag.java +++ b/src/main/java/com/volmit/iris/util/nbt/tag/CompoundTag.java @@ -89,7 +89,7 @@ public class CompoundTag extends Tag>> implements Iterable> C get(String key, Class type) { Tag t = getValue().get(key); - if (t != null) { + if(t != null) { return type.cast(t); } return null; @@ -254,10 +254,10 @@ public class CompoundTag extends Tag>> implements Iterable> e : getValue().entrySet()) { + for(Map.Entry> e : getValue().entrySet()) { sb.append(first ? "" : ",") - .append(escapeString(e.getKey(), false)).append(":") - .append(e.getValue().toString(decrementMaxDepth(maxDepth))); + .append(escapeString(e.getKey(), false)).append(":") + .append(e.getValue().toString(decrementMaxDepth(maxDepth))); first = false; } sb.append("}"); @@ -266,15 +266,15 @@ public class CompoundTag extends Tag>> implements Iterable> e : getValue().entrySet()) { + for(Map.Entry> e : getValue().entrySet()) { Tag v; - if ((v = ((CompoundTag) other).get(e.getKey())) == null || !e.getValue().equals(v)) { + if((v = ((CompoundTag) other).get(e.getKey())) == null || !e.getValue().equals(v)) { return false; } } @@ -289,7 +289,7 @@ public class CompoundTag extends Tag>> implements Iterable> e : getValue().entrySet()) { + for(Map.Entry> e : getValue().entrySet()) { copy.put(e.getKey(), e.getValue().clone()); } return copy; diff --git a/src/main/java/com/volmit/iris/util/nbt/tag/ListTag.java b/src/main/java/com/volmit/iris/util/nbt/tag/ListTag.java index 1242619fe..402875ac5 100644 --- a/src/main/java/com/volmit/iris/util/nbt/tag/ListTag.java +++ b/src/main/java/com/volmit/iris/util/nbt/tag/ListTag.java @@ -48,13 +48,16 @@ public class ListTag> extends Tag> implements Iterable< } /** - * @param typeClass The exact class of the elements - * @throws IllegalArgumentException When {@code typeClass} is {@link EndTag}{@code .class} - * @throws NullPointerException When {@code typeClass} is {@code null} + * @param typeClass + * The exact class of the elements + * @throws IllegalArgumentException + * When {@code typeClass} is {@link EndTag}{@code .class} + * @throws NullPointerException + * When {@code typeClass} is {@code null} */ public ListTag(Class typeClass) throws IllegalArgumentException, NullPointerException { super(createEmptyValue(3)); - if (typeClass == EndTag.class) { + if(typeClass == EndTag.class) { throw new IllegalArgumentException("cannot create ListTag with EndTag elements"); } this.typeClass = Objects.requireNonNull(typeClass); @@ -78,8 +81,10 @@ public class ListTag> extends Tag> implements Iterable< /** *

Creates an empty mutable list to be used as empty value of ListTags.

* - * @param Type of the list elements - * @param initialCapacity The initial capacity of the returned List + * @param + * Type of the list elements + * @param initialCapacity + * The initial capacity of the returned List * @return An instance of {@link List} with an initial capacity of 3 */ private static List createEmptyValue(@SuppressWarnings("SameParameterValue") int initialCapacity) { @@ -141,7 +146,8 @@ public class ListTag> extends Tag> implements Iterable< /** * Adds a Tag to this ListTag after the last index. * - * @param t The element to be added. + * @param t + * The element to be added. */ public void add(T t) { add(size(), t); @@ -149,26 +155,26 @@ public class ListTag> extends Tag> implements Iterable< public void add(int index, T t) { Objects.requireNonNull(t); - if (typeClass == null || typeClass == EndTag.class) { + if(typeClass == null || typeClass == EndTag.class) { typeClass = t.getClass(); - } else if (typeClass != t.getClass()) { + } else if(typeClass != t.getClass()) { throw new ClassCastException( - String.format("cannot add %s to ListTag<%s>", - t.getClass().getSimpleName(), - typeClass.getSimpleName())); + String.format("cannot add %s to ListTag<%s>", + t.getClass().getSimpleName(), + typeClass.getSimpleName())); } getValue().add(index, t); } public void addAll(Collection t) { - for (T tt : t) { + for(T tt : t) { add(tt); } } public void addAll(int index, Collection t) { int i = 0; - for (T tt : t) { + for(T tt : t) { add(index + i, tt); i++; } @@ -287,7 +293,7 @@ public class ListTag> extends Tag> implements Iterable< @Override public String valueToString(int maxDepth) { StringBuilder sb = new StringBuilder("{\"type\":\"").append(getTypeClass().getSimpleName()).append("\",\"list\":["); - for (int i = 0; i < size(); i++) { + for(int i = 0; i < size(); i++) { sb.append(i > 0 ? "," : "").append(get(i).valueToString(decrementMaxDepth(maxDepth))); } sb.append("]}"); @@ -296,14 +302,14 @@ public class ListTag> extends Tag> implements Iterable< @Override public boolean equals(Object other) { - if (this == other) { + if(this == other) { return true; } - if (!super.equals(other) || size() != ((ListTag) other).size() || getTypeClass() != ((ListTag) other).getTypeClass()) { + if(!super.equals(other) || size() != ((ListTag) other).size() || getTypeClass() != ((ListTag) other).getTypeClass()) { return false; } - for (int i = 0; i < size(); i++) { - if (!get(i).equals(((ListTag) other).get(i))) { + for(int i = 0; i < size(); i++) { + if(!get(i).equals(((ListTag) other).get(i))) { return false; } } @@ -326,7 +332,7 @@ public class ListTag> extends Tag> implements Iterable< ListTag copy = new ListTag<>(); // assure type safety for clone copy.typeClass = typeClass; - for (T t : getValue()) { + for(T t : getValue()) { copy.add((T) t.clone()); } return copy; @@ -335,19 +341,19 @@ public class ListTag> extends Tag> implements Iterable< //TODO: make private @SuppressWarnings("unchecked") public void addUnchecked(Tag tag) { - if (typeClass != null && typeClass != tag.getClass() && typeClass != EndTag.class) { + if(typeClass != null && typeClass != tag.getClass() && typeClass != EndTag.class) { throw new IllegalArgumentException(String.format( - "cannot add %s to ListTag<%s>", - tag.getClass().getSimpleName(), typeClass.getSimpleName())); + "cannot add %s to ListTag<%s>", + tag.getClass().getSimpleName(), typeClass.getSimpleName())); } add(size(), (T) tag); } private void checkTypeClass(Class clazz) { - if (typeClass != null && typeClass != EndTag.class && typeClass != clazz) { + if(typeClass != null && typeClass != EndTag.class && typeClass != clazz) { throw new ClassCastException(String.format( - "cannot cast ListTag<%s> to ListTag<%s>", - typeClass.getSimpleName(), clazz.getSimpleName())); + "cannot cast ListTag<%s> to ListTag<%s>", + typeClass.getSimpleName(), clazz.getSimpleName())); } } } diff --git a/src/main/java/com/volmit/iris/util/nbt/tag/NonNullEntrySet.java b/src/main/java/com/volmit/iris/util/nbt/tag/NonNullEntrySet.java index b321fd0ee..692b1be16 100644 --- a/src/main/java/com/volmit/iris/util/nbt/tag/NonNullEntrySet.java +++ b/src/main/java/com/volmit/iris/util/nbt/tag/NonNullEntrySet.java @@ -140,7 +140,7 @@ class NonNullEntrySet implements Set> { @Override public V setValue(V value) { - if (value == null) { + if(value == null) { throw new NullPointerException(getClass().getSimpleName() + " does not allow setting null"); } return entry.setValue(value); diff --git a/src/main/java/com/volmit/iris/util/nbt/tag/Tag.java b/src/main/java/com/volmit/iris/util/nbt/tag/Tag.java index 8d3748f49..3a1192772 100644 --- a/src/main/java/com/volmit/iris/util/nbt/tag/Tag.java +++ b/src/main/java/com/volmit/iris/util/nbt/tag/Tag.java @@ -49,7 +49,8 @@ import java.util.regex.Pattern; * is no guarantee that {@code MaxDepthReachedException}s are thrown for them. The respective class * will document this behavior accordingly.

* - * @param The type of the contained value + * @param + * The type of the contained value */ public abstract class Tag implements Cloneable { @@ -79,7 +80,8 @@ public abstract class Tag implements Cloneable { * Initializes this Tag with some value. If the value is {@code null}, it will * throw a {@code NullPointerException} * - * @param value The value to be set for this Tag. + * @param value + * The value to be set for this Tag. */ public Tag(T value) { setValue(value); @@ -89,21 +91,23 @@ public abstract class Tag implements Cloneable { * Escapes a string to fit into a JSON-like string representation for Minecraft * or to create the JSON string representation of a Tag returned from {@link Tag#toString()} * - * @param s The string to be escaped. - * @param lenient {@code true} if it should force double quotes ({@code "}) at the start and - * the end of the string. + * @param s + * The string to be escaped. + * @param lenient + * {@code true} if it should force double quotes ({@code "}) at the start and + * the end of the string. * @return The escaped string. */ @SuppressWarnings("StringBufferMayBeStringBuilder") protected static String escapeString(String s, @SuppressWarnings("SameParameterValue") boolean lenient) { StringBuffer sb = new StringBuffer(); Matcher m = ESCAPE_PATTERN.matcher(s); - while (m.find()) { + while(m.find()) { m.appendReplacement(sb, ESCAPE_CHARACTERS.get(m.group())); } m.appendTail(sb); m = NON_QUOTE_PATTERN.matcher(s); - if (!lenient || !m.matches()) { + if(!lenient || !m.matches()) { sb.insert(0, "\"").append("\""); } return sb.toString(); @@ -124,8 +128,10 @@ public abstract class Tag implements Cloneable { /** * Sets the value for this Tag directly. * - * @param value The value to be set. - * @throws NullPointerException If the value is null + * @param value + * The value to be set. + * @throws NullPointerException + * If the value is null */ protected void setValue(T value) { this.value = checkValue(value); @@ -134,9 +140,11 @@ public abstract class Tag implements Cloneable { /** * Checks if the value {@code value} is {@code null}. * - * @param value The value to check + * @param value + * The value to check * @return The parameter {@code value} - * @throws NullPointerException If {@code value} was {@code null} + * @throws NullPointerException + * If {@code value} was {@code null} */ protected T checkValue(T value) { return Objects.requireNonNull(value); @@ -145,7 +153,8 @@ public abstract class Tag implements Cloneable { /** * Calls {@link Tag#toString(int)} with an initial depth of {@code 0}. * - * @throws MaxDepthReachedException If the maximum nesting depth is exceeded. + * @throws MaxDepthReachedException + * If the maximum nesting depth is exceeded. * @see Tag#toString(int) */ @Override @@ -156,20 +165,23 @@ public abstract class Tag implements Cloneable { /** * Creates a string representation of this Tag in a valid JSON format. * - * @param maxDepth The maximum nesting depth. + * @param maxDepth + * The maximum nesting depth. * @return The string representation of this Tag. - * @throws MaxDepthReachedException If the maximum nesting depth is exceeded. + * @throws MaxDepthReachedException + * If the maximum nesting depth is exceeded. */ public String toString(int maxDepth) { return "{\"type\":\"" + getClass().getSimpleName() + "\"," + - "\"value\":" + valueToString(maxDepth) + "}"; + "\"value\":" + valueToString(maxDepth) + "}"; } /** * Calls {@link Tag#valueToString(int)} with {@link Tag#DEFAULT_MAX_DEPTH}. * * @return The string representation of the value of this Tag. - * @throws MaxDepthReachedException If the maximum nesting depth is exceeded. + * @throws MaxDepthReachedException + * If the maximum nesting depth is exceeded. */ public String valueToString() { return valueToString(DEFAULT_MAX_DEPTH); @@ -178,9 +190,11 @@ public abstract class Tag implements Cloneable { /** * Returns a JSON representation of the value of this Tag. * - * @param maxDepth The maximum nesting depth. + * @param maxDepth + * The maximum nesting depth. * @return The string representation of the value of this Tag. - * @throws MaxDepthReachedException If the maximum nesting depth is exceeded. + * @throws MaxDepthReachedException + * If the maximum nesting depth is exceeded. */ public abstract String valueToString(int maxDepth); @@ -190,7 +204,8 @@ public abstract class Tag implements Cloneable { * Custom Tag implementations should overwrite this but check the result * of this {@code super}-method while comparing. * - * @param other The Tag to compare to. + * @param other + * The Tag to compare to. * @return {@code true} if they are equal based on the conditions mentioned above. */ @Override diff --git a/src/main/java/com/volmit/iris/util/network/DL.java b/src/main/java/com/volmit/iris/util/network/DL.java index bca5ff472..cde6f3036 100644 --- a/src/main/java/com/volmit/iris/util/network/DL.java +++ b/src/main/java/com/volmit/iris/util/network/DL.java @@ -65,7 +65,7 @@ public abstract class DL { flags = new KSet<>(); latch = new ChronoLatch(500); - for (DownloadFlag i : downloadFlags) { + for(DownloadFlag i : downloadFlags) { flags.add(i); } } @@ -75,7 +75,7 @@ public abstract class DL { } public void update() { - if (m != null) { + if(m != null) { m.onUpdate(state, getProgress(), getElapsed(), getTimeLeft(), bps, getDiskBytesPerSecond(), size, downloaded, bufferSize, getBufferUse()); } } @@ -98,13 +98,13 @@ public abstract class DL { } public void start() throws IOException { - if (!isState(DownloadState.NEW)) { + if(!isState(DownloadState.NEW)) { throw new DownloadException("Cannot start download while " + state.toString()); } state(DownloadState.STARTING); - if (hasFlag(DownloadFlag.CALCULATE_SIZE)) { + if(hasFlag(DownloadFlag.CALCULATE_SIZE)) { size = calculateSize(); } @@ -124,14 +124,14 @@ public abstract class DL { protected abstract void closeStream() throws IOException; public void downloadChunk() throws IOException { - if (!isState(DownloadState.DOWNLOADING)) { + if(!isState(DownloadState.DOWNLOADING)) { throw new DownloadException("Cannot download while " + state.toString()); } long d = download(); lastPull = d; - if (d < 0) { + if(d < 0) { finishDownload(); return; } @@ -142,7 +142,7 @@ public abstract class DL { double chunkTime = (double) (System.currentTimeMillis() - lastChunk) / 1000D; bps = (long) ((double) currentChunk / chunkTime); - if (latch.flip()) { + if(latch.flip()) { update(); } } @@ -152,7 +152,7 @@ public abstract class DL { } private void finishDownload() throws IOException { - if (!isState(DownloadState.NEW)) { + if(!isState(DownloadState.NEW)) { throw new DownloadException("Cannot finish download while " + state.toString()); } @@ -174,7 +174,7 @@ public abstract class DL { } public long getDiskBytesPerSecond() { - if (o == null) { + if(o == null) { return -1; } @@ -224,10 +224,10 @@ public abstract class DL { @Override protected long download() throws IOException { - if (getBytesPerSecond() > mbps) { + if(getBytesPerSecond() > mbps) { try { Thread.sleep(40); - } catch (InterruptedException e) { + } catch(InterruptedException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/network/MeteredInputStream.java b/src/main/java/com/volmit/iris/util/network/MeteredInputStream.java index 939f8746b..a7c9437bc 100644 --- a/src/main/java/com/volmit/iris/util/network/MeteredInputStream.java +++ b/src/main/java/com/volmit/iris/util/network/MeteredInputStream.java @@ -50,7 +50,7 @@ public class MeteredInputStream extends InputStream { written++; totalWritten++; - if (auto && System.currentTimeMillis() - getSince() > interval) { + if(auto && System.currentTimeMillis() - getSince() > interval) { pollRead(); } diff --git a/src/main/java/com/volmit/iris/util/network/MeteredOutputStream.java b/src/main/java/com/volmit/iris/util/network/MeteredOutputStream.java index 8ba0d12ad..ccd6dff29 100644 --- a/src/main/java/com/volmit/iris/util/network/MeteredOutputStream.java +++ b/src/main/java/com/volmit/iris/util/network/MeteredOutputStream.java @@ -51,7 +51,7 @@ public class MeteredOutputStream extends OutputStream { written++; totalWritten++; - if (auto && System.currentTimeMillis() - getSince() > interval) { + if(auto && System.currentTimeMillis() - getSince() > interval) { pollWritten(); } } diff --git a/src/main/java/com/volmit/iris/util/noise/CNG.java b/src/main/java/com/volmit/iris/util/noise/CNG.java index 051046107..f8b2961bd 100644 --- a/src/main/java/com/volmit/iris/util/noise/CNG.java +++ b/src/main/java/com/volmit/iris/util/noise/CNG.java @@ -19,7 +19,6 @@ 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; @@ -34,16 +33,16 @@ import java.util.List; @Data public class CNG { - public static final NoiseInjector ADD = (s, v) -> new double[]{s + v, 1}; - public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[]{s - v < 0 ? 0 : s - v, -1}; - public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[]{v - s < 0 ? 0 : s - v, -1}; - public static final NoiseInjector MULTIPLY = (s, v) -> new double[]{s * v, 0}; - public static final NoiseInjector MAX = (s, v) -> new double[]{Math.max(s, v), 0}; - public static final NoiseInjector MIN = (s, v) -> new double[]{Math.min(s, v), 0}; - public static final NoiseInjector SRC_MOD = (s, v) -> new double[]{s % v, 0}; - public static final NoiseInjector SRC_POW = (s, v) -> new double[]{Math.pow(s, v), 0}; - public static final NoiseInjector DST_MOD = (s, v) -> new double[]{v % s, 0}; - public static final NoiseInjector DST_POW = (s, v) -> new double[]{Math.pow(v, s), 0}; + public static final NoiseInjector ADD = (s, v) -> new double[] {s + v, 1}; + public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[] {s - v < 0 ? 0 : s - v, -1}; + public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[] {v - s < 0 ? 0 : s - v, -1}; + public static final NoiseInjector MULTIPLY = (s, v) -> new double[] {s * v, 0}; + public static final NoiseInjector MAX = (s, v) -> new double[] {Math.max(s, v), 0}; + public static final NoiseInjector MIN = (s, v) -> new double[] {Math.min(s, v), 0}; + public static final NoiseInjector SRC_MOD = (s, v) -> new double[] {s % v, 0}; + public static final NoiseInjector SRC_POW = (s, v) -> new double[] {Math.pow(s, v), 0}; + public static final NoiseInjector DST_MOD = (s, v) -> new double[] {v % s, 0}; + public static final NoiseInjector DST_POW = (s, v) -> new double[] {Math.pow(v, s), 0}; public static long hits = 0; public static long creates = 0; private final double opacity; @@ -98,13 +97,12 @@ public class CNG { this.opacity = opacity; this.injector = ADD; - if (generator instanceof OctaveNoise) { + if(generator instanceof OctaveNoise) { ((OctaveNoise) generator).setOctaves(octaves); } } - public CNG cellularize(RNG seed, double freq) - { + public CNG cellularize(RNG seed, double freq) { FastNoise cellularFilter = new FastNoise(seed.imax()); cellularFilter.SetNoiseType(FastNoise.NoiseType.Cellular); cellularFilter.SetCellularReturnType(FastNoise.CellularReturnType.CellValue); @@ -121,7 +119,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) / 2D) + 0.5D; } @Override @@ -153,7 +151,7 @@ public class CNG { public static CNG signatureDoubleFast(RNG rng, NoiseType t, NoiseType f) { return signatureThickFast(rng, t, f) - .fractureWith(signatureFast(rng.nextParallelRNG(4956), t, f), 93); + .fractureWith(signatureFast(rng.nextParallelRNG(4956), t, f), 93); } public static CNG signature(RNG rng, NoiseType t) { @@ -169,20 +167,20 @@ public class CNG { public static CNG signaturePerlin(RNG rng, NoiseType t) { // @NoArgsConstructor return new CNG(rng.nextParallelRNG(124996), t, 1D, 1) - .fractureWith(new CNG(rng.nextParallelRNG(18), NoiseType.PERLIN, 1, 1).scale(1.25), 250) - .bake(); + .fractureWith(new CNG(rng.nextParallelRNG(18), NoiseType.PERLIN, 1, 1).scale(1.25), 250) + .bake(); // @done } public static CNG signatureFast(RNG rng, NoiseType t, NoiseType f) { // @NoArgsConstructor return new CNG(rng.nextParallelRNG(17), t, 1D, 1) - .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1) - .scale(0.9) - .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1) - .scale(0.21) - .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.9), 620), 145), 44) - .bake(); + .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1) + .scale(0.9) + .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1) + .scale(0.21) + .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.9), 620), 145), 44) + .bake(); // @done } @@ -195,10 +193,10 @@ public class CNG { public static CNG signatureThickFast(RNG rng, NoiseType t, NoiseType f) { // @NoArgsConstructor return new CNG(rng.nextParallelRNG(133), t, 1D, 1) - .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1) - .scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1) - .scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1) - .scale(0.4), 620), 145), 44).bake(); + .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1) + .scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1) + .scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1) + .scale(0.4), 620), 145), 44).bake(); // @done } @@ -211,9 +209,9 @@ public class CNG { public static CNG signatureHalfFast(RNG rng, NoiseType t, NoiseType f) { // @NoArgsConstructor return new CNG(rng.nextParallelRNG(127), t, 1D, 1) - .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1).scale(0.9) - .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.21) - .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.9), 420), 99), 22).bake(); + .fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1).scale(0.9) + .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.21) + .fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.9), 420), 99), 22).bake(); // @done } @@ -236,7 +234,7 @@ public class CNG { } public CNG child(CNG c) { - if (children == null) { + if(children == null) { children = new KList<>(); } @@ -280,28 +278,28 @@ public class CNG { } public T fitRarity(KList b, double... dim) { - if (b.size() == 0) { + if(b.size() == 0) { return null; } - if (b.size() == 1) { + if(b.size() == 1) { return b.get(0); } KList rarityMapped = new KList<>(); boolean o = false; int max = 1; - for (T i : b) { - if (i.getRarity() > max) { + for(T i : b) { + if(i.getRarity() > max) { max = i.getRarity(); } } max++; - for (T i : b) { - for (int j = 0; j < max - i.getRarity(); j++) { - if (o = !o) { + for(T i : b) { + for(int j = 0; j < max - i.getRarity(); j++) { + if(o = !o) { rarityMapped.add(i); } else { rarityMapped.add(0, i); @@ -309,11 +307,11 @@ public class CNG { } } - if (rarityMapped.size() == 1) { + if(rarityMapped.size() == 1) { return rarityMapped.get(0); } - if (rarityMapped.isEmpty()) { + if(rarityMapped.isEmpty()) { throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly ")); } @@ -321,11 +319,11 @@ public class CNG { } public T fit(T[] v, double... dim) { - if (v.length == 0) { + if(v.length == 0) { return null; } - if (v.length == 1) { + if(v.length == 1) { return v[0]; } @@ -333,17 +331,17 @@ public class CNG { } public T fit(List v, double... dim) { - if (v.size() == 0) { + if(v.size() == 0) { return null; } - if (v.size() == 1) { + if(v.size() == 1) { return v.get(0); } try { return v.get(fit(0, v.size() - 1, dim)); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -351,7 +349,7 @@ public class CNG { } public int fit(int min, int max, double... dim) { - if (min == max) { + if(min == max) { return min; } @@ -361,7 +359,7 @@ public class CNG { } public int fit(double min, double max, double... dim) { - if (min == max) { + if(min == max) { return (int) Math.round(min); } @@ -371,7 +369,7 @@ public class CNG { } public double fitDouble(double min, double max, double... dim) { - if (min == max) { + if(min == max) { return min; } @@ -383,14 +381,14 @@ public class CNG { private double getNoise(double... dim) { double scale = noscale ? 1 : this.bakedScale * this.scale; - if (fracture == null || noscale) { + if(fracture == null || noscale) { return generator.noise( - (dim.length > 0 ? dim[0] : 0D) * scale, - (dim.length > 1 ? dim[1] : 0D) * scale, - (dim.length > 2 ? dim[2] : 0D) * scale) * opacity; + (dim.length > 0 ? dim[0] : 0D) * scale, + (dim.length > 1 ? dim[1] : 0D) * scale, + (dim.length > 2 ? dim[2] : 0D) * scale) * opacity; } - if (fracture.isTrueFracturing()) { + if(fracture.isTrueFracturing()) { double x = dim.length > 0 ? dim[0] + ((fracture.noise(dim) - 0.5) * fscale) : 0D; double y = dim.length > 1 ? dim[1] + ((fracture.noise(dim[1], dim[0]) - 0.5) * fscale) : 0D; double z = dim.length > 2 ? dim[2] + ((fracture.noise(dim[2], dim[0], dim[1]) - 0.5) * fscale) : 0D; @@ -405,11 +403,11 @@ public class CNG { } public double invertNoise(double... dim) { - if (dim.length == 1) { + if(dim.length == 1) { return noise(-dim[0]); - } else if (dim.length == 2) { + } else if(dim.length == 2) { return noise(dim[1], dim[0]); - } else if (dim.length == 3) { + } else if(dim.length == 3) { return noise(dim[1], dim[2], dim[0]); } @@ -425,11 +423,11 @@ public class CNG { n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n; double m = 1; hits += oct; - if (children == null) { + if(children == null) { return (n - down + up) * patch; } - for (CNG i : children) { + for(CNG i : children) { double[] r = injector.combine(n, i.noise(dim)); n = r[0]; m += r[1]; diff --git a/src/main/java/com/volmit/iris/util/noise/CellGenerator.java b/src/main/java/com/volmit/iris/util/noise/CellGenerator.java index 66b422fa1..de48d351c 100644 --- a/src/main/java/com/volmit/iris/util/noise/CellGenerator.java +++ b/src/main/java/com/volmit/iris/util/noise/CellGenerator.java @@ -60,7 +60,7 @@ public class CellGenerator { } public double getValue(double x, double z, int possibilities) { - if (possibilities == 1) { + if(possibilities == 1) { return 0; } @@ -68,7 +68,7 @@ public class CellGenerator { } public double getValue(double x, double y, double z, int possibilities) { - if (possibilities == 1) { + if(possibilities == 1) { return 0; } @@ -76,7 +76,7 @@ public class CellGenerator { } public int getIndex(double x, double z, int possibilities) { - if (possibilities == 1) { + if(possibilities == 1) { return 0; } @@ -84,7 +84,7 @@ public class CellGenerator { } public int getIndex(double x, double y, double z, int possibilities) { - if (possibilities == 1) { + if(possibilities == 1) { return 0; } diff --git a/src/main/java/com/volmit/iris/util/noise/CloverNoise.java b/src/main/java/com/volmit/iris/util/noise/CloverNoise.java index 2590aecd5..6813438e1 100644 --- a/src/main/java/com/volmit/iris/util/noise/CloverNoise.java +++ b/src/main/java/com/volmit/iris/util/noise/CloverNoise.java @@ -39,7 +39,7 @@ public class CloverNoise implements NoiseGenerator { @Override public double noise(double x, double y, double z) { - if (z == 0) { + if(z == 0) { return n2.noise(x, y); } @@ -60,7 +60,8 @@ public class CloverNoise implements NoiseGenerator { /** * Constructs a new 2D Clover Noise generator with a specific seed. * - * @param seed The seed for the noise generator. + * @param seed + * The seed for the noise generator. */ public Noise2D(long seed) { this.seed = seed; @@ -76,7 +77,7 @@ public class CloverNoise implements NoiseGenerator { private long doHash(long input, long seed) { input += seed; - if (input < 0) { + if(input < 0) { input += HASH_M; } @@ -91,7 +92,7 @@ public class CloverNoise implements NoiseGenerator { long hash = doHash(seed, (long) Math.floor(position.getX())); hash = doHash(hash, (long) Math.floor(position.getY())); hash = doHash(hash, hash * (long) Math.floor(position.getX() + position.getY())); - if (hash < 0) { + if(hash < 0) { hash += HASH_M; } @@ -108,7 +109,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 2D Clover Noise at a specific point. * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of noise, from 0 to 1. */ public double noise(Vector2 p) { @@ -128,10 +130,10 @@ public class CloverNoise implements NoiseGenerator { Vector2 a, c, d; - if (side_nx < 0 && p.x < c_11.x || side_px > 0 && p.x > c_11.x) { + if(side_nx < 0 && p.x < c_11.x || side_px > 0 && p.x > c_11.x) { double side_py = m_p_c11.sub(d_p_c11.mult(c_12)).ymx(); - if (side_py > 0) { + if(side_py > 0) { a = c_12; c = c_01; d = new Vector2(-1, 1); @@ -143,7 +145,7 @@ public class CloverNoise implements NoiseGenerator { } else { double side_ny = m_p_c11.sub(d_p_c11.mult(c_10)).ymx(); - if (side_ny > 0) { + if(side_ny > 0) { a = c_10; c = c_21; d = new Vector2(1, -1); @@ -163,16 +165,16 @@ public class CloverNoise implements NoiseGenerator { Vector2 ac = a.sub(c); Vector2 bd = c_11.sub(d); - if (ac.x * ac.x + ac.y * ac.y < bd.x * bd.x + bd.y * bd.y) { + if(ac.x * ac.x + ac.y * ac.y < bd.x * bd.x + bd.y * bd.y) { Vector2 pa = p.sub(a); - if (pa.x * ac.y - pa.y * ac.x > 0.) { + if(pa.x * ac.y - pa.y * ac.x > 0.) { h = c_11; } } else { Vector2 pb = p.sub(c_11); - if (pb.x * bd.y - pb.y * bd.x > 0) { + if(pb.x * bd.y - pb.y * bd.x > 0) { f = c_11; } else { g = c_11; @@ -205,8 +207,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 2D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. * @return The value of noise, from 0 to 1. */ public double noise(double x, double y) { @@ -216,8 +220,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal 2D Clover Noise at a specific point. * - * @param p The point to generate noise at. - * @param iterations The number of iterations for the fractal noise. + * @param p + * The point to generate noise at. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of noise, from 0 to 1. */ public double fractalNoise(Vector2 p, int iterations) { @@ -225,7 +231,7 @@ public class CloverNoise implements NoiseGenerator { double weight = 1; double div = 0; - for (int i = 0; i < iterations; i++) { + for(int i = 0; i < iterations; i++) { total += noise(p.mult(1 / weight)) * weight; div += weight; @@ -238,9 +244,12 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal 2D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param iterations The number of iterations for the fractal noise. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of noise, from 0 to 1. */ public double fractalNoise(double x, double y, int iterations) { @@ -250,7 +259,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates curl 2D Clover Noise at a specific point. * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of curl noise, a normalized 2D vector. */ public Vector2 curlNoise(Vector2 p) { @@ -264,8 +274,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates curl 2D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. * @return The value of curl noise, a normalized 2D vector. */ public Vector2 curlNoise(double x, double y) { @@ -275,8 +287,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal curl 2D Clover Noise at a specific point. * - * @param p The point to generate noise at. - * @param iterations The number of iterations for the fractal noise. + * @param p + * The point to generate noise at. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of curl noise, a normalized 2D vector. */ public Vector2 fractalCurlNoise(Vector2 p, int iterations) { @@ -290,9 +304,12 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal curl 2D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param iterations The number of iterations for the fractal noise. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of curl noise, a normalized 2D vector. */ public Vector2 fractalCurlNoise(double x, double y, int iterations) { @@ -302,7 +319,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 2D Frost Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/frost.md * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of noise, from 0 to 1. */ public double frostNoise(Vector2 p) { @@ -317,8 +335,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 2D Frost Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/frost.md * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. * @return The value of noise, from 0 to 1. */ public double frostNoise(double x, double y) { @@ -328,7 +348,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 2D Marble Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/marble.md * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of noise, from 0 to 1. */ public double marbleNoise(Vector2 p) { @@ -353,8 +374,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 2D Marble Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/marble.md * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. * @return The value of noise, from 0 to 1. */ public double marbleNoise(double x, double y) { @@ -381,7 +404,7 @@ public class CloverNoise implements NoiseGenerator { private long doHash(long input, long seed) { input += seed; - if (input < 0) { + if(input < 0) { input += HASH_M; } @@ -397,7 +420,7 @@ public class CloverNoise implements NoiseGenerator { hash = doHash(hash, (long) Math.floor(position.getY())); hash = doHash(hash, (long) Math.floor(position.getZ())); hash = doHash(hash, hash * (long) Math.floor(position.getX() + position.getY() + position.getZ())); - if (hash < 0) { + if(hash < 0) { hash += HASH_M; } @@ -422,10 +445,10 @@ public class CloverNoise implements NoiseGenerator { Vector3 a, b, c, d; - if (side_nx < 0 && p.x < c_11.x || side_px > 0 && p.x >= c_11.x) { + if(side_nx < 0 && p.x < c_11.x || side_px > 0 && p.x >= c_11.x) { double side_py = m_p_c11.sub(d_p_c11.mult(c_12.xy())).ymx(); - if (side_py > 0.) { + if(side_py > 0.) { a = c_01; b = c_02; c = c_12; @@ -439,7 +462,7 @@ public class CloverNoise implements NoiseGenerator { } else { double side_ny = m_p_c11.sub(d_p_c11.mult(c_10.xy())).ymx(); - if (side_ny > 0.) { + if(side_ny > 0.) { a = c_10; b = c_11; c = c_21; @@ -459,7 +482,7 @@ public class CloverNoise implements NoiseGenerator { Vector3 ac = a.sub(c); Vector3 pa = p.sub(a); - if (pa.x * ac.y - pa.y * ac.x > 0) { + if(pa.x * ac.y - pa.y * ac.x > 0) { h = b; } @@ -477,7 +500,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 3D Clover Noise at a specific point. * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of noise, from 0 to 1. */ public double noise(Vector3 p) { @@ -509,9 +533,9 @@ public class CloverNoise implements NoiseGenerator { Vector3 a, b, c, d, e, f, g, h; - if (x_bound) { - if (y_bound) { - if (z_bound) { + if(x_bound) { + if(y_bound) { + if(z_bound) { a = offset(p_floor.add(-1, -1, -1)); b = c_001; c = c_010; @@ -531,7 +555,7 @@ public class CloverNoise implements NoiseGenerator { h = c_112; } } else { - if (z_bound) { + if(z_bound) { a = c_010; b = c_011; c = offset(p_floor.add(-1, 1, -1)); @@ -552,8 +576,8 @@ public class CloverNoise implements NoiseGenerator { } } } else { - if (y_bound) { - if (z_bound) { + if(y_bound) { + if(z_bound) { a = c_100; b = c_101; c = c_110; @@ -573,7 +597,7 @@ public class CloverNoise implements NoiseGenerator { h = c_212; } } else { - if (z_bound) { + if(z_bound) { a = c_110; b = c_111; c = c_120; @@ -610,19 +634,19 @@ public class CloverNoise implements NoiseGenerator { i = a; j = h; - if (plane_b > 0 && plane_d <= 0) { + if(plane_b > 0 && plane_d <= 0) { k = b; l = d; - } else if (plane_d > 0 && plane_c <= 0) { + } else if(plane_d > 0 && plane_c <= 0) { k = d; l = c; - } else if (plane_c > 0 && plane_g <= 0) { + } else if(plane_c > 0 && plane_g <= 0) { k = c; l = g; - } else if (plane_g > 0 && plane_e <= 0) { + } else if(plane_g > 0 && plane_e <= 0) { k = g; l = e; - } else if (plane_e > 0 && plane_f <= 0) { + } else if(plane_e > 0 && plane_f <= 0) { k = e; l = f; } else { @@ -672,9 +696,12 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 3D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param z The z coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param z + * The z coordinate of the point. * @return The value of noise, from 0 to 1. */ public double noise(double x, double y, double z) { @@ -684,8 +711,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal 3D Clover Noise at a specific point. * - * @param p The point to generate noise at. - * @param iterations The number of iterations for the fractal noise. + * @param p + * The point to generate noise at. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of noise, from 0 to 1. */ public double fractalNoise(Vector3 p, int iterations) { @@ -693,7 +722,7 @@ public class CloverNoise implements NoiseGenerator { double weight = 1; double div = 0; - for (int i = 0; i < iterations; i++) { + for(int i = 0; i < iterations; i++) { total += noise(p.mult(1 / weight)) * weight; div += weight; @@ -706,10 +735,14 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal 3D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param z The z coordinate of the point. - * @param iterations The number of iterations for the fractal noise. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param z + * The z coordinate of the point. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of noise, from 0 to 1. */ public double fractalNoise(double x, double y, double z, int iterations) { @@ -719,7 +752,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates curl 3D Clover Noise at a specific point. * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of curl noise, a normalized 3D vector. */ public Vector3 curlNoise(Vector3 p) { @@ -734,9 +768,12 @@ public class CloverNoise implements NoiseGenerator { /** * Generates curl 3D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param z The z coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param z + * The z coordinate of the point. * @return The value of curl noise, a normalized 3D vector. */ public Vector3 curlNoise(double x, double y, double z) { @@ -746,8 +783,10 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal curl 3D Clover Noise at a specific point. * - * @param p The point to generate noise at. - * @param iterations The number of iterations for the fractal noise. + * @param p + * The point to generate noise at. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of curl noise, a normalized 3D vector. */ public Vector3 fractalCurlNoise(Vector3 p, int iterations) { @@ -762,10 +801,14 @@ public class CloverNoise implements NoiseGenerator { /** * Generates fractal curl 3D Clover Noise at a specific point. * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param z The z coordinate of the point. - * @param iterations The number of iterations for the fractal noise. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param z + * The z coordinate of the point. + * @param iterations + * The number of iterations for the fractal noise. * @return The value of curl noise, a normalized 3D vector. */ public Vector3 fractalCurlNoise(double x, double y, double z, int iterations) { @@ -775,7 +818,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 3D Frost Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/frost.md * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of noise, from 0 to 1. */ public double frostNoise(Vector3 p) { @@ -790,9 +834,12 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 3D Frost Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/frost.md * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param z The z coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param z + * The z coordinate of the point. * @return The value of noise, from 0 to 1. */ public double frostNoise(double x, double y, double z) { @@ -802,7 +849,8 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 3D Marble Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/marble.md * - * @param p The point to generate noise at. + * @param p + * The point to generate noise at. * @return The value of noise, from 0 to 1. */ public double marbleNoise(Vector3 p) { @@ -827,9 +875,12 @@ public class CloverNoise implements NoiseGenerator { /** * Generates 3D Marble Noise at a specific point. See https://github.com/ValgoBoi/clover-noise/blob/master/variations/marble.md * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @param z The z coordinate of the point. + * @param x + * The x coordinate of the point. + * @param y + * The y coordinate of the point. + * @param z + * The z coordinate of the point. * @return The value of noise, from 0 to 1. */ public double marbleNoise(double x, double y, double z) { diff --git a/src/main/java/com/volmit/iris/util/noise/FastNoise.java b/src/main/java/com/volmit/iris/util/noise/FastNoise.java index f925a3686..870c2ca35 100644 --- a/src/main/java/com/volmit/iris/util/noise/FastNoise.java +++ b/src/main/java/com/volmit/iris/util/noise/FastNoise.java @@ -203,7 +203,7 @@ public class FastNoise { hash &= 31; float a = yd, b = zd, c = wd; // X,Y,Z - switch (hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS: + switch(hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS: case 1: a = wd; b = xd; @@ -316,7 +316,7 @@ public class FastNoise { private void CalculateFractalBounding() { float amp = m_gain; float ampFractal = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { ampFractal += amp; amp *= m_gain; } @@ -328,11 +328,11 @@ public class FastNoise { y *= m_frequency; z *= m_frequency; - switch (m_noiseType) { + switch(m_noiseType) { case Value: return SingleValue(m_seed, x, y, z); case ValueFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleValueFractalFBM(x, y, z); case Billow: @@ -345,7 +345,7 @@ public class FastNoise { case Perlin: return SinglePerlin(m_seed, x, y, z); case PerlinFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SinglePerlinFractalFBM(x, y, z); case Billow: @@ -358,7 +358,7 @@ public class FastNoise { case Simplex: return SingleSimplex(m_seed, x, y, z); case SimplexFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleSimplexFractalFBM(x, y, z); case Billow: @@ -369,7 +369,7 @@ public class FastNoise { return 0; } case Cellular: - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: case NoiseLookup: case Distance: @@ -382,7 +382,7 @@ public class FastNoise { case Cubic: return SingleCubic(m_seed, x, y, z); case CubicFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleCubicFractalFBM(x, y, z); case Billow: @@ -401,11 +401,11 @@ public class FastNoise { x *= m_frequency; y *= m_frequency; - switch (m_noiseType) { + switch(m_noiseType) { case Value: return SingleValue(m_seed, x, y); case ValueFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleValueFractalFBM(x, y); case Billow: @@ -418,7 +418,7 @@ public class FastNoise { case Perlin: return SinglePerlin(m_seed, x, y); case PerlinFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SinglePerlinFractalFBM(x, y); case Billow: @@ -431,7 +431,7 @@ public class FastNoise { case Simplex: return SingleSimplex(m_seed, x, y); case SimplexFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleSimplexFractalFBM(x, y); case Billow: @@ -442,7 +442,7 @@ public class FastNoise { return 0; } case Cellular: - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: case NoiseLookup: case Distance: @@ -455,7 +455,7 @@ public class FastNoise { case Cubic: return SingleCubic(m_seed, x, y); case CubicFractal: - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleCubicFractalFBM(x, y); case Billow: @@ -518,7 +518,7 @@ public class FastNoise { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleValueFractalFBM(x, y, z); case Billow: @@ -535,7 +535,7 @@ public class FastNoise { float sum = SingleValue(seed, x, y, z); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -552,7 +552,7 @@ public class FastNoise { float sum = Math.abs(SingleValue(seed, x, y, z)) * 2 - 1; float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -569,7 +569,7 @@ public class FastNoise { float sum = 1 - Math.abs(SingleValue(seed, x, y, z)); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -594,7 +594,7 @@ public class FastNoise { int z1 = z0 + 1; float xs, ys, zs; - switch (m_interp) { + switch(m_interp) { default: case Linear: xs = x - x0; @@ -628,7 +628,7 @@ public class FastNoise { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleValueFractalFBM(x, y); case Billow: @@ -645,7 +645,7 @@ public class FastNoise { float sum = SingleValue(seed, x, y); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -661,7 +661,7 @@ public class FastNoise { float sum = Math.abs(SingleValue(seed, x, y)) * 2 - 1; float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; amp *= m_gain; @@ -676,7 +676,7 @@ public class FastNoise { float sum = 1 - Math.abs(SingleValue(seed, x, y)); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -698,7 +698,7 @@ public class FastNoise { int y1 = y0 + 1; float xs, ys; - switch (m_interp) { + switch(m_interp) { default: case Linear: xs = x - x0; @@ -726,7 +726,7 @@ public class FastNoise { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SinglePerlinFractalFBM(x, y, z); case Billow: @@ -743,7 +743,7 @@ public class FastNoise { float sum = SinglePerlin(seed, x, y, z); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -760,7 +760,7 @@ public class FastNoise { float sum = Math.abs(SinglePerlin(seed, x, y, z)) * 2 - 1; float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -777,7 +777,7 @@ public class FastNoise { float sum = 1 - Math.abs(SinglePerlin(seed, x, y, z)); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -802,7 +802,7 @@ public class FastNoise { int z1 = z0 + 1; float xs, ys, zs; - switch (m_interp) { + switch(m_interp) { default: case Linear: xs = x - x0; @@ -843,7 +843,7 @@ public class FastNoise { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SinglePerlinFractalFBM(x, y); case Billow: @@ -860,7 +860,7 @@ public class FastNoise { float sum = SinglePerlin(seed, x, y); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -876,7 +876,7 @@ public class FastNoise { float sum = Math.abs(SinglePerlin(seed, x, y)) * 2 - 1; float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -892,7 +892,7 @@ public class FastNoise { float sum = 1 - Math.abs(SinglePerlin(seed, x, y)); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -914,7 +914,7 @@ public class FastNoise { int y1 = y0 + 1; float xs, ys; - switch (m_interp) { + switch(m_interp) { default: case Linear: xs = x - x0; @@ -947,7 +947,7 @@ public class FastNoise { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleSimplexFractalFBM(x, y, z); case Billow: @@ -964,7 +964,7 @@ public class FastNoise { float sum = SingleSimplex(seed, x, y, z); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -981,7 +981,7 @@ public class FastNoise { float sum = Math.abs(SingleSimplex(seed, x, y, z)) * 2 - 1; float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -998,7 +998,7 @@ public class FastNoise { float sum = 1 - Math.abs(SingleSimplex(seed, x, y, z)); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1028,15 +1028,15 @@ public class FastNoise { int i1, j1, k1; int i2, j2, k2; - if (x0 >= y0) { - if (y0 >= z0) { + if(x0 >= y0) { + if(y0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; - } else if (x0 >= z0) { + } else if(x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; @@ -1054,14 +1054,14 @@ public class FastNoise { } } else // x0 < y0 { - if (y0 < z0) { + if(y0 < z0) { i1 = 0; j1 = 0; k1 = 1; i2 = 0; j2 = 1; k2 = 1; - } else if (x0 < z0) { + } else if(x0 < z0) { i1 = 0; j1 = 1; k1 = 0; @@ -1092,7 +1092,7 @@ public class FastNoise { float n0, n1, n2, n3; t = (float) 0.6 - x0 * x0 - y0 * y0 - z0 * z0; - if (t < 0) + if(t < 0) n0 = 0; else { t *= t; @@ -1100,7 +1100,7 @@ public class FastNoise { } t = (float) 0.6 - x1 * x1 - y1 * y1 - z1 * z1; - if (t < 0) + if(t < 0) n1 = 0; else { t *= t; @@ -1108,7 +1108,7 @@ public class FastNoise { } t = (float) 0.6 - x2 * x2 - y2 * y2 - z2 * z2; - if (t < 0) + if(t < 0) n2 = 0; else { t *= t; @@ -1116,7 +1116,7 @@ public class FastNoise { } t = (float) 0.6 - x3 * x3 - y3 * y3 - z3 * z3; - if (t < 0) + if(t < 0) n3 = 0; else { t *= t; @@ -1130,7 +1130,7 @@ public class FastNoise { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleSimplexFractalFBM(x, y); case Billow: @@ -1147,7 +1147,7 @@ public class FastNoise { float sum = SingleSimplex(seed, x, y); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -1163,7 +1163,7 @@ public class FastNoise { float sum = Math.abs(SingleSimplex(seed, x, y)) * 2 - 1; float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -1179,7 +1179,7 @@ public class FastNoise { float sum = 1 - Math.abs(SingleSimplex(seed, x, y)); float amp = 1; - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -1210,7 +1210,7 @@ public class FastNoise { float y0 = y - Y0; int i1, j1; - if (x0 > y0) { + if(x0 > y0) { i1 = 1; j1 = 0; } else { @@ -1226,7 +1226,7 @@ public class FastNoise { float n0, n1, n2; t = (float) 0.5 - x0 * x0 - y0 * y0; - if (t < 0) + if(t < 0) n0 = 0; else { t *= t; @@ -1234,7 +1234,7 @@ public class FastNoise { } t = (float) 0.5 - x1 * x1 - y1 * y1; - if (t < 0) + if(t < 0) n1 = 0; else { t *= t; @@ -1242,7 +1242,7 @@ public class FastNoise { } t = (float) 0.5 - x2 * x2 - y2 * y2; - if (t < 0) + if(t < 0) n2 = 0; else { t *= t; @@ -1312,35 +1312,35 @@ public class FastNoise { float w4 = w0 - 1 + 4 * G4; t = (float) 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; - if (t < 0) + if(t < 0) n0 = 0; else { t *= t; n0 = t * t * GradCoord4D(seed, i, j, k, l, x0, y0, z0, w0); } t = (float) 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; - if (t < 0) + if(t < 0) n1 = 0; else { t *= t; n1 = t * t * GradCoord4D(seed, i + i1, j + j1, k + k1, l + l1, x1, y1, z1, w1); } t = (float) 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; - if (t < 0) + if(t < 0) n2 = 0; else { t *= t; n2 = t * t * GradCoord4D(seed, i + i2, j + j2, k + k2, l + l2, x2, y2, z2, w2); } t = (float) 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; - if (t < 0) + if(t < 0) n3 = 0; else { t *= t; n3 = t * t * GradCoord4D(seed, i + i3, j + j3, k + k3, l + l3, x3, y3, z3, w3); } t = (float) 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; - if (t < 0) + if(t < 0) n4 = 0; else { t *= t; @@ -1356,7 +1356,7 @@ public class FastNoise { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleCubicFractalFBM(x, y, z); case Billow: @@ -1374,7 +1374,7 @@ public class FastNoise { float amp = 1; int i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1392,7 +1392,7 @@ public class FastNoise { float amp = 1; int i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1410,7 +1410,7 @@ public class FastNoise { float amp = 1; int i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1452,7 +1452,7 @@ public class FastNoise { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { + switch(m_fractalType) { case FBM: return SingleCubicFractalFBM(x, y); case Billow: @@ -1470,7 +1470,7 @@ public class FastNoise { float amp = 1; int i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; @@ -1487,7 +1487,7 @@ public class FastNoise { float amp = 1; int i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; @@ -1504,7 +1504,7 @@ public class FastNoise { float amp = 1; int i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; @@ -1545,7 +1545,7 @@ public class FastNoise { y *= m_frequency; z *= m_frequency; - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: case NoiseLookup: case Distance: @@ -1563,11 +1563,11 @@ public class FastNoise { float distance = 999999; int xc = 0, yc = 0, zc = 0; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { case Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { - for (int zi = zr - 1; zi <= zr + 1; zi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { + for(int zi = zr - 1; zi <= zr + 1; zi++) { Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; float vecX = xi - x + vec.x; @@ -1576,7 +1576,7 @@ public class FastNoise { float newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1587,9 +1587,9 @@ public class FastNoise { } break; case Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { - for (int zi = zr - 1; zi <= zr + 1; zi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { + for(int zi = zr - 1; zi <= zr + 1; zi++) { Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; float vecX = xi - x + vec.x; @@ -1598,7 +1598,7 @@ public class FastNoise { float newDistance = Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1609,9 +1609,9 @@ public class FastNoise { } break; case Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { - for (int zi = zr - 1; zi <= zr + 1; zi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { + for(int zi = zr - 1; zi <= zr + 1; zi++) { Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; float vecX = xi - x + vec.x; @@ -1620,7 +1620,7 @@ public class FastNoise { float newDistance = (Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1632,7 +1632,7 @@ public class FastNoise { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: return ValCoord3D(0, xc, yc, zc); @@ -1655,11 +1655,11 @@ public class FastNoise { float distance = 999999; float distance2 = 999999; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { case Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { - for (int zi = zr - 1; zi <= zr + 1; zi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { + for(int zi = zr - 1; zi <= zr + 1; zi++) { Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; float vecX = xi - x + vec.x; @@ -1675,9 +1675,9 @@ public class FastNoise { } break; case Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { - for (int zi = zr - 1; zi <= zr + 1; zi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { + for(int zi = zr - 1; zi <= zr + 1; zi++) { Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; float vecX = xi - x + vec.x; @@ -1693,9 +1693,9 @@ public class FastNoise { } break; case Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { - for (int zi = zr - 1; zi <= zr + 1; zi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { + for(int zi = zr - 1; zi <= zr + 1; zi++) { Float3 vec = CELL_3D[Hash3D(m_seed, xi, yi, zi) & 255]; float vecX = xi - x + vec.x; @@ -1714,7 +1714,7 @@ public class FastNoise { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case Distance2: return distance2 - 1; case Distance2Add: @@ -1729,11 +1729,12 @@ public class FastNoise { return 0; } } + public float GetCellular(float x, float y, ProceduralStream sourceNoise, double iscale) { x *= m_frequency; y *= m_frequency; - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: case NoiseLookup: case Distance: @@ -1747,7 +1748,7 @@ public class FastNoise { x *= m_frequency; y *= m_frequency; - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: case NoiseLookup: case Distance: @@ -1764,11 +1765,11 @@ public class FastNoise { float distance = 999999; int xc = 0, yc = 0; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { default: case Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1776,7 +1777,7 @@ public class FastNoise { float newDistance = vecX * vecX + vecY * vecY; - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1785,8 +1786,8 @@ public class FastNoise { } break; case Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1794,7 +1795,7 @@ public class FastNoise { float newDistance = (Math.abs(vecX) + Math.abs(vecY)); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1803,8 +1804,8 @@ public class FastNoise { } break; case Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1812,7 +1813,7 @@ public class FastNoise { float newDistance = (Math.abs(vecX) + Math.abs(vecY)) + (vecX * vecX + vecY * vecY); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1822,7 +1823,7 @@ public class FastNoise { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: return ValCoord2D(0, xc, yc); @@ -1844,11 +1845,11 @@ public class FastNoise { float distance = 999999; int xc = 0, yc = 0; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { default: case Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1856,7 +1857,7 @@ public class FastNoise { float newDistance = vecX * vecX + vecY * vecY; - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1865,8 +1866,8 @@ public class FastNoise { } break; case Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1874,7 +1875,7 @@ public class FastNoise { float newDistance = (Math.abs(vecX) + Math.abs(vecY)); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1883,8 +1884,8 @@ public class FastNoise { } break; case Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1892,7 +1893,7 @@ public class FastNoise { float newDistance = (Math.abs(vecX) + Math.abs(vecY)) + (vecX * vecX + vecY * vecY); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1902,7 +1903,7 @@ public class FastNoise { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: return sourceNoise.get(xc * iscale, yc * iscale).floatValue(); @@ -1924,11 +1925,11 @@ public class FastNoise { float distance = 999999; float distance2 = 999999; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { default: case Euclidean: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1942,8 +1943,8 @@ public class FastNoise { } break; case Manhattan: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1957,8 +1958,8 @@ public class FastNoise { } break; case Natural: - for (int xi = xr - 1; xi <= xr + 1; xi++) { - for (int yi = yr - 1; yi <= yr + 1; yi++) { + for(int xi = xr - 1; xi <= xr + 1; xi++) { + for(int yi = yr - 1; yi <= yr + 1; yi++) { Float2 vec = CELL_2D[Hash2D(m_seed, xi, yi) & 255]; float vecX = xi - x + vec.x; @@ -1973,7 +1974,7 @@ public class FastNoise { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case Distance2: return distance2 - 1; case Distance2Add: @@ -2000,7 +2001,7 @@ public class FastNoise { SingleGradientPerturb(seed, amp, m_frequency, v3); - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { freq *= m_lacunarity; amp *= m_gain; SingleGradientPerturb(++seed, amp, freq, v3); @@ -2020,7 +2021,7 @@ public class FastNoise { int z1 = z0 + 1; float xs, ys, zs; - switch (m_interp) { + switch(m_interp) { default: case Linear: xs = xf - x0; @@ -2087,7 +2088,7 @@ public class FastNoise { SingleGradientPerturb(seed, amp, m_frequency, v2); - for (int i = 1; i < m_octaves; i++) { + for(int i = 1; i < m_octaves; i++) { freq *= m_lacunarity; amp *= m_gain; SingleGradientPerturb(++seed, amp, freq, v2); @@ -2104,7 +2105,7 @@ public class FastNoise { int y1 = y0 + 1; float xs, ys; - switch (m_interp) { + switch(m_interp) { default: case Linear: xs = xf - x0; diff --git a/src/main/java/com/volmit/iris/util/noise/FastNoiseDouble.java b/src/main/java/com/volmit/iris/util/noise/FastNoiseDouble.java index 86d65dce8..b502632de 100644 --- a/src/main/java/com/volmit/iris/util/noise/FastNoiseDouble.java +++ b/src/main/java/com/volmit/iris/util/noise/FastNoiseDouble.java @@ -200,7 +200,7 @@ public class FastNoiseDouble { hash &= 31; double a = yd, b = zd, c = wd; // X,Y,Z - switch ((int) hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS: + switch((int) hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS: case 1 -> { a = wd; b = xd; @@ -313,7 +313,7 @@ public class FastNoiseDouble { private void calculateFractalBounding() { double amp = m_gain; double ampFractal = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { ampFractal += amp; amp *= m_gain; } @@ -325,11 +325,11 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - switch (m_noiseType) { + switch(m_noiseType) { case Value: return SingleValue(m_seed, x, y, z); case ValueFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleValueFractalFBM(x, y, z); case Billow -> SingleValueFractalBillow(x, y, z); case RigidMulti -> SingleValueFractalRigidMulti(x, y, z); @@ -337,7 +337,7 @@ public class FastNoiseDouble { case Perlin: return SinglePerlin(m_seed, x, y, z); case PerlinFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SinglePerlinFractalFBM(x, y, z); case Billow -> SinglePerlinFractalBillow(x, y, z); case RigidMulti -> SinglePerlinFractalRigidMulti(x, y, z); @@ -345,13 +345,13 @@ public class FastNoiseDouble { case Simplex: return SingleSimplex(m_seed, x, y, z); case SimplexFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleSimplexFractalFBM(x, y, z); case Billow -> SingleSimplexFractalBillow(x, y, z); case RigidMulti -> SingleSimplexFractalRigidMulti(x, y, z); }; case Cellular: - return switch (m_cellularReturnType) { + return switch(m_cellularReturnType) { case CellValue, NoiseLookup, Distance -> SingleCellular(x, y, z); default -> SingleCellular2Edge(x, y, z); }; @@ -360,7 +360,7 @@ public class FastNoiseDouble { case Cubic: return SingleCubic(m_seed, x, y, z); case CubicFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleCubicFractalFBM(x, y, z); case Billow -> SingleCubicFractalBillow(x, y, z); case RigidMulti -> SingleCubicFractalRigidMulti(x, y, z); @@ -374,11 +374,11 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - switch (m_noiseType) { + switch(m_noiseType) { case Value: return SingleValue(m_seed, x, y); case ValueFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleValueFractalFBM(x, y); case Billow -> SingleValueFractalBillow(x, y); case RigidMulti -> SingleValueFractalRigidMulti(x, y); @@ -386,7 +386,7 @@ public class FastNoiseDouble { case Perlin: return SinglePerlin(m_seed, x, y); case PerlinFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SinglePerlinFractalFBM(x, y); case Billow -> SinglePerlinFractalBillow(x, y); case RigidMulti -> SinglePerlinFractalRigidMulti(x, y); @@ -394,13 +394,13 @@ public class FastNoiseDouble { case Simplex: return SingleSimplex(m_seed, x, y); case SimplexFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleSimplexFractalFBM(x, y); case Billow -> SingleSimplexFractalBillow(x, y); case RigidMulti -> SingleSimplexFractalRigidMulti(x, y); }; case Cellular: - return switch (m_cellularReturnType) { + return switch(m_cellularReturnType) { case CellValue, NoiseLookup, Distance -> SingleCellular(x, y); default -> SingleCellular2Edge(x, y); }; @@ -409,7 +409,7 @@ public class FastNoiseDouble { case Cubic: return SingleCubic(m_seed, x, y); case CubicFractal: - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleCubicFractalFBM(x, y); case Billow -> SingleCubicFractalBillow(x, y); case RigidMulti -> SingleCubicFractalRigidMulti(x, y); @@ -467,7 +467,7 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleValueFractalFBM(x, y, z); case Billow -> SingleValueFractalBillow(x, y, z); case RigidMulti -> SingleValueFractalRigidMulti(x, y, z); @@ -479,7 +479,7 @@ public class FastNoiseDouble { double sum = SingleValue(seed, x, y, z); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -496,7 +496,7 @@ public class FastNoiseDouble { double sum = Math.abs(SingleValue(seed, x, y, z)) * 2 - 1; double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -513,7 +513,7 @@ public class FastNoiseDouble { double sum = 1 - Math.abs(SingleValue(seed, x, y, z)); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -538,7 +538,7 @@ public class FastNoiseDouble { long z1 = z0 + 1; double xs = 0, ys = 0, zs = 0; - switch (m_longerp) { + switch(m_longerp) { case Linear -> { xs = x - x0; ys = y - y0; @@ -571,7 +571,7 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleValueFractalFBM(x, y); case Billow -> SingleValueFractalBillow(x, y); case RigidMulti -> SingleValueFractalRigidMulti(x, y); @@ -583,7 +583,7 @@ public class FastNoiseDouble { double sum = SingleValue(seed, x, y); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -599,7 +599,7 @@ public class FastNoiseDouble { double sum = Math.abs(SingleValue(seed, x, y)) * 2 - 1; double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; amp *= m_gain; @@ -614,7 +614,7 @@ public class FastNoiseDouble { double sum = 1 - Math.abs(SingleValue(seed, x, y)); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -636,7 +636,7 @@ public class FastNoiseDouble { long y1 = y0 + 1; double xs = 0, ys = 0; - switch (m_longerp) { + switch(m_longerp) { case Linear -> { xs = x - x0; ys = y - y0; @@ -663,7 +663,7 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SinglePerlinFractalFBM(x, y, z); case Billow -> SinglePerlinFractalBillow(x, y, z); case RigidMulti -> SinglePerlinFractalRigidMulti(x, y, z); @@ -675,7 +675,7 @@ public class FastNoiseDouble { double sum = SinglePerlin(seed, x, y, z); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -692,7 +692,7 @@ public class FastNoiseDouble { double sum = Math.abs(SinglePerlin(seed, x, y, z)) * 2 - 1; double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -709,7 +709,7 @@ public class FastNoiseDouble { double sum = 1 - Math.abs(SinglePerlin(seed, x, y, z)); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -734,7 +734,7 @@ public class FastNoiseDouble { long z1 = z0 + 1; double xs = 0, ys = 0, zs = 0; - switch (m_longerp) { + switch(m_longerp) { case Linear -> { xs = x - x0; ys = y - y0; @@ -774,7 +774,7 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SinglePerlinFractalFBM(x, y); case Billow -> SinglePerlinFractalBillow(x, y); case RigidMulti -> SinglePerlinFractalRigidMulti(x, y); @@ -786,7 +786,7 @@ public class FastNoiseDouble { double sum = SinglePerlin(seed, x, y); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -802,7 +802,7 @@ public class FastNoiseDouble { double sum = Math.abs(SinglePerlin(seed, x, y)) * 2 - 1; double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -818,7 +818,7 @@ public class FastNoiseDouble { double sum = 1 - Math.abs(SinglePerlin(seed, x, y)); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -840,7 +840,7 @@ public class FastNoiseDouble { long y1 = y0 + 1; double xs = 0, ys = 0; - switch (m_longerp) { + switch(m_longerp) { case Linear -> { xs = x - x0; ys = y - y0; @@ -872,7 +872,7 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleSimplexFractalFBM(x, y, z); case Billow -> SingleSimplexFractalBillow(x, y, z); case RigidMulti -> SingleSimplexFractalRigidMulti(x, y, z); @@ -884,7 +884,7 @@ public class FastNoiseDouble { double sum = SingleSimplex(seed, x, y, z); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -901,7 +901,7 @@ public class FastNoiseDouble { double sum = Math.abs(SingleSimplex(seed, x, y, z)) * 2 - 1; double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -918,7 +918,7 @@ public class FastNoiseDouble { double sum = 1 - Math.abs(SingleSimplex(seed, x, y, z)); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -948,15 +948,15 @@ public class FastNoiseDouble { long i1, j1, k1; long i2, j2, k2; - if (x0 >= y0) { - if (y0 >= z0) { + if(x0 >= y0) { + if(y0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; - } else if (x0 >= z0) { + } else if(x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; @@ -974,14 +974,14 @@ public class FastNoiseDouble { } } else // x0 < y0 { - if (y0 < z0) { + if(y0 < z0) { i1 = 0; j1 = 0; k1 = 1; i2 = 0; j2 = 1; k2 = 1; - } else if (x0 < z0) { + } else if(x0 < z0) { i1 = 0; j1 = 1; k1 = 0; @@ -1012,7 +1012,7 @@ public class FastNoiseDouble { double n0, n1, n2, n3; t = 0.6 - x0 * x0 - y0 * y0 - z0 * z0; - if (t < 0) + if(t < 0) n0 = 0; else { t *= t; @@ -1020,7 +1020,7 @@ public class FastNoiseDouble { } t = 0.6 - x1 * x1 - y1 * y1 - z1 * z1; - if (t < 0) + if(t < 0) n1 = 0; else { t *= t; @@ -1028,7 +1028,7 @@ public class FastNoiseDouble { } t = 0.6 - x2 * x2 - y2 * y2 - z2 * z2; - if (t < 0) + if(t < 0) n2 = 0; else { t *= t; @@ -1036,7 +1036,7 @@ public class FastNoiseDouble { } t = 0.6 - x3 * x3 - y3 * y3 - z3 * z3; - if (t < 0) + if(t < 0) n3 = 0; else { t *= t; @@ -1050,7 +1050,7 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleSimplexFractalFBM(x, y); case Billow -> SingleSimplexFractalBillow(x, y); case RigidMulti -> SingleSimplexFractalRigidMulti(x, y); @@ -1062,7 +1062,7 @@ public class FastNoiseDouble { double sum = SingleSimplex(seed, x, y); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -1078,7 +1078,7 @@ public class FastNoiseDouble { double sum = Math.abs(SingleSimplex(seed, x, y)) * 2 - 1; double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -1094,7 +1094,7 @@ public class FastNoiseDouble { double sum = 1 - Math.abs(SingleSimplex(seed, x, y)); double amp = 1; - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { x *= m_lacunarity; y *= m_lacunarity; @@ -1122,7 +1122,7 @@ public class FastNoiseDouble { double y0 = y - Y0; long i1, j1; - if (x0 > y0) { + if(x0 > y0) { i1 = 1; j1 = 0; } else { @@ -1138,7 +1138,7 @@ public class FastNoiseDouble { double n0, n1, n2; t = 0.5 - x0 * x0 - y0 * y0; - if (t < 0) + if(t < 0) n0 = 0; else { t *= t; @@ -1146,7 +1146,7 @@ public class FastNoiseDouble { } t = 0.5 - x1 * x1 - y1 * y1; - if (t < 0) + if(t < 0) n1 = 0; else { t *= t; @@ -1154,7 +1154,7 @@ public class FastNoiseDouble { } t = 0.5 - x2 * x2 - y2 * y2; - if (t < 0) + if(t < 0) n2 = 0; else { t *= t; @@ -1224,35 +1224,35 @@ public class FastNoiseDouble { double w4 = w0 - 1 + 4 * G4; t = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; - if (t < 0) + if(t < 0) n0 = 0; else { t *= t; n0 = t * t * GradCoord4D(seed, i, j, k, l, x0, y0, z0, w0); } t = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; - if (t < 0) + if(t < 0) n1 = 0; else { t *= t; n1 = t * t * GradCoord4D(seed, i + i1, j + j1, k + k1, l + l1, x1, y1, z1, w1); } t = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; - if (t < 0) + if(t < 0) n2 = 0; else { t *= t; n2 = t * t * GradCoord4D(seed, i + i2, j + j2, k + k2, l + l2, x2, y2, z2, w2); } t = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; - if (t < 0) + if(t < 0) n3 = 0; else { t *= t; n3 = t * t * GradCoord4D(seed, i + i3, j + j3, k + k3, l + l3, x3, y3, z3, w3); } t = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; - if (t < 0) + if(t < 0) n4 = 0; else { t *= t; @@ -1268,7 +1268,7 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleCubicFractalFBM(x, y, z); case Billow -> SingleCubicFractalBillow(x, y, z); case RigidMulti -> SingleCubicFractalRigidMulti(x, y, z); @@ -1281,7 +1281,7 @@ public class FastNoiseDouble { double amp = 1; long i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1299,7 +1299,7 @@ public class FastNoiseDouble { double amp = 1; long i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1317,7 +1317,7 @@ public class FastNoiseDouble { double amp = 1; long i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; @@ -1359,7 +1359,7 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - return switch (m_fractalType) { + return switch(m_fractalType) { case FBM -> SingleCubicFractalFBM(x, y); case Billow -> SingleCubicFractalBillow(x, y); case RigidMulti -> SingleCubicFractalRigidMulti(x, y); @@ -1372,7 +1372,7 @@ public class FastNoiseDouble { double amp = 1; long i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; @@ -1389,7 +1389,7 @@ public class FastNoiseDouble { double amp = 1; long i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; @@ -1406,7 +1406,7 @@ public class FastNoiseDouble { double amp = 1; long i = 0; - while (++i < m_octaves) { + while(++i < m_octaves) { x *= m_lacunarity; y *= m_lacunarity; @@ -1447,7 +1447,7 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - return switch (m_cellularReturnType) { + return switch(m_cellularReturnType) { case CellValue, NoiseLookup, Distance -> SingleCellular(x, y, z); default -> SingleCellular2Edge(x, y, z); }; @@ -1461,11 +1461,11 @@ public class FastNoiseDouble { double distance = 999999; long xc = 0, yc = 0, zc = 0; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { case Euclidean: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { - for (long zi = zr - 1; zi <= zr + 1; zi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { + for(long zi = zr - 1; zi <= zr + 1; zi++) { Double3 vec = CELL_3D[(int) hash3D(m_seed, xi, yi, zi) & 255]; double vecX = xi - x + vec.x; @@ -1474,7 +1474,7 @@ public class FastNoiseDouble { double newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1485,9 +1485,9 @@ public class FastNoiseDouble { } break; case Manhattan: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { - for (long zi = zr - 1; zi <= zr + 1; zi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { + for(long zi = zr - 1; zi <= zr + 1; zi++) { Double3 vec = CELL_3D[(int) hash3D(m_seed, xi, yi, zi) & 255]; double vecX = xi - x + vec.x; @@ -1496,7 +1496,7 @@ public class FastNoiseDouble { double newDistance = Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1507,9 +1507,9 @@ public class FastNoiseDouble { } break; case Natural: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { - for (long zi = zr - 1; zi <= zr + 1; zi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { + for(long zi = zr - 1; zi <= zr + 1; zi++) { Double3 vec = CELL_3D[(int) hash3D(m_seed, xi, yi, zi) & 255]; double vecX = xi - x + vec.x; @@ -1518,7 +1518,7 @@ public class FastNoiseDouble { double newDistance = (Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1530,7 +1530,7 @@ public class FastNoiseDouble { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: return valCoord3D(0, xc, yc, zc); @@ -1553,11 +1553,11 @@ public class FastNoiseDouble { double distance = 999999; double distance2 = 999999; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { case Euclidean: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { - for (long zi = zr - 1; zi <= zr + 1; zi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { + for(long zi = zr - 1; zi <= zr + 1; zi++) { Double3 vec = CELL_3D[(int) hash3D(m_seed, xi, yi, zi) & 255]; double vecX = xi - x + vec.x; @@ -1573,9 +1573,9 @@ public class FastNoiseDouble { } break; case Manhattan: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { - for (long zi = zr - 1; zi <= zr + 1; zi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { + for(long zi = zr - 1; zi <= zr + 1; zi++) { Double3 vec = CELL_3D[(int) hash3D(m_seed, xi, yi, zi) & 255]; double vecX = xi - x + vec.x; @@ -1591,9 +1591,9 @@ public class FastNoiseDouble { } break; case Natural: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { - for (long zi = zr - 1; zi <= zr + 1; zi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { + for(long zi = zr - 1; zi <= zr + 1; zi++) { Double3 vec = CELL_3D[(int) hash3D(m_seed, xi, yi, zi) & 255]; double vecX = xi - x + vec.x; @@ -1612,7 +1612,7 @@ public class FastNoiseDouble { break; } - return switch (m_cellularReturnType) { + return switch(m_cellularReturnType) { case Distance2 -> distance2 - 1; case Distance2Add -> distance2 + distance - 1; case Distance2Sub -> distance2 - distance - 1; @@ -1626,7 +1626,7 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - return switch (m_cellularReturnType) { + return switch(m_cellularReturnType) { case CellValue, NoiseLookup, Distance -> SingleCellular(x, y); default -> SingleCellular2Edge(x, y); }; @@ -1639,11 +1639,11 @@ public class FastNoiseDouble { double distance = 999999; long xc = 0, yc = 0; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { default: case Euclidean: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { Double2 vec = CELL_2D[(int) hash2D(m_seed, xi, yi) & 255]; double vecX = xi - x + vec.x; @@ -1651,7 +1651,7 @@ public class FastNoiseDouble { double newDistance = vecX * vecX + vecY * vecY; - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1660,8 +1660,8 @@ public class FastNoiseDouble { } break; case Manhattan: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { Double2 vec = CELL_2D[(int) hash2D(m_seed, xi, yi) & 255]; double vecX = xi - x + vec.x; @@ -1669,7 +1669,7 @@ public class FastNoiseDouble { double newDistance = (Math.abs(vecX) + Math.abs(vecY)); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1678,8 +1678,8 @@ public class FastNoiseDouble { } break; case Natural: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { Double2 vec = CELL_2D[(int) hash2D(m_seed, xi, yi) & 255]; double vecX = xi - x + vec.x; @@ -1687,7 +1687,7 @@ public class FastNoiseDouble { double newDistance = (Math.abs(vecX) + Math.abs(vecY)) + (vecX * vecX + vecY * vecY); - if (newDistance < distance) { + if(newDistance < distance) { distance = newDistance; xc = xi; yc = yi; @@ -1697,7 +1697,7 @@ public class FastNoiseDouble { break; } - switch (m_cellularReturnType) { + switch(m_cellularReturnType) { case CellValue: return valCoord2D(0, xc, yc); @@ -1719,11 +1719,11 @@ public class FastNoiseDouble { double distance = 999999; double distance2 = 999999; - switch (m_cellularDistanceFunction) { + switch(m_cellularDistanceFunction) { default: case Euclidean: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { Double2 vec = CELL_2D[(int) hash2D(m_seed, xi, yi) & 255]; double vecX = xi - x + vec.x; @@ -1737,8 +1737,8 @@ public class FastNoiseDouble { } break; case Manhattan: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { Double2 vec = CELL_2D[(int) hash2D(m_seed, xi, yi) & 255]; double vecX = xi - x + vec.x; @@ -1752,8 +1752,8 @@ public class FastNoiseDouble { } break; case Natural: - for (long xi = xr - 1; xi <= xr + 1; xi++) { - for (long yi = yr - 1; yi <= yr + 1; yi++) { + for(long xi = xr - 1; xi <= xr + 1; xi++) { + for(long yi = yr - 1; yi <= yr + 1; yi++) { Double2 vec = CELL_2D[(int) hash2D(m_seed, xi, yi) & 255]; double vecX = xi - x + vec.x; @@ -1768,7 +1768,7 @@ public class FastNoiseDouble { break; } - return switch (m_cellularReturnType) { + return switch(m_cellularReturnType) { case Distance2 -> distance2 - 1; case Distance2Add -> distance2 + distance - 1; case Distance2Sub -> distance2 - distance - 1; @@ -1789,7 +1789,7 @@ public class FastNoiseDouble { SingleGradientPerturb(seed, amp, m_frequency, v3); - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { freq *= m_lacunarity; amp *= m_gain; SingleGradientPerturb(++seed, amp, freq, v3); @@ -1809,7 +1809,7 @@ public class FastNoiseDouble { long z1 = z0 + 1; double xs = 0, ys = 0, zs = 0; - switch (m_longerp) { + switch(m_longerp) { case Linear -> { xs = xf - x0; ys = yf - y0; @@ -1875,7 +1875,7 @@ public class FastNoiseDouble { SingleGradientPerturb(seed, amp, m_frequency, v2); - for (long i = 1; i < m_octaves; i++) { + for(long i = 1; i < m_octaves; i++) { freq *= m_lacunarity; amp *= m_gain; SingleGradientPerturb(++seed, amp, freq, v2); @@ -1892,7 +1892,7 @@ public class FastNoiseDouble { long y1 = y0 + 1; double xs = 0, ys = 0; - switch (m_longerp) { + switch(m_longerp) { case Linear -> { xs = xf - x0; ys = yf - y0; diff --git a/src/main/java/com/volmit/iris/util/noise/ImageNoise.java b/src/main/java/com/volmit/iris/util/noise/ImageNoise.java index 4b7603000..66daf8e34 100644 --- a/src/main/java/com/volmit/iris/util/noise/ImageNoise.java +++ b/src/main/java/com/volmit/iris/util/noise/ImageNoise.java @@ -19,9 +19,7 @@ package com.volmit.iris.util.noise; import com.volmit.iris.core.loader.IrisData; -import com.volmit.iris.engine.object.IrisExpression; import com.volmit.iris.engine.object.IrisImageMap; -import com.volmit.iris.util.math.RNG; public class ImageNoise implements NoiseGenerator { private final IrisImageMap expression; @@ -39,7 +37,7 @@ public class ImageNoise implements NoiseGenerator { @Override public double noise(double x, double z) { - return expression.getNoise(data, (int) x, (int)z); + return expression.getNoise(data, (int) x, (int) z); } @Override diff --git a/src/main/java/com/volmit/iris/util/noise/InterpolatedNoise.java b/src/main/java/com/volmit/iris/util/noise/InterpolatedNoise.java index f270ffc70..db9853b57 100644 --- a/src/main/java/com/volmit/iris/util/noise/InterpolatedNoise.java +++ b/src/main/java/com/volmit/iris/util/noise/InterpolatedNoise.java @@ -44,7 +44,7 @@ public class InterpolatedNoise implements NoiseGenerator { @Override public double noise(double x, double y, double z) { - if (z == 0) { + if(z == 0) { return noise(x, y); } diff --git a/src/main/java/com/volmit/iris/util/noise/NoiseGenerator.java b/src/main/java/com/volmit/iris/util/noise/NoiseGenerator.java index 8240771d2..8a5c6b5ec 100644 --- a/src/main/java/com/volmit/iris/util/noise/NoiseGenerator.java +++ b/src/main/java/com/volmit/iris/util/noise/NoiseGenerator.java @@ -36,8 +36,7 @@ public interface NoiseGenerator { return false; } - default ProceduralStream stream() - { + default ProceduralStream stream() { return ProceduralStream.of(this::noise, this::noise, Interpolated.DOUBLE); } } diff --git a/src/main/java/com/volmit/iris/util/noise/PerlinNoise.java b/src/main/java/com/volmit/iris/util/noise/PerlinNoise.java index dfcf03b27..b59bd0523 100644 --- a/src/main/java/com/volmit/iris/util/noise/PerlinNoise.java +++ b/src/main/java/com/volmit/iris/util/noise/PerlinNoise.java @@ -35,7 +35,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise { @Override public double noise(double x) { - if (octaves <= 1) { + if(octaves <= 1) { return f(n.GetPerlin(x, 0)); } @@ -43,7 +43,7 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise { double m = 0; double v = 0; - for (int i = 0; i < octaves; i++) { + for(int i = 0; i < octaves; i++) { v += n.GetPerlin((x * (f == 1 ? f++ : (f *= 2))), 0) * f; m += f; } @@ -53,14 +53,14 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise { @Override public double noise(double x, double z) { - if (octaves <= 1) { + if(octaves <= 1) { return f(n.GetPerlin(x, z)); } double f = 1; double m = 0; double v = 0; - for (int i = 0; i < octaves; i++) { + for(int i = 0; i < octaves; i++) { f = f == 1 ? f + 1 : f * 2; v += n.GetPerlin((x * f), (z * f)) * f; m += f; @@ -71,14 +71,14 @@ public class PerlinNoise implements NoiseGenerator, OctaveNoise { @Override public double noise(double x, double y, double z) { - if (octaves <= 1) { + if(octaves <= 1) { return f(n.GetPerlin(x, y, z)); } double f = 1; double m = 0; double v = 0; - for (int i = 0; i < octaves; i++) { + for(int i = 0; i < octaves; i++) { f = f == 1 ? f + 1 : f * 2; v += n.GetPerlin((x * f), (y * f), (z * f)) * f; m += f; diff --git a/src/main/java/com/volmit/iris/util/noise/RarityCellGenerator.java b/src/main/java/com/volmit/iris/util/noise/RarityCellGenerator.java index 2f5e85a90..77460e3dd 100644 --- a/src/main/java/com/volmit/iris/util/noise/RarityCellGenerator.java +++ b/src/main/java/com/volmit/iris/util/noise/RarityCellGenerator.java @@ -28,28 +28,28 @@ public class RarityCellGenerator extends CellGenerator { } public T get(double x, double z, KList b) { - if (b.size() == 0) { + if(b.size() == 0) { return null; } - if (b.size() == 1) { + if(b.size() == 1) { return b.get(0); } KList rarityMapped = new KList<>(); boolean o = false; int max = 1; - for (T i : b) { - if (i.getRarity() > max) { + for(T i : b) { + if(i.getRarity() > max) { max = i.getRarity(); } } max++; - for (T i : b) { - for (int j = 0; j < max - i.getRarity(); j++) { - if (o = !o) { + for(T i : b) { + for(int j = 0; j < max - i.getRarity(); j++) { + if(o = !o) { rarityMapped.add(i); } else { rarityMapped.add(0, i); @@ -57,11 +57,11 @@ public class RarityCellGenerator extends CellGenerator { } } - if (rarityMapped.size() == 1) { + if(rarityMapped.size() == 1) { return rarityMapped.get(0); } - if (rarityMapped.isEmpty()) { + if(rarityMapped.isEmpty()) { throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly ")); } diff --git a/src/main/java/com/volmit/iris/util/noise/SimplexNoise.java b/src/main/java/com/volmit/iris/util/noise/SimplexNoise.java index a62003fa8..47ede284a 100644 --- a/src/main/java/com/volmit/iris/util/noise/SimplexNoise.java +++ b/src/main/java/com/volmit/iris/util/noise/SimplexNoise.java @@ -35,7 +35,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise { @Override public double noise(double x) { - if (octaves <= 1) { + if(octaves <= 1) { return f(n.GetSimplex(x, 0d)); } @@ -43,7 +43,7 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise { double m = 0; double v = 0; - for (int i = 0; i < octaves; i++) { + for(int i = 0; i < octaves; i++) { v += n.GetSimplex((x * (f == 1 ? f++ : (f *= 2))), 0d) * f; m += f; } @@ -53,14 +53,14 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise { @Override public double noise(double x, double z) { - if (octaves <= 1) { + if(octaves <= 1) { return f(n.GetSimplex(x, z)); } double f = 1; double m = 0; double v = 0; - for (int i = 0; i < octaves; i++) { + for(int i = 0; i < octaves; i++) { f = f == 1 ? f + 1 : f * 2; v += n.GetSimplex((x * f), (z * f)) * f; m += f; @@ -71,14 +71,14 @@ public class SimplexNoise implements NoiseGenerator, OctaveNoise { @Override public double noise(double x, double y, double z) { - if (octaves <= 1) { + if(octaves <= 1) { return f(n.GetSimplex(x, y, z)); } double f = 1; double m = 0; double v = 0; - for (int i = 0; i < octaves; i++) { + for(int i = 0; i < octaves; i++) { f = f == 1 ? f + 1 : f * 2; v += n.GetSimplex((x * f), (y * f), (z * f)) * f; m += f; diff --git a/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java b/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java index 301e00616..e7d15bc4e 100644 --- a/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java +++ b/src/main/java/com/volmit/iris/util/parallel/BurstExecutor.java @@ -42,12 +42,12 @@ public class BurstExecutor { @SuppressWarnings("UnusedReturnValue") public Future queue(Runnable r) { - if (!multicore) { + if(!multicore) { r.run(); return CompletableFuture.completedFuture(null); } - synchronized (futures) { + synchronized(futures) { Future c = executor.submit(r); futures.add(c); @@ -56,16 +56,16 @@ public class BurstExecutor { } public BurstExecutor queue(List r) { - if (!multicore) { - for (Runnable i : new KList<>(r)) { + if(!multicore) { + for(Runnable i : new KList<>(r)) { i.run(); } return this; } - synchronized (futures) { - for (Runnable i : new KList<>(r)) { + synchronized(futures) { + for(Runnable i : new KList<>(r)) { queue(i); } } @@ -74,16 +74,16 @@ public class BurstExecutor { } public BurstExecutor queue(Runnable[] r) { - if (!multicore) { - for (Runnable i : new KList<>(r)) { + if(!multicore) { + for(Runnable i : new KList<>(r)) { i.run(); } return this; } - synchronized (futures) { - for (Runnable i : r) { + synchronized(futures) { + for(Runnable i : r) { queue(i); } } @@ -92,22 +92,22 @@ public class BurstExecutor { } public void complete() { - if (!multicore) { + if(!multicore) { return; } - synchronized (futures) { - if (futures.isEmpty()) { + synchronized(futures) { + if(futures.isEmpty()) { return; } try { - for (Future i : futures) { + for(Future i : futures) { i.get(); } futures.clear(); - } catch (InterruptedException | ExecutionException e) { + } catch(InterruptedException | ExecutionException e) { Iris.reportError(e); } } diff --git a/src/main/java/com/volmit/iris/util/parallel/GridLock.java b/src/main/java/com/volmit/iris/util/parallel/GridLock.java index 12886f205..4f51dfdf3 100644 --- a/src/main/java/com/volmit/iris/util/parallel/GridLock.java +++ b/src/main/java/com/volmit/iris/util/parallel/GridLock.java @@ -82,7 +82,7 @@ public class GridLock { public boolean tryLock(int x, int z, long timeout) { try { return locks.get(x, 0, z).tryLock(timeout, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { + } catch(InterruptedException e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/util/parallel/HyperLock.java b/src/main/java/com/volmit/iris/util/parallel/HyperLock.java index a02bd31e9..e07842489 100644 --- a/src/main/java/com/volmit/iris/util/parallel/HyperLock.java +++ b/src/main/java/com/volmit/iris/util/parallel/HyperLock.java @@ -45,15 +45,15 @@ public class HyperLock { public HyperLock(int capacity, boolean fair) { this.fair = fair; locks = new ConcurrentLinkedHashMap.Builder() - .initialCapacity(capacity) - .maximumWeightedCapacity(capacity) - .listener((k, v) -> { - if (v.isLocked() || v.isHeldByCurrentThread()) { - Iris.warn("InfiniLock Eviction of " + k + " still has locks on it!"); - } - }) - .concurrencyLevel(32) - .build(); + .initialCapacity(capacity) + .maximumWeightedCapacity(capacity) + .listener((k, v) -> { + if(v.isLocked() || v.isHeldByCurrentThread()) { + Iris.warn("InfiniLock Eviction of " + k + " still has locks on it!"); + } + }) + .concurrencyLevel(32) + .build(); } public void with(int x, int z, Runnable r) { @@ -73,12 +73,12 @@ public class HyperLock { Throwable ee = null; try { r.run(); - } catch (Throwable e) { + } catch(Throwable e) { ee = e; } finally { unlock(x, z); - if (ee != null) { + if(ee != null) { throw ee; } } @@ -89,12 +89,12 @@ public class HyperLock { IOException ee = null; try { r.run(); - } catch (IOException e) { + } catch(IOException e) { ee = e; } finally { unlock(x, z); - if (ee != null) { + if(ee != null) { throw ee; } } @@ -114,7 +114,7 @@ public class HyperLock { public boolean tryLock(int x, int z, long timeout) { try { return getLock(x, z).tryLock(timeout, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { + } catch(InterruptedException e) { Iris.reportError(e); } @@ -126,7 +126,7 @@ public class HyperLock { } public void lock(int x, int z) { - if (!enabled) { + if(!enabled) { return; } @@ -134,7 +134,7 @@ public class HyperLock { } public void unlock(int x, int z) { - if (!enabled) { + if(!enabled) { return; } diff --git a/src/main/java/com/volmit/iris/util/parallel/MultiBurst.java b/src/main/java/com/volmit/iris/util/parallel/MultiBurst.java index a834bd717..35c4c6d7e 100644 --- a/src/main/java/com/volmit/iris/util/parallel/MultiBurst.java +++ b/src/main/java/com/volmit/iris/util/parallel/MultiBurst.java @@ -54,20 +54,20 @@ public class MultiBurst { private synchronized ExecutorService getService() { last.set(M.ms()); - if (service == null || service.isShutdown()) { + if(service == null || service.isShutdown()) { service = new ForkJoinPool(IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism()), - new ForkJoinPool.ForkJoinWorkerThreadFactory() { - int m = 0; + new ForkJoinPool.ForkJoinWorkerThreadFactory() { + int m = 0; - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setPriority(priority); - worker.setName(name + " " + ++m); - return worker; - } - }, - (t, e) -> e.printStackTrace(), true); + @Override + public ForkJoinWorkerThread newThread(ForkJoinPool pool) { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setPriority(priority); + worker.setName(name + " " + ++m); + return worker; + } + }, + (t, e) -> e.printStackTrace(), true); } return service; @@ -78,7 +78,7 @@ public class MultiBurst { } public void burst(boolean multicore, Runnable... r) { - if (multicore) { + if(multicore) { burst(r); } else { sync(r); @@ -90,7 +90,7 @@ public class MultiBurst { } public void burst(boolean multicore, List r) { - if (multicore) { + if(multicore) { burst(r); } else { sync(r); @@ -98,19 +98,19 @@ public class MultiBurst { } private void sync(List r) { - for (Runnable i : new KList<>(r)) { + for(Runnable i : new KList<>(r)) { i.run(); } } public void sync(Runnable... r) { - for (Runnable i : r) { + for(Runnable i : r) { i.run(); } } public void sync(KList r) { - for (Runnable i : r) { + for(Runnable i : r) { i.run(); } } @@ -150,25 +150,25 @@ public class MultiBurst { } public void close() { - if (service != null) { + if(service != null) { service.shutdown(); PrecisionStopwatch p = PrecisionStopwatch.start(); try { - while (!service.awaitTermination(1, TimeUnit.SECONDS)) { + while(!service.awaitTermination(1, TimeUnit.SECONDS)) { Iris.info("Still waiting to shutdown burster..."); - if (p.getMilliseconds() > 7000) { + if(p.getMilliseconds() > 7000) { Iris.warn("Forcing Shutdown..."); try { service.shutdownNow(); - } catch (Throwable e) { + } catch(Throwable e) { } break; } } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/util/particle/FastParticle.java b/src/main/java/com/volmit/iris/util/particle/FastParticle.java index bf39a5c0e..315dee25d 100644 --- a/src/main/java/com/volmit/iris/util/particle/FastParticle.java +++ b/src/main/java/com/volmit/iris/util/particle/FastParticle.java @@ -34,9 +34,9 @@ public final class FastParticle { private static final ParticleSender PARTICLE_SENDER; static { - if (FastReflection.optionalClass("org.bukkit.Particle$DustOptions").isPresent()) { + if(FastReflection.optionalClass("org.bukkit.Particle$DustOptions").isPresent()) { PARTICLE_SENDER = new ParticleSender.ParticleSender1_13(); - } else if (FastReflection.optionalClass("org.bukkit.Particle").isPresent()) { + } else if(FastReflection.optionalClass("org.bukkit.Particle").isPresent()) { PARTICLE_SENDER = new ParticleSender.ParticleSenderImpl(); } else { PARTICLE_SENDER = new ParticleSenderLegacy(); @@ -80,7 +80,7 @@ public final class FastParticle { public static void spawnParticle(World world, ParticleType particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) { spawnParticle(world, particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, - offsetZ, data); + offsetZ, data); } public static void spawnParticle(World world, ParticleType particle, double x, double y, double z, int count, @@ -170,7 +170,7 @@ public final class FastParticle { private static void sendParticle(Object receiver, ParticleType particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, Object data) { - if (!particle.isSupported()) { + if(!particle.isSupported()) { throw new IllegalArgumentException("The particle '" + particle + "' is not compatible with your server version"); } diff --git a/src/main/java/com/volmit/iris/util/particle/FastReflection.java b/src/main/java/com/volmit/iris/util/particle/FastReflection.java index 86327de4b..3b7bd4c76 100644 --- a/src/main/java/com/volmit/iris/util/particle/FastReflection.java +++ b/src/main/java/com/volmit/iris/util/particle/FastReflection.java @@ -66,7 +66,7 @@ public final class FastReflection { public static Optional> optionalClass(String className) { try { return Optional.of(Class.forName(className)); - } catch (ClassNotFoundException e) { + } catch(ClassNotFoundException e) { Iris.reportError(e); return Optional.empty(); } diff --git a/src/main/java/com/volmit/iris/util/particle/ParticleSender.java b/src/main/java/com/volmit/iris/util/particle/ParticleSender.java index 70c2a2183..59406740c 100644 --- a/src/main/java/com/volmit/iris/util/particle/ParticleSender.java +++ b/src/main/java/com/volmit/iris/util/particle/ParticleSender.java @@ -51,8 +51,8 @@ interface ParticleSender { public void spawnParticle(Object receiver, ParticleType particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, Object data) { Particle bukkitParticle = Particle.valueOf(particle.toString()); - if (data instanceof Color) { - if (particle.getDataType() == Color.class) { + if(data instanceof Color) { + if(particle.getDataType() == Color.class) { Color color = (Color) data; count = 0; offsetX = color(color.getRed()); @@ -63,9 +63,9 @@ interface ParticleSender { data = null; } - if (receiver instanceof World) { + if(receiver instanceof World) { ((World) receiver).spawnParticle(bukkitParticle, x, y, z, count, offsetX, offsetY, offsetZ, extra, data); - } else if (receiver instanceof Player) { + } else if(receiver instanceof Player) { ((Player) receiver).spawnParticle(bukkitParticle, x, y, z, count, offsetX, offsetY, offsetZ, extra, data); } } @@ -74,7 +74,7 @@ interface ParticleSender { public Particle getParticle(ParticleType particle) { try { return Particle.valueOf(particle.toString()); - } catch (IllegalArgumentException e) { + } catch(IllegalArgumentException e) { Iris.reportError(e); return null; } @@ -95,13 +95,13 @@ interface ParticleSender { public void spawnParticle(Object receiver, ParticleType particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, Object data) { Particle bukkitParticle = Particle.valueOf(particle.toString()); - if (bukkitParticle.getDataType() == Particle.DustOptions.class) { - if (data instanceof Color) { + if(bukkitParticle.getDataType() == Particle.DustOptions.class) { + if(data instanceof Color) { data = new Particle.DustOptions((Color) data, 1); - } else if (data == null) { + } else if(data == null) { data = new Particle.DustOptions(Color.RED, 1); } - } else if (bukkitParticle.getDataType() == BlockData.class && data instanceof MaterialData) { + } else if(bukkitParticle.getDataType() == BlockData.class && data instanceof MaterialData) { data = Bukkit.createBlockData(((MaterialData) data).getItemType()); } @@ -110,11 +110,11 @@ interface ParticleSender { @Override public boolean isValidDataBukkit(Particle particle, Object data) { - if (particle.getDataType() == Particle.DustOptions.class && data instanceof Color) { + if(particle.getDataType() == Particle.DustOptions.class && data instanceof Color) { return true; } - if (particle.getDataType() == BlockData.class && data instanceof MaterialData) { + if(particle.getDataType() == BlockData.class && data instanceof MaterialData) { return true; } diff --git a/src/main/java/com/volmit/iris/util/particle/ParticleSenderLegacy.java b/src/main/java/com/volmit/iris/util/particle/ParticleSenderLegacy.java index de2f0939d..34211e88e 100644 --- a/src/main/java/com/volmit/iris/util/particle/ParticleSenderLegacy.java +++ b/src/main/java/com/volmit/iris/util/particle/ParticleSenderLegacy.java @@ -64,25 +64,25 @@ class ParticleSenderLegacy implements ParticleSender { Class craftPlayerClass = FastReflection.obcClass("entity.CraftPlayer"); Class craftWorldClass = FastReflection.obcClass("CraftWorld"); - if (SERVER_IS_1_8) { + if(SERVER_IS_1_8) { PACKET_PARTICLE = packetParticleClass.getConstructor(ENUM_PARTICLE, boolean.class, float.class, - float.class, float.class, float.class, float.class, float.class, float.class, int.class, - int[].class); + float.class, float.class, float.class, float.class, float.class, float.class, int.class, + int[].class); WORLD_SEND_PARTICLE = worldClass.getDeclaredMethod("sendParticles", entityPlayerClass, ENUM_PARTICLE, - boolean.class, double.class, double.class, double.class, int.class, double.class, double.class, - double.class, double.class, int[].class); + boolean.class, double.class, double.class, double.class, int.class, double.class, double.class, + double.class, double.class, int[].class); } else { PACKET_PARTICLE = packetParticleClass.getConstructor(String.class, float.class, float.class, float.class, - float.class, float.class, float.class, float.class, int.class); + float.class, float.class, float.class, float.class, int.class); WORLD_SEND_PARTICLE = worldClass.getDeclaredMethod("a", String.class, double.class, double.class, - double.class, int.class, double.class, double.class, double.class, double.class); + double.class, int.class, double.class, double.class, double.class, double.class); } WORLD_GET_HANDLE = craftWorldClass.getDeclaredMethod("getHandle"); PLAYER_GET_HANDLE = craftPlayerClass.getDeclaredMethod("getHandle"); PLAYER_CONNECTION = playerClass.getField("playerConnection"); SEND_PACKET = playerConnectionClass.getMethod("sendPacket", FastReflection.nmsClass("Packet")); - } catch (ReflectiveOperationException e) { + } catch(ReflectiveOperationException e) { throw new ExceptionInInitializerError(e); } } @@ -93,8 +93,8 @@ class ParticleSenderLegacy implements ParticleSender { try { int[] datas = toData(particle, data); - if (data instanceof Color) { - if (particle.getDataType() == Color.class) { + if(data instanceof Color) { + if(particle.getDataType() == Color.class) { Color color = (Color) data; count = 0; offsetX = color(color.getRed()); @@ -104,32 +104,32 @@ class ParticleSenderLegacy implements ParticleSender { } } - if (receiver instanceof World) { + if(receiver instanceof World) { Object worldServer = WORLD_GET_HANDLE.invoke(receiver); - if (SERVER_IS_1_8) { + if(SERVER_IS_1_8) { WORLD_SEND_PARTICLE.invoke(worldServer, null, getEnumParticle(particle), true, x, y, z, count, offsetX, offsetY, offsetZ, extra, datas); } else { String particleName = particle.getLegacyName() + (datas.length != 2 ? "" : "_" + datas[0] + "_" + datas[1]); WORLD_SEND_PARTICLE.invoke(worldServer, particleName, x, y, z, count, offsetX, offsetY, offsetZ, extra); } - } else if (receiver instanceof Player) { + } else if(receiver instanceof Player) { Object packet; - if (SERVER_IS_1_8) { + if(SERVER_IS_1_8) { packet = PACKET_PARTICLE.newInstance(getEnumParticle(particle), true, (float) x, (float) y, - (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count, datas); + (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count, datas); } else { String particleName = particle.getLegacyName() + (datas.length != 2 ? "" : "_" + datas[0] + "_" + datas[1]); packet = PACKET_PARTICLE.newInstance(particleName, (float) x, (float) y, (float) z, - (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); + (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); } Object entityPlayer = PLAYER_GET_HANDLE.invoke(receiver); Object playerConnection = PLAYER_CONNECTION.get(entityPlayer); SEND_PACKET.invoke(playerConnection, packet); } - } catch (ReflectiveOperationException e) { + } catch(ReflectiveOperationException e) { Iris.reportError(e); throw new RuntimeException(e); } @@ -142,13 +142,13 @@ class ParticleSenderLegacy implements ParticleSender { @Override public Object getParticle(ParticleType particle) { - if (!SERVER_IS_1_8) { + if(!SERVER_IS_1_8) { return particle.getLegacyName(); } try { return getEnumParticle(particle); - } catch (IllegalArgumentException e) { + } catch(IllegalArgumentException e) { Iris.reportError(e); return null; } @@ -160,23 +160,23 @@ class ParticleSenderLegacy implements ParticleSender { private int[] toData(ParticleType particle, Object data) { Class dataType = particle.getDataType(); - if (dataType == ItemStack.class) { - if (!(data instanceof ItemStack itemStack)) { - return SERVER_IS_1_8 ? new int[2] : new int[]{1, 0}; + if(dataType == ItemStack.class) { + if(!(data instanceof ItemStack itemStack)) { + return SERVER_IS_1_8 ? new int[2] : new int[] {1, 0}; } - return new int[]{itemStack.getType().getId(), itemStack.getDurability()}; + return new int[] {itemStack.getType().getId(), itemStack.getDurability()}; } - if (dataType == MaterialData.class) { - if (!(data instanceof MaterialData materialData)) { - return SERVER_IS_1_8 ? new int[1] : new int[]{1, 0}; + if(dataType == MaterialData.class) { + if(!(data instanceof MaterialData materialData)) { + return SERVER_IS_1_8 ? new int[1] : new int[] {1, 0}; } - if (SERVER_IS_1_8) { - return new int[]{materialData.getItemType().getId() + (materialData.getData() << 12)}; + if(SERVER_IS_1_8) { + return new int[] {materialData.getItemType().getId() + (materialData.getData() << 12)}; } else { - return new int[]{materialData.getItemType().getId(), materialData.getData()}; + return new int[] {materialData.getItemType().getId(), materialData.getData()}; } } diff --git a/src/main/java/com/volmit/iris/util/particle/ParticleType.java b/src/main/java/com/volmit/iris/util/particle/ParticleType.java index 6d60040a7..7b6813279 100644 --- a/src/main/java/com/volmit/iris/util/particle/ParticleType.java +++ b/src/main/java/com/volmit/iris/util/particle/ParticleType.java @@ -145,14 +145,14 @@ public enum ParticleType { public static ParticleType getParticle(String particleName) { try { return ParticleType.valueOf(particleName.toUpperCase()); - } catch (IllegalArgumentException e) { + } catch(IllegalArgumentException e) { Iris.reportError(e); - for (ParticleType particle : values()) { - if (particle.getName().equalsIgnoreCase(particleName)) { + for(ParticleType particle : values()) { + if(particle.getName().equalsIgnoreCase(particleName)) { return particle; } - if (particle.hasLegacyName() && particle.getLegacyName().equalsIgnoreCase(particleName)) { + if(particle.hasLegacyName() && particle.getLegacyName().equalsIgnoreCase(particleName)) { return particle; } } @@ -165,7 +165,7 @@ public enum ParticleType { } public String getLegacyName() { - if (!hasLegacyName()) { + if(!hasLegacyName()) { throw new IllegalStateException("Particle " + name() + " don't have legacy name"); } return legacyName; @@ -180,11 +180,11 @@ public enum ParticleType { } public Class getDataType() { - return switch (this) { + return switch(this) { case ITEM_CRACK -> ItemStack.class; case BLOCK_CRACK, BLOCK_DUST, FALLING_DUST -> - //noinspection deprecation - MaterialData.class; + //noinspection deprecation + MaterialData.class; case REDSTONE -> Color.class; default -> Void.class; }; diff --git a/src/main/java/com/volmit/iris/util/plugin/Chunks.java b/src/main/java/com/volmit/iris/util/plugin/Chunks.java index 60e26c0c6..e1efdbe15 100644 --- a/src/main/java/com/volmit/iris/util/plugin/Chunks.java +++ b/src/main/java/com/volmit/iris/util/plugin/Chunks.java @@ -25,14 +25,14 @@ import org.bukkit.entity.Player; public class Chunks { public static boolean isSafe(World w, int x, int z) { return w.isChunkLoaded(x, z) - && w.isChunkLoaded(x + 1, z) - && w.isChunkLoaded(x, z + 1) - && w.isChunkLoaded(x - 1, z) - && w.isChunkLoaded(x, z - 1) - && w.isChunkLoaded(x - 1, z - 1) - && w.isChunkLoaded(x + 1, z + 1) - && w.isChunkLoaded(x + 1, z - 1) - && w.isChunkLoaded(x - 1, z + 1); + && w.isChunkLoaded(x + 1, z) + && w.isChunkLoaded(x, z + 1) + && w.isChunkLoaded(x - 1, z) + && w.isChunkLoaded(x, z - 1) + && w.isChunkLoaded(x - 1, z - 1) + && w.isChunkLoaded(x + 1, z + 1) + && w.isChunkLoaded(x + 1, z - 1) + && w.isChunkLoaded(x - 1, z + 1); } public static boolean isSafe(Location l) { @@ -42,7 +42,7 @@ public class Chunks { public static boolean hasPlayersNearby(Location at) { try { return !at.getWorld().getNearbyEntities(at, 32, 32, 32, (i) -> i instanceof Player).isEmpty(); - } catch (Throwable ignored) { + } catch(Throwable ignored) { return false; } } diff --git a/src/main/java/com/volmit/iris/util/plugin/ICommand.java b/src/main/java/com/volmit/iris/util/plugin/ICommand.java index 988292568..decd13c06 100644 --- a/src/main/java/com/volmit/iris/util/plugin/ICommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/ICommand.java @@ -52,7 +52,8 @@ public interface ICommand { /** * Add a node to this command * - * @param node the node + * @param node + * the node */ void addNode(String node); @@ -60,8 +61,10 @@ public interface ICommand { * Handle a command. If this is a subcommand, parameters after the subcommand * will be adapted in args for you * - * @param sender the volume sender (pre-tagged) - * @param args the arguments after this command node + * @param sender + * the volume sender (pre-tagged) + * @param args + * the arguments after this command node * @return return true to mark it as handled */ boolean handle(VolmitSender sender, String[] args); diff --git a/src/main/java/com/volmit/iris/util/plugin/Metrics.java b/src/main/java/com/volmit/iris/util/plugin/Metrics.java index f2d6eabe3..9e5ce962c 100644 --- a/src/main/java/com/volmit/iris/util/plugin/Metrics.java +++ b/src/main/java/com/volmit/iris/util/plugin/Metrics.java @@ -75,13 +75,13 @@ public class Metrics { static { // You can use the property to disable the check in your test environment - if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) { + if(System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) { // Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D final String defaultPackage = new String( - new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); - final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); + new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); + final String examplePackage = new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); // We want to make sure nobody just copy & pastes the example and use the wrong package names - if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { + if(Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); } } @@ -101,12 +101,14 @@ public class Metrics { /** * Class constructor. * - * @param plugin The plugin which stats should be submitted. - * @param pluginId The id of the plugin. - * It can be found at What is my plugin id? + * @param plugin + * The plugin which stats should be submitted. + * @param pluginId + * The id of the plugin. + * It can be found at What is my plugin id? */ public Metrics(Plugin plugin, int pluginId) { - if (plugin == null) { + if(plugin == null) { throw new IllegalArgumentException("Plugin cannot be null!"); } this.plugin = plugin; @@ -118,7 +120,7 @@ public class Metrics { YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); // Check if the config file exists - if (!config.isSet("serverUuid")) { + if(!config.isSet("serverUuid")) { // Add default values config.addDefault("enabled", true); @@ -133,15 +135,15 @@ public class Metrics { // Inform the server owners about bStats config.options().header( - """ - bStats collects some data for plugin authors like how many servers are using their plugins. - To honor their work, you should not disable it. - This has nearly no effect on the server performance! - Check out https://bStats.org/ to learn more :)""" + """ + bStats collects some data for plugin authors like how many servers are using their plugins. + To honor their work, you should not disable it. + This has nearly no effect on the server performance! + Check out https://bStats.org/ to learn more :)""" ).copyDefaults(true); try { config.save(configFile); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } } @@ -153,21 +155,21 @@ public class Metrics { logSentData = config.getBoolean("logSentData", false); logResponseStatusText = config.getBoolean("logResponseStatusText", false); - if (enabled) { + if(enabled) { boolean found = false; // Search for all other bStats Metrics classes to see if we are the first one - for (Class service : Bukkit.getServicesManager().getKnownServices()) { + for(Class service : Bukkit.getServicesManager().getKnownServices()) { try { service.getField("B_STATS_VERSION"); // Our identifier :) found = true; // We aren't the first break; - } catch (NoSuchFieldException e) { + } catch(NoSuchFieldException e) { Iris.reportError(e); } } // Register our service Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal); - if (!found) { + if(!found) { // We are the first! startSubmitting(); } @@ -177,18 +179,21 @@ public class Metrics { /** * Sends the data to the bStats server. * - * @param plugin Any plugin. It's just used to get a logger instance. - * @param data The data to send. - * @throws Exception If the request failed. + * @param plugin + * Any plugin. It's just used to get a logger instance. + * @param data + * The data to send. + * @throws Exception + * If the request failed. */ private static void sendData(Plugin plugin, JsonObject data) throws Exception { - if (data == null) { + if(data == null) { throw new IllegalArgumentException("Data cannot be null!"); } - if (Bukkit.isPrimaryThread()) { + if(Bukkit.isPrimaryThread()) { throw new IllegalAccessException("This method must not be called from the main thread!"); } - if (logSentData) { + if(logSentData) { plugin.getLogger().info("Sending data to bStats: " + data); } HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection(); @@ -207,19 +212,19 @@ public class Metrics { // Send data connection.setDoOutput(true); - try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { + try(DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { outputStream.write(compressedData); } StringBuilder builder = new StringBuilder(); - try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { String line; - while ((line = bufferedReader.readLine()) != null) { + while((line = bufferedReader.readLine()) != null) { builder.append(line); } } - if (logResponseStatusText) { + if(logResponseStatusText) { plugin.getLogger().info("Sent data to bStats and received response: " + builder); } } @@ -227,16 +232,18 @@ public class Metrics { /** * Gzips the given String. * - * @param str The string to gzip. + * @param str + * The string to gzip. * @return The gzipped String. - * @throws IOException If the compression failed. + * @throws IOException + * If the compression failed. */ private static byte[] compress(final String str) throws IOException { - if (str == null) { + if(str == null) { return null; } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { + try(GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { gzip.write(str.getBytes(StandardCharsets.UTF_8)); } return outputStream.toByteArray(); @@ -254,10 +261,11 @@ public class Metrics { /** * Adds a custom chart. * - * @param chart The chart to add. + * @param chart + * The chart to add. */ public void addCustomChart(CustomChart chart) { - if (chart == null) { + if(chart == null) { throw new IllegalArgumentException("Chart cannot be null!"); } charts.add(chart); @@ -271,7 +279,7 @@ public class Metrics { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { - if (!plugin.isEnabled()) { // Plugin was disabled + if(!plugin.isEnabled()) { // Plugin was disabled timer.cancel(); return; } @@ -301,10 +309,10 @@ public class Metrics { data.addProperty("id", pluginId); // Append the id of the plugin data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin JsonArray customCharts = new JsonArray(); - for (CustomChart customChart : charts) { + for(CustomChart customChart : charts) { // Add the data of the custom charts JsonObject chart = customChart.getRequestJsonObject(); - if (chart == null) { // If the chart is null, we skip it + if(chart == null) { // If the chart is null, we skip it continue; } customCharts.add(chart); @@ -327,9 +335,9 @@ public class Metrics { // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) - ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() - : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; - } catch (Exception e) { + ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() + : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; + } catch(Exception e) { Iris.reportError(e); playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed } @@ -370,39 +378,39 @@ public class Metrics { JsonArray pluginData = new JsonArray(); // Search for all other bStats Metrics classes to get their plugin data - for (Class service : Bukkit.getServicesManager().getKnownServices()) { + for(Class service : Bukkit.getServicesManager().getKnownServices()) { try { service.getField("B_STATS_VERSION"); // Our identifier :) - for (RegisteredServiceProvider provider : Bukkit.getServicesManager().getRegistrations(service)) { + for(RegisteredServiceProvider provider : Bukkit.getServicesManager().getRegistrations(service)) { try { Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider()); - if (plugin instanceof JsonObject) { + if(plugin instanceof JsonObject) { pluginData.add((JsonObject) plugin); } else { // old bstats version compatibility try { Class jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject"); - if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) { + if(plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) { Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString"); jsonStringGetter.setAccessible(true); String jsonString = (String) jsonStringGetter.invoke(plugin); JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject(); pluginData.add(object); } - } catch (ClassNotFoundException e) { + } catch(ClassNotFoundException e) { Iris.reportError(e); // minecraft version 1.14+ - if (logFailedRequests) { + if(logFailedRequests) { this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e); } } } - } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { + } catch(NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { Iris.reportError(ignored); } } - } catch (NoSuchFieldException e) { + } catch(NoSuchFieldException e) { Iris.reportError(e); } } @@ -414,10 +422,10 @@ public class Metrics { try { // Send the data sendData(plugin, data); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); // Something went wrong! :( - if (logFailedRequests) { + if(logFailedRequests) { plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); } } @@ -435,10 +443,11 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. + * @param chartId + * The id of the chart. */ CustomChart(String chartId) { - if (chartId == null || chartId.isEmpty()) { + if(chartId == null || chartId.isEmpty()) { throw new IllegalArgumentException("ChartId cannot be null or empty!"); } this.chartId = chartId; @@ -449,14 +458,14 @@ public class Metrics { chart.addProperty("chartId", chartId); try { JsonObject data = getChartData(); - if (data == null) { + if(data == null) { // If the data is null we don't send the chart. return null; } chart.add("data", data); - } catch (Throwable t) { + } catch(Throwable t) { Iris.reportError(t); - if (logFailedRequests) { + if(logFailedRequests) { Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t); } return null; @@ -478,8 +487,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public SimplePie(String chartId, Callable callable) { super(chartId); @@ -490,7 +501,7 @@ public class Metrics { protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); String value = callable.call(); - if (value == null || value.isEmpty()) { + if(value == null || value.isEmpty()) { // Null = skip the chart return null; } @@ -509,8 +520,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public AdvancedPie(String chartId, Callable> callable) { super(chartId); @@ -522,19 +535,19 @@ public class Metrics { JsonObject data = new JsonObject(); JsonObject values = new JsonObject(); Map map = callable.call(); - if (map == null || map.isEmpty()) { + if(map == null || map.isEmpty()) { // Null = skip the chart return null; } boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == 0) { + for(Map.Entry entry : map.entrySet()) { + if(entry.getValue() == 0) { continue; // Skip this invalid } allSkipped = false; values.addProperty(entry.getKey(), entry.getValue()); } - if (allSkipped) { + if(allSkipped) { // Null = skip the chart return null; } @@ -553,8 +566,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public DrilldownPie(String chartId, Callable>> callable) { super(chartId); @@ -566,24 +581,24 @@ public class Metrics { JsonObject data = new JsonObject(); JsonObject values = new JsonObject(); Map> map = callable.call(); - if (map == null || map.isEmpty()) { + if(map == null || map.isEmpty()) { // Null = skip the chart return null; } boolean reallyAllSkipped = true; - for (Map.Entry> entryValues : map.entrySet()) { + for(Map.Entry> entryValues : map.entrySet()) { JsonObject value = new JsonObject(); boolean allSkipped = true; - for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { + for(Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { value.addProperty(valueEntry.getKey(), valueEntry.getValue()); allSkipped = false; } - if (!allSkipped) { + if(!allSkipped) { reallyAllSkipped = false; values.add(entryValues.getKey(), value); } } - if (reallyAllSkipped) { + if(reallyAllSkipped) { // Null = skip the chart return null; } @@ -602,8 +617,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public SingleLineChart(String chartId, Callable callable) { super(chartId); @@ -614,7 +631,7 @@ public class Metrics { protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); int value = callable.call(); - if (value == 0) { + if(value == 0) { // Null = skip the chart return null; } @@ -634,8 +651,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public MultiLineChart(String chartId, Callable> callable) { super(chartId); @@ -647,19 +666,19 @@ public class Metrics { JsonObject data = new JsonObject(); JsonObject values = new JsonObject(); Map map = callable.call(); - if (map == null || map.isEmpty()) { + if(map == null || map.isEmpty()) { // Null = skip the chart return null; } boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == 0) { + for(Map.Entry entry : map.entrySet()) { + if(entry.getValue() == 0) { continue; // Skip this invalid } allSkipped = false; values.addProperty(entry.getKey(), entry.getValue()); } - if (allSkipped) { + if(allSkipped) { // Null = skip the chart return null; } @@ -679,8 +698,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public SimpleBarChart(String chartId, Callable> callable) { super(chartId); @@ -692,11 +713,11 @@ public class Metrics { JsonObject data = new JsonObject(); JsonObject values = new JsonObject(); Map map = callable.call(); - if (map == null || map.isEmpty()) { + if(map == null || map.isEmpty()) { // Null = skip the chart return null; } - for (Map.Entry entry : map.entrySet()) { + for(Map.Entry entry : map.entrySet()) { JsonArray categoryValues = new JsonArray(); categoryValues.add(new JsonPrimitive(entry.getValue())); values.add(entry.getKey(), categoryValues); @@ -717,8 +738,10 @@ public class Metrics { /** * Class constructor. * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. */ public AdvancedBarChart(String chartId, Callable> callable) { super(chartId); @@ -730,23 +753,23 @@ public class Metrics { JsonObject data = new JsonObject(); JsonObject values = new JsonObject(); Map map = callable.call(); - if (map == null || map.isEmpty()) { + if(map == null || map.isEmpty()) { // Null = skip the chart return null; } boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue().length == 0) { + for(Map.Entry entry : map.entrySet()) { + if(entry.getValue().length == 0) { continue; // Skip this invalid } allSkipped = false; JsonArray categoryValues = new JsonArray(); - for (int categoryValue : entry.getValue()) { + for(int categoryValue : entry.getValue()) { categoryValues.add(new JsonPrimitive(categoryValue)); } values.add(entry.getKey(), categoryValues); } - if (allSkipped) { + if(allSkipped) { // Null = skip the chart return null; } diff --git a/src/main/java/com/volmit/iris/util/plugin/MetricsLite.java b/src/main/java/com/volmit/iris/util/plugin/MetricsLite.java index cc85a1cb9..83203a368 100644 --- a/src/main/java/com/volmit/iris/util/plugin/MetricsLite.java +++ b/src/main/java/com/volmit/iris/util/plugin/MetricsLite.java @@ -69,14 +69,14 @@ public class MetricsLite { static { // You can use the property to disable the check in your test environment - if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) { + if(System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) { // Maven's Relocate is clever and changes strings, too. So we have to use this // little "trick" ... :D - final String defaultPackage = new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); - final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); + final String defaultPackage = new String(new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); + final String examplePackage = new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); // We want to make sure nobody just copy & pastes the example and use the wrong // package names - if (MetricsLite.class.getPackage().getName().equals(defaultPackage) || MetricsLite.class.getPackage().getName().equals(examplePackage)) { + if(MetricsLite.class.getPackage().getName().equals(defaultPackage) || MetricsLite.class.getPackage().getName().equals(examplePackage)) { throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); } } @@ -93,13 +93,15 @@ public class MetricsLite { /** * Class constructor. * - * @param plugin The plugin which stats should be submitted. - * @param pluginId The id of the plugin. It can be found at - * What is my - * plugin id? + * @param plugin + * The plugin which stats should be submitted. + * @param pluginId + * The id of the plugin. It can be found at + * What is my + * plugin id? */ public MetricsLite(Plugin plugin, int pluginId) { - if (plugin == null) { + if(plugin == null) { throw new IllegalArgumentException("Plugin cannot be null!"); } this.plugin = plugin; @@ -111,7 +113,7 @@ public class MetricsLite { YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); // Check if the config file exists - if (!config.isSet("serverUuid")) { + if(!config.isSet("serverUuid")) { // Add default values config.addDefault("enabled", true); @@ -126,13 +128,13 @@ public class MetricsLite { // Inform the server owners about bStats config.options().header(""" - bStats collects some data for plugin authors like how many servers are using their plugins. - To honor their work, you should not disable it. - This has nearly no effect on the server performance! - Check out https://bStats.org/ to learn more :)""").copyDefaults(true); + bStats collects some data for plugin authors like how many servers are using their plugins. + To honor their work, you should not disable it. + This has nearly no effect on the server performance! + Check out https://bStats.org/ to learn more :)""").copyDefaults(true); try { config.save(configFile); - } catch (IOException e) { + } catch(IOException e) { Iris.reportError(e); } } @@ -143,21 +145,21 @@ public class MetricsLite { enabled = config.getBoolean("enabled", true); logSentData = config.getBoolean("logSentData", false); logResponseStatusText = config.getBoolean("logResponseStatusText", false); - if (enabled) { + if(enabled) { boolean found = false; // Search for all other bStats Metrics classes to see if we are the first one - for (Class service : Bukkit.getServicesManager().getKnownServices()) { + for(Class service : Bukkit.getServicesManager().getKnownServices()) { try { service.getField("B_STATS_VERSION"); // Our identifier :) found = true; // We aren't the first break; - } catch (NoSuchFieldException e) { + } catch(NoSuchFieldException e) { Iris.reportError(e); } } // Register our service Bukkit.getServicesManager().register(MetricsLite.class, this, plugin, ServicePriority.Normal); - if (!found) { + if(!found) { // We are the first! startSubmitting(); } @@ -167,18 +169,21 @@ public class MetricsLite { /** * Sends the data to the bStats server. * - * @param plugin Any plugin. It's just used to get a logger instance. - * @param data The data to send. - * @throws Exception If the request failed. + * @param plugin + * Any plugin. It's just used to get a logger instance. + * @param data + * The data to send. + * @throws Exception + * If the request failed. */ private static void sendData(Plugin plugin, JsonObject data) throws Exception { - if (data == null) { + if(data == null) { throw new IllegalArgumentException("Data cannot be null!"); } - if (Bukkit.isPrimaryThread()) { + if(Bukkit.isPrimaryThread()) { throw new IllegalAccessException("This method must not be called from the main thread!"); } - if (logSentData) { + if(logSentData) { plugin.getLogger().info("Sending data to bStats: " + data); } HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection(); @@ -197,19 +202,19 @@ public class MetricsLite { // Send data connection.setDoOutput(true); - try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { + try(DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { outputStream.write(compressedData); } StringBuilder builder = new StringBuilder(); - try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { String line; - while ((line = bufferedReader.readLine()) != null) { + while((line = bufferedReader.readLine()) != null) { builder.append(line); } } - if (logResponseStatusText) { + if(logResponseStatusText) { plugin.getLogger().info("Sent data to bStats and received response: " + builder); } } @@ -217,16 +222,18 @@ public class MetricsLite { /** * Gzips the given String. * - * @param str The string to gzip. + * @param str + * The string to gzip. * @return The gzipped String. - * @throws IOException If the compression failed. + * @throws IOException + * If the compression failed. */ private static byte[] compress(final String str) throws IOException { - if (str == null) { + if(str == null) { return null; } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { + try(GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { gzip.write(str.getBytes(StandardCharsets.UTF_8)); } return outputStream.toByteArray(); @@ -249,7 +256,7 @@ public class MetricsLite { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { - if (!plugin.isEnabled()) { // Plugin was disabled + if(!plugin.isEnabled()) { // Plugin was disabled timer.cancel(); return; } @@ -300,7 +307,7 @@ public class MetricsLite { // org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed } @@ -341,38 +348,38 @@ public class MetricsLite { JsonArray pluginData = new JsonArray(); // Search for all other bStats Metrics classes to get their plugin data - for (Class service : Bukkit.getServicesManager().getKnownServices()) { + for(Class service : Bukkit.getServicesManager().getKnownServices()) { try { service.getField("B_STATS_VERSION"); // Our identifier :) - for (RegisteredServiceProvider provider : Bukkit.getServicesManager().getRegistrations(service)) { + for(RegisteredServiceProvider provider : Bukkit.getServicesManager().getRegistrations(service)) { try { Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider()); - if (plugin instanceof JsonObject) { + if(plugin instanceof JsonObject) { pluginData.add((JsonObject) plugin); } else { // old bstats version compatibility try { Class jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject"); - if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) { + if(plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) { Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString"); jsonStringGetter.setAccessible(true); String jsonString = (String) jsonStringGetter.invoke(plugin); JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject(); pluginData.add(object); } - } catch (ClassNotFoundException e) { + } catch(ClassNotFoundException e) { Iris.reportError(e); // minecraft version 1.14+ - if (logFailedRequests) { + if(logFailedRequests) { this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception ", e); } } } - } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { + } catch(NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { Iris.reportError(ignored); } } - } catch (NoSuchFieldException e) { + } catch(NoSuchFieldException e) { Iris.reportError(e); } } @@ -385,10 +392,10 @@ public class MetricsLite { try { // Send the data sendData(plugin, data); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); // Something went wrong! :( - if (logFailedRequests) { + if(logFailedRequests) { plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); } } diff --git a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java index f941eb9a7..a16689c4f 100644 --- a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java @@ -45,8 +45,10 @@ public abstract class MortarCommand implements ICommand { * Override this with a super constructor as most commands shouldn't change * these parameters * - * @param node the node (primary node) i.e. volume - * @param nodes the aliases. i.e. v, vol, bile + * @param node + * the node (primary node) i.e. volume + * @param nodes + * the aliases. i.e. v, vol, bile */ public MortarCommand(String node, String... nodes) { category = ""; @@ -60,19 +62,19 @@ public abstract class MortarCommand implements ICommand { @Override public KList handleTab(VolmitSender sender, String[] args) { KList v = new KList<>(); - if (args.length == 0) { - for (MortarCommand i : getChildren()) { + if(args.length == 0) { + for(MortarCommand i : getChildren()) { v.add(i.getNode()); } } addTabOptions(sender, args, v); - if (v.isEmpty()) { + if(v.isEmpty()) { return null; } - if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { + if(sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f); } @@ -84,9 +86,9 @@ public abstract class MortarCommand implements ICommand { public void printHelp(VolmitSender sender) { boolean b = false; - for (MortarCommand i : getChildren()) { - for (String j : i.getRequiredPermissions()) { - if (!sender.hasPermission(j)) { + for(MortarCommand i : getChildren()) { + for(String j : i.getRequiredPermissions()) { + if(!sender.hasPermission(j)) { } } @@ -95,11 +97,11 @@ public abstract class MortarCommand implements ICommand { sender.sendMessage("" + C.GREEN + i.getNode() + " " + "" + (getArgsUsage().trim().isEmpty() ? "" : (C.WHITE + i.getArgsUsage())) + C.GRAY + " - " + i.getDescription()); } - if (!b) { + if(!b) { sender.sendMessage("There are either no sub-commands or you do not have permission to use them."); } - if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { + if(sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { sender.playSound(Sound.ITEM_BOOK_PAGE_TURN, 0.28f, 1.4f); sender.playSound(Sound.ITEM_AXE_STRIP, 0.35f, 1.7f); } @@ -116,7 +118,7 @@ public abstract class MortarCommand implements ICommand { } protected void requiresPermission(MortarPermission node) { - if (node == null) { + if(node == null) { return; } @@ -124,7 +126,7 @@ public abstract class MortarCommand implements ICommand { } protected void requiresPermission(String node) { - if (node == null) { + if(node == null) { return; } @@ -132,19 +134,19 @@ public abstract class MortarCommand implements ICommand { } public void rejectAny(int past, VolmitSender sender, String[] a) { - if (a.length > past) { + if(a.length > past) { int p = past; StringBuilder m = new StringBuilder(); - for (String i : a) { + for(String i : a) { p--; - if (p < 0) { + if(p < 0) { m.append(i).append(", "); } } - if (!m.toString().trim().isEmpty()) { + if(!m.toString().trim().isEmpty()) { sender.sendMessage("Parameters Ignored: " + m); } } @@ -177,21 +179,21 @@ public abstract class MortarCommand implements ICommand { private KList buildChildren() { KList p = new KList<>(); - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Command.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Command.class)) { try { i.setAccessible(true); MortarCommand pc = (MortarCommand) i.getType().getConstructor().newInstance(); Command c = i.getAnnotation(Command.class); - if (!c.value().trim().isEmpty()) { + if(!c.value().trim().isEmpty()) { pc.setCategory(c.value().trim()); } else { pc.setCategory(getCategory()); } p.add(pc); - } catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/plugin/MortarPermission.java b/src/main/java/com/volmit/iris/util/plugin/MortarPermission.java index 1ed6b2f7f..b50fccc2c 100644 --- a/src/main/java/com/volmit/iris/util/plugin/MortarPermission.java +++ b/src/main/java/com/volmit/iris/util/plugin/MortarPermission.java @@ -30,13 +30,13 @@ public abstract class MortarPermission { private MortarPermission parent; public MortarPermission() { - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Permission.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Permission.class)) { try { MortarPermission px = (MortarPermission) i.getType().getConstructor().newInstance(); px.setParent(this); i.set(Modifier.isStatic(i.getModifiers()) ? null : this, px); - } catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); Iris.reportError(e); } @@ -47,11 +47,11 @@ public abstract class MortarPermission { public KList getChildren() { KList p = new KList<>(); - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Permission.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Permission.class)) { try { p.add((MortarPermission) i.get(Modifier.isStatic(i.getModifiers()) ? null : this)); - } catch (IllegalArgumentException | IllegalAccessException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | SecurityException e) { e.printStackTrace(); Iris.reportError(e); } @@ -62,7 +62,7 @@ public abstract class MortarPermission { } public String getFullNode() { - if (hasParent()) { + if(hasParent()) { return getParent().getFullNode() + "." + getNode(); } diff --git a/src/main/java/com/volmit/iris/util/plugin/PluginRegistry.java b/src/main/java/com/volmit/iris/util/plugin/PluginRegistry.java index d9a15ec2b..54d6ee57e 100644 --- a/src/main/java/com/volmit/iris/util/plugin/PluginRegistry.java +++ b/src/main/java/com/volmit/iris/util/plugin/PluginRegistry.java @@ -38,7 +38,7 @@ public class PluginRegistry { } public T get(String s) { - if (!registry.containsKey(s)) { + if(!registry.containsKey(s)) { return null; } @@ -54,7 +54,7 @@ public class PluginRegistry { } public T resolve(String id) { - if (registry.isEmpty()) { + if(registry.isEmpty()) { return null; } diff --git a/src/main/java/com/volmit/iris/util/plugin/PluginRegistryGroup.java b/src/main/java/com/volmit/iris/util/plugin/PluginRegistryGroup.java index ba65a26e3..e9afcec57 100644 --- a/src/main/java/com/volmit/iris/util/plugin/PluginRegistryGroup.java +++ b/src/main/java/com/volmit/iris/util/plugin/PluginRegistryGroup.java @@ -25,12 +25,12 @@ public class PluginRegistryGroup { private final KMap> registries = new KMap<>(); public T resolve(String namespace, String id) { - if (registries.isEmpty()) { + if(registries.isEmpty()) { return null; } PluginRegistry r = registries.get(namespace); - if (r == null) { + if(r == null) { return null; } @@ -52,8 +52,8 @@ public class PluginRegistryGroup { public KList compile() { KList l = new KList<>(); registries.values().forEach((i) - -> i.getRegistries().forEach((j) - -> l.add(i.getNamespace() + ":" + j))); + -> i.getRegistries().forEach((j) + -> l.add(i.getNamespace() + ":" + j))); return l; } } diff --git a/src/main/java/com/volmit/iris/util/plugin/RouterCommand.java b/src/main/java/com/volmit/iris/util/plugin/RouterCommand.java index f1c25c1ff..28cb108c8 100644 --- a/src/main/java/com/volmit/iris/util/plugin/RouterCommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/RouterCommand.java @@ -34,8 +34,10 @@ public class RouterCommand extends org.bukkit.command.Command { /** * The router command routes commands to bukkit executors * - * @param realCommand the real command - * @param ex the executor + * @param realCommand + * the real command + * @param ex + * the executor */ public RouterCommand(ICommand realCommand, CommandExecutor ex) { super(realCommand.getNode().toLowerCase()); diff --git a/src/main/java/com/volmit/iris/util/plugin/VirtualCommand.java b/src/main/java/com/volmit/iris/util/plugin/VirtualCommand.java index ac70b185e..141062b64 100644 --- a/src/main/java/com/volmit/iris/util/plugin/VirtualCommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/VirtualCommand.java @@ -51,14 +51,14 @@ public class VirtualCommand { children = new KMap<>(); this.tag = tag; - for (Field i : command.getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Command.class)) { + for(Field i : command.getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Command.class)) { try { Command cc = i.getAnnotation(Command.class); ICommand cmd = (ICommand) i.getType().getConstructor().newInstance(); new V(command, true, true).set(i.getName(), cmd); children.put(cmd.getAllNodes(), new VirtualCommand(cmd, cc.value().trim().isEmpty() ? tag : cc.value().trim())); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); e.printStackTrace(); } @@ -86,12 +86,12 @@ public class VirtualCommand { VolmitSender vs = new VolmitSender(sender); vs.setTag(tag); - if (label != null) { + if(label != null) { vs.setCommand(label); } - if (chain.isEmpty()) { - if (!checkPermissions(sender, command)) { + if(chain.isEmpty()) { + if(!checkPermissions(sender, command)) { return true; } @@ -100,15 +100,15 @@ public class VirtualCommand { String nl = chain.get(0); - for (KList i : children.k()) { - for (String j : i) { - if (j.equalsIgnoreCase(nl)) { + for(KList i : children.k()) { + for(String j : i) { + if(j.equalsIgnoreCase(nl)) { vs.setCommand(chain.get(0)); VirtualCommand cmd = children.get(i); KList c = chain.copy(); c.remove(0); - if (cmd.hit(sender, c, vs.getCommand())) { - if (vs.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { + if(cmd.hit(sender, c, vs.getCommand())) { + if(vs.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { vs.player().getWorld().playSound(vs.player().getLocation(), Sound.ITEM_AXE_STRIP, 0.35f, 1.8f); } @@ -118,7 +118,7 @@ public class VirtualCommand { } } - if (!checkPermissions(sender, command)) { + if(!checkPermissions(sender, command)) { return true; } @@ -129,11 +129,11 @@ public class VirtualCommand { VolmitSender vs = new VolmitSender(sender); vs.setTag(tag); - if (label != null) + if(label != null) vs.setCommand(label); - if (chain.isEmpty()) { - if (!checkPermissions(sender, command)) { + if(chain.isEmpty()) { + if(!checkPermissions(sender, command)) { return null; } @@ -142,22 +142,22 @@ public class VirtualCommand { String nl = chain.get(0); - for (KList i : children.k()) { - for (String j : i) { - if (j.equalsIgnoreCase(nl)) { + for(KList i : children.k()) { + for(String j : i) { + if(j.equalsIgnoreCase(nl)) { vs.setCommand(chain.get(0)); VirtualCommand cmd = children.get(i); KList c = chain.copy(); c.remove(0); KList v = cmd.hitTab(sender, c, vs.getCommand()); - if (v != null) { + if(v != null) { return v; } } } } - if (!checkPermissions(sender, command)) { + if(!checkPermissions(sender, command)) { return null; } @@ -168,14 +168,14 @@ public class VirtualCommand { private boolean checkPermissions(CommandSender sender, ICommand command2) { boolean failed = false; - for (String i : command.getRequiredPermissions()) { - if (!sender.hasPermission(i)) { + for(String i : command.getRequiredPermissions()) { + if(!sender.hasPermission(i)) { failed = true; Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> sender.sendMessage("- " + C.WHITE + i), 0); } } - if (failed) { + if(failed) { sender.sendMessage("Insufficient Permissions"); return false; } diff --git a/src/main/java/com/volmit/iris/util/plugin/VolmitPlugin.java b/src/main/java/com/volmit/iris/util/plugin/VolmitPlugin.java index adb5293fc..f92378645 100644 --- a/src/main/java/com/volmit/iris/util/plugin/VolmitPlugin.java +++ b/src/main/java/com/volmit/iris/util/plugin/VolmitPlugin.java @@ -97,7 +97,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { outputPluginInfo(); outputCommandInfo(); outputPermissionInfo(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -106,7 +106,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { private void outputPermissionInfo() throws IOException { FileConfiguration fc = new YamlConfiguration(); - for (MortarPermission i : permissionCache) { + for(MortarPermission i : permissionCache) { chain(i, fc); } @@ -116,7 +116,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { private void chain(MortarPermission i, FileConfiguration fc) { KList ff = new KList<>(); - for (MortarPermission j : i.getChildren()) { + for(MortarPermission j : i.getChildren()) { ff.add(j.getFullNode()); } @@ -124,7 +124,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { fc.set(i.getFullNode().replaceAll("\\Q.\\E", ",") + "." + "default", i.isDefault()); fc.set(i.getFullNode().replaceAll("\\Q.\\E", ",") + "." + "children", ff); - for (MortarPermission j : i.getChildren()) { + for(MortarPermission j : i.getChildren()) { chain(j, fc); } } @@ -132,7 +132,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { private void outputCommandInfo() throws IOException { FileConfiguration fc = new YamlConfiguration(); - for (MortarCommand i : commandCache) { + for(MortarCommand i : commandCache) { chain(i, "/", fc); } @@ -145,7 +145,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { fc.set(n + "." + "required-permissions", i.getRequiredPermissions()); fc.set(n + "." + "aliases", i.getAllNodes()); - for (MortarCommand j : i.getChildren()) { + for(MortarCommand j : i.getChildren()) { chain(j, n, fc); } } @@ -160,8 +160,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { private void registerPermissions() { permissionCache = new KList<>(); - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Permission.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Permission.class)) { try { i.setAccessible(true); MortarPermission pc = (MortarPermission) i.getType().getConstructor().newInstance(); @@ -169,7 +169,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { registerPermission(pc); permissionCache.add(pc); v("Registered Permissions " + pc.getFullNode() + " (" + i.getName() + ")"); - } catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { Iris.reportError(e); w("Failed to register permission (field " + i.getName() + ")"); e.printStackTrace(); @@ -177,10 +177,10 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } } - for (org.bukkit.permissions.Permission i : computePermissions()) { + for(org.bukkit.permissions.Permission i : computePermissions()) { try { Bukkit.getPluginManager().addPermission(i); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -189,13 +189,13 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { private KList computePermissions() { KList g = new KList<>(); - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Permission.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Permission.class)) { try { MortarPermission x = (MortarPermission) i.get(Modifier.isStatic(i.getModifiers()) ? null : this); g.add(toPermission(x)); g.addAll(computePermissions(x)); - } catch (IllegalArgumentException | IllegalAccessException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | SecurityException e) { Iris.reportError(e); e.printStackTrace(); } @@ -208,12 +208,12 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { private KList computePermissions(MortarPermission p) { KList g = new KList<>(); - if (p == null) { + if(p == null) { return g; } - for (MortarPermission i : p.getChildren()) { - if (i == null) { + for(MortarPermission i : p.getChildren()) { + if(i == null) { continue; } @@ -225,7 +225,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private org.bukkit.permissions.Permission toPermission(MortarPermission p) { - if (p == null) { + if(p == null) { return null; } @@ -233,7 +233,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { perm.setDescription(p.getDescription() == null ? "" : p.getDescription()); perm.setDefault(p.isDefault() ? PermissionDefault.TRUE : PermissionDefault.OP); - for (MortarPermission i : p.getChildren()) { + for(MortarPermission i : p.getChildren()) { perm.getChildren().put(i.getFullNode(), true); } @@ -253,19 +253,19 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private void tickController(IController i) { - if (bad) { + if(bad) { return; } - if (i.getTickInterval() < 0) { + if(i.getTickInterval() < 0) { return; } M.tick++; - if (M.interval(i.getTickInterval())) { + if(M.interval(i.getTickInterval())) { try { i.tick(); - } catch (Throwable e) { + } catch(Throwable e) { w("Failed to tick controller " + i.getName()); e.printStackTrace(); Iris.reportError(e); @@ -274,16 +274,16 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private void registerInstance() { - if (bad) { + if(bad) { return; } - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Instance.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Instance.class)) { try { i.setAccessible(true); i.set(Modifier.isStatic(i.getModifiers()) ? null : this, this); v("Registered Instance " + i.getName()); - } catch (IllegalArgumentException | IllegalAccessException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | SecurityException e) { w("Failed to register instance (field " + i.getName() + ")"); e.printStackTrace(); Iris.reportError(e); @@ -293,16 +293,16 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private void unregisterInstance() { - if (bad) { + if(bad) { return; } - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(Instance.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(Instance.class)) { try { i.setAccessible(true); i.set(Modifier.isStatic(i.getModifiers()) ? null : this, null); v("Unregistered Instance " + i.getName()); - } catch (IllegalArgumentException | IllegalAccessException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | SecurityException e) { w("Failed to unregister instance (field " + i.getName() + ")"); e.printStackTrace(); Iris.reportError(e); @@ -312,14 +312,14 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private void registerCommands() { - if (bad) { + if(bad) { return; } commands = new KMap<>(); commandCache = new KList<>(); - for (Field i : getClass().getDeclaredFields()) { - if (i.isAnnotationPresent(com.volmit.iris.util.plugin.Command.class)) { + for(Field i : getClass().getDeclaredFields()) { + if(i.isAnnotationPresent(com.volmit.iris.util.plugin.Command.class)) { try { i.setAccessible(true); MortarCommand pc = (MortarCommand) i.getType().getConstructor().newInstance(); @@ -327,7 +327,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { registerCommand(pc, c.value()); commandCache.add(pc); v("Registered Commands /" + pc.getNode() + " (" + i.getName() + ")"); - } catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch(IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { w("Failed to register command (field " + i.getName() + ")"); e.printStackTrace(); Iris.reportError(e); @@ -342,21 +342,21 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { String alias, String[] args) { KList chain = new KList<>(); - for (String i : args) { - if (i.trim().isEmpty()) { + for(String i : args) { + if(i.trim().isEmpty()) { continue; } chain.add(i.trim()); } - for (KList i : commands.k()) { - for (String j : i) { - if (j.equalsIgnoreCase(alias)) { + for(KList i : commands.k()) { + for(String j : i) { + if(j.equalsIgnoreCase(alias)) { VirtualCommand cmd = commands.get(i); List v = cmd.hitTab(sender, chain.copy(), alias); - if (v != null) { + if(v != null) { return v; } } @@ -368,19 +368,19 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { @Override public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) { - if (bad) { + if(bad) { return false; } KList chain = new KList<>(); chain.add(args); - for (KList i : commands.k()) { - for (String j : i) { - if (j.equalsIgnoreCase(label)) { + for(KList i : commands.k()) { + for(String j : i) { + if(j.equalsIgnoreCase(label)) { VirtualCommand cmd = commands.get(i); - if (cmd.hit(sender, chain.copy(), label)) { + if(cmd.hit(sender, chain.copy(), label)) { return true; } } @@ -395,14 +395,14 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } public void registerCommand(ICommand cmd, String subTag) { - if (bad) { + if(bad) { return; } commands.put(cmd.getAllNodes(), new VirtualCommand(cmd, subTag.trim().isEmpty() ? getTag() : getTag(subTag.trim()))); PluginCommand cc = getCommand(cmd.getNode().toLowerCase()); - if (cc != null) { + if(cc != null) { cc.setExecutor(this); cc.setUsage(getName() + ":" + getClass().toString() + ":" + cmd.getNode()); } else { @@ -413,7 +413,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } public void unregisterCommand(ICommand cmd) { - if (bad) { + if(bad) { return; } try { @@ -421,14 +421,14 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { Map k = new V(m).get("knownCommands"); - for (Iterator> it = k.entrySet().iterator(); it.hasNext(); ) { + for(Iterator> it = k.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = it.next(); - if (entry.getValue() instanceof Command) { + if(entry.getValue() instanceof Command) { org.bukkit.command.Command c = entry.getValue(); String u = c.getUsage(); - if (u != null && u.equals(getName() + ":" + getClass().toString() + ":" + cmd.getNode())) { - if (c.unregister(m)) { + if(u != null && u.equals(getName() + ":" + getClass().toString() + ":" + cmd.getNode())) { + if(c.unregister(m)) { it.remove(); v("Unregistered Command /" + cmd.getNode()); } else { @@ -437,14 +437,14 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } } } - } catch (Throwable e) { + } catch(Throwable e) { e.printStackTrace(); Iris.reportError(e); } } public String getTag() { - if (bad) { + if(bad) { return ""; } return getTag(""); @@ -461,20 +461,20 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } public void unregisterListeners() { - if (bad) { + if(bad) { return; } HandlerList.unregisterAll((Listener) this); } public void unregisterCommands() { - if (bad) { + if(bad) { return; } - for (VirtualCommand i : commands.v()) { + for(VirtualCommand i : commands.v()) { try { unregisterCommand(i.getCommand()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -482,10 +482,10 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private void unregisterPermissions() { - if (bad) { + if(bad) { return; } - for (org.bukkit.permissions.Permission i : computePermissions()) { + for(org.bukkit.permissions.Permission i : computePermissions()) { Bukkit.getPluginManager().removePermission(i); v("Unregistered Permission " + i.getName()); } @@ -506,7 +506,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } public File getDataFolder(String... strings) { - if (strings.length == 0) { + if(strings.length == 0) { return super.getDataFolder(); } @@ -517,7 +517,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } public File getDataFolderNoCreate(String... strings) { - if (strings.length == 0) { + if(strings.length == 0) { return super.getDataFolder(); } @@ -529,7 +529,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { public File getDataFolderList(String pre, String[] strings) { KList v = new KList<>(strings); v.add(0, pre); - if (v.size() == 0) { + if(v.size() == 0) { return super.getDataFolder(); } File f = new File(getDataFolder(), v.toString(File.separator)); diff --git a/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java b/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java index 30653e4f3..47631d11f 100644 --- a/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java +++ b/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java @@ -69,7 +69,8 @@ public class VolmitSender implements CommandSender { /** * Wrap a command sender * - * @param s the command sender + * @param s + * the command sender */ public VolmitSender(CommandSender s) { tag = ""; @@ -103,7 +104,7 @@ public class VolmitSender implements CommandSender { hasNext.set(page < totalPages - 1); KList d = new KList<>(); - for (int i = linesPerPage * page; i < Math.min(all.size(), linesPerPage * (page + 1)); i++) { + for(int i = linesPerPage * page; i < Math.min(all.size(), linesPerPage * (page + 1)); i++) { d.add(all.get(i)); } @@ -122,7 +123,8 @@ public class VolmitSender implements CommandSender { /** * Set a command tag (prefix for sendMessage) * - * @param tag the tag + * @param tag + * the tag */ public void setTag(String tag) { this.tag = tag; @@ -226,13 +228,13 @@ public class VolmitSender implements CommandSender { public void sendTitle(String title, String subtitle, int i, int s, int o) { Iris.audiences.player(player()).showTitle(Title.title( - createComponent(title), - createComponent(subtitle), - Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o)))); + createComponent(title), + createComponent(subtitle), + Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o)))); } public void sendProgress(double percent, String thing) { - if (percent < 0) { + if(percent < 0) { int l = 44; int g = (int) (1D * l); sendTitle(C.IRIS + thing + " ", 0, 500, 250); @@ -255,13 +257,13 @@ public class VolmitSender implements CommandSender { public void sendTitle(String subtitle, int i, int s, int o) { Iris.audiences.player(player()).showTitle(Title.title( - createNoPrefixComponent(" "), - createNoPrefixComponent(subtitle), - Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o)))); + createNoPrefixComponent(" "), + createNoPrefixComponent(subtitle), + Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o)))); } private Component createNoPrefixComponent(String message) { - if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) { + if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) { String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(message)); return MiniMessage.get().parse(t); } @@ -276,7 +278,7 @@ public class VolmitSender implements CommandSender { } private Component createComponent(String message) { - if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) { + if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) { String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message)); return MiniMessage.get().parse(t); } @@ -287,7 +289,7 @@ public class VolmitSender implements CommandSender { } private Component createComponentRaw(String message) { - if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) { + if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) { String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message)); return MiniMessage.get().parse(t); } @@ -300,7 +302,7 @@ public class VolmitSender implements CommandSender { AtomicInteger v = new AtomicInteger(); AtomicReference g = new AtomicReference<>(); v.set(J.ar(() -> { - if (f.isDone() && g.get() != null) { + if(f.isDone() && g.get() != null) { J.car(v.get()); sendAction(" "); return; @@ -311,9 +313,9 @@ public class VolmitSender implements CommandSender { J.a(() -> { try { g.set(f.get()); - } catch (InterruptedException e) { + } catch(InterruptedException e) { e.printStackTrace(); - } catch (ExecutionException e) { + } catch(ExecutionException e) { e.printStackTrace(); } }); @@ -322,23 +324,23 @@ public class VolmitSender implements CommandSender { @Override public void sendMessage(String message) { - if (s instanceof CommandDummy) { + if(s instanceof CommandDummy) { return; } - if ((!IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player) || !IrisSettings.get().getGeneral().isUseConsoleCustomColors()) { + if((!IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player) || !IrisSettings.get().getGeneral().isUseConsoleCustomColors()) { s.sendMessage(C.translateAlternateColorCodes('&', getTag() + message)); return; } - if (message.contains("")) { + if(message.contains("")) { s.sendMessage(C.translateAlternateColorCodes('&', getTag() + message.replaceAll("\\Q\\E", ""))); return; } try { Iris.audiences.sender(s).sendMessage(createComponent(message)); - } catch (Throwable e) { + } catch(Throwable e) { String t = C.translateAlternateColorCodes('&', getTag() + message); String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb()); @@ -352,23 +354,23 @@ public class VolmitSender implements CommandSender { } public void sendMessageRaw(String message) { - if (s instanceof CommandDummy) { + if(s instanceof CommandDummy) { return; } - if ((!IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player) || !IrisSettings.get().getGeneral().isUseConsoleCustomColors()) { + if((!IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player) || !IrisSettings.get().getGeneral().isUseConsoleCustomColors()) { s.sendMessage(C.translateAlternateColorCodes('&', message)); return; } - if (message.contains("")) { + if(message.contains("")) { s.sendMessage(message.replaceAll("\\Q\\E", "")); return; } try { Iris.audiences.sender(s).sendMessage(createComponentRaw(message)); - } catch (Throwable e) { + } catch(Throwable e) { String t = C.translateAlternateColorCodes('&', getTag() + message); String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb()); @@ -379,7 +381,7 @@ public class VolmitSender implements CommandSender { @Override public void sendMessage(String[] messages) { - for (String str : messages) + for(String str : messages) sendMessage(str); } @@ -410,21 +412,21 @@ public class VolmitSender implements CommandSender { private String pickRandoms(int max, VirtualDecreeCommand i) { KList m = new KList<>(); - for (int ix = 0; ix < max; ix++) { + for(int ix = 0; ix < max; ix++) { m.add((i.isNode() - ? (i.getNode().getParameters().isNotEmpty()) - ? "<#aebef2>✦ <#5ef288>" - + i.getParentPath() - + " <#42ecf5>" - + i.getName() + " " - + i.getNode().getParameters().shuffleCopy(RNG.r).convert((f) - -> (f.isRequired() || RNG.r.b(0.5) - ? "<#f2e15e>" + f.getNames().getRandom() + "=" - + "<#d665f0>" + f.example() - : "")) - .toString(" ") - : "" - : "")); + ? (i.getNode().getParameters().isNotEmpty()) + ? "<#aebef2>✦ <#5ef288>" + + i.getParentPath() + + " <#42ecf5>" + + i.getName() + " " + + i.getNode().getParameters().shuffleCopy(RNG.r).convert((f) + -> (f.isRequired() || RNG.r.b(0.5) + ? "<#f2e15e>" + f.getNames().getRandom() + "=" + + "<#d665f0>" + f.example() + : "")) + .toString(" ") + : "" + : "")); } return m.removeDuplicates().convert((iff) -> iff.replaceAll("\\Q \\E", " ")).toString("\n"); @@ -439,7 +441,7 @@ public class VolmitSender implements CommandSender { String sf = "["; String se = "]"; - if (name.trim().isEmpty()) { + if(name.trim().isEmpty()) { sendMessageRaw("" + sf + s + "" + s + se); } else { sendMessageRaw("" + sf + s + si + " " + name + " " + so + s + se); @@ -455,8 +457,8 @@ public class VolmitSender implements CommandSender { } public void sendDecreeHelp(VirtualDecreeCommand v, int page) { - if (!isPlayer()) { - for (VirtualDecreeCommand i : v.getNodes()) { + if(!isPlayer()) { + for(VirtualDecreeCommand i : v.getNodes()) { sendDecreeHelpNode(i); } @@ -467,27 +469,27 @@ public class VolmitSender implements CommandSender { sendMessageRaw("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - if (v.getNodes().isNotEmpty()) { + if(v.getNodes().isNotEmpty()) { sendHeader(v.getPath() + (page > 0 ? (" {" + (page + 1) + "}") : "")); - if (isPlayer() && v.getParent() != null) { + if(isPlayer() && v.getParent() != null) { sendMessageRaw("Click to go back to <#3299bf>" + Form.capitalize(v.getParent().getName()) + " Help" + "'><#f58571>〈 Back"); } AtomicBoolean next = new AtomicBoolean(false); - for (VirtualDecreeCommand i : paginate(v.getNodes(), 17, page, next)) { + for(VirtualDecreeCommand i : paginate(v.getNodes(), 17, page, next)) { sendDecreeHelpNode(i); } String s = ""; int l = 75 - (page > 0 ? 10 : 0) - (next.get() ? 10 : 0); - if (page > 0) { + if(page > 0) { s += "Click to go back to page " + page + "'>〈 Page " + page + " "; } s += "" + Form.repeat(" ", l) + ""; - if (next.get()) { + if(next.get()) { s += " Click to go to back to page " + (page + 2) + "'>Page " + (page + 2) + " ❭"; } @@ -498,7 +500,7 @@ public class VolmitSender implements CommandSender { } public void sendDecreeHelpNode(VirtualDecreeCommand i) { - if (isPlayer() || s instanceof CommandDummy) { + if(isPlayer() || s instanceof CommandDummy) { sendMessageRaw(helpCache.computeIfAbsent(i.getPath(), (k) -> { String newline = "\n"; @@ -509,8 +511,8 @@ public class VolmitSender implements CommandSender { String description = "<#3fe05a>✎ <#6ad97d>" + i.getDescription(); String usage = "<#bbe03f>✒ <#a8e0a2>"; String onClick; - if (i.isNode()) { - if (i.getNode().getParameters().isEmpty()) { + if(i.isNode()) { + if(i.getNode().getParameters().isEmpty()) { usage += "There are no parameters. Click to type command."; onClick = "suggest_command"; } else { @@ -524,16 +526,16 @@ public class VolmitSender implements CommandSender { String suggestion = ""; String suggestions = ""; - if (i.isNode() && i.getNode().getParameters().isNotEmpty()) { + if(i.isNode() && i.getNode().getParameters().isNotEmpty()) { suggestion += newline + "<#aebef2>✦ <#5ef288>" + i.getParentPath() + " <#42ecf5>" + i.getName() + " " - + i.getNode().getParameters().convert((f) -> "<#d665f0>" + f.example()).toString(" "); + + i.getNode().getParameters().convert((f) -> "<#d665f0>" + f.example()).toString(" "); suggestions += newline + "" + pickRandoms(Math.min(i.getNode().getParameters().size() + 1, 5), i); } /// Params StringBuilder nodes = new StringBuilder(); - if (i.isNode()) { - for (DecreeParameter p : i.getNode().getParameters()) { + if(i.isNode()) { + for(DecreeParameter p : i.getNode().getParameters()) { String nTitle = "" + p.getName(); String nHoverTitle = p.getNames().convert((ff) -> "<#d665f0>" + ff).toString(", "); @@ -541,13 +543,13 @@ public class VolmitSender implements CommandSender { String nUsage; String fullTitle; Iris.debug("Contextual: " + p.isContextual() + " / player: " + isPlayer()); - if (p.isContextual() && (isPlayer() || s instanceof CommandDummy)) { + if(p.isContextual() && (isPlayer() || s instanceof CommandDummy)) { fullTitle = "<#ffcc00>[" + nTitle + "<#ffcc00>] "; nUsage = "<#ff9900>➱ <#ffcc00>The value may be derived from environment context."; - } else if (p.isRequired()) { + } else if(p.isRequired()) { fullTitle = "[" + nTitle + "] "; nUsage = "<#db4321>⚠ <#faa796>This parameter is required."; - } else if (p.hasDefault()) { + } else if(p.hasDefault()) { fullTitle = "<#4f4f4f>⊰" + nTitle + "<#4f4f4f>⊱"; nUsage = "<#2181db>✔ <#78dcf0>Defaults to \"" + p.getParam().defaultValue() + "\" if undefined."; } else { @@ -557,14 +559,14 @@ public class VolmitSender implements CommandSender { String type = "<#cc00ff>✢ <#ff33cc>This parameter is of type " + p.getType().getSimpleName() + "."; nodes - .append("") - .append(fullTitle) - .append(""); + .append("") + .append(fullTitle) + .append(""); } } else { nodes = new StringBuilder(" - Category of Commands"); @@ -572,21 +574,21 @@ public class VolmitSender implements CommandSender { /// Wrapper String wrapper = - "" + - "" + - "" + - " " + - nodes; + "" + + "" + + "" + + " " + + nodes; return wrapper; })); @@ -596,7 +598,7 @@ public class VolmitSender implements CommandSender { } public void playSound(Sound sound, float volume, float pitch) { - if (isPlayer()) { + if(isPlayer()) { player().playSound(player().getLocation(), sound, volume, pitch); } } diff --git a/src/main/java/com/volmit/iris/util/reflect/V.java b/src/main/java/com/volmit/iris/util/reflect/V.java index e428206fe..8e8dbf243 100644 --- a/src/main/java/com/volmit/iris/util/reflect/V.java +++ b/src/main/java/com/volmit/iris/util/reflect/V.java @@ -52,9 +52,9 @@ public class V { public T get(Class t) { try { return local ? Violator.getDeclaredAnnotation(o.getClass(), t) : Violator.getAnnotation(o.getClass(), t); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (!suppress) { + if(!suppress) { e.printStackTrace(); } } @@ -65,9 +65,9 @@ public class V { public T get(Class t, String mn, Class... pars) { try { return local ? Violator.getDeclaredAnnotation(Violator.getDeclaredMethod(o.getClass(), mn, pars), t) : Violator.getAnnotation(Violator.getMethod(o.getClass(), mn, pars), t); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (!suppress) { + if(!suppress) { e.printStackTrace(); } } @@ -78,9 +78,9 @@ public class V { public T get(Class t, String mn) { try { return local ? Violator.getDeclaredAnnotation(Violator.getDeclaredField(o.getClass(), mn), t) : Violator.getAnnotation(Violator.getField(o.getClass(), mn), t); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (!suppress) { + if(!suppress) { e.printStackTrace(); } } @@ -92,9 +92,9 @@ public class V { public T get(String field) { try { return (T) (local ? Violator.getDeclaredField(o.getClass(), field) : Violator.getField(o.getClass(), field)).get(o); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (!suppress) { + if(!suppress) { e.printStackTrace(); } } @@ -109,15 +109,15 @@ public class V { public Object invoke(String method, Object... parameters) { KList> par = new KList<>(); - for (Object i : parameters) { + for(Object i : parameters) { par.add(i.getClass()); } try { return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class[0])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class[0]))).invoke(o, parameters); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (!suppress) { + if(!suppress) { e.printStackTrace(); } } @@ -129,9 +129,9 @@ public class V { try { // https://github.com/VolmitSoftware/Mortar/issues/5 (local ? Violator.getDeclaredField(o.getClass(), field) : Violator.getField(o.getClass(), field)).set(o, value); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); - if (!suppress) { + if(!suppress) { e.printStackTrace(); } } diff --git a/src/main/java/com/volmit/iris/util/reflect/Violator.java b/src/main/java/com/volmit/iris/util/reflect/Violator.java index 6d5fdfa4e..11bf061ef 100644 --- a/src/main/java/com/volmit/iris/util/reflect/Violator.java +++ b/src/main/java/com/volmit/iris/util/reflect/Violator.java @@ -31,23 +31,23 @@ public class Violator { protected static final ConcurrentSkipListMap nodes = new ConcurrentSkipListMap<>(); private static String id(Object o, Object h) { - if (o instanceof Field) { + if(o instanceof Field) { return id(((Field) o).getDeclaringClass(), null) + "." + ((Field) o).getName(); } - if (o instanceof String) { + if(o instanceof String) { return (String) o; } - if (o instanceof Class) { + if(o instanceof Class) { return ((Class) o).getCanonicalName(); } - if (o instanceof Constructor co) { + if(o instanceof Constructor co) { StringBuilder mx = new StringBuilder(); - for (Class i : co.getParameterTypes()) { + for(Class i : co.getParameterTypes()) { mx.append(",").append(i.getCanonicalName()); } @@ -56,10 +56,10 @@ public class Violator { return id(co.getDeclaringClass(), null) + "(" + mx + ")"; } - if (o instanceof Method) { + if(o instanceof Method) { StringBuilder mx = new StringBuilder(); - for (Class i : ((Method) o).getParameterTypes()) { + for(Class i : ((Method) o).getParameterTypes()) { mx.append(",").append(i.getCanonicalName()); } @@ -68,7 +68,7 @@ public class Violator { return id(((Method) o).getDeclaringClass(), null) + "." + ((Method) o).getName() + "(" + mx + ")"; } - if (o instanceof Annotation a) { + if(o instanceof Annotation a) { return "@" + a.annotationType().getCanonicalName() + "[" + id(h, null) + "]"; } @@ -91,13 +91,13 @@ public class Violator { public static Constructor getConstructor(Class c, Class... params) throws NoSuchMethodException, SecurityException { StringBuilder mx = new StringBuilder(); - for (Class i : params) { + for(Class i : params) { mx.append(",").append(i.getCanonicalName()); } mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); - if (!h(id(c, null) + "(" + mx + ")")) { + if(!h(id(c, null) + "(" + mx + ")")) { Constructor co = c.getConstructor(params); co.setAccessible(true); p(id(co, null), co); @@ -108,15 +108,15 @@ public class Violator { @SuppressWarnings("rawtypes") public static Field getField(Class c, String name) throws Throwable { - if (!h(id(c, null) + "." + name)) { + if(!h(id(c, null) + "." + name)) { try { Field f = c.getField(name); f.setAccessible(true); p(id(c, null) + "." + name, f); - } catch (NoSuchFieldException e) { + } catch(NoSuchFieldException e) { Iris.reportError(e); Class s = c.getSuperclass(); - if (null == s) { + if(null == s) { throw e; } Field f = s.getField(name); @@ -130,15 +130,15 @@ public class Violator { @SuppressWarnings("rawtypes") public static Field getDeclaredField(Class c, String name) throws Throwable { - if (!h(id(c, null) + "." + name)) { + if(!h(id(c, null) + "." + name)) { try { Field f = c.getDeclaredField(name); f.setAccessible(true); p(id(c, null) + "." + name, f); - } catch (NoSuchFieldException e) { + } catch(NoSuchFieldException e) { Iris.reportError(e); Class s = c.getSuperclass(); - if (null == s) { + if(null == s) { throw e; } Field f = s.getDeclaredField(name); @@ -154,14 +154,14 @@ public class Violator { String iv = ""; StringBuilder mx = new StringBuilder(); - for (Class i : pars) { + for(Class i : pars) { mx.append(",").append(i.getCanonicalName()); } mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); iv = id(c, null) + "." + name + "(" + mx + ")"; - if (!h(iv)) { + if(!h(iv)) { Method f = c.getMethod(name, pars); f.setAccessible(true); p(iv, f); @@ -174,14 +174,14 @@ public class Violator { public static T construct(Class c, Object... parameters) { KList> cv = new KList<>(); - for (Object i : parameters) { + for(Object i : parameters) { cv.add(i.getClass()); } try { Constructor co = getConstructor(c, cv.toArray(new Class[0])); return (T) co.newInstance(parameters); - } catch (Exception e) { + } catch(Exception e) { Iris.reportError(e); e.printStackTrace(); } @@ -193,14 +193,14 @@ public class Violator { String iv = ""; StringBuilder mx = new StringBuilder(); - for (Class i : pars) { + for(Class i : pars) { mx.append(",").append(i.getCanonicalName()); } mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); iv = id(c, null) + "." + name + "(" + mx + ")"; - if (!h(iv)) { + if(!h(iv)) { Method f = c.getDeclaredMethod(name, pars); f.setAccessible(true); p(iv, f); @@ -211,7 +211,7 @@ public class Violator { @SuppressWarnings("unchecked") public static T getAnnotation(Class c, Class a) { - if (!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) { + if(!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) { T f = c.getAnnotation(a); p(id(f, c), f); } @@ -221,7 +221,7 @@ public class Violator { @SuppressWarnings("unchecked") public static T getDeclaredAnnotation(Class c, Class a) { - if (!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) { + if(!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) { T f = c.getDeclaredAnnotation(a); p(id(f, c), f); } @@ -231,7 +231,7 @@ public class Violator { @SuppressWarnings("unchecked") public static T getAnnotation(Field c, Class a) { - if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { + if(!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getAnnotation(a); p(id(f, c), f); } @@ -241,7 +241,7 @@ public class Violator { @SuppressWarnings("unchecked") public static T getDeclaredAnnotation(Field c, Class a) { - if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { + if(!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getDeclaredAnnotation(a); p(id(f, c), f); } @@ -251,7 +251,7 @@ public class Violator { @SuppressWarnings("unchecked") public static T getAnnotation(Method c, Class a) { - if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { + if(!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getAnnotation(a); p(id(f, c), f); } @@ -261,7 +261,7 @@ public class Violator { @SuppressWarnings("unchecked") public static T getDeclaredAnnotation(Method c, Class a) { - if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { + if(!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getDeclaredAnnotation(a); p(id(f, c), f); diff --git a/src/main/java/com/volmit/iris/util/scheduling/Callback.java b/src/main/java/com/volmit/iris/util/scheduling/Callback.java index 9677ea5f3..f163634c5 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/Callback.java +++ b/src/main/java/com/volmit/iris/util/scheduling/Callback.java @@ -21,7 +21,8 @@ package com.volmit.iris.util.scheduling; /** * Callback for async workers * - * @param the type of object to be returned in the runnable + * @param + * the type of object to be returned in the runnable * @author cyberpwn */ @FunctionalInterface @@ -29,7 +30,8 @@ public interface Callback { /** * Called when the callback calls back... * - * @param t the object to be called back + * @param t + * the object to be called back */ void run(T t); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/ChronoLatch.java b/src/main/java/com/volmit/iris/util/scheduling/ChronoLatch.java index ef8d75e5a..53b5f3b83 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/ChronoLatch.java +++ b/src/main/java/com/volmit/iris/util/scheduling/ChronoLatch.java @@ -40,7 +40,7 @@ public class ChronoLatch { } public boolean flip() { - if (System.currentTimeMillis() - since > interval) { + if(System.currentTimeMillis() - since > interval) { since = System.currentTimeMillis(); return true; } diff --git a/src/main/java/com/volmit/iris/util/scheduling/GroupedExecutor.java b/src/main/java/com/volmit/iris/util/scheduling/GroupedExecutor.java index 59f8c92e3..328f23354 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/GroupedExecutor.java +++ b/src/main/java/com/volmit/iris/util/scheduling/GroupedExecutor.java @@ -37,7 +37,7 @@ public class GroupedExecutor { xc = 1; mirror = new KMap<>(); - if (threadLimit == 1) { + if(threadLimit == 1) { service = Executors.newSingleThreadExecutor((r) -> { Thread t = new Thread(r); @@ -46,7 +46,7 @@ public class GroupedExecutor { return t; }); - } else if (threadLimit > 1) { + } else if(threadLimit > 1) { final ForkJoinWorkerThreadFactory factory = pool -> { final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); worker.setName(name + " " + xc++); @@ -68,16 +68,16 @@ public class GroupedExecutor { } public void waitFor(String g) { - if (g == null) { + if(g == null) { return; } - if (!mirror.containsKey(g)) { + if(!mirror.containsKey(g)) { return; } - while (true) { - if (mirror.get(g) == 0) { + while(true) { + if(mirror.get(g) == 0) { break; } } @@ -89,7 +89,7 @@ public class GroupedExecutor { { try { r.run(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/IrisLock.java b/src/main/java/com/volmit/iris/util/scheduling/IrisLock.java index 179ca93ed..2a60619db 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/IrisLock.java +++ b/src/main/java/com/volmit/iris/util/scheduling/IrisLock.java @@ -26,7 +26,7 @@ import java.util.concurrent.locks.ReentrantLock; @Data @Accessors( - chain = true + chain = true ) public class IrisLock { private transient final ReentrantLock lock; @@ -39,7 +39,7 @@ public class IrisLock { } public void lock() { - if (disabled) { + if(disabled) { return; } @@ -47,12 +47,12 @@ public class IrisLock { } public void unlock() { - if (disabled) { + if(disabled) { return; } try { lock.unlock(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/J.java b/src/main/java/com/volmit/iris/util/scheduling/J.java index fef71a5b0..16e8f0397 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/J.java +++ b/src/main/java/com/volmit/iris/util/scheduling/J.java @@ -27,7 +27,6 @@ import com.volmit.iris.util.function.NastySupplier; import com.volmit.iris.util.math.FinalInteger; import com.volmit.iris.util.parallel.MultiBurst; import org.bukkit.Bukkit; -import org.bukkit.plugin.IllegalPluginAccessException; import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; @@ -44,18 +43,18 @@ public class J { private static boolean started = false; public static void dofor(int a, Function c, int ch, Consumer d) { - for (int i = a; c.apply(i); i += ch) { + for(int i = a; c.apply(i); i += ch) { c.apply(i); } } public static boolean doif(Supplier c, Runnable g) { try { - if (c.get()) { + if(c.get()) { g.run(); return true; } - } catch (NullPointerException e) { + } catch(NullPointerException e) { Iris.reportError(e); // TODO: Fix this because this is just a suppression for an NPE on g return false; @@ -68,7 +67,7 @@ public class J { MultiBurst.burst.lazy(() -> { try { a.run(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to run async task"); e.printStackTrace(); @@ -80,7 +79,7 @@ public class J { MultiBurst.burst.lazy(() -> { try { a.run(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); Iris.error("Failed to run async task"); e.printStackTrace(); @@ -89,7 +88,7 @@ public class J { } public static void aBukkit(Runnable a) { - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return; } Bukkit.getScheduler().scheduleAsyncDelayedTask(Iris.instance, a); @@ -106,7 +105,7 @@ public class J { public static R attemptResult(NastyFuture r, R onError) { try { return r.run(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -117,7 +116,7 @@ public class J { public static R attemptFunction(NastyFunction r, T param, R onError) { try { return r.run(param); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -136,7 +135,7 @@ public class J { public static T attemptResult(NastySupplier r) { try { return r.get(); - } catch (Throwable e) { + } catch(Throwable e) { return null; } } @@ -144,7 +143,7 @@ public class J { public static Throwable attemptCatch(NastyRunnable r) { try { r.run(); - } catch (Throwable e) { + } catch(Throwable e) { return e; } @@ -154,7 +153,7 @@ public class J { public static T attempt(Supplier t, T i) { try { return t.get(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); return i; } @@ -164,17 +163,17 @@ public class J { * Dont call this unless you know what you are doing! */ public static void executeAfterStartupQueue() { - if (started) { + if(started) { return; } started = true; - for (Runnable r : afterStartup) { + for(Runnable r : afterStartup) { s(r); } - for (Runnable r : afterStartupAsync) { + for(Runnable r : afterStartupAsync) { a(r); } @@ -189,10 +188,11 @@ public class J { * If you dont know if you should queue this or not, do so, it's pretty * forgiving. * - * @param r the runnable + * @param r + * the runnable */ public static void ass(Runnable r) { - if (started) { + if(started) { s(r); } else { afterStartup.add(r); @@ -206,10 +206,11 @@ public class J { * If you dont know if you should queue this or not, do so, it's pretty * forgiving. * - * @param r the runnable + * @param r + * the runnable */ public static void asa(Runnable r) { - if (started) { + if(started) { a(r); } else { afterStartupAsync.add(r); @@ -219,10 +220,11 @@ public class J { /** * Queue a sync task * - * @param r the runnable + * @param r + * the runnable */ public static void s(Runnable r) { - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return; } Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, r); @@ -231,7 +233,7 @@ public class J { public static CompletableFuture sfut(Runnable r) { CompletableFuture f = new CompletableFuture(); - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return null; } Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> { @@ -244,7 +246,7 @@ public class J { public static CompletableFuture sfut(Runnable r, int delay) { CompletableFuture f = new CompletableFuture(); - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return null; } Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> { @@ -266,16 +268,18 @@ public class J { /** * Queue a sync task * - * @param r the runnable - * @param delay the delay to wait in ticks before running + * @param r + * the runnable + * @param delay + * the delay to wait in ticks before running */ public static void s(Runnable r, int delay) { try { - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return; } Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, r, delay); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } } @@ -283,7 +287,8 @@ public class J { /** * Cancel a sync repeating task * - * @param id the task id + * @param id + * the task id */ public static void csr(int id) { Bukkit.getScheduler().cancelTask(id); @@ -292,12 +297,14 @@ public class J { /** * Start a sync repeating task * - * @param r the runnable - * @param interval the interval + * @param r + * the runnable + * @param interval + * the interval * @return the task id */ public static int sr(Runnable r, int interval) { - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return -1; } return Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, r, 0, interval); @@ -306,9 +313,12 @@ public class J { /** * Start a sync repeating task for a limited amount of ticks * - * @param r the runnable - * @param interval the interval in ticks - * @param intervals the maximum amount of intervals to run + * @param r + * the runnable + * @param interval + * the interval in ticks + * @param intervals + * the maximum amount of intervals to run */ public static void sr(Runnable r, int interval, int intervals) { FinalInteger fi = new FinalInteger(0); @@ -319,7 +329,7 @@ public class J { fi.add(1); r.run(); - if (fi.get() >= intervals) { + if(fi.get() >= intervals) { cancel(); } } @@ -329,12 +339,14 @@ public class J { /** * Call an async task dealyed * - * @param r the runnable - * @param delay the delay to wait before running + * @param r + * the runnable + * @param delay + * the delay to wait before running */ @SuppressWarnings("deprecation") public static void a(Runnable r, int delay) { - if (Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { Bukkit.getScheduler().scheduleAsyncDelayedTask(Iris.instance, r, delay); } } @@ -342,7 +354,8 @@ public class J { /** * Cancel an async repeat task * - * @param id the id + * @param id + * the id */ public static void car(int id) { Bukkit.getScheduler().cancelTask(id); @@ -351,13 +364,15 @@ public class J { /** * Start an async repeat task * - * @param r the runnable - * @param interval the interval in ticks + * @param r + * the runnable + * @param interval + * the interval in ticks * @return the task id */ @SuppressWarnings("deprecation") public static int ar(Runnable r, int interval) { - if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { + if(!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) { return -1; } return Bukkit.getScheduler().scheduleAsyncRepeatingTask(Iris.instance, r, 0, interval); @@ -366,9 +381,12 @@ public class J { /** * Start an async repeating task for a limited time * - * @param r the runnable - * @param interval the interval - * @param intervals the intervals to run + * @param r + * the runnable + * @param interval + * the interval + * @param intervals + * the intervals to run */ public static void ar(Runnable r, int interval, int intervals) { FinalInteger fi = new FinalInteger(0); @@ -379,7 +397,7 @@ public class J { fi.add(1); r.run(); - if (fi.get() >= intervals) { + if(fi.get() >= intervals) { cancel(); } } diff --git a/src/main/java/com/volmit/iris/util/scheduling/Looper.java b/src/main/java/com/volmit/iris/util/scheduling/Looper.java index 60a74219b..6e2be300b 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/Looper.java +++ b/src/main/java/com/volmit/iris/util/scheduling/Looper.java @@ -25,20 +25,20 @@ public abstract class Looper extends Thread { @SuppressWarnings("BusyWait") public void run() { Iris.service(PreservationSVC.class).register(this); - while (!interrupted()) { + while(!interrupted()) { try { long m = loop(); - if (m < 0) { + if(m < 0) { break; } //noinspection BusyWait Thread.sleep(m); - } catch (InterruptedException e) { + } catch(InterruptedException e) { Iris.reportError(e); break; - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/O.java b/src/main/java/com/volmit/iris/util/scheduling/O.java index 843270fc7..8241c71fa 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/O.java +++ b/src/main/java/com/volmit/iris/util/scheduling/O.java @@ -33,7 +33,7 @@ public class O implements Observable { public O set(T t) { this.t = t; - if (observers != null && observers.hasElements()) { + if(observers != null && observers.hasElements()) { observers.forEach((o) -> o.onChanged(t, t)); } @@ -53,7 +53,7 @@ public class O implements Observable { @Override public O observe(Observer t) { - if (observers == null) { + if(observers == null) { observers = new KList<>(); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/PrecisionStopwatch.java b/src/main/java/com/volmit/iris/util/scheduling/PrecisionStopwatch.java index aa8e3f811..c7c40fb03 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/PrecisionStopwatch.java +++ b/src/main/java/com/volmit/iris/util/scheduling/PrecisionStopwatch.java @@ -45,7 +45,7 @@ public class PrecisionStopwatch { } public void end() { - if (!profiling) { + if(!profiling) { return; } diff --git a/src/main/java/com/volmit/iris/util/scheduling/QueueExecutor.java b/src/main/java/com/volmit/iris/util/scheduling/QueueExecutor.java index fd4dd8e9e..19e0ffa02 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/QueueExecutor.java +++ b/src/main/java/com/volmit/iris/util/scheduling/QueueExecutor.java @@ -35,16 +35,16 @@ public class QueueExecutor extends Looper { @Override protected long loop() { - while (queue.hasNext()) { + while(queue.hasNext()) { try { queue.next().run(); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); e.printStackTrace(); } } - if (shutdown && !queue.hasNext()) { + if(shutdown && !queue.hasNext()) { interrupt(); return -1; } diff --git a/src/main/java/com/volmit/iris/util/scheduling/ShurikenQueue.java b/src/main/java/com/volmit/iris/util/scheduling/ShurikenQueue.java index 4519c27ac..2d1e3bb02 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/ShurikenQueue.java +++ b/src/main/java/com/volmit/iris/util/scheduling/ShurikenQueue.java @@ -70,8 +70,8 @@ public class ShurikenQueue implements Queue { public KList next(int amt) { KList t = new KList<>(); - for (int i = 0; i < amt; i++) { - if (!hasNext()) { + for(int i = 0; i < amt; i++) { + if(!hasNext()) { break; } diff --git a/src/main/java/com/volmit/iris/util/scheduling/TaskExecutor.java b/src/main/java/com/volmit/iris/util/scheduling/TaskExecutor.java index 08cb4ad5b..83c9ca148 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/TaskExecutor.java +++ b/src/main/java/com/volmit/iris/util/scheduling/TaskExecutor.java @@ -39,7 +39,7 @@ public class TaskExecutor { public TaskExecutor(int threadLimit, int priority, String name) { xc = 1; - if (threadLimit == 1) { + if(threadLimit == 1) { service = Executors.newSingleThreadExecutor((r) -> { Thread t = new Thread(r); @@ -48,7 +48,7 @@ public class TaskExecutor { return t; }); - } else if (threadLimit > 1) { + } else if(threadLimit > 1) { final ForkJoinWorkerThreadFactory factory = pool -> { final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); worker.setName(name + " " + xc++); @@ -102,7 +102,7 @@ public class TaskExecutor { } public TaskGroup queue(NastyRunnable... r) { - for (NastyRunnable i : r) { + for(NastyRunnable i : r) { tasks.add(new AssignedTask(i)); } @@ -110,7 +110,7 @@ public class TaskExecutor { } public TaskGroup queue(KList r) { - for (NastyRunnable i : r) { + for(NastyRunnable i : r) { tasks.add(new AssignedTask(i)); } @@ -126,24 +126,24 @@ public class TaskExecutor { long msv = M.ns(); waiting: - while (true) { + while(true) { try { //noinspection BusyWait Thread.sleep(0); - } catch (InterruptedException ignored) { + } catch(InterruptedException ignored) { } - for (AssignedTask i : tasks) { - if (i.state.equals(TaskState.QUEUED) || i.state.equals(TaskState.RUNNING)) { + for(AssignedTask i : tasks) { + if(i.state.equals(TaskState.QUEUED) || i.state.equals(TaskState.RUNNING)) { continue waiting; } } timeElapsed = (double) (M.ns() - msv) / 1000000D; - for (AssignedTask i : tasks) { - if (i.state.equals(TaskState.COMPLETED)) { + for(AssignedTask i : tasks) { + if(i.state.equals(TaskState.COMPLETED)) { tasksCompleted++; } else { tasksFailed++; @@ -194,7 +194,7 @@ public class TaskExecutor { try { task.run(); state = TaskState.COMPLETED; - } catch (Throwable ex) { + } catch(Throwable ex) { Iris.reportError(ex); ex.printStackTrace(); Iris.reportError(ex); diff --git a/src/main/java/com/volmit/iris/util/scheduling/ThreadMonitor.java b/src/main/java/com/volmit/iris/util/scheduling/ThreadMonitor.java index 096c0784d..a0ee3aee3 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/ThreadMonitor.java +++ b/src/main/java/com/volmit/iris/util/scheduling/ThreadMonitor.java @@ -51,22 +51,22 @@ public class ThreadMonitor extends Thread { } public void run() { - while (running) { + while(running) { try { //noinspection BusyWait Thread.sleep(0); State s = monitor.getState(); - if (lastState != s) { + if(lastState != s) { cycles++; pushState(s); } lastState = s; - if (cl.flip()) { + if(cl.flip()) { Iris.info("Cycles: " + Form.f(cycles) + " (" + Form.duration(sq.getAverage(), 2) + ")"); } - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); running = false; break; @@ -75,8 +75,8 @@ public class ThreadMonitor extends Thread { } public void pushState(State s) { - if (s != State.RUNNABLE) { - if (st != null) { + if(s != State.RUNNABLE) { + if(st != null) { sq.put(st.getMilliseconds()); } } else { diff --git a/src/main/java/com/volmit/iris/util/scheduling/Wrapper.java b/src/main/java/com/volmit/iris/util/scheduling/Wrapper.java index ad8804941..1b20c654c 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/Wrapper.java +++ b/src/main/java/com/volmit/iris/util/scheduling/Wrapper.java @@ -43,24 +43,24 @@ public class Wrapper { @Override public boolean equals(Object obj) { - if (this == obj) { + if(this == obj) { return true; } - if (obj == null) { + if(obj == null) { return false; } - if (!(obj instanceof Wrapper other)) { + if(!(obj instanceof Wrapper other)) { return false; } - if (t == null) { + if(t == null) { return other.t == null; } else return t.equals(other.t); } @Override public String toString() { - if (t != null) { + if(t != null) { return get().toString(); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/jobs/DownloadJob.java b/src/main/java/com/volmit/iris/util/scheduling/jobs/DownloadJob.java index ebab8ff29..1d878832b 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/jobs/DownloadJob.java +++ b/src/main/java/com/volmit/iris/util/scheduling/jobs/DownloadJob.java @@ -38,7 +38,7 @@ public class DownloadJob implements Job { download.monitor(new DownloadMonitor() { @Override public void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse) { - if (size == -1) { + if(size == -1) { tw = 1; } else { tw = (int) (size / 100); @@ -57,10 +57,10 @@ public class DownloadJob implements Job { public void execute() { try { download.start(); - while (download.isState(DL.DownloadState.DOWNLOADING)) { + while(download.isState(DL.DownloadState.DOWNLOADING)) { download.downloadChunk(); } - } catch (IOException e) { + } catch(IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/jobs/Job.java b/src/main/java/com/volmit/iris/util/scheduling/jobs/Job.java index c2b3dfd10..9d4536dea 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/jobs/Job.java +++ b/src/main/java/com/volmit/iris/util/scheduling/jobs/Job.java @@ -64,7 +64,7 @@ public interface Job { PrecisionStopwatch p = PrecisionStopwatch.start(); CompletableFuture f = J.afut(this::execute); int c = J.ar(() -> { - if (sender.isPlayer()) { + if(sender.isPlayer()) { sender.sendProgress(getProgress(), getName()); } else { sender.sendMessage(getName() + ": " + getProgressString()); @@ -72,7 +72,7 @@ public interface Job { }, sender.isPlayer() ? 0 : 20); f.whenComplete((fs, ff) -> { J.car(c); - if (!silentMsg) { + if(!silentMsg) { sender.sendMessage(C.AQUA + "Completed " + getName() + " in " + Form.duration(p.getMilliseconds(), 1)); } whenComplete.run(); diff --git a/src/main/java/com/volmit/iris/util/scheduling/jobs/JobCollection.java b/src/main/java/com/volmit/iris/util/scheduling/jobs/JobCollection.java index 1c3babaf5..bc6eb1195 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/jobs/JobCollection.java +++ b/src/main/java/com/volmit/iris/util/scheduling/jobs/JobCollection.java @@ -42,7 +42,7 @@ public class JobCollection implements Job { @Override public void execute() { - for (Job i : jobs) { + for(Job i : jobs) { status = i.getName(); i.execute(); } diff --git a/src/main/java/com/volmit/iris/util/scheduling/jobs/ParallelQueueJob.java b/src/main/java/com/volmit/iris/util/scheduling/jobs/ParallelQueueJob.java index e136f56d0..21c10251c 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/jobs/ParallelQueueJob.java +++ b/src/main/java/com/volmit/iris/util/scheduling/jobs/ParallelQueueJob.java @@ -25,11 +25,11 @@ import com.volmit.iris.util.parallel.MultiBurst; public abstract class ParallelQueueJob extends QueueJob { @Override public void execute() { - while (queue.isNotEmpty()) { + while(queue.isNotEmpty()) { BurstExecutor b = MultiBurst.burst.burst(queue.size()); KList q = queue.copy(); queue.clear(); - for (T i : q) { + for(T i : q) { b.queue(() -> { execute(i); completeWork(); diff --git a/src/main/java/com/volmit/iris/util/scheduling/jobs/QueueJob.java b/src/main/java/com/volmit/iris/util/scheduling/jobs/QueueJob.java index 37c57741a..514983f97 100644 --- a/src/main/java/com/volmit/iris/util/scheduling/jobs/QueueJob.java +++ b/src/main/java/com/volmit/iris/util/scheduling/jobs/QueueJob.java @@ -50,7 +50,7 @@ public abstract class QueueJob implements Job { @Override public void execute() { totalWork = queue.size(); - while (queue.isNotEmpty()) { + while(queue.isNotEmpty()) { execute(queue.pop()); completeWork(); } diff --git a/src/main/java/com/volmit/iris/util/stream/ArraySignificance.java b/src/main/java/com/volmit/iris/util/stream/ArraySignificance.java index 8e8c319ab..59e89946c 100644 --- a/src/main/java/com/volmit/iris/util/stream/ArraySignificance.java +++ b/src/main/java/com/volmit/iris/util/stream/ArraySignificance.java @@ -36,8 +36,8 @@ public class ArraySignificance implements Significance { this.significance = significance; double s = 0; int v = 0; - for (int i = 0; i < significance.size(); i++) { - if (significance.get(i) > s) { + for(int i = 0; i < significance.size(); i++) { + if(significance.get(i) > s) { s = significance.get(i); v = i; } @@ -53,8 +53,8 @@ public class ArraySignificance implements Significance { @Override public double getSignificance(T t) { - for (int i = 0; i < types.size(); i++) { - if (types.get(i).equals(t)) { + for(int i = 0; i < types.size(); i++) { + if(types.get(i).equals(t)) { return significance.get(i); } } diff --git a/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java b/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java index 75dbd1cc1..4716e7b4a 100644 --- a/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java +++ b/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java @@ -29,7 +29,6 @@ import com.volmit.iris.util.function.Function3; import com.volmit.iris.util.function.Function4; import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.math.RNG; -import com.volmit.iris.util.reflect.V; import com.volmit.iris.util.stream.arithmetic.AddingStream; import com.volmit.iris.util.stream.arithmetic.ClampedStream; import com.volmit.iris.util.stream.arithmetic.CoordinateBitShiftLeftStream; @@ -67,14 +66,13 @@ import com.volmit.iris.util.stream.utility.SynchronizedStream; import java.util.ArrayList; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; @SuppressWarnings("ALL") public interface ProceduralStream extends ProceduralLayer, Interpolated { static ProceduralStream ofDouble(Function2 f) { try { return of(f, Interpolated.DOUBLE); - } catch (IncompatibleClassChangeError e) { + } catch(IncompatibleClassChangeError e) { Iris.warn(f.toString()); Iris.reportError(e); e.printStackTrace(); @@ -355,11 +353,11 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default ProceduralStream selectRarity(V... types) { KList rarityTypes = new KList<>(); int totalRarity = 0; - for (V i : types) { + for(V i : types) { totalRarity += IRare.get(i); } - for (V i : types) { + for(V i : types) { rarityTypes.addMultiple(i, totalRarity / IRare.get(i)); } @@ -381,11 +379,11 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default int countPossibilities(List types, Function loader) { KList rarityTypes = new KList<>(); int totalRarity = 0; - for (V i : types) { + for(V i : types) { totalRarity += IRare.get(loader.apply(i)); } - for (V i : types) { + for(V i : types) { rarityTypes.addMultiple(i, totalRarity / IRare.get(loader.apply(i))); } @@ -418,11 +416,11 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default void fill2D(Hunk h, double x, double z, V v, int parallelism) { h.compute2D(parallelism, (xx, __, zz, hh) -> { - for (int i = 0; i < hh.getWidth(); i++) { - for (int k = 0; k < hh.getDepth(); k++) { + for(int i = 0; i < hh.getWidth(); i++) { + for(int k = 0; k < hh.getDepth(); k++) { double n = getDouble(i + x + xx, k + z + zz); - for (int j = 0; j < Math.min(h.getHeight(), n); j++) { + for(int j = 0; j < Math.min(h.getHeight(), n); j++) { hh.set(i, j, k, v); } } @@ -433,11 +431,11 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default void fill2D(Hunk h, double x, double z, ProceduralStream v, int parallelism) { h.compute2D(parallelism, (xx, yy, zz, hh) -> { - for (int i = 0; i < hh.getWidth(); i++) { - for (int k = 0; k < hh.getDepth(); k++) { + for(int i = 0; i < hh.getWidth(); i++) { + for(int k = 0; k < hh.getDepth(); k++) { double n = getDouble(i + x + xx, k + z + zz); - for (int j = 0; j < Math.min(h.getHeight(), n); j++) { + for(int j = 0; j < Math.min(h.getHeight(), n); j++) { hh.set(i, j, k, v.get(i + x + xx, j + yy, k + z + zz)); } } @@ -448,11 +446,11 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default void fill2DYLocked(Hunk h, double x, double z, V v, int parallelism) { h.compute2D(parallelism, (xx, yy, zz, hh) -> { - for (int i = 0; i < hh.getWidth(); i++) { - for (int k = 0; k < hh.getDepth(); k++) { + for(int i = 0; i < hh.getWidth(); i++) { + for(int k = 0; k < hh.getDepth(); k++) { double n = getDouble(i + x + xx, k + z + zz); - for (int j = 0; j < Math.min(h.getHeight(), n); j++) { + for(int j = 0; j < Math.min(h.getHeight(), n); j++) { hh.set(i, j, k, v); } } @@ -463,11 +461,11 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default void fill2DYLocked(Hunk h, double x, double z, ProceduralStream v, int parallelism) { h.compute2D(parallelism, (xx, yy, zz, hh) -> { - for (int i = 0; i < hh.getWidth(); i++) { - for (int k = 0; k < hh.getDepth(); k++) { + for(int i = 0; i < hh.getWidth(); i++) { + for(int k = 0; k < hh.getDepth(); k++) { double n = getDouble(i + x + xx, k + z + zz); - for (int j = 0; j < Math.min(h.getHeight(), n); j++) { + for(int j = 0; j < Math.min(h.getHeight(), n); j++) { hh.set(i, j, k, v.get(i + x + xx, k + z + zz)); } } @@ -478,7 +476,7 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default void fill3D(Hunk h, double x, int y, double z, V v, int parallelism) { h.compute3D(parallelism, (xx, yy, zz, hh) -> hh.iterate((xv, yv, zv) -> { - if (getDouble(xx + xv + x, yy + yv + y, zz + zv + z) > 0.5) { + if(getDouble(xx + xv + x, yy + yv + y, zz + zv + z) > 0.5) { hh.set(xv, yv, zv, v); } })); @@ -487,7 +485,7 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { default void fill3D(Hunk h, double x, int y, double z, ProceduralStream v, int parallelism) { h.compute3D(parallelism, (xx, yy, zz, hh) -> hh.iterate((xv, yv, zv) -> { - if (getDouble(xx + xv + x, yy + yv + y, zz + zv + z) > 0.5) { + if(getDouble(xx + xv + x, yy + yv + y, zz + zv + z) > 0.5) { hh.set(xv, yv, zv, v.get(xx + xv + x, yy + yv + y, zz + zv + z)); } })); diff --git a/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream2D.java b/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream2D.java index e381c75bf..ba9399a72 100644 --- a/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream2D.java +++ b/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream2D.java @@ -34,7 +34,7 @@ public class AwareConversionStream2D extends BasicStream { @Override public double toDouble(V t) { - if (t instanceof Double) { + if(t instanceof Double) { return (Double) t; } diff --git a/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream3D.java b/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream3D.java index b4296c437..be7de5283 100644 --- a/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream3D.java +++ b/src/main/java/com/volmit/iris/util/stream/convert/AwareConversionStream3D.java @@ -34,7 +34,7 @@ public class AwareConversionStream3D extends BasicStream { @Override public double toDouble(V t) { - if (t instanceof Double) { + if(t instanceof Double) { return (Double) t; } diff --git a/src/main/java/com/volmit/iris/util/stream/convert/ConversionStream.java b/src/main/java/com/volmit/iris/util/stream/convert/ConversionStream.java index d46fb05c6..11a244432 100644 --- a/src/main/java/com/volmit/iris/util/stream/convert/ConversionStream.java +++ b/src/main/java/com/volmit/iris/util/stream/convert/ConversionStream.java @@ -35,7 +35,7 @@ public class ConversionStream extends BasicLayer implements ProceduralStre @Override public double toDouble(V t) { - if (t instanceof Double) { + if(t instanceof Double) { return (Double) t; } diff --git a/src/main/java/com/volmit/iris/util/stream/convert/ForceDoubleStream.java b/src/main/java/com/volmit/iris/util/stream/convert/ForceDoubleStream.java index 912db0533..cb3e6ee24 100644 --- a/src/main/java/com/volmit/iris/util/stream/convert/ForceDoubleStream.java +++ b/src/main/java/com/volmit/iris/util/stream/convert/ForceDoubleStream.java @@ -22,7 +22,7 @@ import com.volmit.iris.util.stream.BasicStream; import com.volmit.iris.util.stream.ProceduralStream; public class ForceDoubleStream extends BasicStream { - private ProceduralStream stream; + private final ProceduralStream stream; public ForceDoubleStream(ProceduralStream stream) { super(null); diff --git a/src/main/java/com/volmit/iris/util/stream/convert/SelectionStream.java b/src/main/java/com/volmit/iris/util/stream/convert/SelectionStream.java index ec32af1aa..2549cce27 100644 --- a/src/main/java/com/volmit/iris/util/stream/convert/SelectionStream.java +++ b/src/main/java/com/volmit/iris/util/stream/convert/SelectionStream.java @@ -50,7 +50,7 @@ public class SelectionStream extends BasicStream { @Override public T get(double x, double z) { - if (options.length == 0) { + if(options.length == 0) { return null; } @@ -59,7 +59,7 @@ public class SelectionStream extends BasicStream { @Override public T get(double x, double y, double z) { - if (options.length == 0) { + if(options.length == 0) { return null; } diff --git a/src/main/java/com/volmit/iris/util/stream/convert/SignificanceStream.java b/src/main/java/com/volmit/iris/util/stream/convert/SignificanceStream.java index f617bbac5..f93d99869 100644 --- a/src/main/java/com/volmit/iris/util/stream/convert/SignificanceStream.java +++ b/src/main/java/com/volmit/iris/util/stream/convert/SignificanceStream.java @@ -55,14 +55,14 @@ public class SignificanceStream, T> extends BasicStrea double m = (360d / checks); double v = 0; - for (int i = 0; i < 360; i += m) { + for(int i = 0; i < 360; i += m) { double sin = Math.sin(Math.toRadians(i)); double cos = Math.cos(Math.toRadians(i)); double cx = x + ((radius * cos) - (radius * sin)); double cz = z + ((radius * sin) + (radius * cos)); T t = stream.get(cx, cz); - if (ke.addIfMissing(t)) { + if(ke.addIfMissing(t)) { va.add(1D); v++; } else { @@ -71,7 +71,7 @@ public class SignificanceStream, T> extends BasicStrea } } - for (int i = 0; i < va.size(); i++) { + for(int i = 0; i < va.size(); i++) { va.set(i, va.get(i) / v); } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/BiHermiteStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/BiHermiteStream.java index b127443c1..06d2a8ce8 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/BiHermiteStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/BiHermiteStream.java @@ -56,23 +56,23 @@ public class BiHermiteStream extends BasicStream implements Interpolator extends BasicStream implements Interpolator< double m = (360D / checks); double v = 0; - for (int i = 0; i < 360; i += m) { + for(int i = 0; i < 360; i += m) { double sin = Math.sin(Math.toRadians(i)); double cos = Math.cos(Math.toRadians(i)); double cx = x + ((rad * cos) - (rad * sin)); diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/BicubicStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/BicubicStream.java index 5794b2fe0..caa7c3ac6 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/BicubicStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/BicubicStream.java @@ -48,23 +48,23 @@ public class BicubicStream extends BasicStream implements Interpolator //@builder return getTypedSource().fromDouble(IrisInterpolation.bicubic( - getTypedSource().getDouble(x0, z0), - getTypedSource().getDouble(x0, z1), - getTypedSource().getDouble(x0, z2), - getTypedSource().getDouble(x0, z3), - getTypedSource().getDouble(x1, z0), - getTypedSource().getDouble(x1, z1), - getTypedSource().getDouble(x1, z2), - getTypedSource().getDouble(x1, z3), - getTypedSource().getDouble(x2, z0), - getTypedSource().getDouble(x2, z1), - getTypedSource().getDouble(x2, z2), - getTypedSource().getDouble(x2, z3), - getTypedSource().getDouble(x3, z0), - getTypedSource().getDouble(x3, z1), - getTypedSource().getDouble(x3, z2), - getTypedSource().getDouble(x3, z3), - px, pz)); + getTypedSource().getDouble(x0, z0), + getTypedSource().getDouble(x0, z1), + getTypedSource().getDouble(x0, z2), + getTypedSource().getDouble(x0, z3), + getTypedSource().getDouble(x1, z0), + getTypedSource().getDouble(x1, z1), + getTypedSource().getDouble(x1, z2), + getTypedSource().getDouble(x1, z3), + getTypedSource().getDouble(x2, z0), + getTypedSource().getDouble(x2, z1), + getTypedSource().getDouble(x2, z2), + getTypedSource().getDouble(x2, z3), + getTypedSource().getDouble(x3, z0), + getTypedSource().getDouble(x3, z1), + getTypedSource().getDouble(x3, z2), + getTypedSource().getDouble(x3, z3), + px, pz)); //@done } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/BilinearStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/BilinearStream.java index 623b3618e..5c09fde36 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/BilinearStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/BilinearStream.java @@ -44,11 +44,11 @@ public class BilinearStream extends BasicStream implements Interpolator //@builder return getTypedSource().fromDouble(IrisInterpolation.blerp( - getTypedSource().getDouble(x1, z1), - getTypedSource().getDouble(x2, z1), - getTypedSource().getDouble(x1, z2), - getTypedSource().getDouble(x2, z2), - px, pz)); + getTypedSource().getDouble(x1, z1), + getTypedSource().getDouble(x2, z1), + getTypedSource().getDouble(x1, z2), + getTypedSource().getDouble(x2, z2), + px, pz)); //@done } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolated.java b/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolated.java index d8d4d6f63..3970ef835 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolated.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolated.java @@ -58,7 +58,7 @@ public interface Interpolated { T fromDouble(double d); default InterpolatorFactory interpolate() { - if (this instanceof ProceduralStream) { + if(this instanceof ProceduralStream) { return new InterpolatorFactory<>((ProceduralStream) this); } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolator.java b/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolator.java index fb22cc38c..0e4482128 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolator.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/Interpolator.java @@ -23,7 +23,7 @@ import com.volmit.iris.util.stream.ProceduralStream; public interface Interpolator { @SuppressWarnings("unchecked") default InterpolatorFactory into() { - if (this instanceof ProceduralStream) { + if(this instanceof ProceduralStream) { return new InterpolatorFactory<>((ProceduralStream) this); } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/TriHermiteStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/TriHermiteStream.java index 0414c6898..218686db9 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/TriHermiteStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/TriHermiteStream.java @@ -60,71 +60,71 @@ public class TriHermiteStream extends BasicStream implements Interpolator< //@builder return getTypedSource().fromDouble(IrisInterpolation.trihermite( - getTypedSource().getDouble(x0, y0, z0), - getTypedSource().getDouble(x0, y0, z1), - getTypedSource().getDouble(x0, y0, z2), - getTypedSource().getDouble(x0, y0, z3), - getTypedSource().getDouble(x1, y0, z0), - getTypedSource().getDouble(x1, y0, z1), - getTypedSource().getDouble(x1, y0, z2), - getTypedSource().getDouble(x1, y0, z3), - getTypedSource().getDouble(x2, y0, z0), - getTypedSource().getDouble(x2, y0, z1), - getTypedSource().getDouble(x2, y0, z2), - getTypedSource().getDouble(x2, y0, z3), - getTypedSource().getDouble(x3, y0, z0), - getTypedSource().getDouble(x3, y0, z1), - getTypedSource().getDouble(x3, y0, z2), - getTypedSource().getDouble(x3, y0, z3), - getTypedSource().getDouble(x0, y1, z0), - getTypedSource().getDouble(x0, y1, z1), - getTypedSource().getDouble(x0, y1, z2), - getTypedSource().getDouble(x0, y1, z3), - getTypedSource().getDouble(x1, y1, z0), - getTypedSource().getDouble(x1, y1, z1), - getTypedSource().getDouble(x1, y1, z2), - getTypedSource().getDouble(x1, y1, z3), - getTypedSource().getDouble(x2, y1, z0), - getTypedSource().getDouble(x2, y1, z1), - getTypedSource().getDouble(x2, y1, z2), - getTypedSource().getDouble(x2, y1, z3), - getTypedSource().getDouble(x3, y1, z0), - getTypedSource().getDouble(x3, y1, z1), - getTypedSource().getDouble(x3, y1, z2), - getTypedSource().getDouble(x3, y1, z3), - getTypedSource().getDouble(x0, y2, z0), - getTypedSource().getDouble(x0, y2, z1), - getTypedSource().getDouble(x0, y2, z2), - getTypedSource().getDouble(x0, y2, z3), - getTypedSource().getDouble(x1, y2, z0), - getTypedSource().getDouble(x1, y2, z1), - getTypedSource().getDouble(x1, y2, z2), - getTypedSource().getDouble(x1, y2, z3), - getTypedSource().getDouble(x2, y2, z0), - getTypedSource().getDouble(x2, y2, z1), - getTypedSource().getDouble(x2, y2, z2), - getTypedSource().getDouble(x2, y2, z3), - getTypedSource().getDouble(x3, y2, z0), - getTypedSource().getDouble(x3, y2, z1), - getTypedSource().getDouble(x3, y2, z2), - getTypedSource().getDouble(x3, y2, z3), - getTypedSource().getDouble(x0, y3, z0), - getTypedSource().getDouble(x0, y3, z1), - getTypedSource().getDouble(x0, y3, z2), - getTypedSource().getDouble(x0, y3, z3), - getTypedSource().getDouble(x1, y3, z0), - getTypedSource().getDouble(x1, y3, z1), - getTypedSource().getDouble(x1, y3, z2), - getTypedSource().getDouble(x1, y3, z3), - getTypedSource().getDouble(x2, y3, z0), - getTypedSource().getDouble(x2, y3, z1), - getTypedSource().getDouble(x2, y3, z2), - getTypedSource().getDouble(x2, y3, z3), - getTypedSource().getDouble(x3, y3, z0), - getTypedSource().getDouble(x3, y3, z1), - getTypedSource().getDouble(x3, y3, z2), - getTypedSource().getDouble(x3, y3, z3), - px, pz, py, tension, bias)); + getTypedSource().getDouble(x0, y0, z0), + getTypedSource().getDouble(x0, y0, z1), + getTypedSource().getDouble(x0, y0, z2), + getTypedSource().getDouble(x0, y0, z3), + getTypedSource().getDouble(x1, y0, z0), + getTypedSource().getDouble(x1, y0, z1), + getTypedSource().getDouble(x1, y0, z2), + getTypedSource().getDouble(x1, y0, z3), + getTypedSource().getDouble(x2, y0, z0), + getTypedSource().getDouble(x2, y0, z1), + getTypedSource().getDouble(x2, y0, z2), + getTypedSource().getDouble(x2, y0, z3), + getTypedSource().getDouble(x3, y0, z0), + getTypedSource().getDouble(x3, y0, z1), + getTypedSource().getDouble(x3, y0, z2), + getTypedSource().getDouble(x3, y0, z3), + getTypedSource().getDouble(x0, y1, z0), + getTypedSource().getDouble(x0, y1, z1), + getTypedSource().getDouble(x0, y1, z2), + getTypedSource().getDouble(x0, y1, z3), + getTypedSource().getDouble(x1, y1, z0), + getTypedSource().getDouble(x1, y1, z1), + getTypedSource().getDouble(x1, y1, z2), + getTypedSource().getDouble(x1, y1, z3), + getTypedSource().getDouble(x2, y1, z0), + getTypedSource().getDouble(x2, y1, z1), + getTypedSource().getDouble(x2, y1, z2), + getTypedSource().getDouble(x2, y1, z3), + getTypedSource().getDouble(x3, y1, z0), + getTypedSource().getDouble(x3, y1, z1), + getTypedSource().getDouble(x3, y1, z2), + getTypedSource().getDouble(x3, y1, z3), + getTypedSource().getDouble(x0, y2, z0), + getTypedSource().getDouble(x0, y2, z1), + getTypedSource().getDouble(x0, y2, z2), + getTypedSource().getDouble(x0, y2, z3), + getTypedSource().getDouble(x1, y2, z0), + getTypedSource().getDouble(x1, y2, z1), + getTypedSource().getDouble(x1, y2, z2), + getTypedSource().getDouble(x1, y2, z3), + getTypedSource().getDouble(x2, y2, z0), + getTypedSource().getDouble(x2, y2, z1), + getTypedSource().getDouble(x2, y2, z2), + getTypedSource().getDouble(x2, y2, z3), + getTypedSource().getDouble(x3, y2, z0), + getTypedSource().getDouble(x3, y2, z1), + getTypedSource().getDouble(x3, y2, z2), + getTypedSource().getDouble(x3, y2, z3), + getTypedSource().getDouble(x0, y3, z0), + getTypedSource().getDouble(x0, y3, z1), + getTypedSource().getDouble(x0, y3, z2), + getTypedSource().getDouble(x0, y3, z3), + getTypedSource().getDouble(x1, y3, z0), + getTypedSource().getDouble(x1, y3, z1), + getTypedSource().getDouble(x1, y3, z2), + getTypedSource().getDouble(x1, y3, z3), + getTypedSource().getDouble(x2, y3, z0), + getTypedSource().getDouble(x2, y3, z1), + getTypedSource().getDouble(x2, y3, z2), + getTypedSource().getDouble(x2, y3, z3), + getTypedSource().getDouble(x3, y3, z0), + getTypedSource().getDouble(x3, y3, z1), + getTypedSource().getDouble(x3, y3, z2), + getTypedSource().getDouble(x3, y3, z3), + px, pz, py, tension, bias)); //@done } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/TriStarcastStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/TriStarcastStream.java index 0921a8062..75470b650 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/TriStarcastStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/TriStarcastStream.java @@ -35,7 +35,7 @@ public class TriStarcastStream extends BasicStream implements Interpolator double m = (360D / checks); double v = 0; - for (int i = 0; i < 360; i += m) { + for(int i = 0; i < 360; i += m) { double sin = Math.sin(Math.toRadians(i)); double cos = Math.cos(Math.toRadians(i)); double cx = x + ((rad * cos) - (rad * sin)); diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/TricubicStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/TricubicStream.java index e629f01ad..4b392137e 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/TricubicStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/TricubicStream.java @@ -56,74 +56,74 @@ public class TricubicStream extends BasicStream implements Interpolator //@builder return getTypedSource().fromDouble(IrisInterpolation.tricubic( - getTypedSource().getDouble(x0, y0, z0), - getTypedSource().getDouble(x0, y0, z1), - getTypedSource().getDouble(x0, y0, z2), - getTypedSource().getDouble(x0, y0, z3), - getTypedSource().getDouble(x1, y0, z0), - getTypedSource().getDouble(x1, y0, z1), - getTypedSource().getDouble(x1, y0, z2), - getTypedSource().getDouble(x1, y0, z3), - getTypedSource().getDouble(x2, y0, z0), - getTypedSource().getDouble(x2, y0, z1), - getTypedSource().getDouble(x2, y0, z2), - getTypedSource().getDouble(x2, y0, z3), - getTypedSource().getDouble(x3, y0, z0), - getTypedSource().getDouble(x3, y0, z1), - getTypedSource().getDouble(x3, y0, z2), - getTypedSource().getDouble(x3, y0, z3), + getTypedSource().getDouble(x0, y0, z0), + getTypedSource().getDouble(x0, y0, z1), + getTypedSource().getDouble(x0, y0, z2), + getTypedSource().getDouble(x0, y0, z3), + getTypedSource().getDouble(x1, y0, z0), + getTypedSource().getDouble(x1, y0, z1), + getTypedSource().getDouble(x1, y0, z2), + getTypedSource().getDouble(x1, y0, z3), + getTypedSource().getDouble(x2, y0, z0), + getTypedSource().getDouble(x2, y0, z1), + getTypedSource().getDouble(x2, y0, z2), + getTypedSource().getDouble(x2, y0, z3), + getTypedSource().getDouble(x3, y0, z0), + getTypedSource().getDouble(x3, y0, z1), + getTypedSource().getDouble(x3, y0, z2), + getTypedSource().getDouble(x3, y0, z3), - getTypedSource().getDouble(x0, y1, z0), - getTypedSource().getDouble(x0, y1, z1), - getTypedSource().getDouble(x0, y1, z2), - getTypedSource().getDouble(x0, y1, z3), - getTypedSource().getDouble(x1, y1, z0), - getTypedSource().getDouble(x1, y1, z1), - getTypedSource().getDouble(x1, y1, z2), - getTypedSource().getDouble(x1, y1, z3), - getTypedSource().getDouble(x2, y1, z0), - getTypedSource().getDouble(x2, y1, z1), - getTypedSource().getDouble(x2, y1, z2), - getTypedSource().getDouble(x2, y1, z3), - getTypedSource().getDouble(x3, y1, z0), - getTypedSource().getDouble(x3, y1, z1), - getTypedSource().getDouble(x3, y1, z2), - getTypedSource().getDouble(x3, y1, z3), + getTypedSource().getDouble(x0, y1, z0), + getTypedSource().getDouble(x0, y1, z1), + getTypedSource().getDouble(x0, y1, z2), + getTypedSource().getDouble(x0, y1, z3), + getTypedSource().getDouble(x1, y1, z0), + getTypedSource().getDouble(x1, y1, z1), + getTypedSource().getDouble(x1, y1, z2), + getTypedSource().getDouble(x1, y1, z3), + getTypedSource().getDouble(x2, y1, z0), + getTypedSource().getDouble(x2, y1, z1), + getTypedSource().getDouble(x2, y1, z2), + getTypedSource().getDouble(x2, y1, z3), + getTypedSource().getDouble(x3, y1, z0), + getTypedSource().getDouble(x3, y1, z1), + getTypedSource().getDouble(x3, y1, z2), + getTypedSource().getDouble(x3, y1, z3), - getTypedSource().getDouble(x0, y2, z0), - getTypedSource().getDouble(x0, y2, z1), - getTypedSource().getDouble(x0, y2, z2), - getTypedSource().getDouble(x0, y2, z3), - getTypedSource().getDouble(x1, y2, z0), - getTypedSource().getDouble(x1, y2, z1), - getTypedSource().getDouble(x1, y2, z2), - getTypedSource().getDouble(x1, y2, z3), - getTypedSource().getDouble(x2, y2, z0), - getTypedSource().getDouble(x2, y2, z1), - getTypedSource().getDouble(x2, y2, z2), - getTypedSource().getDouble(x2, y2, z3), - getTypedSource().getDouble(x3, y2, z0), - getTypedSource().getDouble(x3, y2, z1), - getTypedSource().getDouble(x3, y2, z2), - getTypedSource().getDouble(x3, y2, z3), + getTypedSource().getDouble(x0, y2, z0), + getTypedSource().getDouble(x0, y2, z1), + getTypedSource().getDouble(x0, y2, z2), + getTypedSource().getDouble(x0, y2, z3), + getTypedSource().getDouble(x1, y2, z0), + getTypedSource().getDouble(x1, y2, z1), + getTypedSource().getDouble(x1, y2, z2), + getTypedSource().getDouble(x1, y2, z3), + getTypedSource().getDouble(x2, y2, z0), + getTypedSource().getDouble(x2, y2, z1), + getTypedSource().getDouble(x2, y2, z2), + getTypedSource().getDouble(x2, y2, z3), + getTypedSource().getDouble(x3, y2, z0), + getTypedSource().getDouble(x3, y2, z1), + getTypedSource().getDouble(x3, y2, z2), + getTypedSource().getDouble(x3, y2, z3), - getTypedSource().getDouble(x0, y3, z0), - getTypedSource().getDouble(x0, y3, z1), - getTypedSource().getDouble(x0, y3, z2), - getTypedSource().getDouble(x0, y3, z3), - getTypedSource().getDouble(x1, y3, z0), - getTypedSource().getDouble(x1, y3, z1), - getTypedSource().getDouble(x1, y3, z2), - getTypedSource().getDouble(x1, y3, z3), - getTypedSource().getDouble(x2, y3, z0), - getTypedSource().getDouble(x2, y3, z1), - getTypedSource().getDouble(x2, y3, z2), - getTypedSource().getDouble(x2, y3, z3), - getTypedSource().getDouble(x3, y3, z0), - getTypedSource().getDouble(x3, y3, z1), - getTypedSource().getDouble(x3, y3, z2), - getTypedSource().getDouble(x3, y3, z3), - px, pz, py)); + getTypedSource().getDouble(x0, y3, z0), + getTypedSource().getDouble(x0, y3, z1), + getTypedSource().getDouble(x0, y3, z2), + getTypedSource().getDouble(x0, y3, z3), + getTypedSource().getDouble(x1, y3, z0), + getTypedSource().getDouble(x1, y3, z1), + getTypedSource().getDouble(x1, y3, z2), + getTypedSource().getDouble(x1, y3, z3), + getTypedSource().getDouble(x2, y3, z0), + getTypedSource().getDouble(x2, y3, z1), + getTypedSource().getDouble(x2, y3, z2), + getTypedSource().getDouble(x2, y3, z3), + getTypedSource().getDouble(x3, y3, z0), + getTypedSource().getDouble(x3, y3, z1), + getTypedSource().getDouble(x3, y3, z2), + getTypedSource().getDouble(x3, y3, z3), + px, pz, py)); //@done } diff --git a/src/main/java/com/volmit/iris/util/stream/interpolation/TrilinearStream.java b/src/main/java/com/volmit/iris/util/stream/interpolation/TrilinearStream.java index a92075443..5bebba979 100644 --- a/src/main/java/com/volmit/iris/util/stream/interpolation/TrilinearStream.java +++ b/src/main/java/com/volmit/iris/util/stream/interpolation/TrilinearStream.java @@ -50,15 +50,15 @@ public class TrilinearStream extends BasicStream implements Interpolator extends BasicStream implements ProceduralStrea public T get(double x, double z) { T t = stream.get(x, z); - if (t == null) { + if(t == null) { return ifNull; } @@ -56,7 +56,7 @@ public class NullSafeStream extends BasicStream implements ProceduralStrea public T get(double x, double y, double z) { T t = stream.get(x, y, z); - if (t == null) { + if(t == null) { return ifNull; } diff --git a/src/main/java/com/volmit/iris/util/stream/utility/ProfiledStream.java b/src/main/java/com/volmit/iris/util/stream/utility/ProfiledStream.java index ef900bc23..40a8a1a35 100644 --- a/src/main/java/com/volmit/iris/util/stream/utility/ProfiledStream.java +++ b/src/main/java/com/volmit/iris/util/stream/utility/ProfiledStream.java @@ -44,7 +44,7 @@ public class ProfiledStream extends BasicStream { public static void print(Consumer printer, ProceduralStream stream) { KList tails = getTails(stream); int ind = tails.size(); - for (ProfiledTail i : tails) { + for(ProfiledTail i : tails) { printer.accept(Form.repeat(" ", ind) + i); ind--; } @@ -54,11 +54,11 @@ public class ProfiledStream extends BasicStream { KList> v = new KList<>(); ProceduralStream cursor = s; - for (int i = 0; i < 32; i++) { + for(int i = 0; i < 32; i++) { v.add(cursor); cursor = nextChuld(cursor); - if (cursor == null) { + if(cursor == null) { break; } } @@ -72,7 +72,7 @@ public class ProfiledStream extends BasicStream { } private static ProfiledTail getTail(ProceduralStream t) { - if (t instanceof ProfiledStream s) { + if(t instanceof ProfiledStream s) { return new ProfiledTail(s.getId(), s.getMetrics(), s.getClass().getSimpleName().replaceAll("\\QStream\\E", "")); } @@ -83,15 +83,15 @@ public class ProfiledStream extends BasicStream { private static KList getTails(ProceduralStream t) { KList tails = new KList<>(); - for (ProceduralStream v : getAllChildren(t)) { + for(ProceduralStream v : getAllChildren(t)) { ProfiledTail p = getTail(v); - if (p != null) { + if(p != null) { tails.add(p); } } - if (tails.isEmpty()) { + if(tails.isEmpty()) { return null; } @@ -99,7 +99,7 @@ public class ProfiledStream extends BasicStream { KList tailx = new KList<>(); tailx.add(cursor); - while (tails.isNotEmpty()) { + while(tails.isNotEmpty()) { tailx.add(cursor); ProfiledTail parent = tails.popLast(); parent.setChild(cursor); @@ -130,7 +130,7 @@ public class ProfiledStream extends BasicStream { T t = getTypedSource().get(x, z); try { metrics.put(p.getMilliseconds()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } @@ -143,7 +143,7 @@ public class ProfiledStream extends BasicStream { T t = getTypedSource().get(x, y, z); try { metrics.put(p.getMilliseconds()); - } catch (Throwable e) { + } catch(Throwable e) { Iris.reportError(e); } diff --git a/src/main/java/com/volmit/iris/util/stream/utility/SemaphoreStream.java b/src/main/java/com/volmit/iris/util/stream/utility/SemaphoreStream.java index 548224df2..7a8bc77e1 100644 --- a/src/main/java/com/volmit/iris/util/stream/utility/SemaphoreStream.java +++ b/src/main/java/com/volmit/iris/util/stream/utility/SemaphoreStream.java @@ -43,14 +43,14 @@ public class SemaphoreStream extends BasicStream { @Override public T get(double x, double z) { - synchronized (getTypedSource()) { + synchronized(getTypedSource()) { return getTypedSource().get(x, z); } } @Override public T get(double x, double y, double z) { - synchronized (getTypedSource()) { + synchronized(getTypedSource()) { return getTypedSource().get(x, y, z); } } diff --git a/src/main/java/com/volmit/iris/util/stream/utility/SynchronizedStream.java b/src/main/java/com/volmit/iris/util/stream/utility/SynchronizedStream.java index 43cd14e9e..86d14adc9 100644 --- a/src/main/java/com/volmit/iris/util/stream/utility/SynchronizedStream.java +++ b/src/main/java/com/volmit/iris/util/stream/utility/SynchronizedStream.java @@ -38,14 +38,14 @@ public class SynchronizedStream extends BasicStream { @Override public T get(double x, double z) { - synchronized (getTypedSource()) { + synchronized(getTypedSource()) { return getTypedSource().get(x, z); } } @Override public T get(double x, double y, double z) { - synchronized (getTypedSource()) { + synchronized(getTypedSource()) { return getTypedSource().get(x, y, z); } } From cdb419c3f1b2438a3f0ad7025195856f5cbef1c1 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 06:24:26 -0500 Subject: [PATCH 27/42] Fixes --- .../engine/actuator/IrisBiomeActuator.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java index ff3a21938..922c41c44 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java @@ -25,17 +25,20 @@ import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiomeCustom; +import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.view.BiomeGridHunkView; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.parallel.BurstExecutor; +import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch; import org.bukkit.block.Biome; import org.bukkit.generator.ChunkGenerator; public class IrisBiomeActuator extends EngineAssignedActuator { private final RNG rng; + private final ChronoLatch cl = new ChronoLatch(5000); public IrisBiomeActuator(Engine engine) { super(engine, "Biome"); @@ -78,6 +81,15 @@ public class IrisBiomeActuator extends EngineAssignedActuator { try { IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z); Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey() + ":" + custom.getId()); +// +// int m = hits.size(); +// String str = ib.getLoadKey() + ":custom:" + custom.getId(); +// hits.add(str); +// +// if(m != hits.size()) +// { +// Iris.info("Added " + str); +// } if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) { throw new RuntimeException("Cant inject biome!"); @@ -95,8 +107,17 @@ public class IrisBiomeActuator extends EngineAssignedActuator { } } else { Biome v = ib.getSkyBiome(rng, x, 0, z); - for(int i = 0; i < maxHeight; i++) { - h.set(finalXf, i, zf, v); + + if(v != null) + { + for(int i = 0; i < maxHeight; i++) { + h.set(finalXf, i, zf, v); + } + } + + else if(cl.flip()) + { + Iris.error("No biome provided for " + ib.getLoadKey()); } } } From 732e04925235c1699696ed55de2ea1d3053fffb8 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 07:18:23 -0500 Subject: [PATCH 28/42] Height command check info --- .../java/com/volmit/iris/core/commands/CommandIris.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/volmit/iris/core/commands/CommandIris.java b/src/main/java/com/volmit/iris/core/commands/CommandIris.java index 73948cd38..7310f1f43 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -101,6 +101,12 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); } + @Decree(description = "Print version information", origin = DecreeOrigin.PLAYER) + public void height() { + sender().sendMessage(C.GREEN + "" + sender().player().getWorld().getMinHeight() + " to " + sender().player().getWorld().getMaxHeight()); + sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight())); + } + @Decree(description = "Set aura spins") public void aura( @Param(description = "The h color value", defaultValue = "-20") From 369b125c52bbab1b882b5afcba8452b8a2030bba Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 07:23:08 -0500 Subject: [PATCH 29/42] Scoreboard min height patch --- src/main/java/com/volmit/iris/core/service/BoardSVC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/core/service/BoardSVC.java b/src/main/java/com/volmit/iris/core/service/BoardSVC.java index 72c020479..50f7caa9d 100644 --- a/src/main/java/com/volmit/iris/core/service/BoardSVC.java +++ b/src/main/java/com/volmit/iris/core/service/BoardSVC.java @@ -131,7 +131,7 @@ public class BoardSVC implements IrisService, BoardProvider { lines.add("&7&m "); lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName()); - lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z))); + lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z) + engine.getWorld().minHeight())); lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2)); lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond())); lines.add("&7&m "); From 6b5d4fc5571077819229d6e3c5a877ae5cf78c87 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 07:32:59 -0500 Subject: [PATCH 30/42] ? --- src/main/java/com/volmit/iris/core/service/BoardSVC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/core/service/BoardSVC.java b/src/main/java/com/volmit/iris/core/service/BoardSVC.java index 50f7caa9d..4ecfc0f9b 100644 --- a/src/main/java/com/volmit/iris/core/service/BoardSVC.java +++ b/src/main/java/com/volmit/iris/core/service/BoardSVC.java @@ -131,7 +131,7 @@ public class BoardSVC implements IrisService, BoardProvider { lines.add("&7&m "); lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName()); - lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z) + engine.getWorld().minHeight())); + lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z) + player.getWorld().getMinHeight())); lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2)); lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond())); lines.add("&7&m "); From 5fa1efb1f27d6e6251b2ea701eabedabea4b0af9 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:01:26 -0500 Subject: [PATCH 31/42] Fix by id nms --- .../iris/core/nms/v18_1/NMSBinding18_1.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index fabf939d2..0cda4e8e3 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -35,8 +35,10 @@ import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer; import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; import com.volmit.iris.util.nbt.tag.CompoundTag; +import com.volmit.iris.util.scheduling.J; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.core.BlockPos; +import net.minecraft.core.IdMap; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.NbtIo; @@ -63,7 +65,9 @@ import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -76,6 +80,7 @@ public class NMSBinding18_1 implements INMSBinding { private final AtomicCache> registryCache = new AtomicCache<>(); private final AtomicCache> globalCache = new AtomicCache<>(); private final AtomicCache registryAccess = new AtomicCache<>(); + private final AtomicCache byIdRef = new AtomicCache<>(); private Field biomeStorageCache = null; @Override @@ -159,7 +164,25 @@ public class NMSBinding18_1 implements INMSBinding { @Override public Object getBiomeBaseFromId(int id) { - return getCustomBiomeRegistry().byId(id); + try { + return byIdRef.aquire(() -> { + for(Method i : IdMap.class.getDeclaredMethods()) + { + if(i.getParameterCount() == 1 && i.getParameterTypes()[0].equals(int.class)) + { + Iris.info("[NMS] Found byId method in " + IdMap.class.getSimpleName() + "." + i.getName() + "(int) => " + Biome.class.getSimpleName()); + return i; + } + } + + Iris.error("Cannot find byId method!"); + return null; + }).invoke(getCustomBiomeRegistry(), id); + } catch(IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + + return null; } @Override @@ -254,7 +277,7 @@ public class NMSBinding18_1 implements INMSBinding { @Override public net.minecraft.world.level.biome.Biome byId(int paramInt) { - return getCustomBiomeRegistry().byId(paramInt); + return (net.minecraft.world.level.biome.Biome) getBiomeBaseFromId(paramInt); } }); } From 6c2b65055b0bb71546095383efa9f0e2abd8874f Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:12:19 -0500 Subject: [PATCH 32/42] Support negative MCA file sections --- .../com/volmit/iris/util/nbt/mca/Chunk.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java b/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java index 4ba38653b..83dba6f87 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java @@ -20,6 +20,7 @@ package com.volmit.iris.util.nbt.mca; import com.volmit.iris.Iris; import com.volmit.iris.core.nms.INMS; +import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.nbt.io.NBTDeserializer; import com.volmit.iris.util.nbt.io.NBTSerializer; import com.volmit.iris.util.nbt.io.NamedTag; @@ -39,7 +40,7 @@ import static com.volmit.iris.util.nbt.mca.LoadFlags.*; public class Chunk { public static final int DEFAULT_DATA_VERSION = 2730; - private final AtomicReferenceArray
sections = new AtomicReferenceArray<>(16); + private final KMap sections = new KMap<>(); private boolean partial; private int lastMCAUpdate; private CompoundTag data; @@ -151,7 +152,7 @@ public class Chunk { if(newSection.isEmpty()) { continue; } - sections.set(sectionIndex, newSection); + sections.put(sectionIndex, newSection); } } @@ -272,10 +273,6 @@ public class Chunk { public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) { int s = MCAUtil.blockToChunk(blockY); - if(sections.length() <= s) { - return null; - } - Section section = sections.get(s); if(section == null) { return null; @@ -303,14 +300,10 @@ public class Chunk { public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) { int sectionIndex = MCAUtil.blockToChunk(blockY); - if(sections.length() <= sectionIndex) { - return; - } - Section section = sections.get(sectionIndex); if(section == null) { section = Section.newSection(); - sections.set(sectionIndex, section); + sections.put(sectionIndex, section); } section.setBlockStateAt(blockX, blockY, blockZ, state, cleanup); } @@ -387,7 +380,7 @@ public class Chunk { * The section to be set. */ public void setSection(int sectionY, Section section) { - sections.set(sectionY, section); + sections.put(sectionY, section); } /** @@ -616,8 +609,7 @@ public class Chunk { } public void cleanupPalettesAndBlockStates() { - for(int i = 0; i < sections.length(); i++) { - Section section = sections.get(i); + for(Section section : sections.values()) { if(section != null) { section.cleanupPaletteAndBlockStates(); } @@ -645,16 +637,19 @@ public class Chunk { level.putString("Status", status); if(structures != null) level.put("Structures", structures); ListTag sections = new ListTag<>(CompoundTag.class); - for(int i = 0; i < this.sections.length(); i++) { + + for(int i : this.sections.keySet()) + { if(this.sections.get(i) != null) { sections.add(this.sections.get(i).updateHandle(i)); } } + level.put("Sections", sections); return data; } public int sectionCount() { - return sections.length(); + return sections.size(); } } From f9e3d96673816ce99c73fd47c32a8b302d2432dd Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:17:14 -0500 Subject: [PATCH 33/42] New default heights --- .../com/volmit/iris/core/tools/IrisWorldCreator.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java b/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java index 6322e76f5..13aee2ac5 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java @@ -33,8 +33,8 @@ public class IrisWorldCreator { private boolean studio = false; private String dimensionName = null; private long seed = 1337; - private int maxHeight = 256; - private int minHeight = 0; + private int maxHeight = 320; + private int minHeight = -64; public IrisWorldCreator() { @@ -45,12 +45,6 @@ public class IrisWorldCreator { return this; } - public IrisWorldCreator height(int maxHeight) { - this.maxHeight = maxHeight; - this.minHeight = 0; - return this; - } - public IrisWorldCreator height(int minHeight, int maxHeight) { this.maxHeight = maxHeight; this.minHeight = minHeight; From b220db9d8535f9ecf4ff18c202bd7a06e0c1dff5 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:17:28 -0500 Subject: [PATCH 34/42] Terrain chunk fixes --- .../volmit/iris/engine/data/chunk/MCATerrainChunk.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java index 89e7bd947..f664b81f8 100644 --- a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java +++ b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java @@ -81,8 +81,8 @@ public class MCATerrainChunk implements TerrainChunk { int xx = (x + ox) & 15; int zz = (z + oz) & 15; - if(y > 255 || y < 0) { - return; + if(y > getMaxHeight() || y < getMinHeight()) { + return; } if(blockData == null) { @@ -98,8 +98,8 @@ public class MCATerrainChunk implements TerrainChunk { y = getMaxHeight(); } - if(y < 0) { - y = 0; + if(y < getMinHeight()) { + y = getMinHeight(); } return NBTWorld.getBlockData(mcaChunk.getBlockStateAt((x + ox) & 15, y, (z + oz) & 15)); From c9c2deae1a33d9ad5ac8e7a042d46f813cab7c10 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:17:36 -0500 Subject: [PATCH 35/42] Headless default heights --- .../java/com/volmit/iris/engine/object/HeadlessWorld.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java b/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java index 3e8876dab..8e615ec98 100644 --- a/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java +++ b/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java @@ -53,8 +53,8 @@ public class HeadlessWorld { .environment(dimension.getEnvironment()) .worldFolder(new File(worldName)) .seed(seed) - .maxHeight(256) - .minHeight(0) + .maxHeight(320) + .minHeight(-64) .name(worldName) .build(); world.worldFolder().mkdirs(); From 5144a2a2dfcc934403e306aedd22815f1a158cfd Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:17:45 -0500 Subject: [PATCH 36/42] Default heights for world --- src/main/java/com/volmit/iris/Iris.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 9c6536c58..b83d820cd 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -607,8 +607,8 @@ public class Iris extends VolmitPlugin implements Listener { .seed(1337) .environment(dim.getEnvironment()) .worldFolder(new File(worldName)) - .minHeight(0) - .maxHeight(256) + .minHeight(-64) + .maxHeight(320) .build(); Iris.debug("Generator Config: " + w.toString()); From 9f1aa916e43213e7f8d4ff5e65430d769460a9d3 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:23:58 -0500 Subject: [PATCH 37/42] Configurable world heights --- .../com/volmit/iris/engine/object/IrisDimension.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index 683dd364d..6f9773ecd 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -157,6 +157,8 @@ public class IrisDimension extends IrisRegistrant { @MaxNumber(255) @Desc("The fluid height for this dimension") private int fluidHeight = 63; + @Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.") + private IrisRange dimensionHeight = new IrisRange(-64, 320); @RegistryListResource(IrisBiome.class) @Desc("Keep this either undefined or empty. Setting any biome name into this will force iris to only generate the specified biome. Great for testing.") private String focus = ""; @@ -228,6 +230,16 @@ public class IrisDimension extends IrisRegistrant { @ArrayType(type = IrisOreGenerator.class, min = 1) private KList ores = new KList<>(); + public int getMaxHeight() + { + return (int) getDimensionHeight().getMax(); + } + + public int getMinHeight() + { + return (int) getDimensionHeight().getMin(); + } + public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) { if(ores.isEmpty()) { return null; From b108a0164a3b5342f09996ed80b1e1a4aff9f34e Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:26:01 -0500 Subject: [PATCH 38/42] Headless use dimension height request --- .../java/com/volmit/iris/engine/object/HeadlessWorld.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java b/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java index 8e615ec98..292ce4eed 100644 --- a/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java +++ b/src/main/java/com/volmit/iris/engine/object/HeadlessWorld.java @@ -53,8 +53,8 @@ public class HeadlessWorld { .environment(dimension.getEnvironment()) .worldFolder(new File(worldName)) .seed(seed) - .maxHeight(320) - .minHeight(-64) + .maxHeight(dimension.getMaxHeight()) + .minHeight(dimension.getMinHeight()) .name(worldName) .build(); world.worldFolder().mkdirs(); From bfd7a02c9d9fb657e1027c5366f6f40c9585e197 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:27:04 -0500 Subject: [PATCH 39/42] Iris WC use dimension heights --- .../volmit/iris/core/tools/IrisWorldCreator.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java b/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java index 13aee2ac5..89a1c3197 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisWorldCreator.java @@ -33,8 +33,6 @@ public class IrisWorldCreator { private boolean studio = false; private String dimensionName = null; private long seed = 1337; - private int maxHeight = 320; - private int minHeight = -64; public IrisWorldCreator() { @@ -45,12 +43,6 @@ public class IrisWorldCreator { return this; } - public IrisWorldCreator height(int minHeight, int maxHeight) { - this.maxHeight = maxHeight; - this.minHeight = minHeight; - return this; - } - public IrisWorldCreator name(String name) { this.name = name; return this; @@ -72,16 +64,18 @@ public class IrisWorldCreator { } public WorldCreator create() { + IrisDimension dim = IrisData.loadAnyDimension(dimensionName); + IrisWorld w = IrisWorld.builder() .name(name) - .minHeight(minHeight) - .maxHeight(maxHeight) + .minHeight(dim.getMinHeight()) + .maxHeight(dim.getMaxHeight()) .seed(seed) .worldFolder(new File(name)) .environment(findEnvironment()) .build(); ChunkGenerator g = new BukkitChunkGenerator(w, studio, studio - ? IrisData.loadAnyDimension(dimensionName).getLoader().getDataFolder() : + ? dim.getLoader().getDataFolder() : new File(w.worldFolder(), "iris/pack"), dimensionName); return new WorldCreator(name) From 2a73524a192f1f1658f965b8edb7c9f35268f456 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:27:55 -0500 Subject: [PATCH 40/42] Default world hint use dimension height requests --- src/main/java/com/volmit/iris/Iris.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index b83d820cd..36b74a57d 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -607,8 +607,8 @@ public class Iris extends VolmitPlugin implements Listener { .seed(1337) .environment(dim.getEnvironment()) .worldFolder(new File(worldName)) - .minHeight(-64) - .maxHeight(320) + .minHeight(dim.getMinHeight()) + .maxHeight(dim.getMaxHeight()) .build(); Iris.debug("Generator Config: " + w.toString()); From 64d8f22757ff3e5ee253647a88b110fded48c236 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:38:34 -0500 Subject: [PATCH 41/42] Ignore the setting lol not possible now --- .../java/com/volmit/iris/engine/object/IrisDimension.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index 6f9773ecd..4271d3036 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -232,12 +232,14 @@ public class IrisDimension extends IrisRegistrant { public int getMaxHeight() { - return (int) getDimensionHeight().getMax(); + return 320; + // return (int) getDimensionHeight().getMax(); } public int getMinHeight() { - return (int) getDimensionHeight().getMin(); + return -64; + // return (int) getDimensionHeight().getMin(); } public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) { From 4430fd21f5e61bc9a1506261ee41710d8419907d Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 12 Jan 2022 08:39:55 -0500 Subject: [PATCH 42/42] Cleanup sources --- .../com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java | 8 ++------ .../volmit/iris/engine/actuator/IrisBiomeActuator.java | 9 ++------- .../volmit/iris/engine/data/chunk/MCATerrainChunk.java | 2 +- .../java/com/volmit/iris/engine/framework/Engine.java | 1 - .../volmit/iris/engine/framework/PregeneratedData.java | 1 - .../com/volmit/iris/engine/object/IrisDimension.java | 6 ++---- .../volmit/iris/engine/platform/HeadlessGenerator.java | 1 - src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java | 4 +--- 8 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java index 0cda4e8e3..5d4daf2e1 100644 --- a/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java +++ b/src/main/java/com/volmit/iris/core/nms/v18_1/NMSBinding18_1.java @@ -35,7 +35,6 @@ import com.volmit.iris.util.nbt.mca.palette.MCAPaletteAccess; import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer; import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer; import com.volmit.iris.util.nbt.tag.CompoundTag; -import com.volmit.iris.util.scheduling.J; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.core.BlockPos; import net.minecraft.core.IdMap; @@ -67,7 +66,6 @@ import java.io.DataOutputStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -166,10 +164,8 @@ public class NMSBinding18_1 implements INMSBinding { public Object getBiomeBaseFromId(int id) { try { return byIdRef.aquire(() -> { - for(Method i : IdMap.class.getDeclaredMethods()) - { - if(i.getParameterCount() == 1 && i.getParameterTypes()[0].equals(int.class)) - { + for(Method i : IdMap.class.getDeclaredMethods()) { + if(i.getParameterCount() == 1 && i.getParameterTypes()[0].equals(int.class)) { Iris.info("[NMS] Found byId method in " + IdMap.class.getSimpleName() + "." + i.getName() + "(int) => " + Biome.class.getSimpleName()); return i; } diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java index 922c41c44..6504d6614 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java @@ -25,7 +25,6 @@ import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisBiomeCustom; -import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.hunk.view.BiomeGridHunkView; @@ -108,15 +107,11 @@ public class IrisBiomeActuator extends EngineAssignedActuator { } else { Biome v = ib.getSkyBiome(rng, x, 0, z); - if(v != null) - { + if(v != null) { for(int i = 0; i < maxHeight; i++) { h.set(finalXf, i, zf, v); } - } - - else if(cl.flip()) - { + } else if(cl.flip()) { Iris.error("No biome provided for " + ib.getLoadKey()); } } diff --git a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java index f664b81f8..0e65fdd5a 100644 --- a/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java +++ b/src/main/java/com/volmit/iris/engine/data/chunk/MCATerrainChunk.java @@ -82,7 +82,7 @@ public class MCATerrainChunk implements TerrainChunk { int zz = (z + oz) & 15; if(y > getMaxHeight() || y < getMinHeight()) { - return; + return; } if(blockData == null) { diff --git a/src/main/java/com/volmit/iris/engine/framework/Engine.java b/src/main/java/com/volmit/iris/engine/framework/Engine.java index 177ce0e4d..285c4cae6 100644 --- a/src/main/java/com/volmit/iris/engine/framework/Engine.java +++ b/src/main/java/com/volmit/iris/engine/framework/Engine.java @@ -78,7 +78,6 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.data.BlockData; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.generator.ChunkGenerator; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java b/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java index 6a2ef9f2c..0e7aff574 100644 --- a/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java +++ b/src/main/java/com/volmit/iris/engine/framework/PregeneratedData.java @@ -24,7 +24,6 @@ import com.volmit.iris.util.hunk.Hunk; import lombok.Data; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; -import org.bukkit.generator.ChunkGenerator; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index 4271d3036..64166d240 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -230,14 +230,12 @@ public class IrisDimension extends IrisRegistrant { @ArrayType(type = IrisOreGenerator.class, min = 1) private KList ores = new KList<>(); - public int getMaxHeight() - { + public int getMaxHeight() { return 320; // return (int) getDimensionHeight().getMax(); } - public int getMinHeight() - { + public int getMinHeight() { return -64; // return (int) getDimensionHeight().getMin(); } diff --git a/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java b/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java index b59e903be..e9e34c06f 100644 --- a/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java +++ b/src/main/java/com/volmit/iris/engine/platform/HeadlessGenerator.java @@ -44,7 +44,6 @@ import lombok.Data; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.data.BlockData; -import org.bukkit.generator.ChunkGenerator; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java b/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java index 83dba6f87..6d42b82cc 100644 --- a/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java +++ b/src/main/java/com/volmit/iris/util/nbt/mca/Chunk.java @@ -34,7 +34,6 @@ import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.RandomAccessFile; -import java.util.concurrent.atomic.AtomicReferenceArray; import static com.volmit.iris.util.nbt.mca.LoadFlags.*; @@ -638,8 +637,7 @@ public class Chunk { if(structures != null) level.put("Structures", structures); ListTag sections = new ListTag<>(CompoundTag.class); - for(int i : this.sections.keySet()) - { + for(int i : this.sections.keySet()) { if(this.sections.get(i) != null) { sections.add(this.sections.get(i).updateHandle(i)); }

* This is the same as {@link String#getBytes()}. * - * @param input the String to convert + * @param input + * the String to convert * @return the requested byte array * @deprecated Use {@link String#getBytes()} */ @@ -702,10 +744,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param is the InputStream to read from + * @param is + * the InputStream to read from * @return the requested character array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static char[] toCharArray(InputStream is) throws IOException { @@ -724,11 +769,15 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param is the InputStream to read from - * @param encoding the encoding to use, null means platform default + * @param is + * the InputStream to read from + * @param encoding + * the encoding to use, null means platform default * @return the requested character array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static char[] toCharArray(InputStream is, String encoding) throws IOException { @@ -746,10 +795,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedReader. * - * @param input the Reader to read from + * @param input + * the Reader to read from * @return the requested character array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static char[] toCharArray(Reader input) throws IOException { @@ -765,10 +817,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param input the InputStream to read from + * @param input + * the InputStream to read from * @return the requested String - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs */ public static String toString(InputStream input) throws IOException { StringWriter sw = new StringWriter(); @@ -786,11 +841,15 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param input the InputStream to read from - * @param encoding the encoding to use, null means platform default + * @param input + * the InputStream to read from + * @param encoding + * the encoding to use, null means platform default * @return the requested String - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs */ public static String toString(InputStream input, String encoding) throws IOException { StringWriter sw = new StringWriter(); @@ -804,10 +863,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedReader. * - * @param input the Reader to read from + * @param input + * the Reader to read from * @return the requested String - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs */ public static String toString(Reader input) throws IOException { StringWriter sw = new StringWriter(); @@ -819,7 +881,8 @@ public class IO { * Get the contents of a byte[] as a String using the default * character encoding of the platform. * - * @param input the byte array to read from + * @param input + * the byte array to read from * @return the requested String * @deprecated Use {@link String#String(byte[])} */ @@ -838,16 +901,20 @@ public class IO { * Character encoding names can be found at * IANA. * - * @param input the byte array to read from - * @param encoding the encoding to use, null means platform default + * @param input + * the byte array to read from + * @param encoding + * the encoding to use, null means platform default * @return the requested String - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs (never occurs) + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs (never occurs) * @deprecated Use {@link String#String(byte[], String)} */ @Deprecated public static String toString(byte[] input, String encoding) throws IOException { - if (encoding == null) { + if(encoding == null) { return new String(input); } else { return new String(input, encoding); @@ -861,10 +928,13 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param input the InputStream to read from, not null + * @param input + * the InputStream to read from, not null * @return the list of Strings, never null - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static List readLines(InputStream input) throws IOException { @@ -882,15 +952,19 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedInputStream. * - * @param input the InputStream to read from, not null - * @param encoding the encoding to use, null means platform default + * @param input + * the InputStream to read from, not null + * @param encoding + * the encoding to use, null means platform default * @return the list of Strings, never null - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static List readLines(InputStream input, String encoding) throws IOException { - if (encoding == null) { + if(encoding == null) { return readLines(input); } else { InputStreamReader reader = new InputStreamReader(input, encoding); @@ -907,17 +981,20 @@ public class IO { * This method buffers the input internally, so there is no need to use a * BufferedReader. * - * @param input the Reader to read from, not null + * @param input + * the Reader to read from, not null * @return the list of Strings, never null - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static List readLines(Reader input) throws IOException { BufferedReader reader = new BufferedReader(input); List list = new ArrayList(); String line = reader.readLine(); - while (line != null) { + while(line != null) { list.add(line); line = reader.readLine(); } @@ -928,7 +1005,8 @@ public class IO { * Convert the specified string to an input stream, encoded as bytes using the * default character encoding of the platform. * - * @param input the string to convert + * @param input + * the string to convert * @return an input stream * @since Commons IO 1.1 */ @@ -947,10 +1025,13 @@ public class IO { * Character encoding names can be found at * IANA. * - * @param input the string to convert - * @param encoding the encoding to use, null means platform default + * @param input + * the string to convert + * @param encoding + * the encoding to use, null means platform default * @return an input stream - * @throws IOException if the encoding is invalid + * @throws IOException + * if the encoding is invalid * @since Commons IO 1.1 */ public static InputStream toInputStream(String input, String encoding) throws IOException { @@ -961,14 +1042,18 @@ public class IO { /** * Writes bytes from a byte[] to an OutputStream. * - * @param data the byte array to writeNodeData, do not modify during output, null ignored - * @param output the OutputStream to writeNodeData to - * @throws NullPointerException if output is null - * @throws IOException if an I/O error occurs + * @param data + * the byte array to writeNodeData, do not modify during output, null ignored + * @param output + * the OutputStream to writeNodeData to + * @throws NullPointerException + * if output is null + * @throws IOException + * if an I/O error occurs * @since Commons IO 1.1 */ public static void write(byte[] data, OutputStream output) throws IOException { - if (data != null) { + if(data != null) { output.write(data); } } @@ -979,14 +1064,18 @@ public class IO { *

Dye ColorColor
%1$sTest String