mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 23:00:19 +00:00
Merge remote-tracking branch 'origin/dev/bukkit/biome-settings' into dev/biomes3
This commit is contained in:
@@ -11,5 +11,5 @@ dependencies {
|
||||
|
||||
shadedApi("com.google.guava", "guava", Versions.Libraries.Internal.guava)
|
||||
|
||||
shadedApi("org.incendo", "cloud-paper", Versions.Libraries.cloudPaper)
|
||||
shadedApi("org.incendo", "cloud-paper", Versions.Bukkit.cloud)
|
||||
}
|
||||
|
||||
@@ -4,18 +4,15 @@ import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.bukkit.config.PreLoadCompatibilityOptions;
|
||||
import com.dfsek.terra.bukkit.config.VanillaBiomeProperties;
|
||||
|
||||
|
||||
public class BukkitAddon implements BaseAddon {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
private final PlatformImpl terraBukkitPlugin;
|
||||
protected final PlatformImpl terraBukkitPlugin;
|
||||
|
||||
public BukkitAddon(PlatformImpl terraBukkitPlugin) {
|
||||
this.terraBukkitPlugin = terraBukkitPlugin;
|
||||
@@ -28,16 +25,6 @@ public class BukkitAddon implements BaseAddon {
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().getContext().put(event.loadTemplate(new PreLoadCompatibilityOptions())))
|
||||
.global();
|
||||
|
||||
terraBukkitPlugin.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(Biome.class)) {
|
||||
event.getLoadedObject(Biome.class).getContext().put(event.load(new VanillaBiomeProperties()));
|
||||
}
|
||||
})
|
||||
.global();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,9 @@ package com.dfsek.terra.bukkit;
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
|
||||
import com.dfsek.terra.bukkit.nms.Initializer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -96,7 +99,7 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
|
||||
@Override
|
||||
protected Iterable<BaseAddon> platformAddon() {
|
||||
return List.of(new BukkitAddon(this));
|
||||
return List.of(Initializer.nmsAddon(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.dfsek.terra.bukkit.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
|
||||
|
||||
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Value("colors.grass")
|
||||
@Default
|
||||
private Integer grassColor = null;
|
||||
|
||||
@Value("colors.fog")
|
||||
@Default
|
||||
private Integer fogColor = null;
|
||||
|
||||
@Value("colors.water")
|
||||
@Default
|
||||
private Integer waterColor = null;
|
||||
|
||||
@Value("colors.water-fog")
|
||||
@Default
|
||||
private Integer waterFogColor = null;
|
||||
|
||||
@Value("colors.foliage")
|
||||
@Default
|
||||
private Integer foliageColor = null;
|
||||
|
||||
@Value("colors.sky")
|
||||
@Default
|
||||
private Integer skyColor = null;
|
||||
|
||||
public Integer getFogColor() {
|
||||
return fogColor;
|
||||
}
|
||||
|
||||
public Integer getFoliageColor() {
|
||||
return foliageColor;
|
||||
}
|
||||
|
||||
public Integer getGrassColor() {
|
||||
return grassColor;
|
||||
}
|
||||
|
||||
public Integer getWaterColor() {
|
||||
return waterColor;
|
||||
}
|
||||
|
||||
public Integer getWaterFogColor() {
|
||||
return waterFogColor;
|
||||
}
|
||||
|
||||
public Integer getSkyColor() {
|
||||
return skyColor;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.nms;
|
||||
|
||||
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -13,20 +15,11 @@ public interface Initializer {
|
||||
|
||||
static boolean init(PlatformImpl platform) {
|
||||
Logger logger = LoggerFactory.getLogger(Initializer.class);
|
||||
try {
|
||||
String packageVersion = NMS;
|
||||
if(NMS.equals("v1_21_1")) {
|
||||
packageVersion = "v1_21";
|
||||
}
|
||||
|
||||
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
|
||||
try {
|
||||
Initializer initializer = (Initializer) initializerClass.getConstructor().newInstance();
|
||||
initializer.initialize(platform);
|
||||
} catch(ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Error initializing NMS bindings. Report this to Terra.", e);
|
||||
}
|
||||
} catch(ClassNotFoundException e) {
|
||||
Initializer initializer = constructInitializer();
|
||||
if(initializer != null) {
|
||||
initializer.initialize(platform);
|
||||
} else {
|
||||
logger.error("NMS bindings for version {} do not exist. Support for this version is limited.", NMS);
|
||||
logger.error("This is usually due to running Terra on an unsupported Minecraft version.");
|
||||
String bypassKey = "IKnowThereAreNoNMSBindingsFor" + NMS + "ButIWillProceedAnyway";
|
||||
@@ -49,8 +42,34 @@ public interface Initializer {
|
||||
logger.error("Since you enabled the \"{}\" flag, we won't disable Terra. But be warned.", bypassKey);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static BukkitAddon nmsAddon(PlatformImpl platform) {
|
||||
Initializer initializer = constructInitializer();
|
||||
return initializer != null ? initializer.getNMSAddon(platform) : new BukkitAddon(platform);
|
||||
}
|
||||
|
||||
private static Initializer constructInitializer() {
|
||||
try {
|
||||
String packageVersion = NMS;
|
||||
if(NMS.equals("v1_21_3")) {
|
||||
packageVersion = "v1_21"; // TODO: Refactor nms package to v1_21_3
|
||||
}
|
||||
|
||||
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
|
||||
try {
|
||||
return (Initializer) initializerClass.getConstructor().newInstance();
|
||||
} catch(ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Error initializing NMS bindings. Report this to Terra.", e);
|
||||
}
|
||||
} catch(ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void initialize(PlatformImpl plugin);
|
||||
|
||||
BukkitAddon getNMSAddon(PlatformImpl plugin);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
@@ -43,7 +42,7 @@ public class AwfulBukkitHacks {
|
||||
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
||||
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
|
||||
vanillaBukkitKey.getKey());
|
||||
Biome platform = NMSBiomeInjector.createBiome(biome, Objects.requireNonNull(biomeRegistry.get(vanillaMinecraftKey)));
|
||||
Biome platform = NMSBiomeInjector.createBiome(biome, biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value());
|
||||
|
||||
ResourceKey<Biome> delegateKey = ResourceKey.create(
|
||||
Registries.BIOME,
|
||||
@@ -70,7 +69,7 @@ public class AwfulBukkitHacks {
|
||||
.getTags() // streamKeysAndEntries
|
||||
.collect(HashMap::new,
|
||||
(map, pair) ->
|
||||
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
||||
map.put(pair.key(), new ArrayList<>(Reflection.HOLDER_SET.invokeContents(pair).stream().toList())),
|
||||
HashMap::putAll);
|
||||
|
||||
terraBiomeMap
|
||||
@@ -91,8 +90,8 @@ public class AwfulBukkitHacks {
|
||||
() -> LOGGER.error("No such biome: {}", tb))),
|
||||
() -> LOGGER.error("No vanilla biome: {}", vb)));
|
||||
|
||||
biomeRegistry.resetTags();
|
||||
biomeRegistry.bindTags(ImmutableMap.copyOf(collect));
|
||||
((MappedRegistry<Biome>) biomeRegistry).bindAllTagsToEmpty();
|
||||
ImmutableMap.copyOf(collect).forEach(biomeRegistry::bindTag);
|
||||
|
||||
} catch(SecurityException | IllegalArgumentException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21;
|
||||
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||
import com.dfsek.terra.bukkit.PlatformImpl;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21.config.VanillaBiomeProperties;
|
||||
|
||||
|
||||
public class NMSAddon extends BukkitAddon {
|
||||
|
||||
public NMSAddon(PlatformImpl platform) {
|
||||
super(platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
terraBukkitPlugin.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(Biome.class)) {
|
||||
event.getLoadedObject(Biome.class).getContext().put(event.load(new VanillaBiomeProperties()));
|
||||
}
|
||||
})
|
||||
.global();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.bukkit.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21.config.VanillaBiomeProperties;
|
||||
|
||||
|
||||
public class NMSBiomeInjector {
|
||||
@@ -19,56 +19,69 @@ public class NMSBiomeInjector {
|
||||
public static <T> Optional<Holder<T>> getEntry(Registry<T> registry, ResourceLocation identifier) {
|
||||
return registry.getOptional(identifier)
|
||||
.flatMap(registry::getResourceKey)
|
||||
.flatMap(registry::getHolder);
|
||||
.flatMap(registry::get);
|
||||
}
|
||||
|
||||
public static Biome createBiome(com.dfsek.terra.api.world.biome.Biome biome, Biome vanilla)
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
Biome.BiomeBuilder builder = new Biome.BiomeBuilder();
|
||||
|
||||
builder
|
||||
.downfall(vanilla.climateSettings.downfall())
|
||||
.temperature(vanilla.getBaseTemperature())
|
||||
.mobSpawnSettings(vanilla.getMobSettings())
|
||||
.generationSettings(vanilla.getGenerationSettings());
|
||||
|
||||
|
||||
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
|
||||
|
||||
effects.grassColorModifier(vanilla.getSpecialEffects().getGrassColorModifier());
|
||||
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
|
||||
|
||||
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
|
||||
|
||||
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()))
|
||||
.grassColorModifier(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColorModifier(), vanilla.getSpecialEffects().getGrassColorModifier()))
|
||||
.grassColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getGrassColor(), vanilla.getSpecialEffects().getGrassColorOverride().orElseGet(() -> Reflection.BIOME.invokeGrassColorFromTexture(vanilla))))
|
||||
.foliageColorOverride(Objects.requireNonNullElse(vanillaBiomeProperties.getFoliageColor(), vanilla.getFoliageColor()));
|
||||
|
||||
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()));
|
||||
|
||||
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
||||
vanilla.getSpecialEffects().getFoliageColorOverride().ifPresent(effects::foliageColorOverride);
|
||||
if(vanillaBiomeProperties.getParticleConfig() == null) {
|
||||
vanilla.getSpecialEffects().getAmbientParticleSettings().ifPresent(effects::ambientParticle);
|
||||
} else {
|
||||
effects.foliageColorOverride(vanillaBiomeProperties.getFoliageColor());
|
||||
effects.ambientParticle(vanillaBiomeProperties.getParticleConfig());
|
||||
}
|
||||
|
||||
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
||||
if(vanillaBiomeProperties.getLoopSound() == null) {
|
||||
vanilla.getSpecialEffects().getAmbientLoopSoundEvent().ifPresent(effects::ambientLoopSound);
|
||||
} else {
|
||||
// grass
|
||||
effects.grassColorOverride(vanillaBiomeProperties.getGrassColor());
|
||||
RegistryFetcher.soundEventRegistry().get(vanillaBiomeProperties.getLoopSound().location()).ifPresent(effects::ambientLoopSound);
|
||||
}
|
||||
|
||||
vanilla.getAmbientLoop().ifPresent(effects::ambientLoopSound);
|
||||
vanilla.getAmbientAdditions().ifPresent(effects::ambientAdditionsSound);
|
||||
vanilla.getAmbientMood().ifPresent(effects::ambientMoodSound);
|
||||
vanilla.getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
||||
vanilla.getAmbientParticle().ifPresent(effects::ambientParticle);
|
||||
if(vanillaBiomeProperties.getMoodSound() == null) {
|
||||
vanilla.getSpecialEffects().getAmbientMoodSettings().ifPresent(effects::ambientMoodSound);
|
||||
} else {
|
||||
effects.ambientMoodSound(vanillaBiomeProperties.getMoodSound());
|
||||
}
|
||||
|
||||
builder.specialEffects(effects.build());
|
||||
if(vanillaBiomeProperties.getAdditionsSound() == null) {
|
||||
vanilla.getSpecialEffects().getAmbientAdditionsSettings().ifPresent(effects::ambientAdditionsSound);
|
||||
} else {
|
||||
effects.ambientAdditionsSound(vanillaBiomeProperties.getAdditionsSound());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
if(vanillaBiomeProperties.getMusic() == null) {
|
||||
vanilla.getSpecialEffects().getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
||||
} else {
|
||||
effects.backgroundMusic(vanillaBiomeProperties.getMusic());
|
||||
}
|
||||
|
||||
builder.hasPrecipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.hasPrecipitation()));
|
||||
|
||||
builder.temperature(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperature(), vanilla.getBaseTemperature()));
|
||||
|
||||
builder.downfall(Objects.requireNonNullElse(vanillaBiomeProperties.getDownfall(), vanilla.climateSettings.downfall()));
|
||||
|
||||
builder.temperatureAdjustment(Objects.requireNonNullElse(vanillaBiomeProperties.getTemperatureModifier(), vanilla.climateSettings.temperatureModifier()));
|
||||
|
||||
builder.mobSpawnSettings(Objects.requireNonNullElse(vanillaBiomeProperties.getSpawnSettings(), vanilla.getMobSettings()));
|
||||
|
||||
return builder
|
||||
.specialEffects(effects.build())
|
||||
.generationSettings(vanilla.getGenerationSettings())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class NMSBiomeProvider extends BiomeSource {
|
||||
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
||||
return delegate.stream()
|
||||
.map(biome -> RegistryFetcher.biomeRegistry()
|
||||
.getHolderOrThrow(((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
|
||||
.getOrThrow(((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
|
||||
.get(NMSBiomeInfo.class)
|
||||
.biomeKey()));
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class NMSBiomeProvider extends BiomeSource {
|
||||
|
||||
@Override
|
||||
public @NotNull Holder<Biome> getNoiseBiome(int x, int y, int z, @NotNull Sampler sampler) {
|
||||
return biomeRegistry.getHolderOrThrow(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed)
|
||||
return biomeRegistry.getOrThrow(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed)
|
||||
.getPlatformBiome()).getContext()
|
||||
.get(NMSBiomeInfo.class)
|
||||
.biomeKey());
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.Beardifier;
|
||||
import net.minecraft.world.level.levelgen.DensityFunction.SinglePointContext;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep.Carving;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
@@ -59,7 +58,7 @@ public class NMSChunkGeneratorDelegate extends ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public void applyCarvers(@NotNull WorldGenRegion chunkRegion, long seed, @NotNull RandomState noiseConfig, @NotNull BiomeManager world,
|
||||
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk, @NotNull Carving carverStep) {
|
||||
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21;
|
||||
|
||||
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.dfsek.terra.bukkit.PlatformImpl;
|
||||
@@ -12,4 +14,9 @@ public class NMSInitializer implements Initializer {
|
||||
AwfulBukkitHacks.registerBiomes(platform.getRawConfigRegistry());
|
||||
Bukkit.getPluginManager().registerEvents(new NMSInjectListener(), platform.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitAddon getNMSAddon(PlatformImpl plugin) {
|
||||
return new NMSAddon(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,19 +41,15 @@ public class NMSInjectListener implements Listener {
|
||||
ChunkGenerator vanilla = serverWorld.getChunkSource().getGenerator();
|
||||
NMSBiomeProvider provider = new NMSBiomeProvider(pack.getBiomeProvider(), craftWorld.getSeed());
|
||||
ChunkMap chunkMap = serverWorld.getChunkSource().chunkMap;
|
||||
WorldGenContext worldGenContext = chunkMap.worldGenContext;
|
||||
|
||||
try {
|
||||
ReflectionUtil.setFinalField(chunkMap, "worldGenContext", new WorldGenContext(
|
||||
worldGenContext.level(),
|
||||
new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed()),
|
||||
worldGenContext.structureManager(),
|
||||
worldGenContext.lightEngine(),
|
||||
worldGenContext.mainThreadMailBox()
|
||||
));
|
||||
} catch(NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
WorldGenContext worldGenContext = Reflection.CHUNKMAP.getWorldGenContext(chunkMap);
|
||||
Reflection.CHUNKMAP.setWorldGenContext(chunkMap, new WorldGenContext(
|
||||
worldGenContext.level(),
|
||||
new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed()),
|
||||
worldGenContext.structureManager(),
|
||||
worldGenContext.lightEngine(),
|
||||
worldGenContext.mainThreadExecutor(),
|
||||
worldGenContext.unsavedListener()
|
||||
));
|
||||
|
||||
LOGGER.info("Successfully injected into world.");
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ public class NMSWorldProperties implements WorldProperties {
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return height.getMaxBuildHeight();
|
||||
return height.getMaxY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinHeight() {
|
||||
return height.getMinBuildHeight();
|
||||
return height.getMinY();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.dfsek.terra.bukkit.nms.v1_21;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Holder.Reference;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.status.WorldGenContext;
|
||||
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
||||
import xyz.jpenilla.reflectionremapper.proxy.ReflectionProxyFactory;
|
||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldGetter;
|
||||
@@ -12,6 +16,8 @@ import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldSetter;
|
||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.MethodName;
|
||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.Proxies;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Reflection {
|
||||
public static final MappedRegistryProxy MAPPED_REGISTRY;
|
||||
@@ -19,6 +25,11 @@ public class Reflection {
|
||||
|
||||
public static final ReferenceProxy REFERENCE;
|
||||
|
||||
|
||||
public static final ChunkMapProxy CHUNKMAP;
|
||||
public static final HolderSetProxy HOLDER_SET;
|
||||
public static final BiomeProxy BIOME;
|
||||
|
||||
static {
|
||||
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
||||
ReflectionProxyFactory reflectionProxyFactory = ReflectionProxyFactory.create(reflectionRemapper,
|
||||
@@ -27,6 +38,9 @@ public class Reflection {
|
||||
MAPPED_REGISTRY = reflectionProxyFactory.reflectionProxy(MappedRegistryProxy.class);
|
||||
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
||||
REFERENCE = reflectionProxyFactory.reflectionProxy(ReferenceProxy.class);
|
||||
CHUNKMAP = reflectionProxyFactory.reflectionProxy(ChunkMapProxy.class);
|
||||
HOLDER_SET = reflectionProxyFactory.reflectionProxy(HolderSetProxy.class);
|
||||
BIOME = reflectionProxyFactory.reflectionProxy(BiomeProxy.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,4 +63,25 @@ public class Reflection {
|
||||
@MethodName("bindValue")
|
||||
<T> void invokeBindValue(Reference<T> instance, T value);
|
||||
}
|
||||
|
||||
@Proxies(ChunkMap.class)
|
||||
public interface ChunkMapProxy {
|
||||
@FieldGetter("worldGenContext")
|
||||
WorldGenContext getWorldGenContext(ChunkMap instance);
|
||||
|
||||
@FieldSetter("worldGenContext")
|
||||
void setWorldGenContext(ChunkMap instance, WorldGenContext worldGenContext);
|
||||
}
|
||||
|
||||
@Proxies(HolderSet.class)
|
||||
public interface HolderSetProxy {
|
||||
@MethodName("contents")
|
||||
<T> List<Holder<T>> invokeContents(HolderSet<T> instance);
|
||||
}
|
||||
|
||||
@Proxies(Biome.class)
|
||||
public interface BiomeProxy {
|
||||
@MethodName("getGrassColorFromTexture")
|
||||
int invokeGrassColorFromTexture(Biome instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
@@ -15,10 +16,16 @@ public class RegistryFetcher {
|
||||
DedicatedServer dedicatedserver = craftserver.getServer();
|
||||
return dedicatedserver
|
||||
.registryAccess()
|
||||
.registryOrThrow(key);
|
||||
.get(key)
|
||||
.orElseThrow()
|
||||
.value();
|
||||
}
|
||||
|
||||
public static Registry<Biome> biomeRegistry() {
|
||||
return getRegistry(Registries.BIOME);
|
||||
}
|
||||
|
||||
public static Registry<SoundEvent> soundEventRegistry() {
|
||||
return getRegistry(Registries.SOUND_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,27 +3,21 @@ package com.dfsek.terra.bukkit.nms.v1_21.config;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import java.util.List;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.npc.VillagerType;
|
||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||
import net.minecraft.world.level.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
|
||||
|
||||
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
|
||||
@Value("tags")
|
||||
@Default
|
||||
private List<ResourceLocation> tags = null;
|
||||
|
||||
@Value("colors.grass")
|
||||
@Default
|
||||
private Integer grassColor = null;
|
||||
@@ -58,7 +52,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
|
||||
@Value("climate.precipitation")
|
||||
@Default
|
||||
private Boolean precipitation = null;
|
||||
private Boolean precipitation = true;
|
||||
|
||||
@Value("climate.temperature")
|
||||
@Default
|
||||
@@ -95,79 +89,75 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Value("villager-type")
|
||||
@Default
|
||||
private VillagerType villagerType = null;
|
||||
|
||||
public List<ResourceLocation> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public Integer getGrassColor() {
|
||||
return grassColor;
|
||||
}
|
||||
|
||||
|
||||
public Integer getFogColor() {
|
||||
return fogColor;
|
||||
}
|
||||
|
||||
public Integer getWaterColor() {
|
||||
return waterColor;
|
||||
}
|
||||
|
||||
public Integer getWaterFogColor() {
|
||||
return waterFogColor;
|
||||
}
|
||||
|
||||
|
||||
public Integer getFoliageColor() {
|
||||
return foliageColor;
|
||||
}
|
||||
|
||||
|
||||
public Integer getGrassColor() {
|
||||
return grassColor;
|
||||
}
|
||||
|
||||
public Integer getWaterColor() {
|
||||
return waterColor;
|
||||
}
|
||||
|
||||
public Integer getWaterFogColor() {
|
||||
return waterFogColor;
|
||||
}
|
||||
|
||||
public Integer getSkyColor() {
|
||||
return skyColor;
|
||||
}
|
||||
|
||||
|
||||
public GrassColorModifier getGrassColorModifier() {
|
||||
return grassColorModifier;
|
||||
}
|
||||
|
||||
|
||||
public AmbientParticleSettings getParticleConfig() {
|
||||
return particleConfig;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getPrecipitation() {
|
||||
return precipitation;
|
||||
}
|
||||
|
||||
|
||||
public Float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
|
||||
public TemperatureModifier getTemperatureModifier() {
|
||||
return temperatureModifier;
|
||||
}
|
||||
|
||||
|
||||
public Float getDownfall() {
|
||||
return downfall;
|
||||
}
|
||||
|
||||
|
||||
public SoundEvent getLoopSound() {
|
||||
return loopSound;
|
||||
}
|
||||
|
||||
|
||||
public AmbientMoodSettings getMoodSound() {
|
||||
return moodSound;
|
||||
}
|
||||
|
||||
|
||||
public AmbientAdditionsSettings getAdditionsSound() {
|
||||
return additionsSound;
|
||||
}
|
||||
|
||||
|
||||
public Music getMusic() {
|
||||
return music;
|
||||
}
|
||||
|
||||
|
||||
public MobSpawnSettings getSpawnSettings() {
|
||||
return spawnSettings;
|
||||
}
|
||||
|
||||
|
||||
public VillagerType getVillagerType() {
|
||||
return villagerType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user