Skip to content

Commit a6155c7

Browse files
committed
fix(bukkit): offset local and relative LocationCoordinates by 0.5 for BlockCommandSender
1 parent cbf1055 commit a6155c7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cloud-bukkit/src/main/java/org/incendo/cloud/bukkit/parser/location/LocationCoordinateParser.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
//
2424
package org.incendo.cloud.bukkit.parser.location;
2525

26+
import org.bukkit.command.BlockCommandSender;
2627
import org.checkerframework.checker.nullness.qual.NonNull;
28+
import org.incendo.cloud.bukkit.BukkitCommandContextKeys;
2729
import org.incendo.cloud.context.CommandContext;
2830
import org.incendo.cloud.context.CommandInput;
2931
import org.incendo.cloud.parser.ArgumentParseResult;
@@ -57,7 +59,7 @@ public final class LocationCoordinateParser<C> implements ArgumentParser<C, Loca
5759
locationCoordinateType = LocationCoordinateType.ABSOLUTE;
5860
}
5961

60-
final double coordinate;
62+
double coordinate;
6163
try {
6264
final boolean empty = commandInput.peekString().isEmpty() || commandInput.peek() == ' ';
6365
coordinate = empty ? 0 : commandInput.readDouble();
@@ -75,6 +77,12 @@ public final class LocationCoordinateParser<C> implements ArgumentParser<C, Loca
7577
));
7678
}
7779

80+
if (commandContext.get(BukkitCommandContextKeys.BUKKIT_COMMAND_SENDER) instanceof BlockCommandSender
81+
&& (locationCoordinateType == LocationCoordinateType.LOCAL || locationCoordinateType == LocationCoordinateType.RELATIVE)
82+
) {
83+
coordinate += 0.5;
84+
}
85+
7886
return ArgumentParseResult.success(
7987
LocationCoordinate.of(
8088
locationCoordinateType,

0 commit comments

Comments
 (0)