Use a proper registry for biomes

Dieser Commit ist enthalten in:
Matthew Miller 2019-02-16 17:27:00 +10:00
Ursprung d6bc85ccbe
Commit 1b101740fe
33 geänderte Dateien mit 314 neuen und 326 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,8 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; 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.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; 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.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -304,6 +306,27 @@ public class BukkitAdapter {
return GameModes.get(gameMode.name().toLowerCase()); 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. * Create a WorldEdit EntityType from a Bukkit one.
* *
@ -318,7 +341,7 @@ public class BukkitAdapter {
if (!entityType.getId().startsWith("minecraft:")) { if (!entityType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla entities"); 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));
} }
/** /**

Datei anzeigen

@ -19,16 +19,11 @@
package com.sk89q.worldedit.bukkit; 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.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -41,35 +36,9 @@ class BukkitBiomeRegistry implements BiomeRegistry {
@Nullable @Nullable
@Override @Override
public BaseBiome createFromId(int id) { public BiomeData getData(BiomeType biome) {
return new BaseBiome(id); final Biome bukkitBiome = BukkitAdapter.adapt(biome);
} return bukkitBiome == null ? null : bukkitBiome::name;
@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;
}
} }
} }

Datei anzeigen

@ -34,16 +34,14 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.TreeType; import org.bukkit.TreeType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
@ -465,25 +463,13 @@ public class BukkitWorld extends AbstractWorld {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
if (adapter != null) {
int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
return new BaseBiome(id);
} else {
return new BaseBiome(0);
}
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
if (adapter != null) {
Biome bukkitBiome = adapter.getBiome(biome.getId());
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), bukkitBiome);
return true; return true;
} else {
return false;
}
} }
} }

Datei anzeigen

@ -20,15 +20,14 @@
package com.sk89q.worldedit.bukkit.adapter; package com.sk89q.worldedit.bukkit.adapter;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property; 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.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,26 +40,6 @@ import javax.annotation.Nullable;
*/ */
public interface BukkitImplAdapter { 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. * Get the block at the given location.
* *

Datei anzeigen

@ -52,8 +52,8 @@ import com.sk89q.worldedit.function.block.Counter;
import com.sk89q.worldedit.function.block.Naturalizer; import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator; import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.BlockMask; 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.BlockStateMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.BoundedHeightMask; import com.sk89q.worldedit.function.mask.BoundedHeightMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; 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.util.eventbus.EventBus;
import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.World; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockState; 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.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -129,6 +128,8 @@ import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.Nullable;
/** /**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits, * An {@link Extent} that handles history, {@link BlockBag}s, change limits,
* block re-ordering, and much more. Most operations in WorldEdit use this class. * block re-ordering, and much more. Most operations in WorldEdit use this class.
@ -562,12 +563,12 @@ public class EditSession implements Extent, AutoCloseable {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return bypassNone.getBiome(position); return bypassNone.getBiome(position);
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
return bypassNone.setBiome(position, 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 zero2D = zero.toVector2();
final Vector2 unit2D = unit.toVector2(); final Vector2 unit2D = unit.toVector2();
@ -2215,7 +2216,7 @@ public class EditSession implements Extent, AutoCloseable {
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) { final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
@Override @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); final Vector2 current = Vector2.at(x, z);
environment.setCurrentBlock(current.toVector3(0)); environment.setCurrentBlock(current.toVector3(0));
final Vector2 scaled = current.subtract(zero2D).divide(unit2D); final Vector2 scaled = current.subtract(zero2D).divide(unit2D);

Datei anzeigen

@ -48,12 +48,12 @@ import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.world.World; 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.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -94,10 +94,10 @@ public class BiomeCommands {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
List<BaseBiome> biomes = biomeRegistry.getBiomes(); Collection<BiomeType> biomes = BiomeType.REGISTRY.values();
int totalPages = biomes.size() / 19 + 1; int totalPages = biomes.size() / 19 + 1;
player.print("Available Biomes (page " + page + "/" + totalPages + ") :"); player.print("Available Biomes (page " + page + "/" + totalPages + ") :");
for (BaseBiome biome : biomes) { for (BiomeType biome : biomes) {
if (offset > 0) { if (offset > 0) {
offset--; offset--;
} else { } else {
@ -129,7 +129,7 @@ public class BiomeCommands {
public void biomeInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void biomeInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
Set<BaseBiome> biomes = new HashSet<>(); Set<BiomeType> biomes = new HashSet<>();
String qualifier; String qualifier;
if (args.hasFlag('t')) { if (args.hasFlag('t')) {
@ -139,12 +139,12 @@ public class BiomeCommands {
return; return;
} }
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2()); BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
biomes.add(biome); biomes.add(biome);
qualifier = "at line of sight point"; qualifier = "at line of sight point";
} else if (args.hasFlag('p')) { } 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); biomes.add(biome);
qualifier = "at your position"; qualifier = "at your position";
@ -166,7 +166,7 @@ public class BiomeCommands {
} }
player.print(biomes.size() != 1 ? "Biomes " + qualifier + ":" : "Biome " + qualifier + ":"); player.print(biomes.size() != 1 ? "Biomes " + qualifier + ":" : "Biome " + qualifier + ":");
for (BaseBiome biome : biomes) { for (BiomeType biome : biomes) {
BiomeData data = biomeRegistry.getData(biome); BiomeData data = biomeRegistry.getData(biome);
if (data != null) { if (data != null) {
player.print(" " + data.getName()); player.print(" " + data.getName());
@ -188,7 +188,7 @@ public class BiomeCommands {
) )
@Logging(REGION) @Logging(REGION)
@CommandPermissions("worldedit.biome.set") @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(); World world = player.getWorld();
Region region; Region region;
Mask mask = editSession.getMask(); Mask mask = editSession.getMask();

Datei anzeigen

@ -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.Switch;
import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.parametric.Optional; 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. * Commands for the generation of shapes and other objects.
@ -337,7 +337,7 @@ public class GenerationCommands {
@Logging(ALL) @Logging(ALL)
public void generateBiome(Player player, LocalSession session, EditSession editSession, public void generateBiome(Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Selection Region region,
BaseBiome target, BiomeType target,
@Text String expression, @Text String expression,
@Switch('h') boolean hollow, @Switch('h') boolean hollow,
@Switch('r') boolean useRawCoords, @Switch('r') boolean useRawCoords,

Datei anzeigen

@ -28,12 +28,12 @@ import com.sk89q.worldedit.function.mask.BiomeMask2D;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.internal.registry.InputParser; 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.biome.Biomes;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
public class BiomeMaskParser extends InputParser<Mask> { public class BiomeMaskParser extends InputParser<Mask> {
@ -48,11 +48,11 @@ public class BiomeMaskParser extends InputParser<Mask> {
return null; return null;
} }
Set<BaseBiome> biomes = new HashSet<>(); Set<BiomeType> biomes = new HashSet<>();
BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); 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))) { 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) { if (biome == null) {
throw new InputParseException("Unknown biome '" + biomeName + '\''); throw new InputParseException("Unknown biome '" + biomeName + '\'');
} }

Datei anzeigen

@ -30,7 +30,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -97,12 +97,12 @@ public abstract class AbstractDelegateExtent implements Extent {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return extent.getBiome(position); return extent.getBiome(position);
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
return extent.setBiome(position, biome); return extent.setBiome(position, biome);
} }

Datei anzeigen

@ -33,7 +33,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -69,9 +69,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
BaseBiome previous = getBiome(position); BiomeType previous = getBiome(position);
changeSet.add(new BiomeChange(position, previous, new BaseBiome(biome))); changeSet.add(new BiomeChange(position, previous, biome));
return super.setBiome(position, biome); return super.setBiome(position, biome);
} }

Datei anzeigen

@ -22,7 +22,7 @@ package com.sk89q.worldedit.extent;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; 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 * @param position the (x, z) location to check the biome at
* @return the biome at the location * @return the biome at the location
*/ */
BaseBiome getBiome(BlockVector2 position); BiomeType getBiome(BlockVector2 position);
} }

Datei anzeigen

@ -27,7 +27,8 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -80,10 +81,9 @@ public class NullExtent implements Extent {
return getBlock(position).toBaseBlock(); return getBlock(position).toBaseBlock();
} }
@Nullable
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return null; return BiomeTypes.THE_VOID;
} }
@Override @Override
@ -92,7 +92,7 @@ public class NullExtent implements Extent {
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
return false; return false;
} }

Datei anzeigen

@ -23,7 +23,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; 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 com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -59,7 +59,7 @@ public interface OutputExtent {
* @param biome the biome to set to * @param biome the biome to set to
* @return true if the biome was successfully set (return value may not be accurate) * @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 * Return an {@link Operation} that should be called to tie up loose ends

Datei anzeigen

@ -29,7 +29,8 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -160,12 +161,12 @@ public class BlockArrayClipboard implements Clipboard {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return new BaseBiome(0); return BiomeTypes.OCEAN;
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
return false; return false;
} }

Datei anzeigen

@ -25,7 +25,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.math.BlockVector2; 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. * 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 { public class BiomeReplace implements FlatRegionFunction {
private final Extent extent; private final Extent extent;
private BaseBiome biome; private BiomeType biome;
/** /**
* Create a new instance. * Create a new instance.
@ -41,7 +41,7 @@ public class BiomeReplace implements FlatRegionFunction {
* @param extent an extent * @param extent an extent
* @param biome a biome * @param biome a biome
*/ */
public BiomeReplace(Extent extent, BaseBiome biome) { public BiomeReplace(Extent extent, BiomeType biome) {
checkNotNull(extent); checkNotNull(extent);
checkNotNull(biome); checkNotNull(biome);
this.extent = extent; this.extent = extent;

Datei anzeigen

@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2; 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.Arrays;
import java.util.Collection; import java.util.Collection;
@ -36,7 +36,7 @@ import java.util.Set;
public class BiomeMask2D extends AbstractMask2D { public class BiomeMask2D extends AbstractMask2D {
private final Extent extent; private final Extent extent;
private final Set<BaseBiome> biomes = new HashSet<>(); private final Set<BiomeType> biomes = new HashSet<>();
/** /**
* Create a new biome mask. * Create a new biome mask.
@ -44,7 +44,7 @@ public class BiomeMask2D extends AbstractMask2D {
* @param extent the extent * @param extent the extent
* @param biomes a list of biomes to match * @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(extent);
checkNotNull(biomes); checkNotNull(biomes);
this.extent = extent; this.extent = extent;
@ -57,7 +57,7 @@ public class BiomeMask2D extends AbstractMask2D {
* @param extent the extent * @param extent the extent
* @param biome an array of biomes to match * @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))); this(extent, Arrays.asList(checkNotNull(biome)));
} }
@ -66,7 +66,7 @@ public class BiomeMask2D extends AbstractMask2D {
* *
* @param biomes a list of biomes * @param biomes a list of biomes
*/ */
public void add(Collection<BaseBiome> biomes) { public void add(Collection<BiomeType> biomes) {
checkNotNull(biomes); checkNotNull(biomes);
this.biomes.addAll(biomes); this.biomes.addAll(biomes);
} }
@ -76,7 +76,7 @@ public class BiomeMask2D extends AbstractMask2D {
* *
* @param biome an array of biomes * @param biome an array of biomes
*/ */
public void add(BaseBiome... biome) { public void add(BiomeType... biome) {
add(Arrays.asList(checkNotNull(biome))); add(Arrays.asList(checkNotNull(biome)));
} }
@ -85,13 +85,13 @@ public class BiomeMask2D extends AbstractMask2D {
* *
* @return a list of biomes * @return a list of biomes
*/ */
public Collection<BaseBiome> getBiomes() { public Collection<BiomeType> getBiomes() {
return biomes; return biomes;
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(BlockVector2 vector) {
BaseBiome biome = extent.getBiome(vector); BiomeType biome = extent.getBiome(vector);
return biomes.contains(biome); return biomes.contains(biome);
} }

Datei anzeigen

@ -25,7 +25,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.math.BlockVector2; 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. * 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 { public class BiomeChange implements Change {
private final BlockVector2 position; private final BlockVector2 position;
private final BaseBiome previous; private final BiomeType previous;
private final BaseBiome current; private final BiomeType current;
/** /**
* Create a new biome change. * Create a new biome change.
@ -47,7 +47,7 @@ public class BiomeChange implements Change {
* @param previous the previous biome * @param previous the previous biome
* @param current the current 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(position);
checkNotNull(previous); checkNotNull(previous);
checkNotNull(current); checkNotNull(current);
@ -70,7 +70,7 @@ public class BiomeChange implements Change {
* *
* @return the previous biome * @return the previous biome
*/ */
public BaseBiome getPrevious() { public BiomeType getPrevious() {
return previous; return previous;
} }
@ -79,7 +79,7 @@ public class BiomeChange implements Change {
* *
* @return the current biome * @return the current biome
*/ */
public BaseBiome getCurrent() { public BiomeType getCurrent() {
return current; return current;
} }

Datei anzeigen

@ -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.BindingMatch;
import com.sk89q.worldedit.util.command.parametric.ParameterException; import com.sk89q.worldedit.util.command.parametric.ParameterException;
import com.sk89q.worldedit.world.World; 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.biome.Biomes;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; 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 com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.Collection;
/** /**
* Binds standard WorldEdit classes such as {@link Player} and {@link LocalSession}. * 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 * @param context the context
* @return a pattern * @return a pattern
* @throws ParameterException on error * @throws ParameterException on error
* @throws WorldEditException on error * @throws WorldEditException on error
*/ */
@BindingMatch(type = BaseBiome.class, @BindingMatch(type = BiomeType.class,
behavior = BindingBehavior.CONSUMES, behavior = BindingBehavior.CONSUMES,
consumedCount = 1) consumedCount = 1)
public BaseBiome getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException { public BiomeType getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException {
String input = context.next(); String input = context.next();
if (input != null) { if (input != null) {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes(); Collection<BiomeType> knownBiomes = BiomeType.REGISTRY.values();
BaseBiome biome = Biomes.findBiomeByName(knownBiomes, input, biomeRegistry); BiomeType biome = Biomes.findBiomeByName(knownBiomes, input, biomeRegistry);
if (biome != null) { if (biome != null) {
return biome; return biome;
} else { } else {

Datei anzeigen

@ -24,7 +24,8 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region; 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 * Generates solid and hollow shapes according to materials returned by the
@ -54,10 +55,10 @@ public abstract class ArbitraryBiomeShape {
cacheOffsetX = min.getBlockX() - 1; cacheOffsetX = min.getBlockX() - 1;
cacheOffsetZ = min.getBlockZ() - 1; cacheOffsetZ = min.getBlockZ() - 1;
cacheSizeX = (int) (max.getX() - cacheOffsetX + 2); cacheSizeX = max.getX() - cacheOffsetX + 2;
cacheSizeZ = (int) (max.getZ() - cacheOffsetZ + 2); cacheSizeZ = max.getZ() - cacheOffsetZ + 2;
cache = new BaseBiome[cacheSizeX * cacheSizeZ]; cache = new BiomeType[cacheSizeX * cacheSizeZ];
} }
protected Iterable<BlockVector2> getExtent() { protected Iterable<BlockVector2> getExtent() {
@ -71,7 +72,7 @@ public abstract class ArbitraryBiomeShape {
* OUTSIDE = outside * OUTSIDE = outside
* else = inside * else = inside
*/ */
private final BaseBiome[] cache; private final BiomeType[] cache;
/** /**
* Override this function to specify the shape to generate. * 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. * @param defaultBaseBiome The default biome for the current column.
* @return material to place or null to not place anything. * @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 int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
final BaseBiome cacheEntry = cache[index]; final BiomeType cacheEntry = cache[index];
if (cacheEntry == null) {// unknown, fetch material if (cacheEntry == null) {// unknown, fetch material
final BaseBiome material = getBiome(x, z, baseBiome); final BiomeType material = getBiome(x, z, baseBiome);
if (material == null) { if (material == null) {
// outside // outside
cache[index] = OUTSIDE; cache[index] = BiomeTypes.THE_VOID;
return null; return null;
} }
@ -99,7 +100,7 @@ public abstract class ArbitraryBiomeShape {
return material; return material;
} }
if (cacheEntry == OUTSIDE) { if (cacheEntry == BiomeTypes.THE_VOID) {
// outside // outside
return null; return null;
} }
@ -107,16 +108,16 @@ public abstract class ArbitraryBiomeShape {
return cacheEntry; 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 int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
final BaseBiome cacheEntry = cache[index]; final BiomeType cacheEntry = cache[index];
if (cacheEntry == null) { if (cacheEntry == null) {
// unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape // 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 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. * @param hollow Specifies whether to generate a hollow shape.
* @return number of affected blocks. * @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; int affected = 0;
for (BlockVector2 position : getExtent()) { for (BlockVector2 position : getExtent()) {
@ -135,8 +136,8 @@ public abstract class ArbitraryBiomeShape {
int z = position.getBlockZ(); int z = position.getBlockZ();
if (!hollow) { if (!hollow) {
final BaseBiome material = getBiome(x, z, baseBiome); final BiomeType material = getBiome(x, z, baseBiome);
if (material != null && material != OUTSIDE) { if (material != null && material != BiomeTypes.THE_VOID) {
editSession.getWorld().setBiome(position, material); editSession.getWorld().setBiome(position, material);
++affected; ++affected;
} }
@ -144,7 +145,7 @@ public abstract class ArbitraryBiomeShape {
continue; continue;
} }
final BaseBiome material = getBiomeCached(x, z, baseBiome); final BiomeType material = getBiomeCached(x, z, baseBiome);
if (material == null) { if (material == null) {
continue; continue;
} }
@ -180,16 +181,4 @@ public abstract class ArbitraryBiomeShape {
return affected; 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;
}
};
} }

Datei anzeigen

@ -31,12 +31,14 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -80,12 +82,12 @@ public class NullWorld extends AbstractWorld {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return null; return BiomeTypes.THE_VOID;
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
return false; return false;
} }
@ -109,7 +111,7 @@ public class NullWorld extends AbstractWorld {
@Override @Override
public WeatherType getWeather() { public WeatherType getWeather() {
return null; return WeatherTypes.CLEAR;
} }
@Override @Override

Datei anzeigen

@ -29,7 +29,7 @@ import javax.annotation.Nullable;
/** /**
* Returns the name of a biome using a given {@code BiomeRegistry}. * 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; private final BiomeRegistry registry;
@ -45,7 +45,7 @@ class BiomeName implements Function<BaseBiome, String> {
@Nullable @Nullable
@Override @Override
public String apply(BaseBiome input) { public String apply(BiomeType input) {
BiomeData data = registry.getData(input); BiomeData data = registry.getData(input);
if (data != null) { if (data != null) {
return data.getName(); return data.getName();

Datei anzeigen

@ -19,64 +19,42 @@
package com.sk89q.worldedit.world.biome; 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");
/** private String id;
* Create a new biome with the given biome ID.
* public BiomeType(String id) {
* @param id the biome ID
*/
public BaseBiome(int id) {
this.id = 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) { public String getId() {
checkNotNull(biome); return this.id;
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;
} }
@Override @Override
public boolean equals(Object o) { public String toString() {
if (this == o) return true; return getId();
if (o == null || getClass() != o.getClass()) return false;
BaseBiome baseBiome = (BaseBiome) o;
return id == baseBiome.id;
} }
@Override @Override
public int hashCode() { 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);
} }
} }

Datei anzeigen

@ -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 {
public static final BiomeType BADLANDS = register("minecraft:badlands");
public static final BiomeType BADLANDS_PLATEAU = register("minecraft:badlands_plateau");
public static final BiomeType BEACH = register("minecraft:beach");
public static final BiomeType BIRCH_FOREST = register("minecraft:birch_forest");
public static final BiomeType BIRCH_FOREST_HILLS = register("minecraft:birch_forest_hills");
public static final BiomeType COLD_OCEAN = register("minecraft:cold_ocean");
public static final BiomeType DARK_FOREST = register("minecraft:dark_forest");
public static final BiomeType DARK_FOREST_HILLS = register("minecraft:dark_forest_hills");
public static final BiomeType DEEP_COLD_OCEAN = register("minecraft:deep_cold_ocean");
public static final BiomeType DEEP_FROZEN_OCEAN = register("minecraft:deep_frozen_ocean");
public static final BiomeType DEEP_LUKEWARM_OCEAN = register("minecraft:deep_lukewarm_ocean");
public static final BiomeType DEEP_OCEAN = register("minecraft:deep_ocean");
public static final BiomeType DEEP_WARM_OCEAN = register("minecraft:deep_warm_ocean");
public static final BiomeType DESERT = register("minecraft:desert");
public static final BiomeType DESERT_HILLS = register("minecraft:desert_hills");
public static final BiomeType DESERT_LAKES = register("minecraft:desert_lakes");
public static final BiomeType END_BARRENS = register("minecraft:end_barrens");
public static final BiomeType END_HIGHLANDS = register("minecraft:end_highlands");
public static final BiomeType END_MIDLANDS = register("minecraft:end_midlands");
public static final BiomeType ERODED_BADLANDS = register("minecraft:eroded_badlands");
public static final BiomeType FLOWER_FOREST = register("minecraft:flower_forest");
public static final BiomeType FOREST = register("minecraft:forest");
public static final BiomeType FROZEN_OCEAN = register("minecraft:frozen_ocean");
public static final BiomeType FROZEN_RIVER = register("minecraft:frozen_river");
public static final BiomeType GIANT_SPRUCE_TAIGA = register("minecraft:giant_spruce_taiga");
public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = register("minecraft:giant_spruce_taiga_hills");
public static final BiomeType GIANT_TREE_TAIGA = register("minecraft:giant_tree_taiga");
public static final BiomeType GIANT_TREE_TAIGA_HILLS = register("minecraft:giant_tree_taiga_hills");
public static final BiomeType GRAVELLY_MOUNTAINS = register("minecraft:gravelly_mountains");
public static final BiomeType ICE_SPIKES = register("minecraft:ice_spikes");
public static final BiomeType JUNGLE = register("minecraft:jungle");
public static final BiomeType JUNGLE_EDGE = register("minecraft:jungle_edge");
public static final BiomeType JUNGLE_HILLS = register("minecraft:jungle_hills");
public static final BiomeType LUKEWARM_OCEAN = register("minecraft:lukewarm_ocean");
public static final BiomeType MODIFIED_BADLANDS_PLATEAU = register("minecraft:modified_badlands_plateau");
public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = register("minecraft:modified_gravelly_mountains");
public static final BiomeType MODIFIED_JUNGLE = register("minecraft:modified_jungle");
public static final BiomeType MODIFIED_JUNGLE_EDGE = register("minecraft:modified_jungle_edge");
public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = register("minecraft:modified_wooded_badlands_plateau");
public static final BiomeType MOUNTAIN_EDGE = register("minecraft:mountain_edge");
public static final BiomeType MOUNTAINS = register("minecraft:mountains");
public static final BiomeType MUSHROOM_FIELD_SHORE = register("minecraft:mushroom_field_shore");
public static final BiomeType MUSHROOM_FIELDS = register("minecraft:mushroom_fields");
public static final BiomeType NETHER = register("minecraft:nether");
public static final BiomeType OCEAN = register("minecraft:ocean");
public static final BiomeType PLAINS = register("minecraft:plains");
public static final BiomeType RIVER = register("minecraft:river");
public static final BiomeType SAVANNA = register("minecraft:savanna");
public static final BiomeType SAVANNA_PLATEAU = register("minecraft:savanna_plateau");
public static final BiomeType SHATTERED_SAVANNA = register("minecraft:shattered_savanna");
public static final BiomeType SHATTERED_SAVANNA_PLATEAU = register("minecraft:shattered_savanna_plateau");
public static final BiomeType SMALL_END_ISLANDS = register("minecraft:small_end_islands");
public static final BiomeType SNOWY_BEACH = register("minecraft:snowy_beach");
public static final BiomeType SNOWY_MOUNTAINS = register("minecraft:snowy_mountains");
public static final BiomeType SNOWY_TAIGA = register("minecraft:snowy_taiga");
public static final BiomeType SNOWY_TAIGA_HILLS = register("minecraft:snowy_taiga_hills");
public static final BiomeType SNOWY_TAIGA_MOUNTAINS = register("minecraft:snowy_taiga_mountains");
public static final BiomeType SNOWY_TUNDRA = register("minecraft:snowy_tundra");
public static final BiomeType STONE_SHORE = register("minecraft:stone_shore");
public static final BiomeType SUNFLOWER_PLAINS = register("minecraft:sunflower_plains");
public static final BiomeType SWAMP = register("minecraft:swamp");
public static final BiomeType SWAMP_HILLS = register("minecraft:swamp_hills");
public static final BiomeType TAIGA = register("minecraft:taiga");
public static final BiomeType TAIGA_HILLS = register("minecraft:taiga_hills");
public static final BiomeType TAIGA_MOUNTAINS = register("minecraft:taiga_mountains");
public static final BiomeType TALL_BIRCH_FOREST = register("minecraft:tall_birch_forest");
public static final BiomeType TALL_BIRCH_HILLS = register("minecraft:tall_birch_hills");
public static final BiomeType THE_END = register("minecraft:the_end");
public static final BiomeType THE_VOID = register("minecraft:the_void");
public static final BiomeType WARM_OCEAN = register("minecraft:warm_ocean");
public static final BiomeType WOODED_BADLANDS_PLATEAU = register("minecraft:wooded_badlands_plateau");
public static final BiomeType WOODED_HILLS = register("minecraft:wooded_hills");
public static final BiomeType WOODED_MOUNTAINS = register("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);
}
}

Datei anzeigen

@ -50,17 +50,17 @@ public final class Biomes {
* @return a biome or null * @return a biome or null
*/ */
@Nullable @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(biomes);
checkNotNull(name); checkNotNull(name);
checkNotNull(registry); checkNotNull(registry);
Function<String, ? extends Number> compare = new LevenshteinDistance(name, false, LevenshteinDistance.STANDARD_CHARS); 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); WeightedChoice<BiomeType> chooser = new WeightedChoice<>(Functions.compose(compare::apply, new BiomeName(registry)), 0);
for (BaseBiome biome : biomes) { for (BiomeType biome : biomes) {
chooser.consider(biome); chooser.consider(biome);
} }
Optional<Choice<BaseBiome>> choice = chooser.getChoice(); Optional<Choice<BiomeType>> choice = chooser.getChoice();
if (choice.isPresent() && choice.get().getScore() <= 1) { if (choice.isPresent() && choice.get().getScore() <= 1) {
return choice.get().getValue(); return choice.get().getValue();
} else { } else {

Datei anzeigen

@ -19,10 +19,8 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -31,22 +29,6 @@ import javax.annotation.Nullable;
*/ */
public interface BiomeRegistry { 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. * Get data about a biome.
* *
@ -54,6 +36,6 @@ public interface BiomeRegistry {
* @return a data object or null if information is not known * @return a data object or null if information is not known
*/ */
@Nullable @Nullable
BiomeData getData(BaseBiome biome); BiomeData getData(BiomeType biome);
} }

Datei anzeigen

@ -19,11 +19,8 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -40,18 +37,7 @@ public class NullBiomeRegistry implements BiomeRegistry {
@Nullable @Nullable
@Override @Override
public BaseBiome createFromId(int id) { public BiomeData getData(BiomeType biome) {
return null;
}
@Override
public List<BaseBiome> getBiomes() {
return Collections.emptyList();
}
@Nullable
@Override
public BiomeData getData(BaseBiome biome) {
return null; return null;
} }

Datei anzeigen

@ -30,14 +30,18 @@ import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.World; 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.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.biome.Biome;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -50,6 +54,14 @@ final class ForgeAdapter {
return new ForgeWorld(world); 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) { public static Vector3 adapt(Vec3d vector) {
return Vector3.at(vector.x, vector.y, vector.z); return Vector3.at(vector.x, vector.y, vector.z);
} }

Datei anzeigen

@ -19,36 +19,20 @@
package com.sk89q.worldedit.forge; 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.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import java.util.ArrayList;
import java.util.List;
/** /**
* Provides access to biome data in Forge. * Provides access to biome data in Forge.
*/ */
class ForgeBiomeRegistry implements BiomeRegistry { class ForgeBiomeRegistry implements BiomeRegistry {
@Override
public BaseBiome createFromId(int id) {
return new BaseBiome(id);
}
@Override @Override
public List<BaseBiome> getBiomes() { public BiomeData getData(BiomeType biome) {
List<BaseBiome> list = new ArrayList<>(); return new ForgeBiomeData(ForgeAdapter.adapt(biome));
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()));
} }
/** /**

Datei anzeigen

@ -41,7 +41,7 @@ import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.AbstractWorld; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; 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.item.ItemTypes;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockOldLeaf; import net.minecraft.block.BlockOldLeaf;
@ -262,19 +261,19 @@ public class ForgeWorld extends AbstractWorld {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
checkNotNull(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 @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
checkNotNull(position); checkNotNull(position);
checkNotNull(biome); checkNotNull(biome);
Chunk chunk = getWorld().getChunkFromBlockCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ())); Chunk chunk = getWorld().getChunkFromBlockCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ()));
if (chunk.isLoaded()) { 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; return true;
} }

Datei anzeigen

@ -26,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; 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.Sponge;
import org.spongepowered.api.entity.living.player.Player; 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. * Create a WorldEdit location from a Sponge location.
* *

Datei anzeigen

@ -19,15 +19,10 @@
package com.sk89q.worldedit.sponge; package com.sk89q.worldedit.sponge;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeType;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -37,23 +32,8 @@ class SpongeBiomeRegistry implements BiomeRegistry {
@Nullable @Nullable
@Override @Override
public BaseBiome createFromId(int id) { public BiomeData getData(com.sk89q.worldedit.world.biome.BiomeType biome) {
return new BaseBiome(id); return new SpongeBiomeData(SpongeAdapter.adapt(biome));
}
@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()));
} }
private static class SpongeBiomeData implements BiomeData { private static class SpongeBiomeData implements BiomeData {

Datei anzeigen

@ -35,7 +35,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.AbstractWorld; 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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
@ -192,17 +192,17 @@ public abstract class SpongeWorld extends AbstractWorld {
} }
@Override @Override
public BaseBiome getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
checkNotNull(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 @Override
public boolean setBiome(BlockVector2 position, BaseBiome biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
checkNotNull(position); checkNotNull(position);
checkNotNull(biome); 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; return true;
} }

Datei anzeigen

@ -36,16 +36,6 @@ import org.spongepowered.api.world.biome.BiomeType;
*/ */
public interface SpongeImplAdapter { 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); BaseEntity createBaseEntity(Entity entity);
ItemStack makeSpongeStack(BaseItemStack itemStack); ItemStack makeSpongeStack(BaseItemStack itemStack);