aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle13
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java6
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java129
3 files changed, 66 insertions, 82 deletions
diff --git a/build.gradle b/build.gradle
index f453021..878a388 100644
--- a/build.gradle
+++ b/build.gradle
@@ -39,15 +39,18 @@ dependencies {
}
processResources {
+ String mc_version = project.minecraft_version.replace("pre-", "pre.")
+ getLogger().info("version: {}", mc_version)
+
inputs.property "version", project.version
- inputs.property "minecraft_version", project.minecraft_version
+ inputs.property "minecraft_version", mc_version
inputs.property "loader_version", project.loader_version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
- expand "version": project.version,
- "minecraft_version": project.minecraft_version,
- "loader_version": project.loader_version
+ expand "version": inputs.properties.version,
+ "minecraft_version": inputs.properties.minecraft_version,
+ "loader_version": inputs.properties.loader_version
}
}
@@ -65,7 +68,7 @@ java {
jar {
from("LICENSE") {
- rename { "${it}_${inputs.properties.archivesName}"}
+ rename { "${it}_${inputs.properties.archivesName}" }
}
}
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 af299ea..bdba025 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java
@@ -3,7 +3,6 @@ package world.anhgelus.molehunt.client.mixin;
import net.minecraft.client.Options;
import net.minecraft.world.entity.player.PlayerModelPart;
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;
@@ -11,14 +10,9 @@ import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(Options.class)
public abstract class NoCustomizableSkinOverlay {
- @Shadow
- public void setModelPart(PlayerModelPart part, boolean enabled) {}
-
@Inject(at = @At("HEAD"), method = "setModelPart", cancellable = true)
public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) {
if (MolehuntClient.showSkins()) return;
- setModelPart(part, true);
- ((Options) (Object) this).broadcastOptions();
ci.cancel();
}
}
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java
index 984f906..966d6c5 100644
--- a/src/main/java/world/anhgelus/molehunt/Molehunt.java
+++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java
@@ -42,84 +42,71 @@ public class Molehunt implements ModInitializer {
public static final String MOD_ID = "molehunt";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
- public static Config CONFIG;
-
public static final SimpleConfig CONFIG_FILE = Config.configFile(MOD_ID);
-
public static final GameRule<Integer> GAME_DURATION = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("game_duration", 90))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "gameDurationMinutes"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "game_duration_minutes"));
public static final GameRule<Integer> MOLE_PERCENTAGE = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("mole_percentage", 25))
.range(0, 100)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "molePercentage"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "mole_percentage"));
public static final GameRule<Integer> MOLE_COUNT = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("mole_count", -1))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "moleCount"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "mole_count"));
public static final GameRule<Boolean> SHOW_NAMETAGS = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("show_nametags", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showNametags"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_nametags"));
public static final GameRule<Boolean> SHOW_TAB = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("show_tab", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showTab"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_tab"));
public static final GameRule<Boolean> SHOW_SKINS = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("show_skins", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showSkins"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_skins"));
public static final GameRule<Integer> INITIAL_WORLD_SIZE = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("initial_world_size", 600))
.minValue(0)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initialWorldSize"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initial_world_size"));
public static final GameRule<Integer> FINAL_WORLD_SIZE = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("final_world_size", 100))
.minValue(0)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "finalWorldSize"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "final_world_size"));
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.fromNamespaceAndPath(MOD_ID, "borderMovingStartingTimeOffsetMinutes"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "border_moving_starting_time_offset_minutes"));
public static final GameRule<Boolean> ENABLE_PORTALS = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("enable_portals", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enablePortals"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enable_portals"));
public static final GameRule<Boolean> FOOD_ON_START = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("food_on_start", true))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "foodOnStart"));
-
- public Game game;
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "food_on_start"));
+ public static Config CONFIG;
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);
}
+ public Game game;
+
+ private static <T> void sendConfigPayload(T v, MinecraftServer server) {
+ if (CONFIG == null) return;
+ CONFIG.sendConfigPayload();
+ }
+
@Override
public void onInitialize() {
LOGGER.info("Initializing Molehunt");
@@ -128,10 +115,10 @@ public class Molehunt implements ModInitializer {
command.then(literal("start")
.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
.executes(context -> {
- game = new Game(context.getSource().getServer());
- game.start();
- return Command.SINGLE_SUCCESS;
- }));
+ game = new Game(context.getSource().getServer());
+ game.start();
+ return Command.SINGLE_SUCCESS;
+ }));
command.then(literal("timer").requires(CommandSourceStack::isPlayer).then(
literal("show").executes(context -> {
var player = context.getSource().getPlayer();
@@ -142,7 +129,7 @@ public class Molehunt implements ModInitializer {
if (game == null || !game.started()) {
player.connection.send(new ClientboundSetActionBarTextPacket(
- Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED)
+ Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED)
));
} else {
player.connection.send(new ClientboundSetActionBarTextPacket(Component.translationArg(game.getRemainingText())));
@@ -163,45 +150,45 @@ public class Molehunt implements ModInitializer {
command.then(literal("role")
.requires(CommandSourceStack::isPlayer)
.executes(context -> {
- if (game == null || !game.started()) {
- throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
- }
-
- final var source = context.getSource();
- final var player = source.getPlayer();
- assert player != null;
-
- if (game.isMole(player)) {
- source.sendSuccess(
- () -> Component.translatable("commands.molehunt.role.mole")
- .append("\n\n")
- .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())),
- false);
- } else if (player.isSpectator()) {
- source.sendSuccess(
- () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()),
- false);
- } else {
- source.sendSuccess(
- () -> Component.translatable("commands.molehunt.role.survivor")
- .append("\n\n")
- .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())),
- false);
- }
-
- return Command.SINGLE_SUCCESS;
- }));
+ if (game == null || !game.started()) {
+ throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
+ }
+
+ final var source = context.getSource();
+ final var player = source.getPlayer();
+ assert player != null;
+
+ if (game.isMole(player)) {
+ source.sendSuccess(
+ () -> Component.translatable("commands.molehunt.role.mole")
+ .append("\n\n")
+ .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())),
+ false);
+ } else if (player.isSpectator()) {
+ source.sendSuccess(
+ () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()),
+ false);
+ } else {
+ source.sendSuccess(
+ () -> Component.translatable("commands.molehunt.role.survivor")
+ .append("\n\n")
+ .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())),
+ false);
+ }
+
+ return Command.SINGLE_SUCCESS;
+ }));
command.then(literal("stop")
.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
.executes(context -> {
- if (game == null || !game.started()) {
- throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
- }
+ if (game == null || !game.started()) {
+ throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
+ }
- game.stop();
+ game.stop();
- return Command.SINGLE_SUCCESS;
- }));
+ return Command.SINGLE_SUCCESS;
+ }));
ServerLifecycleEvents.SERVER_STARTED.register(server -> CONFIG = new Config(server));