geforkt von Mirrors/FastAsyncWorldEdit
Upstream merge of the region package and things that may have broken with it.
Dieser Commit ist enthalten in:
Ursprung
de34047365
Commit
79b5612311
@ -3,24 +3,22 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||||
@ -51,11 +49,6 @@ 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 io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
@ -69,15 +62,42 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
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;
|
||||||
|
|
||||||
public class BukkitWorld extends AbstractWorld {
|
public class BukkitWorld extends AbstractWorld {
|
||||||
|
|
||||||
private static final Logger logger = WorldEdit.logger;
|
private static final Logger logger = WorldEdit.logger;
|
||||||
|
|
||||||
|
private static final boolean HAS_3D_BIOMES;
|
||||||
|
|
||||||
private static final Map<Integer, Effect> effects = new HashMap<>();
|
private static final Map<Integer, Effect> effects = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Effect effect : Effect.values()) {
|
for (Effect effect : Effect.values()) {
|
||||||
effects.put(effect.getId(), effect);
|
@SuppressWarnings("deprecation")
|
||||||
|
int id = effect.getId();
|
||||||
|
effects.put(id, effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean temp;
|
||||||
|
try {
|
||||||
|
World.class.getMethod("getBiome", int.class, int.class, int.class);
|
||||||
|
temp = true;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
temp = false;
|
||||||
|
}
|
||||||
|
HAS_3D_BIOMES = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WeakReference<World> worldRef;
|
private WeakReference<World> worldRef;
|
||||||
@ -157,7 +177,9 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
World tmp = worldRef.get();
|
World tmp = worldRef.get();
|
||||||
if (tmp == null) {
|
if (tmp == null) {
|
||||||
tmp = Bukkit.getWorld(worldNameRef);
|
tmp = Bukkit.getWorld(worldNameRef);
|
||||||
if (tmp != null) worldRef = new WeakReference<>(tmp);
|
if (tmp != null) {
|
||||||
|
worldRef = new WeakReference<>(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return checkNotNull(tmp, "The world was unloaded and the reference is unavailable");
|
return checkNotNull(tmp, "The world was unloaded and the reference is unavailable");
|
||||||
}
|
}
|
||||||
@ -187,7 +209,16 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getStoragePath() {
|
public Path getStoragePath() {
|
||||||
return getWorld().getWorldFolder().toPath();
|
Path worldFolder = getWorld().getWorldFolder().toPath();
|
||||||
|
switch (getWorld().getEnvironment()) {
|
||||||
|
case NETHER:
|
||||||
|
return worldFolder.resolve("DIM-1");
|
||||||
|
case THE_END:
|
||||||
|
return worldFolder.resolve("DIM1");
|
||||||
|
case NORMAL:
|
||||||
|
default:
|
||||||
|
return worldFolder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -299,7 +330,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
|
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes.
|
||||||
*/
|
*/
|
||||||
private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping =
|
private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping =
|
||||||
new EnumMap<>(TreeGenerator.TreeType.class);
|
new EnumMap<>(TreeGenerator.TreeType.class);
|
||||||
@ -385,6 +416,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return getWorld().getMaxHeight() - 1;
|
return getWorld().getMaxHeight() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
@ -488,8 +520,8 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return worldNativeAccess.setBlock(position, block, sideEffects);
|
return worldNativeAccess.setBlock(position, block, sideEffects);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) {
|
if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) {
|
||||||
logger.warn("Tried to set a corrupt tile entity at " + position.toString() +
|
logger.warn("Tried to set a corrupt tile entity at " + position.toString()
|
||||||
": " + ((BaseBlock) block).getNbtData(), e);
|
+ ": " + ((BaseBlock) block).getNbtData(), e);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Failed to set block via adapter, falling back to generic", e);
|
logger.warn("Failed to set block via adapter, falling back to generic", e);
|
||||||
}
|
}
|
||||||
@ -535,20 +567,29 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiome(BlockVector2 position) {
|
public BiomeType getBiome(BlockVector3 position) {
|
||||||
|
if (HAS_3D_BIOMES) {
|
||||||
|
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
|
||||||
|
} else {
|
||||||
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||||
|
if (HAS_3D_BIOMES) {
|
||||||
|
getWorld().setBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ(), BukkitAdapter.adapt(biome));
|
||||||
|
} else {
|
||||||
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
|
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
return setBlock(BlockVector3.at(x,y,z), block);
|
return setBlock(BlockVector3.at(x, y, z), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -558,12 +599,12 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
return setBiome(BlockVector2.at(x,z), biome);
|
return setBiome(BlockVector2.at(x, z), biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshChunk(int X, int Z) {
|
public void refreshChunk(int chunkX, int chunkZ) {
|
||||||
getWorld().refreshChunk(X, Z);
|
getWorld().refreshChunk(chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +38,9 @@ public interface VirtualWorld extends SimpleWorld, Closeable {
|
|||||||
|
|
||||||
void close(boolean update) throws IOException;
|
void close(boolean update) throws IOException;
|
||||||
|
|
||||||
default void handleBlockInteract(Player player, BlockVector3 pos, BlockInteractEvent event) {}
|
default void handleBlockInteract(Player player, BlockVector3 pos, BlockInteractEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
default void handlePlayerInput(Player player, PlayerInputEvent event) {}
|
default void handlePlayerInput(Player player, PlayerInputEvent event) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
private ImageViewer viewer;
|
private ImageViewer viewer;
|
||||||
// Used for visualizing the world by sending chunk packets
|
// Used for visualizing the world by sending chunk packets
|
||||||
// These three variables should be set together
|
// These three variables should be set together
|
||||||
// private IQueueExtent packetQueue;
|
// private IQueueExtent packetQueue;
|
||||||
private Player player;
|
private Player player;
|
||||||
private BlockVector2 chunkOffset = BlockVector2.ZERO;
|
private BlockVector2 chunkOffset = BlockVector2.ZERO;
|
||||||
private EditSession editSession;
|
private EditSession editSession;
|
||||||
@ -895,6 +895,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
return getFolder().toPath();
|
return getFolder().toPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinY() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
|
public boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
|
||||||
// Unsupported
|
// Unsupported
|
||||||
|
@ -292,7 +292,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
return parent.setBiome(x, y , z, biome);
|
return parent.setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2925,7 +2925,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
final int[] timedOut = {0};
|
final int[] timedOut = {0};
|
||||||
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
||||||
@Override
|
@Override
|
||||||
protected BiomeType getBiome(int x, int z, BiomeType defaultBiomeType) {
|
protected BiomeType getBiome(int x, int y, int z, BiomeType defaultBiomeType) {
|
||||||
environment.setCurrentBlock(x, 0, z);
|
environment.setCurrentBlock(x, 0, z);
|
||||||
double scaledX = (x - zero2D.getX()) / unit2D.getX();
|
double scaledX = (x - zero2D.getX()) / unit2D.getX();
|
||||||
double scaledZ = (z - zero2D.getZ()) / unit2D.getZ();
|
double scaledZ = (z - zero2D.getZ()) / unit2D.getZ();
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
@ -22,6 +22,8 @@ package com.sk89q.worldedit.extent;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
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.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||||
@ -72,18 +74,51 @@ public interface OutputExtent {
|
|||||||
* @param position the (x, z) location to set the biome at
|
* @param position the (x, z) location to set the biome at
|
||||||
* @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)
|
||||||
|
* @deprecated Biomes in Minecraft are 3D now, use {@link OutputExtent#setBiome(BlockVector3, BiomeType)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonAbstractForCompatibility(
|
||||||
|
delegateName = "setBiome",
|
||||||
|
delegateParams = { int.class, int.class, int.class, BiomeType.class }
|
||||||
|
)
|
||||||
// The defaults need to remain for compatibility (the actual implementation still needs to override one of these)
|
// The defaults need to remain for compatibility (the actual implementation still needs to override one of these)
|
||||||
default boolean setBiome(int x, int y, int z, BiomeType biome) {
|
default boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||||
|
|
||||||
return setBiome(MutableBlockVector2.get(x, z), biome);
|
return setBiome(MutableBlockVector2.get(x, z), biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the light value
|
* Set the biome.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* As implementation varies per Minecraft version, this may set more than
|
||||||
|
* this position's biome. On versions prior to 1.15, this will set the entire
|
||||||
|
* column. On later versions it will set the 4x4x4 cube.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param position the (x, y, z) location to set the biome at
|
||||||
|
* @param biome the biome to set to
|
||||||
|
* @return true if the biome was successfully set (return value may not be accurate)
|
||||||
|
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||||
|
* for details
|
||||||
|
*/
|
||||||
|
@NonAbstractForCompatibility(
|
||||||
|
delegateName = "setBiome",
|
||||||
|
delegateParams = { BlockVector3.class, BiomeType.class }
|
||||||
|
)
|
||||||
|
default boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||||
|
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||||
|
|
||||||
|
return setBiome(position.toBlockVector2(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the light value.
|
||||||
*
|
*
|
||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @param value light level to set
|
* @param value light level to set
|
||||||
@ -92,10 +127,11 @@ public interface OutputExtent {
|
|||||||
setBlockLight(position.getX(), position.getY(), position.getZ(), value);
|
setBlockLight(position.getX(), position.getY(), position.getZ(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void setBlockLight(int x, int y, int z, int value) {}
|
default void setBlockLight(int x, int y, int z, int value) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the sky light value
|
* Set the sky light value.
|
||||||
*
|
*
|
||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @param value light level to set
|
* @param value light level to set
|
||||||
@ -104,7 +140,8 @@ public interface OutputExtent {
|
|||||||
setSkyLight(position.getX(), position.getY(), position.getZ(), value);
|
setSkyLight(position.getX(), position.getY(), position.getZ(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void setSkyLight(int x, int y, int z, int value) {}
|
default void setSkyLight(int x, int y, int z, int value) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -208,6 +208,16 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sub-class utilities
|
||||||
|
|
||||||
|
protected final int getWorldMinY() {
|
||||||
|
return world == null ? 0 : world.getMinY();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final int getWorldMaxY() {
|
||||||
|
return world == null ? 255 : world.getMaxY();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int worldHash = this.world == null ? 7 : this.world.hashCode();
|
int worldHash = this.world == null ? 7 : this.world.hashCode();
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -68,7 +68,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last triangle that caused a {@link #contains(BlockVector3)} to classify a point as "outside". Used for optimization.
|
* The last triangle that caused a {@link #contains(BlockVector3)}} to classify a point as "outside". Used for optimization.
|
||||||
*/
|
*/
|
||||||
private Triangle lastTriangle;
|
private Triangle lastTriangle;
|
||||||
|
|
||||||
@ -127,12 +127,14 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 vertexD = vertex.toVector3();
|
||||||
|
|
||||||
if (vertices.size() == 3) {
|
if (vertices.size() == 3) {
|
||||||
if (vertexBacklog.contains(vertex)) {
|
if (vertexBacklog.contains(vertex)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (containsRaw(vertex.toVector3())) {
|
if (containsRaw(vertexD)) {
|
||||||
return vertexBacklog.add(vertex);
|
return vertexBacklog.add(vertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +160,14 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Generate minimal mesh to start from
|
// Generate minimal mesh to start from
|
||||||
final BlockVector3[] v = vertices.toArray(new BlockVector3[vertices.size()]);
|
final BlockVector3[] v = vertices.toArray(new BlockVector3[0]);
|
||||||
|
|
||||||
triangles.add((new Triangle(v[0].toVector3(), v[1].toVector3(), v[2].toVector3())));
|
triangles.add((new Triangle(v[0].toVector3(), v[1].toVector3(), v[2].toVector3())));
|
||||||
triangles.add((new Triangle(v[0].toVector3(), v[2].toVector3(), v[1].toVector3())));
|
triangles.add((new Triangle(v[0].toVector3(), v[2].toVector3(), v[1].toVector3())));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for triangles that face the vertex and remove them
|
// Look for triangles that face the vertex and remove them
|
||||||
@ -171,7 +176,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
final Triangle triangle = it.next();
|
final Triangle triangle = it.next();
|
||||||
|
|
||||||
// If the triangle can't be seen, it's not relevant
|
// If the triangle can't be seen, it's not relevant
|
||||||
if (!triangle.above(vertex.toVector3())) {
|
if (!triangle.above(vertexD)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +196,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
|
|
||||||
// Add triangles between the remembered edges and the new vertex.
|
// Add triangles between the remembered edges and the new vertex.
|
||||||
for (Edge edge : borderEdges) {
|
for (Edge edge : borderEdges) {
|
||||||
triangles.add(edge.createTriangle(vertex.toVector3()));
|
triangles.add(edge.createTriangle(vertexD));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vertexBacklog.isEmpty()) {
|
if (!vertexBacklog.isEmpty()) {
|
||||||
@ -275,19 +280,12 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int x = position.getBlockX();
|
|
||||||
final int y = position.getBlockY();
|
|
||||||
final int z = position.getBlockZ();
|
|
||||||
|
|
||||||
final BlockVector3 min = getMinimumPoint();
|
final BlockVector3 min = getMinimumPoint();
|
||||||
final BlockVector3 max = getMaximumPoint();
|
final BlockVector3 max = getMaximumPoint();
|
||||||
|
|
||||||
if (x < min.getBlockX()) return false;
|
if (!position.containedWithin(min, max)) {
|
||||||
if (x > max.getBlockX()) return false;
|
return false;
|
||||||
if (y < min.getBlockY()) return false;
|
}
|
||||||
if (y > max.getBlockY()) return false;
|
|
||||||
if (z < min.getBlockZ()) return false;
|
|
||||||
if (z > max.getBlockZ()) return false;
|
|
||||||
|
|
||||||
return containsRaw(position.toVector3());
|
return containsRaw(position.toVector3());
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -49,7 +49,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||||
|
|
||||||
|
|
||||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
private int minX;
|
||||||
|
private int minY;
|
||||||
|
private int minZ;
|
||||||
|
private int maxX;
|
||||||
|
private int maxY;
|
||||||
|
private int maxZ;
|
||||||
private BlockVector3 pos1;
|
private BlockVector3 pos1;
|
||||||
private BlockVector3 pos2;
|
private BlockVector3 pos2;
|
||||||
|
|
||||||
@ -318,16 +323,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
final int size = (maxX - minX + 1) * (maxZ - minZ + 1);
|
final int size = (maxX - minX + 1) * (maxZ - minZ + 1);
|
||||||
|
|
||||||
return new AbstractSet<BlockVector2>() {
|
return new AbstractSet<BlockVector2>() {
|
||||||
@NotNull @Override
|
@NotNull
|
||||||
|
@Override
|
||||||
public Iterator<BlockVector2> iterator() {
|
public Iterator<BlockVector2> iterator() {
|
||||||
return new Iterator<BlockVector2>() {
|
return new Iterator<BlockVector2>() {
|
||||||
final MutableBlockVector2 mutable = new MutableBlockVector2(0, 0);
|
final MutableBlockVector2 mutable = new MutableBlockVector2(0, 0);
|
||||||
|
|
||||||
int bx = minX;
|
final int bx = minX;
|
||||||
int bz = minZ;
|
final int bz = minZ;
|
||||||
|
|
||||||
int tx = maxX;
|
final int tx = maxX;
|
||||||
int tz = maxZ;
|
final int tz = maxZ;
|
||||||
|
|
||||||
private int x = minX;
|
private int x = minX;
|
||||||
private int z = minZ;
|
private int z = minZ;
|
||||||
@ -444,16 +450,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
return new Iterator<BlockVector3>() {
|
return new Iterator<BlockVector3>() {
|
||||||
final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
||||||
private BlockVector3 min = getMinimumPoint();
|
private final BlockVector3 min = getMinimumPoint();
|
||||||
private BlockVector3 max = getMaximumPoint();
|
private final BlockVector3 max = getMaximumPoint();
|
||||||
|
|
||||||
int bx = min.getBlockX();
|
final int bx = min.getBlockX();
|
||||||
int by = min.getBlockY();
|
final int by = min.getBlockY();
|
||||||
int bz = min.getBlockZ();
|
final int bz = min.getBlockZ();
|
||||||
|
|
||||||
int tx = max.getBlockX();
|
final int tx = max.getBlockX();
|
||||||
int ty = max.getBlockY();
|
final int ty = max.getBlockY();
|
||||||
int tz = max.getBlockZ();
|
final int tz = max.getBlockZ();
|
||||||
|
|
||||||
private int x = min.getBlockX();
|
private int x = min.getBlockX();
|
||||||
private int y = min.getBlockY();
|
private int y = min.getBlockY();
|
||||||
@ -524,8 +530,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
public Iterator<BlockVector3> iterator_old() {
|
public Iterator<BlockVector3> iterator_old() {
|
||||||
final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
||||||
return new Iterator<BlockVector3>() {
|
return new Iterator<BlockVector3>() {
|
||||||
private BlockVector3 min = getMinimumPoint();
|
private final BlockVector3 min = getMinimumPoint();
|
||||||
private BlockVector3 max = getMaximumPoint();
|
private final BlockVector3 max = getMaximumPoint();
|
||||||
private int nextX = min.getBlockX();
|
private int nextX = min.getBlockX();
|
||||||
private int nextY = min.getBlockY();
|
private int nextY = min.getBlockY();
|
||||||
private int nextZ = min.getBlockZ();
|
private int nextZ = min.getBlockZ();
|
||||||
@ -546,7 +552,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
if (++nextZ > max.getBlockZ()) {
|
if (++nextZ > max.getBlockZ()) {
|
||||||
nextZ = min.getBlockZ();
|
nextZ = min.getBlockZ();
|
||||||
if (++nextY > max.getBlockY()) {
|
if (++nextY > max.getBlockY()) {
|
||||||
if (!hasNext()) throw new NoSuchElementException();
|
if (!hasNext()) {
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
nextX = max.getBlockX();
|
nextX = max.getBlockX();
|
||||||
nextZ = max.getBlockZ();
|
nextZ = max.getBlockZ();
|
||||||
nextY = max.getBlockY();
|
nextY = max.getBlockY();
|
||||||
@ -562,8 +570,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
@Override
|
@Override
|
||||||
public Iterable<BlockVector2> asFlatRegion() {
|
public Iterable<BlockVector2> asFlatRegion() {
|
||||||
return () -> new Iterator<BlockVector2>() {
|
return () -> new Iterator<BlockVector2>() {
|
||||||
private BlockVector3 min = getMinimumPoint();
|
private final BlockVector3 min = getMinimumPoint();
|
||||||
private BlockVector3 max = getMaximumPoint();
|
private final BlockVector3 max = getMaximumPoint();
|
||||||
private int nextX = min.getBlockX();
|
private int nextX = min.getBlockX();
|
||||||
private int nextZ = min.getBlockZ();
|
private int nextZ = min.getBlockZ();
|
||||||
|
|
||||||
@ -574,7 +582,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector2 next() {
|
public BlockVector2 next() {
|
||||||
if (!hasNext()) throw new NoSuchElementException();
|
if (!hasNext()) {
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
||||||
if (++nextX > max.getBlockX()) {
|
if (++nextX > max.getBlockX()) {
|
||||||
nextX = min.getBlockX();
|
nextX = min.getBlockX();
|
||||||
@ -717,13 +727,13 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
boolean trimX = lowerX != 0 || upperX != 15;
|
boolean trimX = lowerX != 0 || upperX != 15;
|
||||||
boolean trimZ = lowerZ != 0 || upperZ != 15;
|
boolean trimZ = lowerZ != 0 || upperZ != 15;
|
||||||
|
|
||||||
int indexY, index;
|
|
||||||
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
char[] arr = set.load(layer);
|
char[] arr = set.load(layer);
|
||||||
if (trimX || trimZ) {
|
if (trimX || trimZ) {
|
||||||
indexY = 0;
|
int indexY = 0;
|
||||||
for (int y = 0; y < 16; y++, indexY += 256) {
|
for (int y = 0; y < 16; y++, indexY += 256) {
|
||||||
|
int index;
|
||||||
if (trimZ) {
|
if (trimZ) {
|
||||||
index = indexY;
|
index = indexY;
|
||||||
for (int z = 0; z < lowerZ; z++) {
|
for (int z = 0; z < lowerZ; z++) {
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.Vector3;
|
|||||||
import com.sk89q.worldedit.math.geom.Polygons;
|
import com.sk89q.worldedit.math.geom.Polygons;
|
||||||
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
||||||
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -54,7 +55,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
private boolean hasY = false;
|
private boolean hasY = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the region
|
* Construct the region.
|
||||||
*/
|
*/
|
||||||
public CylinderRegion() {
|
public CylinderRegion() {
|
||||||
this((World) null);
|
this((World) null);
|
||||||
@ -116,7 +117,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the main center point of the region
|
* Sets the main center point of the region.
|
||||||
*
|
*
|
||||||
* @param center the center point
|
* @param center the center point
|
||||||
*/
|
*/
|
||||||
@ -125,7 +126,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the radius of the cylinder
|
* Returns the radius of the cylinder.
|
||||||
*
|
*
|
||||||
* @return the radius along the X and Z axes
|
* @return the radius along the X and Z axes
|
||||||
*/
|
*/
|
||||||
@ -134,7 +135,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the radius of the cylinder
|
* Sets the radius of the cylinder.
|
||||||
*
|
*
|
||||||
* @param radius the radius along the X and Z axes
|
* @param radius the radius along the X and Z axes
|
||||||
*/
|
*/
|
||||||
@ -144,7 +145,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the radius to be at least the given radius
|
* Extends the radius to be at least the given radius.
|
||||||
*
|
*
|
||||||
* @param minRadius the minimum radius
|
* @param minRadius the minimum radius
|
||||||
*/
|
*/
|
||||||
@ -233,7 +234,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((diff.getBlockX() & 1) + (diff.getBlockZ() & 1) != 0) {
|
if ((diff.getBlockX() & 1) + (diff.getBlockZ() & 1) != 0) {
|
||||||
throw new RegionOperationException("Cylinders changes must be even for each horizontal dimensions.");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.cylinder.error.even-horizontal"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return diff.divide(2).floor();
|
return diff.divide(2).floor();
|
||||||
@ -253,7 +254,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
* Expand the region.
|
* Expand the region.
|
||||||
*
|
*
|
||||||
* @param changes array/arguments with multiple related changes
|
* @param changes array/arguments with multiple related changes
|
||||||
* @throws RegionOperationException
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
@ -375,7 +375,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns string representation in the format
|
* Returns string representation in the format.
|
||||||
* "(centerX, centerZ) - (radiusX, radiusZ) - (minY, maxY)"
|
* "(centerX, centerZ) - (radiusX, radiusZ) - (minY, maxY)"
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -29,6 +29,7 @@ import com.boydti.fawe.util.MathMan;
|
|||||||
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.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||||
|
|
||||||
@ -125,8 +126,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
BlockVector3 diff = BlockVector3.ZERO.add(changes);
|
BlockVector3 diff = BlockVector3.ZERO.add(changes);
|
||||||
|
|
||||||
if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) {
|
if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) {
|
||||||
throw new RegionOperationException(
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.ellipsoid.error.even-horizontal"));
|
||||||
"Ellipsoid changes must be even for each dimensions.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return diff.divide(2).floor();
|
return diff.divide(2).floor();
|
||||||
@ -214,8 +214,10 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunks.add(
|
chunks.add(BlockVector2.at(
|
||||||
BlockVector2.at(x >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS));
|
x >> ChunkStore.CHUNK_SHIFTS,
|
||||||
|
z >> ChunkStore.CHUNK_SHIFTS
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,10 +349,9 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
if (remainderZ < 0) {
|
if (remainderZ < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int diffX, minX, maxX;
|
int diffX = (int) Math.floor(Math.sqrt(remainderZ));
|
||||||
diffX = (int) Math.floor(Math.sqrt(remainderZ));
|
int minX = Math.max(0, cx - diffX - bx);
|
||||||
minX = Math.max(0, cx - diffX - bx);
|
int maxX = Math.min(15, cx + diffX - bx);
|
||||||
maxX = Math.min(15, cx + diffX - bx);
|
|
||||||
block.filter(filter, minX, y, z, maxX, y, z);
|
block.filter(filter, minX, y, z, maxX, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,17 +372,15 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
|
|
||||||
int cx1 = Math.abs(bx - cx);
|
int cx1 = Math.abs(bx - cx);
|
||||||
int cx2 = Math.abs(tx - cx);
|
int cx2 = Math.abs(tx - cx);
|
||||||
int cxMax, cxMin;
|
int cxMin = Math.min(cx1, cx2);
|
||||||
cxMin = Math.min(cx1, cx2);
|
int cxMax = Math.max(cx1, cx2);
|
||||||
cxMax = Math.max(cx1, cx2);
|
|
||||||
int cxMin2 = cxMin * cxMin;
|
int cxMin2 = cxMin * cxMin;
|
||||||
int cxMax2 = cxMax * cxMax;
|
int cxMax2 = cxMax * cxMax;
|
||||||
|
|
||||||
int cz1 = Math.abs(bz - cz);
|
int cz1 = Math.abs(bz - cz);
|
||||||
int cz2 = Math.abs(tz - cz);
|
int cz2 = Math.abs(tz - cz);
|
||||||
int czMax, czMin;
|
int czMin = Math.min(cz1, cz2);
|
||||||
czMin = Math.min(cz1, cz2);
|
int czMax = Math.max(cz1, cz2);
|
||||||
czMax = Math.max(cz1, cz2);
|
|
||||||
int czMin2 = czMin * czMin;
|
int czMin2 = czMin * czMin;
|
||||||
int czMax2 = czMax * czMax;
|
int czMax2 = czMax * czMax;
|
||||||
|
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -24,14 +24,14 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
public interface FlatRegion extends Region {
|
public interface FlatRegion extends Region {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the minimum Y value
|
* Gets the minimum Y value.
|
||||||
*
|
*
|
||||||
* @return the Y value
|
* @return the Y value
|
||||||
*/
|
*/
|
||||||
int getMinimumY();
|
int getMinimumY();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum Y value
|
* Gets the maximum Y value.
|
||||||
*
|
*
|
||||||
* @return the Y value
|
* @return the Y value
|
||||||
*/
|
*/
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -22,6 +22,7 @@ package com.sk89q.worldedit.regions;
|
|||||||
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.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -74,17 +75,17 @@ public class NullRegion implements Region {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
throw new RegionOperationException("Cannot change NullRegion");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.null.error.immutable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||||
throw new RegionOperationException("Cannot change NullRegion");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.null.error.immutable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||||
throw new RegionOperationException("Cannot change NullRegion");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.null.error.immutable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -23,6 +23,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
||||||
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -45,7 +46,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
private boolean hasY = false;
|
private boolean hasY = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the region
|
* Construct the region.
|
||||||
*/
|
*/
|
||||||
public Polygonal2DRegion() {
|
public Polygonal2DRegion() {
|
||||||
this((World) null);
|
this((World) null);
|
||||||
@ -118,10 +119,18 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
for (BlockVector2 v : points) {
|
for (BlockVector2 v : points) {
|
||||||
int x = v.getBlockX();
|
int x = v.getBlockX();
|
||||||
int z = v.getBlockZ();
|
int z = v.getBlockZ();
|
||||||
if (x < minX) minX = x;
|
if (x < minX) {
|
||||||
if (z < minZ) minZ = z;
|
minX = x;
|
||||||
if (x > maxX) maxX = x;
|
}
|
||||||
if (z > maxZ) maxZ = z;
|
if (z < minZ) {
|
||||||
|
minZ = z;
|
||||||
|
}
|
||||||
|
if (x > maxX) {
|
||||||
|
maxX = x;
|
||||||
|
}
|
||||||
|
if (z > maxZ) {
|
||||||
|
maxZ = z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldMinY = minY;
|
int oldMinY = minY;
|
||||||
@ -129,8 +138,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
minY = Math.min(oldMinY, oldMaxY);
|
minY = Math.min(oldMinY, oldMaxY);
|
||||||
maxY = Math.max(oldMinY, oldMaxY);
|
maxY = Math.max(oldMinY, oldMaxY);
|
||||||
|
|
||||||
minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY());
|
minY = Math.min(Math.max(getWorldMinY(), minY), getWorldMaxY());
|
||||||
maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY());
|
maxY = Math.min(Math.max(getWorldMinY(), maxY), getWorldMaxY());
|
||||||
|
|
||||||
min = BlockVector2.at(minX, minZ);
|
min = BlockVector2.at(minX, minZ);
|
||||||
max = BlockVector2.at(maxX, maxZ);
|
max = BlockVector2.at(maxX, maxZ);
|
||||||
@ -201,7 +210,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
@Override
|
@Override
|
||||||
public long getVolume() {
|
public long getVolume() {
|
||||||
long area = 0;
|
long area = 0;
|
||||||
int i, j = points.size() - 1;
|
int i;
|
||||||
|
int j = points.size() - 1;
|
||||||
|
|
||||||
for (i = 0; i < points.size(); ++i) {
|
for (i = 0; i < points.size(); ++i) {
|
||||||
long x = points.get(j).getBlockX() + points.get(i).getBlockX();
|
long x = points.get(j).getBlockX() + points.get(i).getBlockX();
|
||||||
@ -236,7 +246,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
for (BlockVector3 change : changes) {
|
for (BlockVector3 change : changes) {
|
||||||
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
||||||
throw new RegionOperationException("Polygons can only be expanded vertically.");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.polygon2d.error.expand-only-vertical"));
|
||||||
}
|
}
|
||||||
int changeY = change.getBlockY();
|
int changeY = change.getBlockY();
|
||||||
if (changeY > 0) {
|
if (changeY > 0) {
|
||||||
@ -252,7 +262,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||||
for (BlockVector3 change : changes) {
|
for (BlockVector3 change : changes) {
|
||||||
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
||||||
throw new RegionOperationException("Polygons can only be contracted vertically.");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.polygon2d.error.contract-only-vertical"));
|
||||||
}
|
}
|
||||||
int changeY = change.getBlockY();
|
int changeY = change.getBlockY();
|
||||||
if (changeY > 0) {
|
if (changeY > 0) {
|
||||||
@ -285,10 +295,14 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
public boolean contains(int targetX, int targetZ) {
|
public boolean contains(int targetX, int targetZ) {
|
||||||
boolean inside = false;
|
boolean inside = false;
|
||||||
int npoints = points.size();
|
int npoints = points.size();
|
||||||
int xNew, zNew;
|
int xNew;
|
||||||
int xOld, zOld;
|
int zNew;
|
||||||
int x1, z1;
|
int xOld;
|
||||||
int x2, z2;
|
int zOld;
|
||||||
|
int x1;
|
||||||
|
int z1;
|
||||||
|
int x2;
|
||||||
|
int z2;
|
||||||
long crossproduct;
|
long crossproduct;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -317,7 +331,9 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
crossproduct = ((long) targetZ - (long) z1) * (long) (x2 - x1)
|
crossproduct = ((long) targetZ - (long) z1) * (long) (x2 - x1)
|
||||||
- ((long) z2 - (long) z1) * (long) (targetX - x1);
|
- ((long) z2 - (long) z1) * (long) (targetX - x1);
|
||||||
if (crossproduct == 0) {
|
if (crossproduct == 0) {
|
||||||
if ((z1 <= targetZ) == (targetZ <= z2)) return true; //on edge
|
if ((z1 <= targetZ) == (targetZ <= z2)) {
|
||||||
|
return true; //on edge
|
||||||
|
}
|
||||||
} else if (crossproduct < 0 && (x1 != targetX)) {
|
} else if (crossproduct < 0 && (x1 != targetX)) {
|
||||||
inside = !inside;
|
inside = !inside;
|
||||||
}
|
}
|
||||||
@ -357,15 +373,17 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
|
|
||||||
boolean inside = false;
|
boolean inside = false;
|
||||||
int npoints = points.size();
|
int npoints = points.size();
|
||||||
int xNew, zNew;
|
int xNew;
|
||||||
int xOld, zOld;
|
int zNew;
|
||||||
int x1, z1;
|
int x1;
|
||||||
int x2, z2;
|
int z1;
|
||||||
|
int x2;
|
||||||
|
int z2;
|
||||||
long crossproduct;
|
long crossproduct;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
xOld = points.get(npoints - 1).getBlockX();
|
int xOld = points.get(npoints - 1).getBlockX();
|
||||||
zOld = points.get(npoints - 1).getBlockZ();
|
int zOld = points.get(npoints - 1).getBlockZ();
|
||||||
|
|
||||||
for (i = 0; i < npoints; ++i) {
|
for (i = 0; i < npoints; ++i) {
|
||||||
xNew = points.get(i).getBlockX();
|
xNew = points.get(i).getBlockX();
|
||||||
@ -389,7 +407,9 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
crossproduct = ((long) targetZ - (long) z1) * (long) (x2 - x1)
|
crossproduct = ((long) targetZ - (long) z1) * (long) (x2 - x1)
|
||||||
- ((long) z2 - (long) z1) * (long) (targetX - x1);
|
- ((long) z2 - (long) z1) * (long) (targetX - x1);
|
||||||
if (crossproduct == 0) {
|
if (crossproduct == 0) {
|
||||||
if ((z1 <= targetZ) == (targetZ <= z2)) return true; //on edge
|
if ((z1 <= targetZ) == (targetZ <= z2)) {
|
||||||
|
return true; //on edge
|
||||||
|
}
|
||||||
} else if (crossproduct < 0 && (x1 != targetX)) {
|
} else if (crossproduct < 0 && (x1 != targetX)) {
|
||||||
inside = !inside;
|
inside = !inside;
|
||||||
}
|
}
|
||||||
@ -457,7 +477,9 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
BlockVector2 current = it.next();
|
BlockVector2 current = it.next();
|
||||||
sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")");
|
sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")");
|
||||||
if (it.hasNext()) sb.append(" - ");
|
if (it.hasNext()) {
|
||||||
|
sb.append(" - ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.append(" * (").append(minY).append(" - ").append(maxY).append(")");
|
sb.append(" * (").append(minY).append(" - ").append(maxY).append(")");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@ -482,16 +504,24 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
@Override
|
@Override
|
||||||
public boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
public boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
||||||
for (int x = bx; x <= tx; x++) {
|
for (int x = bx; x <= tx; x++) {
|
||||||
if (!contains(x, 0, bz)) return false;
|
if (!contains(x, 0, bz)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int x = bx; x <= tx; x++) {
|
for (int x = bx; x <= tx; x++) {
|
||||||
if (!contains(x, 0, tz)) return false;
|
if (!contains(x, 0, tz)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int z = bz; z <= tz; z++) {
|
for (int z = bz; z <= tz; z++) {
|
||||||
if (!contains(bx, 0, z)) return false;
|
if (!contains(bx, 0, z)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int z = bz; z <= tz; z++) {
|
for (int z = bz; z <= tz; z++) {
|
||||||
if (!contains(tx, 0, z)) return false;
|
if (!contains(tx, 0, z)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -28,6 +28,8 @@ import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
|||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
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.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
@ -85,19 +87,17 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
/**
|
/**
|
||||||
* Get the number of blocks in the region.
|
* Get the number of blocks in the region.
|
||||||
*
|
*
|
||||||
* <p>Note: This method <b>must</b> be overridden.</p>
|
|
||||||
*
|
|
||||||
* @return number of blocks
|
* @return number of blocks
|
||||||
|
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||||
|
* for details
|
||||||
*/
|
*/
|
||||||
|
@NonAbstractForCompatibility(
|
||||||
|
delegateName = "getArea",
|
||||||
|
delegateParams = {}
|
||||||
|
)
|
||||||
default long getVolume() {
|
default long getVolume() {
|
||||||
// TODO Remove default status when getArea is removed.
|
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||||
try {
|
|
||||||
if (getClass().getMethod("getArea").getDeclaringClass().equals(Region.class)) {
|
|
||||||
throw new IllegalStateException("Class " + getClass().getName() + " must override getVolume.");
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
return getArea();
|
return getArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
* Expand the region.
|
* Expand the region.
|
||||||
*
|
*
|
||||||
* @param changes array/arguments with multiple related changes
|
* @param changes array/arguments with multiple related changes
|
||||||
* @throws RegionOperationException
|
* @throws RegionOperationException if the operation cannot be performed
|
||||||
*/
|
*/
|
||||||
void expand(BlockVector3... changes) throws RegionOperationException;
|
void expand(BlockVector3... changes) throws RegionOperationException;
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
* Contract the region.
|
* Contract the region.
|
||||||
*
|
*
|
||||||
* @param changes array/arguments with multiple related changes
|
* @param changes array/arguments with multiple related changes
|
||||||
* @throws RegionOperationException
|
* @throws RegionOperationException if the operation cannot be performed
|
||||||
*/
|
*/
|
||||||
void contract(BlockVector3... changes) throws RegionOperationException;
|
void contract(BlockVector3... changes) throws RegionOperationException;
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
* Shift the region.
|
* Shift the region.
|
||||||
*
|
*
|
||||||
* @param change the change
|
* @param change the change
|
||||||
* @throws RegionOperationException
|
* @throws RegionOperationException if the operation cannot be performed
|
||||||
*/
|
*/
|
||||||
void shift(BlockVector3 change) throws RegionOperationException;
|
void shift(BlockVector3 change) throws RegionOperationException;
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
Set<BlockVector2> getChunks();
|
Set<BlockVector2> getChunks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of 16*16*16 chunks in a region
|
* Return a list of 16*16*16 chunks in a region.
|
||||||
*
|
*
|
||||||
* @return the chunk cubes this region overlaps with
|
* @return the chunk cubes this region overlaps with
|
||||||
*/
|
*/
|
||||||
@ -232,7 +232,9 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
int maxSection = Math.min(15, getMaximumY() >> 4);
|
int maxSection = Math.min(15, getMaximumY() >> 4);
|
||||||
block = block.initChunk(chunk.getX(), chunk.getZ());
|
block = block.initChunk(chunk.getX(), chunk.getZ());
|
||||||
for (int layer = minSection; layer <= maxSection; layer++) {
|
for (int layer = minSection; layer <= maxSection; layer++) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
block = block.initLayer(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter, this);
|
block.filter(filter, this);
|
||||||
}
|
}
|
||||||
@ -264,32 +266,38 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, boolean full) {
|
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, boolean full) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
block = block.initLayer(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter);
|
block.filter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean full) {
|
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean full) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
block = block.initLayer(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter, minX, minY, minZ, maxX, maxY, maxZ);
|
block.filter(filter, minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd, boolean full) {
|
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set, int layer, int yStart, int yEnd, boolean full) {
|
||||||
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) return;
|
if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(chunk, layer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
block = block.initLayer(get, set, layer);
|
block = block.initLayer(get, set, layer);
|
||||||
block.filter(filter, yStart, yEnd);
|
block.filter(filter, yStart, yEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
default boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
||||||
return contains(bx, by, bz) &&
|
return contains(bx, by, bz)
|
||||||
contains(bx, by, tz) &&
|
&& contains(bx, by, tz)
|
||||||
contains(tx, by, bz) &&
|
&& contains(tx, by, bz)
|
||||||
contains(tx, by, tz) &&
|
&& contains(tx, by, tz)
|
||||||
contains(bx, ty, bz) &&
|
&& contains(bx, ty, bz)
|
||||||
contains(bx, ty, tz) &&
|
&& contains(bx, ty, tz)
|
||||||
contains(tx, ty, bz) &&
|
&& contains(tx, ty, bz)
|
||||||
contains(tx, ty, tz);
|
&& contains(tx, ty, tz);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean containsChunk(int chunkX, int chunkZ) {
|
default boolean containsChunk(int chunkX, int chunkZ) {
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -26,6 +26,7 @@ import com.google.common.collect.Iterators;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
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.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -115,13 +116,13 @@ public class RegionIntersection extends AbstractRegion {
|
|||||||
@Override
|
@Override
|
||||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
checkNotNull(changes);
|
checkNotNull(changes);
|
||||||
throw new RegionOperationException("Cannot expand a region intersection");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.intersection.error.cannot-expand"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||||
checkNotNull(changes);
|
checkNotNull(changes);
|
||||||
throw new RegionOperationException("Cannot contract a region intersection");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.intersection.error.cannot-contract"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,14 +138,10 @@ public class RegionIntersection extends AbstractRegion {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked"})
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
Iterator<BlockVector3>[] iterators = (Iterator<BlockVector3>[]) new Iterator[regions.size()];
|
return Iterators.concat(Iterators.transform(regions.iterator(), r -> r.iterator()));
|
||||||
for (int i = 0; i < regions.size(); i++) {
|
|
||||||
iterators[i] = regions.get(i).iterator();
|
|
||||||
}
|
|
||||||
return Iterators.concat(iterators);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -205,19 +202,31 @@ public class RegionIntersection extends AbstractRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsChunk(int chunkX, int chunkZ) {
|
public boolean containsChunk(int chunkX, int chunkZ) {
|
||||||
for (Region region : regions) if (region.containsChunk(chunkX, chunkZ)) return true;
|
for (Region region : regions) {
|
||||||
|
if (region.containsChunk(chunkX, chunkZ)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int z) {
|
public boolean contains(int x, int z) {
|
||||||
for (Region region : regions) if (region.contains(x, z)) return true;
|
for (Region region : regions) {
|
||||||
|
if (region.contains(x, z)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
for (Region region : regions) if (region.contains(x, y, z)) return true;
|
for (Region region : regions) {
|
||||||
|
if (region.contains(x, y, z)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,28 +3,34 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
|
|
||||||
public class RegionOperationException extends WorldEditException {
|
public class RegionOperationException extends WorldEditException {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public RegionOperationException(String msg) {
|
public RegionOperationException(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RegionOperationException(Component msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -23,6 +23,8 @@ import com.google.common.collect.Lists;
|
|||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.internal.util.DeprecationUtil;
|
||||||
|
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
@ -144,19 +146,17 @@ public interface RegionSelector {
|
|||||||
/**
|
/**
|
||||||
* Get the number of blocks inside the region.
|
* Get the number of blocks inside the region.
|
||||||
*
|
*
|
||||||
* <p>Note: This method <b>must</b> be overridden.</p>
|
|
||||||
*
|
|
||||||
* @return number of blocks, or -1 if undefined
|
* @return number of blocks, or -1 if undefined
|
||||||
|
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||||
|
* for details
|
||||||
*/
|
*/
|
||||||
|
@NonAbstractForCompatibility(
|
||||||
|
delegateName = "getArea",
|
||||||
|
delegateParams = {}
|
||||||
|
)
|
||||||
default long getVolume() {
|
default long getVolume() {
|
||||||
// TODO Remove default once getArea is removed
|
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||||
try {
|
|
||||||
if (getClass().getMethod("getArea").getDeclaringClass().equals(RegionSelector.class)) {
|
|
||||||
throw new IllegalStateException("Class " + getClass().getName() + " must override getVolume.");
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
return getArea();
|
return getArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ public interface RegionSelector {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
default List<String> getInformationLines() {
|
default List<String> getInformationLines() {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get lines of information about the selection.
|
* Get lines of information about the selection.
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
@ -24,6 +24,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.Identity;
|
import com.sk89q.worldedit.math.transform.Identity;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -133,17 +134,17 @@ public class TransformRegion extends AbstractRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
throw new RegionOperationException("Can't expand a TransformedRegion");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.transform.error.cannot-expand"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||||
throw new RegionOperationException("Can't contract a TransformedRegion");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.transform.error.cannot-contract"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||||
throw new RegionOperationException("Can't change a TransformedRegion");
|
throw new RegionOperationException(TranslatableComponent.of("worldedit.selection.transform.error.cannot-change"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.factory;
|
package com.sk89q.worldedit.regions.factory;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.factory;
|
package com.sk89q.worldedit.regions.factory;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.factory;
|
package com.sk89q.worldedit.regions.factory;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.factory;
|
package com.sk89q.worldedit.regions.factory;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.iterator;
|
package com.sk89q.worldedit.regions.iterator;
|
||||||
@ -30,9 +30,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
public class FlatRegion3DIterator implements Iterator<BlockVector3> {
|
public class FlatRegion3DIterator implements Iterator<BlockVector3> {
|
||||||
|
|
||||||
private Iterator<BlockVector2> flatIterator;
|
private final Iterator<BlockVector2> flatIterator;
|
||||||
private int minY;
|
private final int minY;
|
||||||
private int maxY;
|
private final int maxY;
|
||||||
|
|
||||||
private BlockVector2 next2D;
|
private BlockVector2 next2D;
|
||||||
private int nextY;
|
private int nextY;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.iterator;
|
package com.sk89q.worldedit.regions.iterator;
|
||||||
@ -30,13 +30,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
public class FlatRegionIterator implements Iterator<BlockVector2> {
|
public class FlatRegionIterator implements Iterator<BlockVector2> {
|
||||||
|
|
||||||
private Region region;
|
private final Region region;
|
||||||
private int y;
|
private final int y;
|
||||||
private int minX;
|
private final int minX;
|
||||||
|
private final int maxX;
|
||||||
|
private final int maxZ;
|
||||||
private int nextX;
|
private int nextX;
|
||||||
private int nextZ;
|
private int nextZ;
|
||||||
private int maxX;
|
|
||||||
private int maxZ;
|
|
||||||
|
|
||||||
public FlatRegionIterator(Region region) {
|
public FlatRegionIterator(Region region) {
|
||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.iterator;
|
package com.sk89q.worldedit.regions.iterator;
|
||||||
@ -68,7 +68,9 @@ public class RegionIterator implements Iterator<BlockVector3> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 next() {
|
public BlockVector3 next() {
|
||||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
if (!hasNext()) {
|
||||||
|
throw new java.util.NoSuchElementException();
|
||||||
|
}
|
||||||
|
|
||||||
BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ);
|
BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ);
|
||||||
|
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.polyhedron;
|
package com.sk89q.worldedit.regions.polyhedron;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.polyhedron;
|
package com.sk89q.worldedit.regions.polyhedron;
|
||||||
@ -28,10 +28,10 @@ public class Triangle {
|
|||||||
private String tag = "Triangle";
|
private String tag = "Triangle";
|
||||||
private final Vector3[] vertices;
|
private final Vector3[] vertices;
|
||||||
private final Vector3 normal;
|
private final Vector3 normal;
|
||||||
private final double b;
|
private final double maxDotProduct;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a triangle with the given vertices (counter-clockwise)
|
* Constructs a triangle with the given vertices (counter-clockwise).
|
||||||
*
|
*
|
||||||
* @param v0 first vertex
|
* @param v0 first vertex
|
||||||
* @param v1 second vertex
|
* @param v1 second vertex
|
||||||
@ -45,7 +45,7 @@ public class Triangle {
|
|||||||
vertices = new Vector3[] { v0, v1, v2 };
|
vertices = new Vector3[] { v0, v1, v2 };
|
||||||
|
|
||||||
this.normal = v1.subtract(v0).cross(v2.subtract(v0)).normalize();
|
this.normal = v1.subtract(v0).cross(v2.subtract(v0)).normalize();
|
||||||
this.b = Math.max(Math.max(normal.dot(v0), normal.dot(v1)), normal.dot(v2));
|
this.maxDotProduct = Math.max(Math.max(normal.dot(v0), normal.dot(v1)), normal.dot(v2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +79,7 @@ public class Triangle {
|
|||||||
*/
|
*/
|
||||||
public boolean below(Vector3 pt) {
|
public boolean below(Vector3 pt) {
|
||||||
checkNotNull(pt);
|
checkNotNull(pt);
|
||||||
return normal.dot(pt) < b;
|
return normal.dot(pt) < maxDotProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +90,7 @@ public class Triangle {
|
|||||||
*/
|
*/
|
||||||
public boolean above(Vector3 pt) {
|
public boolean above(Vector3 pt) {
|
||||||
checkNotNull(pt);
|
checkNotNull(pt);
|
||||||
return normal.dot(pt) > b;
|
return normal.dot(pt) > maxDotProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
@ -51,7 +51,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
*/
|
*/
|
||||||
public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||||
|
|
||||||
protected static transient final NumberFormat NUMBER_FORMAT;
|
protected static final transient NumberFormat NUMBER_FORMAT;
|
||||||
protected transient CylinderRegion region;
|
protected transient CylinderRegion region;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
@ -122,9 +122,9 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
|||||||
region.setPos1(position1);
|
region.setPos1(position1);
|
||||||
region.setPos2(position2);
|
region.setPos2(position2);
|
||||||
|
|
||||||
assert(region.contains(o1));
|
assert region.contains(o1);
|
||||||
assert(region.contains(o2));
|
assert region.contains(o2);
|
||||||
assert(region.contains(position));
|
assert region.contains(position);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector;
|
package com.sk89q.worldedit.regions.selector;
|
||||||
@ -53,7 +53,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new selector from another one
|
* Create a new selector from another one.
|
||||||
*
|
*
|
||||||
* @param oldSelector the old selector
|
* @param oldSelector the old selector
|
||||||
*/
|
*/
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector.limit;
|
package com.sk89q.worldedit.regions.selector.limit;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.selector.limit;
|
package com.sk89q.worldedit.regions.selector.limit;
|
||||||
|
@ -3,76 +3,75 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.shape;
|
package com.sk89q.worldedit.regions.shape;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
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.Region;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates solid and hollow shapes according to materials returned by the
|
* Generates solid and hollow shapes according to materials returned by the
|
||||||
* {@link #getBiome} method.
|
* {@link #getBiome} method.
|
||||||
*/
|
*/
|
||||||
public abstract class ArbitraryBiomeShape {
|
public abstract class ArbitraryBiomeShape {
|
||||||
|
|
||||||
private final FlatRegion extent;
|
private final Region extent;
|
||||||
private int cacheOffsetX;
|
private final int cacheOffsetX;
|
||||||
private int cacheOffsetZ;
|
private final int cacheOffsetY;
|
||||||
|
private final int cacheOffsetZ;
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
private int cacheSizeX;
|
private final int cacheSizeX;
|
||||||
private int cacheSizeZ;
|
private final int cacheSizeY;
|
||||||
|
private final int cacheSizeZ;
|
||||||
public ArbitraryBiomeShape(Region extent) {
|
|
||||||
if (extent instanceof FlatRegion) {
|
|
||||||
this.extent = (FlatRegion) extent;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO: polygonize
|
|
||||||
this.extent = new CuboidRegion(extent.getWorld(), extent.getMinimumPoint(), extent.getMaximumPoint());
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockVector2 min = extent.getMinimumPoint().toBlockVector2();
|
|
||||||
BlockVector2 max = extent.getMaximumPoint().toBlockVector2();
|
|
||||||
|
|
||||||
cacheOffsetX = min.getBlockX() - 1;
|
|
||||||
cacheOffsetZ = min.getBlockZ() - 1;
|
|
||||||
|
|
||||||
cacheSizeX = max.getX() - cacheOffsetX + 2;
|
|
||||||
cacheSizeZ = max.getZ() - cacheOffsetZ + 2;
|
|
||||||
|
|
||||||
cache = new BiomeType[cacheSizeX * cacheSizeZ];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Iterable<BlockVector2> getExtent() {
|
|
||||||
return extent.asFlatRegion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache entries:
|
* Cache entries.
|
||||||
* null = unknown
|
* null = unknown
|
||||||
* OUTSIDE = outside
|
* OUTSIDE = outside
|
||||||
* else = inside
|
* else = inside
|
||||||
*/
|
*/
|
||||||
private final BiomeType[] cache;
|
private final BiomeType[] cache;
|
||||||
|
private final BitSet isCached;
|
||||||
|
|
||||||
|
public ArbitraryBiomeShape(Region extent) {
|
||||||
|
this.extent = extent;
|
||||||
|
|
||||||
|
BlockVector3 min = extent.getMinimumPoint();
|
||||||
|
BlockVector3 max = extent.getMaximumPoint();
|
||||||
|
|
||||||
|
cacheOffsetX = min.getBlockX() - 1;
|
||||||
|
cacheOffsetY = min.getBlockY() - 1;
|
||||||
|
cacheOffsetZ = min.getBlockZ() - 1;
|
||||||
|
|
||||||
|
cacheSizeX = max.getX() - cacheOffsetX + 2;
|
||||||
|
cacheSizeY = max.getY() - cacheOffsetY + 2;
|
||||||
|
cacheSizeZ = max.getZ() - cacheOffsetZ + 2;
|
||||||
|
|
||||||
|
cache = new BiomeType[cacheSizeX * cacheSizeY * cacheSizeZ];
|
||||||
|
isCached = new BitSet(cache.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Iterable<BlockVector3> getExtent() {
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this function to specify the shape to generate.
|
* Override this function to specify the shape to generate.
|
||||||
@ -82,44 +81,37 @@ 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 BiomeType getBiome(int x, int z, BiomeType defaultBaseBiome);
|
protected abstract BiomeType getBiome(int x, int y, int z, BiomeType defaultBaseBiome);
|
||||||
|
|
||||||
private BiomeType getBiomeCached(int x, int z, BiomeType baseBiome) {
|
private BiomeType getBiomeCached(int x, int y, int z, BiomeType baseBiome) {
|
||||||
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
final int index = (y - cacheOffsetY) + (z - cacheOffsetZ) * cacheSizeY + (x - cacheOffsetX) * cacheSizeY * cacheSizeZ;
|
||||||
|
|
||||||
final BiomeType cacheEntry = cache[index];
|
|
||||||
if (cacheEntry == null) {// unknown, fetch material
|
|
||||||
final BiomeType material = getBiome(x, z, baseBiome);
|
|
||||||
if (material == null) {
|
|
||||||
// outside
|
|
||||||
cache[index] = BiomeTypes.THE_VOID;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!isCached.get(index)) {
|
||||||
|
final BiomeType material = getBiome(x, y, z, baseBiome);
|
||||||
|
isCached.set(index);
|
||||||
cache[index] = material;
|
cache[index] = material;
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cacheEntry == BiomeTypes.THE_VOID) {
|
return cache[index];
|
||||||
// outside
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cacheEntry;
|
private boolean isInsideCached(int x, int y, int z, BiomeType baseBiome) {
|
||||||
}
|
final int index = (y - cacheOffsetY) + (z - cacheOffsetZ) * cacheSizeY + (x - cacheOffsetX) * cacheSizeY * cacheSizeZ;
|
||||||
|
|
||||||
private boolean isInsideCached(int x, int z, BiomeType baseBiome) {
|
|
||||||
final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ;
|
|
||||||
|
|
||||||
final BiomeType 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, y, z, baseBiome) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cacheEntry != BiomeTypes.THE_VOID;
|
return cacheEntry != BiomeTypes.THE_VOID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isOutside(int x, int y, int z, BiomeType baseBiome) {
|
||||||
|
return getBiomeCached(x, y, z, baseBiome) == null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the shape.
|
* Generates the shape.
|
||||||
*
|
*
|
||||||
@ -131,13 +123,14 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) {
|
public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (BlockVector2 position : getExtent()) {
|
for (BlockVector3 position : getExtent()) {
|
||||||
int x = position.getBlockX();
|
int x = position.getBlockX();
|
||||||
|
int y = position.getBlockY();
|
||||||
int z = position.getBlockZ();
|
int z = position.getBlockZ();
|
||||||
|
|
||||||
if (!hollow) {
|
if (!hollow) {
|
||||||
final BiomeType material = getBiome(x, z, baseBiome);
|
final BiomeType material = getBiome(x, y, z, baseBiome);
|
||||||
if (material != null && material != BiomeTypes.THE_VOID) {
|
if (material != null) {
|
||||||
editSession.getWorld().setBiome(position, material);
|
editSession.getWorld().setBiome(position, material);
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
@ -145,32 +138,12 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final BiomeType material = getBiomeCached(x, z, baseBiome);
|
final BiomeType material = getBiomeCached(x, y, z, baseBiome);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean draw = false;
|
if (!shouldDraw(x, y, z, material)) {
|
||||||
do {
|
|
||||||
if (!isInsideCached(x + 1, z, baseBiome)) {
|
|
||||||
draw = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isInsideCached(x - 1, z, baseBiome)) {
|
|
||||||
draw = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isInsideCached(x, z + 1, baseBiome)) {
|
|
||||||
draw = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isInsideCached(x, z - 1, baseBiome)) {
|
|
||||||
draw = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (false);
|
|
||||||
|
|
||||||
if (!draw) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,4 +154,25 @@ public abstract class ArbitraryBiomeShape {
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldDraw(int x, int y, int z, BiomeType material) {
|
||||||
|
// we should draw this if the surrounding blocks fall outside the shape,
|
||||||
|
// this position will form an edge of the hull
|
||||||
|
if (isOutside(x + 1, y, z, material)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isOutside(x - 1, y, z, material)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isOutside(x, y, z + 1, material)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isOutside(x, y, z - 1, material)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isOutside(x, y + 1, z, material)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return isOutside(x, y - 1, z, material);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.shape;
|
package com.sk89q.worldedit.regions.shape;
|
||||||
@ -34,18 +34,22 @@ public abstract class ArbitraryShape {
|
|||||||
|
|
||||||
protected final Region extent;
|
protected final Region extent;
|
||||||
|
|
||||||
private int cacheOffsetX;
|
private final int cacheOffsetX;
|
||||||
private int cacheOffsetY;
|
private final int cacheOffsetY;
|
||||||
private int cacheOffsetZ;
|
private final int cacheOffsetZ;
|
||||||
private int cacheSizeX;
|
private final int cacheSizeX;
|
||||||
private int cacheSizeY;
|
private final int cacheSizeY;
|
||||||
private int cacheSizeZ;
|
private final int cacheSizeZ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache entires:
|
* Cache for expression results.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Cache entries:
|
||||||
* 0 = unknown
|
* 0 = unknown
|
||||||
* -1 = outside
|
* -1 = outside
|
||||||
* 1 = inside
|
* 1 = inside
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private final byte[] cache;
|
private final byte[] cache;
|
||||||
|
|
||||||
@ -88,7 +92,7 @@ public abstract class ArbitraryShape {
|
|||||||
* @param pattern The pattern to generate default materials from.
|
* @param pattern The pattern to generate default materials from.
|
||||||
* @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.
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException if the maximum blocks changed is exceeded
|
||||||
*/
|
*/
|
||||||
public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException {
|
public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.shape;
|
package com.sk89q.worldedit.regions.shape;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.regions.shape;
|
package com.sk89q.worldedit.regions.shape;
|
||||||
@ -31,7 +31,7 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
|||||||
private final Vector3 unit;
|
private final Vector3 unit;
|
||||||
private final Vector3 zero2;
|
private final Vector3 zero2;
|
||||||
private Vector3 current = new MutableVector3(Vector3.ZERO);
|
private Vector3 current = new MutableVector3(Vector3.ZERO);
|
||||||
private Extent extent;
|
private final Extent extent;
|
||||||
|
|
||||||
public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
|
public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
|
||||||
this((Extent) editSession, unit, zero);
|
this((Extent) editSession, unit, zero);
|
||||||
@ -52,31 +52,37 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
|||||||
return current.add(x, y, z);
|
return current.add(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int getBlockType(double x, double y, double z) {
|
public int getBlockType(double x, double y, double z) {
|
||||||
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() >> 4;
|
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int getBlockData(double x, double y, double z) {
|
public int getBlockData(double x, double y, double z) {
|
||||||
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF;
|
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int getBlockTypeAbs(double x, double y, double z) {
|
public int getBlockTypeAbs(double x, double y, double z) {
|
||||||
return extent.getBlock(BlockVector3.at(x, y, z)).getBlockType().getLegacyCombinedId() >> 4;
|
return extent.getBlock(BlockVector3.at(x, y, z)).getBlockType().getLegacyCombinedId() >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int getBlockDataAbs(double x, double y, double z) {
|
public int getBlockDataAbs(double x, double y, double z) {
|
||||||
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF;
|
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int getBlockTypeRel(double x, double y, double z) {
|
public int getBlockTypeRel(double x, double y, double z) {
|
||||||
return extent.getBlock(toWorldRel(x, y, z).toBlockPoint()).getBlockType().getLegacyCombinedId() >> 4;
|
return extent.getBlock(toWorldRel(x, y, z).toBlockPoint()).getBlockType().getLegacyCombinedId() >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public int getBlockDataRel(double x, double y, double z) {
|
public int getBlockDataRel(double x, double y, double z) {
|
||||||
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF;
|
return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF;
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.world;
|
package com.sk89q.worldedit.world;
|
||||||
@ -64,9 +64,14 @@ public abstract class AbstractWorld implements World {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinY() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxY() {
|
public int getMaxY() {
|
||||||
return getMaximumPoint().getBlockY();
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,12 +129,12 @@ public abstract class AbstractWorld implements World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return BlockVector3.at(-30000000, 0, -30000000);
|
return BlockVector3.at(-30000000, getMinY(), -30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return BlockVector3.at(30000000, 255, 30000000);
|
return BlockVector3.at(30000000, getMaxY(), 30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,6 +99,7 @@ public class NullWorld extends AbstractWorld {
|
|||||||
public BiomeType getBiome(BlockVector2 position) {
|
public BiomeType getBiome(BlockVector2 position) {
|
||||||
return BiomeTypes.THE_VOID;
|
return BiomeTypes.THE_VOID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiomeType(int x, int y, int z) {
|
public BiomeType getBiomeType(int x, int y, int z) {
|
||||||
return BiomeTypes.THE_VOID;
|
return BiomeTypes.THE_VOID;
|
||||||
|
@ -100,7 +100,7 @@ public interface SimpleWorld extends World {
|
|||||||
default void fixLighting(Iterable<BlockVector2> chunks) {
|
default void fixLighting(Iterable<BlockVector2> chunks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
default boolean playEffect(BlockVector3 position, int type, int data) {
|
default boolean playEffect(BlockVector3 position, int type, int data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful,
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.world;
|
package com.sk89q.worldedit.world;
|
||||||
@ -71,6 +71,13 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
Path getStoragePath();
|
Path getStoragePath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the minimum Y.
|
||||||
|
*
|
||||||
|
* @return the minimum Y
|
||||||
|
*/
|
||||||
|
int getMinY();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum Y.
|
* Get the maximum Y.
|
||||||
*
|
*
|
||||||
@ -324,11 +331,9 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh a specific chunk
|
* Refresh a specific chunk.
|
||||||
* Note: only 0 is guaranteed to send all tiles / entities
|
* Note: only 0 is guaranteed to send all tiles / entities
|
||||||
* Note: Only 65535 is guaranteed to send all blocks
|
* Note: Only 65535 is guaranteed to send all blocks
|
||||||
* @param chunkX
|
|
||||||
* @param chunkZ
|
|
||||||
*/
|
*/
|
||||||
void refreshChunk(final int chunkX, final int chunkZ);
|
void refreshChunk(final int chunkX, final int chunkZ);
|
||||||
|
|
||||||
@ -336,7 +341,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
|
|||||||
IChunkGet get(int x, int z);
|
IChunkGet get(int x, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a fake chunk to a player/s
|
* Send a fake chunk to a player.
|
||||||
* @param player may be null to send to everyone
|
* @param player may be null to send to everyone
|
||||||
* @param packet the chunk packet
|
* @param packet the chunk packet
|
||||||
*/
|
*/
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren