mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
fix bukkit pack reloading
This commit is contained in:
1 parent
60fec05e12
commit
bea8f97179
2 files changed
+36
-10
No files matched your search
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package com.dfsek.terra.bukkit.generator;
|
||||||
|
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
import org.bukkit.generator.LimitedRegion;
|
||||||
|
import org.bukkit.generator.WorldInfo;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.bukkit.world.BukkitProtoWorld;
|
||||||
|
|
||||||
|
|
||||||
|
public class BukkitBlockPopulator extends BlockPopulator {
|
||||||
|
private ConfigPack pack;
|
||||||
|
private final BlockState air;
|
||||||
|
|
||||||
|
public BukkitBlockPopulator(ConfigPack pack, BlockState air) {
|
||||||
|
this.pack = pack;
|
||||||
|
this.air = air;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPack(ConfigPack pack) {
|
||||||
|
this.pack = pack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ,
|
||||||
|
@NotNull LimitedRegion limitedRegion) {
|
||||||
|
pack.getStages().forEach(generationStage -> generationStage.populate(new BukkitProtoWorld(limitedRegion, air, pack.getBiomeProvider())));
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-10
@@ -45,12 +45,14 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
private final BlockState air;
|
private final BlockState air;
|
||||||
private ChunkGenerator delegate;
|
private ChunkGenerator delegate;
|
||||||
private ConfigPack pack;
|
private ConfigPack pack;
|
||||||
|
private final BukkitBlockPopulator blockPopulator;
|
||||||
|
|
||||||
|
|
||||||
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack, BlockState air) {
|
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack, BlockState air) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
this.air = air;
|
this.air = air;
|
||||||
|
this.blockPopulator = new BukkitBlockPopulator(pack, air);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelegate(ChunkGenerator delegate) {
|
public void setDelegate(ChunkGenerator delegate) {
|
||||||
@@ -70,16 +72,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||||
return pack.getStages()
|
return List.of(blockPopulator);
|
||||||
.stream()
|
|
||||||
.map(generationStage -> new BlockPopulator() {
|
|
||||||
@Override
|
|
||||||
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z,
|
|
||||||
@NotNull LimitedRegion limitedRegion) {
|
|
||||||
generationStage.populate(new BukkitProtoWorld(limitedRegion, air, pack.getBiomeProvider()));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user