mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-12-03 20:01:49 +00:00
feat: bukkit metapacks and clean up
This commit is contained in:
1 parent
dcf38956c4
commit
02c2176222
36 files changed
+1026
-230
No files matched your search
+13
-9
@@ -7,7 +7,6 @@ import net.minecraft.resources.ResourceKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
@@ -15,6 +14,7 @@ import com.dfsek.terra.minecraft.attribute.BiomeTags.PlatformTagSource;
|
||||
import com.dfsek.terra.minecraft.attribute.MinecraftAttributeParents;
|
||||
import com.dfsek.terra.minecraft.attribute.MinecraftBiomeFactory;
|
||||
import com.dfsek.terra.minecraft.attribute.PackParents;
|
||||
import com.dfsek.terra.minecraft.attribute.TerraBiomeIndex;
|
||||
import com.dfsek.terra.mod.CommonPlatform;
|
||||
import com.dfsek.terra.mod.ModPlatform;
|
||||
import com.dfsek.terra.mod.config.PreLoadCompatibilityOptions;
|
||||
@@ -34,16 +34,16 @@ public final class LifecycleBiomeUtil {
|
||||
|
||||
public static void registerBiomes(Registry<net.minecraft.world.level.biome.Biome> biomeRegistry, MinecraftBiomeFactory factory) {
|
||||
logger.info("Registering biomes...");
|
||||
BiomeUtil.TERRA_BIOME_MAP.clear();
|
||||
BiomeUtil.TERRA_BIOME_PLATFORM_TAGS.clear();
|
||||
TerraBiomeIndex biomes = new TerraBiomeIndex();
|
||||
ModPlatform platform = CommonPlatform.get();
|
||||
MinecraftAttributeParents parents = platform.attributeParents();
|
||||
platform.getConfigRegistry().forEach(pack -> { // Register all Terra biomes.
|
||||
PackParents packParents = parents.prepare(pack, platform.getAttributeHandle().pack(pack),
|
||||
AttributeReport.logging(pack));
|
||||
pack.getCheckedRegistry(Biome.class)
|
||||
.forEach((id, biome) -> registerBiome(biome, pack, packParents, id, biomeRegistry, parents, factory));
|
||||
.forEach((id, biome) -> registerBiome(biome, pack, packParents, id, biomeRegistry, parents, factory, biomes));
|
||||
});
|
||||
BiomeUtil.setTerraBiomes(biomes);
|
||||
logger.info("Terra biomes registered.");
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class LifecycleBiomeUtil {
|
||||
private static void registerBiome(Biome biome, ConfigPack pack, PackParents packParents,
|
||||
com.dfsek.terra.api.registry.key.RegistryKey id,
|
||||
Registry<net.minecraft.world.level.biome.Biome> registry, MinecraftAttributeParents parents,
|
||||
MinecraftBiomeFactory factory) {
|
||||
MinecraftBiomeFactory factory, TerraBiomeIndex biomes) {
|
||||
ProtoPlatformBiome proto = (ProtoPlatformBiome) biome.getPlatformBiome();
|
||||
ResourceKey<net.minecraft.world.level.biome.Biome> vanilla = proto.get(registry);
|
||||
net.minecraft.world.level.biome.Biome vanillaBiome = vanilla == null ? null : registry.getValue(vanilla);
|
||||
@@ -75,7 +75,13 @@ public final class LifecycleBiomeUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
Identifier identifier = Identifier.fromNamespaceAndPath("terra", BiomeUtil.createBiomeID(pack, id));
|
||||
Identifier identifier = MinecraftBiomeFactory.terraId(pack, id);
|
||||
|
||||
if(biomes.contains(identifier)) {
|
||||
logger.warn(TerraBiomeIndex.sharedBiome(pack.getID(), biome.getID(), identifier));
|
||||
proto.setDelegate(MinecraftUtil.getEntry(registry, identifier).orElseThrow());
|
||||
return;
|
||||
}
|
||||
|
||||
if(registry.containsKey(identifier)) {
|
||||
// Registered by an earlier load; edits wait for the next registry load.
|
||||
@@ -88,8 +94,6 @@ public final class LifecycleBiomeUtil {
|
||||
VillagerTypeAccessor.getBiomeTypeToIdMap().put(ResourceKey.create(Registries.BIOME, identifier), built.villagerType());
|
||||
}
|
||||
|
||||
BiomeUtil.TERRA_BIOME_PLATFORM_TAGS.put(identifier,
|
||||
new PlatformTagSource(packParents.report(), biome.getID(), biome.getPlatformTags()));
|
||||
BiomeUtil.TERRA_BIOME_MAP.computeIfAbsent(vanilla.identifier(), i -> new ArrayList<>()).add(identifier);
|
||||
biomes.record(identifier, vanilla.identifier(), new PlatformTagSource(packParents.report(), biome.getID(), biome.getPlatformTags()));
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -40,8 +40,7 @@ public final class LifecycleUtil {
|
||||
|
||||
private static void registerTimelines(ModPlatform platform, WritableRegistry<Timeline> timelines) {
|
||||
MinecraftAttributeParents parents = platform.attributeParents();
|
||||
VanillaContext context = parents.context();
|
||||
if(context == null) throw new IllegalStateException("no registry load has begun");
|
||||
VanillaContext context = parents.requireContext();
|
||||
platform.getConfigRegistry().forEach(pack -> {
|
||||
PackParents packParents = parents.prepare(pack, platform.getAttributeHandle().pack(pack),
|
||||
AttributeReport.logging(pack));
|
||||
@@ -50,8 +49,6 @@ public final class LifecycleUtil {
|
||||
}
|
||||
|
||||
public static MinecraftBiomeFactory biomeFactory(ModPlatform platform) {
|
||||
VanillaContext context = platform.attributeParents().context();
|
||||
if(context == null) throw new IllegalStateException("no registry load has begun");
|
||||
return new MinecraftBiomeFactory(platform.getAttributeHandle(), context);
|
||||
return new MinecraftBiomeFactory(platform.getAttributeHandle(), platform.attributeParents().requireContext());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user