aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java10
-rw-r--r--src/main/java/world/anhgelus/molehunt/config/Config.java12
-rw-r--r--src/main/java/world/anhgelus/molehunt/game/Game.java3
-rw-r--r--src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java19
-rw-r--r--src/main/resources/molehunt.mixins.json3
6 files changed, 44 insertions, 5 deletions
diff --git a/README.md b/README.md
index e5338a9..475b263 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,8 @@ The mod stops the game when every innocent is dead or when the timer ended.
The moles can see the name of other moles with `/molehunt moles`.
+Disable the nether, the end and every other portal.
+
_Almost_ everything in the mod can configured.
## Configuration
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java
index 52399dc..9026dab 100644
--- a/src/main/java/world/anhgelus/molehunt/Molehunt.java
+++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java
@@ -94,6 +94,11 @@ public class Molehunt implements ModInitializer {
GameRules.Category.MISC,
GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("border_moving_starting_time_offset", 10), 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 Game game;
@@ -134,7 +139,10 @@ public class Molehunt implements ModInitializer {
return Command.SINGLE_SUCCESS;
})
));
- command.then(literal("moles").requires(source -> game != null && game.isAMole(source.getPlayer())).executes(context -> {
+ command.then(literal("moles").requires(source ->
+ (game != null && game.isAMole(source.getPlayer())) ||
+ (source.getPlayer() != null && source.getPlayer().isSpectator())
+ ).executes(context -> {
context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.moles.list").append(" " + game.getMolesAsString()),false);
return Command.SINGLE_SUCCESS;
}));
diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java
index e1c84a4..b2e45ab 100644
--- a/src/main/java/world/anhgelus/molehunt/config/Config.java
+++ b/src/main/java/world/anhgelus/molehunt/config/Config.java
@@ -60,6 +60,10 @@ public class Config {
return server.getGameRules().getInt(Molehunt.MOVING_STARTING_TIME_OFFSET);
}
+ public boolean arePortalsEnabled() {
+ return server.getGameRules().getBoolean(Molehunt.ENABLE_PORTALS);
+ }
+
public static SimpleConfig configFile(String fileName) {
return SimpleConfig.of(fileName).provider(Config::defaultConfig).request();
}
@@ -102,7 +106,7 @@ public class Config {
show_tab = false
- # World border settings :
+ # World border settings
# Initial world size (in blocks).
# Default: 200 blocks.
@@ -117,6 +121,12 @@ public class Config {
# If this value is greater than the game duration, borders will never move.
# Default: 10 minutes.
border_moving_starting_time_offset = 10
+
+ # Other
+
+ # Enable portals (nether, end, end gateway)
+ # Default: false
+ enable_portals = false
""";
}
}
diff --git a/src/main/java/world/anhgelus/molehunt/game/Game.java b/src/main/java/world/anhgelus/molehunt/game/Game.java
index a2fdfbb..0bc7270 100644
--- a/src/main/java/world/anhgelus/molehunt/game/Game.java
+++ b/src/main/java/world/anhgelus/molehunt/game/Game.java
@@ -57,7 +57,6 @@ public class Game {
gamerules.get(GameRules.ANNOUNCE_ADVANCEMENTS).set(false, server);
// gamerules for the start
gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(true, server);
- gamerules.get(GameRules.DO_ENTITY_DROPS).set(false, server);
final var worldBorder = server.getOverworld().getWorldBorder();
worldBorder.setSize(Molehunt.CONFIG.getInitialWorldSize());
@@ -76,6 +75,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.networkHandler.sendPacket(timing);
p.networkHandler.sendPacket(title);
@@ -103,7 +103,6 @@ public class Game {
});
// reset gamerules after the start
gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(false, server);
- gamerules.get(GameRules.DO_ENTITY_DROPS).set(true, server);
// reset time and weather
server.getOverworld().setTimeOfDay(0);
server.getOverworld().resetWeather();
diff --git a/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java b/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java
new file mode 100644
index 0000000..96c63aa
--- /dev/null
+++ b/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java
@@ -0,0 +1,19 @@
+package world.anhgelus.molehunt.mixin;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.server.world.ServerWorld;
+import net.minecraft.world.dimension.PortalManager;
+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;
+import world.anhgelus.molehunt.Molehunt;
+
+@Mixin(PortalManager.class)
+public class NoPortals {
+ @Inject(at = @At("HEAD"), method = "tick", cancellable = true)
+ public void disableTick(ServerWorld world, Entity entity, boolean canUsePortals, CallbackInfoReturnable<Boolean> cir) {
+ if (Molehunt.CONFIG == null || Molehunt.CONFIG.arePortalsEnabled()) return;
+ cir.setReturnValue(false);
+ }
+}
diff --git a/src/main/resources/molehunt.mixins.json b/src/main/resources/molehunt.mixins.json
index 7ee051d..287cfc4 100644
--- a/src/main/resources/molehunt.mixins.json
+++ b/src/main/resources/molehunt.mixins.json
@@ -4,7 +4,8 @@
"package": "world.anhgelus.molehunt.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
- "NoMsgCommand"
+ "NoMsgCommand",
+ "NoPortals"
],
"injectors": {
"defaultRequire": 1