Initial commit based on mod template
This commit is contained in:
parent
5e4f705757
commit
9e5378cab4
26 changed files with 295 additions and 216 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
group=com.example
|
||||
group=eu.m724.worldborder
|
||||
version=1.0.0-SNAPSHOT
|
||||
description=Example mod for Ignite
|
||||
|
||||
|
|
|
@ -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" }
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -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
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
This file is part of Ignite, licensed under the MIT License (MIT).
|
||||
|
||||
Copyright (c) vectrix.space <https://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.
|
|
@ -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"
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* This file is part of Ignite, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) vectrix.space <https://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;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* This file is part of Ignite, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) vectrix.space <https://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 = "<init>", at = @At("RETURN"))
|
||||
private void onConstruction(CallbackInfo callback) {
|
||||
this.getLogger().info("Hello World!");
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* This file is part of Ignite, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) vectrix.space <https://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"));
|
||||
}
|
||||
}
|
|
@ -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;
|
9
src/main/java/eu/m724/worldborder/Numbers.java
Normal file
9
src/main/java/eu/m724/worldborder/Numbers.java
Normal file
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Integer> cir) {
|
||||
cir.setReturnValue(
|
||||
Mth.clamp(cir.getReturnValue(), 0, aquiferCache.length - 1)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<Integer> cir) {
|
||||
cir.setReturnValue(Numbers.MAX_BORDER_RADIUS);
|
||||
}
|
||||
}
|
22
src/main/java/eu/m724/worldborder/mixin/MixinEntity.java
Normal file
22
src/main/java/eu/m724/worldborder/mixin/MixinEntity.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<Double> cir) {
|
||||
cir.setReturnValue(Mth.clamp(value, -Numbers.MAX_WORLD_RADIUS, Numbers.MAX_WORLD_RADIUS));
|
||||
}
|
||||
}
|
30
src/main/java/eu/m724/worldborder/mixin/MixinWorld.java
Normal file
30
src/main/java/eu/m724/worldborder/mixin/MixinWorld.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
20
src/main/java/eu/m724/worldborder/mixin/MixinWorldView.java
Normal file
20
src/main/java/eu/m724/worldborder/mixin/MixinWorldView.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "example",
|
||||
"id": "worldborder",
|
||||
"version": "1.0.0",
|
||||
"mixins": [
|
||||
"mixins.example.core.json"
|
||||
"mixins.worldborder.json"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
20
src/main/resources/mixins.worldborder.json
Normal file
20
src/main/resources/mixins.worldborder.json
Normal file
|
@ -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"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue