Biome -> PlatformBiome

This commit is contained in:
dfsek 2021-12-04 17:46:26 -07:00
parent 4d2639207d
commit 16c80a0976
10 changed files with 31 additions and 27 deletions

View File

@ -27,7 +27,7 @@ import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.PlatformBiome;
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
@ -53,7 +53,7 @@ public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTempl
private @Meta NoiseSampler carvingEquation = NoiseSampler.zero();
@Value("vanilla")
private @Meta ProbabilityCollection<Biome> vanilla;
private @Meta ProbabilityCollection<PlatformBiome> vanilla;
@Value("biome-noise")
@Default
@ -198,7 +198,7 @@ public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTempl
return id;
}
public ProbabilityCollection<Biome> getVanilla() {
public ProbabilityCollection<PlatformBiome> getVanilla() {
return vanilla;
}

View File

@ -11,7 +11,7 @@ import java.util.Set;
import com.dfsek.terra.api.properties.Context;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.PlatformBiome;
import com.dfsek.terra.api.world.biome.GenerationSettings;
import com.dfsek.terra.api.world.biome.TerraBiome;
@ -21,7 +21,7 @@ import com.dfsek.terra.api.world.biome.TerraBiome;
*/
public class UserDefinedBiome implements TerraBiome {
private final UserDefinedGenerationSettings gen;
private final ProbabilityCollection<Biome> vanilla;
private final ProbabilityCollection<PlatformBiome> vanilla;
private final String id;
private final BiomeTemplate config;
private final int color;
@ -29,7 +29,7 @@ public class UserDefinedBiome implements TerraBiome {
private final Context context = new Context();
public UserDefinedBiome(ProbabilityCollection<Biome> vanilla, UserDefinedGenerationSettings gen, BiomeTemplate config) {
public UserDefinedBiome(ProbabilityCollection<PlatformBiome> vanilla, UserDefinedGenerationSettings gen, BiomeTemplate config) {
this.vanilla = vanilla;
this.gen = gen;
this.id = config.getID();
@ -50,7 +50,7 @@ public class UserDefinedBiome implements TerraBiome {
* @return Collection of biomes to represent the custom biome.
*/
@Override
public ProbabilityCollection<Biome> getVanillaBiomes() {
public ProbabilityCollection<PlatformBiome> getVanillaBiomes() {
return vanilla;
}

View File

@ -10,5 +10,5 @@ package com.dfsek.terra.api.world.biome;
import com.dfsek.terra.api.Handle;
public interface Biome extends Handle {
public interface PlatformBiome extends Handle {
}

View File

@ -24,7 +24,7 @@ public interface TerraBiome extends PropertyHolder {
*
* @return TerraBiome - The Vanilla biome.
*/
ProbabilityCollection<Biome> getVanillaBiomes();
ProbabilityCollection<PlatformBiome> getVanillaBiomes();
/**
* Gets the BiomeTerrain instance used to generate the biome.

View File

@ -29,10 +29,10 @@ import com.dfsek.terra.AbstractPlatform;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.handle.WorldHandle;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.PlatformBiome;
import com.dfsek.terra.bukkit.handles.BukkitItemHandle;
import com.dfsek.terra.bukkit.handles.BukkitWorldHandle;
import com.dfsek.terra.bukkit.world.BukkitBiome;
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
import org.jetbrains.annotations.NotNull;
@ -87,13 +87,13 @@ public class PlatformImpl extends AbstractPlatform {
public void register(TypeRegistry registry) {
super.register(registry);
registry.registerLoader(BlockState.class, (t, o, l) -> handle.createBlockData((String) o))
.registerLoader(Biome.class, (t, o, l) -> parseBiome((String) o))
.registerLoader(PlatformBiome.class, (t, o, l) -> parseBiome((String) o))
.registerLoader(EntityType.class, (t, o, l) -> EntityType.valueOf((String) o));
}
private BukkitBiome parseBiome(String id) throws LoadException {
private BukkitPlatformBiome parseBiome(String id) throws LoadException {
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id);
return new BukkitBiome(org.bukkit.block.Biome.valueOf(id.toUpperCase(Locale.ROOT).substring(10)));
return new BukkitPlatformBiome(org.bukkit.block.Biome.valueOf(id.toUpperCase(Locale.ROOT).substring(10)));
}
}

View File

@ -17,13 +17,13 @@
package com.dfsek.terra.bukkit.world;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.PlatformBiome;
public class BukkitBiome implements Biome {
public class BukkitPlatformBiome implements PlatformBiome {
private final org.bukkit.block.Biome biome;
public BukkitBiome(org.bukkit.block.Biome biome) {
public BukkitPlatformBiome(org.bukkit.block.Biome biome) {
this.biome = biome;
}

View File

@ -22,6 +22,9 @@ import ca.solostudios.strata.parser.tokenizer.ParseException;
import ca.solostudios.strata.version.Version;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.TypeRegistry;
import com.dfsek.terra.api.world.biome.PlatformBiome;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.MinecraftVersion;
import net.minecraft.server.world.ServerWorld;
@ -46,7 +49,7 @@ import com.dfsek.terra.api.util.generic.Lazy;
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
import com.dfsek.terra.fabric.handle.FabricItemHandle;
import com.dfsek.terra.fabric.handle.FabricWorldHandle;
import com.dfsek.terra.fabric.util.ProtoBiome;
import com.dfsek.terra.fabric.util.ProtoPlatformBiome;
public class PlatformImpl extends AbstractPlatform {
@ -135,7 +138,7 @@ public class PlatformImpl extends AbstractPlatform {
@Override
public void register(TypeRegistry registry) {
super.register(registry);
registry.registerLoader(com.dfsek.terra.api.world.biome.Biome.class, (t, o, l) -> parseBiome((String) o))
registry.registerLoader(PlatformBiome.class, (t, o, l) -> parseBiome((String) o))
.registerLoader(Identifier.class, (t, o, l) -> {
Identifier identifier = Identifier.tryParse((String) o);
if(identifier == null)
@ -145,9 +148,9 @@ public class PlatformImpl extends AbstractPlatform {
}
private ProtoBiome parseBiome(String id) throws LoadException {
private ProtoPlatformBiome parseBiome(String id) throws LoadException {
Identifier identifier = Identifier.tryParse(id);
if(BuiltinRegistries.BIOME.get(identifier) == null) throw new LoadException("Invalid Biome ID: " + identifier); // failure.
return new ProtoBiome(identifier);
return new ProtoPlatformBiome(identifier);
}
}

View File

@ -17,6 +17,8 @@
package com.dfsek.terra.fabric.mixin.implementations;
import com.dfsek.terra.api.world.biome.PlatformBiome;
import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
@ -25,7 +27,7 @@ import org.spongepowered.asm.mixin.Mixin;
@Mixin(Biome.class)
@Implements(@Interface(iface = com.dfsek.terra.api.world.biome.Biome.class, prefix = "terra$", remap = Interface.Remap.NONE))
@Implements(@Interface(iface = PlatformBiome.class, prefix = "terra$", remap = Interface.Remap.NONE))
public abstract class BiomeMixin {
@Intrinsic
public Object terra$getHandle() {

View File

@ -46,7 +46,6 @@ import com.dfsek.terra.api.block.entity.MobSpawner;
import com.dfsek.terra.api.block.entity.Sign;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.fabric.FabricEntryPoint;
import com.dfsek.terra.fabric.mixin.access.BiomeEffectsAccessor;
@ -70,7 +69,7 @@ public final class FabricUtil {
//TerraFabricPlugin.FabricAddon fabricAddon = TerraFabricPlugin.getInstance().getFabricAddon();
Registry<Biome> biomeRegistry = registryManager.get(Registry.BIOME_KEY);
Biome vanilla = ((ProtoBiome) (new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0))).get(biomeRegistry);
Biome vanilla = ((ProtoPlatformBiome) (new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0))).get(biomeRegistry);
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();

View File

@ -20,13 +20,13 @@ package com.dfsek.terra.fabric.util;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.PlatformBiome;
public class ProtoBiome implements Biome {
public class ProtoPlatformBiome implements PlatformBiome {
private final Identifier identifier;
public ProtoBiome(Identifier identifier) {
public ProtoPlatformBiome(Identifier identifier) {
this.identifier = identifier;
}