implement BiomeMixin

This commit is contained in:
dfsek 2021-05-02 22:49:57 -07:00
parent 20a5762d2e
commit 2d27e07441
3 changed files with 8 additions and 24 deletions

View File

@ -38,10 +38,9 @@ import com.dfsek.terra.config.lang.Language;
import com.dfsek.terra.config.pack.ConfigPack; import com.dfsek.terra.config.pack.ConfigPack;
import com.dfsek.terra.config.templates.BiomeTemplate; import com.dfsek.terra.config.templates.BiomeTemplate;
import com.dfsek.terra.fabric.handle.FabricItemHandle; import com.dfsek.terra.fabric.handle.FabricItemHandle;
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
import com.dfsek.terra.fabric.world.FabricBiome;
import com.dfsek.terra.fabric.world.FabricTree;
import com.dfsek.terra.fabric.handle.FabricWorldHandle; import com.dfsek.terra.fabric.handle.FabricWorldHandle;
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
import com.dfsek.terra.fabric.world.FabricTree;
import com.dfsek.terra.fabric.world.TerraBiomeSource; import com.dfsek.terra.fabric.world.TerraBiomeSource;
import com.dfsek.terra.fabric.world.features.PopulatorFeature; import com.dfsek.terra.fabric.world.features.PopulatorFeature;
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper; import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
@ -247,14 +246,14 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
genericLoaders.register(registry); genericLoaders.register(registry);
registry registry
.registerLoader(BlockData.class, (t, o, l) -> worldHandle.createBlockData((String) o)) .registerLoader(BlockData.class, (t, o, l) -> worldHandle.createBlockData((String) o))
.registerLoader(com.dfsek.terra.api.platform.world.Biome.class, (t, o, l) -> new FabricBiome(biomeFixer.translate((String) o))); .registerLoader(com.dfsek.terra.api.platform.world.Biome.class, (t, o, l) -> biomeFixer.translate((String) o));
} }
private Biome createBiome(BiomeBuilder biome) { private Biome createBiome(BiomeBuilder biome) {
BiomeTemplate template = biome.getTemplate(); BiomeTemplate template = biome.getTemplate();
Map<String, Integer> colors = template.getColors(); Map<String, Integer> colors = template.getColors();
Biome vanilla = ((FabricBiome) new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0)).getHandle(); Biome vanilla = (Biome) (new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0)).getHandle();
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder(); GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
generationSettings.surfaceBuilder(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(Blocks.GRASS_BLOCK.getDefaultState(), Blocks.DIRT.getDefaultState(), Blocks.GRAVEL.getDefaultState()))); // It needs a surfacebuilder, even though we dont use it. generationSettings.surfaceBuilder(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(Blocks.GRASS_BLOCK.getDefaultState(), Blocks.DIRT.getDefaultState(), Blocks.GRAVEL.getDefaultState()))); // It needs a surfacebuilder, even though we dont use it.

View File

@ -7,6 +7,8 @@ import org.spongepowered.asm.mixin.Mixin;
@Mixin(Biome.class) @Mixin(Biome.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.Biome.class, prefix = "terra$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.world.Biome.class, prefix = "terra$"))
public class BiomeMixin { public abstract class BiomeMixin {
public Object terra$getHandle() {
return this;
}
} }

View File

@ -1,17 +0,0 @@
package com.dfsek.terra.fabric.world;
import com.dfsek.terra.api.platform.world.Biome;
public class FabricBiome implements Biome {
private final net.minecraft.world.biome.Biome delegate;
public FabricBiome(net.minecraft.world.biome.Biome delegate) {
this.delegate = delegate;
}
@Override
public net.minecraft.world.biome.Biome getHandle() {
return delegate;
}
}