mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
fix NMSBiomeProvider
This commit is contained in:
@@ -74,8 +74,8 @@ public class NMSBiomeInjector {
|
||||
ResourceKey<BiomeBase> delegateKey = ResourceKey.a(IRegistry.aP, new MinecraftKey("terra", createBiomeID(pack, key)));
|
||||
|
||||
RegistryGeneration.a(RegistryGeneration.i, delegateKey, platform);
|
||||
Holder<BiomeBase> resourceKey = biomeRegistry.a(delegateKey, platform, Lifecycle.stable());
|
||||
platformBiome.setResourceKey(resourceKey);
|
||||
biomeRegistry.a(delegateKey, platform, Lifecycle.stable());
|
||||
platformBiome.setResourceKey(delegateKey);
|
||||
|
||||
terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.a());
|
||||
|
||||
@@ -87,6 +87,7 @@ public class NMSBiomeInjector {
|
||||
|
||||
frozen.set(biomeRegistry, true); // freeze registry again :)
|
||||
|
||||
/*
|
||||
LOGGER.info("Doing tag garbage....");
|
||||
Map<TagKey<BiomeBase>, List<Holder<BiomeBase>>> collect = biomeRegistry
|
||||
.g() // streamKeysAndEntries
|
||||
@@ -130,6 +131,8 @@ public class NMSBiomeInjector {
|
||||
|
||||
biomeRegistry.k(); // clearTags
|
||||
biomeRegistry.a(ImmutableMap.copyOf(collect)); // populateTags
|
||||
|
||||
*/
|
||||
} catch(NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package com.dfsek.terra.bukkit.nms;
|
||||
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.Climate.Sampler;
|
||||
import net.minecraft.world.level.biome.WorldChunkManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
|
||||
|
||||
|
||||
public class NMSBiomeProvider extends WorldChunkManager {
|
||||
@@ -16,8 +22,13 @@ public class NMSBiomeProvider extends WorldChunkManager {
|
||||
private final WorldChunkManager vanilla;
|
||||
private final long seed;
|
||||
|
||||
private static final Lazy<IRegistry<BiomeBase>> biomeRegistry = Lazy.lazy(() -> {
|
||||
DedicatedServer dedicatedserver = ((CraftServer) Bukkit.getServer()).getServer();
|
||||
return dedicatedserver.aU().b(IRegistry.aP);
|
||||
});
|
||||
|
||||
public NMSBiomeProvider(BiomeProvider delegate, WorldChunkManager vanilla, long seed) {
|
||||
super(vanilla.b().stream());
|
||||
super(delegate.stream().map(biome -> biomeRegistry.value().g(((BukkitPlatformBiome) biome.getPlatformBiome()).getResourceKey())));
|
||||
this.delegate = delegate;
|
||||
this.vanilla = vanilla;
|
||||
this.seed = seed;
|
||||
@@ -39,6 +50,7 @@ public class NMSBiomeProvider extends WorldChunkManager {
|
||||
|
||||
@Override
|
||||
public Holder<BiomeBase> getNoiseBiome(int x, int y, int z, Sampler sampler) {
|
||||
return ((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed).getPlatformBiome()).getResourceKey();
|
||||
//return CraftBlock.biomeToBiomeBase(biomeRegistry.value(), ((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed).getPlatformBiome()).getHandle());
|
||||
return biomeRegistry.value().g(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed).getPlatformBiome()).getResourceKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class NMSInjectListener implements Listener {
|
||||
custom.conf = vanilla.conf; // world config from Spigot
|
||||
|
||||
serverWorld.k().a.u = custom;
|
||||
serverWorld.generator = null;
|
||||
|
||||
LOGGER.info("Successfully injected into world.");
|
||||
INJECT_LOCK.unlock();
|
||||
|
||||
@@ -20,22 +20,23 @@ package com.dfsek.terra.bukkit.world;
|
||||
import com.dfsek.terra.api.world.biome.PlatformBiome;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
|
||||
|
||||
public class BukkitPlatformBiome implements PlatformBiome {
|
||||
private final org.bukkit.block.Biome biome;
|
||||
private Holder<BiomeBase> resourceKey;
|
||||
private ResourceKey<BiomeBase> resourceKey;
|
||||
|
||||
public BukkitPlatformBiome(org.bukkit.block.Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
public void setResourceKey(Holder<BiomeBase> resourceKey) {
|
||||
public void setResourceKey(ResourceKey<BiomeBase> resourceKey) {
|
||||
this.resourceKey = resourceKey;
|
||||
}
|
||||
|
||||
public Holder<BiomeBase> getResourceKey() {
|
||||
public ResourceKey<BiomeBase> getResourceKey() {
|
||||
return resourceKey;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user