diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-03-16 21:07:06 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-03-16 21:07:06 +0100 |
| commit | 411484a33f6fa407de332ec9eddf8ecb65ee078c (patch) | |
| tree | 4e4d64fb1c8de84aa1d99036204e762f99a92199 | |
| parent | 28e2e6e284445f72514be092855285fd8291cbb5 (diff) | |
feat(): support java 1.21.11
| -rw-r--r-- | build.gradle | 23 | ||||
| -rw-r--r-- | gradle.properties | 10 | ||||
| -rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | gradlew | 0 | ||||
| -rw-r--r-- | src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java | 14 | ||||
| -rw-r--r-- | src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java | 2 | ||||
| -rw-r--r-- | src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java | 11 | ||||
| -rw-r--r-- | src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java | 19 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/Molehunt.java | 165 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/config/Config.java | 22 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java | 6 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/game/Game.java | 18 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/game/GamePayload.java | 2 | ||||
| -rw-r--r-- | src/main/resources/fabric.mod.json | 2 |
14 files changed, 154 insertions, 142 deletions
diff --git a/build.gradle b/build.gradle index 6ecb14b..d34a196 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.7-SNAPSHOT' + id 'fabric-loom' version '1.15-SNAPSHOT' id 'maven-publish' } @@ -52,32 +52,21 @@ processResources { } } -def targetJavaVersion = 21 tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. + it.options.release = 21 it.options.encoding = "UTF-8" - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release.set(targetJavaVersion) - } } java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } + rename { "${it}_${inputs.properties.archivesName}"} } } diff --git a/gradle.properties b/gradle.properties index e68a168..958a1c5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 -loader_version=0.16.2 +minecraft_version=1.21.11 +yarn_mappings=1.21.11+build.4 +loader_version=0.18.4 # Mod Properties mod_version=1.2.1 maven_group=world.anhgelus archives_base_name=Molehunt # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.102.1+1.21.1 +fabric_version=0.141.3+1.21.11 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..dbc3ce4 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.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index 75c927e..03198ee 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -28,13 +28,13 @@ public class MolehuntClient implements ClientModInitializer { ClientLifecycleEvents.CLIENT_STARTED.register(client -> { var options = client.options; - options.togglePlayerModelPart(PlayerModelPart.CAPE, true); - options.togglePlayerModelPart(PlayerModelPart.HAT, true); - options.togglePlayerModelPart(PlayerModelPart.JACKET, true); - options.togglePlayerModelPart(PlayerModelPart.LEFT_SLEEVE, true); - options.togglePlayerModelPart(PlayerModelPart.RIGHT_SLEEVE, true); - options.togglePlayerModelPart(PlayerModelPart.LEFT_PANTS_LEG, true); - options.togglePlayerModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true); + options.setPlayerModelPart(PlayerModelPart.CAPE, true); + options.setPlayerModelPart(PlayerModelPart.HAT, true); + options.setPlayerModelPart(PlayerModelPart.JACKET, true); + options.setPlayerModelPart(PlayerModelPart.LEFT_SLEEVE, true); + options.setPlayerModelPart(PlayerModelPart.RIGHT_SLEEVE, true); + options.setPlayerModelPart(PlayerModelPart.LEFT_PANTS_LEG, true); + options.setPlayerModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true); }); } diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java index 2ca0b4c..c2c0ab0 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java @@ -14,7 +14,7 @@ public abstract class NoCustomizableSkinOverlay { @Shadow private void setPlayerModelPart(PlayerModelPart part, boolean enabled) {} - @Inject(at = @At("HEAD"), method = "togglePlayerModelPart", cancellable = true) + @Inject(at = @At("HEAD"), method = "setPlayerModelPart", cancellable = true) public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) { if (MolehuntClient.showSkins()) return; setPlayerModelPart(part, true); diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java index 7f334a0..555fb00 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java @@ -1,9 +1,12 @@ package world.anhgelus.molehunt.client.mixin;
-import net.minecraft.client.render.VertexConsumerProvider;
+import net.minecraft.client.render.command.OrderedRenderCommandQueue;
import net.minecraft.client.render.entity.EntityRenderer;
+import net.minecraft.client.render.entity.state.EntityRenderState;
+import net.minecraft.client.render.state.CameraRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -12,10 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(EntityRenderer.class)
-public class NoNametags<T extends Entity> {
+public class NoNametags<T extends Entity, S extends EntityRenderState> {
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
- private void renderLabelOrNot(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
- if (!(entity instanceof PlayerEntity) || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted()) return;
+ private void renderLabelOrNot(S state, MatrixStack matrices, OrderedRenderCommandQueue queue, CameraRenderState cameraState, CallbackInfo ci) {
+ if (EntityType.PLAYER != state.entityType || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted()) return;
ci.cancel();
}
}
\ No newline at end of file diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java index 6638c1b..b6b67cc 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java @@ -1,7 +1,9 @@ package world.anhgelus.molehunt.client.mixin;
import net.minecraft.client.network.AbstractClientPlayerEntity;
-import net.minecraft.client.util.SkinTextures;
+import net.minecraft.entity.player.PlayerSkinType;
+import net.minecraft.entity.player.SkinTextures;
+import net.minecraft.util.AssetInfo;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -12,15 +14,14 @@ import world.anhgelus.molehunt.client.MolehuntClient; @Mixin(AbstractClientPlayerEntity.class)
public class NoSkin {
- @Inject(at = @At("HEAD"), method = "getSkinTextures", cancellable = true)
+ @Inject(at = @At("HEAD"), method = "getSkin", cancellable = true)
public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
if (MolehuntClient.showSkins() || !MolehuntClient.gameStarted()) return;
- cir.setReturnValue(new SkinTextures(
- Identifier.of(Molehunt.MOD_ID, "textures/skin.png"),
- null,
- null,
- null,
- SkinTextures.Model.WIDE, true)
- );
+ cir.setReturnValue(SkinTextures.create(
+ new AssetInfo.TextureAssetInfo(Identifier.of(Molehunt.MOD_ID, "skin")),
+ null,
+ null,
+ PlayerSkinType.WIDE
+ ));
}
}
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index 7fa10a3..8df6e32 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -7,19 +7,23 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; -import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry; +import net.fabricmc.fabric.api.gamerule.v1.GameRuleBuilder; +import net.fabricmc.fabric.api.gamerule.v1.GameRuleEvents; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.Identifier; import net.minecraft.world.GameMode; -import net.minecraft.world.GameRules; +import net.minecraft.world.rule.GameRule; +import net.minecraft.world.rule.GameRuleCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import world.anhgelus.molehunt.config.Config; @@ -29,6 +33,7 @@ import world.anhgelus.molehunt.game.Game; import world.anhgelus.molehunt.game.GamePayload; import java.util.HashMap; +import java.util.UUID; import static net.minecraft.server.command.CommandManager.literal; @@ -41,93 +46,100 @@ public class Molehunt implements ModInitializer { public static final SimpleConfig CONFIG_FILE = Config.configFile(MOD_ID); - public static final GameRules.Key<GameRules.IntRule> GAME_DURATION = GameRuleRegistry.register( - MOD_ID +":gameDurationMinutes", - GameRules.Category.MISC, - GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("game_duration", 90)) - ); - public static final GameRules.Key<GameRules.IntRule> MOLE_PERCENTAGE = GameRuleRegistry.register( - MOD_ID +":molePercentage", - GameRules.Category.MISC, - GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("mole_percentage", 25)) - ); - public static final GameRules.Key<GameRules.IntRule> MOLE_COUNT = GameRuleRegistry.register( - MOD_ID +":moleCount", - GameRules.Category.MISC, - GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("mole_count", -1)) - ); - public static final GameRules.Key<GameRules.BooleanRule> SHOW_NAMETAGS = GameRuleRegistry.register( - MOD_ID +":showNametags", - GameRules.Category.MISC, - GameRuleFactory.createBooleanRule(CONFIG_FILE.getOrDefault("show_nametags", false), (server, val) -> { - if (CONFIG == null) return; - CONFIG.sendConfigPayload(); - }) - ); - public static final GameRules.Key<GameRules.BooleanRule> SHOW_TAB = GameRuleRegistry.register( - MOD_ID +":showTab" - , GameRules.Category.MISC, - GameRuleFactory.createBooleanRule(CONFIG_FILE.getOrDefault("show_tab", false), (server, val) -> { - if (CONFIG == null) return; - CONFIG.sendConfigPayload(); - }) - ); - public static final GameRules.Key<GameRules.BooleanRule> SHOW_SKINS = GameRuleRegistry.register( - MOD_ID +":showSkins", - GameRules.Category.MISC, - GameRuleFactory.createBooleanRule(CONFIG_FILE.getOrDefault("show_skins", false), (server, val) -> { - if (CONFIG == null) return; - CONFIG.sendConfigPayload(); - }) - ); - public static final GameRules.Key<GameRules.IntRule> INITIAL_WORLD_SIZE = GameRuleRegistry.register( - MOD_ID +":initialWorldSize", - GameRules.Category.MISC, - GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("initial_world_size", 600), 0) - ); - public static final GameRules.Key<GameRules.IntRule> FINAL_WORLD_SIZE = GameRuleRegistry.register( - MOD_ID +":finalWorldSize", - GameRules.Category.MISC, - GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("final_world_size", 100), 0) - ); - public static final GameRules.Key<GameRules.IntRule> MOVING_STARTING_TIME_OFFSET = GameRuleRegistry.register( - MOD_ID +":borderMovingStartingTimeOffsetMinutes", - GameRules.Category.MISC, - GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("border_moving_starting_time_offset", 30), 0) - ); - public static final GameRules.Key<GameRules.BooleanRule> ENABLE_PORTALS = GameRuleRegistry.register( - MOD_ID +":enablePortals", - GameRules.Category.MISC, - GameRuleFactory.createBooleanRule(CONFIG_FILE.getOrDefault("enable_portals", false)) - ); - public static final GameRules.Key<GameRules.BooleanRule> FOOD_ON_START = GameRuleRegistry.register( - MOD_ID +":foodOnStart", - GameRules.Category.MISC, - GameRuleFactory.createBooleanRule(CONFIG_FILE.getOrDefault("food_on_start", true)) - ); + public static final GameRule<Integer> GAME_DURATION = GameRuleBuilder + .forInteger(CONFIG_FILE.getOrDefault("game_duration", 90)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "gameDurationMinutes")); + + public static final GameRule<Integer> MOLE_PERCENTAGE = GameRuleBuilder + .forInteger(CONFIG_FILE.getOrDefault("mole_percentage", 25)) + .range(0, 100) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "molePercentage")); + + public static final GameRule<Integer> MOLE_COUNT = GameRuleBuilder + .forInteger(CONFIG_FILE.getOrDefault("mole_count", -1)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "moleCount")); + + public static final GameRule<Boolean> SHOW_NAMETAGS = GameRuleBuilder + .forBoolean(CONFIG_FILE.getOrDefault("show_nametags", false)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "showNametags")); + + public static final GameRule<Boolean> SHOW_TAB = GameRuleBuilder + .forBoolean(CONFIG_FILE.getOrDefault("show_tab", false)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "showTab")); + + public static final GameRule<Boolean> SHOW_SKINS = GameRuleBuilder + .forBoolean(CONFIG_FILE.getOrDefault("show_skins", false)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "showSkins")); + + public static final GameRule<Integer> INITIAL_WORLD_SIZE = GameRuleBuilder + .forInteger(CONFIG_FILE.getOrDefault("initial_world_size", 600)) + .minValue(0) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "initialWorldSize")); + + public static final GameRule<Integer> FINAL_WORLD_SIZE = GameRuleBuilder + .forInteger(CONFIG_FILE.getOrDefault("final_world_size", 100)) + .minValue(0) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "finalWorldSize")); + + public static final GameRule<Integer> MOVING_STARTING_TIME_OFFSET = GameRuleBuilder + .forInteger(CONFIG_FILE.getOrDefault("border_moving_starting_time_offset", 30)) + .minValue(0) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "borderMovingStartingTimeOffsetMinutes")); + + public static final GameRule<Boolean> ENABLE_PORTALS = GameRuleBuilder + .forBoolean(CONFIG_FILE.getOrDefault("enable_portals", false)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "enablePortals")); + + public static final GameRule<Boolean> FOOD_ON_START = GameRuleBuilder + .forBoolean(CONFIG_FILE.getOrDefault("food_on_start", true)) + .category(GameRuleCategory.MISC) + .buildAndRegister(Identifier.of(MOD_ID, "foodOnStart")); public Game game; - public static HashMap<ServerPlayerEntity, Boolean> timerVisibility = new HashMap<>(); + public static HashMap<UUID, Boolean> timerVisibility = new HashMap<>(); + + private static <T> void sendConfigPayload(T v, MinecraftServer server) { + if (CONFIG == null) return; + CONFIG.sendConfigPayload(); + } + + static { + GameRuleEvents.changeCallback(SHOW_NAMETAGS).register(Molehunt::sendConfigPayload); + GameRuleEvents.changeCallback(SHOW_TAB).register(Molehunt::sendConfigPayload); + GameRuleEvents.changeCallback(SHOW_SKINS).register(Molehunt::sendConfigPayload); + } @Override public void onInitialize() { LOGGER.info("Initializing Molehunt"); final var command = literal("molehunt"); - command.then(literal("start").requires(source -> source.hasPermissionLevel(1)).executes(context -> { + command.then(literal("start") + .requires(CommandManager.requirePermissionLevel(CommandManager.GAMEMASTERS_CHECK)) + .executes(context -> { game = new Game(context.getSource().getServer()); game.start(); return Command.SINGLE_SUCCESS; })); command.then(literal("timer").requires(ServerCommandSource::isExecutedByPlayer).then( literal("show").executes(context -> { - timerVisibility.put(context.getSource().getPlayer(), true); - context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.timer.show"), false); - var player = context.getSource().getPlayer(); assert player != null; + timerVisibility.put(player.getUuid(), true); + context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.timer.show"), false); + if (game == null || !game.started()) { player.networkHandler.sendPacket(new OverlayMessageS2CPacket( Text.translatable("commands.molehunt.error.game_not_started").formatted(Formatting.RED) @@ -140,7 +152,10 @@ public class Molehunt implements ModInitializer { }) ).then( literal("hide").executes(context -> { - timerVisibility.put(context.getSource().getPlayer(), false); + var player = context.getSource().getPlayer(); + assert player != null; + + timerVisibility.put(player.getUuid(), false); context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.timer.hide"), false); return Command.SINGLE_SUCCESS; }) @@ -174,7 +189,9 @@ public class Molehunt implements ModInitializer { return Command.SINGLE_SUCCESS; })); - command.then(literal("stop").requires(source -> source.hasPermissionLevel(1)).executes(context -> { + command.then(literal("stop") + .requires(CommandManager.requirePermissionLevel(CommandManager.GAMEMASTERS_CHECK)) + .executes(context -> { if (game == null || !game.started()) { throw (new SimpleCommandExceptionType(Text.translatable("commands.molehunt.error.game_not_started"))).create(); } diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java index e448f7d..08c3850 100644 --- a/src/main/java/world/anhgelus/molehunt/config/Config.java +++ b/src/main/java/world/anhgelus/molehunt/config/Config.java @@ -25,47 +25,47 @@ public class Config { } public int getGameDuration() { - return server.getGameRules().getInt(Molehunt.GAME_DURATION); + return server.getOverworld().getGameRules().getValue(Molehunt.GAME_DURATION); } public int getMolePercentage() { - return server.getGameRules().getInt(Molehunt.MOLE_PERCENTAGE); + return server.getOverworld().getGameRules().getValue(Molehunt.MOLE_PERCENTAGE); } public int getMoleCount() { - return server.getGameRules().getInt(Molehunt.MOLE_COUNT); + return server.getOverworld().getGameRules().getValue(Molehunt.MOLE_COUNT); } public boolean nametagsEnabled() { - return server.getGameRules().getBoolean(Molehunt.SHOW_NAMETAGS); + return server.getOverworld().getGameRules().getValue(Molehunt.SHOW_NAMETAGS); } public boolean skinsEnabled() { - return server.getGameRules().getBoolean(Molehunt.SHOW_SKINS); + return server.getOverworld().getGameRules().getValue(Molehunt.SHOW_SKINS); } public boolean tabEnabled() { - return server.getGameRules().getBoolean(Molehunt.SHOW_TAB); + return server.getOverworld().getGameRules().getValue(Molehunt.SHOW_TAB); } public int getInitialWorldSize() { - return server.getGameRules().getInt(Molehunt.INITIAL_WORLD_SIZE); + return server.getOverworld().getGameRules().getValue(Molehunt.INITIAL_WORLD_SIZE); } public int getFinalWorldSize() { - return server.getGameRules().getInt(Molehunt.FINAL_WORLD_SIZE); + return server.getOverworld().getGameRules().getValue(Molehunt.FINAL_WORLD_SIZE); } public int getBorderShrinkingStartingTimeOffset() { - return server.getGameRules().getInt(Molehunt.MOVING_STARTING_TIME_OFFSET); + return server.getOverworld().getGameRules().getValue(Molehunt.MOVING_STARTING_TIME_OFFSET); } public boolean portalsEnabled() { - return server.getGameRules().getBoolean(Molehunt.ENABLE_PORTALS); + return server.getOverworld().getGameRules().getValue(Molehunt.ENABLE_PORTALS); } public boolean foodOnStart() { - return server.getGameRules().getBoolean(Molehunt.FOOD_ON_START); + return server.getOverworld().getGameRules().getValue(Molehunt.FOOD_ON_START); } public static SimpleConfig configFile(String fileName) { diff --git a/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java b/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java index 0123e74..b43bd1b 100644 --- a/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java +++ b/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java @@ -12,9 +12,9 @@ public record ConfigPayload(boolean showNametags, boolean showSkins, boolean sho public static final CustomPayload.Id<ConfigPayload> ID = new CustomPayload.Id<>(CONFIG_PACKET_ID);
public static final PacketCodec<RegistryByteBuf, ConfigPayload> CODEC = PacketCodec.tuple(
- PacketCodecs.BOOL, ConfigPayload::showNametags,
- PacketCodecs.BOOL, ConfigPayload::showSkins,
- PacketCodecs.BOOL, ConfigPayload::showTab,
+ PacketCodecs.BOOLEAN, ConfigPayload::showNametags,
+ PacketCodecs.BOOLEAN, ConfigPayload::showSkins,
+ PacketCodecs.BOOLEAN, ConfigPayload::showTab,
ConfigPayload::new
);
diff --git a/src/main/java/world/anhgelus/molehunt/game/Game.java b/src/main/java/world/anhgelus/molehunt/game/Game.java index 58ea4ee..117dbce 100644 --- a/src/main/java/world/anhgelus/molehunt/game/Game.java +++ b/src/main/java/world/anhgelus/molehunt/game/Game.java @@ -11,7 +11,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.world.GameMode;
-import net.minecraft.world.GameRules;
+import net.minecraft.world.rule.GameRules;
import world.anhgelus.molehunt.Molehunt;
import world.anhgelus.molehunt.utils.TimeUtils;
@@ -53,12 +53,12 @@ public class Game { players.remove(r);
}
- final var gamerules = server.getGameRules();
+ final var gamerules = server.getOverworld().getGameRules();
// immutable gamerules
- gamerules.get(GameRules.SHOW_DEATH_MESSAGES).set(false, server);
- gamerules.get(GameRules.ANNOUNCE_ADVANCEMENTS).set(false, server);
+ gamerules.setValue(GameRules.SHOW_DEATH_MESSAGES, false, server);
+ gamerules.setValue(GameRules.ANNOUNCE_ADVANCEMENTS, false, server);
// gamerules for the start
- gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(true, server);
+ gamerules.setValue(GameRules.DO_IMMEDIATE_RESPAWN, true, server);
final var worldBorder = server.getOverworld().getWorldBorder();
worldBorder.setSize(Molehunt.CONFIG.getInitialWorldSize());
@@ -70,7 +70,9 @@ public class Game { worldBorder.interpolateSize(
Molehunt.CONFIG.getInitialWorldSize(),
Molehunt.CONFIG.getFinalWorldSize(),
- (long) (Molehunt.CONFIG.getGameDuration() - Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset()) * 60 * 1000);
+ (long) (Molehunt.CONFIG.getGameDuration() - Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset()) * 60 * 1000,
+ 0L
+ );
}
}, (long) Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() * 60 * 1000);
}
@@ -78,7 +80,7 @@ public class Game { final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense"));
playerManager.getPlayerList().forEach(p -> {
p.getInventory().clear();
- p.kill();
+ p.kill(p.getEntityWorld());
p.networkHandler.sendPacket(timing);
p.networkHandler.sendPacket(title);
p.changeGameMode(GameMode.SURVIVAL);
@@ -105,7 +107,7 @@ public class Game { p.getHungerManager().setSaturationLevel(5.0f);
});
// reset gamerules after the start
- gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(false, server);
+ gamerules.setValue(GameRules.DO_IMMEDIATE_RESPAWN, false, server);
// reset time and weather
server.getOverworld().setTimeOfDay(0);
server.getOverworld().resetWeather();
diff --git a/src/main/java/world/anhgelus/molehunt/game/GamePayload.java b/src/main/java/world/anhgelus/molehunt/game/GamePayload.java index 4f7b8ce..66e3209 100644 --- a/src/main/java/world/anhgelus/molehunt/game/GamePayload.java +++ b/src/main/java/world/anhgelus/molehunt/game/GamePayload.java @@ -12,7 +12,7 @@ public record GamePayload(boolean gameLaunched) implements CustomPayload { public static final CustomPayload.Id<GamePayload> ID = new CustomPayload.Id<>(GAME_PACKET_ID);
public static final PacketCodec<RegistryByteBuf, GamePayload> CODEC = PacketCodec.tuple(
- PacketCodecs.BOOL, GamePayload::gameLaunched,
+ PacketCodecs.BOOLEAN, GamePayload::gameLaunched,
GamePayload::new
);
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 81d7829..09a65fe 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ ], "depends": { "fabricloader": ">=${loader_version}", - "fabric": "*", + "fabric-api": "*", "minecraft": "${minecraft_version}" } } |
