aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/commands/WorldBorderCommand.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/commands/WorldBorderCommand.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/commands/WorldBorderCommand.java.patch353
1 files changed, 353 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/commands/WorldBorderCommand.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/commands/WorldBorderCommand.java.patch
new file mode 100644
index 0000000000..addc8865a7
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/commands/WorldBorderCommand.java.patch
@@ -0,0 +1,353 @@
+--- a/net/minecraft/server/commands/WorldBorderCommand.java
++++ b/net/minecraft/server/commands/WorldBorderCommand.java
+@@ -4,12 +4,12 @@
+ import com.mojang.brigadier.arguments.DoubleArgumentType;
+ import com.mojang.brigadier.arguments.FloatArgumentType;
+ import com.mojang.brigadier.arguments.IntegerArgumentType;
+-import com.mojang.brigadier.context.CommandContext;
++import com.mojang.brigadier.builder.LiteralArgumentBuilder;
++import com.mojang.brigadier.builder.RequiredArgumentBuilder;
+ import com.mojang.brigadier.exceptions.CommandSyntaxException;
+ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
+ import java.util.Locale;
+ import net.minecraft.commands.CommandSourceStack;
+-import net.minecraft.commands.Commands;
+ import net.minecraft.commands.arguments.coordinates.Vec2Argument;
+ import net.minecraft.network.chat.Component;
+ import net.minecraft.util.Mth;
+@@ -17,226 +17,156 @@
+ import net.minecraft.world.phys.Vec2;
+
+ public class WorldBorderCommand {
+- private static final SimpleCommandExceptionType ERROR_SAME_CENTER = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.center.failed")
+- );
+- private static final SimpleCommandExceptionType ERROR_SAME_SIZE = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.set.failed.nochange")
+- );
+- private static final SimpleCommandExceptionType ERROR_TOO_SMALL = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.set.failed.small")
+- );
+- private static final SimpleCommandExceptionType ERROR_TOO_BIG = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.set.failed.big", 5.999997E7F)
+- );
+- private static final SimpleCommandExceptionType ERROR_TOO_FAR_OUT = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.set.failed.far", 2.9999984E7)
+- );
+- private static final SimpleCommandExceptionType ERROR_SAME_WARNING_TIME = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.warning.time.failed")
+- );
+- private static final SimpleCommandExceptionType ERROR_SAME_WARNING_DISTANCE = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.warning.distance.failed")
+- );
+- private static final SimpleCommandExceptionType ERROR_SAME_DAMAGE_BUFFER = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.damage.buffer.failed")
+- );
+- private static final SimpleCommandExceptionType ERROR_SAME_DAMAGE_AMOUNT = new SimpleCommandExceptionType(
+- Component.translatable("commands.worldborder.damage.amount.failed")
+- );
+
++ private static final SimpleCommandExceptionType ERROR_SAME_CENTER = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.center.failed"));
++ private static final SimpleCommandExceptionType ERROR_SAME_SIZE = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.set.failed.nochange"));
++ private static final SimpleCommandExceptionType ERROR_TOO_SMALL = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.set.failed.small"));
++ private static final SimpleCommandExceptionType ERROR_TOO_BIG = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.set.failed.big", 5.9999968E7D));
++ private static final SimpleCommandExceptionType ERROR_TOO_FAR_OUT = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.set.failed.far", 2.9999984E7D));
++ private static final SimpleCommandExceptionType ERROR_SAME_WARNING_TIME = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.warning.time.failed"));
++ private static final SimpleCommandExceptionType ERROR_SAME_WARNING_DISTANCE = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.warning.distance.failed"));
++ private static final SimpleCommandExceptionType ERROR_SAME_DAMAGE_BUFFER = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.damage.buffer.failed"));
++ private static final SimpleCommandExceptionType ERROR_SAME_DAMAGE_AMOUNT = new SimpleCommandExceptionType(Component.translatable("commands.worldborder.damage.amount.failed"));
++
++ public WorldBorderCommand() {}
++
+ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
+- dispatcher.register(
+- Commands.literal("worldborder")
+- .requires(source -> source.hasPermission(2))
+- .then(
+- Commands.literal("add")
+- .then(
+- Commands.argument("distance", DoubleArgumentType.doubleArg(-5.999997E7F, 5.999997E7F))
+- .executes(
+- context -> setSize(
+- context.getSource(),
+- context.getSource().getLevel().getWorldBorder().getSize() + DoubleArgumentType.getDouble(context, "distance"),
+- 0L
+- )
+- )
+- .then(
+- Commands.argument("time", IntegerArgumentType.integer(0))
+- .executes(
+- context -> setSize(
+- context.getSource(),
+- context.getSource().getLevel().getWorldBorder().getSize()
+- + DoubleArgumentType.getDouble(context, "distance"),
+- context.getSource().getLevel().getWorldBorder().getLerpRemainingTime()
+- + (long)IntegerArgumentType.getInteger(context, "time") * 1000L
+- )
+- )
+- )
+- )
+- )
+- .then(
+- Commands.literal("set")
+- .then(
+- Commands.argument("distance", DoubleArgumentType.doubleArg(-5.999997E7F, 5.999997E7F))
+- .executes(context -> setSize(context.getSource(), DoubleArgumentType.getDouble(context, "distance"), 0L))
+- .then(
+- Commands.argument("time", IntegerArgumentType.integer(0))
+- .executes(
+- context -> setSize(
+- context.getSource(),
+- DoubleArgumentType.getDouble(context, "distance"),
+- (long)IntegerArgumentType.getInteger(context, "time") * 1000L
+- )
+- )
+- )
+- )
+- )
+- .then(
+- Commands.literal("center")
+- .then(
+- Commands.argument("pos", Vec2Argument.vec2())
+- .executes(context -> setCenter(context.getSource(), Vec2Argument.getVec2(context, "pos")))
+- )
+- )
+- .then(
+- Commands.literal("damage")
+- .then(
+- Commands.literal("amount")
+- .then(
+- Commands.argument("damagePerBlock", FloatArgumentType.floatArg(0.0F))
+- .executes(context -> setDamageAmount(context.getSource(), FloatArgumentType.getFloat(context, "damagePerBlock")))
+- )
+- )
+- .then(
+- Commands.literal("buffer")
+- .then(
+- Commands.argument("distance", FloatArgumentType.floatArg(0.0F))
+- .executes(context -> setDamageBuffer(context.getSource(), FloatArgumentType.getFloat(context, "distance")))
+- )
+- )
+- )
+- .then(Commands.literal("get").executes(context -> getSize(context.getSource())))
+- .then(
+- Commands.literal("warning")
+- .then(
+- Commands.literal("distance")
+- .then(
+- Commands.argument("distance", IntegerArgumentType.integer(0))
+- .executes(context -> setWarningDistance(context.getSource(), IntegerArgumentType.getInteger(context, "distance")))
+- )
+- )
+- .then(
+- Commands.literal("time")
+- .then(
+- Commands.argument("time", IntegerArgumentType.integer(0))
+- .executes(context -> setWarningTime(context.getSource(), IntegerArgumentType.getInteger(context, "time")))
+- )
+- )
+- )
+- );
++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("worldborder").requires((commandlistenerwrapper) -> {
++ return commandlistenerwrapper.hasPermission(2);
++ })).then(net.minecraft.commands.Commands.literal("add").then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("distance", DoubleArgumentType.doubleArg(-5.9999968E7D, 5.9999968E7D)).executes((commandcontext) -> {
++ return setSize((CommandSourceStack) commandcontext.getSource(), ((CommandSourceStack) commandcontext.getSource()).getLevel().getWorldBorder().getSize() + DoubleArgumentType.getDouble(commandcontext, "distance"), 0L);
++ })).then(net.minecraft.commands.Commands.argument("time", IntegerArgumentType.integer(0)).executes((commandcontext) -> {
++ return setSize((CommandSourceStack) commandcontext.getSource(), ((CommandSourceStack) commandcontext.getSource()).getLevel().getWorldBorder().getSize() + DoubleArgumentType.getDouble(commandcontext, "distance"), ((CommandSourceStack) commandcontext.getSource()).getLevel().getWorldBorder().getLerpRemainingTime() + (long) IntegerArgumentType.getInteger(commandcontext, "time") * 1000L);
++ }))))).then(net.minecraft.commands.Commands.literal("set").then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("distance", DoubleArgumentType.doubleArg(-5.9999968E7D, 5.9999968E7D)).executes((commandcontext) -> {
++ return setSize((CommandSourceStack) commandcontext.getSource(), DoubleArgumentType.getDouble(commandcontext, "distance"), 0L);
++ })).then(net.minecraft.commands.Commands.argument("time", IntegerArgumentType.integer(0)).executes((commandcontext) -> {
++ return setSize((CommandSourceStack) commandcontext.getSource(), DoubleArgumentType.getDouble(commandcontext, "distance"), (long) IntegerArgumentType.getInteger(commandcontext, "time") * 1000L);
++ }))))).then(net.minecraft.commands.Commands.literal("center").then(net.minecraft.commands.Commands.argument("pos", Vec2Argument.vec2()).executes((commandcontext) -> {
++ return setCenter((CommandSourceStack) commandcontext.getSource(), Vec2Argument.getVec2(commandcontext, "pos"));
++ })))).then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("damage").then(net.minecraft.commands.Commands.literal("amount").then(net.minecraft.commands.Commands.argument("damagePerBlock", FloatArgumentType.floatArg(0.0F)).executes((commandcontext) -> {
++ return setDamageAmount((CommandSourceStack) commandcontext.getSource(), FloatArgumentType.getFloat(commandcontext, "damagePerBlock"));
++ })))).then(net.minecraft.commands.Commands.literal("buffer").then(net.minecraft.commands.Commands.argument("distance", FloatArgumentType.floatArg(0.0F)).executes((commandcontext) -> {
++ return setDamageBuffer((CommandSourceStack) commandcontext.getSource(), FloatArgumentType.getFloat(commandcontext, "distance"));
++ }))))).then(net.minecraft.commands.Commands.literal("get").executes((commandcontext) -> {
++ return getSize((CommandSourceStack) commandcontext.getSource());
++ }))).then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("warning").then(net.minecraft.commands.Commands.literal("distance").then(net.minecraft.commands.Commands.argument("distance", IntegerArgumentType.integer(0)).executes((commandcontext) -> {
++ return setWarningDistance((CommandSourceStack) commandcontext.getSource(), IntegerArgumentType.getInteger(commandcontext, "distance"));
++ })))).then(net.minecraft.commands.Commands.literal("time").then(net.minecraft.commands.Commands.argument("time", IntegerArgumentType.integer(0)).executes((commandcontext) -> {
++ return setWarningTime((CommandSourceStack) commandcontext.getSource(), IntegerArgumentType.getInteger(commandcontext, "time"));
++ })))));
+ }
+
+ private static int setDamageBuffer(CommandSourceStack source, float distance) throws CommandSyntaxException {
+- WorldBorder worldBorder = source.getServer().overworld().getWorldBorder();
+- if (worldBorder.getDamageSafeZone() == (double)distance) {
+- throw ERROR_SAME_DAMAGE_BUFFER.create();
++ WorldBorder worldborder = source.getLevel().getWorldBorder(); // CraftBukkit
++
++ if (worldborder.getDamageSafeZone() == (double) distance) {
++ throw WorldBorderCommand.ERROR_SAME_DAMAGE_BUFFER.create();
+ } else {
+- worldBorder.setDamageSafeZone((double)distance);
+- source.sendSuccess(() -> Component.translatable("commands.worldborder.damage.buffer.success", String.format(Locale.ROOT, "%.2f", distance)), true);
+- return (int)distance;
++ worldborder.setDamageSafeZone((double) distance);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.damage.buffer.success", String.format(Locale.ROOT, "%.2f", distance));
++ }, true);
++ return (int) distance;
+ }
+ }
+
+ private static int setDamageAmount(CommandSourceStack source, float damagePerBlock) throws CommandSyntaxException {
+- WorldBorder worldBorder = source.getServer().overworld().getWorldBorder();
+- if (worldBorder.getDamagePerBlock() == (double)damagePerBlock) {
+- throw ERROR_SAME_DAMAGE_AMOUNT.create();
++ WorldBorder worldborder = source.getLevel().getWorldBorder(); // CraftBukkit
++
++ if (worldborder.getDamagePerBlock() == (double) damagePerBlock) {
++ throw WorldBorderCommand.ERROR_SAME_DAMAGE_AMOUNT.create();
+ } else {
+- worldBorder.setDamagePerBlock((double)damagePerBlock);
+- source.sendSuccess(
+- () -> Component.translatable("commands.worldborder.damage.amount.success", String.format(Locale.ROOT, "%.2f", damagePerBlock)), true
+- );
+- return (int)damagePerBlock;
++ worldborder.setDamagePerBlock((double) damagePerBlock);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.damage.amount.success", String.format(Locale.ROOT, "%.2f", damagePerBlock));
++ }, true);
++ return (int) damagePerBlock;
+ }
+ }
+
+ private static int setWarningTime(CommandSourceStack source, int time) throws CommandSyntaxException {
+- WorldBorder worldBorder = source.getServer().overworld().getWorldBorder();
+- if (worldBorder.getWarningTime() == time) {
+- throw ERROR_SAME_WARNING_TIME.create();
++ WorldBorder worldborder = source.getLevel().getWorldBorder(); // CraftBukkit
++
++ if (worldborder.getWarningTime() == time) {
++ throw WorldBorderCommand.ERROR_SAME_WARNING_TIME.create();
+ } else {
+- worldBorder.setWarningTime(time);
+- source.sendSuccess(() -> Component.translatable("commands.worldborder.warning.time.success", time), true);
++ worldborder.setWarningTime(time);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.warning.time.success", time);
++ }, true);
+ return time;
+ }
+ }
+
+ private static int setWarningDistance(CommandSourceStack source, int distance) throws CommandSyntaxException {
+- WorldBorder worldBorder = source.getServer().overworld().getWorldBorder();
+- if (worldBorder.getWarningBlocks() == distance) {
+- throw ERROR_SAME_WARNING_DISTANCE.create();
++ WorldBorder worldborder = source.getLevel().getWorldBorder(); // CraftBukkit
++
++ if (worldborder.getWarningBlocks() == distance) {
++ throw WorldBorderCommand.ERROR_SAME_WARNING_DISTANCE.create();
+ } else {
+- worldBorder.setWarningBlocks(distance);
+- source.sendSuccess(() -> Component.translatable("commands.worldborder.warning.distance.success", distance), true);
++ worldborder.setWarningBlocks(distance);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.warning.distance.success", distance);
++ }, true);
+ return distance;
+ }
+ }
+
+ private static int getSize(CommandSourceStack source) {
+- double size = source.getServer().overworld().getWorldBorder().getSize();
+- source.sendSuccess(() -> Component.translatable("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", size)), false);
+- return Mth.floor(size + 0.5);
++ double d0 = source.getLevel().getWorldBorder().getSize(); // CraftBukkit
++
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0));
++ }, false);
++ return Mth.floor(d0 + 0.5D);
+ }
+
+ private static int setCenter(CommandSourceStack source, Vec2 pos) throws CommandSyntaxException {
+- WorldBorder worldBorder = source.getServer().overworld().getWorldBorder();
+- if (worldBorder.getCenterX() == (double)pos.x && worldBorder.getCenterZ() == (double)pos.y) {
+- throw ERROR_SAME_CENTER.create();
+- } else if (!((double)Math.abs(pos.x) > 2.9999984E7) && !((double)Math.abs(pos.y) > 2.9999984E7)) {
+- worldBorder.setCenter((double)pos.x, (double)pos.y);
+- source.sendSuccess(
+- () -> Component.translatable(
+- "commands.worldborder.center.success", String.format(Locale.ROOT, "%.2f", pos.x), String.format(Locale.ROOT, "%.2f", pos.y)
+- ),
+- true
+- );
++ WorldBorder worldborder = source.getLevel().getWorldBorder(); // CraftBukkit
++
++ if (worldborder.getCenterX() == (double) pos.x && worldborder.getCenterZ() == (double) pos.y) {
++ throw WorldBorderCommand.ERROR_SAME_CENTER.create();
++ } else if ((double) Math.abs(pos.x) <= 2.9999984E7D && (double) Math.abs(pos.y) <= 2.9999984E7D) {
++ worldborder.setCenter((double) pos.x, (double) pos.y);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.center.success", String.format(Locale.ROOT, "%.2f", pos.x), String.format(Locale.ROOT, "%.2f", pos.y));
++ }, true);
+ return 0;
+ } else {
+- throw ERROR_TOO_FAR_OUT.create();
++ throw WorldBorderCommand.ERROR_TOO_FAR_OUT.create();
+ }
+ }
+
+- private static int setSize(CommandSourceStack source, double newSize, long time) throws CommandSyntaxException {
+- WorldBorder worldBorder = source.getServer().overworld().getWorldBorder();
+- double size = worldBorder.getSize();
+- if (size == newSize) {
+- throw ERROR_SAME_SIZE.create();
+- } else if (newSize < 1.0) {
+- throw ERROR_TOO_SMALL.create();
+- } else if (newSize > 5.999997E7F) {
+- throw ERROR_TOO_BIG.create();
++ private static int setSize(CommandSourceStack source, double newSize, long i) throws CommandSyntaxException {
++ WorldBorder worldborder = source.getLevel().getWorldBorder(); // CraftBukkit
++ double d1 = worldborder.getSize();
++
++ if (d1 == newSize) {
++ throw WorldBorderCommand.ERROR_SAME_SIZE.create();
++ } else if (newSize < 1.0D) {
++ throw WorldBorderCommand.ERROR_TOO_SMALL.create();
++ } else if (newSize > 5.9999968E7D) {
++ throw WorldBorderCommand.ERROR_TOO_BIG.create();
+ } else {
+- if (time > 0L) {
+- worldBorder.lerpSizeBetween(size, newSize, time);
+- if (newSize > size) {
+- source.sendSuccess(
+- () -> Component.translatable("commands.worldborder.set.grow", String.format(Locale.ROOT, "%.1f", newSize), Long.toString(time / 1000L)),
+- true
+- );
++ if (i > 0L) {
++ worldborder.lerpSizeBetween(d1, newSize, i);
++ if (newSize > d1) {
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.set.grow", String.format(Locale.ROOT, "%.1f", newSize), Long.toString(i / 1000L));
++ }, true);
+ } else {
+- source.sendSuccess(
+- () -> Component.translatable(
+- "commands.worldborder.set.shrink", String.format(Locale.ROOT, "%.1f", newSize), Long.toString(time / 1000L)
+- ),
+- true
+- );
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.set.shrink", String.format(Locale.ROOT, "%.1f", newSize), Long.toString(i / 1000L));
++ }, true);
+ }
+ } else {
+- worldBorder.setSize(newSize);
+- source.sendSuccess(() -> Component.translatable("commands.worldborder.set.immediate", String.format(Locale.ROOT, "%.1f", newSize)), true);
++ worldborder.setSize(newSize);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.worldborder.set.immediate", String.format(Locale.ROOT, "%.1f", newSize));
++ }, true);
+ }
+
+- return (int)(newSize - size);
++ return (int) (newSize - d1);
+ }
+ }
+ }