mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Remove hardcoding of world limits (#1199)
* Remove hardcoding of world limits - seems to be working fine without the datapack for world height changing - particular attention should be given to LocalBlockVectorSet and MathMan changes * update adapters * Override getMinY in various classes and ensure selections have a world attached to them * no message * Address comments - Fix for lighting mode 1 * A few more changes * Fix LocalBlockVectorSet * Fix range statement * Various fixes/comment-addressing - There's not much point in having a different file name now for history. We've broken it before... - Fix history read/write - Fix range on for loops in CharBlocks * undo bad CharBlocks change * Fix history y level * Fix biome history * Fix lighting * Fix /up * Make regen fail not because of these changes * Fixes for y < 0 * Fix isEmpty where only the uppermost chunksection is edited * Fix javadocs/FAWE annotations * Better explain why BiomeMath is removed * If history task throws an error, it should only be caught and printed if not completing now. * Min|max world heights for new patterns * Load biomes from NMS instead of bukkit (#1200) * Update adapters * Update adapters * Don't initialise BlockTypes when biomes aren't set up yet so all BiomeTypes.BIOME are no longer null thanks. * Address some comments. * rename layer -> sectionIndex to imply inclusivity * Javadoctored. Co-authored-by: NotMyFault <mc.cache@web.de> Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
This commit is contained in:
@ -266,8 +266,8 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
|
||||
});
|
||||
}
|
||||
|
||||
source = new SingleThreadQueueExtent();
|
||||
source.init(null, initSourceQueueCache(), null);
|
||||
source = new SingleThreadQueueExtent(originalBukkitWorld.getMinHeight(), originalBukkitWorld.getMaxHeight());
|
||||
source.init(target, initSourceQueueCache(), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import javax.annotation.Nonnull;
|
||||
public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
||||
|
||||
public static final MinecraftVersion NETHER = new MinecraftVersion(1, 16);
|
||||
public static final MinecraftVersion CAVES_17 = new MinecraftVersion(1, 17);
|
||||
|
||||
private final int major;
|
||||
private final int minor;
|
||||
|
@ -49,6 +49,7 @@ import com.sk89q.worldedit.util.lifecycle.Lifecycled;
|
||||
import com.sk89q.worldedit.util.lifecycle.SimpleLifecycled;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
@ -59,6 +60,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
@ -234,17 +236,18 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
// datapacks aren't loaded until just before the world is, and bukkit has no event for this
|
||||
// so the earliest we can do this is in WorldInit
|
||||
setupTags();
|
||||
setupBiomes(); // FAWE - load biomes later
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent(platform));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
private void initializeRegistries() {
|
||||
// Biome
|
||||
/* // FAWE start - move Biomes to their own method
|
||||
for (Biome biome : Biome.values()) {
|
||||
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
|
||||
BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
|
||||
}
|
||||
/*
|
||||
// FAWE end
|
||||
|
||||
// Block & Item
|
||||
for (Material material : Material.values()) {
|
||||
@ -304,6 +307,30 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
"The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update.");
|
||||
}
|
||||
}
|
||||
|
||||
// FAWE start
|
||||
private void setupBiomes() {
|
||||
if (this.adapter.value().isPresent()) {
|
||||
// We don't know which world is the one with the data packs
|
||||
// so we just loop over them. Doesn't hurt
|
||||
for (org.bukkit.World world : Bukkit.getWorlds()) {
|
||||
// cast is needed, thanks to raw types <3
|
||||
for (final NamespacedKey biome : ((BukkitImplAdapter<?>) adapter.value().get()).getRegisteredBiomes(world)) {
|
||||
if (BiomeType.REGISTRY.get(biome.toString()) == null) { // only register once
|
||||
BiomeType.REGISTRY.register(biome.toString(), new BiomeType(biome.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("Failed to load biomes via adapter (not present). Will load via bukkit");
|
||||
for (Biome biome : Biome.values()) {
|
||||
if (BiomeType.REGISTRY.get(biome.toString()) == null) { // only register once
|
||||
BiomeType.REGISTRY.register(biome.getKey().toString(), new BiomeType(biome.getKey().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// FAWE end
|
||||
|
||||
private void loadAdapter() {
|
||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||
|
@ -50,7 +50,9 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -60,9 +62,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* An interface for adapters of various Bukkit implementations.
|
||||
@ -304,6 +308,18 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
return Biome.BADLANDS.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterable of all biomes known to the server.
|
||||
*
|
||||
* @param world the world to load the registered biomes from.
|
||||
* @return all biomes known to the server.
|
||||
*/
|
||||
default Iterable<NamespacedKey> getRegisteredBiomes(World world) {
|
||||
return Arrays.stream(Biome.values())
|
||||
.map(Keyed::getKey)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
default RelighterFactory getRelighterFactory() {
|
||||
return new NMSRelighterFactory(); // TODO implement in adapters instead
|
||||
}
|
||||
|
Reference in New Issue
Block a user