Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
More support for 3D biomes (#608)
* More support for 3D biomes * Resolved merge conflicts
Dieser Commit ist enthalten in:
Ursprung
de199a0e59
Commit
d00899e177
@ -31,7 +31,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
@ -71,7 +70,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -144,7 +142,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
//createEntity was moved to IChunkExtent to prevent issues with Async Entitiy Add.
|
||||
|
||||
|
||||
/**
|
||||
* Get the world handle.
|
||||
*
|
||||
@ -543,6 +541,13 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fullySupports3DBiomes() {
|
||||
// Supports if API does and we're not in the overworld
|
||||
return HAS_3D_BIOMES && getWorld().getEnvironment() != World.Environment.NORMAL;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
if (HAS_3D_BIOMES) {
|
||||
@ -576,7 +581,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return setBiome(BlockVector2.at(x, z), biome);
|
||||
return setBiome(BlockVector3.at(x, y, z), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,6 @@ import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.collection.BlockVector3ChunkMap;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -198,8 +197,8 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return setBiome(position.getX(),0, position.getZ(), biome);
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return setBiome(position.getX(),position.getY(), position.getZ(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,6 +82,10 @@ object NullChunk : IQueueChunk<Nothing> {
|
||||
|
||||
}
|
||||
|
||||
override fun fullySupports3DBiomes(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun setBlockLight(x: Int, y: Int, z: Int, value: Int) {
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
@ -397,7 +397,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
public char getOrdinalChar(Extent orDefault) {
|
||||
return getOrdinalChar();
|
||||
}
|
||||
|
||||
|
||||
//Set delegate
|
||||
private SetDelegate initSet() {
|
||||
setArr = set.load(layer);
|
||||
@ -419,8 +419,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return setBiome(position.getX(), position.getY(), position.getBlockZ(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,12 +150,6 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||
setBiome(biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrdinal(Extent orDefault) {
|
||||
return getOrdinal();
|
||||
|
@ -16,7 +16,6 @@ import com.sk89q.worldedit.function.generator.GenBase;
|
||||
import com.sk89q.worldedit.function.generator.Resource;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
@ -545,7 +544,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
limit.THROW_MAX_CHECKS();
|
||||
try {
|
||||
return getExtent().getBiome(position);
|
||||
@ -614,7 +613,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
limit.THROW_MAX_CHANGES();
|
||||
try {
|
||||
return getExtent().setBiome(position, biome);
|
||||
|
@ -16,7 +16,6 @@ import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
@ -481,14 +480,14 @@ public class MCAChunk implements IChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 pos, BiomeType biome) {
|
||||
return this.setBiome(pos.getX(), 0, pos.getZ(), biome);
|
||||
public boolean setBiome(BlockVector3 pos, BiomeType biome) {
|
||||
return this.setBiome(pos.getX(), pos.getY(), pos.getZ(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
setModified();
|
||||
biomes[x + (z << 4)] = biome;
|
||||
biomes[x + (z << 4)] = biome; //TODO Support 3D Biomes
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -96,7 +95,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType newBiome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(position);
|
||||
if (oldBiome.getId() != newBiome.getId()) {
|
||||
this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockZ(), oldBiome, newBiome);
|
||||
@ -108,7 +107,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(BlockVector2.at(x, z));
|
||||
BiomeType oldBiome = this.getBiome(BlockVector3.at(x, y, z));
|
||||
if (oldBiome.getId() != newBiome.getId()) {
|
||||
this.changeSet.addBiomeChange(x, z, oldBiome, newBiome);
|
||||
return getExtent().setBiome(x, y, z, newBiome);
|
||||
|
@ -4,7 +4,6 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -28,7 +27,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return BiomeTypes.FOREST;
|
||||
}
|
||||
|
||||
|
@ -1024,8 +1024,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return getBiomeType(position.getBlockX(), 0, position.getBlockZ());
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return getBiomeType(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ object EmptyClipboard : Clipboard {
|
||||
return BlockTypes.AIR!!.defaultState
|
||||
}
|
||||
|
||||
override fun getBiome(position: BlockVector2): BiomeType? {
|
||||
override fun getBiome(position: BlockVector3): BiomeType? {
|
||||
return null
|
||||
}
|
||||
|
||||
@ -64,7 +64,11 @@ object EmptyClipboard : Clipboard {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun setBiome(position: BlockVector2, biome: BiomeType): Boolean {
|
||||
override fun setBiome(position: BlockVector3, biome: BiomeType): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun fullySupports3DBiomes(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.boydti.fawe.object.extent;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
@ -36,8 +35,8 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return super.setBiome(position.add(dx, dz), biome);
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return super.setBiome(position.add(dx, dy, dz), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,8 +45,8 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return super.getBiome(position.add(dx, dz));
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return super.getBiome(position.add(dx, dy, dz));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +93,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
|
@ -19,7 +19,6 @@ import com.sk89q.worldedit.function.generator.Resource;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
@ -110,7 +109,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return BiomeTypes.THE_VOID;
|
||||
}
|
||||
|
||||
@ -141,7 +140,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -149,7 +148,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isQueueEnabled() {
|
||||
throw reason;
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
@ -62,11 +61,11 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
return super.getBiome(getPos(mutable).toBlockVector2());
|
||||
mutable.mutY(position.getBlockY());
|
||||
return super.getBiome(getPos(mutable));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,11 +80,11 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
return super.setBiome(getPos(mutable).toBlockVector2(), biome);
|
||||
mutable.mutY(position.getBlockY());
|
||||
return super.setBiome(getPos(mutable), biome);
|
||||
}
|
||||
|
||||
public void setTransform(Transform transform) {
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
@ -69,7 +68,7 @@ public class TemporalExtent extends PassthroughExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
if (position.getX() == bx && position.getZ() == bz) {
|
||||
return biome;
|
||||
}
|
||||
|
@ -3,31 +3,31 @@ package com.boydti.fawe.object.function.block;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
|
||||
public class BiomeCopy implements RegionFunction {
|
||||
|
||||
protected final Extent source;
|
||||
protected final Extent destination;
|
||||
private final MutableBlockVector2 mPos2d;
|
||||
private final MutableBlockVector3 mutableVector;
|
||||
|
||||
public BiomeCopy(Extent source, Extent destination) {
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
this.mPos2d = new MutableBlockVector2();
|
||||
this.mPos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
this.mutableVector = new MutableBlockVector3();
|
||||
this.mutableVector.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
if (x != mPos2d.getBlockX() || z != mPos2d.getBlockZ()) {
|
||||
mPos2d.setComponents(x, z);
|
||||
BlockVector2 bv = mPos2d;
|
||||
return destination.setBiome(bv, source.getBiome(bv));
|
||||
if (x != mutableVector.getBlockX() || z != mutableVector.getBlockZ()|| y != mutableVector
|
||||
.getBlockY()) {
|
||||
mutableVector.setComponents(x, y, z);
|
||||
return destination.setBiome(mutableVector, source.getBiome(mutableVector));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -281,12 +281,12 @@ public class WorldWrapper extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return parent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return parent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||
@ -763,7 +762,17 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return this.getExtent().fullySupports3DBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return this.getExtent().getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
this.changes++;
|
||||
return this.getExtent().setBiome(position, biome);
|
||||
}
|
||||
@ -2916,8 +2925,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BiomeType biomeType,
|
||||
final String expressionString, final boolean hollow, final int timeout)
|
||||
throws ExpressionException, MaxChangedBlocksException {
|
||||
final Vector2 zero2D = zero.toVector2();
|
||||
final Vector2 unit2D = unit.toVector2();
|
||||
|
||||
final Expression expression = Expression.compile(expressionString, "x", "z");
|
||||
expression.optimize();
|
||||
@ -2930,12 +2937,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
||||
@Override
|
||||
protected BiomeType getBiome(int x, int y, int z, BiomeType defaultBiomeType) {
|
||||
environment.setCurrentBlock(x, 0, z);
|
||||
double scaledX = (x - zero2D.getX()) / unit2D.getX();
|
||||
double scaledZ = (z - zero2D.getZ()) / unit2D.getZ();
|
||||
environment.setCurrentBlock(x, y, z);
|
||||
double scaledX = (x - zero.getX()) / unit.getX();
|
||||
double scaledY = (x - zero.getY()) / unit.getX();
|
||||
double scaledZ = (z - zero.getZ()) / unit.getZ();
|
||||
|
||||
try {
|
||||
if (expression.evaluate(timeout, scaledX, scaledZ) <= 0) {
|
||||
if (expression.evaluate(timeout, scaledX, scaledY, scaledZ) <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,8 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -132,12 +130,12 @@ public class BiomeCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint());
|
||||
biomes.add(biome);
|
||||
|
||||
messageKey = "worldedit.biomeinfo.lineofsight";
|
||||
} else if (usePosition) {
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint());
|
||||
biomes.add(biome);
|
||||
|
||||
messageKey = "worldedit.biomeinfo.position";
|
||||
@ -145,14 +143,8 @@ public class BiomeCommands {
|
||||
World world = player.getWorld();
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
if (region instanceof FlatRegion) {
|
||||
for (BlockVector2 pt : ((FlatRegion) region).asFlatRegion()) {
|
||||
biomes.add(world.getBiome(pt));
|
||||
}
|
||||
} else {
|
||||
for (BlockVector3 pt : region) {
|
||||
biomes.add(world.getBiome(pt.toBlockVector2()));
|
||||
}
|
||||
for (BlockVector3 pt : region) {
|
||||
biomes.add(world.getBiome(pt));
|
||||
}
|
||||
|
||||
messageKey = "worldedit.biomeinfo.selection";
|
||||
|
@ -32,7 +32,6 @@ import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -40,15 +39,12 @@ 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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -88,10 +84,21 @@ public class AbstractDelegateExtent implements Extent {
|
||||
return extent.getBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
return extent.getFullBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return extent.getFullBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
/*
|
||||
Queue based methods
|
||||
TODO NOT IMPLEMENTED: IQueueExtent and such need to implement these
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isQueueEnabled() {
|
||||
return extent.isQueueEnabled();
|
||||
@ -122,10 +129,10 @@ public class AbstractDelegateExtent implements Extent {
|
||||
new ExtentTraverser<>(this).setNext(new ForgetfulExtentBuffer(extent));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
History
|
||||
*/
|
||||
|
||||
public void setChangeSet(AbstractChangeSet changeSet) {
|
||||
if (extent instanceof HistoryExtent) {
|
||||
HistoryExtent history = ((HistoryExtent) extent);
|
||||
@ -173,13 +180,13 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return extent.getBiome(position);
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return extent.fullySupports3DBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
return extent.getFullBlock(x, y, z);
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -210,8 +217,8 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return extent.setBiome(position.getX(), 0, position.getZ(), biome);
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return extent.setBiome(position.getX(), position.getY(), position.getZ(), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,12 +22,11 @@ package com.sk89q.worldedit.extent;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.history.change.BiomeChange;
|
||||
import com.sk89q.worldedit.history.change.BiomeChange3D;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
import com.sk89q.worldedit.history.change.EntityCreate;
|
||||
import com.sk89q.worldedit.history.change.EntityRemove;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -68,9 +67,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
BiomeType previous = getBiome(position);
|
||||
changeSet.add(new BiomeChange(position, previous, biome));
|
||||
changeSet.add(new BiomeChange3D(position, previous, biome));
|
||||
return super.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,11 @@ public class NullExtent implements Extent {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||
return false;
|
||||
|
@ -67,6 +67,22 @@ public interface OutputExtent {
|
||||
|
||||
boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException;
|
||||
|
||||
/**
|
||||
* Check if this extent fully supports 3D biomes.
|
||||
*
|
||||
* <p>
|
||||
* If {@code false}, the extent only visually reads biomes from {@code y = 0}.
|
||||
* The biomes will still be set in 3D, but the client will only see the one at
|
||||
* {@code y = 0}. It is up to the caller to determine if they want to set that
|
||||
* biome instead, or simply warn the actor.
|
||||
* </p>
|
||||
*
|
||||
* @return if the extent fully supports 3D biomes
|
||||
*/
|
||||
default boolean fullySupports3DBiomes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome.
|
||||
*
|
||||
@ -77,7 +93,7 @@ public interface OutputExtent {
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
||||
return setBiome(position.toBlockVector3(), biome);
|
||||
}
|
||||
|
||||
@NonAbstractForCompatibility(
|
||||
@ -149,5 +165,4 @@ public interface OutputExtent {
|
||||
* @return an operation or null if there is none to execute
|
||||
*/
|
||||
@Nullable Operation commit();
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
@ -41,6 +40,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -54,13 +54,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern, BiomePattern {
|
||||
|
||||
private final Map<BlockVector3, BaseBlock> buffer = new LinkedHashMap<>();
|
||||
private final Map<BlockVector2, BiomeType> biomeBuffer = new LinkedHashMap<>();
|
||||
private final Map<BlockVector3, BiomeType> biomeBuffer = new LinkedHashMap<>();
|
||||
private final Mask mask;
|
||||
private final Mask2D biomeMask;
|
||||
private BlockVector3 min = null;
|
||||
private BlockVector2 min2d = null;
|
||||
private BlockVector3 max = null;
|
||||
private BlockVector2 max2d = null;
|
||||
|
||||
/**
|
||||
* Create a new extent buffer that will buffer every change.
|
||||
@ -87,8 +84,6 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
super(delegate);
|
||||
checkNotNull(mask);
|
||||
this.mask = mask;
|
||||
Mask2D bmask = mask.toMask2D();
|
||||
this.biomeMask = bmask == null ? Masks.alwaysTrue2D() : bmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,7 +102,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max = max.getMaximum(location);
|
||||
}
|
||||
|
||||
if (mask.test( location)) {
|
||||
if (mask.test(location)) {
|
||||
buffer.put(location, block.toBaseBlock());
|
||||
return true;
|
||||
} else {
|
||||
@ -116,22 +111,22 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
// Update minimum
|
||||
if (min2d == null) {
|
||||
min2d = position;
|
||||
if (min == null) {
|
||||
min = position;
|
||||
} else {
|
||||
min2d = min2d.getMinimum(position);
|
||||
min = min.getMinimum(position);
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max2d == null) {
|
||||
max2d = position;
|
||||
if (max == null) {
|
||||
max = position;
|
||||
} else {
|
||||
max2d = max2d.getMaximum(position);
|
||||
max = max.getMaximum(position);
|
||||
}
|
||||
|
||||
if (biomeMask.test(position)) {
|
||||
if (mask.test(position)) {
|
||||
biomeBuffer.put(position, biome);
|
||||
return true;
|
||||
} else {
|
||||
@ -142,25 +137,26 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
// Update minimum
|
||||
if (min2d == null) {
|
||||
min2d = BlockVector2.at(x, z);
|
||||
if (min == null) {
|
||||
min = BlockVector3.at(x, y, z);
|
||||
} else {
|
||||
min2d = min2d.getMinimum(BlockVector2.at(x,z));
|
||||
min = min.getMinimum(BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max2d == null) {
|
||||
max2d = BlockVector2.at(x,z);
|
||||
if (max == null) {
|
||||
max = BlockVector3.at(x, y, z);
|
||||
} else {
|
||||
max2d = max2d.getMaximum(BlockVector2.at(x,z));
|
||||
max = max.getMaximum(BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
if (biomeMask.test(BlockVector2.at(x,z))) {
|
||||
biomeBuffer.put(BlockVector2.at(x,z), biome);
|
||||
if (mask.test(BlockVector3.at(x, y, z))) {
|
||||
biomeBuffer.put(BlockVector3.at(x, y, z), biome);
|
||||
return true;
|
||||
} else {
|
||||
return getExtent().setBiome(x, y, z, biome);
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ -174,7 +170,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType apply(BlockVector2 pos) {
|
||||
public BiomeType applyBiome(BlockVector3 pos) {
|
||||
BiomeType biome = biomeBuffer.get(pos);
|
||||
if (biome != null) {
|
||||
return biome;
|
||||
@ -222,7 +218,10 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
|
||||
@Override
|
||||
public Iterable<BlockVector2> asFlatRegion() {
|
||||
return biomeBuffer.keySet();
|
||||
return biomeBuffer.keySet()
|
||||
.stream()
|
||||
.map(BlockVector3::toBlockVector2)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Stores block data as a multi-dimensional array of {@link BlockState}s and
|
||||
@ -174,16 +174,17 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
BlockVector2 v = position.subtract(region.getMinimumPoint().toBlockVector2());
|
||||
return getParent().getBiomeType(v.getX(), 0, v.getZ());
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
return getParent().getBiomeType(v.getX(), v.getY(), v.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
int x = position.getBlockX() - origin.getX();
|
||||
int y = position.getBlockY() - origin.getY();
|
||||
int z = position.getBlockZ() - origin.getZ();
|
||||
return getParent().setBiome(x, 0, z, biome);
|
||||
return getParent().setBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
@ -311,16 +311,17 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
|
||||
pasteBiomes &= Clipboard.this.hasBiomes();
|
||||
|
||||
MutableBlockVector2 mpos2d = new MutableBlockVector2();
|
||||
mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
MutableBlockVector3 blockVector3 = new MutableBlockVector3();
|
||||
blockVector3.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
for (BlockVector3 pos : this) {
|
||||
BaseBlock block = pos.getFullBlock(this);
|
||||
int xx = pos.getX() + relx;
|
||||
int zz = pos.getZ() + relz;
|
||||
int yy = pos.getZ() + relz;
|
||||
int zz = pos.getY() + rely;
|
||||
if (hasBiomes() && pos.getBlockY() == 0) {
|
||||
if (pasteBiomes && (xx != mpos2d.getBlockX() || zz != mpos2d.getBlockZ())) {
|
||||
mpos2d.setComponents(xx, zz);
|
||||
extent.setBiome(mpos2d, Clipboard.this.getBiome(BlockVector2.at(pos.getX(), pos.getZ())));
|
||||
if (pasteBiomes && (xx != blockVector3.getBlockX() || zz != blockVector3.getBlockZ())) {
|
||||
blockVector3.setComponents(xx, yy, zz);
|
||||
extent.setBiome(blockVector3, Clipboard.this.getBiome(BlockVector3.at(pos.getX(), pos.getY(), pos.getZ())));
|
||||
}
|
||||
}
|
||||
if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
|
||||
|
@ -37,7 +37,6 @@ import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
@ -287,7 +286,7 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
int z0 = min.getBlockZ() + z;
|
||||
for (int x = 0; x < width; x++, i++) {
|
||||
int x0 = min.getBlockX() + x;
|
||||
BlockVector2 pt = BlockVector2.at(x0, z0);
|
||||
BlockVector3 pt = BlockVector3.at(x0, min.getBlockY(), z0);
|
||||
BiomeType biome = clipboard.getBiome(pt);
|
||||
task.applyInt(i, biome.getInternalId());
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -155,11 +154,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
values.remove("z");
|
||||
|
||||
values.put("Id", new StringTag(block.getNbtId()));
|
||||
values.put("Pos", new IntArrayTag(new int[]{
|
||||
x,
|
||||
y,
|
||||
z
|
||||
}));
|
||||
values.put("Pos", new IntArrayTag(new int[] { x, y, z }));
|
||||
|
||||
tileEntities.add(new CompoundTag(values));
|
||||
}
|
||||
@ -218,7 +213,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
int z0 = min.getBlockZ() + z;
|
||||
for (int x = 0; x < width; x++) {
|
||||
int x0 = min.getBlockX() + x;
|
||||
BlockVector2 pt = BlockVector2.at(x0, z0);
|
||||
BlockVector3 pt = BlockVector3.at(x0, min.getBlockY(), z0);
|
||||
BiomeType biome = clipboard.getBiome(pt);
|
||||
|
||||
String biomeKey = biome.getId();
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.extent.world;
|
||||
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
* Handles quirks when placing biomes.
|
||||
*/
|
||||
public class BiomeQuirkExtent extends AbstractDelegateExtent {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
*/
|
||||
public BiomeQuirkExtent(Extent extent) {
|
||||
super(extent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
boolean success = false;
|
||||
if (!fullySupports3DBiomes()) {
|
||||
// Also place at Y = 0 for proper handling
|
||||
success = super.setBiome(position.withY(0), biome);
|
||||
}
|
||||
return success || super.setBiome(position, biome);
|
||||
}
|
||||
}
|
@ -22,8 +22,10 @@ package com.sk89q.worldedit.function.biome;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -31,10 +33,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Replaces the biome at the locations that this function is applied to.
|
||||
*/
|
||||
public class BiomeReplace implements FlatRegionFunction {
|
||||
public class BiomeReplace implements FlatRegionFunction, RegionFunction {
|
||||
|
||||
private final Extent extent;
|
||||
private BiomePattern biome;
|
||||
private final BiomePattern biome;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -60,8 +62,17 @@ public class BiomeReplace implements FlatRegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
return extent.setBiome(position, biome.apply(position));
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return extent.setBiome(position, biome.applyBiome(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
boolean success = false;
|
||||
for (int y = extent.getMinimumPoint().getY(); y <= extent.getMaximumPoint().getY(); y++) {
|
||||
success |= apply(position.toBlockVector3(y));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ package com.sk89q.worldedit.function.biome;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
@ -31,12 +33,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Copies the biome from one extent to another.
|
||||
*/
|
||||
public class ExtentBiomeCopy implements FlatRegionFunction {
|
||||
public class ExtentBiomeCopy implements FlatRegionFunction, RegionFunction {
|
||||
|
||||
private final Extent source;
|
||||
private final Extent destination;
|
||||
private final BlockVector2 from;
|
||||
private final BlockVector2 to;
|
||||
private final BlockVector3 from;
|
||||
private final BlockVector3 to;
|
||||
private final Transform transform;
|
||||
|
||||
/**
|
||||
@ -47,8 +49,32 @@ public class ExtentBiomeCopy implements FlatRegionFunction {
|
||||
* @param destination the destination extent
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
* @deprecated use {@link ExtentBiomeCopy#ExtentBiomeCopy(Extent, BlockVector3, Extent, BlockVector3, Transform)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ExtentBiomeCopy(Extent source, BlockVector2 from, Extent destination, BlockVector2 to, Transform transform) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
checkNotNull(to);
|
||||
checkNotNull(transform);
|
||||
this.source = source;
|
||||
this.from = from.toBlockVector3();
|
||||
this.destination = destination;
|
||||
this.to = to.toBlockVector3();
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a new biome copy.
|
||||
*
|
||||
* @param source the source extent
|
||||
* @param from the source offset
|
||||
* @param destination the destination extent
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
*/
|
||||
public ExtentBiomeCopy(Extent source, BlockVector3 from, Extent destination, BlockVector3 to, Transform transform) {
|
||||
checkNotNull(source);
|
||||
checkNotNull(from);
|
||||
checkNotNull(destination);
|
||||
@ -62,11 +88,23 @@ public class ExtentBiomeCopy implements FlatRegionFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BiomeType biome = source.getBiome(position);
|
||||
BlockVector2 orig = position.subtract(from);
|
||||
BlockVector2 transformed = transform.apply(orig.toVector3(0)).toVector2().toBlockPoint();
|
||||
BlockVector3 orig = position.subtract(from);
|
||||
BlockVector3 transformed = transform.apply(orig.toVector3())
|
||||
.toBlockPoint()
|
||||
.add(to);
|
||||
|
||||
return destination.setBiome(transformed.add(to), biome);
|
||||
return destination.setBiome(transformed, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||
boolean success = false;
|
||||
for (int y = destination.getMinimumPoint().getY(); y <= destination.getMaximumPoint().getY(); y++) {
|
||||
success |= apply(position.toBlockVector3(y));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -85,6 +84,10 @@ public class ForwardExtentCopy implements Operation {
|
||||
private Transform currentTransform = null;
|
||||
private int affectedBlocks;
|
||||
private RegionFunction filterFunction;
|
||||
private RegionVisitor lastBiomeVisitor;
|
||||
private EntityVisitor lastEntityVisitor;
|
||||
private int affectedBiomeCols;
|
||||
private int affectedEntities;
|
||||
|
||||
/**
|
||||
* Create a new copy using the region's lowest minimum point as the
|
||||
@ -99,10 +102,6 @@ public class ForwardExtentCopy implements Operation {
|
||||
public ForwardExtentCopy(Extent source, Region region, Extent destination, BlockVector3 to) {
|
||||
this(source, region, region.getMinimumPoint(), destination, to);
|
||||
}
|
||||
private FlatRegionVisitor lastBiomeVisitor;
|
||||
private EntityVisitor lastEntityVisitor;
|
||||
private int affectedBiomeCols;
|
||||
private int affectedEntities;
|
||||
|
||||
/**
|
||||
* Create a new copy.
|
||||
|
@ -19,7 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.internal.util.DeprecationUtil;
|
||||
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
@ -31,7 +34,29 @@ public interface BiomePattern {
|
||||
* Return a {@link BiomeType} for the given position.
|
||||
*
|
||||
* @param position the position
|
||||
* @return a block
|
||||
* @return a biome
|
||||
* @deprecated use {@link BiomePattern#applyBiome(BlockVector3)}
|
||||
*/
|
||||
BiomeType apply(BlockVector2 position);
|
||||
@Deprecated
|
||||
default BiomeType apply(BlockVector2 position) {
|
||||
return applyBiome(position.toBlockVector3());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link BiomeType} for the given position.
|
||||
*
|
||||
* @param position the position
|
||||
* @return a biome
|
||||
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||
* for details
|
||||
*/
|
||||
@NonAbstractForCompatibility(
|
||||
delegateName = "apply",
|
||||
delegateParams = { BlockVector2.class }
|
||||
)
|
||||
default BiomeType applyBiome(BlockVector3 position) {
|
||||
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||
|
||||
return apply(position.toBlockVector2());
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* <p>This biome change does not have an {@link Extent} assigned to it because
|
||||
* one will be taken from the passed {@link UndoContext}. If the context
|
||||
* does not have an extent (it is null), cryptic errors may occur.</p>
|
||||
* @deprecated use {@link BiomeChange3D}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BiomeChange implements Change {
|
||||
|
||||
private final BlockVector2 position;
|
||||
@ -85,12 +87,12 @@ public class BiomeChange implements Change {
|
||||
|
||||
@Override
|
||||
public void undo(UndoContext context) throws WorldEditException {
|
||||
checkNotNull(context.getExtent()).setBiome(position, previous);
|
||||
checkNotNull(context.getExtent()).setBiome(position.toBlockVector3(), previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo(UndoContext context) throws WorldEditException {
|
||||
checkNotNull(context.getExtent()).setBiome(position, current);
|
||||
checkNotNull(context.getExtent()).setBiome(position.toBlockVector3(), current);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.math;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -715,10 +714,6 @@ public abstract class BlockVector3 {
|
||||
return orDefault.setBlock(this, block);
|
||||
}
|
||||
|
||||
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||
return orDefault.setBiome(getX(), getY(), getZ(), biome);
|
||||
}
|
||||
|
||||
public int getOrdinal(Extent orDefault) {
|
||||
return getBlock(orDefault).getOrdinal();
|
||||
}
|
||||
@ -778,7 +773,7 @@ public abstract class BlockVector3 {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
|
||||
}
|
||||
|
||||
|
@ -325,11 +325,6 @@ public class DelegateBlockVector3 extends BlockVector3 {
|
||||
return parent.setFullBlock(orDefault, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||
return parent.setBiome(orDefault, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrdinal(Extent orDefault) {
|
||||
return parent.getOrdinal(orDefault);
|
||||
|
@ -26,7 +26,6 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -87,7 +86,7 @@ public class RequestExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return getExtent().getBiome(position);
|
||||
}
|
||||
|
||||
@ -102,19 +101,24 @@ public class RequestExtent implements Extent {
|
||||
return getExtent().setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return getExtent().fullySupports3DBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||
return getExtent().setTile(x, y, z, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return getExtent().setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return getExtent().setBiome(BlockVector2.at(x,z), biome);
|
||||
return getExtent().setBiome(BlockVector3.at(x, y, z), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,7 +31,6 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -94,9 +93,13 @@ public class NullWorld extends AbstractWorld {
|
||||
public boolean clearContainerBlockContents(BlockVector3 position) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean fullySupports3DBiomes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return BiomeTypes.THE_VOID;
|
||||
}
|
||||
|
||||
@ -106,7 +109,7 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -166,6 +169,11 @@ public class NullWorld extends AbstractWorld {
|
||||
return NullChunkGet.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return this.getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.worldedit.world.biome;
|
||||
|
||||
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.Keyed;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
import com.sk89q.worldedit.registry.RegistryItem;
|
||||
@ -84,7 +84,7 @@ public class BiomeType implements RegistryItem, Keyed, BiomePattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType apply(BlockVector2 position) {
|
||||
public BiomeType applyBiome(BlockVector3 position) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren