diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts
index 81f2f92..33b8f86 100644
--- a/build-logic/build.gradle.kts
+++ b/build-logic/build.gradle.kts
@@ -13,15 +13,15 @@ dependencies {
}
java {
- sourceCompatibility = JavaVersion.VERSION_11
- targetCompatibility = JavaVersion.VERSION_11
+ sourceCompatibility = JavaVersion.VERSION_21
+ targetCompatibility = JavaVersion.VERSION_21
}
kotlin {
target {
compilations.configureEach {
kotlinOptions {
- jvmTarget = "11"
+ jvmTarget = "21"
}
}
}
diff --git a/build-logic/src/main/kotlin/mod.base-conventions.gradle.kts b/build-logic/src/main/kotlin/mod.base-conventions.gradle.kts
index e84eb1d..901c0cc 100644
--- a/build-logic/src/main/kotlin/mod.base-conventions.gradle.kts
+++ b/build-logic/src/main/kotlin/mod.base-conventions.gradle.kts
@@ -1,8 +1,8 @@
import com.diffplug.gradle.spotless.FormatExtension
-import java.nio.charset.StandardCharsets
-import java.nio.file.Files
-import java.util.regex.Pattern
-import java.util.stream.Collectors
+import gradle.kotlin.dsl.accessors._43f5a8ee9331a3869a213f1d800d4801.compileOnlyApi
+import gradle.kotlin.dsl.accessors._43f5a8ee9331a3869a213f1d800d4801.java
+import gradle.kotlin.dsl.accessors._43f5a8ee9331a3869a213f1d800d4801.reobfJar
+import gradle.kotlin.dsl.accessors._43f5a8ee9331a3869a213f1d800d4801.spotless
plugins {
`java-library`
@@ -16,7 +16,7 @@ plugins {
val libs = extensions.getByType(org.gradle.accessors.dm.LibrariesForLibs::class)
java {
- javaTarget(17)
+ javaTarget(21)
withSourcesJar()
}
@@ -38,32 +38,8 @@ spotless {
indentWithSpaces(2)
}
- fun formatLicense(): String {
- val splitPattern = Pattern.compile("\r?\n")
- val lineSeparator = System.lineSeparator()
- val headerPrefix = "/*$lineSeparator"
- val linePrefix = " * "
- val headerSuffix = "$lineSeparator */"
-
- val headerText = String(Files.readAllBytes(rootProject.file("license_header.txt").toPath()), StandardCharsets.UTF_8)
-
- return splitPattern.splitAsStream(headerText)
- .map {
- StringBuilder(it.length + 4)
- .append(linePrefix)
- .append(it)
- .toString()
- }
- .collect(Collectors.joining(
- lineSeparator,
- headerPrefix,
- headerSuffix
- ))
- }
-
java {
- licenseHeader(formatLicense())
applyCommon()
}
diff --git a/build.gradle.kts b/build.gradle.kts
index 927c370..3b3f411 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,7 +3,7 @@ plugins {
}
dependencies {
- remapper("net.fabricmc:tiny-remapper:0.10.1:fat")
+ remapper("net.fabricmc:tiny-remapper:0.10.4:fat")
compileOnly(libs.ignite)
compileOnly(libs.mixin)
diff --git a/gradle.properties b/gradle.properties
index 51ecd66..f8311d2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-group=com.example
+group=eu.m724.worldborder
version=1.0.0-SNAPSHOT
description=Example mod for Ignite
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index cbac33d..ce7a7fd 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -2,14 +2,14 @@ metadata.format.version = "1.1"
[versions]
-jetbrains = "24.1.0"
-ignite = "1.0.0"
-mixin = "0.8.5"
-mixinExtras = "0.3.5"
-paperweight = "1.5.11"
+jetbrains = "26.0.1"
+ignite = "1.1.0"
+mixin = "0.8.7"
+mixinExtras = "0.4.1"
+paperweight = "1.7.5"
shadow = "8.1.1"
-spotless = "6.23.3"
-paper = "1.20.4-R0.1-SNAPSHOT"
+spotless = "6.25.0"
+paper = "1.21.1-R0.1-SNAPSHOT"
[libraries]
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3499ded..5c40527 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/license_header.txt b/license_header.txt
deleted file mode 100644
index d5d50b8..0000000
--- a/license_header.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-This file is part of Ignite, licensed under the MIT License (MIT).
-
-Copyright (c) vectrix.space
-Copyright (c) contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 3e00c33..7a0eaf7 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -7,9 +7,9 @@ pluginManagement {
}
plugins {
- id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
+ id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
-rootProject.name = "ignite-mod-template"
+rootProject.name = "worldborder"
diff --git a/src/main/java/com/example/command/HelloCommand.java b/src/main/java/com/example/command/HelloCommand.java
deleted file mode 100644
index 5a4f4c6..0000000
--- a/src/main/java/com/example/command/HelloCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is part of Ignite, licensed under the MIT License (MIT).
- *
- * Copyright (c) vectrix.space
- * Copyright (c) contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.example.command;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.defaults.BukkitCommand;
-import org.checkerframework.checker.nullness.qual.NonNull;
-
-public final class HelloCommand extends BukkitCommand {
- public HelloCommand(final @NonNull String name) {
- super(name);
-
- this.setPermission("example.hello");
- }
-
- @Override
- public boolean execute(final @NonNull CommandSender commandSender, final @NonNull String currentAlias, final @NonNull String[] args) {
- if (!this.testPermission(commandSender)) {
- return true;
- } else {
- commandSender.sendMessage("Hello " + commandSender.getName());
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/example/mixin/core/MixinCraftServer.java b/src/main/java/com/example/mixin/core/MixinCraftServer.java
deleted file mode 100644
index 692ac07..0000000
--- a/src/main/java/com/example/mixin/core/MixinCraftServer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of Ignite, licensed under the MIT License (MIT).
- *
- * Copyright (c) vectrix.space
- * Copyright (c) contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.example.mixin.core;
-
-import java.util.logging.Logger;
-import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-@Mixin(value = CraftServer.class)
-public abstract class MixinCraftServer {
- @Shadow public abstract Logger getLogger();
-
- @Inject(method = "", at = @At("RETURN"))
- private void onConstruction(CallbackInfo callback) {
- this.getLogger().info("Hello World!");
- }
-}
diff --git a/src/main/java/com/example/mixin/core/MixinSimpleCommandMap.java b/src/main/java/com/example/mixin/core/MixinSimpleCommandMap.java
deleted file mode 100644
index 1e86760..0000000
--- a/src/main/java/com/example/mixin/core/MixinSimpleCommandMap.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * This file is part of Ignite, licensed under the MIT License (MIT).
- *
- * Copyright (c) vectrix.space
- * Copyright (c) contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.example.mixin.core;
-
-import com.example.command.HelloCommand;
-import org.bukkit.command.Command;
-import org.bukkit.command.SimpleCommandMap;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-@Mixin(value = SimpleCommandMap.class)
-public abstract class MixinSimpleCommandMap {
- @Shadow public abstract boolean register(String fallbackPrefix, Command command);
-
- @Inject(method = "setDefaultCommands()V", at = @At("TAIL"), remap = false)
- public void registerOwnCommands(CallbackInfo callback) {
- this.register("example", new HelloCommand("hello"));
- }
-}
diff --git a/src/main/java/com/example/mixin/plugins/CorePlugin.java b/src/main/java/eu/m724/worldborder/CorePlugin.java
similarity index 98%
rename from src/main/java/com/example/mixin/plugins/CorePlugin.java
rename to src/main/java/eu/m724/worldborder/CorePlugin.java
index dde3a47..393ad76 100644
--- a/src/main/java/com/example/mixin/plugins/CorePlugin.java
+++ b/src/main/java/eu/m724/worldborder/CorePlugin.java
@@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-package com.example.mixin.plugins;
+package eu.m724.worldborder;
import java.util.List;
import java.util.Set;
diff --git a/src/main/java/eu/m724/worldborder/Numbers.java b/src/main/java/eu/m724/worldborder/Numbers.java
new file mode 100644
index 0000000..aab2484
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/Numbers.java
@@ -0,0 +1,9 @@
+package eu.m724.worldborder;
+
+public class Numbers {
+ public static final int MAX_WORLD_RADIUS = 33554431;
+
+ public static final int MAX_BORDER_RADIUS = MAX_WORLD_RADIUS - 16;
+ public static final int MAX_WORLD_DIAMETER = MAX_WORLD_RADIUS * 2;
+ public static final int MAX_BORDER_DIAMETER = MAX_BORDER_RADIUS * 2;
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MinecraftServerMixin.java b/src/main/java/eu/m724/worldborder/mixin/MinecraftServerMixin.java
new file mode 100644
index 0000000..48003b3
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MinecraftServerMixin.java
@@ -0,0 +1,18 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.server.MinecraftServer;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.Constant;
+import org.spongepowered.asm.mixin.injection.ModifyConstant;
+
+// used for integrated server, dedicated has radius set in server.properties
+
+@Mixin(MinecraftServer.class)
+public class MinecraftServerMixin {
+ @ModifyConstant(method = "getAbsoluteMaxWorldSize", constant = @Constant(intValue = 29999984))
+ public int a(int v) {
+ return Numbers.MAX_BORDER_RADIUS;
+ }
+
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinAquiferSampler.java b/src/main/java/eu/m724/worldborder/mixin/MixinAquiferSampler.java
new file mode 100644
index 0000000..2ec6112
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinAquiferSampler.java
@@ -0,0 +1,25 @@
+package eu.m724.worldborder.mixin;
+
+import net.minecraft.util.Mth;
+import net.minecraft.world.level.levelgen.Aquifer;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+// fixes a crash too
+
+@Mixin(Aquifer.NoiseBasedAquifer.class)
+public abstract class MixinAquiferSampler {
+ @Shadow @Final
+ private Aquifer.FluidStatus[] aquiferCache;
+
+ @Inject(method = "getIndex", at = @At("RETURN"), cancellable = true)
+ public void index(int x, int y, int z, CallbackInfoReturnable cir) {
+ cir.setReturnValue(
+ Mth.clamp(cir.getReturnValue(), 0, aquiferCache.length - 1)
+ );
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinDedicatedServer.java b/src/main/java/eu/m724/worldborder/mixin/MixinDedicatedServer.java
new file mode 100644
index 0000000..efc6523
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinDedicatedServer.java
@@ -0,0 +1,19 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.server.dedicated.DedicatedServer;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+// this is only for the dedicated server, it modifies range of the max border radius in server.properties, MinecraftServerMixin handles integrated
+// TODO make it actually do that
+
+@Mixin(DedicatedServer.class)
+public class MixinDedicatedServer {
+ @Inject(method = "getAbsoluteMaxWorldSize", at = @At("HEAD"), cancellable = true)
+ public void a(CallbackInfoReturnable cir) {
+ cir.setReturnValue(Numbers.MAX_BORDER_RADIUS);
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinEntity.java b/src/main/java/eu/m724/worldborder/mixin/MixinEntity.java
new file mode 100644
index 0000000..63d1d8c
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinEntity.java
@@ -0,0 +1,22 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.util.Mth;
+import net.minecraft.world.entity.Entity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(Entity.class)
+public abstract class MixinEntity {
+ @Redirect(method = "absMoveTo(DDD)V", at = @At(target = "Lnet/minecraft/util/Mth;clamp(DDD)D", value = "INVOKE"))
+ private double redirectClamp(double value, double min, double max) {
+ return Mth.clamp(value, -Numbers.MAX_WORLD_RADIUS, Numbers.MAX_WORLD_RADIUS);
+ }
+
+ @Redirect(method = "load", at = @At(target = "Lnet/minecraft/util/Mth;clamp(DDD)D", value = "INVOKE"))
+ private double redirectClampReadNbt(double value, double min, double max) {
+ // +512 is in Minecraft source, so I just copied it
+ return Mth.clamp(value, -Numbers.MAX_WORLD_RADIUS - 512, Numbers.MAX_WORLD_RADIUS + 512);
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinPlayerEntity.java b/src/main/java/eu/m724/worldborder/mixin/MixinPlayerEntity.java
new file mode 100644
index 0000000..cc1dccc
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinPlayerEntity.java
@@ -0,0 +1,16 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.util.Mth;
+import net.minecraft.world.entity.player.Player;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(Player.class)
+public abstract class MixinPlayerEntity {
+ @Redirect(method = "tick", at = @At(target = "Lnet/minecraft/util/Mth;clamp(DDD)D", value = "INVOKE"))
+ private double redirectClamp(double value, double min, double max) {
+ return Mth.clamp(value, -Numbers.MAX_WORLD_RADIUS + 1, Numbers.MAX_WORLD_RADIUS - 1);
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinServerPlayNetworkHandler.java b/src/main/java/eu/m724/worldborder/mixin/MixinServerPlayNetworkHandler.java
new file mode 100644
index 0000000..e4c5c27
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinServerPlayNetworkHandler.java
@@ -0,0 +1,19 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
+import net.minecraft.util.Mth;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+// allows for movement beyond the hardcoded 30 mil (server side)
+
+@Mixin(ServerGamePacketListenerImpl.class)
+public abstract class MixinServerPlayNetworkHandler {
+ @Inject(method = "clampHorizontal", at = @At("RETURN"), cancellable = true)
+ private static void clampHorizontal(double value, CallbackInfoReturnable cir) {
+ cir.setReturnValue(Mth.clamp(value, -Numbers.MAX_WORLD_RADIUS, Numbers.MAX_WORLD_RADIUS));
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinWorld.java b/src/main/java/eu/m724/worldborder/mixin/MixinWorld.java
new file mode 100644
index 0000000..c1b7c3c
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinWorld.java
@@ -0,0 +1,30 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.world.level.Level;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.Constant;
+import org.spongepowered.asm.mixin.injection.ModifyConstant;
+
+@Mixin(Level.class)
+public class MixinWorld {
+ @ModifyConstant(method = "isInWorldBoundsHorizontal", constant = @Constant(intValue = -30000000))
+ private static int injected3(int value) {
+ return -Numbers.MAX_WORLD_RADIUS;
+ }
+
+ @ModifyConstant(method = "isInWorldBoundsHorizontal", constant = @Constant(intValue = 30000000))
+ private static int injected4(int value) {
+ return Numbers.MAX_WORLD_RADIUS;
+ }
+
+ @ModifyConstant(method = "getHeight", constant = @Constant(intValue = -30000000))
+ private int injected1(int value) {
+ return -Numbers.MAX_WORLD_RADIUS;
+ }
+
+ @ModifyConstant(method = "getHeight", constant = @Constant(intValue = 30000000))
+ private int injected2(int value) {
+ return Numbers.MAX_WORLD_RADIUS;
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinWorldBorderCommand.java b/src/main/java/eu/m724/worldborder/mixin/MixinWorldBorderCommand.java
new file mode 100644
index 0000000..e195015
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinWorldBorderCommand.java
@@ -0,0 +1,48 @@
+package eu.m724.worldborder.mixin;
+
+import com.mojang.brigadier.arguments.DoubleArgumentType;
+import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
+import eu.m724.worldborder.Numbers;
+import net.minecraft.network.chat.Component;
+import net.minecraft.server.commands.WorldBorderCommand;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Constant;
+import org.spongepowered.asm.mixin.injection.ModifyConstant;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(WorldBorderCommand.class)
+public abstract class MixinWorldBorderCommand {
+
+ @Shadow
+ private static final SimpleCommandExceptionType ERROR_TOO_BIG = new SimpleCommandExceptionType(
+ Component.translatable("commands.worldborder.set.failed.big", Numbers.MAX_BORDER_DIAMETER)
+ );
+ @Shadow
+ private static final SimpleCommandExceptionType ERROR_TOO_FAR_OUT = new SimpleCommandExceptionType(
+ Component.translatable("commands.worldborder.set.failed.far", Numbers.MAX_BORDER_RADIUS)
+ );
+
+ @Redirect(
+ method = "register",
+ at = @At(
+ value = "INVOKE",
+ target = "Lcom/mojang/brigadier/arguments/DoubleArgumentType;doubleArg(DD)Lcom/mojang/brigadier/arguments/DoubleArgumentType;"
+ )
+ )
+ private static DoubleArgumentType register(double min, double max) {
+ return DoubleArgumentType.doubleArg(0, Numbers.MAX_BORDER_DIAMETER);
+ }
+
+ @ModifyConstant(method = "setSize", constant = @Constant(doubleValue = 5.9999968E7))
+ private static double executeSet(double original) {
+ return Numbers.MAX_BORDER_DIAMETER;
+ }
+
+ @ModifyConstant(method = "setCenter", constant = @Constant(doubleValue = 2.9999984E7))
+ private static double executeCenter(double original) {
+ return Numbers.MAX_BORDER_RADIUS;
+ }
+
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/MixinWorldView.java b/src/main/java/eu/m724/worldborder/mixin/MixinWorldView.java
new file mode 100644
index 0000000..4f8e354
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/MixinWorldView.java
@@ -0,0 +1,20 @@
+package eu.m724.worldborder.mixin;
+
+import eu.m724.worldborder.Numbers;
+import net.minecraft.world.level.LevelReader;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.Constant;
+import org.spongepowered.asm.mixin.injection.ModifyConstant;
+
+@Mixin(LevelReader.class)
+public interface MixinWorldView {
+ @ModifyConstant(method = "getMaxLocalRawBrightness(Lnet/minecraft/core/BlockPos;I)I", constant = @Constant(intValue = -30000000))
+ default int a(int constant) {
+ return -Numbers.MAX_WORLD_RADIUS;
+ }
+
+ @ModifyConstant(method = "getMaxLocalRawBrightness(Lnet/minecraft/core/BlockPos;I)I", constant = @Constant(intValue = 30000000))
+ default int b(int constant) {
+ return Numbers.MAX_WORLD_RADIUS;
+ }
+}
diff --git a/src/main/java/eu/m724/worldborder/mixin/SectionedEntityCacheMixin.java b/src/main/java/eu/m724/worldborder/mixin/SectionedEntityCacheMixin.java
new file mode 100644
index 0000000..8356ecb
--- /dev/null
+++ b/src/main/java/eu/m724/worldborder/mixin/SectionedEntityCacheMixin.java
@@ -0,0 +1,26 @@
+package eu.m724.worldborder.mixin;
+
+import it.unimi.dsi.fastutil.longs.LongAVLTreeSet;
+import it.unimi.dsi.fastutil.longs.LongSortedSet;
+import net.minecraft.world.level.entity.EntitySectionStorage;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+// fixes a crash
+
+@Mixin(EntitySectionStorage.class)
+public class SectionedEntityCacheMixin {
+
+ @Redirect(
+ method = "forEachAccessibleNonEmptySection",
+ at = @At(
+ value = "INVOKE",
+ target = "Lit/unimi/dsi/fastutil/longs/LongSortedSet;subSet(JJ)Lit/unimi/dsi/fastutil/longs/LongSortedSet;"
+ )
+ )
+ public LongSortedSet a(LongSortedSet instance, long left, long right) {
+ return left > right ? new LongAVLTreeSet() : instance.subSet(left, right);
+ }
+
+}
diff --git a/src/main/resources/ignite.mod.json b/src/main/resources/ignite.mod.json
index 181ae7a..97e0b9b 100644
--- a/src/main/resources/ignite.mod.json
+++ b/src/main/resources/ignite.mod.json
@@ -1,7 +1,7 @@
{
- "id": "example",
+ "id": "worldborder",
"version": "1.0.0",
"mixins": [
- "mixins.example.core.json"
+ "mixins.worldborder.json"
]
}
diff --git a/src/main/resources/mixins.example.core.json b/src/main/resources/mixins.example.core.json
deleted file mode 100644
index 7af2e18..0000000
--- a/src/main/resources/mixins.example.core.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "required": true,
- "minVersion": "0.8.5",
- "package": "com.example.mixin.core",
- "plugin": "com.example.mixin.plugins.CorePlugin",
- "target": "@env(DEFAULT)",
- "compatibilityLevel": "JAVA_17",
- "server": [
- "MixinCraftServer",
- "MixinSimpleCommandMap"
- ]
-}
diff --git a/src/main/resources/mixins.worldborder.json b/src/main/resources/mixins.worldborder.json
new file mode 100644
index 0000000..228683c
--- /dev/null
+++ b/src/main/resources/mixins.worldborder.json
@@ -0,0 +1,20 @@
+{
+ "required": true,
+ "minVersion": "0.8.7",
+ "package": "eu.m724.worldborder.mixin",
+ "plugin": "eu.m724.worldborder.CorePlugin",
+ "target": "@env(DEFAULT)",
+ "compatibilityLevel": "JAVA_21",
+ "mixins": [
+ "MinecraftServerMixin",
+ "MixinAquiferSampler",
+ "MixinEntity",
+ "MixinPlayerEntity",
+ "MixinServerPlayNetworkHandler",
+ "MixinWorld",
+ "MixinWorldBorderCommand",
+ "MixinWorldView",
+ "SectionedEntityCacheMixin",
+ "MixinDedicatedServer"
+ ]
+}