mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-03 16:36:00 +00:00
1.20 Baseline
This commit is contained in:
parent
f5a3a7eb1a
commit
b0c96be841
12
build.gradle
12
build.gradle
@ -24,11 +24,11 @@ plugins {
|
|||||||
id "de.undercouch.download" version "5.0.1"
|
id "de.undercouch.download" version "5.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
version '2.6.2-1.19.4'
|
version '2.7.0-1.20.0'
|
||||||
def nmsVersion = "1.19.4" //[NMS]
|
def nmsVersion = "1.20" //[NMS]
|
||||||
def apiVersion = '1.19'
|
def apiVersion = '1.20'
|
||||||
def specialSourceVersion = '1.11.0' //[NMS]
|
def specialSourceVersion = '1.11.0' //[NMS]
|
||||||
def spigotJarVersion = '1.19.4-R0.1-SNAPSHOT' //[NMS]
|
def spigotJarVersion = '1.20-R0.1-SNAPSHOT' //[NMS]
|
||||||
def name = getRootProject().getName() // Defined in settings.gradle
|
def name = getRootProject().getName() // Defined in settings.gradle
|
||||||
def main = 'com.volmit.iris.Iris'
|
def main = 'com.volmit.iris.Iris'
|
||||||
|
|
||||||
@ -129,8 +129,8 @@ dependencies {
|
|||||||
// Provided or Classpath
|
// Provided or Classpath
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||||
implementation 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT'
|
implementation 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
||||||
implementation 'org.bukkit:craftbukkit:1.19.4-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
|
implementation 'org.bukkit:craftbukkit:1.20-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
|
||||||
|
|
||||||
// Third Party Integrations
|
// Third Party Integrations
|
||||||
implementation 'com.github.oraxen:oraxen:1.152.5'
|
implementation 'com.github.oraxen:oraxen:1.152.5'
|
||||||
|
@ -28,7 +28,7 @@ import com.volmit.iris.core.link.MultiverseCoreLink;
|
|||||||
import com.volmit.iris.core.link.MythicMobsLink;
|
import com.volmit.iris.core.link.MythicMobsLink;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.nms.v19_4.NMSBinding19_4;
|
import com.volmit.iris.core.nms.v20.NMSBinding19_4;
|
||||||
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
|
@ -1,77 +1,77 @@
|
|||||||
/*
|
/*
|
||||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.volmit.iris.core.nms;
|
package com.volmit.iris.core.nms;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.nms.v19_4.NMSBinding19_4;
|
import com.volmit.iris.core.nms.v20.NMSBinding19_4;
|
||||||
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class INMS {
|
public class INMS {
|
||||||
//@builder
|
//@builder
|
||||||
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
|
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
|
||||||
.qput("v1_19_R3", NMSBinding19_4.class);
|
.qput("v1_19_R3", NMSBinding19_4.class);
|
||||||
//@done
|
//@done
|
||||||
private static final INMSBinding binding = bind();
|
private static final INMSBinding binding = bind();
|
||||||
|
|
||||||
public static INMSBinding get() {
|
public static INMSBinding get() {
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNMSTag() {
|
public static String getNMSTag() {
|
||||||
if (IrisSettings.get().getGeneral().isDisableNMS()) {
|
if (IrisSettings.get().getGeneral().isDisableNMS()) {
|
||||||
return "BUKKIT";
|
return "BUKKIT";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Bukkit.getServer().getClass().getCanonicalName().split("\\Q.\\E")[3];
|
return Bukkit.getServer().getClass().getCanonicalName().split("\\Q.\\E")[3];
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
Iris.error("Failed to determine server nms version!");
|
Iris.error("Failed to determine server nms version!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "BUKKIT";
|
return "BUKKIT";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static INMSBinding bind() {
|
private static INMSBinding bind() {
|
||||||
String code = getNMSTag();
|
String code = getNMSTag();
|
||||||
Iris.info("Locating NMS Binding for " + code);
|
Iris.info("Locating NMS Binding for " + code);
|
||||||
|
|
||||||
if (bindings.containsKey(code)) {
|
if (bindings.containsKey(code)) {
|
||||||
try {
|
try {
|
||||||
INMSBinding b = bindings.get(code).getConstructor().newInstance();
|
INMSBinding b = bindings.get(code).getConstructor().newInstance();
|
||||||
Iris.info("Craftbukkit " + code + " <-> " + b.getClass().getSimpleName() + " Successfully Bound");
|
Iris.info("Craftbukkit " + code + " <-> " + b.getClass().getSimpleName() + " Successfully Bound");
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iris.info("Craftbukkit " + code + " <-> " + NMSBinding1X.class.getSimpleName() + " Successfully Bound");
|
Iris.info("Craftbukkit " + code + " <-> " + NMSBinding1X.class.getSimpleName() + " Successfully Bound");
|
||||||
Iris.warn("Note: Some features of Iris may not work the same since you are on an unsupported version of Minecraft.");
|
Iris.warn("Note: Some features of Iris may not work the same since you are on an unsupported version of Minecraft.");
|
||||||
Iris.warn("Note: If this is a new version, expect an update soon.");
|
Iris.warn("Note: If this is a new version, expect an update soon.");
|
||||||
|
|
||||||
return new NMSBinding1X();
|
return new NMSBinding1X();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.volmit.iris.core.nms.v19_4;
|
package com.volmit.iris.core.nms.v20;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
@ -18,10 +18,9 @@ import net.minecraft.world.level.biome.BiomeSource;
|
|||||||
import net.minecraft.world.level.biome.Climate;
|
import net.minecraft.world.level.biome.Climate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,453 +1,454 @@
|
|||||||
/*
|
/*
|
||||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.volmit.iris.core.nms.v19_4;
|
package com.volmit.iris.core.nms.v20;
|
||||||
|
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.nms.INMSBinding;
|
import com.volmit.iris.core.nms.INMSBinding;
|
||||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
import com.volmit.iris.util.matter.MatterBiomeInject;
|
import com.volmit.iris.util.matter.MatterBiomeInject;
|
||||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
import com.volmit.iris.util.nbt.io.NBTUtil;
|
||||||
import com.volmit.iris.util.nbt.mca.NBTWorld;
|
import com.volmit.iris.util.nbt.mca.NBTWorld;
|
||||||
import com.volmit.iris.util.nbt.mca.palette.*;
|
import com.volmit.iris.util.nbt.mca.palette.*;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.craftbukkit.v1_20_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.entity.Entity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataInputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.io.DataOutputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
public class NMSBinding19_4 implements INMSBinding {
|
|
||||||
|
public class NMSBinding19_4 implements INMSBinding {
|
||||||
public static final String NMS_VERSION = "1.19.4";
|
|
||||||
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
public static final String NMS_VERSION = "1.19.4";
|
||||||
private final BlockData AIR = Material.AIR.createBlockData();
|
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
||||||
private final AtomicCache<MCAIdMap<net.minecraft.world.level.biome.Biome>> biomeMapCache = new AtomicCache<>();
|
private final BlockData AIR = Material.AIR.createBlockData();
|
||||||
private final AtomicCache<MCAIdMapper<BlockState>> registryCache = new AtomicCache<>();
|
private final AtomicCache<MCAIdMap<net.minecraft.world.level.biome.Biome>> biomeMapCache = new AtomicCache<>();
|
||||||
private final AtomicCache<MCAPalette<BlockState>> globalCache = new AtomicCache<>();
|
private final AtomicCache<MCAIdMapper<BlockState>> registryCache = new AtomicCache<>();
|
||||||
private final AtomicCache<RegistryAccess> registryAccess = new AtomicCache<>();
|
private final AtomicCache<MCAPalette<BlockState>> globalCache = new AtomicCache<>();
|
||||||
private final AtomicCache<Method> byIdRef = new AtomicCache<>();
|
private final AtomicCache<RegistryAccess> registryAccess = new AtomicCache<>();
|
||||||
private Field biomeStorageCache = null;
|
private final AtomicCache<Method> byIdRef = new AtomicCache<>();
|
||||||
|
private Field biomeStorageCache = null;
|
||||||
private static Object getFor(Class<?> type, Object source) {
|
|
||||||
Object o = fieldFor(type, source);
|
private static Object getFor(Class<?> type, Object source) {
|
||||||
|
Object o = fieldFor(type, source);
|
||||||
if (o != null) {
|
|
||||||
return o;
|
if (o != null) {
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
return invokeFor(type, source);
|
|
||||||
}
|
return invokeFor(type, source);
|
||||||
|
}
|
||||||
private static Object invokeFor(Class<?> returns, Object in) {
|
|
||||||
for (Method i : in.getClass().getMethods()) {
|
private static Object invokeFor(Class<?> returns, Object in) {
|
||||||
if (i.getReturnType().equals(returns)) {
|
for (Method i : in.getClass().getMethods()) {
|
||||||
i.setAccessible(true);
|
if (i.getReturnType().equals(returns)) {
|
||||||
try {
|
i.setAccessible(true);
|
||||||
Iris.debug("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
|
try {
|
||||||
return i.invoke(in);
|
Iris.debug("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
|
||||||
} catch (Throwable e) {
|
return i.invoke(in);
|
||||||
e.printStackTrace();
|
} catch (Throwable e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
private static Object fieldFor(Class<?> returns, Object in) {
|
|
||||||
return fieldForClass(returns, in.getClass(), in);
|
private static Object fieldFor(Class<?> returns, Object in) {
|
||||||
}
|
return fieldForClass(returns, in.getClass(), in);
|
||||||
|
}
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
|
@SuppressWarnings("unchecked")
|
||||||
for (Field i : sourceType.getDeclaredFields()) {
|
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
|
||||||
if (i.getType().equals(returnType)) {
|
for (Field i : sourceType.getDeclaredFields()) {
|
||||||
i.setAccessible(true);
|
if (i.getType().equals(returnType)) {
|
||||||
try {
|
i.setAccessible(true);
|
||||||
Iris.debug("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
|
try {
|
||||||
return (T) i.get(in);
|
Iris.debug("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
|
||||||
} catch (IllegalAccessException e) {
|
return (T) i.get(in);
|
||||||
e.printStackTrace();
|
} catch (IllegalAccessException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
private static Class<?> getClassType(Class<?> type, int ordinal) {
|
|
||||||
return type.getDeclaredClasses()[ordinal];
|
private static Class<?> getClassType(Class<?> type, int ordinal) {
|
||||||
}
|
return type.getDeclaredClasses()[ordinal];
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean hasTile(Location l) {
|
@Override
|
||||||
return ((CraftWorld) l.getWorld()).getHandle().getBlockEntity(new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null;
|
public boolean hasTile(Location l) {
|
||||||
}
|
return ((CraftWorld) l.getWorld()).getHandle().getBlockEntity(new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public CompoundTag serializeTile(Location location) {
|
@Override
|
||||||
BlockEntity e = ((CraftWorld) location.getWorld()).getHandle().getBlockEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
|
public CompoundTag serializeTile(Location location) {
|
||||||
|
BlockEntity e = ((CraftWorld) location.getWorld()).getHandle().getBlockEntity(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
|
||||||
if (e == null) {
|
|
||||||
return null;
|
if (e == null) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
net.minecraft.nbt.CompoundTag tag = e.saveWithFullMetadata();
|
|
||||||
return convert(tag);
|
net.minecraft.nbt.CompoundTag tag = e.saveWithFullMetadata();
|
||||||
}
|
return convert(tag);
|
||||||
|
}
|
||||||
private CompoundTag convert(net.minecraft.nbt.CompoundTag tag) {
|
|
||||||
try {
|
private CompoundTag convert(net.minecraft.nbt.CompoundTag tag) {
|
||||||
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
try {
|
||||||
DataOutputStream dos = new DataOutputStream(boas);
|
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
||||||
tag.write(dos);
|
DataOutputStream dos = new DataOutputStream(boas);
|
||||||
dos.close();
|
tag.write(dos);
|
||||||
return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag();
|
dos.close();
|
||||||
} catch (Throwable ex) {
|
return (CompoundTag) NBTUtil.read(new ByteArrayInputStream(boas.toByteArray()), false).getTag();
|
||||||
ex.printStackTrace();
|
} catch (Throwable ex) {
|
||||||
}
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
private net.minecraft.nbt.CompoundTag convert(CompoundTag tag) {
|
|
||||||
try {
|
private net.minecraft.nbt.CompoundTag convert(CompoundTag tag) {
|
||||||
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
try {
|
||||||
NBTUtil.write(tag, boas, false);
|
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
||||||
DataInputStream din = new DataInputStream(new ByteArrayInputStream(boas.toByteArray()));
|
NBTUtil.write(tag, boas, false);
|
||||||
net.minecraft.nbt.CompoundTag c = NbtIo.read(din);
|
DataInputStream din = new DataInputStream(new ByteArrayInputStream(boas.toByteArray()));
|
||||||
din.close();
|
net.minecraft.nbt.CompoundTag c = NbtIo.read(din);
|
||||||
return c;
|
din.close();
|
||||||
} catch (Throwable e) {
|
return c;
|
||||||
e.printStackTrace();
|
} catch (Throwable e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void deserializeTile(CompoundTag c, Location pos) {
|
@Override
|
||||||
((CraftWorld) pos.getWorld()).getHandle().getChunkAt(new BlockPos(pos.getBlockX(), 0, pos.getBlockZ())).setBlockEntityNbt(convert(c));
|
public void deserializeTile(CompoundTag c, Location pos) {
|
||||||
}
|
((CraftWorld) pos.getWorld()).getHandle().getChunkAt(new BlockPos(pos.getBlockX(), 0, pos.getBlockZ())).setBlockEntityNbt(convert(c));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public CompoundTag serializeEntity(Entity location) {
|
@Override
|
||||||
return null;// TODO:
|
public CompoundTag serializeEntity(Entity location) {
|
||||||
}
|
return null;// TODO:
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Entity deserializeEntity(CompoundTag s, Location newPosition) {
|
@Override
|
||||||
return null;// TODO:
|
public Entity deserializeEntity(CompoundTag s, Location newPosition) {
|
||||||
}
|
return null;// TODO:
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean supportsCustomHeight() {
|
@Override
|
||||||
return true;
|
public boolean supportsCustomHeight() {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
private RegistryAccess registry() {
|
|
||||||
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
|
private RegistryAccess registry() {
|
||||||
}
|
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
|
||||||
|
}
|
||||||
private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() {
|
|
||||||
return registry().registry(Registries.BIOME).orElse(null);
|
private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() {
|
||||||
}
|
return registry().registry(Registries.BIOME).orElse(null);
|
||||||
|
}
|
||||||
private Registry<Block> getBlockRegistry() {
|
|
||||||
return registry().registry(Registries.BLOCK).orElse(null);
|
private Registry<Block> getBlockRegistry() {
|
||||||
}
|
return registry().registry(Registries.BLOCK).orElse(null);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Object getBiomeBaseFromId(int id) {
|
@Override
|
||||||
return getCustomBiomeRegistry().getHolder(id);
|
public Object getBiomeBaseFromId(int id) {
|
||||||
}
|
return getCustomBiomeRegistry().getHolder(id);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getMinHeight(World world) {
|
@Override
|
||||||
return world.getMinHeight();
|
public int getMinHeight(World world) {
|
||||||
}
|
return world.getMinHeight();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean supportsCustomBiomes() {
|
@Override
|
||||||
return true;
|
public boolean supportsCustomBiomes() {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getTrueBiomeBaseId(Object biomeBase) {
|
@Override
|
||||||
return getCustomBiomeRegistry().getId(((Holder<net.minecraft.world.level.biome.Biome>) biomeBase).value());
|
public int getTrueBiomeBaseId(Object biomeBase) {
|
||||||
}
|
return getCustomBiomeRegistry().getId(((Holder<net.minecraft.world.level.biome.Biome>) biomeBase).value());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Object getTrueBiomeBase(Location location) {
|
@Override
|
||||||
return ((CraftWorld) location.getWorld()).getHandle().getBiome(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
public Object getTrueBiomeBase(Location location) {
|
||||||
}
|
return ((CraftWorld) location.getWorld()).getHandle().getBiome(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getTrueBiomeBaseKey(Location location) {
|
@Override
|
||||||
return getKeyForBiomeBase(getTrueBiomeBase(location));
|
public String getTrueBiomeBaseKey(Location location) {
|
||||||
}
|
return getKeyForBiomeBase(getTrueBiomeBase(location));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Object getCustomBiomeBaseFor(String mckey) {
|
@Override
|
||||||
return getCustomBiomeRegistry().get(new ResourceLocation(mckey));
|
public Object getCustomBiomeBaseFor(String mckey) {
|
||||||
}
|
return getCustomBiomeRegistry().get(new ResourceLocation(mckey));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Object getCustomBiomeBaseHolderFor(String mckey) {
|
@Override
|
||||||
return getCustomBiomeRegistry().getHolder(getTrueBiomeBaseId(getCustomBiomeRegistry().get(new ResourceLocation(mckey)))).get();
|
public Object getCustomBiomeBaseHolderFor(String mckey) {
|
||||||
}
|
return getCustomBiomeRegistry().getHolder(getTrueBiomeBaseId(getCustomBiomeRegistry().get(new ResourceLocation(mckey)))).get();
|
||||||
|
}
|
||||||
public int getBiomeBaseIdForKey(String key) {
|
|
||||||
return getCustomBiomeRegistry().getId(getCustomBiomeRegistry().get(new ResourceLocation(key)));
|
public int getBiomeBaseIdForKey(String key) {
|
||||||
}
|
return getCustomBiomeRegistry().getId(getCustomBiomeRegistry().get(new ResourceLocation(key)));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getKeyForBiomeBase(Object biomeBase) {
|
@Override
|
||||||
return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something
|
public String getKeyForBiomeBase(Object biomeBase) {
|
||||||
}
|
return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Object getBiomeBase(World world, Biome biome) {
|
@Override
|
||||||
return CraftBlock.biomeToBiomeBase(((CraftWorld) world).getHandle()
|
public Object getBiomeBase(World world, Biome biome) {
|
||||||
.registryAccess().registry(Registries.BIOME).orElse(null), biome);
|
return CraftBlock.biomeToBiomeBase(((CraftWorld) world).getHandle()
|
||||||
}
|
.registryAccess().registry(Registries.BIOME).orElse(null), biome);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Object getBiomeBase(Object registry, Biome biome) {
|
@Override
|
||||||
Object v = baseBiomeCache.get(biome);
|
public Object getBiomeBase(Object registry, Biome biome) {
|
||||||
|
Object v = baseBiomeCache.get(biome);
|
||||||
if (v != null) {
|
|
||||||
return v;
|
if (v != null) {
|
||||||
}
|
return v;
|
||||||
//noinspection unchecked
|
}
|
||||||
v = CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
|
//noinspection unchecked
|
||||||
if (v == null) {
|
v = CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
|
||||||
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
|
if (v == null) {
|
||||||
// But, this does NOT exist within CraftBukkit which makes it return an error.
|
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
|
||||||
// So, we will just return the ID that the plains biome returns instead.
|
// But, this does NOT exist within CraftBukkit which makes it return an error.
|
||||||
//noinspection unchecked
|
// So, we will just return the ID that the plains biome returns instead.
|
||||||
return CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
|
//noinspection unchecked
|
||||||
}
|
return CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
|
||||||
baseBiomeCache.put(biome, v);
|
}
|
||||||
return v;
|
baseBiomeCache.put(biome, v);
|
||||||
}
|
return v;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean isBukkit() {
|
@Override
|
||||||
return true;
|
public boolean isBukkit() {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getBiomeId(Biome biome) {
|
@Override
|
||||||
for (World i : Bukkit.getWorlds()) {
|
public int getBiomeId(Biome biome) {
|
||||||
if (i.getEnvironment().equals(World.Environment.NORMAL)) {
|
for (World i : Bukkit.getWorlds()) {
|
||||||
Registry<net.minecraft.world.level.biome.Biome> registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registries.BIOME).orElse(null);
|
if (i.getEnvironment().equals(World.Environment.NORMAL)) {
|
||||||
return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome));
|
Registry<net.minecraft.world.level.biome.Biome> registry = ((CraftWorld) i).getHandle().registryAccess().registry(Registries.BIOME).orElse(null);
|
||||||
}
|
return registry.getId((net.minecraft.world.level.biome.Biome) getBiomeBase(registry, biome));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return biome.ordinal();
|
|
||||||
}
|
return biome.ordinal();
|
||||||
|
}
|
||||||
private MCAIdMap<net.minecraft.world.level.biome.Biome> getBiomeMapping() {
|
|
||||||
return biomeMapCache.aquire(() -> new MCAIdMap<>() {
|
private MCAIdMap<net.minecraft.world.level.biome.Biome> getBiomeMapping() {
|
||||||
@NotNull
|
return biomeMapCache.aquire(() -> new MCAIdMap<>() {
|
||||||
@Override
|
@NotNull
|
||||||
public Iterator<net.minecraft.world.level.biome.Biome> iterator() {
|
@Override
|
||||||
return getCustomBiomeRegistry().iterator();
|
public Iterator<net.minecraft.world.level.biome.Biome> iterator() {
|
||||||
}
|
return getCustomBiomeRegistry().iterator();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getId(net.minecraft.world.level.biome.Biome paramT) {
|
@Override
|
||||||
return getCustomBiomeRegistry().getId(paramT);
|
public int getId(net.minecraft.world.level.biome.Biome paramT) {
|
||||||
}
|
return getCustomBiomeRegistry().getId(paramT);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public net.minecraft.world.level.biome.Biome byId(int paramInt) {
|
@Override
|
||||||
return (net.minecraft.world.level.biome.Biome) getBiomeBaseFromId(paramInt);
|
public net.minecraft.world.level.biome.Biome byId(int paramInt) {
|
||||||
}
|
return (net.minecraft.world.level.biome.Biome) getBiomeBaseFromId(paramInt);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
@NotNull
|
|
||||||
private MCABiomeContainer getBiomeContainerInterface(MCAIdMap<net.minecraft.world.level.biome.Biome> biomeMapping, MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base) {
|
@NotNull
|
||||||
return new MCABiomeContainer() {
|
private MCABiomeContainer getBiomeContainerInterface(MCAIdMap<net.minecraft.world.level.biome.Biome> biomeMapping, MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base) {
|
||||||
@Override
|
return new MCABiomeContainer() {
|
||||||
public int[] getData() {
|
@Override
|
||||||
return base.writeBiomes();
|
public int[] getData() {
|
||||||
}
|
return base.writeBiomes();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void setBiome(int x, int y, int z, int id) {
|
@Override
|
||||||
base.setBiome(x, y, z, biomeMapping.byId(id));
|
public void setBiome(int x, int y, int z, int id) {
|
||||||
}
|
base.setBiome(x, y, z, biomeMapping.byId(id));
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int getBiome(int x, int y, int z) {
|
@Override
|
||||||
return biomeMapping.getId(base.getBiome(x, y, z));
|
public int getBiome(int x, int y, int z) {
|
||||||
}
|
return biomeMapping.getId(base.getBiome(x, y, z));
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public MCABiomeContainer newBiomeContainer(int min, int max) {
|
@Override
|
||||||
MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max);
|
public MCABiomeContainer newBiomeContainer(int min, int max) {
|
||||||
return getBiomeContainerInterface(getBiomeMapping(), base);
|
MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max);
|
||||||
}
|
return getBiomeContainerInterface(getBiomeMapping(), base);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public MCABiomeContainer newBiomeContainer(int min, int max, int[] data) {
|
@Override
|
||||||
MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max, data);
|
public MCABiomeContainer newBiomeContainer(int min, int max, int[] data) {
|
||||||
return getBiomeContainerInterface(getBiomeMapping(), base);
|
MCAChunkBiomeContainer<net.minecraft.world.level.biome.Biome> base = new MCAChunkBiomeContainer<>(getBiomeMapping(), min, max, data);
|
||||||
}
|
return getBiomeContainerInterface(getBiomeMapping(), base);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int countCustomBiomes() {
|
@Override
|
||||||
AtomicInteger a = new AtomicInteger(0);
|
public int countCustomBiomes() {
|
||||||
|
AtomicInteger a = new AtomicInteger(0);
|
||||||
getCustomBiomeRegistry().keySet().forEach((i) -> {
|
|
||||||
if (i.getNamespace().equals("minecraft")) {
|
getCustomBiomeRegistry().keySet().forEach((i) -> {
|
||||||
return;
|
if (i.getNamespace().equals("minecraft")) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
a.incrementAndGet();
|
|
||||||
Iris.debug("Custom Biome: " + i);
|
a.incrementAndGet();
|
||||||
});
|
Iris.debug("Custom Biome: " + i);
|
||||||
|
});
|
||||||
return a.get();
|
|
||||||
}
|
return a.get();
|
||||||
|
}
|
||||||
public boolean supportsDataPacks() {
|
|
||||||
return true;
|
public boolean supportsDataPacks() {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
public void setBiomes(int cx, int cz, World world, Hunk<Object> biomes) {
|
|
||||||
LevelChunk c = ((CraftWorld) world).getHandle().getChunk(cx, cz);
|
public void setBiomes(int cx, int cz, World world, Hunk<Object> biomes) {
|
||||||
biomes.iterateSync((x, y, z, b) -> c.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) b));
|
LevelChunk c = ((CraftWorld) world).getHandle().getChunk(cx, cz);
|
||||||
c.setUnsaved(true);
|
biomes.iterateSync((x, y, z, b) -> c.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) b));
|
||||||
}
|
c.setUnsaved(true);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
|
@Override
|
||||||
try {
|
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
|
||||||
ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk);
|
try {
|
||||||
Holder<net.minecraft.world.level.biome.Biome> biome = (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty;
|
ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk);
|
||||||
s.setBiome(x, y, z, biome);
|
Holder<net.minecraft.world.level.biome.Biome> biome = (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty;
|
||||||
} catch (IllegalAccessException e) {
|
s.setBiome(x, y, z, biome);
|
||||||
Iris.reportError(e);
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
Iris.reportError(e);
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private Field getFieldForBiomeStorage(Object storage) {
|
|
||||||
Field f = biomeStorageCache;
|
private Field getFieldForBiomeStorage(Object storage) {
|
||||||
|
Field f = biomeStorageCache;
|
||||||
if (f != null) {
|
|
||||||
return f;
|
if (f != null) {
|
||||||
}
|
return f;
|
||||||
try {
|
}
|
||||||
f = storage.getClass().getDeclaredField("biome");
|
try {
|
||||||
f.setAccessible(true);
|
f = storage.getClass().getDeclaredField("biome");
|
||||||
return f;
|
f.setAccessible(true);
|
||||||
} catch (Throwable e) {
|
return f;
|
||||||
Iris.reportError(e);
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
Iris.reportError(e);
|
||||||
Iris.error(storage.getClass().getCanonicalName());
|
e.printStackTrace();
|
||||||
}
|
Iris.error(storage.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
biomeStorageCache = f;
|
|
||||||
return null;
|
biomeStorageCache = f;
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public MCAPaletteAccess createPalette() {
|
@Override
|
||||||
MCAIdMapper<BlockState> registry = registryCache.aquireNasty(() -> {
|
public MCAPaletteAccess createPalette() {
|
||||||
Field cf = net.minecraft.core.IdMapper.class.getDeclaredField("tToId");
|
MCAIdMapper<BlockState> registry = registryCache.aquireNasty(() -> {
|
||||||
Field df = net.minecraft.core.IdMapper.class.getDeclaredField("idToT");
|
Field cf = net.minecraft.core.IdMapper.class.getDeclaredField("tToId");
|
||||||
Field bf = net.minecraft.core.IdMapper.class.getDeclaredField("nextId");
|
Field df = net.minecraft.core.IdMapper.class.getDeclaredField("idToT");
|
||||||
cf.setAccessible(true);
|
Field bf = net.minecraft.core.IdMapper.class.getDeclaredField("nextId");
|
||||||
df.setAccessible(true);
|
cf.setAccessible(true);
|
||||||
bf.setAccessible(true);
|
df.setAccessible(true);
|
||||||
net.minecraft.core.IdMapper<BlockState> blockData = Block.BLOCK_STATE_REGISTRY;
|
bf.setAccessible(true);
|
||||||
int b = bf.getInt(blockData);
|
net.minecraft.core.IdMapper<BlockState> blockData = Block.BLOCK_STATE_REGISTRY;
|
||||||
Object2IntMap<BlockState> c = (Object2IntMap<BlockState>) cf.get(blockData);
|
int b = bf.getInt(blockData);
|
||||||
List<BlockState> d = (List<BlockState>) df.get(blockData);
|
Object2IntMap<BlockState> c = (Object2IntMap<BlockState>) cf.get(blockData);
|
||||||
return new MCAIdMapper<BlockState>(c, d, b);
|
List<BlockState> d = (List<BlockState>) df.get(blockData);
|
||||||
});
|
return new MCAIdMapper<BlockState>(c, d, b);
|
||||||
MCAPalette<BlockState> global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState()));
|
});
|
||||||
MCAPalettedContainer<BlockState> container = new MCAPalettedContainer<>(global, registry,
|
MCAPalette<BlockState> global = globalCache.aquireNasty(() -> new MCAGlobalPalette<>(registry, ((CraftBlockData) AIR).getState()));
|
||||||
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(),
|
MCAPalettedContainer<BlockState> container = new MCAPalettedContainer<>(global, registry,
|
||||||
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(),
|
||||||
((CraftBlockData) AIR).getState());
|
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
||||||
return new MCAWrappedPalettedContainer<>(container,
|
((CraftBlockData) AIR).getState());
|
||||||
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
return new MCAWrappedPalettedContainer<>(container,
|
||||||
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
|
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
||||||
}
|
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void injectBiomesFromMantle(Chunk e, Mantle mantle) {
|
@Override
|
||||||
ChunkAccess chunk = ((CraftChunk) e).getHandle(ChunkStatus.FULL);
|
public void injectBiomesFromMantle(Chunk e, Mantle mantle) {
|
||||||
AtomicInteger c = new AtomicInteger();
|
ChunkAccess chunk = ((CraftChunk) e).getHandle(ChunkStatus.FULL);
|
||||||
AtomicInteger r = new AtomicInteger();
|
AtomicInteger c = new AtomicInteger();
|
||||||
mantle.iterateChunk(e.getX(), e.getZ(), MatterBiomeInject.class, (x, y, z, b) -> {
|
AtomicInteger r = new AtomicInteger();
|
||||||
if (b != null) {
|
mantle.iterateChunk(e.getX(), e.getZ(), MatterBiomeInject.class, (x, y, z, b) -> {
|
||||||
if (b.isCustom()) {
|
if (b != null) {
|
||||||
chunk.setBiome(x, y, z, getCustomBiomeRegistry().getHolder(b.getBiomeId()).get());
|
if (b.isCustom()) {
|
||||||
c.getAndIncrement();
|
chunk.setBiome(x, y, z, getCustomBiomeRegistry().getHolder(b.getBiomeId()).get());
|
||||||
} else {
|
c.getAndIncrement();
|
||||||
chunk.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) getBiomeBase(e.getWorld(), b.getBiome()));
|
} else {
|
||||||
r.getAndIncrement();
|
chunk.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) getBiomeBase(e.getWorld(), b.getBiome()));
|
||||||
}
|
r.getAndIncrement();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,95 +1,95 @@
|
|||||||
/*
|
/*
|
||||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.volmit.iris.core.service;
|
package com.volmit.iris.core.service;
|
||||||
|
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||||
import com.volmit.iris.util.function.Consumer4;
|
import com.volmit.iris.util.function.Consumer4;
|
||||||
import com.volmit.iris.util.math.Spiraler;
|
import com.volmit.iris.util.math.Spiraler;
|
||||||
import com.volmit.iris.util.matter.MatterStructurePOI;
|
import com.volmit.iris.util.matter.MatterStructurePOI;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
import com.volmit.iris.util.plugin.IrisService;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftDolphin;
|
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftDolphin;
|
||||||
import org.bukkit.entity.Dolphin;
|
import org.bukkit.entity.Dolphin;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.generator.structure.StructureType;
|
import org.bukkit.generator.structure.StructureType;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class DolphinSVC implements IrisService {
|
public class DolphinSVC implements IrisService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(PlayerInteractEntityEvent event) {
|
public void on(PlayerInteractEntityEvent event) {
|
||||||
if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
|
if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType();
|
Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType();
|
||||||
if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) {
|
if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) {
|
||||||
Engine e = IrisToolbelt.access(event.getPlayer().getWorld()).getEngine();
|
Engine e = IrisToolbelt.access(event.getPlayer().getWorld()).getEngine();
|
||||||
searchNearestTreasure(e, event.getPlayer().getLocation().getBlockX() >> 4, event.getPlayer().getLocation().getBlockZ() >> 4, e.getMantle().getRadius() - 1, StructureType.BURIED_TREASURE, (x, y, z, p) -> {
|
searchNearestTreasure(e, event.getPlayer().getLocation().getBlockX() >> 4, event.getPlayer().getLocation().getBlockZ() >> 4, e.getMantle().getRadius() - 1, StructureType.BURIED_TREASURE, (x, y, z, p) -> {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Dolphin d = (Dolphin) event.getRightClicked();
|
Dolphin d = (Dolphin) event.getRightClicked();
|
||||||
CraftDolphin cd = (CraftDolphin) d;
|
CraftDolphin cd = (CraftDolphin) d;
|
||||||
d.getWorld().playSound(d, Sound.ENTITY_DOLPHIN_EAT, SoundCategory.NEUTRAL, 1, 1);
|
d.getWorld().playSound(d, Sound.ENTITY_DOLPHIN_EAT, SoundCategory.NEUTRAL, 1, 1);
|
||||||
cd.getHandle().setTreasurePos(new BlockPos(x, y, z));
|
cd.getHandle().setTreasurePos(new BlockPos(x, y, z));
|
||||||
cd.getHandle().setGotFish(true);
|
cd.getHandle().setGotFish(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
public void findTreasure(Engine engine, int chunkX, int chunkY, StructureType type, Consumer4<Integer, Integer, Integer, MatterStructurePOI> consumer) {
|
public void findTreasure(Engine engine, int chunkX, int chunkY, StructureType type, Consumer4<Integer, Integer, Integer, MatterStructurePOI> consumer) {
|
||||||
AtomicReference<MatterStructurePOI> ref = new AtomicReference<>();
|
AtomicReference<MatterStructurePOI> ref = new AtomicReference<>();
|
||||||
engine.getMantle().getMantle().iterateChunk(chunkX, chunkY, MatterStructurePOI.class, ref.get() == null ? (x, y, z, d) -> {
|
engine.getMantle().getMantle().iterateChunk(chunkX, chunkY, MatterStructurePOI.class, ref.get() == null ? (x, y, z, d) -> {
|
||||||
if (d.getType().equals(type.getKey().getKey())) {
|
if (d.getType().equals(type.getKey().getKey())) {
|
||||||
ref.set(d);
|
ref.set(d);
|
||||||
consumer.accept(x, y, z, d);
|
consumer.accept(x, y, z, d);
|
||||||
}
|
}
|
||||||
} : (x, y, z, d) -> {
|
} : (x, y, z, d) -> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
public void searchNearestTreasure(Engine engine, int chunkX, int chunkY, int radius, StructureType type, Consumer4<Integer, Integer, Integer, MatterStructurePOI> consumer) {
|
public void searchNearestTreasure(Engine engine, int chunkX, int chunkY, int radius, StructureType type, Consumer4<Integer, Integer, Integer, MatterStructurePOI> consumer) {
|
||||||
AtomicReference<MatterStructurePOI> ref = new AtomicReference<>();
|
AtomicReference<MatterStructurePOI> ref = new AtomicReference<>();
|
||||||
new Spiraler(radius * 2, radius * 2, (x, z) -> findTreasure(engine, x, z, type, ref.get() == null ? (i, d, g, a) -> {
|
new Spiraler(radius * 2, radius * 2, (x, z) -> findTreasure(engine, x, z, type, ref.get() == null ? (i, d, g, a) -> {
|
||||||
ref.set(a);
|
ref.set(a);
|
||||||
consumer.accept(i, d, g, a);
|
consumer.accept(i, d, g, a);
|
||||||
} : (i, d, g, a) -> {
|
} : (i, d, g, a) -> {
|
||||||
})).setOffset(chunkX, chunkY).drain();
|
})).setOffset(chunkX, chunkY).drain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||||||
import net.minecraft.nbt.TagParser;
|
import net.minecraft.nbt.TagParser;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.Damageable;
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
|
@ -20,7 +20,7 @@ package com.volmit.iris.engine.platform;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.v19_4.CustomBiomeSource;
|
import com.volmit.iris.core.nms.v20.CustomBiomeSource;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
import com.volmit.iris.engine.IrisEngine;
|
import com.volmit.iris.engine.IrisEngine;
|
||||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
@ -46,7 +46,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user