aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/world
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/world')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java5
-rw-r--r--src/main/java/world/anhgelus/molehunt/config/Config.java8
-rw-r--r--src/main/java/world/anhgelus/molehunt/game/Game.java3
3 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java
index b867337..83309a0 100644
--- a/src/main/java/world/anhgelus/molehunt/Molehunt.java
+++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java
@@ -100,6 +100,11 @@ public class Molehunt implements ModInitializer {
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 Game game;
diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java
index 9db560b..e448f7d 100644
--- a/src/main/java/world/anhgelus/molehunt/config/Config.java
+++ b/src/main/java/world/anhgelus/molehunt/config/Config.java
@@ -64,6 +64,10 @@ public class Config {
return server.getGameRules().getBoolean(Molehunt.ENABLE_PORTALS);
}
+ public boolean foodOnStart() {
+ return server.getGameRules().getBoolean(Molehunt.FOOD_ON_START);
+ }
+
public static SimpleConfig configFile(String fileName) {
return SimpleConfig.of(fileName).provider(Config::defaultConfig).request();
}
@@ -90,6 +94,10 @@ public class Config {
# Default: -1.
mole_count = -1
+ # Give food on start
+ # Default: true
+ food_on_start = true
+
# Client-side settings (applies to all players)
diff --git a/src/main/java/world/anhgelus/molehunt/game/Game.java b/src/main/java/world/anhgelus/molehunt/game/Game.java
index 3ffdf61..bac6c27 100644
--- a/src/main/java/world/anhgelus/molehunt/game/Game.java
+++ b/src/main/java/world/anhgelus/molehunt/game/Game.java
@@ -1,6 +1,8 @@
package world.anhgelus.molehunt.game;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.Items;
import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket;
import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket;
import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket;
@@ -80,6 +82,7 @@ public class Game {
p.networkHandler.sendPacket(timing);
p.networkHandler.sendPacket(title);
p.changeGameMode(GameMode.SURVIVAL);
+ if (Molehunt.CONFIG.foodOnStart()) p.giveItemStack(new ItemStack(Items.COOKED_BEEF, 64));
});
server.setDefaultGameMode(GameMode.SPECTATOR);