mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 16:35:50 +00:00
commit
04f6d18198
@ -9,27 +9,27 @@ object Versions {
|
||||
const val strata = "1.3.2"
|
||||
|
||||
const val cloud = "2.0.0"
|
||||
const val cloudPaper = "2.0.0-beta.10"
|
||||
const val cloudFabric = "2.0.0-beta.9"
|
||||
|
||||
const val caffeine = "3.1.8"
|
||||
|
||||
const val slf4j = "2.0.16"
|
||||
|
||||
object Internal {
|
||||
const val shadow = "8.3.1"
|
||||
const val shadow = "8.3.3"
|
||||
const val apacheText = "1.12.0"
|
||||
const val apacheIO = "2.16.1"
|
||||
const val guava = "33.3.0-jre"
|
||||
const val asm = "9.7"
|
||||
const val apacheIO = "2.17.0"
|
||||
const val guava = "33.3.1-jre"
|
||||
const val asm = "9.7.1"
|
||||
const val snakeYml = "2.3"
|
||||
const val jetBrainsAnnotations = "24.1.0"
|
||||
const val junit = "5.11.0"
|
||||
const val jetBrainsAnnotations = "26.0.1"
|
||||
const val junit = "5.11.3"
|
||||
const val nbt = "6.1"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricAPI = "0.104.0+${Mod.minecraft}"
|
||||
const val fabricAPI = "0.106.1+${Mod.minecraft}"
|
||||
const val cloud = "2.0.0-beta.9"
|
||||
}
|
||||
//
|
||||
// object Quilt {
|
||||
@ -40,12 +40,13 @@ object Versions {
|
||||
object Mod {
|
||||
const val mixin = "0.15.3+mixin.0.8.7"
|
||||
|
||||
const val minecraft = "1.21.1"
|
||||
const val yarn = "$minecraft+build.3"
|
||||
const val fabricLoader = "0.16.5"
|
||||
const val minecraft = "1.21.3"
|
||||
const val yarn = "$minecraft+build.2"
|
||||
const val fabricLoader = "0.16.7"
|
||||
|
||||
const val architecuryLoom = "1.7.413"
|
||||
const val architecturyPlugin = "3.4.159"
|
||||
|
||||
}
|
||||
//
|
||||
// object Forge {
|
||||
@ -54,14 +55,15 @@ object Versions {
|
||||
// }
|
||||
|
||||
object Bukkit {
|
||||
const val minecraft = "1.21.1"
|
||||
const val paperBuild = "$minecraft-R0.1-20240917.151311-80"
|
||||
const val minecraft = "1.21.3"
|
||||
const val paperBuild = "$minecraft-R0.1-20241025.163321-1"
|
||||
const val paper = paperBuild
|
||||
const val paperLib = "1.0.8"
|
||||
const val reflectionRemapper = "0.1.1"
|
||||
const val paperDevBundle = paperBuild
|
||||
const val runPaper = "2.3.1"
|
||||
const val paperWeight = "1.7.2"
|
||||
const val cloud = "2.0.0-beta.10"
|
||||
}
|
||||
|
||||
//
|
||||
@ -72,7 +74,6 @@ object Versions {
|
||||
// }
|
||||
//
|
||||
object CLI {
|
||||
const val nbt = "6.1"
|
||||
const val logback = "1.5.8"
|
||||
const val picocli = "4.7.6"
|
||||
}
|
||||
|
@ -6,8 +6,3 @@ dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
}
|
||||
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.numberpredicate.lib.paralithic")
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.7")
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
api("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
implementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic)
|
||||
}
|
||||
|
||||
tasks.withType<Jar> {
|
||||
|
@ -3,11 +3,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.7")
|
||||
api("com.github.Querz:NBT:6.1")
|
||||
api("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
api("com.github.Querz", "NBT", Versions.Libraries.Internal.nbt)
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons")
|
||||
}
|
@ -3,10 +3,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
version = version("1.2.0")
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.7")
|
||||
api("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.apache.commons", "com.dfsek.terra.addons.terrascript.lib.commons")
|
||||
}
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
|
||||
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
5
gradlew
vendored
5
gradlew
vendored
@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@ -84,7 +86,8 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -19,7 +19,7 @@ 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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,14 @@ 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;
|
||||
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.mainThreadMailBox()
|
||||
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,6 +2,7 @@ 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;
|
||||
@ -14,6 +15,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;
|
||||
@ -22,6 +25,7 @@ public class Reflection {
|
||||
public static final ReferenceProxy REFERENCE;
|
||||
|
||||
public static final ChunkMapProxy CHUNKMAP;
|
||||
public static final HolderSetProxy HOLDER_SET;
|
||||
|
||||
static {
|
||||
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
||||
@ -32,6 +36,7 @@ public class Reflection {
|
||||
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
||||
REFERENCE = reflectionProxyFactory.reflectionProxy(ReferenceProxy.class);
|
||||
CHUNKMAP = reflectionProxyFactory.reflectionProxy(ChunkMapProxy.class);
|
||||
HOLDER_SET = reflectionProxyFactory.reflectionProxy(HolderSetProxy.class);
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +62,16 @@ public class Reflection {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ public class RegistryFetcher {
|
||||
DedicatedServer dedicatedserver = craftserver.getServer();
|
||||
return dedicatedserver
|
||||
.registryAccess()
|
||||
.registryOrThrow(key);
|
||||
.get(key)
|
||||
.orElseThrow()
|
||||
.value();
|
||||
}
|
||||
|
||||
public static Registry<Biome> biomeRegistry() {
|
||||
|
@ -8,7 +8,7 @@ dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
shadedApi("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
shadedApi("com.github.Querz", "NBT", Versions.CLI.nbt)
|
||||
shadedApi("com.github.Querz", "NBT", Versions.Libraries.Internal.nbt)
|
||||
|
||||
shadedImplementation("info.picocli", "picocli", Versions.CLI.picocli)
|
||||
annotationProcessor("info.picocli", "picocli-codegen", Versions.CLI.picocli)
|
||||
|
@ -26,8 +26,8 @@ dependencies {
|
||||
|
||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
||||
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric)
|
||||
include("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric)
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||
include("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||
|
||||
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
|
||||
}
|
||||
|
@ -32,9 +32,9 @@
|
||||
"terra.common.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.5",
|
||||
"fabricloader": ">=0.16.7",
|
||||
"java": ">=21",
|
||||
"minecraft": ">=1.21.1",
|
||||
"minecraft": ">=1.21.3",
|
||||
"fabric": "*"
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticle
|
||||
try {
|
||||
return new BiomeParticleConfig(
|
||||
ParticleEffectArgumentType.readParameters(new StringReader(particle),
|
||||
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE.getReadOnlyWrapper()),
|
||||
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE),
|
||||
probability);
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -15,6 +15,6 @@ public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
|
||||
|
||||
@Override
|
||||
public EntityType<?> get() {
|
||||
return Registries.ENTITY_TYPE.get(id);
|
||||
return Registries.ENTITY_TYPE.getEntry(id).orElseThrow().value();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
|
||||
|
||||
@Override
|
||||
public VillagerType get() {
|
||||
return Registries.VILLAGER_TYPE.get(id);
|
||||
return Registries.VILLAGER_TYPE.getEntry(id).orElseThrow().value();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeAccess;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.GenerationStep.Carver;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.StructureWeightSampler;
|
||||
import net.minecraft.world.gen.chunk.Blender;
|
||||
@ -97,7 +96,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
public void populateEntities(ChunkRegion region) {
|
||||
if(!this.settings.value().mobGenerationDisabled()) {
|
||||
ChunkPos chunkPos = region.getCenterPos();
|
||||
RegistryEntry<Biome> registryEntry = region.getBiome(chunkPos.getStartPos().withY(region.getTopY() - 1));
|
||||
RegistryEntry<Biome> registryEntry = region.getBiome(chunkPos.getStartPos().withY(region.getTopYInclusive() - 1));
|
||||
ChunkRandom chunkRandom = new ChunkRandom(new CheckedRandom(RandomSeed.getSeed()));
|
||||
chunkRandom.setPopulationSeed(region.getSeed(), chunkPos.getStartX(), chunkPos.getStartZ());
|
||||
SpawnHelper.populateEntities(region, registryEntry, chunkPos, chunkRandom);
|
||||
@ -179,7 +178,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
|
||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||
int min = height.getBottomY();
|
||||
for(int y = height.getTopY() - 1; y >= min; y--) {
|
||||
for(int y = height.getTopYInclusive() - 1; y >= min; y--) {
|
||||
if(heightmap
|
||||
.getBlockPredicate()
|
||||
.test((BlockState) delegate.getBlock(properties, x, y, z, biomeProvider))) return y + 1;
|
||||
@ -192,14 +191,14 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
BlockState[] array = new BlockState[height.getHeight()];
|
||||
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
|
||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
||||
for(int y = height.getTopYInclusive() - 1; y >= height.getBottomY(); y--) {
|
||||
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(properties, x, y, z, biomeProvider);
|
||||
}
|
||||
return new VerticalBlockSample(height.getBottomY(), array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
|
||||
public void appendDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@ -215,10 +214,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
logger.debug("Loading world with config pack {}", pack.getID());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor,
|
||||
Chunk chunk, Carver carverStep) {
|
||||
// no op
|
||||
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess biomeAccess,
|
||||
StructureAccessor structureAccessor, Chunk chunk) {
|
||||
//no op
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,6 +24,7 @@ import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryWrapper.Impl;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -43,14 +44,19 @@ public class MinecraftItemHandle implements ItemHandle {
|
||||
public Item createItem(String data) {
|
||||
try {
|
||||
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
|
||||
@Override
|
||||
public FeatureSet getEnabledFeatures() {
|
||||
return FeatureSet.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
|
||||
return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<Impl<T>> getOptionalWrapper(RegistryKey<? extends Registry<? extends T>> registryRef) {
|
||||
return Optional.of(CommonPlatform.get().getServer().getRegistryManager().getWrapperOrThrow(registryRef));
|
||||
public <T> Optional<Impl<T>> getOptional(RegistryKey<? extends Registry<? extends T>> registryRef) {
|
||||
return Optional.of(CommonPlatform.get().getServer().getRegistryManager().getOrThrow(registryRef));
|
||||
}
|
||||
}).parse(new StringReader(data)).getItem();
|
||||
} catch(CommandSyntaxException e) {
|
||||
@ -60,7 +66,7 @@ public class MinecraftItemHandle implements ItemHandle {
|
||||
|
||||
@Override
|
||||
public Enchantment getEnchantment(String id) {
|
||||
return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().get(Identifier.tryParse(id)));
|
||||
return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().getEntry(Identifier.tryParse(id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +48,7 @@ public class MinecraftWorldHandle implements WorldHandle {
|
||||
". You are advised to perform this rename in your config packs as this translation will be removed in the next major " +
|
||||
"version of Terra.");
|
||||
}
|
||||
net.minecraft.block.BlockState state = BlockArgumentParser.block(Registries.BLOCK.getReadOnlyWrapper(), data, true)
|
||||
net.minecraft.block.BlockState state = BlockArgumentParser.block(Registries.BLOCK, data, true)
|
||||
.blockState();
|
||||
if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
|
||||
return (BlockState) state;
|
||||
@ -76,6 +76,6 @@ public class MinecraftWorldHandle implements WorldHandle {
|
||||
if(!id.contains(":")) throw new IllegalArgumentException("Invalid entity identifier " + id);
|
||||
Identifier identifier = Identifier.tryParse(id);
|
||||
if(identifier == null) identifier = Identifier.tryParse(id);
|
||||
return (EntityType) Registries.ENTITY_TYPE.get(identifier);
|
||||
return (EntityType) Registries.ENTITY_TYPE.getEntry(identifier).orElseThrow().value();
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
public abstract void setEntityType(net.minecraft.entity.EntityType<?> entityType, Random random);
|
||||
|
||||
public EntityType terra$getSpawnedType() {
|
||||
return (EntityType) Registries.ENTITY_TYPE.get(
|
||||
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id")));
|
||||
return (EntityType) Registries.ENTITY_TYPE.getEntry(
|
||||
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id"))).orElseThrow();
|
||||
}
|
||||
|
||||
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
||||
|
@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
|
||||
@ -24,7 +25,7 @@ public abstract class PropertyMixin<T> {
|
||||
private String name;
|
||||
|
||||
@Shadow
|
||||
public abstract Collection<T> getValues();
|
||||
public abstract List<T> getValues();
|
||||
|
||||
@Intrinsic
|
||||
public Collection<T> terra$values() {
|
||||
|
@ -49,9 +49,6 @@ public abstract class WorldChunkMixin {
|
||||
@Nullable
|
||||
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
||||
|
||||
@Shadow
|
||||
public abstract TickSchedulers getTickSchedulers();
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||
BlockPos blockPos = new BlockPos(x, y, z);
|
||||
setBlockState(blockPos, (net.minecraft.block.BlockState) data, false);
|
||||
|
@ -48,6 +48,6 @@ public abstract class ProtoChunkMixin {
|
||||
}
|
||||
|
||||
public int terra$getMaxHeight() {
|
||||
return getHeightLimitView().getTopY();
|
||||
return getHeightLimitView().getTopYInclusive();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package com.dfsek.terra.mod.mixin.implementations.terra.inventory.item;
|
||||
|
||||
import net.minecraft.component.ComponentChanges;
|
||||
import net.minecraft.component.ComponentMap;
|
||||
import net.minecraft.component.ComponentMapImpl;
|
||||
import net.minecraft.component.MergedComponentMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
@ -37,7 +37,7 @@ import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
public abstract class ItemStackMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private ComponentMapImpl components;
|
||||
private MergedComponentMap components;
|
||||
|
||||
@Shadow
|
||||
public abstract int getCount();
|
||||
|
@ -18,6 +18,7 @@
|
||||
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
||||
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.util.collection.BoundedRegionArray;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -99,7 +100,7 @@ public abstract class ChunkRegionMixin {
|
||||
}
|
||||
|
||||
public int terraWorld$getMaxHeight() {
|
||||
return world.getTopY();
|
||||
return world.getTopYInclusive();
|
||||
}
|
||||
|
||||
@Intrinsic(displace = true)
|
||||
@ -125,7 +126,7 @@ public abstract class ChunkRegionMixin {
|
||||
}
|
||||
|
||||
public Entity terraWorld$spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(world);
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(world, SpawnReason.CHUNK_GENERATION);
|
||||
entity.setPos(x, y, z);
|
||||
((ChunkRegion) (Object) this).spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
||||
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
@ -42,7 +43,7 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
|
||||
public abstract class ServerWorldMixin {
|
||||
public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(null);
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(null, SpawnReason.CHUNK_GENERATION);
|
||||
entity.setPos(x, y, z);
|
||||
((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -1,10 +1,16 @@
|
||||
package com.dfsek.terra.mod.mixin.lifecycle;
|
||||
|
||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.Registry.PendingTagLoad;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.ReloadableRegistries;
|
||||
import net.minecraft.registry.ServerDynamicRegistryType;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.server.DataPackContents;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -16,6 +22,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
import com.dfsek.terra.mod.util.TagUtil;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
|
||||
@Mixin(DataPackContents.class)
|
||||
public class DataPackContentsMixin {
|
||||
@ -26,12 +38,17 @@ public class DataPackContentsMixin {
|
||||
/*
|
||||
* #refresh populates all tags in the registries
|
||||
*/
|
||||
@Inject(method = "refresh()V", at = @At("RETURN"))
|
||||
private void injectReload(CallbackInfo ci) {
|
||||
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager();
|
||||
TagUtil.registerWorldPresetTags(dynamicRegistryManager.get(RegistryKeys.WORLD_PRESET));
|
||||
@Inject(method = "reload(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
|
||||
private static void injectReload(ResourceManager resourceManager,
|
||||
CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries,
|
||||
List<PendingTagLoad<?>> pendingTagLoads, FeatureSet enabledFeatures,
|
||||
CommandManager.RegistrationEnvironment environment, int functionPermissionLevel,
|
||||
Executor prepareExecutor,
|
||||
Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<DataPackContents>> cir) {
|
||||
DynamicRegistryManager.Immutable dynamicRegistryManager = dynamicRegistries.getCombinedRegistryManager();
|
||||
TagUtil.registerWorldPresetTags(dynamicRegistryManager.getOrThrow(RegistryKeys.WORLD_PRESET));
|
||||
|
||||
Registry<Biome> biomeRegistry = dynamicRegistryManager.get(RegistryKeys.BIOME);
|
||||
Registry<Biome> biomeRegistry = dynamicRegistryManager.getOrThrow(RegistryKeys.BIOME);
|
||||
TagUtil.registerBiomeTags(biomeRegistry);
|
||||
MinecraftUtil.registerFlora(biomeRegistry);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public final class MinecraftAdapter {
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return height.getTopY();
|
||||
return height.getTopYInclusive();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,9 +46,8 @@ public final class MinecraftUtil {
|
||||
}
|
||||
|
||||
public static <T> Optional<RegistryEntry<T>> getEntry(Registry<T> registry, Identifier identifier) {
|
||||
return registry.getOrEmpty(identifier)
|
||||
.flatMap(registry::getKey)
|
||||
.flatMap(registry::getEntry);
|
||||
return registry.getOptionalValue(identifier)
|
||||
.flatMap(id -> Optional.ofNullable(registry.getEntry(id)));
|
||||
}
|
||||
|
||||
public static BlockEntity createState(WorldAccess worldAccess, BlockPos pos) {
|
||||
@ -67,9 +66,9 @@ public final class MinecraftUtil {
|
||||
logger.info("Injecting flora into Terra biomes...");
|
||||
TERRA_BIOME_MAP
|
||||
.forEach((vb, terraBiomes) ->
|
||||
biomes.getOrEmpty(vb)
|
||||
biomes.getOptionalValue(vb)
|
||||
.ifPresentOrElse(vanilla -> terraBiomes
|
||||
.forEach(tb -> biomes.getOrEmpty(tb)
|
||||
.forEach(tb -> biomes.getOptionalValue(tb)
|
||||
.ifPresentOrElse(
|
||||
terra -> {
|
||||
List<ConfiguredFeature<?, ?>> flowerFeatures = List.copyOf(
|
||||
|
@ -40,9 +40,8 @@ public class PresetUtil {
|
||||
platform.multiNoiseBiomeSourceParameterListRegistry();
|
||||
|
||||
|
||||
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getEntry(DimensionTypes.OVERWORLD).orElseThrow();
|
||||
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.OVERWORLD)
|
||||
.orElseThrow();
|
||||
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.OVERWORLD));
|
||||
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.OVERWORLD));
|
||||
|
||||
|
||||
Identifier generatorID = Identifier.tryParse(
|
||||
@ -51,15 +50,13 @@ public class PresetUtil {
|
||||
|
||||
PRESETS.add(generatorID);
|
||||
|
||||
RegistryEntry<DimensionType> registryEntry = dimensionTypeRegistry.getEntry(DimensionTypes.THE_NETHER).orElseThrow();
|
||||
RegistryEntry.Reference<MultiNoiseBiomeSourceParameterList> reference = multiNoiseBiomeSourceParameterLists.getEntry(
|
||||
MultiNoiseBiomeSourceParameterLists.NETHER).orElseThrow();
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry2 = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.NETHER)
|
||||
.orElseThrow();
|
||||
RegistryEntry<DimensionType> registryEntry = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.THE_NETHER));
|
||||
RegistryEntry<MultiNoiseBiomeSourceParameterList> reference = multiNoiseBiomeSourceParameterLists.getEntry(
|
||||
multiNoiseBiomeSourceParameterLists.get(MultiNoiseBiomeSourceParameterLists.NETHER));
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry2 = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.NETHER));
|
||||
|
||||
RegistryEntry<DimensionType> registryEntry3 = dimensionTypeRegistry.getEntry(DimensionTypes.THE_END).orElseThrow();
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry4 = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.END)
|
||||
.orElseThrow();
|
||||
RegistryEntry<DimensionType> registryEntry3 = dimensionTypeRegistry.getEntry(dimensionTypeRegistry.get(DimensionTypes.THE_END));
|
||||
RegistryEntry<ChunkGeneratorSettings> registryEntry4 = chunkGeneratorSettingsRegistry.getEntry(chunkGeneratorSettingsRegistry.get(ChunkGeneratorSettings.END));
|
||||
|
||||
TerraBiomeSource biomeSource = new TerraBiomeSource(pack);
|
||||
ChunkGenerator generator = new MinecraftChunkGeneratorWrapper(biomeSource, pack, overworld);
|
||||
@ -69,7 +66,7 @@ public class PresetUtil {
|
||||
new NoiseChunkGenerator(MultiNoiseBiomeSource.create(reference),
|
||||
registryEntry2));
|
||||
DimensionOptions endDimensionOptions = new DimensionOptions(registryEntry3, new NoiseChunkGenerator(
|
||||
TheEndBiomeSource.createVanilla(platform.biomeRegistry().getReadOnlyWrapper()), registryEntry4));
|
||||
TheEndBiomeSource.createVanilla(platform.biomeRegistry()), registryEntry4));
|
||||
|
||||
WorldPreset preset = createPreset(dimensionOptions, netherDimensionOptions, endDimensionOptions);
|
||||
LOGGER.info("Created world type \"{}\"", generatorID);
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.tag.TagGroupLoader.RegistryTags;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.registry.tag.WorldPresetTags;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public final class TagUtil {
|
||||
@ -24,11 +25,8 @@ public final class TagUtil {
|
||||
}
|
||||
|
||||
private static <T> Map<TagKey<T>, List<RegistryEntry<T>>> tagsToMutableMap(Registry<T> registry) {
|
||||
return registry
|
||||
.streamTagsAndEntries()
|
||||
.collect(HashMap::new,
|
||||
(map, pair) ->
|
||||
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
||||
return registry.streamTags().collect(HashMap::new,
|
||||
(map, tag) -> map.put(tag.getTag(), tag.stream().collect(Collectors.toList())),
|
||||
HashMap::putAll);
|
||||
}
|
||||
|
||||
@ -46,8 +44,14 @@ public final class TagUtil {
|
||||
.add(preset),
|
||||
() -> logger.error("Preset {} does not exist!", id)));
|
||||
|
||||
registry.clearTags();
|
||||
registry.populateTags(ImmutableMap.copyOf(collect));
|
||||
registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
|
||||
|
||||
if(logger.isDebugEnabled()) {
|
||||
registry.streamEntries()
|
||||
.map(e -> e.registryKey().getValue() + ": " +
|
||||
e.streamTags().reduce("", (s, t) -> t.id() + ", " + s, String::concat))
|
||||
.forEach(logger::debug);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerBiomeTags(Registry<Biome> registry) {
|
||||
@ -90,8 +94,7 @@ public final class TagUtil {
|
||||
tb))),
|
||||
() -> logger.error("No vanilla biome: {}", vb)));
|
||||
|
||||
registry.clearTags();
|
||||
registry.populateTags(ImmutableMap.copyOf(collect));
|
||||
registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
|
||||
|
||||
if(logger.isDebugEnabled()) {
|
||||
registry.streamEntries()
|
||||
|
@ -15,7 +15,7 @@ dependencies {
|
||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric) {
|
||||
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
||||
|
||||
|
||||
if(server != null) {
|
||||
BiomeUtil.registerBiomes(server.getRegistryManager().get(RegistryKeys.BIOME));
|
||||
BiomeUtil.registerBiomes(server.getRegistryManager().getOrThrow(RegistryKeys.BIOME));
|
||||
server.reloadResources(server.getDataPackManager().getEnabledIds()).exceptionally(throwable -> {
|
||||
LOGGER.warn("Failed to execute reload", throwable);
|
||||
return null;
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized;
|
||||
|
||||
|
||||
@Mixin(CreateWorldScreen.class)
|
||||
public class CreateWorldScreenMixin {
|
||||
@Inject(method = "onCloseScreen()V", at = @At("HEAD"))
|
||||
public void onClose(CallbackInfo ci) {
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
platform.getRawConfigRegistry().clear();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -34,6 +37,8 @@ public class MinecraftServerMixin {
|
||||
|
||||
@Inject(method = "shutdown()V", at = @At("RETURN"))
|
||||
private void injectShutdown(CallbackInfo ci) {
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
platform.getRawConfigRegistry().clear();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ public class RegistryLoaderMixin {
|
||||
private static Logger LOGGER;
|
||||
|
||||
@Redirect(
|
||||
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;" +
|
||||
"Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.ServerDynamicRegistryType;
|
||||
import net.minecraft.server.SaveLoading;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -18,13 +19,11 @@ public class SaveLoadingMixin {
|
||||
"Ljava/util/concurrent/CompletableFuture;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/registry/RegistryLoader;loadFromResource(Lnet/minecraft/resource/ResourceManager;" +
|
||||
"Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)" +
|
||||
"Lnet/minecraft/registry/DynamicRegistryManager$Immutable;"),
|
||||
target = "Lnet/minecraft/server/DataPackContents;reload(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"),
|
||||
index = 1
|
||||
)
|
||||
private static DynamicRegistryManager grabManager(DynamicRegistryManager registryManager) {
|
||||
MinecraftUtil.registerFlora(registryManager.get(RegistryKeys.BIOME));
|
||||
return registryManager;
|
||||
private static CombinedDynamicRegistries<ServerDynamicRegistryType> grabManager(CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries) {
|
||||
MinecraftUtil.registerFlora(dynamicRegistries.getCombinedRegistryManager().getOrThrow(RegistryKeys.BIOME));
|
||||
return dynamicRegistries;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public final class BiomeUtil {
|
||||
|
||||
|
||||
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(vanilla).orElseThrow());
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(registry.get(vanilla)));
|
||||
} else {
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
"lifecycle.SaveLoadingMixin"
|
||||
],
|
||||
"client": [
|
||||
"lifecycle.CreateWorldScreenMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user