Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Use a long to refer to the volume of a region to prevent overflow (#1350)
* Use a long to refer to the volume of a region, and rename the method to getVolume * Fixed issues noted in review * Forgot to floor * Fixed review notes * Can use a long here rather than BigDecimal * Improve javadocs * style (cherry picked from commit 328030fd6281e58a4ea1d0cdd0a2e274da90afbe)
Dieser Commit ist enthalten in:
Ursprung
a23b182de5
Commit
33adba4a6f
@ -20,11 +20,6 @@
|
|||||||
package com.sk89q.bukkit.util;
|
package com.sk89q.bukkit.util;
|
||||||
|
|
||||||
import com.sk89q.util.ReflectionUtil;
|
import com.sk89q.util.ReflectionUtil;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -33,6 +28,12 @@ import org.bukkit.command.PluginIdentifiableCommand;
|
|||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CommandRegistration {
|
public class CommandRegistration {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -61,6 +62,7 @@ public class CommandRegistration {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean register(List<CommandInfo> registered) {
|
public boolean register(List<CommandInfo> registered) {
|
||||||
CommandMap commandMap = getCommandMap();
|
CommandMap commandMap = getCommandMap();
|
||||||
if (registered == null || commandMap == null) {
|
if (registered == null || commandMap == null) {
|
||||||
@ -82,6 +84,7 @@ public class CommandRegistration {
|
|||||||
if (fallbackCommands != null) {
|
if (fallbackCommands != null) {
|
||||||
return fallbackCommands;
|
return fallbackCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
|
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
|
||||||
if (commandMap == null) {
|
if (commandMap == null) {
|
||||||
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
|
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
|
||||||
|
@ -50,7 +50,7 @@ public class AsyncPreloader implements Preloader, Runnable {
|
|||||||
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
|
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
|
||||||
try {
|
try {
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
if (!(region instanceof CuboidRegion) || region.getArea() > 50466816) {
|
if (!(region instanceof CuboidRegion) || region.getVolume() > 50466816) {
|
||||||
// TOO LARGE or NOT CUBOID
|
// TOO LARGE or NOT CUBOID
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().getEntities(region);
|
return getExtent().getEntities(region);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -223,8 +223,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCaves(Region region) throws WorldEditException {
|
public void addCaves(Region region) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
getExtent().addCaves(region);
|
getExtent().addCaves(region);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -236,8 +236,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Region region, GenBase gen) throws WorldEditException {
|
public void generate(Region region, GenBase gen) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
getExtent().generate(region, gen);
|
getExtent().generate(region, gen);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -249,8 +249,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
getExtent().addSchems(region, mask, clipboards, rarity, rotate);
|
getExtent().addSchems(region, mask, clipboards, rarity, rotate);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -262,8 +262,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
getExtent().spawnResource(region, gen, rarity, frequency);
|
getExtent().spawnResource(region, gen, rarity, frequency);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -275,8 +275,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -288,8 +288,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOres(Region region, Mask mask) throws WorldEditException {
|
public void addOres(Region region, Mask mask) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
getExtent().addOres(region, mask);
|
getExtent().addOres(region, mask);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -301,7 +301,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().getBlockDistribution(region);
|
return getExtent().getBlockDistribution(region);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -314,7 +314,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().getBlockDistributionWithData(region);
|
return getExtent().getBlockDistributionWithData(region);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -327,7 +327,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().countBlocks(region, searchBlocks);
|
return getExtent().countBlocks(region, searchBlocks);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -340,7 +340,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Mask searchMask) {
|
public int countBlocks(Region region, Mask searchMask) {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().countBlocks(region, searchMask);
|
return getExtent().countBlocks(region, searchMask);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -353,7 +353,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().setBlocks(region, block);
|
return getExtent().setBlocks(region, block);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -366,7 +366,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().setBlocks(region, pattern);
|
return getExtent().setBlocks(region, pattern);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -379,8 +379,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().replaceBlocks(region, filter, replacement);
|
return getExtent().replaceBlocks(region, filter, replacement);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -393,8 +393,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().replaceBlocks(region, filter, pattern);
|
return getExtent().replaceBlocks(region, filter, pattern);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -407,8 +407,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().replaceBlocks(region, mask, pattern);
|
return getExtent().replaceBlocks(region, mask, pattern);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -421,8 +421,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().center(region, pattern);
|
return getExtent().center(region, pattern);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -448,8 +448,8 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||||
limit.THROW_MAX_CHECKS(region.getArea());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getArea());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
try {
|
||||||
return getExtent().apply(region, filter, full);
|
return getExtent().apply(region, filter, full);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
|
@ -162,6 +162,9 @@ public class FaweLimit {
|
|||||||
public void THROW_MAX_CHANGES(int amt) {
|
public void THROW_MAX_CHANGES(int amt) {
|
||||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
||||||
}
|
}
|
||||||
|
public void THROW_MAX_CHANGES(long amt) {
|
||||||
|
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
||||||
|
}
|
||||||
|
|
||||||
public void THROW_MAX_FAILS(int amt) {
|
public void THROW_MAX_FAILS(int amt) {
|
||||||
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||||
@ -171,6 +174,10 @@ public class FaweLimit {
|
|||||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void THROW_MAX_CHECKS(long amt) {
|
||||||
|
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||||
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ITERATIONS(int amt) {
|
public void THROW_MAX_ITERATIONS(int amt) {
|
||||||
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS;
|
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS;
|
||||||
}
|
}
|
||||||
|
@ -87,14 +87,12 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) {
|
public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) {
|
||||||
int size = this.region.getArea();
|
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getVolume() + ")"));
|
||||||
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) {
|
public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) {
|
||||||
int size = this.region.getArea();
|
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getVolume() + ")"));
|
||||||
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -176,7 +176,7 @@ public class ClipboardCommands {
|
|||||||
|
|
||||||
lazyClipboard.setOrigin(session.getPlacementPosition(actor));
|
lazyClipboard.setOrigin(session.getPlacementPosition(actor));
|
||||||
session.setClipboard(new ClipboardHolder(lazyClipboard));
|
session.setClipboard(new ClipboardHolder(lazyClipboard));
|
||||||
actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getArea()));
|
actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Command(
|
// @Command(
|
||||||
|
@ -104,14 +104,14 @@ public class ExpandCommands {
|
|||||||
private static void expandVert(LocalSession session, Actor actor, World world) throws IncompleteRegionException {
|
private static void expandVert(LocalSession session, Actor actor, World world) throws IncompleteRegionException {
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
try {
|
try {
|
||||||
int oldSize = region.getArea();
|
long oldSize = region.getVolume();
|
||||||
region.expand(
|
region.expand(
|
||||||
BlockVector3.at(0, (world.getMaxY() + 1), 0),
|
BlockVector3.at(0, (world.getMaxY() + 1), 0),
|
||||||
BlockVector3.at(0, -(world.getMaxY() + 1), 0));
|
BlockVector3.at(0, -(world.getMaxY() + 1), 0));
|
||||||
session.getRegionSelector(world).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
int newSize = region.getArea();
|
long newSize = region.getVolume();
|
||||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||||
int changeSize = newSize - oldSize;
|
long changeSize = newSize - oldSize;
|
||||||
actor.printInfo(
|
actor.printInfo(
|
||||||
TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize))
|
TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize))
|
||||||
);
|
);
|
||||||
@ -134,7 +134,7 @@ public class ExpandCommands {
|
|||||||
@MultiDirection
|
@MultiDirection
|
||||||
List<BlockVector3> direction) throws WorldEditException {
|
List<BlockVector3> direction) throws WorldEditException {
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
int oldSize = region.getArea();
|
long oldSize = region.getVolume();
|
||||||
|
|
||||||
if (reverseAmount == 0) {
|
if (reverseAmount == 0) {
|
||||||
for (BlockVector3 dir : direction) {
|
for (BlockVector3 dir : direction) {
|
||||||
@ -147,11 +147,11 @@ public class ExpandCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(world).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
int newSize = region.getArea();
|
long newSize = region.getVolume();
|
||||||
|
|
||||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||||
|
|
||||||
int changeSize = newSize - oldSize;
|
long changeSize = newSize - oldSize;
|
||||||
actor.printInfo(TranslatableComponent.of("worldedit.expand.expanded", TextComponent.of(changeSize)));
|
actor.printInfo(TranslatableComponent.of("worldedit.expand.expanded", TextComponent.of(changeSize)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ public class SelectionCommands {
|
|||||||
List<BlockVector3> direction) throws WorldEditException {
|
List<BlockVector3> direction) throws WorldEditException {
|
||||||
try {
|
try {
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
int oldSize = region.getArea();
|
long oldSize = region.getVolume();
|
||||||
if (reverseAmount == 0) {
|
if (reverseAmount == 0) {
|
||||||
for (BlockVector3 dir : direction) {
|
for (BlockVector3 dir : direction) {
|
||||||
region.contract(dir.multiply(amount));
|
region.contract(dir.multiply(amount));
|
||||||
@ -350,7 +350,7 @@ public class SelectionCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.getRegionSelector(world).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
int newSize = region.getArea();
|
long newSize = region.getVolume();
|
||||||
|
|
||||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ public class SelectionCommands {
|
|||||||
|
|
||||||
actor.printInfo(TranslatableComponent.of("worldedit.size.size", TextComponent.of(size.toString())));
|
actor.printInfo(TranslatableComponent.of("worldedit.size.size", TextComponent.of(size.toString())));
|
||||||
actor.printInfo(TranslatableComponent.of("worldedit.size.distance", TextComponent.of(region.getMaximumPoint().distance(region.getMinimumPoint()))));
|
actor.printInfo(TranslatableComponent.of("worldedit.size.distance", TextComponent.of(region.getMaximumPoint().distance(region.getMinimumPoint()))));
|
||||||
actor.printInfo(TranslatableComponent.of("worldedit.size.blocks", TextComponent.of(region.getArea())));
|
actor.printInfo(TranslatableComponent.of("worldedit.size.blocks", TextComponent.of(region.getVolume())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.platform;
|
package com.sk89q.worldedit.extension.platform;
|
||||||
|
|
||||||
import com.boydti.fawe.config.Caption;
|
|
||||||
import com.boydti.fawe.object.task.AsyncNotifyQueue;
|
import com.boydti.fawe.object.task.AsyncNotifyQueue;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
|
||||||
@ -701,10 +700,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Region getLargestRegion() {
|
public Region getLargestRegion() {
|
||||||
int area = 0;
|
long area = 0;
|
||||||
Region max = null;
|
Region max = null;
|
||||||
for (Region region : this.getCurrentRegions()) {
|
for (Region region : this.getCurrentRegions()) {
|
||||||
final int tmp = region.getArea();
|
final long tmp = region.getVolume();
|
||||||
if (tmp > area) {
|
if (tmp > area) {
|
||||||
area = tmp;
|
area = tmp;
|
||||||
max = region;
|
max = region;
|
||||||
|
@ -27,8 +27,9 @@ public class SelectionPoint2DEvent implements CUIEvent {
|
|||||||
protected final int id;
|
protected final int id;
|
||||||
protected final int blockX;
|
protected final int blockX;
|
||||||
protected final int blockZ;
|
protected final int blockZ;
|
||||||
protected final int area;
|
protected final long area;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SelectionPoint2DEvent(int id, BlockVector2 pos, int area) {
|
public SelectionPoint2DEvent(int id, BlockVector2 pos, int area) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.blockX = pos.getX();
|
this.blockX = pos.getX();
|
||||||
@ -36,6 +37,7 @@ public class SelectionPoint2DEvent implements CUIEvent {
|
|||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SelectionPoint2DEvent(int id, BlockVector3 pos, int area) {
|
public SelectionPoint2DEvent(int id, BlockVector3 pos, int area) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.blockX = pos.getX();
|
this.blockX = pos.getX();
|
||||||
@ -43,6 +45,20 @@ public class SelectionPoint2DEvent implements CUIEvent {
|
|||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SelectionPoint2DEvent(int id, BlockVector2 pos, long area) {
|
||||||
|
this.id = id;
|
||||||
|
this.blockX = pos.getX();
|
||||||
|
this.blockZ = pos.getZ();
|
||||||
|
this.area = area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectionPoint2DEvent(int id, BlockVector3 pos, long area) {
|
||||||
|
this.id = id;
|
||||||
|
this.blockX = pos.getX();
|
||||||
|
this.blockZ = pos.getZ();
|
||||||
|
this.area = area;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "p2";
|
return "p2";
|
||||||
|
@ -25,14 +25,21 @@ public class SelectionPointEvent implements CUIEvent {
|
|||||||
|
|
||||||
protected final int id;
|
protected final int id;
|
||||||
protected final BlockVector3 pos;
|
protected final BlockVector3 pos;
|
||||||
protected final int area;
|
protected final long area;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SelectionPointEvent(int id, BlockVector3 pos, int area) {
|
public SelectionPointEvent(int id, BlockVector3 pos, int area) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SelectionPointEvent(int id, BlockVector3 pos, long area) {
|
||||||
|
this.id = id;
|
||||||
|
this.pos = pos;
|
||||||
|
this.area = area;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "p";
|
return "p";
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||||
|
import com.google.common.primitives.Longs;
|
||||||
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;
|
||||||
@ -44,7 +45,7 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return getArea();
|
return com.google.common.primitives.Ints.saturatedCast(getVolume());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -106,19 +107,14 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of blocks in the region.
|
|
||||||
*
|
|
||||||
* @return number of blocks
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
BlockVector3 min = getMinimumPoint();
|
BlockVector3 min = getMinimumPoint();
|
||||||
BlockVector3 max = getMaximumPoint();
|
BlockVector3 max = getMaximumPoint();
|
||||||
|
|
||||||
return (max.getX() - min.getX() + 1) *
|
return (max.getX() - min.getX() + 1L) *
|
||||||
(max.getY() - min.getY() + 1) *
|
(max.getY() - min.getY() + 1L) *
|
||||||
(max.getZ() - min.getZ() + 1);
|
(max.getZ() - min.getZ() + 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,7 +214,7 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
|||||||
int result = worldHash ^ (worldHash >>> 32);
|
int result = worldHash ^ (worldHash >>> 32);
|
||||||
result = 31 * result + this.getMinimumPoint().hashCode();
|
result = 31 * result + this.getMinimumPoint().hashCode();
|
||||||
result = 31 * result + this.getMaximumPoint().hashCode();
|
result = 31 * result + this.getMaximumPoint().hashCode();
|
||||||
result = 31 * result + this.getArea();
|
result = (int) (31 * result + this.getVolume());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +235,7 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
|||||||
if(this.getWorld().equals(region.getWorld())
|
if(this.getWorld().equals(region.getWorld())
|
||||||
&& this.getMinimumPoint().equals(region.getMinimumPoint())
|
&& this.getMinimumPoint().equals(region.getMinimumPoint())
|
||||||
&& this.getMaximumPoint().equals(region.getMaximumPoint())
|
&& this.getMaximumPoint().equals(region.getMaximumPoint())
|
||||||
&& this.getArea() == region.getArea()){
|
&& this.getVolume() == region.getVolume()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,6 +35,9 @@ 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.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -196,9 +199,16 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return minY;
|
return minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final BigDecimal PI = BigDecimal.valueOf(Math.PI);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return (int) Math.floor(radius.getX() * radius.getZ() * Math.PI * getHeight());
|
return BigDecimal.valueOf(radius.getX())
|
||||||
|
.multiply(BigDecimal.valueOf(radius.getZ()))
|
||||||
|
.multiply(PI)
|
||||||
|
.multiply(BigDecimal.valueOf(getHeight()))
|
||||||
|
.setScale(0, RoundingMode.FLOOR)
|
||||||
|
.longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,8 @@ import com.sk89q.worldedit.math.Vector3;
|
|||||||
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;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -92,10 +94,16 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
return center.toVector3().add(getRadius()).toBlockPoint();
|
return center.toVector3().add(getRadius()).toBlockPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final BigDecimal ELLIPSOID_BASE_MULTIPLIER = BigDecimal.valueOf((4.0 / 3.0) * Math.PI);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return (int) Math
|
return ELLIPSOID_BASE_MULTIPLIER
|
||||||
.floor((4.0 / 3.0) * Math.PI * radius.getX() * radius.getY() * radius.getZ());
|
.multiply(BigDecimal.valueOf(radius.getX()))
|
||||||
|
.multiply(BigDecimal.valueOf(radius.getY()))
|
||||||
|
.multiply(BigDecimal.valueOf(radius.getZ()))
|
||||||
|
.setScale(0, RoundingMode.FLOOR)
|
||||||
|
.longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,7 +53,7 @@ public class NullRegion implements Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ 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.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -197,18 +199,22 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
double area = 0;
|
long area = 0;
|
||||||
int i, j = points.size() - 1;
|
int i, j = points.size() - 1;
|
||||||
|
|
||||||
for (i = 0; i < points.size(); ++i) {
|
for (i = 0; i < points.size(); ++i) {
|
||||||
area += (points.get(j).getBlockX() + points.get(i).getBlockX())
|
long x = points.get(j).getBlockX() + points.get(i).getBlockX();
|
||||||
* (points.get(j).getBlockZ() - points.get(i).getBlockZ());
|
long z = points.get(j).getBlockZ() - points.get(i).getBlockZ();
|
||||||
|
area += x * z;
|
||||||
j = i;
|
j = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) Math.floor(Math.abs(area * 0.5)
|
return BigDecimal.valueOf(area)
|
||||||
* (maxY - minY + 1));
|
.multiply(BigDecimal.valueOf(0.5))
|
||||||
|
.abs()
|
||||||
|
.setScale(0, RoundingMode.FLOOR)
|
||||||
|
.longValue() * (maxY - minY + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,8 +32,10 @@ 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.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,14 +76,40 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
|||||||
* Get the number of blocks in the region.
|
* Get the number of blocks in the region.
|
||||||
*
|
*
|
||||||
* @return number of blocks
|
* @return number of blocks
|
||||||
|
* @deprecated use {@link Region#getVolume()} to prevent overflows
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default int getArea() {
|
||||||
|
return (int) getVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of blocks in the region.
|
||||||
|
*
|
||||||
|
* <p>Note: This method <b>must</b> be overridden.</p>
|
||||||
|
*
|
||||||
|
* @return number of blocks
|
||||||
|
*/
|
||||||
|
default long getVolume() {
|
||||||
|
// TODO Remove default status when getArea is removed.
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FAWE code for getArea() before merge:
|
||||||
default int getArea() {
|
default int getArea() {
|
||||||
BlockVector3 min = getMinimumPoint();
|
BlockVector3 min = getMinimumPoint();
|
||||||
BlockVector3 max = getMaximumPoint();
|
BlockVector3 max = getMaximumPoint();
|
||||||
|
|
||||||
return (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1) * (max.getZ() - min.getZ() + 1);
|
return (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1) * (max.getZ() - min.getZ() + 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Get X-size.
|
* Get X-size.
|
||||||
*
|
*
|
||||||
|
@ -135,8 +135,31 @@ public interface RegionSelector {
|
|||||||
* Get the number of blocks inside the region.
|
* Get the number of blocks inside the region.
|
||||||
*
|
*
|
||||||
* @return number of blocks, or -1 if undefined
|
* @return number of blocks, or -1 if undefined
|
||||||
|
* @deprecated use {@link RegionSelector#getVolume()}
|
||||||
*/
|
*/
|
||||||
int getArea();
|
@Deprecated
|
||||||
|
default int getArea() {
|
||||||
|
return (int) getVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
default long getVolume() {
|
||||||
|
// TODO Remove default once getArea is removed
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the selector with changes to the region.
|
* Update the selector with changes to the region.
|
||||||
|
@ -113,8 +113,8 @@ public class TransformRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return region.getArea(); // Cannot transform this
|
return region.getVolume(); // Cannot transform this
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,8 +170,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return region.getArea();
|
return region.getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -250,7 +250,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
|||||||
int lastVertexId = -1;
|
int lastVertexId = -1;
|
||||||
for (BlockVector3 vertex : vertices) {
|
for (BlockVector3 vertex : vertices) {
|
||||||
vertexIds.put(vertex, ++lastVertexId);
|
vertexIds.put(vertex, ++lastVertexId);
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Triangle triangle : triangles) {
|
for (Triangle triangle : triangles) {
|
||||||
@ -273,8 +273,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
|||||||
checkNotNull(session);
|
checkNotNull(session);
|
||||||
|
|
||||||
if (isDefined()) {
|
if (isDefined()) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getVolume()));
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getVolume()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,13 +161,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.cuboid.explain.primary-area",
|
"worldedit.selection.cuboid.explain.primary-area",
|
||||||
TextComponent.of(position1.toString()),
|
TextComponent.of(position1.toString()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
} else if (position1 != null) {
|
} else if (position1 != null) {
|
||||||
player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.primary", TextComponent.of(position1.toString())));
|
player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.primary", TextComponent.of(position1.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -180,13 +180,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.cuboid.explain.secondary-area",
|
"worldedit.selection.cuboid.explain.secondary-area",
|
||||||
TextComponent.of(position2.toString()),
|
TextComponent.of(position2.toString()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
} else if (position2 != null) {
|
} else if (position2 != null) {
|
||||||
player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.secondary", TextComponent.of(position2.toString())));
|
player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.secondary", TextComponent.of(position2.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -197,11 +197,11 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
||||||
|
|
||||||
if (position1 != null) {
|
if (position1 != null) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position2 != null) {
|
if (position2 != null) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getVolume()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
if (position1 == null) {
|
if (position1 == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -277,17 +277,17 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return region.getArea();
|
return region.getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void describeCUI(LocalSession session, Actor player) {
|
public void describeCUI(LocalSession session, Actor player) {
|
||||||
if (position1 != null) {
|
if (position1 != null) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position2 != null) {
|
if (position2 != null) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getVolume()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
"worldedit.selection.cylinder.explain.secondary",
|
"worldedit.selection.cylinder.explain.secondary",
|
||||||
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getX())),
|
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getX())),
|
||||||
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getZ())),
|
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getZ())),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
player.printError(TranslatableComponent.of("worldedit.selection.cylinder.explain.secondary-missing"));
|
player.printError(TranslatableComponent.of("worldedit.selection.cylinder.explain.secondary-missing"));
|
||||||
@ -260,8 +260,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return region.getArea();
|
return region.getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -273,8 +273,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
@Override
|
@Override
|
||||||
public void describeLegacyCUI(LocalSession session, Actor player) {
|
public void describeLegacyCUI(LocalSession session, Actor player) {
|
||||||
if (isDefined()) {
|
if (isDefined()) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getVolume()));
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getVolume()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.ellipsoid.explain.primary-area",
|
"worldedit.selection.ellipsoid.explain.primary-area",
|
||||||
TextComponent.of(region.getCenter().toString()),
|
TextComponent.of(region.getCenter().toString()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
@ -169,7 +169,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.ellipsoid.explain.secondary-area",
|
"worldedit.selection.ellipsoid.explain.secondary-area",
|
||||||
TextComponent.of(region.getRadius().toString()),
|
TextComponent.of(region.getRadius().toString()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
@ -238,8 +238,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return region.getArea();
|
return region.getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -250,8 +250,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void describeLegacyCUI(LocalSession session, Actor player) {
|
public void describeLegacyCUI(LocalSession session, Actor player) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getVolume()));
|
||||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,7 +134,7 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.extend.explain.primary",
|
"worldedit.selection.extend.explain.primary",
|
||||||
TextComponent.of(pos.toString()),
|
TextComponent.of(pos.toString()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
|
|
||||||
explainRegionAdjust(player, session);
|
explainRegionAdjust(player, session);
|
||||||
@ -145,7 +145,7 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.extend.explain.secondary",
|
"worldedit.selection.extend.explain.secondary",
|
||||||
TextComponent.of(pos.toString()),
|
TextComponent.of(pos.toString()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
|
|
||||||
explainRegionAdjust(player, session);
|
explainRegionAdjust(player, session);
|
||||||
|
@ -174,7 +174,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
player.printInfo(TranslatableComponent.of("worldedit.selection.polygon2d.explain.primary", TextComponent.of(pos.toString())));
|
player.printInfo(TranslatableComponent.of("worldedit.selection.polygon2d.explain.primary", TextComponent.of(pos.toString())));
|
||||||
|
|
||||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
||||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getVolume()));
|
||||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
TextComponent.of(pos.toString())
|
TextComponent.of(pos.toString())
|
||||||
));
|
));
|
||||||
|
|
||||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
|
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getVolume()));
|
||||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +247,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return region.getArea();
|
return region.getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,7 +264,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
public void describeCUI(LocalSession session, Actor player) {
|
public void describeCUI(LocalSession session, Actor player) {
|
||||||
final List<BlockVector2> points = region.getPoints();
|
final List<BlockVector2> points = region.getPoints();
|
||||||
for (int id = 0; id < points.size(); id++) {
|
for (int id = 0; id < points.size(); id++) {
|
||||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea()));
|
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getVolume()));
|
||||||
}
|
}
|
||||||
|
|
||||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||||
|
@ -93,7 +93,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
|||||||
player.printInfo(TranslatableComponent.of(
|
player.printInfo(TranslatableComponent.of(
|
||||||
"worldedit.selection.sphere.explain.secondary-defined",
|
"worldedit.selection.sphere.explain.secondary-defined",
|
||||||
TextComponent.of(region.getRadius().getX()),
|
TextComponent.of(region.getRadius().getX()),
|
||||||
TextComponent.of(region.getArea())
|
TextComponent.of(region.getVolume())
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
player.printInfo(TranslatableComponent.of("worldedit.selection.sphere.explain.secondary", TextComponent.of(region.getRadius().getX())));
|
player.printInfo(TranslatableComponent.of("worldedit.selection.sphere.explain.secondary", TextComponent.of(region.getRadius().getX())));
|
||||||
|
@ -78,8 +78,8 @@ public class RequestSelection implements Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public long getVolume() {
|
||||||
return getRegion().getArea();
|
return getRegion().getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren