mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 06:40:12 +00:00
drastically simplify generator API
This commit is contained in:
@@ -209,6 +209,6 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
||||
return new BukkitChunkGeneratorWrapper(generatorMap.computeIfAbsent(worldName, name -> {
|
||||
ConfigPack pack = platform.getConfigRegistry().get(id).orElseThrow(() -> new IllegalArgumentException("No such config pack \"" + id + "\""));
|
||||
return pack.getGeneratorProvider().newInstance(pack);
|
||||
}), platform.getRawConfigRegistry().get(id).orElseThrow(), platform);
|
||||
}), platform.getRawConfigRegistry().get(id).orElseThrow());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,6 @@
|
||||
|
||||
package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.bukkit.world.BukkitProtoWorld;
|
||||
|
||||
import com.dfsek.terra.bukkit.world.BukkitServerWorld;
|
||||
|
||||
import com.dfsek.terra.world.SamplerProviderImpl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
@@ -40,8 +30,13 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
|
||||
import com.dfsek.terra.bukkit.world.BukkitProtoWorld;
|
||||
import com.dfsek.terra.bukkit.world.BukkitServerWorld;
|
||||
|
||||
|
||||
public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGenerator implements GeneratorWrapper {
|
||||
@@ -51,12 +46,10 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
||||
private ServerWorld terraWorld;
|
||||
|
||||
private final ConfigPack pack;
|
||||
private final Platform platform;
|
||||
|
||||
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack, Platform platform) {
|
||||
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack) {
|
||||
this.delegate = delegate;
|
||||
this.pack = pack;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.generator.LimitedRegion;
|
||||
|
||||
@@ -78,6 +80,11 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getWorld().getGenerator()).getPack().getBiomeProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getWorld().getGenerator()).getPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int centerChunkX() {
|
||||
return delegate.getCenterChunkX();
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.UUID;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -44,18 +45,6 @@ public class BukkitServerWorld implements ServerWorld {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public UUID getUID() {
|
||||
return delegate.getUID();
|
||||
}
|
||||
|
||||
public boolean isChunkGenerated(int x, int z) {
|
||||
return delegate.isChunkGenerated(x, z);
|
||||
}
|
||||
|
||||
public File getWorldFolder() {
|
||||
return delegate.getWorldFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||
return new BukkitEntity(
|
||||
@@ -104,12 +93,12 @@ public class BukkitServerWorld implements ServerWorld {
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getGenerator()).getWorldConfig().getProvider();
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getGenerator()).getPack().getBiomeProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldConfig getConfig() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getGenerator()).getWorldConfig();
|
||||
public ConfigPack getPack() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getGenerator()).getPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||
|
||||
import net.minecraft.block.FluidBlock;
|
||||
@@ -59,7 +60,7 @@ import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
@Mixin(ChunkRegion.class)
|
||||
@Implements(@Interface(iface = ProtoWorld.class, prefix = "terraWorld$", remap = Interface.Remap.NONE))
|
||||
public abstract class ChunkRegionMixin {
|
||||
private WorldConfig config;
|
||||
private ConfigPack config;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@@ -80,7 +81,7 @@ public abstract class ChunkRegionMixin {
|
||||
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V")
|
||||
public void injectConstructor(net.minecraft.server.world.ServerWorld world, List<net.minecraft.world.chunk.Chunk> list, ChunkStatus chunkStatus, int i,
|
||||
CallbackInfo ci) {
|
||||
this.config = ((ServerWorld) world).getConfig();
|
||||
this.config = ((ServerWorld) world).getPack();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -149,7 +150,7 @@ public abstract class ChunkRegionMixin {
|
||||
return (ServerWorld) world;
|
||||
}
|
||||
|
||||
public WorldConfig terraWorld$getConfig() {
|
||||
public ConfigPack terraWorld$getPack() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListener;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
@@ -60,7 +62,7 @@ import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
@Mixin(net.minecraft.server.world.ServerWorld.class)
|
||||
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ServerWorldMixin {
|
||||
private WorldConfig config;
|
||||
private ConfigPack config;
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerChunkManager chunkManager;
|
||||
@@ -80,7 +82,7 @@ public abstract class ServerWorldMixin {
|
||||
net.minecraft.world.gen.chunk.ChunkGenerator chunkGenerator, boolean debugWorld, long seed,
|
||||
List<Spawner> spawners, boolean shouldTickTime, CallbackInfo ci) {
|
||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||
config = ((FabricChunkGeneratorWrapper) chunkGenerator).getPack().toWorldConfig((ServerWorld) this);
|
||||
config = ((FabricChunkGeneratorWrapper) chunkGenerator).getPack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +131,7 @@ public abstract class ServerWorldMixin {
|
||||
return ((TerraBiomeSource) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager().getChunkGenerator().getBiomeSource()).getProvider();
|
||||
}
|
||||
|
||||
public WorldConfig terra$getConfig() {
|
||||
public ConfigPack terra$getPack() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user