mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Clamp Y coordinates during selection
This commit is contained in:
parent
048974dca5
commit
98bd93c752
@ -37,7 +37,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
|
||||||
return setBlock(position, block);
|
return setBlock(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException {
|
||||||
return unsupported();
|
return unsupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public interface VirtualWorld extends SimpleWorld, Closeable {
|
|||||||
int getMaxY();
|
int getMaxY();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException;
|
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
|
||||||
|
|
||||||
Player getPlayer();
|
Player getPlayer();
|
||||||
|
|
||||||
|
@ -718,7 +718,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws WorldEditException {
|
||||||
return setBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ(), block);
|
return setBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
return this.setBlock(x, y, z, block.getOrdinalChar());
|
return this.setBlock(x, y, z, block.getOrdinalChar());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,7 +979,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
return heights.getByte(index) & 0xFF;
|
return heights.getByte(index) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFloor(int x, int z, BlockStateHolder block) {
|
public <B extends BlockStateHolder<B>> void setFloor(int x, int z, B block) {
|
||||||
int index = z * getWidth() + x;
|
int index = z * getWidth() + x;
|
||||||
floor.setInt(index, block.getOrdinalChar());
|
floor.setInt(index, block.getOrdinalChar());
|
||||||
}
|
}
|
||||||
@ -1914,7 +1914,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
|
||||||
return setBlock(position, block);
|
return setBlock(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +120,9 @@ public class SelectionCommands {
|
|||||||
BlockVector3 coordinates) throws WorldEditException {
|
BlockVector3 coordinates) throws WorldEditException {
|
||||||
Location pos;
|
Location pos;
|
||||||
if (coordinates != null) {
|
if (coordinates != null) {
|
||||||
pos = new Location(world, coordinates.toVector3());
|
pos = new Location(world, coordinates.toVector3().clampY(0, world.getMaxY()));
|
||||||
} else if (actor instanceof Locatable) {
|
} else if (actor instanceof Locatable) {
|
||||||
pos = ((Locatable) actor).getBlockLocation();
|
pos = ((Locatable) actor).getBlockLocation().clampY(0, world.getMaxY());
|
||||||
} else {
|
} else {
|
||||||
actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
|
actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
|
||||||
return;
|
return;
|
||||||
@ -149,9 +149,9 @@ public class SelectionCommands {
|
|||||||
BlockVector3 coordinates) throws WorldEditException {
|
BlockVector3 coordinates) throws WorldEditException {
|
||||||
Location pos;
|
Location pos;
|
||||||
if (coordinates != null) {
|
if (coordinates != null) {
|
||||||
pos = new Location(world, coordinates.toVector3());
|
pos = new Location(world, coordinates.toVector3().clampY(0, world.getMaxY()));
|
||||||
} else if (actor instanceof Locatable) {
|
} else if (actor instanceof Locatable) {
|
||||||
pos = ((Locatable) actor).getBlockLocation();
|
pos = ((Locatable) actor).getBlockLocation().clampY(0, world.getMaxY());
|
||||||
} else {
|
} else {
|
||||||
actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
|
actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
|
||||||
return;
|
return;
|
||||||
@ -530,9 +530,7 @@ public class SelectionCommands {
|
|||||||
Integer page) throws WorldEditException {
|
Integer page) throws WorldEditException {
|
||||||
List<Countable<BlockState>> distribution;
|
List<Countable<BlockState>> distribution;
|
||||||
|
|
||||||
Region region;
|
|
||||||
if (page == null) {
|
if (page == null) {
|
||||||
Extent extent;
|
|
||||||
if (clipboardDistr) {
|
if (clipboardDistr) {
|
||||||
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
||||||
BlockDistributionCounter count = new BlockDistributionCounter(clipboard, separateStates);
|
BlockDistributionCounter count = new BlockDistributionCounter(clipboard, separateStates);
|
||||||
@ -541,8 +539,7 @@ public class SelectionCommands {
|
|||||||
distribution = count.getDistribution();
|
distribution = count.getDistribution();
|
||||||
} else {
|
} else {
|
||||||
try (EditSession editSession = session.createEditSession(actor)) {
|
try (EditSession editSession = session.createEditSession(actor)) {
|
||||||
distribution = editSession
|
distribution = editSession.getBlockDistribution(session.getSelection(world), separateStates);
|
||||||
.getBlockDistribution(session.getSelection(world), separateStates);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.setLastDistribution(distribution);
|
session.setLastDistribution(distribution);
|
||||||
@ -554,6 +551,7 @@ public class SelectionCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (distribution.isEmpty()) { // *Should* always be false
|
if (distribution.isEmpty()) { // *Should* always be false
|
||||||
actor.printError(TranslatableComponent.of("worldedit.distr.no-blocks"));
|
actor.printError(TranslatableComponent.of("worldedit.distr.no-blocks"));
|
||||||
return;
|
return;
|
||||||
|
@ -406,7 +406,6 @@ public class PlatformManager {
|
|||||||
// making changes to the world
|
// making changes to the world
|
||||||
Player player = createProxyActor(event.getPlayer());
|
Player player = createProxyActor(event.getPlayer());
|
||||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||||
|
|
||||||
VirtualWorld virtual = session.getVirtualWorld();
|
VirtualWorld virtual = session.getVirtualWorld();
|
||||||
if (virtual != null) {
|
if (virtual != null) {
|
||||||
virtual.handlePlayerInput(player, event);
|
virtual.handlePlayerInput(player, event);
|
||||||
@ -416,7 +415,6 @@ public class PlatformManager {
|
|||||||
try {
|
try {
|
||||||
switch (event.getInputType()) {
|
switch (event.getInputType()) {
|
||||||
case PRIMARY: {
|
case PRIMARY: {
|
||||||
|
|
||||||
Tool tool = session.getTool(player);
|
Tool tool = session.getTool(player);
|
||||||
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
|
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
|
||||||
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING),
|
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||||
|
Loading…
Reference in New Issue
Block a user