mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-25 01:59:15 +00:00
Compare commits
14 Commits
2.4.2-1.19
...
2.5.1-.19.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ebcd02ae6 | ||
|
|
051015656a | ||
|
|
ee082762c6 | ||
|
|
e967b5e052 | ||
|
|
36505e2fa1 | ||
|
|
502aa054f6 | ||
|
|
cc5a880fd7 | ||
|
|
6f9ad8b0eb | ||
|
|
ac6ab74d48 | ||
|
|
807ed2b247 | ||
|
|
367de5a8fd | ||
|
|
5bf2da714a | ||
|
|
cc90f42deb | ||
|
|
20ceaead09 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
|
||||
build/
|
||||
libs/
|
||||
|
||||
.gradle/
|
||||
|
||||
|
||||
26
build.gradle
26
build.gradle
@@ -24,11 +24,11 @@ plugins {
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
version '2.4.1-1.19.3'
|
||||
def nmsVersion = "1.19.3" //[NMS]
|
||||
version '2.5.1-1.19.4'
|
||||
def nmsVersion = "1.19.4" //[NMS]
|
||||
def apiVersion = '1.19'
|
||||
def specialSourceVersion = '1.11.0' //[NMS]
|
||||
def spigotJarVersion = '1.19.3-R0.1-SNAPSHOT' //[NMS]
|
||||
def spigotJarVersion = '1.19.4-R0.1-SNAPSHOT' //[NMS]
|
||||
def name = getRootProject().getName() // Defined in settings.gradle
|
||||
def main = 'com.volmit.iris.Iris'
|
||||
|
||||
@@ -39,7 +39,7 @@ registerCustomOutputTask('Psycho', 'C://Dan/MinecraftDevelopment/Server/plugins'
|
||||
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Coco', 'D://mcsm/plugins')
|
||||
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.3/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins')
|
||||
// ========================== UNIX ==============================
|
||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
||||
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
||||
@@ -74,8 +74,15 @@ repositories {
|
||||
includeGroup("org.spigotmc")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
maven { url "https://arcanearts.jfrog.io/artifactory/archives" }
|
||||
maven { url "https://mvn.lumine.io/repository/maven-public/" }
|
||||
maven { url "https://jitpack.io"}
|
||||
|
||||
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots" }
|
||||
maven { url "https://mvn.lumine.io/repository/maven/" }
|
||||
maven { url "https://repo.triumphteam.dev/snapshots" }
|
||||
maven { url "https://repo.mineinabyss.com/releases" }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,11 +129,14 @@ dependencies {
|
||||
// Provided or Classpath
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
implementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
|
||||
implementation 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT'
|
||||
implementation 'org.bukkit:craftbukkit:1.19.4-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
|
||||
|
||||
// Third Party Integrations
|
||||
implementation 'com.github.oraxen:oraxen:1.152.5'
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.2.5'
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||
implementation 'org.bukkit:craftbukkit:1.19.3-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
||||
//implementation files('libs/CustomItems.jar')
|
||||
|
||||
// Shaded
|
||||
implementation 'com.dfsek:Paralithic:0.4.0'
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.volmit.iris.core.link.MultiverseCoreLink;
|
||||
import com.volmit.iris.core.link.MythicMobsLink;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.nms.v19_3.NMSBinding19_3;
|
||||
import com.volmit.iris.core.nms.v19_4.NMSBinding19_4;
|
||||
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
@@ -66,6 +66,7 @@ import org.bukkit.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -301,8 +302,8 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
msg(C.IRIS + string);
|
||||
}
|
||||
|
||||
public static void info(String string) {
|
||||
msg(C.WHITE + string);
|
||||
public static void info(String format, Object... args) {
|
||||
msg(C.WHITE + String.format(format, args));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -462,33 +463,38 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
FileConfiguration fc = new YamlConfiguration();
|
||||
try {
|
||||
fc.load(new File("bukkit.yml"));
|
||||
searching:
|
||||
for (String i : fc.getKeys(true)) {
|
||||
if (i.startsWith("worlds.") && i.endsWith(".generator")) {
|
||||
String worldName = i.split("\\Q.\\E")[1];
|
||||
String generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
if (fc.getString(i).startsWith("Iris:")) {
|
||||
generator = fc.getString(i).split("\\Q:\\E")[1];
|
||||
} else if (fc.getString(i).equals("Iris")) {
|
||||
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
ConfigurationSection section = fc.getConfigurationSection("worlds");
|
||||
if(section == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (World j : Bukkit.getWorlds()) {
|
||||
if (j.getName().equals(worldName)) {
|
||||
continue searching;
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Detected an Iris World in the bukkit yml '" + worldName + "' using Iris that was not loaded by bukkit. Good Guy Iris will load it up for you!");
|
||||
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + worldName + "' using Iris:" + generator);
|
||||
World world = new WorldCreator(worldName)
|
||||
.generator(getDefaultWorldGenerator(worldName, generator))
|
||||
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
|
||||
.createWorld();
|
||||
Iris.info(C.LIGHT_PURPLE + "Loaded " + worldName + "!");
|
||||
for(String s : section.getKeys(false)){
|
||||
ConfigurationSection entry = section.getConfigurationSection(s);
|
||||
if(!entry.contains("generator", true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String generator = entry.getString("generator");
|
||||
if(generator.startsWith("Iris:")) {
|
||||
generator = generator.split("\\Q:\\E")[1];
|
||||
} else if(generator.equalsIgnoreCase("Iris")) {
|
||||
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
Iris.info("2 World: %s | Generator: %s", s, generator);
|
||||
|
||||
if(Bukkit.getWorlds().stream().anyMatch(w -> w.getName().equals(s))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + s + "' using Iris:" + generator + "...");
|
||||
new WorldCreator(s)
|
||||
.generator(getDefaultWorldGenerator(s, generator))
|
||||
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
|
||||
.createWorld();
|
||||
Iris.info(C.LIGHT_PURPLE + "Loaded " + s + "!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@@ -570,13 +576,13 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
private boolean setupChecks() {
|
||||
boolean passed = true;
|
||||
Iris.info("Version Information: " + instance.getServer().getVersion() + " | " + instance.getServer().getBukkitVersion());
|
||||
if (!instance.getServer().getBukkitVersion().contains(NMSBinding19_3.NMS_VERSION)) {
|
||||
if (!instance.getServer().getBukkitVersion().contains(NMSBinding19_4.NMS_VERSION)) {
|
||||
passed = false;
|
||||
Iris.warn("============================================");
|
||||
Iris.warn("=");
|
||||
Iris.warn("=");
|
||||
Iris.warn("=");
|
||||
Iris.warn("Iris is not compatible with this version of Minecraft.\nPlease use " + NMSBinding19_3.NMS_VERSION + " or use an older version of Iris.");
|
||||
Iris.warn("Iris is not compatible with this version of Minecraft.\nPlease use " + NMSBinding19_4.NMS_VERSION + " or use an older version of Iris.");
|
||||
Iris.warn("=");
|
||||
Iris.warn("=");
|
||||
Iris.warn("=");
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
//package com.volmit.iris.core.link;
|
||||
//
|
||||
//import com.jojodmo.customitems.api.CustomItemsAPI;
|
||||
//import com.jojodmo.customitems.item.custom.CustomItem;
|
||||
//import com.jojodmo.customitems.item.custom.block.CustomMushroomBlock;
|
||||
//import com.jojodmo.customitems.version.SafeMaterial;
|
||||
//import com.volmit.iris.util.collection.KList;
|
||||
//import com.volmit.iris.util.reflect.WrappedField;
|
||||
//import com.volmit.iris.util.reflect.WrappedReturningMethod;
|
||||
//import org.bukkit.block.BlockFace;
|
||||
//import org.bukkit.block.data.BlockData;
|
||||
//import org.bukkit.block.data.MultipleFacing;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//
|
||||
//import java.util.Map;
|
||||
//import java.util.MissingResourceException;
|
||||
//
|
||||
//public class CustomItemsDataProvider extends ExternalDataProvider {
|
||||
//
|
||||
// private static final String FIELD_FACES = "faces";
|
||||
// private static final String METHOD_GET_MATERIAL = "getMaterial";
|
||||
//
|
||||
// private WrappedField<CustomMushroomBlock, Map<Integer, boolean[]>> mushroomFaces;
|
||||
// private WrappedReturningMethod<CustomMushroomBlock, SafeMaterial> mushroomMaterial;
|
||||
//
|
||||
// public CustomItemsDataProvider() {
|
||||
// super("CustomItems");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void init() {
|
||||
// this.mushroomFaces = new WrappedField<>(CustomMushroomBlock.class, FIELD_FACES);
|
||||
// this.mushroomMaterial = new WrappedReturningMethod<>(CustomMushroomBlock.class, METHOD_GET_MATERIAL);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
|
||||
// CustomItem item = CustomItem.get(blockId.key());
|
||||
// if(item == null) {
|
||||
// throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
|
||||
// } else if(item.getBlockTexture().isSpawner()) {
|
||||
// throw new MissingResourceException("Iris does not yet support SpawnerBlocks from CustomItems.", blockId.namespace(), blockId.key());
|
||||
// } else if(item.getBlockTexture() != null && item.getBlockTexture().isValid()) {
|
||||
// throw new MissingResourceException("Tried to fetch BlockData for a CustomItem that is not placeable!", blockId.namespace(), blockId.key());
|
||||
// }
|
||||
// return getMushroomData(item);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
|
||||
// ItemStack stack = CustomItemsAPI.getCustomItem(itemId.key());
|
||||
// if(stack == null) {
|
||||
// throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
|
||||
// }
|
||||
// return stack;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Identifier[] getBlockTypes() {
|
||||
// KList<Identifier> names = new KList<>();
|
||||
// for (String name : CustomItemsAPI.listBlockCustomItemIDs()) {
|
||||
// try {
|
||||
// Identifier key = new Identifier("cui", name);
|
||||
// if (getItemStack(key) != null)
|
||||
// names.add(key);
|
||||
// } catch (MissingResourceException ignored) { }
|
||||
// }
|
||||
//
|
||||
// return names.toArray(new Identifier[0]);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Identifier[] getItemTypes() {
|
||||
// KList<Identifier> names = new KList<>();
|
||||
// for (String name : CustomItemsAPI.listCustomItemIDs()) {
|
||||
// try {
|
||||
// Identifier key = new Identifier("cui", name);
|
||||
// if (getItemStack(key) != null)
|
||||
// names.add(key);
|
||||
// } catch (MissingResourceException ignored) { }
|
||||
// }
|
||||
//
|
||||
// return names.toArray(new Identifier[0]);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isValidProvider(Identifier key, boolean isItem) {
|
||||
// return key.namespace().equalsIgnoreCase("cui");
|
||||
// }
|
||||
//
|
||||
// private BlockData getMushroomData(CustomItem item) {
|
||||
// MultipleFacing data = (MultipleFacing)mushroomMaterial.invoke(item.getBlockTexture().getMushroomId()).parseMaterial().createBlockData();
|
||||
// boolean[] values = mushroomFaces.get().get(item.getBlockTexture().getMushroomId());
|
||||
// data.setFace(BlockFace.DOWN, values[0]);
|
||||
// data.setFace(BlockFace.EAST, values[1]);
|
||||
// data.setFace(BlockFace.NORTH, values[2]);
|
||||
// data.setFace(BlockFace.SOUTH, values[3]);
|
||||
// data.setFace(BlockFace.UP, values[4]);
|
||||
// data.setFace(BlockFace.WEST, values[5]);
|
||||
// return data;
|
||||
// }
|
||||
//}
|
||||
@@ -26,11 +26,13 @@ public abstract class ExternalDataProvider {
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public abstract BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException;
|
||||
public abstract BlockData getBlockData(Identifier blockId) throws MissingResourceException;
|
||||
|
||||
public abstract ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException;
|
||||
public abstract ItemStack getItemStack(Identifier itemId) throws MissingResourceException;
|
||||
|
||||
public abstract NamespacedKey[] getBlockTypes();
|
||||
public abstract Identifier[] getBlockTypes();
|
||||
|
||||
public abstract boolean isValidProvider(NamespacedKey namespace);
|
||||
public abstract Identifier[] getItemTypes();
|
||||
|
||||
public abstract boolean isValidProvider(Identifier id, boolean isItem);
|
||||
}
|
||||
|
||||
33
src/main/java/com/volmit/iris/core/link/Identifier.java
Normal file
33
src/main/java/com/volmit/iris/core/link/Identifier.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.volmit.iris.core.link;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public record Identifier(String namespace, String key) {
|
||||
|
||||
private static final String DEFAULT_NAMESPACE = "minecraft";
|
||||
|
||||
public static Identifier fromString(String id) {
|
||||
String[] strings = id.split(":", 1);
|
||||
if(strings.length == 1) {
|
||||
return new Identifier(DEFAULT_NAMESPACE, strings[0]);
|
||||
} else {
|
||||
return new Identifier(strings[0], strings[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return namespace + ":" + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Identifier i) {
|
||||
return i.namespace().equals(this.namespace) && i.key().equals(this.key);
|
||||
} else if(obj instanceof NamespacedKey i) {
|
||||
return i.getNamespace().equals(this.namespace) && i.getKey().equals(this.key);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.volmit.iris.core.link;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.ItemsAdder;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -12,41 +10,59 @@ import java.util.MissingResourceException;
|
||||
|
||||
public class ItemAdderDataProvider extends ExternalDataProvider {
|
||||
|
||||
private KList<String> itemNamespaces, blockNamespaces;
|
||||
|
||||
public ItemAdderDataProvider() {
|
||||
super("ItemsAdder");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.itemNamespaces = new KList<>();
|
||||
this.blockNamespaces = new KList<>();
|
||||
|
||||
for(Identifier i : getItemTypes()) {
|
||||
itemNamespaces.addIfMissing(i.namespace());
|
||||
}
|
||||
for(Identifier i : getBlockTypes()) {
|
||||
blockNamespaces.addIfMissing(i.namespace());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
|
||||
return CustomBlock.getBaseBlockData(blockId.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException {
|
||||
public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
|
||||
CustomStack stack = CustomStack.getInstance(itemId.toString());
|
||||
if (stack == null)
|
||||
throw new MissingResourceException("Failed to find ItemData!", itemId.getNamespace(), itemId.getKey());
|
||||
if (stack == null) {
|
||||
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
|
||||
}
|
||||
return stack.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getBlockTypes() {
|
||||
KList<NamespacedKey> keys = new KList<>();
|
||||
for (String s : ItemsAdder.getNamespacedBlocksNamesInConfig())
|
||||
keys.add(NamespacedKey.fromString(s));
|
||||
return keys.toArray(new NamespacedKey[0]);
|
||||
public Identifier[] getBlockTypes() {
|
||||
KList<Identifier> keys = new KList<>();
|
||||
for (String s : CustomBlock.getNamespacedIdsInRegistry()) {
|
||||
keys.add(Identifier.fromString(s));
|
||||
}
|
||||
return keys.toArray(new Identifier[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey blockId) {
|
||||
for (NamespacedKey k : getBlockTypes())
|
||||
if (k.equals(blockId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public Identifier[] getItemTypes() {
|
||||
KList<Identifier> keys = new KList<>();
|
||||
for (String s : CustomStack.getNamespacedIdsInRegistry()) {
|
||||
keys.add(Identifier.fromString(s));
|
||||
}
|
||||
return keys.toArray(new Identifier[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(Identifier id, boolean isItem) {
|
||||
return isItem ? this.itemNamespaces.contains(id.namespace()) : this.blockNamespaces.contains(id.namespace());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,17 +20,17 @@ package com.volmit.iris.core.link;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.reflect.WrappedField;
|
||||
import io.th0rgal.oraxen.api.OraxenItems;
|
||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||
import io.th0rgal.oraxen.items.OraxenItems;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicsManager;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.utils.Utils;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -44,7 +44,7 @@ public class OraxenDataProvider extends ExternalDataProvider {
|
||||
|
||||
private static final String FIELD_FACTORIES_MAP = "FACTORIES_BY_MECHANIC_ID";
|
||||
|
||||
private Map<String, MechanicFactory> factories;
|
||||
private WrappedField<MechanicsManager, Map<String, MechanicFactory>> factories;
|
||||
|
||||
public OraxenDataProvider() {
|
||||
super("Oraxen");
|
||||
@@ -52,48 +52,59 @@ public class OraxenDataProvider extends ExternalDataProvider {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
try {
|
||||
Field f = MechanicsManager.class.getDeclaredField(FIELD_FACTORIES_MAP);
|
||||
f.setAccessible(true);
|
||||
factories = (Map<String, MechanicFactory>) f.get(null);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
Iris.error("Failed to set up Oraxen Link:");
|
||||
Iris.error("\t" + e.getClass().getSimpleName());
|
||||
this.factories = new WrappedField<>(MechanicsManager.class, FIELD_FACTORIES_MAP);
|
||||
if(this.factories.hasFailed()) {
|
||||
Iris.error("Failed to set up Oraxen Link: Unable to fetch MechanicFactoriesMap!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
MechanicFactory f = getFactory(blockId);
|
||||
if (f instanceof NoteBlockMechanicFactory)
|
||||
return ((NoteBlockMechanicFactory) f).createNoteBlockData(blockId.getKey());
|
||||
else if (f instanceof BlockMechanicFactory) {
|
||||
public BlockData getBlockData(Identifier blockId) throws MissingResourceException {
|
||||
MechanicFactory factory = getFactory(blockId);
|
||||
if (factory instanceof NoteBlockMechanicFactory f)
|
||||
return f.createNoteBlockData(blockId.key());
|
||||
else if (factory instanceof BlockMechanicFactory f) {
|
||||
MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM);
|
||||
Utils.setBlockFacing(newBlockData, ((BlockMechanic) f.getMechanic(blockId.getKey())).getCustomVariation());
|
||||
BlockMechanic.setBlockFacing(newBlockData, ((BlockMechanic) f.getMechanic(blockId.key())).getCustomVariation());
|
||||
return newBlockData;
|
||||
} else if (factory instanceof StringBlockMechanicFactory f) {
|
||||
return f.createTripwireData(blockId.key());
|
||||
} else
|
||||
throw new MissingResourceException("Failed to find BlockData!", blockId.getNamespace(), blockId.getKey());
|
||||
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException {
|
||||
Optional<ItemBuilder> opt = OraxenItems.getOptionalItemById(itemId.getKey());
|
||||
return opt.orElseThrow(() -> new MissingResourceException("Failed to find ItemData!", itemId.getNamespace(), itemId.getKey())).build();
|
||||
public ItemStack getItemStack(Identifier itemId) throws MissingResourceException {
|
||||
Optional<ItemBuilder> opt = OraxenItems.getOptionalItemById(itemId.key());
|
||||
return opt.orElseThrow(() -> new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key())).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getBlockTypes() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
public Identifier[] getBlockTypes() {
|
||||
KList<Identifier> names = new KList<>();
|
||||
for (String name : OraxenItems.getItemNames()) {
|
||||
try {
|
||||
NamespacedKey key = new NamespacedKey("oraxen", name);
|
||||
Identifier key = new Identifier("oraxen", name);
|
||||
if (getBlockData(key) != null)
|
||||
names.add(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
} catch (MissingResourceException ignored) { }
|
||||
}
|
||||
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
return names.toArray(new Identifier[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier[] getItemTypes() {
|
||||
KList<Identifier> names = new KList<>();
|
||||
for (String name : OraxenItems.getItemNames()) {
|
||||
try {
|
||||
Identifier key = new Identifier("oraxen", name);
|
||||
if (getItemStack(key) != null)
|
||||
names.add(key);
|
||||
} catch (MissingResourceException ignored) { }
|
||||
}
|
||||
|
||||
return names.toArray(new Identifier[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,14 +113,14 @@ public class OraxenDataProvider extends ExternalDataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey key) {
|
||||
return key.getNamespace().equalsIgnoreCase("oraxen");
|
||||
public boolean isValidProvider(Identifier key, boolean isItem) {
|
||||
return key.namespace().equalsIgnoreCase("oraxen");
|
||||
}
|
||||
|
||||
private MechanicFactory getFactory(NamespacedKey key) throws MissingResourceException {
|
||||
return factories.values().stream()
|
||||
.filter(i -> i.getItems().contains(key.getKey()))
|
||||
private MechanicFactory getFactory(Identifier key) throws MissingResourceException {
|
||||
return factories.get().values().stream()
|
||||
.filter(i -> i.getItems().contains(key.key()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new MissingResourceException("Failed to find BlockData!", key.getNamespace(), key.getKey()));
|
||||
.orElseThrow(() -> new MissingResourceException("Failed to find BlockData!", key.namespace(), key.key()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.core.nms;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.nms.v19_3.NMSBinding19_3;
|
||||
import com.volmit.iris.core.nms.v19_4.NMSBinding19_4;
|
||||
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -28,7 +28,7 @@ import org.bukkit.Bukkit;
|
||||
public class INMS {
|
||||
//@builder
|
||||
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
|
||||
.qput("v1_19_R2", NMSBinding19_3.class);
|
||||
.qput("v1_19_R3", NMSBinding19_4.class);
|
||||
//@done
|
||||
private static final INMSBinding binding = bind();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.volmit.iris.core.nms.v19_3;
|
||||
package com.volmit.iris.core.nms.v19_4;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.volmit.iris.Iris;
|
||||
@@ -18,16 +18,18 @@ import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CustomBiomeSource extends BiomeSource {
|
||||
|
||||
private final long seed;
|
||||
private final Engine engine;
|
||||
private final Registry<Biome> biomeCustomRegistry;
|
||||
@@ -37,19 +39,23 @@ public class CustomBiomeSource extends BiomeSource {
|
||||
private final KMap<String, Holder<Biome>> customBiomes;
|
||||
|
||||
public CustomBiomeSource(long seed, Engine engine, World world) {
|
||||
super(getAllBiomes(
|
||||
((RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()))
|
||||
.registry(Registries.BIOME).orElse(null),
|
||||
((CraftWorld) world).getHandle().registryAccess().registry(Registries.BIOME).orElse(null),
|
||||
engine));
|
||||
this.engine = engine;
|
||||
this.seed = seed;
|
||||
this.biomeCustomRegistry = registry().registry(Registries.BIOME).orElse(null);
|
||||
this.biomeRegistry = ((CraftWorld) world).getHandle().registryAccess().registry(Registries.BIOME).orElse(null);
|
||||
this.biomeRegistry = ((RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer())).registry(Registries.BIOME).orElse(null);
|
||||
this.rng = new RNG(engine.getSeedManager().getBiome());
|
||||
this.customBiomes = fillCustomBiomes(biomeCustomRegistry, engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
||||
return getAllBiomes(
|
||||
((RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()))
|
||||
.registry(Registries.BIOME).orElse(null),
|
||||
((CraftWorld) engine.getWorld().realWorld()).getHandle().registryAccess().registry(Registries.BIOME).orElse(null),
|
||||
engine).stream();
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getAllBiomes(Registry<Biome> customRegistry, Registry<Biome> registry, Engine engine) {
|
||||
List<Holder<Biome>> b = new ArrayList<>();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.core.nms.v19_3;
|
||||
package com.volmit.iris.core.nms.v19_4;
|
||||
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
@@ -46,10 +46,11 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -64,9 +65,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class NMSBinding19_3 implements INMSBinding {
|
||||
public class NMSBinding19_4 implements INMSBinding {
|
||||
|
||||
public static final String NMS_VERSION = "1.19.3";
|
||||
public static final String NMS_VERSION = "1.19.4";
|
||||
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
||||
private final BlockData AIR = Material.AIR.createBlockData();
|
||||
private final AtomicCache<MCAIdMap<net.minecraft.world.level.biome.Biome>> biomeMapCache = new AtomicCache<>();
|
||||
@@ -197,7 +198,6 @@ public class NMSBinding19_3 implements INMSBinding {
|
||||
}
|
||||
|
||||
private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() {
|
||||
|
||||
return registry().registry(Registries.BIOME).orElse(null);
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class NMSBinding19_3 implements INMSBinding {
|
||||
|
||||
@Override
|
||||
public Object getBiomeBase(World world, Biome biome) {
|
||||
return org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock.biomeToBiomeBase(((CraftWorld) world).getHandle()
|
||||
return CraftBlock.biomeToBiomeBase(((CraftWorld) world).getHandle()
|
||||
.registryAccess().registry(Registries.BIOME).orElse(null), biome);
|
||||
}
|
||||
|
||||
@@ -268,13 +268,13 @@ public class NMSBinding19_3 implements INMSBinding {
|
||||
return v;
|
||||
}
|
||||
//noinspection unchecked
|
||||
v = org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
|
||||
v = CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
|
||||
if (v == null) {
|
||||
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
|
||||
// But, this does NOT exist within CraftBukkit which makes it return an error.
|
||||
// So, we will just return the ID that the plains biome returns instead.
|
||||
//noinspection unchecked
|
||||
return org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
|
||||
return CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
|
||||
}
|
||||
baseBiomeCache.put(biome, v);
|
||||
return v;
|
||||
@@ -394,7 +394,6 @@ public class NMSBinding19_3 implements INMSBinding {
|
||||
return f;
|
||||
}
|
||||
try {
|
||||
|
||||
f = storage.getClass().getDeclaredField("biome");
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
@@ -101,7 +101,8 @@ public class IrisPregenerator {
|
||||
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
|
||||
|
||||
if (cl.flip()) {
|
||||
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (" + Form.pc((double) generated.get() / (double) totalChunks.get(), 0) + ") " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2));
|
||||
double percentage = ((double) generated.get() / (double) totalChunks.get()) * 100;
|
||||
Iris.info("Pregen: " + Form.f(generated.get()) + " of " + Form.f(totalChunks.get()) + " (%.0f%%) " + Form.f((int) chunksPerSecond.getAverage()) + "/s ETA: " + Form.duration((double) eta, 2), percentage);
|
||||
}
|
||||
|
||||
return 1000;
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.core.BlockPos;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftDolphin;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftDolphin;
|
||||
import org.bukkit.entity.Dolphin;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
package com.volmit.iris.core.service;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.link.ExternalDataProvider;
|
||||
import com.volmit.iris.core.link.ItemAdderDataProvider;
|
||||
import com.volmit.iris.core.link.OraxenDataProvider;
|
||||
import com.volmit.iris.core.link.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import lombok.Data;
|
||||
@@ -39,7 +37,10 @@ public class ExternalDataSVC implements IrisService {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
addProvider(new OraxenDataProvider(), new ItemAdderDataProvider());
|
||||
addProvider(
|
||||
// new CustomItemsDataProvider(), //need this to be gradelized before i can add it to the master repo
|
||||
new OraxenDataProvider(),
|
||||
new ItemAdderDataProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,8 +56,8 @@ public class ExternalDataSVC implements IrisService {
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<BlockData> getBlockData(NamespacedKey key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key)).findFirst();
|
||||
public Optional<BlockData> getBlockData(Identifier key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key, false)).findFirst();
|
||||
if (provider.isEmpty())
|
||||
return Optional.empty();
|
||||
try {
|
||||
@@ -67,10 +68,12 @@ public class ExternalDataSVC implements IrisService {
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<ItemStack> getItemStack(NamespacedKey key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key)).findFirst();
|
||||
if (provider.isEmpty())
|
||||
public Optional<ItemStack> getItemStack(Identifier key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key, true)).findFirst();
|
||||
if (provider.isEmpty()) {
|
||||
Iris.warn("No matching Provider found for modded material \"%s\"!", key);
|
||||
return Optional.empty();
|
||||
}
|
||||
try {
|
||||
return Optional.of(provider.get().getItemStack(key));
|
||||
} catch (MissingResourceException e) {
|
||||
@@ -79,9 +82,15 @@ public class ExternalDataSVC implements IrisService {
|
||||
}
|
||||
}
|
||||
|
||||
public NamespacedKey[] getAllIdentifiers() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
public Identifier[] getAllBlockIdentifiers() {
|
||||
KList<Identifier> names = new KList<>();
|
||||
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getBlockTypes()));
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
return names.toArray(new Identifier[0]);
|
||||
}
|
||||
|
||||
public Identifier[] getAllItemIdentifiers() {
|
||||
KList<Identifier> names = new KList<>();
|
||||
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getItemTypes()));
|
||||
return names.toArray(new Identifier[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public class IrisBiomeCustom {
|
||||
j.put("temperature", getTemperature());
|
||||
j.put("downfall", getHumidity());
|
||||
j.put("creature_spawn_probability", getSpawnRarity());
|
||||
j.put("has_precipitation", getDownfallType() != IrisBiomeCustomPrecipType.none);
|
||||
j.put("precipitation", getDownfallType().toString().toLowerCase());
|
||||
j.put("category", getCategory().toString().toLowerCase());
|
||||
j.put("effects", effects);
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.link.Identifier;
|
||||
import com.volmit.iris.core.service.ExternalDataSVC;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
@@ -39,8 +40,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
@@ -149,10 +149,10 @@ public class IrisLoot {
|
||||
// TODO Better Third Party Item Acquisition
|
||||
private ItemStack getItemStack(RNG rng) {
|
||||
if (!type.startsWith("minecraft:") && type.contains(":")) {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(Identifier.fromString(type));
|
||||
if (opt.isEmpty()) {
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
ItemStack is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
@@ -198,8 +198,10 @@ public class IrisLoot {
|
||||
colorable.setColor(getDyeColor());
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
if(displayName != null) {
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
|
||||
@@ -494,29 +494,37 @@ public class IrisObject extends IrisRegistrant {
|
||||
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, BiConsumer<BlockPosition, BlockData> listener, CarveResult c, IrisData rdata) {
|
||||
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
|
||||
|
||||
// Rotation calculation
|
||||
int slopeRotationY = 0;
|
||||
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
|
||||
if (config.isRotateTowardsSlope()) {
|
||||
// Whichever side of the rectangle that bounds the object is lowest is the 'direction' of the slope (simply said).
|
||||
double hNorth = heightStream.get(x, z + ((float)d) / 2);
|
||||
double hEast = heightStream.get(x + ((float)w) / 2, z);
|
||||
double hSouth = heightStream.get(x, z - ((float)d) / 2);
|
||||
double hWest = heightStream.get(x - ((float)w) / 2, z);
|
||||
double min = Math.min(Math.min(hNorth, hEast), Math.min(hSouth, hWest));
|
||||
if (min == hNorth) {
|
||||
slopeRotationY = 0;
|
||||
} else if (min == hEast) {
|
||||
slopeRotationY = 90;
|
||||
} else if (min == hSouth) {
|
||||
slopeRotationY = 180;
|
||||
} else if (min == hWest) {
|
||||
slopeRotationY = 270;
|
||||
if (rdata != null) {
|
||||
// Slope condition
|
||||
if (!config.getSlopeCondition().isDefault() &&
|
||||
!config.getSlopeCondition().isValid(rdata.getEngine().getComplex().getSlopeStream().get(x, z))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rotation calculation
|
||||
int slopeRotationY = 0;
|
||||
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
|
||||
if (config.isRotateTowardsSlope()) {
|
||||
// Whichever side of the rectangle that bounds the object is lowest is the 'direction' of the slope (simply said).
|
||||
double hNorth = heightStream.get(x, z + ((float) d) / 2);
|
||||
double hEast = heightStream.get(x + ((float) w) / 2, z);
|
||||
double hSouth = heightStream.get(x, z - ((float) d) / 2);
|
||||
double hWest = heightStream.get(x - ((float) w) / 2, z);
|
||||
double min = Math.min(Math.min(hNorth, hEast), Math.min(hSouth, hWest));
|
||||
if (min == hNorth) {
|
||||
slopeRotationY = 0;
|
||||
} else if (min == hEast) {
|
||||
slopeRotationY = 90;
|
||||
} else if (min == hSouth) {
|
||||
slopeRotationY = 180;
|
||||
} else if (min == hWest) {
|
||||
slopeRotationY = 270;
|
||||
}
|
||||
}
|
||||
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
|
||||
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 360));
|
||||
config.getRotation().setEnabled(true);
|
||||
}
|
||||
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
|
||||
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 360));
|
||||
config.getRotation().setEnabled(true);
|
||||
|
||||
if (config.isSmartBore()) {
|
||||
ensureSmartBored(placer.isDebugSmartBore());
|
||||
|
||||
@@ -62,6 +62,8 @@ public class IrisObjectPlacement {
|
||||
private double snow = 0;
|
||||
@Desc("Whether or not this object can be targeted by a dolphin.")
|
||||
private boolean isDolphinTarget = false;
|
||||
@Desc("The slope at which this object can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the object placement.")
|
||||
private IrisSlopeClip slopeCondition = new IrisSlopeClip();
|
||||
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object." +
|
||||
"Rounded to 90 degrees. Adds the *min* rotation of the y axis as well (to still allow you to rotate objects nicely). Discards *max* and *interval* on *yaxis*")
|
||||
private boolean rotateTowardsSlope = false;
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.engine.platform;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.nms.v19_3.CustomBiomeSource;
|
||||
import com.volmit.iris.core.nms.v19_4.CustomBiomeSource;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||
@@ -46,7 +46,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -92,6 +92,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
@Setter
|
||||
private StudioGenerator studioGenerator;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
||||
setup = new AtomicBoolean(false);
|
||||
studioGenerator = null;
|
||||
@@ -124,21 +126,23 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
@EventHandler
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
try {
|
||||
if (world.name().equals(event.getWorld().getName()) && world.getRawWorldSeed() == event.getWorld().getSeed()) {
|
||||
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
|
||||
Engine engine = getEngine(event.getWorld());
|
||||
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
|
||||
Field biomeSource = getField(clazz, "b");
|
||||
biomeSource.setAccessible(true);
|
||||
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
||||
CustomBiomeSource customBiomeSource = new CustomBiomeSource(event.getWorld().getSeed(), engine, event.getWorld());
|
||||
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
|
||||
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
|
||||
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
|
||||
} else {
|
||||
Iris.info("World " + event.getWorld().getName() + " is not an Iris world in this context");
|
||||
if(!initialized) {
|
||||
world.setRawWorldSeed(event.getWorld().getSeed());
|
||||
if (world.name().equals(event.getWorld().getName())) {
|
||||
ServerLevel serverLevel = ((CraftWorld) event.getWorld()).getHandle();
|
||||
Engine engine = getEngine(event.getWorld());
|
||||
Class<?> clazz = serverLevel.getChunkSource().chunkMap.generator.getClass();
|
||||
Field biomeSource = getField(clazz, "b");
|
||||
biomeSource.setAccessible(true);
|
||||
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
Unsafe unsafe = (Unsafe) unsafeField.get(null);
|
||||
CustomBiomeSource customBiomeSource = new CustomBiomeSource(event.getWorld().getSeed(), engine, event.getWorld());
|
||||
unsafe.putObject(biomeSource.get(serverLevel.getChunkSource().chunkMap.generator), unsafe.objectFieldOffset(biomeSource), customBiomeSource);
|
||||
biomeSource.set(serverLevel.getChunkSource().chunkMap.generator, customBiomeSource);
|
||||
Iris.info("Injected Iris Biome Source into " + event.getWorld().getName());
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
public class DummyBiomeProvider extends BiomeProvider {
|
||||
private final List<Biome> ALL = new KList<>(Biome.values()).qdel(Biome.CUSTOM);
|
||||
private final List<Biome> ALL = new KList<>(Biome.values()).qdel(Biome.CHERRY_GROVE).qdel(Biome.CUSTOM);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.volmit.iris.util.data;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.link.Identifier;
|
||||
import com.volmit.iris.core.service.ExternalDataSVC;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@@ -27,7 +28,6 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
@@ -471,7 +471,7 @@ public class B {
|
||||
BlockData bx = null;
|
||||
|
||||
if (!ix.startsWith("minecraft:") && ix.contains(":")) {
|
||||
NamespacedKey key = NamespacedKey.fromString(ix);
|
||||
Identifier key = Identifier.fromString(ix);
|
||||
Optional<BlockData> bd = Iris.service(ExternalDataSVC.class).getBlockData(key);
|
||||
if (bd.isPresent())
|
||||
bx = bd.get();
|
||||
@@ -647,7 +647,7 @@ public class B {
|
||||
}
|
||||
}
|
||||
|
||||
for (NamespacedKey id : Iris.service(ExternalDataSVC.class).getAllIdentifiers())
|
||||
for (Identifier id : Iris.service(ExternalDataSVC.class).getAllBlockIdentifiers())
|
||||
bt.add(id.toString());
|
||||
bt.addAll(custom.k());
|
||||
|
||||
@@ -662,6 +662,9 @@ public class B {
|
||||
bt.add(v);
|
||||
}
|
||||
|
||||
for (Identifier id : Iris.service(ExternalDataSVC.class).getAllItemIdentifiers())
|
||||
bt.add(id.toString());
|
||||
|
||||
return bt.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
||||
42
src/main/java/com/volmit/iris/util/reflect/WrappedField.java
Normal file
42
src/main/java/com/volmit/iris/util/reflect/WrappedField.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.volmit.iris.util.reflect;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedField<C, T> {
|
||||
|
||||
private final Field field;
|
||||
|
||||
public WrappedField(Class<C> origin, String methodName) {
|
||||
Field f = null;
|
||||
try {
|
||||
f = origin.getDeclaredField(methodName);
|
||||
f.setAccessible(true);
|
||||
} catch(NoSuchFieldException e) {
|
||||
Iris.error("Failed to created WrappedField %s#%s: %s%s", origin.getSimpleName(), methodName, e.getClass().getSimpleName(), e.getMessage().equals("") ? "" : " | " + e.getMessage());
|
||||
}
|
||||
this.field = f;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return get(null);
|
||||
}
|
||||
|
||||
public T get(C instance) {
|
||||
if(field == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return (T)field.get(instance);
|
||||
} catch(IllegalAccessException e) {
|
||||
Iris.error("Failed to get WrappedField %s#%s: %s%s", field.getDeclaringClass().getSimpleName(), field.getName(), e.getClass().getSimpleName(), e.getMessage().equals("") ? "" : " | " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFailed() {
|
||||
return field == null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.volmit.iris.util.reflect;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class WrappedReturningMethod<C, R> {
|
||||
|
||||
private final Method method;
|
||||
|
||||
public WrappedReturningMethod(Class<C> origin, String methodName, Class<?>... paramTypes) {
|
||||
Method m = null;
|
||||
try {
|
||||
m = origin.getDeclaredMethod(methodName, paramTypes);
|
||||
m.setAccessible(true);
|
||||
} catch(NoSuchMethodException e) {
|
||||
Iris.error("Failed to created WrappedMethod %s#%s: %s%s", origin.getSimpleName(), methodName, e.getClass().getSimpleName(), e.getMessage().equals("") ? "" : " | " + e.getMessage());
|
||||
}
|
||||
this.method = m;
|
||||
}
|
||||
|
||||
public R invoke(Object... args) {
|
||||
return invoke(null, args);
|
||||
}
|
||||
|
||||
public R invoke(C instance, Object... args) {
|
||||
if(method == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return (R)method.invoke(instance, args);
|
||||
} catch(InvocationTargetException | IllegalAccessException e) {
|
||||
Iris.error("Failed to invoke WrappedMethod %s#%s: %s%s", method.getDeclaringClass().getSimpleName(), method.getName(), e.getClass().getSimpleName(), e.getMessage().equals("") ? "" : " | " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,4 +21,6 @@ commands:
|
||||
iris:
|
||||
aliases: [ ir, irs ]
|
||||
api-version: ${apiversion}
|
||||
softdepend:
|
||||
- ItemsAdder
|
||||
hotload-dependencies: false
|
||||
Reference in New Issue
Block a user