9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 19:19:07 +00:00

Repackage utils

This commit is contained in:
Daniel Mills
2021-07-16 02:11:37 -04:00
parent b9b30f9f53
commit da53a7d469
471 changed files with 1043 additions and 601 deletions

View File

@@ -1,33 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface ArrayType {
Class<?> type();
int min() default 0;
}

View File

@@ -1,519 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.volmit.iris.Iris;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
public class B {
private static final Material AIR_MATERIAL = Material.AIR;
private static final BlockData AIR = AIR_MATERIAL.createBlockData();
private static final KSet<String> nullBlockDataCache = new KSet<>();
private static final KSet<String> nullMaterialCache = new KSet<>();
private static final KMap<Material, Boolean> solidCache = new KMap<>();
private static final KMap<Material, Boolean> updatableCache = new KMap<>();
private static final KMap<Material, Boolean> foliageCache = new KMap<>();
private static final KMap<Material, Boolean> litCache = new KMap<>();
private static final KMap<Material, Boolean> decorantCache = new KMap<>();
private static final KMap<Material, Boolean> storageCache = new KMap<>();
private static final KMap<Material, Boolean> storageChestCache = new KMap<>();
private static final KMap<String, BlockData> blockDataCache = new KMap<>();
private static final KMap<String, Material> materialCache = new KMap<>();
public static boolean isWater(BlockData b) {
return b.getMaterial().equals(Material.WATER);
}
public static BlockData getAir() {
return AIR;
}
public static Material getMaterial(String bdx) {
Material mat = getMaterialOrNull(bdx);
if (mat != null) {
return mat;
}
return AIR_MATERIAL;
}
public static Material getMaterialOrNull(String bdxx) {
String bx = bdxx.trim().toUpperCase();
if (nullMaterialCache.contains(bx)) {
return null;
}
Material mat = materialCache.get(bx);
if (mat != null) {
return mat;
}
try {
Material mm = Material.valueOf(bx);
materialCache.put(bx, mm);
return mm;
} catch (Throwable e) {Iris.reportError(e);
nullMaterialCache.add(bx);
return null;
}
}
public static boolean isSolid(BlockData mat) {
return isSolid(mat.getMaterial());
}
public static boolean isSolid(Material mat) {
Boolean solid = solidCache.get(mat);
if (solid != null) {
return solid;
}
solid = mat.isSolid();
solidCache.put(mat, solid);
return solid;
}
public static BlockData getOrNull(String bdxf) {
try {
String bd = bdxf.trim();
BlockData bdx = parseBlockData(bd);
if (bdx == null) {
Iris.warn("Unknown Block Data '" + bd + "'");
return AIR;
}
return bdx;
} catch (Throwable e) {Iris.reportError(e);
Iris.warn("Unknown Block Data '" + bdxf + "'");
}
return null;
}
public static BlockData get(String bdxf) {
BlockData bd = getOrNull(bdxf);
if (bd != null) {
return bd;
}
return AIR;
}
private static BlockData parseBlockDataOrNull(String ix) {
if (nullBlockDataCache.contains(ix)) {
return null;
}
try {
BlockData bb = blockDataCache.get(ix);
if (bb != null) {
return bb;
}
BlockData bx = Bukkit.createBlockData(ix);
blockDataCache.put(ix, bx);
return bx;
} catch (Throwable e) {Iris.reportError(e);
}
String i = ix.toUpperCase().trim();
i = i.equals("WOOL") ? "WHITE_WOOL" : i;
i = i.equals("CONCRETE") ? "WHITE_CONCRETE" : i;
try {
BlockData bd = Material.valueOf(i).createBlockData();
blockDataCache.put(ix, bd);
} catch (Throwable e) {Iris.reportError(e);
}
nullBlockDataCache.add(ix);
return null;
}
private static BlockData parseBlockData(String ix) {
BlockData bd = parseBlockDataOrNull(ix);
if (bd != null) {
return bd;
}
return AIR;
}
public static boolean isStorage(BlockData mat) {
Material mm = mat.getMaterial();
Boolean f = storageCache.get(mm);
if (f != null) {
return f;
}
f = mm.equals(B.getMaterial("CHEST"))
|| mm.equals(B.getMaterial("TRAPPED_CHEST"))
|| mm.equals(B.getMaterial("SHULKER_BOX"))
|| mm.equals(B.getMaterial("WHITE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("ORANGE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("MAGENTA_SHULKER_BOX"))
|| mm.equals(B.getMaterial("LIGHT_BLUE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("YELLOW_SHULKER_BOX"))
|| mm.equals(B.getMaterial("LIME_SHULKER_BOX"))
|| mm.equals(B.getMaterial("PINK_SHULKER_BOX"))
|| mm.equals(B.getMaterial("GRAY_SHULKER_BOX"))
|| mm.equals(B.getMaterial("LIGHT_GRAY_SHULKER_BOX"))
|| mm.equals(B.getMaterial("CYAN_SHULKER_BOX"))
|| mm.equals(B.getMaterial("PURPLE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BLUE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BROWN_SHULKER_BOX"))
|| mm.equals(B.getMaterial("GREEN_SHULKER_BOX"))
|| mm.equals(B.getMaterial("RED_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BLACK_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BARREL"))
|| mm.equals(B.getMaterial("DISPENSER"))
|| mm.equals(B.getMaterial("DROPPER"))
|| mm.equals(B.getMaterial("HOPPER"))
|| mm.equals(B.getMaterial("FURNACE"))
|| mm.equals(B.getMaterial("BLAST_FURNACE"))
|| mm.equals(B.getMaterial("SMOKER"));
storageCache.put(mm, f);
return f;
}
public static boolean isStorageChest(BlockData mat) {
if (!isStorage(mat)) {
return false;
}
Material mm = mat.getMaterial();
Boolean f = storageChestCache.get(mm);
if (f != null) {
return f;
}
f = mm.equals(B.getMaterial("CHEST"))
|| mm.equals(B.getMaterial("TRAPPED_CHEST"))
|| mm.equals(B.getMaterial("SHULKER_BOX"))
|| mm.equals(B.getMaterial("WHITE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("ORANGE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("MAGENTA_SHULKER_BOX"))
|| mm.equals(B.getMaterial("LIGHT_BLUE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("YELLOW_SHULKER_BOX"))
|| mm.equals(B.getMaterial("LIME_SHULKER_BOX"))
|| mm.equals(B.getMaterial("PINK_SHULKER_BOX"))
|| mm.equals(B.getMaterial("GRAY_SHULKER_BOX"))
|| mm.equals(B.getMaterial("LIGHT_GRAY_SHULKER_BOX"))
|| mm.equals(B.getMaterial("CYAN_SHULKER_BOX"))
|| mm.equals(B.getMaterial("PURPLE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BLUE_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BROWN_SHULKER_BOX"))
|| mm.equals(B.getMaterial("GREEN_SHULKER_BOX"))
|| mm.equals(B.getMaterial("RED_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BLACK_SHULKER_BOX"))
|| mm.equals(B.getMaterial("BARREL"))
|| mm.equals(B.getMaterial("DISPENSER"))
|| mm.equals(B.getMaterial("DROPPER"))
|| mm.equals(B.getMaterial("HOPPER"));
storageChestCache.put(mm, f);
return f;
}
public static boolean isLit(BlockData mat) {
Material mm = mat.getMaterial();
Boolean f = litCache.get(mm);
if (f != null) {
return f;
}
f = mm.equals(B.getMaterial("GLOWSTONE"))
|| mm.equals(B.getMaterial("END_ROD"))
|| mm.equals(B.getMaterial("SOUL_SAND"))
|| mm.equals(B.getMaterial("TORCH"))
|| mm.equals(Material.REDSTONE_TORCH)
|| mm.equals(B.getMaterial("SOUL_TORCH"))
|| mm.equals(Material.REDSTONE_WALL_TORCH)
|| mm.equals(Material.WALL_TORCH)
|| mm.equals(B.getMaterial("SOUL_WALL_TORCH"))
|| mm.equals(B.getMaterial("LANTERN"))
|| mm.equals(Material.JACK_O_LANTERN)
|| mm.equals(Material.REDSTONE_LAMP)
|| mm.equals(Material.MAGMA_BLOCK)
|| mm.equals(B.getMaterial("SHROOMLIGHT"))
|| mm.equals(B.getMaterial("SEA_LANTERN"))
|| mm.equals(B.getMaterial("SOUL_LANTERN"))
|| mm.equals(Material.FIRE)
|| mm.equals(B.getMaterial("SOUL_FIRE"))
|| mm.equals(B.getMaterial("SEA_PICKLE"))
|| mm.equals(Material.BREWING_STAND)
|| mm.equals(Material.REDSTONE_ORE);
litCache.put(mm, f);
return f;
}
public static boolean isUpdatable(BlockData mat) {
Boolean u = updatableCache.get(mat.getMaterial());
if (u != null) {
return u;
}
u = isLit(mat) || isStorage(mat);
updatableCache.put(mat.getMaterial(), u);
return u;
}
public static boolean isFoliage(Material d) {
return isFoliage(d.createBlockData());
}
public static boolean isFoliage(BlockData d) {
Boolean f = foliageCache.get(d.getMaterial());
if (f != null) {
return f;
}
if (isFluid(d) || isAir(d) || isSolid(d)) {
foliageCache.put(d.getMaterial(), false);
return false;
}
Material mat = d.getMaterial();
f = mat.equals(Material.POPPY)
|| mat.equals(Material.DANDELION)
|| mat.equals(B.getMaterial("CORNFLOWER"))
|| mat.equals(B.getMaterial("SWEET_BERRY_BUSH"))
|| mat.equals(B.getMaterial("CRIMSON_ROOTS"))
|| mat.equals(B.getMaterial("WARPED_ROOTS"))
|| mat.equals(B.getMaterial("NETHER_SPROUTS"))
|| mat.equals(B.getMaterial("ALLIUM"))
|| mat.equals(B.getMaterial("AZURE_BLUET"))
|| mat.equals(B.getMaterial("BLUE_ORCHID"))
|| mat.equals(B.getMaterial("POPPY"))
|| mat.equals(B.getMaterial("DANDELION"))
|| mat.equals(B.getMaterial("OXEYE_DAISY"))
|| mat.equals(B.getMaterial("LILY_OF_THE_VALLEY"))
|| mat.equals(B.getMaterial("WITHER_ROSE"))
|| mat.equals(Material.DARK_OAK_SAPLING)
|| mat.equals(Material.ACACIA_SAPLING)
|| mat.equals(Material.JUNGLE_SAPLING)
|| mat.equals(Material.BIRCH_SAPLING)
|| mat.equals(Material.SPRUCE_SAPLING)
|| mat.equals(Material.OAK_SAPLING)
|| mat.equals(Material.ORANGE_TULIP)
|| mat.equals(Material.PINK_TULIP)
|| mat.equals(Material.RED_TULIP)
|| mat.equals(Material.WHITE_TULIP)
|| mat.equals(Material.FERN)
|| mat.equals(Material.LARGE_FERN)
|| mat.equals(Material.GRASS)
|| mat.equals(Material.TALL_GRASS);
foliageCache.put(d.getMaterial(), f);
return f;
}
public static boolean canPlaceOnto(Material mat, Material onto) {
String key = mat.name() + "" + onto.name();
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"))) {
return false;
}
if (onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH)) {
return false;
}
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)) {
return mat.isSolid();
}
return true;
}
public static boolean isDecorant(BlockData m) {
Material mm = m.getMaterial();
Boolean f = decorantCache.get(mm);
if (f != null) {
return f;
}
f = mm.equals(Material.GRASS)
|| mm.equals(Material.TALL_GRASS)
|| mm.equals(B.getMaterial("CORNFLOWER"))
|| mm.equals(Material.SUNFLOWER)
|| mm.equals(Material.CHORUS_FLOWER)
|| mm.equals(Material.POPPY)
|| mm.equals(Material.DANDELION)
|| mm.equals(Material.OXEYE_DAISY)
|| mm.equals(Material.ORANGE_TULIP)
|| mm.equals(Material.PINK_TULIP)
|| mm.equals(Material.RED_TULIP)
|| mm.equals(Material.WHITE_TULIP)
|| mm.equals(Material.LILAC)
|| mm.equals(Material.DEAD_BUSH)
|| mm.equals(B.getMaterial("SWEET_BERRY_BUSH"))
|| mm.equals(Material.ROSE_BUSH)
|| mm.equals(B.getMaterial("WITHER_ROSE"))
|| mm.equals(Material.ALLIUM)
|| mm.equals(Material.BLUE_ORCHID)
|| mm.equals(B.getMaterial("LILY_OF_THE_VALLEY"))
|| mm.equals(B.getMaterial("CRIMSON_FUNGUS"))
|| mm.equals(B.getMaterial("WARPED_FUNGUS"))
|| mm.equals(Material.RED_MUSHROOM)
|| mm.equals(Material.BROWN_MUSHROOM)
|| mm.equals(B.getMaterial("CRIMSON_ROOTS"))
|| mm.equals(B.getMaterial("AZURE_BLUET"))
|| mm.equals(B.getMaterial("WEEPING_VINES"))
|| mm.equals(B.getMaterial("WEEPING_VINES_PLANT"))
|| mm.equals(B.getMaterial("WARPED_ROOTS"))
|| mm.equals(B.getMaterial("NETHER_SPROUTS"))
|| mm.equals(B.getMaterial("TWISTING_VINES"))
|| mm.equals(B.getMaterial("TWISTING_VINES_PLANT"))
|| mm.equals(Material.SUGAR_CANE)
|| mm.equals(Material.WHEAT)
|| mm.equals(Material.POTATOES)
|| mm.equals(Material.CARROTS)
|| mm.equals(Material.BEETROOTS)
|| mm.equals(Material.NETHER_WART)
|| mm.equals(B.getMaterial("SEA_PICKLE"))
|| mm.equals(B.getMaterial("SEAGRASS"))
|| mm.equals(B.getMaterial("ACACIA_BUTTON"))
|| mm.equals(B.getMaterial("BIRCH_BUTTON"))
|| mm.equals(B.getMaterial("CRIMSON_BUTTON"))
|| mm.equals(B.getMaterial("DARK_OAK_BUTTON"))
|| mm.equals(B.getMaterial("JUNGLE_BUTTON"))
|| mm.equals(B.getMaterial("OAK_BUTTON"))
|| mm.equals(B.getMaterial("POLISHED_BLACKSTONE_BUTTON"))
|| mm.equals(B.getMaterial("SPRUCE_BUTTON"))
|| mm.equals(B.getMaterial("STONE_BUTTON"))
|| mm.equals(B.getMaterial("WARPED_BUTTON"))
|| mm.equals(Material.TORCH)
|| mm.equals(B.getMaterial("SOUL_TORCH"));
decorantCache.put(mm, f);
return f;
}
public static KList<BlockData> get(KList<String> find) {
KList<BlockData> b = new KList<>();
for (String i : find) {
BlockData bd = get(i);
if (bd != null) {
b.add(bd);
}
}
return b;
}
public static boolean isFoliagePlantable(BlockData d) {
return d.getMaterial().equals(Material.GRASS_BLOCK)
|| 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(Material.COARSE_DIRT)
|| d.equals(Material.PODZOL);
}
public static boolean isFluid(BlockData d) {
return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.LAVA);
}
public static boolean isAirOrFluid(BlockData d) {
return isAir(d) || isFluid(d);
}
public static boolean isAir(BlockData d) {
if (d == null) {
return true;
}
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR) || d.getMaterial().equals(Material.VOID_AIR);
}
public static String[] getBlockTypes() {
KList<String> bt = new KList<>();
for (Material i : Material.values()) {
if (i.isBlock()) {
String v = i.createBlockData().getAsString(true);
if (v.contains("[")) {
v = v.split("\\Q[\\E")[0];
}
if (v.contains(":")) {
v = v.split("\\Q:\\E")[1];
}
bt.add(v);
}
}
return bt.toArray(new String[0]);
}
public static String[] getItemTypes() {
KList<String> bt = new KList<>();
for (Material i : Material.values()) {
String v = i.name().toLowerCase().trim();
bt.add(v);
}
return bt.toArray(new String[0]);
}
}

View File

@@ -1,34 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import lombok.Value;
@SuppressWarnings("ClassCanBeRecord")
@Value
public class CarveResult {
@SuppressWarnings("RedundantModifiersValueLombok")
private final int surface;
@SuppressWarnings("RedundantModifiersValueLombok")
private final int ceiling;
public int getHeight() {
return ceiling - surface;
}
}

View File

@@ -1,36 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import lombok.Data;
@Data
public class CaveResult {
private int floor;
private int ceiling;
public CaveResult(int floor, int ceiling) {
this.floor = floor;
this.ceiling = ceiling;
}
public boolean isWithin(int v) {
return v > floor || v < ceiling;
}
}

View File

@@ -1,23 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
public class Denv {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({FIELD})
public @interface DependsOn {
String[] value();
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface Desc {
String value();
}

View File

@@ -1,25 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
public class ING {
public ING(RNG rng) {
}
}

View File

@@ -1,45 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.volmit.iris.engine.object.tile.TileData;
import org.bukkit.block.TileState;
import org.bukkit.block.data.BlockData;
public interface IObjectPlacer {
int getHighest(int x, int z);
int getHighest(int x, int z, boolean ignoreFluid);
void set(int x, int y, int z, BlockData d);
BlockData get(int x, int y, int z);
boolean isPreventingDecay();
boolean isSolid(int x, int y, int z);
boolean isUnderwater(int x, int z);
int getFluidHeight();
boolean isDebugSmartBore();
void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile);
}

View File

@@ -1,36 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
public interface IPostBlockAccess {
BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData);
void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData);
int highestTerrainOrFluidBlock(int x, int z);
int highestTerrainBlock(int x, int z);
void updateHeight(int x, int z, int h);
KList<CaveResult> caveFloors(int x, int z);
}

View File

@@ -1,27 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
public interface IRare {
int getRarity();
static int get(Object v) {
return v instanceof IRare ? Math.max(1, ((IRare) v).getRarity()) : 1;
}
}

View File

@@ -1,27 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import org.bukkit.Bukkit;
public class Info {
public static String getPortIP() {
return Bukkit.getPort() + Bukkit.getIp();
}
}

View File

@@ -1,27 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
public enum InterpolationType {
LINEAR,
PARAMETRIC_2,
PARAMETRIC_4,
BEZIER,
NONE
}

View File

@@ -1,885 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.engine.object.InterpolationMethod;
import com.volmit.iris.engine.object.NoiseStyle;
public class IrisInterpolation {
public static double bezier(double t) {
return t * t * (3.0d - 2.0d * t);
}
public static double parametric(double t, double alpha) {
double sqt = Math.pow(t, alpha);
return sqt / (alpha * (sqt - Math.pow(t, alpha - 1)) + 1.0d);
}
public static float lerpf(float a, float b, float f) {
return a + (f * (b - a));
}
public static double lerpBezier(double a, double b, double f) {
return a + (bezier(f) * (b - a));
}
public static double sinCenter(double f) {
return Math.sin(f * Math.PI);
}
public static double lerpCenterSinBezier(double a, double b, double f) {
return lerpBezier(a, b, sinCenter(f));
}
public static double lerpCenterSin(double a, double b, double f) {
return lerpBezier(a, b, sinCenter(f));
}
public static double lerpParametric(double a, double b, double f, double v) {
return a + (parametric(f, v) * (b - a));
}
public static double blerp(double a, double b, double c, double d, double tx, double ty, InterpolationType type) {
if (type.equals(InterpolationType.LINEAR)) {
return blerp(a, b, c, d, tx, ty);
}
if (type.equals(InterpolationType.BEZIER)) {
return blerpBezier(a, b, c, d, tx, ty);
}
if (type.equals(InterpolationType.PARAMETRIC_2)) {
return blerpParametric(a, b, c, d, tx, ty, 2);
}
if (type.equals(InterpolationType.PARAMETRIC_4)) {
return blerpParametric(a, b, c, d, tx, ty, 4);
}
return 0;
}
public static double blerpBezier(double a, double b, double c, double d, double tx, double ty) {
return lerpBezier(lerpBezier(a, b, tx), lerpBezier(c, d, tx), ty);
}
public static double blerpSinCenter(double a, double b, double c, double d, double tx, double ty) {
return lerpCenterSin(lerpCenterSin(a, b, tx), lerpCenterSin(c, d, tx), ty);
}
public static double blerpParametric(double a, double b, double c, double d, double tx, double ty, double v) {
return lerpParametric(lerpParametric(a, b, tx, v), lerpParametric(c, d, tx, v), ty, v);
}
public static double hermiteBezier(double p0, double p1, double p2, double p3, double mu, double tension, double bias) {
return bezier(hermite(p0, p1, p2, p3, mu, tension, bias));
}
public static double hermiteParametric(double p0, double p1, double p2, double p3, double mu, double tension, double bias, double a) {
return parametric(hermite(p0, p1, p2, p3, mu, tension, bias), a);
}
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);
//@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);
//@done
}
public static double cubicBezier(double p0, double p1, double p2, double p3, double mu) {
return bezier(cubic(p0, p1, p2, p3, mu));
}
public static double cubicParametric(double p0, double p1, double p2, double p3, double mu, double a) {
return parametric(cubic(p0, p1, p2, p3, mu), a);
}
public static double hermite(double p0, double p1, double p2, double p3, double mu, double tension, double bias) {
double m0, m1, mu2, mu3;
double a0, a1, a2, a3;
mu2 = mu * mu;
mu3 = mu2 * mu;
m0 = (p1 - p0) * (1 + bias) * (1 - tension) / 2;
m0 += (p2 - p1) * (1 - bias) * (1 - tension) / 2;
m1 = (p2 - p1) * (1 + bias) * (1 - tension) / 2;
m1 += (p3 - p2) * (1 - bias) * (1 - tension) / 2;
a0 = 2 * mu3 - 3 * mu2 + 1;
a1 = mu3 - 2 * mu2 + mu;
a2 = mu3 - mu2;
a3 = -2 * mu3 + 3 * mu2;
return (a0 * p1 + a1 * m0 + a2 * m1 + a3 * p2);
}
public static double cubic(double p0, double p1, double p2, double p3, double mu) {
double a0, a1, a2, a3, mu2;
mu2 = mu * mu;
a0 = p3 - p2 - p0 + p1;
a1 = p0 - p1 - a0;
a2 = p2 - p0;
a3 = p1;
return a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3;
}
public static double getTriStarcast(int x, int y, int z, double rad, double checks, NoiseProvider n) {
return (getStarcast(x, z, rad, checks, n) + getStarcast(x, y, rad, checks, n) + getStarcast(y, z, rad, checks, n)) / 3D;
}
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);
//@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);
//@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);
//@done
}
public static double tricubic(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) {
//@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);
//@done
}
public static double lerp(double a, double b, double f) {
return a + (f * (b - a));
}
public static double blerp(double a, double b, double c, double d, double tx, double ty) {
return lerp(lerp(a, b, tx), lerp(c, d, tx), ty);
}
public static double trilerp(double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double x, double y, double z) {
return lerp(blerp(v1, v2, v3, v4, x, y), blerp(v5, v6, v7, v8, x, y), z);
}
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);
//@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);
//@done
}
public static CNG cng = NoiseStyle.SIMPLEX.create(new RNG());
public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getStarcast(int x, int z, double rad, double checks, NoiseProvider n) {
double m = (360 / checks);
double v = 0;
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));
double cz = z + ((rad * sin) + (rad * cos));
v += n.noise(cx, cz);
}
return v / checks;
}
public static double getBilinearBezierNoise(int x, int z, double rad, NoiseProvider n) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getBilinearParametricNoise(int x, int z, double rad, NoiseProvider n, double a) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getTrilinear(int x, int y, int z, double rad, NoiseProvider3 n) {
int fx = (int) Math.floor(x / rad);
int fy = (int) Math.floor(y / rad);
int fz = (int) Math.floor(z / rad);
int x1 = (int) Math.round(fx * rad);
int y1 = (int) Math.round(fy * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int y2 = (int) Math.round((fy + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
double px = rangeScale(0, 1, x1, x2, x);
double py = rangeScale(0, 1, y1, y2, y);
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);
//@done
}
public static double getTricubic(int x, int y, int z, double rad, NoiseProvider3 n) {
int fx = (int) Math.floor(x / rad);
int fy = (int) Math.floor(y / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int y0 = (int) Math.round((fy - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int y1 = (int) Math.round(fy * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int y2 = (int) Math.round((fy + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int y3 = (int) Math.round((fy + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
double py = rangeScale(0, 1, y1, y2, y);
double pz = rangeScale(0, 1, z1, z2, z);
//@builder
//!!!!!!!!!!!!!!!!!! 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);
//@done
}
public static double getTrihermite(int x, int y, int z, double rad, NoiseProvider3 n) {
return getTrihermite(x, y, z, rad, n, 0D, 0D);
}
public static double getTrihermite(int x, int y, int z, double rad, NoiseProvider3 n, double tension, double bias) {
int fx = (int) Math.floor(x / rad);
int fy = (int) Math.floor(y / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int y0 = (int) Math.round((fy - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int y1 = (int) Math.round(fy * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int y2 = (int) Math.round((fy + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int y3 = (int) Math.round((fy + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
double py = rangeScale(0, 1, y1, y2, y);
double pz = rangeScale(0, 1, z1, z2, z);
//@builder
//!!!!!!!!!!!!!!!!!! 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);
//@done
}
public static double getBilinearCenterSineNoise(int x, int z, double rad, NoiseProvider n) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getBicubicNoise(int x, int z, double rad, NoiseProvider n) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getBicubicBezierNoise(int x, int z, double rad, NoiseProvider n) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getBicubicParametricNoise(int x, int z, double rad, NoiseProvider n, double a) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n) {
return getHermiteNoise(x, z, rad, n, 0.5, 0);
}
public static double getHermiteBezierNoise(int x, int z, double rad, NoiseProvider n) {
return getHermiteBezierNoise(x, z, rad, n, 0.5, 0);
}
public static double getHermiteParametricNoise(int x, int z, double rad, NoiseProvider n, double a) {
return getHermiteParametricNoise(x, z, rad, n, 0.5, 0, a);
}
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n, double t, double b) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getHermiteBezierNoise(int x, int z, double rad, NoiseProvider n, double t, double b) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getHermiteParametricNoise(int x, int z, double rad, NoiseProvider n, double t, double b, double a) {
int fx = (int) Math.floor(x / rad);
int fz = (int) Math.floor(z / rad);
int x0 = (int) Math.round((fx - 1) * rad);
int z0 = (int) Math.round((fz - 1) * rad);
int x1 = (int) Math.round(fx * rad);
int z1 = (int) Math.round(fz * rad);
int x2 = (int) Math.round((fx + 1) * rad);
int z2 = (int) Math.round((fz + 1) * rad);
int x3 = (int) Math.round((fx + 2) * rad);
int z3 = (int) Math.round((fz + 2) * rad);
double px = rangeScale(0, 1, x1, x2, x);
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);
//@done
}
public static double getRealRadius(InterpolationMethod method, double h) {
AtomicDouble rad = new AtomicDouble(h);
AtomicDouble accessX = new AtomicDouble();
AtomicDouble accessZ = new AtomicDouble();
NoiseProvider np = (x1, z1) -> {
double d = Math.max(Math.abs(x1), Math.abs(z1));
if (d > rad.get()) {
rad.set(d);
}
return 0;
};
getNoise(method, 0, 0, h, np);
return rad.get();
}
public static double getNoise(InterpolationMethod method, int x, int z, double h, NoiseProvider n) {
if (method.equals(InterpolationMethod.BILINEAR)) {
return getBilinearNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.STARCAST_3)) {
return getStarcast(x, z, h, 3D, n);
} else if (method.equals(InterpolationMethod.STARCAST_6)) {
return getStarcast(x, z, h, 6D, n);
} else if (method.equals(InterpolationMethod.STARCAST_9)) {
return getStarcast(x, z, h, 9D, n);
} else if (method.equals(InterpolationMethod.STARCAST_12)) {
return getStarcast(x, z, h, 12D, n);
} else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_3)) {
return getStarcast(x, z, h, 3D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n));
} else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_6)) {
return getStarcast(x, z, h, 6D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n));
} else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_9)) {
return getStarcast(x, z, h, 9D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n));
} else if (method.equals(InterpolationMethod.BILINEAR_STARCAST_12)) {
return getStarcast(x, z, h, 12D, (xx, zz) -> getBilinearNoise((int) xx, (int) zz, h, n));
} else if (method.equals(InterpolationMethod.HERMITE_STARCAST_3)) {
return getStarcast(x, z, h, 3D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D));
} else if (method.equals(InterpolationMethod.HERMITE_STARCAST_6)) {
return getStarcast(x, z, h, 6D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D));
} else if (method.equals(InterpolationMethod.HERMITE_STARCAST_9)) {
return getStarcast(x, z, h, 9D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D));
} else if (method.equals(InterpolationMethod.HERMITE_STARCAST_12)) {
return getStarcast(x, z, h, 12D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D));
} else if (method.equals(InterpolationMethod.BILINEAR_BEZIER)) {
return getBilinearBezierNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_2)) {
return getBilinearParametricNoise(x, z, h, n, 2);
} else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_4)) {
return getBilinearParametricNoise(x, z, h, n, 4);
} else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_1_5)) {
return getBilinearParametricNoise(x, z, h, n, 1.5);
} else if (method.equals(InterpolationMethod.BICUBIC)) {
return getBilinearNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.HERMITE)) {
return getHermiteNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.HERMITE_TENSE)) {
return getHermiteNoise(x, z, h, n, 0.8D, 0D);
} else if (method.equals(InterpolationMethod.CATMULL_ROM_SPLINE)) {
return getHermiteNoise(x, z, h, n, 1D, 0D);
} 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)) {
return getHermiteNoise(x, z, h, n, 0D, -0.5D);
} 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)) {
return getHermiteNoise(x, z, h, n, 0D, -1D);
} else if (method.equals(InterpolationMethod.HERMITE_LOOSE_FULL_POSITIVE_BIAS)) {
return getHermiteNoise(x, z, h, n, 0D, 1D);
}
return n.noise(x, z);
}
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) {
return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));
}
}

View File

@@ -1,227 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.BiomeBaseInjector;
import com.volmit.iris.core.nms.INMS;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("deprecation")
public class LinkedTerrainChunk implements TerrainChunk {
private final Biome[] biome2D;
private final IrisBiomeStorage biome3D;
private ChunkData rawChunkData;
private final BiomeGrid storage;
public LinkedTerrainChunk(int maxHeight) {
this(null, maxHeight);
}
public LinkedTerrainChunk(BiomeGrid storage, ChunkData data) {
this.storage = storage;
rawChunkData = data;
biome2D = storage != null ? null : Iris.biome3d ? null : new Biome[256];
biome3D = storage != null ? null : Iris.biome3d ? new IrisBiomeStorage() : null;
}
public LinkedTerrainChunk(BiomeGrid storage, int maxHeight) {
this.storage = storage;
rawChunkData = createChunkData(maxHeight);
biome2D = storage != null ? null : Iris.biome3d ? null : new Biome[256];
biome3D = storage != null ? null : Iris.biome3d ? new IrisBiomeStorage() : null;
}
private ChunkData createChunkData(int maxHeight) {
try {
return Bukkit.createChunkData(new HeightedFakeWorld(maxHeight));
} catch (Throwable e) {Iris.reportError(e);
e.printStackTrace();
}
return null;
}
@Override
public BiomeBaseInjector getBiomeBaseInjector() {
return (x, y, z, bb) -> INMS.get().forceBiomeInto(x, y, z, bb, storage);
}
@NotNull
@Override
public Biome getBiome(int x, int z) {
if (storage != null) {
return storage.getBiome(x, z);
}
if (biome2D != null) {
return biome2D[(z << 4) | x];
}
return biome3D.getBiome(x, 0, z);
}
@NotNull
@Override
public Biome getBiome(int x, int y, int z) {
if (storage != null) {
return storage.getBiome(x, y, z);
}
if (biome2D != null) {
return biome2D[(z << 4) | x];
}
return biome3D.getBiome(x, y, z);
}
@Override
public void setBiome(int x, int z, Biome bio) {
if (storage != null) {
storage.setBiome(x, z, bio);
return;
}
if (biome2D != null) {
biome2D[(z << 4) | x] = bio;
return;
}
biome3D.setBiome(x, 0, z, bio);
}
public BiomeGrid getRawBiome() {
return storage;
}
@Override
public void setBiome(int x, int y, int z, Biome bio) {
if (storage != null) {
storage.setBiome(x, y, z, bio);
return;
}
if (biome2D != null) {
biome2D[(z << 4) | x] = bio;
return;
}
biome3D.setBiome(x, y, z, bio);
}
@Override
public int getMinHeight() {
return rawChunkData.getMinHeight();
}
@Override
public int getMaxHeight() {
return rawChunkData.getMaxHeight();
}
@Override
public void setBlock(int x, int y, int z, BlockData blockData) {
rawChunkData.setBlock(x, y, z, blockData);
}
@NotNull
@Override
public BlockData getBlockData(int x, int y, int z) {
return rawChunkData.getBlockData(x, y, z);
}
@Deprecated
@Override
public void setBlock(int x, int y, int z, @NotNull Material material) {
rawChunkData.setBlock(x, y, z, material);
}
@Deprecated
@Override
public void setBlock(int x, int y, int z, @NotNull MaterialData material) {
rawChunkData.setBlock(x, y, z, material);
}
@Deprecated
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material) {
rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material);
}
@Deprecated
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material) {
rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material);
}
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData) {
rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, blockData);
}
@NotNull
@Deprecated
@Override
public Material getType(int x, int y, int z) {
return rawChunkData.getType(x, y, z);
}
@NotNull
@Deprecated
@Override
public MaterialData getTypeAndData(int x, int y, int z) {
return rawChunkData.getTypeAndData(x, y, z);
}
@Deprecated
@Override
public byte getData(int x, int y, int z) {
return rawChunkData.getData(x, y, z);
}
@Override
public ChunkData getRaw() {
return rawChunkData;
}
@Override
public void setRaw(ChunkData data) {
rawChunkData = data;
}
@Override
public void inject(BiomeGrid biome) {
if (biome2D != null) {
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
biome.setBiome(i, j, getBiome(i, j));
}
}
} else if (biome3D != null) {
biome3D.inject(biome);
}
}
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({FIELD})
public @interface MaxNumber {
double value();
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({FIELD})
public @interface MinNumber {
double value();
}

View File

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

View File

@@ -1,220 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisDataManager;
import com.volmit.iris.engine.object.IrisObject;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
private final ChronoLatch useFlip = new ChronoLatch(2222);
private final KMap<String, Long> useCache = new KMap<>();
private final ChronoLatch cl;
private final AtomicInteger unload;
public ObjectResourceLoader(File root, IrisDataManager idm, String folderName, String resourceTypeName) {
super(root, idm, folderName, resourceTypeName, IrisObject.class);
cl = new ChronoLatch(30000);
unload = new AtomicInteger(0);
}
public int getSize() {
return loadCache.size();
}
public int getTotalStorage() {
int m = 0;
for (IrisObject i : loadCache.values()) {
m += i.getBlocks().size();
}
return m;
}
public void clean() {
if (useFlip.flip()) {
unloadLast(30000);
}
}
public void unloadLast(long age) {
String v = getOldest();
if (v == null) {
return;
}
if (M.ms() - useCache.get(v) > age) {
unload(v);
}
}
private String getOldest() {
long min = M.ms();
String v = null;
for (String i : useCache.k()) {
long t = useCache.get(i);
if (t < min) {
min = t;
v = i;
}
}
return v;
}
private void unload(String v) {
lock.lock();
useCache.remove(v);
loadCache.remove(v);
lock.unlock();
unload.getAndIncrement();
if (unload.get() == 1) {
cl.flip();
}
if (cl.flip()) {
J.a(() -> {
Iris.verbose("Unloaded " + C.WHITE + unload.get() + " " + resourceTypeName + (unload.get() == 1 ? "" : "s") + C.GRAY + " to optimize memory usage." + " (" + Form.f(getLoadCache().size()) + " " + resourceTypeName + (loadCache.size() == 1 ? "" : "s") + " Loaded)");
unload.set(0);
});
}
}
public IrisObject loadFile(File j, String key, String name) {
lock.lock();
try {
IrisObject t = new IrisObject(0, 0, 0);
t.read(j);
loadCache.put(key, t);
logLoad(j);
t.setLoadKey(name);
t.setLoader(manager);
t.setLoadFile(j);
lock.unlock();
return t;
} catch (Throwable e) {
Iris.reportError(e);
lock.unlock();
Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage());
return null;
}
}
public String[] getPossibleKeys() {
if (possibleKeys != null) {
return possibleKeys;
}
Iris.info("Building " + resourceTypeName + " Possibility Lists");
KSet<String> m = new KSet<>();
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")) {
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")) {
m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.iob\\E", ""));
}
}
}
}
}
}
}
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
return possibleKeys;
}
public File findFile(String name) {
lock.lock();
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)) {
lock.unlock();
return j;
}
}
File file = new File(i, name + ".iob");
if (file.exists()) {
lock.unlock();
return file;
}
}
Iris.warn("Couldn't find " + resourceTypeName + ": " + name);
lock.unlock();
return null;
}
public IrisObject load(String name) {
return load(name, true);
}
public IrisObject load(String name, boolean warn) {
String key = name + "-" + objectClass.getCanonicalName();
if (loadCache.containsKey(key)) {
IrisObject t = loadCache.get(key);
useCache.put(key, M.ms());
return t;
}
lock.lock();
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)) {
useCache.put(key, M.ms());
lock.unlock();
return loadFile(j, key, name);
}
}
File file = new File(i, name + ".iob");
if (file.exists()) {
useCache.put(key, M.ms());
lock.unlock();
return loadFile(file, key, name);
}
}
Iris.warn("Couldn't find " + resourceTypeName + ": " + name);
lock.unlock();
return null;
}
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListBiome {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListBiomeDownfallType {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListBlockType {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListDimension {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListEntity {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListFont {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListGenerator {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListItemType {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListJigsaw {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListJigsawPiece {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListJigsawPool {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListLoot {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListMythical {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListObject {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface RegistryListRegion {
}

View File

@@ -1,31 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Target({PARAMETER, TYPE, FIELD})
public @interface Required {
}

View File

@@ -1,256 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisDataManager;
import com.volmit.iris.engine.object.IrisRegistrant;
import lombok.Data;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
@Data
public class ResourceLoader<T extends IrisRegistrant> {
protected File root;
protected String folderName;
protected String resourceTypeName;
protected KMap<String, File> folderMapCache;
protected KMap<String, T> loadCache;
protected KList<File> folderCache;
protected Class<? extends T> objectClass;
protected String cname;
protected IrisLock lock;
protected String[] possibleKeys = null;
protected IrisDataManager manager;
protected AtomicInteger loads;
protected ChronoLatch sec;
public ResourceLoader(File root, IrisDataManager manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
lock = new IrisLock("Res");
this.manager = manager;
sec = new ChronoLatch(5000);
loads = new AtomicInteger();
folderMapCache = new KMap<>();
this.objectClass = objectClass;
cname = objectClass.getCanonicalName();
this.resourceTypeName = resourceTypeName;
this.root = root;
this.folderName = folderName;
loadCache = new KMap<>();
}
public void logLoad(File path) {
loads.getAndIncrement();
if (loads.get() == 1) {
sec.flip();
}
if (sec.flip()) {
J.a(() -> {
Iris.verbose("Loaded " + C.WHITE + loads.get() + " " + resourceTypeName + (loads.get() == 1 ? "" : "s") + C.GRAY + " (" + Form.f(getLoadCache().size()) + " " + resourceTypeName + (loadCache.size() == 1 ? "" : "s") + " Loaded)");
loads.set(0);
});
}
}
public void failLoad(File path, Throwable e) {
J.a(() -> Iris.warn("Couldn't Load " + resourceTypeName + " file: " + path.getPath() + ": " + e.getMessage()));
}
public String[] getPossibleKeys() {
if (possibleKeys != null) {
return possibleKeys;
}
Iris.info("Building " + resourceTypeName + " Registry Lists");
KSet<String> m = new KSet<>();
for (File i : getFolders()) {
for (File j : i.listFiles()) {
if (j.isFile() && j.getName().endsWith(".json")) {
m.add(j.getName().replaceAll("\\Q.json\\E", ""));
} else if (j.isDirectory()) {
for (File k : j.listFiles()) {
if (k.isFile() && k.getName().endsWith(".json")) {
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.json\\E", ""));
}
}
}
}
}
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
return possibleKeys;
}
public long count() {
return loadCache.size();
}
protected T loadFile(File j, String key, String name) {
try {
T t = new Gson().fromJson(IO.readAll(j), objectClass);
loadCache.put(key, t);
logLoad(j);
t.setLoadKey(name);
t.setLoadFile(j);
t.setLoader(manager);
lock.unlock();
return t;
} catch (Throwable e) {Iris.reportError(e);
lock.unlock();
failLoad(j, e);
return null;
}
}
public KList<T> loadAll(KList<String> s)
{
KList<T> m = new KList<>();
for(String i : s)
{
T t = load(i);
if(t != null)
{
m.add(t);
}
}
return m;
}
public T load(String name) {
return load(name, true);
}
public T load(String name, boolean warn) {
if (name == null) {
return null;
}
if (name.trim().isEmpty()) {
return null;
}
String key = name + "-" + cname;
if (loadCache.containsKey(key)) {
return loadCache.get(key);
}
lock.lock();
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 loadFile(j, key, name);
}
}
File file = new File(i, name + ".json");
if (file.exists()) {
return loadFile(file, key, name);
}
}
if (warn && !resourceTypeName.equals("Dimension")) {
J.a(() -> Iris.warn("Couldn't find " + resourceTypeName + ": " + name));
}
lock.unlock();
return null;
}
public KList<File> getFolders() {
lock.lock();
if (folderCache == null) {
folderCache = new KList<>();
for (File i : root.listFiles()) {
if (i.isDirectory()) {
if (i.getName().equals(folderName)) {
folderCache.add(i);
break;
}
}
}
}
lock.unlock();
return folderCache;
}
public KList<File> getFolders(String rc) {
KList<File> folders = getFolders().copy();
if (rc.contains(":")) {
for (File i : folders.copy()) {
if (!rc.startsWith(i.getName() + ":")) {
folders.remove(i);
}
}
}
return folders;
}
public void clearCache() {
lock.lock();
possibleKeys = null;
loadCache.clear();
folderCache = null;
lock.unlock();
}
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())) {
return j;
}
}
File file = new File(i, b.getLoadKey() + ".json");
if (file.exists()) {
return file;
}
}
return null;
}
public boolean isLoaded(String next) {
return loadCache.containsKey(next);
}
public void clearList() {
lock.lock();
folderCache = null;
possibleKeys = null;
lock.unlock();
}
}

View File

@@ -1,138 +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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
import com.volmit.iris.core.nms.BiomeBaseInjector;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.jetbrains.annotations.NotNull;
public interface TerrainChunk extends BiomeGrid, ChunkData {
static TerrainChunk create(World world) {
return create(world.getMaxHeight());
}
static TerrainChunk create(int maxHeight) {
return new LinkedTerrainChunk(maxHeight);
}
static TerrainChunk create(World world, BiomeGrid grid) {
return create(world.getMaxHeight(), grid);
}
static TerrainChunk create(ChunkData raw, BiomeGrid grid) {
return new LinkedTerrainChunk(grid, raw);
}
static TerrainChunk create(int maxHeight, BiomeGrid grid) {
return new LinkedTerrainChunk(grid, maxHeight);
}
BiomeBaseInjector getBiomeBaseInjector();
void setRaw(ChunkData data);
/**
* Get biome at x, z within chunk being generated
*
* @param x - 0-15
* @param z - 0-15
* @return Biome value
* @deprecated biomes are now 3-dimensional
*/
@NotNull
@Deprecated
Biome getBiome(int x, int z);
/**
* Get biome at x, z within chunk being generated
*
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
* @return Biome value
*/
@NotNull
Biome getBiome(int x, int y, int z);
/**
* Set biome at x, z within chunk being generated
*
* @param x - 0-15
* @param z - 0-15
* @param bio - Biome value
* @deprecated biomes are now 3-dimensional
*/
@Deprecated
void setBiome(int x, int z, @NotNull Biome bio);
/**
* 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
*/
void setBiome(int x, int y, int z, @NotNull Biome bio);
/**
* Get the maximum height for the chunk.
* <p>
* Setting blocks at or above this height will do nothing.
*
* @return the maximum height
*/
int getMaxHeight();
/**
* Set the block at x,y,z in the chunk data to material.
* <p>
* 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
*/
void setBlock(int x, int y, int z, @NotNull BlockData blockData);
/**
* Get the type and data of the block at x, y, z.
* <p>
* 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
* @return the data of the block or the BlockData for air if x, y or z are
* outside the chunk's bounds
*/
@NotNull
BlockData getBlockData(int x, int y, int z);
ChunkData getRaw();
void inject(BiomeGrid biome);
}

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.collection;
import java.io.Serializable;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.collection;
import java.util.List;

View File

@@ -16,9 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.collection;
import com.google.common.util.concurrent.AtomicDoubleArray;
import com.volmit.iris.util.json.JSONArray;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import java.util.*;
import java.util.function.Function;

View File

@@ -16,9 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.collection;
import com.volmit.iris.Iris;
import com.volmit.iris.util.function.Consumer2;
import com.volmit.iris.util.function.Consumer3;
import com.volmit.iris.util.scheduling.Queue;
import java.util.Collections;
import java.util.Comparator;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.collection;
import java.util.Collection;
import java.util.HashSet;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.collection;
/**
* Represents a keypair

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.volmit.iris.engine.object.IrisBiome;

View File

@@ -16,8 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.volmit.iris.util.Dimension;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.math.Direction;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
/**
* Represents a cuboid exception

View File

@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.volmit.iris.util.KList;
import java.io.DataInputStream;
import java.io.DataOutputStream;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.google.common.util.concurrent.AtomicDoubleArray;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import java.util.Arrays;

View File

@@ -16,8 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.volmit.iris.util.IrisMathHelper;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import java.io.DataInputStream;
import java.io.DataOutputStream;

View File

@@ -1,9 +1,7 @@
package com.volmit.iris.util;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple;
import org.bukkit.block.Biome;
import com.volmit.iris.util.RandomColor.*;
import com.volmit.iris.util.inventorygui.RandomColor.*;
public class VanillaBiomeMap {

View File

@@ -16,7 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.Shrinkwrap;
public class WeightMap<T> extends KMap<T, Double> {
private static final long serialVersionUID = 87558033900969389L;

View File

@@ -16,7 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KeyPair;
import java.util.Random;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util;
package com.volmit.iris.util.data;
import java.io.DataInputStream;
import java.io.DataOutputStream;

View File

@@ -18,6 +18,9 @@
package com.volmit.iris.util;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RollingSequence;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.NumberFormat;

Some files were not shown because too many files have changed in this diff Show More