mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-05 04:16:06 +00:00
Merge pull request #449 from EngineHub/feature/biome-registry
Refactor registries, and added a registry for biomes
This commit is contained in:
commit
df5ef52d6c
@ -12,7 +12,7 @@ repositories {
|
||||
dependencies {
|
||||
compile project(':worldedit-core')
|
||||
compile 'com.sk89q:dummypermscompat:1.8'
|
||||
compile 'org.bukkit:bukkit:1.13-R0.1-SNAPSHOT' // zzz
|
||||
compile 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT' // zzz
|
||||
compile 'org.bstats:bstats-bukkit:1.4'
|
||||
compile "io.papermc:paperlib:1.0.1"
|
||||
compileOnly "net.milkbowl.vault:VaultAPI:1.7"
|
||||
|
@ -33,6 +33,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
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.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -43,9 +45,9 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -304,6 +306,27 @@ public class BukkitAdapter {
|
||||
return GameModes.get(gameMode.name().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BiomeType from a Bukkit one.
|
||||
*
|
||||
* @param biome Bukkit Biome
|
||||
* @return WorldEdit BiomeType
|
||||
*/
|
||||
public static BiomeType adapt(Biome biome) {
|
||||
return BiomeTypes.get(biome.name().toLowerCase());
|
||||
}
|
||||
|
||||
public static Biome adapt(BiomeType biomeType) {
|
||||
if (!biomeType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
||||
}
|
||||
try {
|
||||
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit EntityType from a Bukkit one.
|
||||
*
|
||||
@ -318,7 +341,7 @@ public class BukkitAdapter {
|
||||
if (!entityType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
||||
}
|
||||
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase());
|
||||
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,16 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
@ -41,35 +36,9 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome createFromId(int id) {
|
||||
return new BaseBiome(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseBiome> getBiomes() {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
List<BaseBiome> biomes = new ArrayList<>();
|
||||
for (Biome biome : Biome.values()) {
|
||||
int biomeId = adapter.getBiomeId(biome);
|
||||
biomes.add(new BaseBiome(biomeId));
|
||||
}
|
||||
return biomes;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BiomeData getData(BaseBiome biome) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
final Biome bukkitBiome = adapter.getBiome(biome.getId());
|
||||
return bukkitBiome::name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
public BiomeData getData(BiomeType biome) {
|
||||
final Biome bukkitBiome = BukkitAdapter.adapt(biome);
|
||||
return bukkitBiome == null ? null : bukkitBiome::name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,16 +34,14 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
@ -465,25 +463,13 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
||||
return new BaseBiome(id);
|
||||
} else {
|
||||
return new BaseBiome(0);
|
||||
}
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
Biome bukkitBiome = adapter.getBiome(biome.getId());
|
||||
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), bukkitBiome);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,26 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.item.ItemCategory;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -51,6 +65,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -88,6 +103,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
server = new BukkitServerInterface(this, getServer());
|
||||
worldEdit.getPlatformManager().register(server);
|
||||
loadAdapter(); // Need an adapter to work with special blocks with NBT data
|
||||
setupRegistries();
|
||||
worldEdit.loadMappings();
|
||||
|
||||
loadConfig(); // Load configuration
|
||||
@ -109,6 +125,56 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||
new Metrics(this);
|
||||
}
|
||||
|
||||
public void setupRegistries() {
|
||||
// Biome
|
||||
for (Biome biome : Biome.values()) {
|
||||
BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(), new BiomeType("minecraft:" + biome.name().toLowerCase()));
|
||||
}
|
||||
// Block & Item
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isBlock()) {
|
||||
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
|
||||
// TODO Use something way less hacky than this.
|
||||
ParserContext context = new ParserContext();
|
||||
context.setPreferringWildcard(true);
|
||||
context.setTryLegacy(false);
|
||||
context.setRestricted(false);
|
||||
try {
|
||||
FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput(
|
||||
BukkitAdapter.adapt(blockState.getBlockType()).createBlockData().getAsString(), context
|
||||
).toImmutableState();
|
||||
BlockState defaultState = blockState.getBlockType().getAllStates().get(0);
|
||||
for (Map.Entry<Property<?>, Object> propertyObjectEntry : state.getStates().entrySet()) {
|
||||
defaultState = defaultState.with((Property) propertyObjectEntry.getKey(), propertyObjectEntry.getValue());
|
||||
}
|
||||
return defaultState;
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
return blockState;
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (material.isItem()) {
|
||||
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
|
||||
}
|
||||
}
|
||||
// Entity
|
||||
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
|
||||
EntityType.REGISTRY.register("minecraft:" + entityType.name().toLowerCase(), new EntityType("minecraft:" + entityType.name().toLowerCase()));
|
||||
}
|
||||
// Tags
|
||||
try {
|
||||
for (org.bukkit.Tag<Material> blockTag : Bukkit.getTags(Tag.REGISTRY_BLOCKS, Material.class)) {
|
||||
BlockCategory.REGISTRY.register(blockTag.getKey().toString(), new BlockCategory(blockTag.getKey().toString()));
|
||||
}
|
||||
for (org.bukkit.Tag<Material> itemTag : Bukkit.getTags(Tag.REGISTRY_ITEMS, Material.class)) {
|
||||
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
getLogger().warning("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update.");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
createDefaultConfiguration("config.yml"); // Create the default configuration file
|
||||
|
||||
|
@ -20,15 +20,14 @@
|
||||
package com.sk89q.worldedit.bukkit.adapter;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -41,26 +40,6 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public interface BukkitImplAdapter {
|
||||
|
||||
/**
|
||||
* Get the biome ID for the given biome.
|
||||
*
|
||||
* <p>Returns 0 if it is not known or it doesn't exist.</p>
|
||||
*
|
||||
* @param biome biome
|
||||
* @return the biome ID
|
||||
*/
|
||||
int getBiomeId(Biome biome);
|
||||
|
||||
/**
|
||||
* Get the biome ID for the given biome ID..
|
||||
*
|
||||
* <p>Returns {@link Biome#OCEAN} if it is not known or it doesn't exist.</p>
|
||||
*
|
||||
* @param id the biome ID
|
||||
* @return the biome
|
||||
*/
|
||||
Biome getBiome(int id);
|
||||
|
||||
/**
|
||||
* Get the block at the given location.
|
||||
*
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -52,8 +52,8 @@ import com.sk89q.worldedit.function.block.Counter;
|
||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockStateMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -108,7 +108,7 @@ import com.sk89q.worldedit.util.collection.DoubleArrayList;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.NullWorld;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -117,7 +117,6 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -129,6 +128,8 @@ import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
||||
* block re-ordering, and much more. Most operations in WorldEdit use this class.
|
||||
@ -562,12 +563,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return bypassNone.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return bypassNone.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@ -2202,7 +2203,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BiomeType biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||
final Vector2 zero2D = zero.toVector2();
|
||||
final Vector2 unit2D = unit.toVector2();
|
||||
|
||||
@ -2215,7 +2216,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
|
||||
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
||||
@Override
|
||||
protected BaseBiome getBiome(int x, int z, BaseBiome defaultBiomeType) {
|
||||
protected BiomeType getBiome(int x, int z, BiomeType defaultBiomeType) {
|
||||
final Vector2 current = Vector2.at(x, z);
|
||||
environment.setCurrentBlock(current.toVector3(0));
|
||||
final Vector2 scaled = current.subtract(zero2D).divide(unit2D);
|
||||
|
@ -1,174 +1,179 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents WorldEdit's configuration.
|
||||
*/
|
||||
public abstract class LocalConfiguration {
|
||||
|
||||
protected static final String[] defaultDisallowedBlocks = new String[] {
|
||||
// dangerous stuff (physics/drops items)
|
||||
BlockTypes.OAK_SAPLING.getId(),
|
||||
BlockTypes.JUNGLE_SAPLING.getId(),
|
||||
BlockTypes.DARK_OAK_SAPLING.getId(),
|
||||
BlockTypes.SPRUCE_SAPLING.getId(),
|
||||
BlockTypes.BIRCH_SAPLING.getId(),
|
||||
BlockTypes.ACACIA_SAPLING.getId(),
|
||||
BlockTypes.BLACK_BED.getId(),
|
||||
BlockTypes.BLUE_BED.getId(),
|
||||
BlockTypes.BROWN_BED.getId(),
|
||||
BlockTypes.CYAN_BED.getId(),
|
||||
BlockTypes.GRAY_BED.getId(),
|
||||
BlockTypes.GREEN_BED.getId(),
|
||||
BlockTypes.LIGHT_BLUE_BED.getId(),
|
||||
BlockTypes.LIGHT_GRAY_BED.getId(),
|
||||
BlockTypes.LIME_BED.getId(),
|
||||
BlockTypes.MAGENTA_BED.getId(),
|
||||
BlockTypes.ORANGE_BED.getId(),
|
||||
BlockTypes.PINK_BED.getId(),
|
||||
BlockTypes.PURPLE_BED.getId(),
|
||||
BlockTypes.RED_BED.getId(),
|
||||
BlockTypes.WHITE_BED.getId(),
|
||||
BlockTypes.YELLOW_BED.getId(),
|
||||
BlockTypes.POWERED_RAIL.getId(),
|
||||
BlockTypes.DETECTOR_RAIL.getId(),
|
||||
BlockTypes.GRASS.getId(),
|
||||
BlockTypes.DEAD_BUSH.getId(),
|
||||
BlockTypes.MOVING_PISTON.getId(),
|
||||
BlockTypes.PISTON_HEAD.getId(),
|
||||
BlockTypes.SUNFLOWER.getId(),
|
||||
BlockTypes.ROSE_BUSH.getId(),
|
||||
BlockTypes.DANDELION.getId(),
|
||||
BlockTypes.POPPY.getId(),
|
||||
BlockTypes.BROWN_MUSHROOM.getId(),
|
||||
BlockTypes.RED_MUSHROOM.getId(),
|
||||
BlockTypes.TNT.getId(),
|
||||
BlockTypes.TORCH.getId(),
|
||||
BlockTypes.FIRE.getId(),
|
||||
BlockTypes.REDSTONE_WIRE.getId(),
|
||||
BlockTypes.WHEAT.getId(),
|
||||
BlockTypes.POTATOES.getId(),
|
||||
BlockTypes.CARROTS.getId(),
|
||||
BlockTypes.MELON_STEM.getId(),
|
||||
BlockTypes.PUMPKIN_STEM.getId(),
|
||||
BlockTypes.BEETROOTS.getId(),
|
||||
BlockTypes.RAIL.getId(),
|
||||
BlockTypes.LEVER.getId(),
|
||||
BlockTypes.REDSTONE_TORCH.getId(),
|
||||
BlockTypes.REDSTONE_WALL_TORCH.getId(),
|
||||
BlockTypes.REPEATER.getId(),
|
||||
BlockTypes.COMPARATOR.getId(),
|
||||
BlockTypes.STONE_BUTTON.getId(),
|
||||
BlockTypes.BIRCH_BUTTON.getId(),
|
||||
BlockTypes.ACACIA_BUTTON.getId(),
|
||||
BlockTypes.DARK_OAK_BUTTON.getId(),
|
||||
BlockTypes.JUNGLE_BUTTON.getId(),
|
||||
BlockTypes.OAK_BUTTON.getId(),
|
||||
BlockTypes.SPRUCE_BUTTON.getId(),
|
||||
BlockTypes.CACTUS.getId(),
|
||||
BlockTypes.SUGAR_CANE.getId(),
|
||||
// ores and stuff
|
||||
BlockTypes.BEDROCK.getId(),
|
||||
};
|
||||
|
||||
public boolean profile = false;
|
||||
public boolean traceUnflushedSessions = false;
|
||||
public Set<String> disallowedBlocks = new HashSet<>();
|
||||
public int defaultChangeLimit = -1;
|
||||
public int maxChangeLimit = -1;
|
||||
public int defaultMaxPolygonalPoints = -1;
|
||||
public int maxPolygonalPoints = 20;
|
||||
public int defaultMaxPolyhedronPoints = -1;
|
||||
public int maxPolyhedronPoints = 20;
|
||||
public String shellSaveType = "";
|
||||
public SnapshotRepository snapshotRepo = null;
|
||||
public int maxRadius = -1;
|
||||
public int maxSuperPickaxeSize = 5;
|
||||
public int maxBrushRadius = 6;
|
||||
public boolean logCommands = false;
|
||||
public String logFile = "";
|
||||
public String logFormat = LogFormat.DEFAULT_FORMAT;
|
||||
public boolean registerHelp = true; // what is the point of this, it's not even used
|
||||
public String wandItem = ItemTypes.WOODEN_AXE.getId();
|
||||
public boolean superPickaxeDrop = true;
|
||||
public boolean superPickaxeManyDrop = true;
|
||||
public boolean noDoubleSlash = false;
|
||||
public boolean useInventory = false;
|
||||
public boolean useInventoryOverride = false;
|
||||
public boolean useInventoryCreativeOverride = false;
|
||||
public boolean navigationUseGlass = true;
|
||||
public String navigationWand = ItemTypes.COMPASS.getId();
|
||||
public int navigationWandMaxDistance = 50;
|
||||
public int scriptTimeout = 3000;
|
||||
public int calculationTimeout = 100;
|
||||
public Set<String> allowedDataCycleBlocks = new HashSet<>();
|
||||
public String saveDir = "schematics";
|
||||
public String scriptsDir = "craftscripts";
|
||||
public boolean showHelpInfo = true;
|
||||
public int butcherDefaultRadius = -1;
|
||||
public int butcherMaxRadius = -1;
|
||||
public boolean allowSymlinks = false;
|
||||
public boolean serverSideCUI = true;
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Get the working directory to work from.
|
||||
*
|
||||
* @return a working directory
|
||||
*/
|
||||
public File getWorkingDirectory() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
public String convertLegacyItem(String legacy) {
|
||||
String item = legacy;
|
||||
try {
|
||||
String[] splitter = item.split(":", 2);
|
||||
int id = 0;
|
||||
byte data = 0;
|
||||
if (splitter.length == 1) {
|
||||
id = Integer.parseInt(item);
|
||||
} else {
|
||||
id = Integer.parseInt(splitter[0]);
|
||||
data = Byte.parseByte(splitter[1]);
|
||||
}
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents WorldEdit's configuration.
|
||||
*/
|
||||
public abstract class LocalConfiguration {
|
||||
|
||||
public boolean profile = false;
|
||||
public boolean traceUnflushedSessions = false;
|
||||
public Set<String> disallowedBlocks = new HashSet<>();
|
||||
public int defaultChangeLimit = -1;
|
||||
public int maxChangeLimit = -1;
|
||||
public int defaultMaxPolygonalPoints = -1;
|
||||
public int maxPolygonalPoints = 20;
|
||||
public int defaultMaxPolyhedronPoints = -1;
|
||||
public int maxPolyhedronPoints = 20;
|
||||
public String shellSaveType = "";
|
||||
public SnapshotRepository snapshotRepo = null;
|
||||
public int maxRadius = -1;
|
||||
public int maxSuperPickaxeSize = 5;
|
||||
public int maxBrushRadius = 6;
|
||||
public boolean logCommands = false;
|
||||
public String logFile = "";
|
||||
public String logFormat = LogFormat.DEFAULT_FORMAT;
|
||||
public boolean registerHelp = true; // what is the point of this, it's not even used
|
||||
public String wandItem = "minecraft:wooden_axe";
|
||||
public boolean superPickaxeDrop = true;
|
||||
public boolean superPickaxeManyDrop = true;
|
||||
public boolean noDoubleSlash = false;
|
||||
public boolean useInventory = false;
|
||||
public boolean useInventoryOverride = false;
|
||||
public boolean useInventoryCreativeOverride = false;
|
||||
public boolean navigationUseGlass = true;
|
||||
public String navigationWand = "minecraft:compass";
|
||||
public int navigationWandMaxDistance = 50;
|
||||
public int scriptTimeout = 3000;
|
||||
public int calculationTimeout = 100;
|
||||
public Set<String> allowedDataCycleBlocks = new HashSet<>();
|
||||
public String saveDir = "schematics";
|
||||
public String scriptsDir = "craftscripts";
|
||||
public boolean showHelpInfo = true;
|
||||
public int butcherDefaultRadius = -1;
|
||||
public int butcherMaxRadius = -1;
|
||||
public boolean allowSymlinks = false;
|
||||
public boolean serverSideCUI = true;
|
||||
|
||||
protected String[] getDefaultDisallowedBlocks() {
|
||||
List<BlockType> blockTypes = Lists.newArrayList(
|
||||
BlockTypes.OAK_SAPLING,
|
||||
BlockTypes.JUNGLE_SAPLING,
|
||||
BlockTypes.DARK_OAK_SAPLING,
|
||||
BlockTypes.SPRUCE_SAPLING,
|
||||
BlockTypes.BIRCH_SAPLING,
|
||||
BlockTypes.ACACIA_SAPLING,
|
||||
BlockTypes.BLACK_BED,
|
||||
BlockTypes.BLUE_BED,
|
||||
BlockTypes.BROWN_BED,
|
||||
BlockTypes.CYAN_BED,
|
||||
BlockTypes.GRAY_BED,
|
||||
BlockTypes.GREEN_BED,
|
||||
BlockTypes.LIGHT_BLUE_BED,
|
||||
BlockTypes.LIGHT_GRAY_BED,
|
||||
BlockTypes.LIME_BED,
|
||||
BlockTypes.MAGENTA_BED,
|
||||
BlockTypes.ORANGE_BED,
|
||||
BlockTypes.PINK_BED,
|
||||
BlockTypes.PURPLE_BED,
|
||||
BlockTypes.RED_BED,
|
||||
BlockTypes.WHITE_BED,
|
||||
BlockTypes.YELLOW_BED,
|
||||
BlockTypes.POWERED_RAIL,
|
||||
BlockTypes.DETECTOR_RAIL,
|
||||
BlockTypes.GRASS,
|
||||
BlockTypes.DEAD_BUSH,
|
||||
BlockTypes.MOVING_PISTON,
|
||||
BlockTypes.PISTON_HEAD,
|
||||
BlockTypes.SUNFLOWER,
|
||||
BlockTypes.ROSE_BUSH,
|
||||
BlockTypes.DANDELION,
|
||||
BlockTypes.POPPY,
|
||||
BlockTypes.BROWN_MUSHROOM,
|
||||
BlockTypes.RED_MUSHROOM,
|
||||
BlockTypes.TNT,
|
||||
BlockTypes.TORCH,
|
||||
BlockTypes.FIRE,
|
||||
BlockTypes.REDSTONE_WIRE,
|
||||
BlockTypes.WHEAT,
|
||||
BlockTypes.POTATOES,
|
||||
BlockTypes.CARROTS,
|
||||
BlockTypes.MELON_STEM,
|
||||
BlockTypes.PUMPKIN_STEM,
|
||||
BlockTypes.BEETROOTS,
|
||||
BlockTypes.RAIL,
|
||||
BlockTypes.LEVER,
|
||||
BlockTypes.REDSTONE_TORCH,
|
||||
BlockTypes.REDSTONE_WALL_TORCH,
|
||||
BlockTypes.REPEATER,
|
||||
BlockTypes.COMPARATOR,
|
||||
BlockTypes.STONE_BUTTON,
|
||||
BlockTypes.BIRCH_BUTTON,
|
||||
BlockTypes.ACACIA_BUTTON,
|
||||
BlockTypes.DARK_OAK_BUTTON,
|
||||
BlockTypes.JUNGLE_BUTTON,
|
||||
BlockTypes.OAK_BUTTON,
|
||||
BlockTypes.SPRUCE_BUTTON,
|
||||
BlockTypes.CACTUS,
|
||||
BlockTypes.SUGAR_CANE,
|
||||
// ores and stuff
|
||||
BlockTypes.BEDROCK
|
||||
);
|
||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Get the working directory to work from.
|
||||
*
|
||||
* @return a working directory
|
||||
*/
|
||||
public File getWorkingDirectory() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
public String convertLegacyItem(String legacy) {
|
||||
String item = legacy;
|
||||
try {
|
||||
String[] splitter = item.split(":", 2);
|
||||
int id = 0;
|
||||
byte data = 0;
|
||||
if (splitter.length == 1) {
|
||||
id = Integer.parseInt(item);
|
||||
} else {
|
||||
id = Integer.parseInt(splitter[0]);
|
||||
data = Byte.parseByte(splitter[1]);
|
||||
}
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,12 +48,12 @@ import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -94,10 +94,10 @@ public class BiomeCommands {
|
||||
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
List<BaseBiome> biomes = biomeRegistry.getBiomes();
|
||||
Collection<BiomeType> biomes = BiomeType.REGISTRY.values();
|
||||
int totalPages = biomes.size() / 19 + 1;
|
||||
player.print("Available Biomes (page " + page + "/" + totalPages + ") :");
|
||||
for (BaseBiome biome : biomes) {
|
||||
for (BiomeType biome : biomes) {
|
||||
if (offset > 0) {
|
||||
offset--;
|
||||
} else {
|
||||
@ -129,7 +129,7 @@ public class BiomeCommands {
|
||||
public void biomeInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
Set<BaseBiome> biomes = new HashSet<>();
|
||||
Set<BiomeType> biomes = new HashSet<>();
|
||||
String qualifier;
|
||||
|
||||
if (args.hasFlag('t')) {
|
||||
@ -139,12 +139,12 @@ public class BiomeCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at line of sight point";
|
||||
} else if (args.hasFlag('p')) {
|
||||
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at your position";
|
||||
@ -166,7 +166,7 @@ public class BiomeCommands {
|
||||
}
|
||||
|
||||
player.print(biomes.size() != 1 ? "Biomes " + qualifier + ":" : "Biome " + qualifier + ":");
|
||||
for (BaseBiome biome : biomes) {
|
||||
for (BiomeType biome : biomes) {
|
||||
BiomeData data = biomeRegistry.getData(biome);
|
||||
if (data != null) {
|
||||
player.print(" " + data.getName());
|
||||
@ -188,7 +188,7 @@ public class BiomeCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.biome.set")
|
||||
public void setBiome(Player player, LocalSession session, EditSession editSession, BaseBiome target, @Switch('p') boolean atPosition) throws WorldEditException {
|
||||
public void setBiome(Player player, LocalSession session, EditSession editSession, BiomeType target, @Switch('p') boolean atPosition) throws WorldEditException {
|
||||
World world = player.getWorld();
|
||||
Region region;
|
||||
Mask mask = editSession.getMask();
|
||||
|
@ -43,7 +43,7 @@ import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
* Commands for the generation of shapes and other objects.
|
||||
@ -337,7 +337,7 @@ public class GenerationCommands {
|
||||
@Logging(ALL)
|
||||
public void generateBiome(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
BaseBiome target,
|
||||
BiomeType target,
|
||||
@Text String expression,
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
|
@ -28,12 +28,12 @@ import com.sk89q.worldedit.function.mask.BiomeMask2D;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BiomeMaskParser extends InputParser<Mask> {
|
||||
@ -48,11 +48,11 @@ public class BiomeMaskParser extends InputParser<Mask> {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<BaseBiome> biomes = new HashSet<>();
|
||||
Set<BiomeType> biomes = new HashSet<>();
|
||||
BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
||||
Collection<BiomeType> knownBiomes = BiomeType.REGISTRY.values();
|
||||
for (String biomeName : Splitter.on(",").split(input.substring(1))) {
|
||||
BaseBiome biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry);
|
||||
BiomeType biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry);
|
||||
if (biome == null) {
|
||||
throw new InputParseException("Unknown biome '" + biomeName + '\'');
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -97,12 +97,12 @@ public abstract class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -69,9 +69,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
BaseBiome previous = getBiome(position);
|
||||
changeSet.add(new BiomeChange(position, previous, new BaseBiome(biome)));
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
BiomeType previous = getBiome(position);
|
||||
changeSet.add(new BiomeChange(position, previous, biome));
|
||||
return super.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ package com.sk89q.worldedit.extent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -64,6 +64,6 @@ public interface InputExtent {
|
||||
* @param position the (x, z) location to check the biome at
|
||||
* @return the biome at the location
|
||||
*/
|
||||
BaseBiome getBiome(BlockVector2 position);
|
||||
BiomeType getBiome(BlockVector2 position);
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -80,10 +81,9 @@ public class NullExtent implements Extent {
|
||||
return getBlock(position).toBaseBlock();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return BiomeTypes.THE_VOID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -92,7 +92,7 @@ public class NullExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -59,7 +59,7 @@ public interface OutputExtent {
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
*/
|
||||
boolean setBiome(BlockVector2 position, BaseBiome biome);
|
||||
boolean setBiome(BlockVector2 position, BiomeType biome);
|
||||
|
||||
/**
|
||||
* Return an {@link Operation} that should be called to tie up loose ends
|
||||
|
@ -29,7 +29,8 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -160,12 +161,12 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return new BaseBiome(0);
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return BiomeTypes.OCEAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
* Replaces the biome at the locations that this function is applied to.
|
||||
@ -33,7 +33,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
public class BiomeReplace implements FlatRegionFunction {
|
||||
|
||||
private final Extent extent;
|
||||
private BaseBiome biome;
|
||||
private BiomeType biome;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -41,7 +41,7 @@ public class BiomeReplace implements FlatRegionFunction {
|
||||
* @param extent an extent
|
||||
* @param biome a biome
|
||||
*/
|
||||
public BiomeReplace(Extent extent, BaseBiome biome) {
|
||||
public BiomeReplace(Extent extent, BiomeType biome) {
|
||||
checkNotNull(extent);
|
||||
checkNotNull(biome);
|
||||
this.extent = extent;
|
||||
|
@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -36,7 +36,7 @@ import java.util.Set;
|
||||
public class BiomeMask2D extends AbstractMask2D {
|
||||
|
||||
private final Extent extent;
|
||||
private final Set<BaseBiome> biomes = new HashSet<>();
|
||||
private final Set<BiomeType> biomes = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Create a new biome mask.
|
||||
@ -44,7 +44,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
* @param extent the extent
|
||||
* @param biomes a list of biomes to match
|
||||
*/
|
||||
public BiomeMask2D(Extent extent, Collection<BaseBiome> biomes) {
|
||||
public BiomeMask2D(Extent extent, Collection<BiomeType> biomes) {
|
||||
checkNotNull(extent);
|
||||
checkNotNull(biomes);
|
||||
this.extent = extent;
|
||||
@ -57,7 +57,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
* @param extent the extent
|
||||
* @param biome an array of biomes to match
|
||||
*/
|
||||
public BiomeMask2D(Extent extent, BaseBiome... biome) {
|
||||
public BiomeMask2D(Extent extent, BiomeType... biome) {
|
||||
this(extent, Arrays.asList(checkNotNull(biome)));
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
*
|
||||
* @param biomes a list of biomes
|
||||
*/
|
||||
public void add(Collection<BaseBiome> biomes) {
|
||||
public void add(Collection<BiomeType> biomes) {
|
||||
checkNotNull(biomes);
|
||||
this.biomes.addAll(biomes);
|
||||
}
|
||||
@ -76,7 +76,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
*
|
||||
* @param biome an array of biomes
|
||||
*/
|
||||
public void add(BaseBiome... biome) {
|
||||
public void add(BiomeType... biome) {
|
||||
add(Arrays.asList(checkNotNull(biome)));
|
||||
}
|
||||
|
||||
@ -85,13 +85,13 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
*
|
||||
* @return a list of biomes
|
||||
*/
|
||||
public Collection<BaseBiome> getBiomes() {
|
||||
public Collection<BiomeType> getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector2 vector) {
|
||||
BaseBiome biome = extent.getBiome(vector);
|
||||
BiomeType biome = extent.getBiome(vector);
|
||||
return biomes.contains(biome);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
* Represents a biome change that may be undone or replayed.
|
||||
@ -37,8 +37,8 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
public class BiomeChange implements Change {
|
||||
|
||||
private final BlockVector2 position;
|
||||
private final BaseBiome previous;
|
||||
private final BaseBiome current;
|
||||
private final BiomeType previous;
|
||||
private final BiomeType current;
|
||||
|
||||
/**
|
||||
* Create a new biome change.
|
||||
@ -47,7 +47,7 @@ public class BiomeChange implements Change {
|
||||
* @param previous the previous biome
|
||||
* @param current the current biome
|
||||
*/
|
||||
public BiomeChange(BlockVector2 position, BaseBiome previous, BaseBiome current) {
|
||||
public BiomeChange(BlockVector2 position, BiomeType previous, BiomeType current) {
|
||||
checkNotNull(position);
|
||||
checkNotNull(previous);
|
||||
checkNotNull(current);
|
||||
@ -70,7 +70,7 @@ public class BiomeChange implements Change {
|
||||
*
|
||||
* @return the previous biome
|
||||
*/
|
||||
public BaseBiome getPrevious() {
|
||||
public BiomeType getPrevious() {
|
||||
return previous;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public class BiomeChange implements Change {
|
||||
*
|
||||
* @return the current biome
|
||||
*/
|
||||
public BaseBiome getCurrent() {
|
||||
public BiomeType getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ import com.sk89q.worldedit.util.command.parametric.BindingHelper;
|
||||
import com.sk89q.worldedit.util.command.parametric.BindingMatch;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -54,7 +54,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Binds standard WorldEdit classes such as {@link Player} and {@link LocalSession}.
|
||||
@ -298,23 +298,23 @@ public class WorldEditBinding extends BindingHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link BaseBiome} from a {@link ArgumentStack}.
|
||||
* Gets an {@link BiomeType} from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return a pattern
|
||||
* @throws ParameterException on error
|
||||
* @throws WorldEditException on error
|
||||
*/
|
||||
@BindingMatch(type = BaseBiome.class,
|
||||
@BindingMatch(type = BiomeType.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public BaseBiome getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException {
|
||||
public BiomeType getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException {
|
||||
String input = context.next();
|
||||
if (input != null) {
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
||||
BaseBiome biome = Biomes.findBiomeByName(knownBiomes, input, biomeRegistry);
|
||||
Collection<BiomeType> knownBiomes = BiomeType.REGISTRY.values();
|
||||
BiomeType biome = Biomes.findBiomeByName(knownBiomes, input, biomeRegistry);
|
||||
if (biome != null) {
|
||||
return biome;
|
||||
} else {
|
||||
|
@ -24,7 +24,8 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
/**
|
||||
* Generates solid and hollow shapes according to materials returned by the
|
||||
@ -54,10 +55,10 @@ public abstract class ArbitraryBiomeShape {
|
||||
cacheOffsetX = min.getBlockX() - 1;
|
||||
cacheOffsetZ = min.getBlockZ() - 1;
|
||||
|
||||
cacheSizeX = (int) (max.getX() - cacheOffsetX + 2);
|
||||
cacheSizeZ = (int) (max.getZ() - cacheOffsetZ + 2);
|
||||
cacheSizeX = max.getX() - cacheOffsetX + 2;
|
||||
cacheSizeZ = max.getZ() - cacheOffsetZ + 2;
|
||||
|
||||
cache = new BaseBiome[cacheSizeX * cacheSizeZ];
|
||||
cache = new BiomeType[cacheSizeX * cacheSizeZ];
|
||||
}
|
||||
|
||||
protected Iterable<BlockVector2> getExtent() {
|
||||
@ -71,7 +72,7 @@ public abstract class ArbitraryBiomeShape {
|
||||
* OUTSIDE = outside
|
||||
* else = inside
|
||||
*/
|
||||
private final BaseBiome[] cache;
|
||||
private final BiomeType[] cache;
|
||||
|
||||
/**
|
||||
* Override this function to specify the shape to generate.
|
||||
@ -81,17 +82,17 @@ public abstract class ArbitraryBiomeShape {
|
||||
* @param defaultBaseBiome The default biome for the current column.
|
||||
* @return material to place or null to not place anything.
|
||||
*/
|
||||
protected abstract BaseBiome getBiome(int x, int z, BaseBiome defaultBaseBiome);
|
||||
protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBaseBiome);
|
||||
|
||||
private BaseBiome getBiomeCached(int x, int z, BaseBiome baseBiome) {
|
||||
private BiomeType getBiomeCached(int x, int z, BiomeType baseBiome) {
|
||||
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
||||
|
||||
final BaseBiome cacheEntry = cache[index];
|
||||
final BiomeType cacheEntry = cache[index];
|
||||
if (cacheEntry == null) {// unknown, fetch material
|
||||
final BaseBiome material = getBiome(x, z, baseBiome);
|
||||
final BiomeType material = getBiome(x, z, baseBiome);
|
||||
if (material == null) {
|
||||
// outside
|
||||
cache[index] = OUTSIDE;
|
||||
cache[index] = BiomeTypes.THE_VOID;
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -99,7 +100,7 @@ public abstract class ArbitraryBiomeShape {
|
||||
return material;
|
||||
}
|
||||
|
||||
if (cacheEntry == OUTSIDE) {
|
||||
if (cacheEntry == BiomeTypes.THE_VOID) {
|
||||
// outside
|
||||
return null;
|
||||
}
|
||||
@ -107,16 +108,16 @@ public abstract class ArbitraryBiomeShape {
|
||||
return cacheEntry;
|
||||
}
|
||||
|
||||
private boolean isInsideCached(int x, int z, BaseBiome baseBiome) {
|
||||
private boolean isInsideCached(int x, int z, BiomeType baseBiome) {
|
||||
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
||||
|
||||
final BaseBiome cacheEntry = cache[index];
|
||||
final BiomeType cacheEntry = cache[index];
|
||||
if (cacheEntry == null) {
|
||||
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape
|
||||
return getBiomeCached(x, z, baseBiome) != null;
|
||||
}
|
||||
|
||||
return cacheEntry != OUTSIDE;
|
||||
return cacheEntry != BiomeTypes.THE_VOID;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +128,7 @@ public abstract class ArbitraryBiomeShape {
|
||||
* @param hollow Specifies whether to generate a hollow shape.
|
||||
* @return number of affected blocks.
|
||||
*/
|
||||
public int generate(EditSession editSession, BaseBiome baseBiome, boolean hollow) {
|
||||
public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) {
|
||||
int affected = 0;
|
||||
|
||||
for (BlockVector2 position : getExtent()) {
|
||||
@ -135,8 +136,8 @@ public abstract class ArbitraryBiomeShape {
|
||||
int z = position.getBlockZ();
|
||||
|
||||
if (!hollow) {
|
||||
final BaseBiome material = getBiome(x, z, baseBiome);
|
||||
if (material != null && material != OUTSIDE) {
|
||||
final BiomeType material = getBiome(x, z, baseBiome);
|
||||
if (material != null && material != BiomeTypes.THE_VOID) {
|
||||
editSession.getWorld().setBiome(position, material);
|
||||
++affected;
|
||||
}
|
||||
@ -144,7 +145,7 @@ public abstract class ArbitraryBiomeShape {
|
||||
continue;
|
||||
}
|
||||
|
||||
final BaseBiome material = getBiomeCached(x, z, baseBiome);
|
||||
final BiomeType material = getBiomeCached(x, z, baseBiome);
|
||||
if (material == null) {
|
||||
continue;
|
||||
}
|
||||
@ -180,16 +181,4 @@ public abstract class ArbitraryBiomeShape {
|
||||
return affected;
|
||||
}
|
||||
|
||||
private static final BaseBiome OUTSIDE = new BaseBiome(0) {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
||||
|
||||
profile = getBool("profile", profile);
|
||||
traceUnflushedSessions = getBool("trace-unflushed-sessions", traceUnflushedSessions);
|
||||
disallowedBlocks = getStringSet("disallowed-blocks", defaultDisallowedBlocks);
|
||||
disallowedBlocks = getStringSet("disallowed-blocks", getDefaultDisallowedBlocks());
|
||||
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
|
||||
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
|
||||
defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints);
|
||||
|
@ -79,7 +79,7 @@ public class YAMLConfiguration extends LocalConfiguration {
|
||||
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
|
||||
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
|
||||
|
||||
disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(defaultDisallowedBlocks)));
|
||||
disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks())));
|
||||
allowedDataCycleBlocks = new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null));
|
||||
|
||||
registerHelp = config.getBoolean("register-help", true);
|
||||
|
@ -31,12 +31,14 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -80,12 +82,12 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return BiomeTypes.THE_VOID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -109,7 +111,7 @@ public class NullWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public WeatherType getWeather() {
|
||||
return null;
|
||||
return WeatherTypes.CLEAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Returns the name of a biome using a given {@code BiomeRegistry}.
|
||||
*/
|
||||
class BiomeName implements Function<BaseBiome, String> {
|
||||
class BiomeName implements Function<BiomeType, String> {
|
||||
|
||||
private final BiomeRegistry registry;
|
||||
|
||||
@ -45,7 +45,7 @@ class BiomeName implements Function<BaseBiome, String> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String apply(BaseBiome input) {
|
||||
public String apply(BiomeType input) {
|
||||
BiomeData data = registry.getData(input);
|
||||
if (data != null) {
|
||||
return data.getName();
|
||||
|
@ -19,64 +19,42 @@
|
||||
|
||||
package com.sk89q.worldedit.world.biome;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
/**
|
||||
* Basic storage object to represent a given biome.
|
||||
* All the types of biomes in the game.
|
||||
*/
|
||||
public class BaseBiome {
|
||||
public class BiomeType {
|
||||
|
||||
private int id;
|
||||
public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type");
|
||||
|
||||
/**
|
||||
* Create a new biome with the given biome ID.
|
||||
*
|
||||
* @param id the biome ID
|
||||
*/
|
||||
public BaseBiome(int id) {
|
||||
private String id;
|
||||
|
||||
public BiomeType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a clone of the given biome.
|
||||
* Gets the ID of this biome.
|
||||
*
|
||||
* @param biome the biome to clone
|
||||
* @return The id
|
||||
*/
|
||||
public BaseBiome(BaseBiome biome) {
|
||||
checkNotNull(biome);
|
||||
this.id = biome.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the biome ID.
|
||||
*
|
||||
* @return the biome ID
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome id.
|
||||
*
|
||||
* @param id the biome ID
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BaseBiome baseBiome = (BaseBiome) o;
|
||||
|
||||
return id == baseBiome.id;
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof BiomeType && this.id.equals(((BiomeType) obj).id);
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.world.biome;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Stores a list of common Biome String IDs.
|
||||
*/
|
||||
public class BiomeTypes {
|
||||
|
||||
@Nullable public static final BiomeType BADLANDS = get("minecraft:badlands");
|
||||
@Nullable public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau");
|
||||
@Nullable public static final BiomeType BEACH = get("minecraft:beach");
|
||||
@Nullable public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest");
|
||||
@Nullable public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills");
|
||||
@Nullable public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean");
|
||||
@Nullable public static final BiomeType DARK_FOREST = get("minecraft:dark_forest");
|
||||
@Nullable public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills");
|
||||
@Nullable public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean");
|
||||
@Nullable public static final BiomeType DEEP_FROZEN_OCEAN = get("minecraft:deep_frozen_ocean");
|
||||
@Nullable public static final BiomeType DEEP_LUKEWARM_OCEAN = get("minecraft:deep_lukewarm_ocean");
|
||||
@Nullable public static final BiomeType DEEP_OCEAN = get("minecraft:deep_ocean");
|
||||
@Nullable public static final BiomeType DEEP_WARM_OCEAN = get("minecraft:deep_warm_ocean");
|
||||
@Nullable public static final BiomeType DESERT = get("minecraft:desert");
|
||||
@Nullable public static final BiomeType DESERT_HILLS = get("minecraft:desert_hills");
|
||||
@Nullable public static final BiomeType DESERT_LAKES = get("minecraft:desert_lakes");
|
||||
@Nullable public static final BiomeType END_BARRENS = get("minecraft:end_barrens");
|
||||
@Nullable public static final BiomeType END_HIGHLANDS = get("minecraft:end_highlands");
|
||||
@Nullable public static final BiomeType END_MIDLANDS = get("minecraft:end_midlands");
|
||||
@Nullable public static final BiomeType ERODED_BADLANDS = get("minecraft:eroded_badlands");
|
||||
@Nullable public static final BiomeType FLOWER_FOREST = get("minecraft:flower_forest");
|
||||
@Nullable public static final BiomeType FOREST = get("minecraft:forest");
|
||||
@Nullable public static final BiomeType FROZEN_OCEAN = get("minecraft:frozen_ocean");
|
||||
@Nullable public static final BiomeType FROZEN_RIVER = get("minecraft:frozen_river");
|
||||
@Nullable public static final BiomeType GIANT_SPRUCE_TAIGA = get("minecraft:giant_spruce_taiga");
|
||||
@Nullable public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = get("minecraft:giant_spruce_taiga_hills");
|
||||
@Nullable public static final BiomeType GIANT_TREE_TAIGA = get("minecraft:giant_tree_taiga");
|
||||
@Nullable public static final BiomeType GIANT_TREE_TAIGA_HILLS = get("minecraft:giant_tree_taiga_hills");
|
||||
@Nullable public static final BiomeType GRAVELLY_MOUNTAINS = get("minecraft:gravelly_mountains");
|
||||
@Nullable public static final BiomeType ICE_SPIKES = get("minecraft:ice_spikes");
|
||||
@Nullable public static final BiomeType JUNGLE = get("minecraft:jungle");
|
||||
@Nullable public static final BiomeType JUNGLE_EDGE = get("minecraft:jungle_edge");
|
||||
@Nullable public static final BiomeType JUNGLE_HILLS = get("minecraft:jungle_hills");
|
||||
@Nullable public static final BiomeType LUKEWARM_OCEAN = get("minecraft:lukewarm_ocean");
|
||||
@Nullable public static final BiomeType MODIFIED_BADLANDS_PLATEAU = get("minecraft:modified_badlands_plateau");
|
||||
@Nullable public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = get("minecraft:modified_gravelly_mountains");
|
||||
@Nullable public static final BiomeType MODIFIED_JUNGLE = get("minecraft:modified_jungle");
|
||||
@Nullable public static final BiomeType MODIFIED_JUNGLE_EDGE = get("minecraft:modified_jungle_edge");
|
||||
@Nullable public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = get("minecraft:modified_wooded_badlands_plateau");
|
||||
@Nullable public static final BiomeType MOUNTAIN_EDGE = get("minecraft:mountain_edge");
|
||||
@Nullable public static final BiomeType MOUNTAINS = get("minecraft:mountains");
|
||||
@Nullable public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore");
|
||||
@Nullable public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields");
|
||||
@Nullable public static final BiomeType NETHER = get("minecraft:nether");
|
||||
@Nullable public static final BiomeType OCEAN = get("minecraft:ocean");
|
||||
@Nullable public static final BiomeType PLAINS = get("minecraft:plains");
|
||||
@Nullable public static final BiomeType RIVER = get("minecraft:river");
|
||||
@Nullable public static final BiomeType SAVANNA = get("minecraft:savanna");
|
||||
@Nullable public static final BiomeType SAVANNA_PLATEAU = get("minecraft:savanna_plateau");
|
||||
@Nullable public static final BiomeType SHATTERED_SAVANNA = get("minecraft:shattered_savanna");
|
||||
@Nullable public static final BiomeType SHATTERED_SAVANNA_PLATEAU = get("minecraft:shattered_savanna_plateau");
|
||||
@Nullable public static final BiomeType SMALL_END_ISLANDS = get("minecraft:small_end_islands");
|
||||
@Nullable public static final BiomeType SNOWY_BEACH = get("minecraft:snowy_beach");
|
||||
@Nullable public static final BiomeType SNOWY_MOUNTAINS = get("minecraft:snowy_mountains");
|
||||
@Nullable public static final BiomeType SNOWY_TAIGA = get("minecraft:snowy_taiga");
|
||||
@Nullable public static final BiomeType SNOWY_TAIGA_HILLS = get("minecraft:snowy_taiga_hills");
|
||||
@Nullable public static final BiomeType SNOWY_TAIGA_MOUNTAINS = get("minecraft:snowy_taiga_mountains");
|
||||
@Nullable public static final BiomeType SNOWY_TUNDRA = get("minecraft:snowy_tundra");
|
||||
@Nullable public static final BiomeType STONE_SHORE = get("minecraft:stone_shore");
|
||||
@Nullable public static final BiomeType SUNFLOWER_PLAINS = get("minecraft:sunflower_plains");
|
||||
@Nullable public static final BiomeType SWAMP = get("minecraft:swamp");
|
||||
@Nullable public static final BiomeType SWAMP_HILLS = get("minecraft:swamp_hills");
|
||||
@Nullable public static final BiomeType TAIGA = get("minecraft:taiga");
|
||||
@Nullable public static final BiomeType TAIGA_HILLS = get("minecraft:taiga_hills");
|
||||
@Nullable public static final BiomeType TAIGA_MOUNTAINS = get("minecraft:taiga_mountains");
|
||||
@Nullable public static final BiomeType TALL_BIRCH_FOREST = get("minecraft:tall_birch_forest");
|
||||
@Nullable public static final BiomeType TALL_BIRCH_HILLS = get("minecraft:tall_birch_hills");
|
||||
@Nullable public static final BiomeType THE_END = get("minecraft:the_end");
|
||||
@Nullable public static final BiomeType THE_VOID = get("minecraft:the_void");
|
||||
@Nullable public static final BiomeType WARM_OCEAN = get("minecraft:warm_ocean");
|
||||
@Nullable public static final BiomeType WOODED_BADLANDS_PLATEAU = get("minecraft:wooded_badlands_plateau");
|
||||
@Nullable public static final BiomeType WOODED_HILLS = get("minecraft:wooded_hills");
|
||||
@Nullable public static final BiomeType WOODED_MOUNTAINS = get("minecraft:wooded_mountains");
|
||||
|
||||
private BiomeTypes() {
|
||||
}
|
||||
|
||||
private static BiomeType register(final String id) {
|
||||
return register(new BiomeType(id));
|
||||
}
|
||||
|
||||
public static BiomeType register(final BiomeType biome) {
|
||||
return BiomeType.REGISTRY.register(biome.getId(), biome);
|
||||
}
|
||||
|
||||
public static @Nullable BiomeType get(final String id) {
|
||||
return BiomeType.REGISTRY.get(id);
|
||||
}
|
||||
}
|
@ -50,17 +50,17 @@ public final class Biomes {
|
||||
* @return a biome or null
|
||||
*/
|
||||
@Nullable
|
||||
public static BaseBiome findBiomeByName(Collection<BaseBiome> biomes, String name, BiomeRegistry registry) {
|
||||
public static BiomeType findBiomeByName(Collection<BiomeType> biomes, String name, BiomeRegistry registry) {
|
||||
checkNotNull(biomes);
|
||||
checkNotNull(name);
|
||||
checkNotNull(registry);
|
||||
|
||||
Function<String, ? extends Number> compare = new LevenshteinDistance(name, false, LevenshteinDistance.STANDARD_CHARS);
|
||||
WeightedChoice<BaseBiome> chooser = new WeightedChoice<>(Functions.compose(compare::apply, new BiomeName(registry)), 0);
|
||||
for (BaseBiome biome : biomes) {
|
||||
WeightedChoice<BiomeType> chooser = new WeightedChoice<>(Functions.compose(compare::apply, new BiomeName(registry)), 0);
|
||||
for (BiomeType biome : biomes) {
|
||||
chooser.consider(biome);
|
||||
}
|
||||
Optional<Choice<BaseBiome>> choice = chooser.getChoice();
|
||||
Optional<Choice<BiomeType>> choice = chooser.getChoice();
|
||||
if (choice.isPresent() && choice.get().getScore() <= 1) {
|
||||
return choice.get().getValue();
|
||||
} else {
|
||||
|
@ -26,50 +26,42 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public final class BlockCategories {
|
||||
|
||||
public static final BlockCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
||||
public static final BlockCategory ANVIL = register("minecraft:anvil");
|
||||
public static final BlockCategory BANNERS = register("minecraft:banners");
|
||||
public static final BlockCategory BIRCH_LOGS = register("minecraft:birch_logs");
|
||||
public static final BlockCategory BUTTONS = register("minecraft:buttons");
|
||||
public static final BlockCategory CARPETS = register("minecraft:carpets");
|
||||
public static final BlockCategory CORALS = register("minecraft:corals");
|
||||
public static final BlockCategory CORAL_BLOCKS = register("minecraft:coral_blocks");
|
||||
public static final BlockCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs");
|
||||
public static final BlockCategory DOORS = register("minecraft:doors");
|
||||
public static final BlockCategory ENDERMAN_HOLDABLE = register("minecraft:enderman_holdable");
|
||||
public static final BlockCategory FLOWER_POTS = register("minecraft:flower_pots");
|
||||
public static final BlockCategory ICE = register("minecraft:ice");
|
||||
public static final BlockCategory JUNGLE_LOGS = register("minecraft:jungle_logs");
|
||||
public static final BlockCategory LEAVES = register("minecraft:leaves");
|
||||
public static final BlockCategory LOGS = register("minecraft:logs");
|
||||
public static final BlockCategory OAK_LOGS = register("minecraft:oak_logs");
|
||||
public static final BlockCategory PLANKS = register("minecraft:planks");
|
||||
public static final BlockCategory RAILS = register("minecraft:rails");
|
||||
public static final BlockCategory SAND = register("minecraft:sand");
|
||||
public static final BlockCategory SAPLINGS = register("minecraft:saplings");
|
||||
public static final BlockCategory SLABS = register("minecraft:slabs");
|
||||
public static final BlockCategory SPRUCE_LOGS = register("minecraft:spruce_logs");
|
||||
public static final BlockCategory STAIRS = register("minecraft:stairs");
|
||||
public static final BlockCategory STONE_BRICKS = register("minecraft:stone_bricks");
|
||||
public static final BlockCategory VALID_SPAWN = register("minecraft:valid_spawn");
|
||||
public static final BlockCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons");
|
||||
public static final BlockCategory WOODEN_DOORS = register("minecraft:wooden_doors");
|
||||
public static final BlockCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates");
|
||||
public static final BlockCategory WOODEN_SLABS = register("minecraft:wooden_slabs");
|
||||
public static final BlockCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
||||
public static final BlockCategory WOOL = register("minecraft:wool");
|
||||
public static final BlockCategory ACACIA_LOGS = get("minecraft:acacia_logs");
|
||||
public static final BlockCategory ANVIL = get("minecraft:anvil");
|
||||
public static final BlockCategory BANNERS = get("minecraft:banners");
|
||||
public static final BlockCategory BIRCH_LOGS = get("minecraft:birch_logs");
|
||||
public static final BlockCategory BUTTONS = get("minecraft:buttons");
|
||||
public static final BlockCategory CARPETS = get("minecraft:carpets");
|
||||
public static final BlockCategory CORALS = get("minecraft:corals");
|
||||
public static final BlockCategory CORAL_BLOCKS = get("minecraft:coral_blocks");
|
||||
public static final BlockCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs");
|
||||
public static final BlockCategory DOORS = get("minecraft:doors");
|
||||
public static final BlockCategory ENDERMAN_HOLDABLE = get("minecraft:enderman_holdable");
|
||||
public static final BlockCategory FLOWER_POTS = get("minecraft:flower_pots");
|
||||
public static final BlockCategory ICE = get("minecraft:ice");
|
||||
public static final BlockCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
|
||||
public static final BlockCategory LEAVES = get("minecraft:leaves");
|
||||
public static final BlockCategory LOGS = get("minecraft:logs");
|
||||
public static final BlockCategory OAK_LOGS = get("minecraft:oak_logs");
|
||||
public static final BlockCategory PLANKS = get("minecraft:planks");
|
||||
public static final BlockCategory RAILS = get("minecraft:rails");
|
||||
public static final BlockCategory SAND = get("minecraft:sand");
|
||||
public static final BlockCategory SAPLINGS = get("minecraft:saplings");
|
||||
public static final BlockCategory SLABS = get("minecraft:slabs");
|
||||
public static final BlockCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
|
||||
public static final BlockCategory STAIRS = get("minecraft:stairs");
|
||||
public static final BlockCategory STONE_BRICKS = get("minecraft:stone_bricks");
|
||||
public static final BlockCategory VALID_SPAWN = get("minecraft:valid_spawn");
|
||||
public static final BlockCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
|
||||
public static final BlockCategory WOODEN_DOORS = get("minecraft:wooden_doors");
|
||||
public static final BlockCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates");
|
||||
public static final BlockCategory WOODEN_SLABS = get("minecraft:wooden_slabs");
|
||||
public static final BlockCategory WOODEN_STAIRS = get("minecraft:wooden_stairs");
|
||||
public static final BlockCategory WOOL = get("minecraft:wool");
|
||||
|
||||
private BlockCategories() {
|
||||
}
|
||||
|
||||
private static BlockCategory register(final String id) {
|
||||
return register(new BlockCategory(id));
|
||||
}
|
||||
|
||||
public static BlockCategory register(final BlockCategory tag) {
|
||||
return BlockCategory.REGISTRY.register(tag.getId(), tag);
|
||||
}
|
||||
|
||||
public static @Nullable BlockCategory get(final String id) {
|
||||
return BlockCategory.REGISTRY.get(id);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -57,7 +57,12 @@ public class FuzzyBlockState extends BlockState {
|
||||
Property<Object> objKey = (Property<Object>) entry.getKey();
|
||||
state = state.with(objKey, entry.getValue());
|
||||
}
|
||||
return getBlockType().getDefaultState();
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState toImmutableState() {
|
||||
return getFullState();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,113 +23,105 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class EntityTypes {
|
||||
|
||||
public static final EntityType AREA_EFFECT_CLOUD = register("minecraft:area_effect_cloud");
|
||||
public static final EntityType ARMOR_STAND = register("minecraft:armor_stand");
|
||||
public static final EntityType ARROW = register("minecraft:arrow");
|
||||
public static final EntityType BAT = register("minecraft:bat");
|
||||
public static final EntityType BLAZE = register("minecraft:blaze");
|
||||
public static final EntityType BOAT = register("minecraft:boat");
|
||||
public static final EntityType CAVE_SPIDER = register("minecraft:cave_spider");
|
||||
public static final EntityType CHEST_MINECART = register("minecraft:chest_minecart");
|
||||
public static final EntityType CHICKEN = register("minecraft:chicken");
|
||||
public static final EntityType COD = register("minecraft:cod");
|
||||
public static final EntityType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart");
|
||||
public static final EntityType COW = register("minecraft:cow");
|
||||
public static final EntityType CREEPER = register("minecraft:creeper");
|
||||
public static final EntityType DOLPHIN = register("minecraft:dolphin");
|
||||
public static final EntityType DONKEY = register("minecraft:donkey");
|
||||
public static final EntityType DRAGON_FIREBALL = register("minecraft:dragon_fireball");
|
||||
public static final EntityType DROWNED = register("minecraft:drowned");
|
||||
public static final EntityType EGG = register("minecraft:egg");
|
||||
public static final EntityType ELDER_GUARDIAN = register("minecraft:elder_guardian");
|
||||
public static final EntityType END_CRYSTAL = register("minecraft:end_crystal");
|
||||
public static final EntityType ENDER_DRAGON = register("minecraft:ender_dragon");
|
||||
public static final EntityType ENDER_PEARL = register("minecraft:ender_pearl");
|
||||
public static final EntityType ENDERMAN = register("minecraft:enderman");
|
||||
public static final EntityType ENDERMITE = register("minecraft:endermite");
|
||||
public static final EntityType EVOKER = register("minecraft:evoker");
|
||||
public static final EntityType EVOKER_FANGS = register("minecraft:evoker_fangs");
|
||||
public static final EntityType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle");
|
||||
public static final EntityType EXPERIENCE_ORB = register("minecraft:experience_orb");
|
||||
public static final EntityType EYE_OF_ENDER = register("minecraft:eye_of_ender");
|
||||
public static final EntityType FALLING_BLOCK = register("minecraft:falling_block");
|
||||
public static final EntityType FIREBALL = register("minecraft:fireball");
|
||||
public static final EntityType FIREWORK_ROCKET = register("minecraft:firework_rocket");
|
||||
public static final EntityType FISHING_BOBBER = register("minecraft:fishing_bobber");
|
||||
public static final EntityType FURNACE_MINECART = register("minecraft:furnace_minecart");
|
||||
public static final EntityType GHAST = register("minecraft:ghast");
|
||||
public static final EntityType GIANT = register("minecraft:giant");
|
||||
public static final EntityType GUARDIAN = register("minecraft:guardian");
|
||||
public static final EntityType HOPPER_MINECART = register("minecraft:hopper_minecart");
|
||||
public static final EntityType HORSE = register("minecraft:horse");
|
||||
public static final EntityType HUSK = register("minecraft:husk");
|
||||
public static final EntityType ILLUSIONER = register("minecraft:illusioner");
|
||||
public static final EntityType IRON_GOLEM = register("minecraft:iron_golem");
|
||||
public static final EntityType ITEM = register("minecraft:item");
|
||||
public static final EntityType ITEM_FRAME = register("minecraft:item_frame");
|
||||
public static final EntityType LEASH_KNOT = register("minecraft:leash_knot");
|
||||
public static final EntityType LIGHTNING_BOLT = register("minecraft:lightning_bolt");
|
||||
public static final EntityType LLAMA = register("minecraft:llama");
|
||||
public static final EntityType LLAMA_SPIT = register("minecraft:llama_spit");
|
||||
public static final EntityType MAGMA_CUBE = register("minecraft:magma_cube");
|
||||
public static final EntityType MINECART = register("minecraft:minecart");
|
||||
public static final EntityType MOOSHROOM = register("minecraft:mooshroom");
|
||||
public static final EntityType MULE = register("minecraft:mule");
|
||||
public static final EntityType OCELOT = register("minecraft:ocelot");
|
||||
public static final EntityType PAINTING = register("minecraft:painting");
|
||||
public static final EntityType PARROT = register("minecraft:parrot");
|
||||
public static final EntityType PHANTOM = register("minecraft:phantom");
|
||||
public static final EntityType PIG = register("minecraft:pig");
|
||||
public static final EntityType PLAYER = register("minecraft:player");
|
||||
public static final EntityType POLAR_BEAR = register("minecraft:polar_bear");
|
||||
public static final EntityType POTION = register("minecraft:potion");
|
||||
public static final EntityType PUFFERFISH = register("minecraft:pufferfish");
|
||||
public static final EntityType RABBIT = register("minecraft:rabbit");
|
||||
public static final EntityType SALMON = register("minecraft:salmon");
|
||||
public static final EntityType SHEEP = register("minecraft:sheep");
|
||||
public static final EntityType SHULKER = register("minecraft:shulker");
|
||||
public static final EntityType SHULKER_BULLET = register("minecraft:shulker_bullet");
|
||||
public static final EntityType SILVERFISH = register("minecraft:silverfish");
|
||||
public static final EntityType SKELETON = register("minecraft:skeleton");
|
||||
public static final EntityType SKELETON_HORSE = register("minecraft:skeleton_horse");
|
||||
public static final EntityType SLIME = register("minecraft:slime");
|
||||
public static final EntityType SMALL_FIREBALL = register("minecraft:small_fireball");
|
||||
public static final EntityType SNOW_GOLEM = register("minecraft:snow_golem");
|
||||
public static final EntityType SNOWBALL = register("minecraft:snowball");
|
||||
public static final EntityType SPAWNER_MINECART = register("minecraft:spawner_minecart");
|
||||
public static final EntityType SPECTRAL_ARROW = register("minecraft:spectral_arrow");
|
||||
public static final EntityType SPIDER = register("minecraft:spider");
|
||||
public static final EntityType SQUID = register("minecraft:squid");
|
||||
public static final EntityType STRAY = register("minecraft:stray");
|
||||
public static final EntityType TNT = register("minecraft:tnt");
|
||||
public static final EntityType TNT_MINECART = register("minecraft:tnt_minecart");
|
||||
public static final EntityType TRIDENT = register("minecraft:trident");
|
||||
public static final EntityType TROPICAL_FISH = register("minecraft:tropical_fish");
|
||||
public static final EntityType TURTLE = register("minecraft:turtle");
|
||||
public static final EntityType VEX = register("minecraft:vex");
|
||||
public static final EntityType VILLAGER = register("minecraft:villager");
|
||||
public static final EntityType VINDICATOR = register("minecraft:vindicator");
|
||||
public static final EntityType WITCH = register("minecraft:witch");
|
||||
public static final EntityType WITHER = register("minecraft:wither");
|
||||
public static final EntityType WITHER_SKELETON = register("minecraft:wither_skeleton");
|
||||
public static final EntityType WITHER_SKULL = register("minecraft:wither_skull");
|
||||
public static final EntityType WOLF = register("minecraft:wolf");
|
||||
public static final EntityType ZOMBIE = register("minecraft:zombie");
|
||||
public static final EntityType ZOMBIE_HORSE = register("minecraft:zombie_horse");
|
||||
public static final EntityType ZOMBIE_PIGMAN = register("minecraft:zombie_pigman");
|
||||
public static final EntityType ZOMBIE_VILLAGER = register("minecraft:zombie_villager");
|
||||
@Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
|
||||
@Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
|
||||
@Nullable public static final EntityType ARROW = get("minecraft:arrow");
|
||||
@Nullable public static final EntityType BAT = get("minecraft:bat");
|
||||
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
|
||||
@Nullable public static final EntityType BOAT = get("minecraft:boat");
|
||||
@Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
|
||||
@Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart");
|
||||
@Nullable public static final EntityType CHICKEN = get("minecraft:chicken");
|
||||
@Nullable public static final EntityType COD = get("minecraft:cod");
|
||||
@Nullable public static final EntityType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart");
|
||||
@Nullable public static final EntityType COW = get("minecraft:cow");
|
||||
@Nullable public static final EntityType CREEPER = get("minecraft:creeper");
|
||||
@Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin");
|
||||
@Nullable public static final EntityType DONKEY = get("minecraft:donkey");
|
||||
@Nullable public static final EntityType DRAGON_FIREBALL = get("minecraft:dragon_fireball");
|
||||
@Nullable public static final EntityType DROWNED = get("minecraft:drowned");
|
||||
@Nullable public static final EntityType EGG = get("minecraft:egg");
|
||||
@Nullable public static final EntityType ELDER_GUARDIAN = get("minecraft:elder_guardian");
|
||||
@Nullable public static final EntityType END_CRYSTAL = get("minecraft:end_crystal");
|
||||
@Nullable public static final EntityType ENDER_DRAGON = get("minecraft:ender_dragon");
|
||||
@Nullable public static final EntityType ENDER_PEARL = get("minecraft:ender_pearl");
|
||||
@Nullable public static final EntityType ENDERMAN = get("minecraft:enderman");
|
||||
@Nullable public static final EntityType ENDERMITE = get("minecraft:endermite");
|
||||
@Nullable public static final EntityType EVOKER = get("minecraft:evoker");
|
||||
@Nullable public static final EntityType EVOKER_FANGS = get("minecraft:evoker_fangs");
|
||||
@Nullable public static final EntityType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle");
|
||||
@Nullable public static final EntityType EXPERIENCE_ORB = get("minecraft:experience_orb");
|
||||
@Nullable public static final EntityType EYE_OF_ENDER = get("minecraft:eye_of_ender");
|
||||
@Nullable public static final EntityType FALLING_BLOCK = get("minecraft:falling_block");
|
||||
@Nullable public static final EntityType FIREBALL = get("minecraft:fireball");
|
||||
@Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket");
|
||||
@Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber");
|
||||
@Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart");
|
||||
@Nullable public static final EntityType GHAST = get("minecraft:ghast");
|
||||
@Nullable public static final EntityType GIANT = get("minecraft:giant");
|
||||
@Nullable public static final EntityType GUARDIAN = get("minecraft:guardian");
|
||||
@Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart");
|
||||
@Nullable public static final EntityType HORSE = get("minecraft:horse");
|
||||
@Nullable public static final EntityType HUSK = get("minecraft:husk");
|
||||
@Nullable public static final EntityType ILLUSIONER = get("minecraft:illusioner");
|
||||
@Nullable public static final EntityType IRON_GOLEM = get("minecraft:iron_golem");
|
||||
@Nullable public static final EntityType ITEM = get("minecraft:item");
|
||||
@Nullable public static final EntityType ITEM_FRAME = get("minecraft:item_frame");
|
||||
@Nullable public static final EntityType LEASH_KNOT = get("minecraft:leash_knot");
|
||||
@Nullable public static final EntityType LIGHTNING_BOLT = get("minecraft:lightning_bolt");
|
||||
@Nullable public static final EntityType LLAMA = get("minecraft:llama");
|
||||
@Nullable public static final EntityType LLAMA_SPIT = get("minecraft:llama_spit");
|
||||
@Nullable public static final EntityType MAGMA_CUBE = get("minecraft:magma_cube");
|
||||
@Nullable public static final EntityType MINECART = get("minecraft:minecart");
|
||||
@Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom");
|
||||
@Nullable public static final EntityType MULE = get("minecraft:mule");
|
||||
@Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
|
||||
@Nullable public static final EntityType PAINTING = get("minecraft:painting");
|
||||
@Nullable public static final EntityType PARROT = get("minecraft:parrot");
|
||||
@Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
|
||||
@Nullable public static final EntityType PIG = get("minecraft:pig");
|
||||
@Nullable public static final EntityType PLAYER = get("minecraft:player");
|
||||
@Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");
|
||||
@Nullable public static final EntityType POTION = get("minecraft:potion");
|
||||
@Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish");
|
||||
@Nullable public static final EntityType RABBIT = get("minecraft:rabbit");
|
||||
@Nullable public static final EntityType SALMON = get("minecraft:salmon");
|
||||
@Nullable public static final EntityType SHEEP = get("minecraft:sheep");
|
||||
@Nullable public static final EntityType SHULKER = get("minecraft:shulker");
|
||||
@Nullable public static final EntityType SHULKER_BULLET = get("minecraft:shulker_bullet");
|
||||
@Nullable public static final EntityType SILVERFISH = get("minecraft:silverfish");
|
||||
@Nullable public static final EntityType SKELETON = get("minecraft:skeleton");
|
||||
@Nullable public static final EntityType SKELETON_HORSE = get("minecraft:skeleton_horse");
|
||||
@Nullable public static final EntityType SLIME = get("minecraft:slime");
|
||||
@Nullable public static final EntityType SMALL_FIREBALL = get("minecraft:small_fireball");
|
||||
@Nullable public static final EntityType SNOW_GOLEM = get("minecraft:snow_golem");
|
||||
@Nullable public static final EntityType SNOWBALL = get("minecraft:snowball");
|
||||
@Nullable public static final EntityType SPAWNER_MINECART = get("minecraft:spawner_minecart");
|
||||
@Nullable public static final EntityType SPECTRAL_ARROW = get("minecraft:spectral_arrow");
|
||||
@Nullable public static final EntityType SPIDER = get("minecraft:spider");
|
||||
@Nullable public static final EntityType SQUID = get("minecraft:squid");
|
||||
@Nullable public static final EntityType STRAY = get("minecraft:stray");
|
||||
@Nullable public static final EntityType TNT = get("minecraft:tnt");
|
||||
@Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart");
|
||||
@Nullable public static final EntityType TRIDENT = get("minecraft:trident");
|
||||
@Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish");
|
||||
@Nullable public static final EntityType TURTLE = get("minecraft:turtle");
|
||||
@Nullable public static final EntityType VEX = get("minecraft:vex");
|
||||
@Nullable public static final EntityType VILLAGER = get("minecraft:villager");
|
||||
@Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator");
|
||||
@Nullable public static final EntityType WITCH = get("minecraft:witch");
|
||||
@Nullable public static final EntityType WITHER = get("minecraft:wither");
|
||||
@Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton");
|
||||
@Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull");
|
||||
@Nullable public static final EntityType WOLF = get("minecraft:wolf");
|
||||
@Nullable public static final EntityType ZOMBIE = get("minecraft:zombie");
|
||||
@Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
|
||||
@Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
|
||||
@Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
|
||||
|
||||
private EntityTypes() {
|
||||
}
|
||||
|
||||
private static EntityType register(final String id) {
|
||||
return register(new EntityType(id));
|
||||
}
|
||||
|
||||
public static EntityType register(final EntityType entityType) {
|
||||
return EntityType.REGISTRY.register(entityType.getId(), entityType);
|
||||
}
|
||||
|
||||
public static @Nullable EntityType get(final String id) {
|
||||
return EntityType.REGISTRY.get(id);
|
||||
}
|
||||
|
@ -26,48 +26,40 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public final class ItemCategories {
|
||||
|
||||
public static final ItemCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
||||
public static final ItemCategory ANVIL = register("minecraft:anvil");
|
||||
public static final ItemCategory BANNERS = register("minecraft:banners");
|
||||
public static final ItemCategory BIRCH_LOGS = register("minecraft:birch_logs");
|
||||
public static final ItemCategory BOATS = register("minecraft:boats");
|
||||
public static final ItemCategory BUTTONS = register("minecraft:buttons");
|
||||
public static final ItemCategory CARPETS = register("minecraft:carpets");
|
||||
public static final ItemCategory CORAL = register("minecraft:coral");
|
||||
public static final ItemCategory CORAL_PLANTS = register("minecraft:coral_plants");
|
||||
public static final ItemCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs");
|
||||
public static final ItemCategory DOORS = register("minecraft:doors");
|
||||
public static final ItemCategory FISHES = register("minecraft:fishes");
|
||||
public static final ItemCategory JUNGLE_LOGS = register("minecraft:jungle_logs");
|
||||
public static final ItemCategory LEAVES = register("minecraft:leaves");
|
||||
public static final ItemCategory LOGS = register("minecraft:logs");
|
||||
public static final ItemCategory OAK_LOGS = register("minecraft:oak_logs");
|
||||
public static final ItemCategory PLANKS = register("minecraft:planks");
|
||||
public static final ItemCategory RAILS = register("minecraft:rails");
|
||||
public static final ItemCategory SAND = register("minecraft:sand");
|
||||
public static final ItemCategory SAPLINGS = register("minecraft:saplings");
|
||||
public static final ItemCategory SLABS = register("minecraft:slabs");
|
||||
public static final ItemCategory SPRUCE_LOGS = register("minecraft:spruce_logs");
|
||||
public static final ItemCategory STAIRS = register("minecraft:stairs");
|
||||
public static final ItemCategory STONE_BRICKS = register("minecraft:stone_bricks");
|
||||
public static final ItemCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons");
|
||||
public static final ItemCategory WOODEN_DOORS = register("minecraft:wooden_doors");
|
||||
public static final ItemCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates");
|
||||
public static final ItemCategory WOODEN_SLABS = register("minecraft:wooden_slabs");
|
||||
public static final ItemCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
||||
public static final ItemCategory WOOL = register("minecraft:wool");
|
||||
public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs");
|
||||
public static final ItemCategory ANVIL = get("minecraft:anvil");
|
||||
public static final ItemCategory BANNERS = get("minecraft:banners");
|
||||
public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs");
|
||||
public static final ItemCategory BOATS = get("minecraft:boats");
|
||||
public static final ItemCategory BUTTONS = get("minecraft:buttons");
|
||||
public static final ItemCategory CARPETS = get("minecraft:carpets");
|
||||
public static final ItemCategory CORAL = get("minecraft:coral");
|
||||
public static final ItemCategory CORAL_PLANTS = get("minecraft:coral_plants");
|
||||
public static final ItemCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs");
|
||||
public static final ItemCategory DOORS = get("minecraft:doors");
|
||||
public static final ItemCategory FISHES = get("minecraft:fishes");
|
||||
public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
|
||||
public static final ItemCategory LEAVES = get("minecraft:leaves");
|
||||
public static final ItemCategory LOGS = get("minecraft:logs");
|
||||
public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs");
|
||||
public static final ItemCategory PLANKS = get("minecraft:planks");
|
||||
public static final ItemCategory RAILS = get("minecraft:rails");
|
||||
public static final ItemCategory SAND = get("minecraft:sand");
|
||||
public static final ItemCategory SAPLINGS = get("minecraft:saplings");
|
||||
public static final ItemCategory SLABS = get("minecraft:slabs");
|
||||
public static final ItemCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
|
||||
public static final ItemCategory STAIRS = get("minecraft:stairs");
|
||||
public static final ItemCategory STONE_BRICKS = get("minecraft:stone_bricks");
|
||||
public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
|
||||
public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors");
|
||||
public static final ItemCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates");
|
||||
public static final ItemCategory WOODEN_SLABS = get("minecraft:wooden_slabs");
|
||||
public static final ItemCategory WOODEN_STAIRS = get("minecraft:wooden_stairs");
|
||||
public static final ItemCategory WOOL = get("minecraft:wool");
|
||||
|
||||
private ItemCategories() {
|
||||
}
|
||||
|
||||
private static ItemCategory register(final String id) {
|
||||
return register(new ItemCategory(id));
|
||||
}
|
||||
|
||||
public static ItemCategory register(final ItemCategory tag) {
|
||||
return ItemCategory.REGISTRY.register(tag.getId(), tag);
|
||||
}
|
||||
|
||||
public static @Nullable ItemCategory get(final String id) {
|
||||
return ItemCategory.REGISTRY.get(id);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,10 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -31,22 +29,6 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public interface BiomeRegistry {
|
||||
|
||||
/**
|
||||
* Create a new biome given its biome ID.
|
||||
*
|
||||
* @param id its biome ID
|
||||
* @return a new biome or null if it can't be created
|
||||
*/
|
||||
@Nullable
|
||||
BaseBiome createFromId(int id);
|
||||
|
||||
/**
|
||||
* Get a list of available biomes.
|
||||
*
|
||||
* @return a list of biomes
|
||||
*/
|
||||
List<BaseBiome> getBiomes();
|
||||
|
||||
/**
|
||||
* Get data about a biome.
|
||||
*
|
||||
@ -54,6 +36,6 @@ public interface BiomeRegistry {
|
||||
* @return a data object or null if information is not known
|
||||
*/
|
||||
@Nullable
|
||||
BiomeData getData(BaseBiome biome);
|
||||
BiomeData getData(BiomeType biome);
|
||||
|
||||
}
|
||||
|
@ -19,11 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -40,18 +37,7 @@ public class NullBiomeRegistry implements BiomeRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome createFromId(int id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseBiome> getBiomes() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BiomeData getData(BaseBiome biome) {
|
||||
public BiomeData getData(BiomeType biome) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -23,21 +23,20 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class WeatherTypes {
|
||||
|
||||
public static final WeatherType CLEAR = register("clear");
|
||||
public static final WeatherType RAIN = register("rain");
|
||||
public static final WeatherType THUNDER_STORM = register("thunder_storm");
|
||||
static {
|
||||
// This isn't really a proper registry - so inject these before they're obtained.
|
||||
WeatherType.REGISTRY.register("clear", new WeatherType("clear"));
|
||||
WeatherType.REGISTRY.register("rain", new WeatherType("rain"));
|
||||
WeatherType.REGISTRY.register("thunder_storm", new WeatherType("thunder_storm"));
|
||||
}
|
||||
|
||||
@Nullable public static final WeatherType CLEAR = get("clear");
|
||||
@Nullable public static final WeatherType RAIN = get("rain");
|
||||
@Nullable public static final WeatherType THUNDER_STORM = get("thunder_storm");
|
||||
|
||||
private WeatherTypes() {
|
||||
}
|
||||
|
||||
private static WeatherType register(final String id) {
|
||||
return register(new WeatherType(id));
|
||||
}
|
||||
|
||||
public static WeatherType register(final WeatherType weatherType) {
|
||||
return WeatherType.REGISTRY.register(weatherType.getId(), weatherType);
|
||||
}
|
||||
|
||||
public static @Nullable WeatherType get(final String id) {
|
||||
return WeatherType.REGISTRY.get(id);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class BlockTransformExtentTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
BlockTypes.register(new BlockType("worldedit:test"));
|
||||
BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -30,14 +30,18 @@ import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -50,6 +54,14 @@ final class ForgeAdapter {
|
||||
return new ForgeWorld(world);
|
||||
}
|
||||
|
||||
public static Biome adapt(BiomeType biomeType) {
|
||||
return Biome.REGISTRY.getObject(new ResourceLocation(biomeType.getId()));
|
||||
}
|
||||
|
||||
public static BiomeType adapt(Biome biome) {
|
||||
return BiomeTypes.get(biome.getRegistryName().toString());
|
||||
}
|
||||
|
||||
public static Vector3 adapt(Vec3d vector) {
|
||||
return Vector3.at(vector.x, vector.y, vector.z);
|
||||
}
|
||||
|
@ -19,36 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides access to biome data in Forge.
|
||||
*/
|
||||
class ForgeBiomeRegistry implements BiomeRegistry {
|
||||
|
||||
@Override
|
||||
public BaseBiome createFromId(int id) {
|
||||
return new BaseBiome(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseBiome> getBiomes() {
|
||||
List<BaseBiome> list = new ArrayList<>();
|
||||
for (Biome biome : Biome.REGISTRY) {
|
||||
list.add(new BaseBiome(Biome.getIdForBiome(biome)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeData getData(BaseBiome biome) {
|
||||
return new ForgeBiomeData(Biome.getBiome(biome.getId()));
|
||||
public BiomeData getData(BiomeType biome) {
|
||||
return new ForgeBiomeData(ForgeAdapter.adapt(biome));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -49,7 +49,6 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
@ -262,19 +261,19 @@ public class ForgeWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
checkNotNull(position);
|
||||
return new BaseBiome(Biome.getIdForBiome(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ()))));
|
||||
return ForgeAdapter.adapt(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
checkNotNull(position);
|
||||
checkNotNull(biome);
|
||||
|
||||
Chunk chunk = getWorld().getChunkFromBlockCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ()));
|
||||
if (chunk.isLoaded()) {
|
||||
chunk.getBiomeArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = (byte) biome.getId();
|
||||
chunk.getBiomeArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = (byte) Biome.getIdForBiome(ForgeAdapter.adapt(biome));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,14 +129,14 @@ public class ForgeWorldEdit {
|
||||
for (ResourceLocation name : Block.REGISTRY.getKeys()) {
|
||||
String nameStr = name.toString();
|
||||
if (!BlockType.REGISTRY.keySet().contains(nameStr)) {
|
||||
BlockTypes.register(new BlockType(nameStr));
|
||||
BlockType.REGISTRY.register(nameStr, new BlockType(nameStr));
|
||||
}
|
||||
}
|
||||
|
||||
for (ResourceLocation name : Item.REGISTRY.getKeys()) {
|
||||
String nameStr = name.toString();
|
||||
if (!ItemType.REGISTRY.keySet().contains(nameStr)) {
|
||||
ItemTypes.register(new ItemType(nameStr));
|
||||
ItemType.REGISTRY.register(nameStr, new ItemType(nameStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
@ -103,6 +105,14 @@ public class SpongeAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public static BiomeType adapt(org.spongepowered.api.world.biome.BiomeType biomeType) {
|
||||
return BiomeTypes.get(biomeType.getId());
|
||||
}
|
||||
|
||||
public static org.spongepowered.api.world.biome.BiomeType adapt(BiomeType biomeType) {
|
||||
return Sponge.getRegistry().getType(org.spongepowered.api.world.biome.BiomeType.class, biomeType.getId()).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit location from a Sponge location.
|
||||
*
|
||||
|
@ -19,15 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.sponge;
|
||||
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.world.biome.BiomeType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
@ -37,23 +32,8 @@ class SpongeBiomeRegistry implements BiomeRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome createFromId(int id) {
|
||||
return new BaseBiome(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseBiome> getBiomes() {
|
||||
List<BaseBiome> list = new ArrayList<>();
|
||||
for (BiomeType biome : Sponge.getGame().getRegistry().getAllOf(BiomeType.class)) {
|
||||
list.add(new BaseBiome(SpongeWorldEdit.inst().getAdapter().resolve(biome)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BiomeData getData(BaseBiome biome) {
|
||||
return new SpongeBiomeData(SpongeWorldEdit.inst().getAdapter().resolveBiome(biome.getId()));
|
||||
public BiomeData getData(com.sk89q.worldedit.world.biome.BiomeType biome) {
|
||||
return new SpongeBiomeData(SpongeAdapter.adapt(biome));
|
||||
}
|
||||
|
||||
private static class SpongeBiomeData implements BiomeData {
|
||||
|
@ -35,7 +35,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
@ -192,17 +192,17 @@ public abstract class SpongeWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
checkNotNull(position);
|
||||
return new BaseBiome(SpongeWorldEdit.inst().getAdapter().resolve(getWorld().getBiome(position.getBlockX(), 0, position.getBlockZ())));
|
||||
return SpongeAdapter.adapt(getWorld().getBiome(position.getBlockX(), 0, position.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
checkNotNull(position);
|
||||
checkNotNull(biome);
|
||||
|
||||
getWorld().setBiome(position.getBlockX(), 0, position.getBlockZ(), SpongeWorldEdit.inst().getAdapter().resolveBiome(biome.getId()));
|
||||
getWorld().setBiome(position.getBlockX(), 0, position.getBlockZ(), SpongeAdapter.adapt(biome));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@ import com.sk89q.worldedit.sponge.adapter.AdapterLoadException;
|
||||
import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter;
|
||||
import com.sk89q.worldedit.sponge.adapter.SpongeImplLoader;
|
||||
import com.sk89q.worldedit.sponge.config.SpongeConfiguration;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.bstats.sponge.Metrics2;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Sponge;
|
||||
@ -141,14 +140,14 @@ public class SpongeWorldEdit {
|
||||
// TODO Handle blockstate stuff
|
||||
String id = blockType.getId();
|
||||
if (!com.sk89q.worldedit.world.block.BlockType.REGISTRY.keySet().contains(id)) {
|
||||
com.sk89q.worldedit.world.block.BlockTypes.register(new com.sk89q.worldedit.world.block.BlockType(id));
|
||||
com.sk89q.worldedit.world.block.BlockType.REGISTRY.register(id, new com.sk89q.worldedit.world.block.BlockType(id));
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemType itemType : Sponge.getRegistry().getAllOf(ItemType.class)) {
|
||||
String id = itemType.getId();
|
||||
if (!com.sk89q.worldedit.world.item.ItemType.REGISTRY.keySet().contains(id)) {
|
||||
ItemTypes.register(new com.sk89q.worldedit.world.item.ItemType(id));
|
||||
com.sk89q.worldedit.world.item.ItemType.REGISTRY.register(id, new com.sk89q.worldedit.world.item.ItemType(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,16 +36,6 @@ import org.spongepowered.api.world.biome.BiomeType;
|
||||
*/
|
||||
public interface SpongeImplAdapter {
|
||||
|
||||
/**
|
||||
* Resolves the numerical ID from this {@link BiomeType}
|
||||
*
|
||||
* @param type The biometype
|
||||
* @return The numerical ID
|
||||
*/
|
||||
int resolve(BiomeType type);
|
||||
|
||||
BiomeType resolveBiome(int intID);
|
||||
|
||||
BaseEntity createBaseEntity(Entity entity);
|
||||
|
||||
ItemStack makeSpongeStack(BaseItemStack itemStack);
|
||||
|
Loading…
Reference in New Issue
Block a user