mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
NMS for datapack discovery
This commit is contained in:
parent
b05736e4fb
commit
bc5529ded8
@ -1,11 +1,24 @@
|
|||||||
package com.volmit.iris.nms;
|
package com.volmit.iris.nms;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
public interface INMSBinding
|
public interface INMSBinding
|
||||||
{
|
{
|
||||||
|
public Object getBiomeBaseFromId(int id);
|
||||||
|
|
||||||
|
public int getTrueBiomeBaseId(Object biomeBase);
|
||||||
|
|
||||||
|
public Object getTrueBiomeBase(Location location);
|
||||||
|
|
||||||
|
public String getTrueBiomeBaseKey(Location location);
|
||||||
|
|
||||||
|
public Object getCustomBiomeBaseFor(String mckey);
|
||||||
|
|
||||||
|
public String getKeyForBiomeBase(Object biomeBase);
|
||||||
|
|
||||||
public Object getBiomeBase(World world, Biome biome);
|
public Object getBiomeBase(World world, Biome biome);
|
||||||
|
|
||||||
public Object getBiomeBase(Object registry, Biome biome);
|
public Object getBiomeBase(Object registry, Biome biome);
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
package com.volmit.iris.nms.v17_1;
|
package com.volmit.iris.nms.v17_1;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.nms.INMSBinding;
|
import com.volmit.iris.nms.INMSBinding;
|
||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import net.minecraft.core.IRegistry;
|
import net.minecraft.core.IRegistry;
|
||||||
|
import net.minecraft.core.IRegistryWritable;
|
||||||
|
import net.minecraft.data.worldgen.biome.BiomeRegistry;
|
||||||
|
import net.minecraft.resources.MinecraftKey;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.WorldServer;
|
||||||
import net.minecraft.world.level.biome.BiomeBase;
|
import net.minecraft.world.level.biome.BiomeBase;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -15,6 +24,41 @@ public class NMSBinding17_1 implements INMSBinding
|
|||||||
{
|
{
|
||||||
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
||||||
|
|
||||||
|
private IRegistryWritable<BiomeBase> getCustomBiomeRegistry()
|
||||||
|
{
|
||||||
|
return ((CraftServer)Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.aO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getBiomeBaseFromId(int id) {
|
||||||
|
return getCustomBiomeRegistry().fromId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTrueBiomeBaseId(Object biomeBase) {
|
||||||
|
return getCustomBiomeRegistry().getId((BiomeBase)biomeBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTrueBiomeBase(Location location) {
|
||||||
|
return ((CraftWorld)location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTrueBiomeBaseKey(Location location) {
|
||||||
|
return getKeyForBiomeBase(getTrueBiomeBase(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getCustomBiomeBaseFor(String mckey) {
|
||||||
|
return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKeyForBiomeBase(Object biomeBase) {
|
||||||
|
return getCustomBiomeRegistry().c((BiomeBase)biomeBase).get().a().toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getBiomeBase(World world, Biome biome)
|
public Object getBiomeBase(World world, Biome biome)
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,42 @@
|
|||||||
package com.volmit.iris.nms.v1X;
|
package com.volmit.iris.nms.v1X;
|
||||||
|
|
||||||
import com.volmit.iris.nms.INMSBinding;
|
import com.volmit.iris.nms.INMSBinding;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
public class NMSBinding1X implements INMSBinding
|
public class NMSBinding1X implements INMSBinding
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
|
public Object getBiomeBaseFromId(int id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTrueBiomeBaseId(Object biomeBase) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTrueBiomeBase(Location location) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTrueBiomeBaseKey(Location location) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getCustomBiomeBaseFor(String mckey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKeyForBiomeBase(Object biomeBase) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getBiomeBase(World world, Biome biome)
|
public Object getBiomeBase(World world, Biome biome)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user