Skip to content

Commit c62d7a1

Browse files
committed
Fixed missing game rule translations
1 parent 6647daa commit c62d7a1

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

neoforge-datagen/src/main/java/dev/compactmods/machines/datagen/base/lang/BaseLangGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
import net.minecraft.data.DataGenerator;
77
import net.minecraft.data.PackOutput;
88
import net.minecraft.resources.ResourceLocation;
9+
import net.minecraft.world.level.GameRules;
910
import net.neoforged.neoforge.common.data.LanguageProvider;
1011
import org.apache.commons.lang3.StringUtils;
1112

1213
public abstract class BaseLangGenerator extends LanguageProvider {
1314

14-
private final String locale;
15-
1615
public BaseLangGenerator(PackOutput packOutput, String locale) {
1716
super(packOutput, CompactMachines.MOD_ID, locale);
18-
this.locale = locale;
1917
}
2018

2119
protected String getMachineTranslation() {
@@ -25,6 +23,11 @@ protected String getMachineTranslation() {
2523
@Override
2624
protected void addTranslations() {}
2725

26+
protected void addGamerule(String key, String title, String description) {
27+
add("gamerule." + key, title);
28+
add("gamerule." + key + ".description", description);
29+
}
30+
2831
protected void addCreativeTab(ResourceLocation id, String translation) {
2932
add(Util.makeDescriptionId("itemGroup", id), translation);
3033
}

neoforge-datagen/src/main/java/dev/compactmods/machines/datagen/base/lang/EnglishLangGenerator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dev.compactmods.machines.api.CompactMachines;
44
import dev.compactmods.machines.api.room.template.RoomTemplate;
5+
import dev.compactmods.machines.gamerule.CMGameRules;
56
import dev.compactmods.machines.i18n.Translations;
67
import dev.compactmods.machines.api.advancement.Advancements;
78
import dev.compactmods.machines.i18n.CommandTranslations;
@@ -78,6 +79,12 @@ protected void addTranslations() {
7879
add(RoomUpgradeUIMapping.NAME, "Open Room Upgrade Screen");
7980

8081
addJade();
82+
83+
addGamerule(CMGameRules.ALLOW_SURVIVAL_OUT_OF_BOUNDS_KEY, "Allow Survival OOB", "Allow out-of-bounds survival players");
84+
addGamerule(CMGameRules.ALLOW_CREATIVE_OUT_OF_BOUNDS_KEY, "Allow Creative OOB", "Allow out-of-bounds creative players");
85+
addGamerule(CMGameRules.ALLOW_SPECTATORS_OUT_OF_BOUNDS_KEY, "Allow Spectators OOB", "Allow out-of-bounds spectators");
86+
addGamerule(CMGameRules.DAMAGE_OOB_PLAYERS_KEY, "Damage OOB Players", "Damage players that are out of bounds");
87+
addGamerule(CMGameRules.DAMAGE_PSD_ITEMS_ON_ROOM_EXIT_KEY, "Damage PSDs on Exit", "Damage shrinking devices by leaving rooms");
8188
}
8289

8390
private void blocksAndItems() {

neoforge-main/src/main/java/dev/compactmods/machines/gamerule/CMGameRules.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,31 @@
55

66
public class CMGameRules {
77

8+
public static final String ALLOW_SURVIVAL_OUT_OF_BOUNDS_KEY = CompactMachines.dotPrefix("allow_survival_oob");
89
public static GameRules.Key<GameRules.BooleanValue> ALLOW_SURVIVAL_OUT_OF_BOUNDS;
10+
11+
public static final String ALLOW_CREATIVE_OUT_OF_BOUNDS_KEY = CompactMachines.dotPrefix("allow_creative_oob");
912
public static GameRules.Key<GameRules.BooleanValue> ALLOW_CREATIVE_OUT_OF_BOUNDS;
13+
1014
public static GameRules.Key<GameRules.BooleanValue> ALLOW_SPECTATORS_OUT_OF_BOUNDS;
15+
public static final String ALLOW_SPECTATORS_OUT_OF_BOUNDS_KEY = CompactMachines.dotPrefix("allow_spectator_oob");
16+
17+
public static final String DAMAGE_OOB_PLAYERS_KEY = CompactMachines.dotPrefix("damage_oob");
1118
public static GameRules.Key<GameRules.BooleanValue> DAMAGE_OOB_PLAYERS;
1219

1320
/**
1421
* For hardcore-style packs. If a shrinking item is successfully used to LEAVE a room,
1522
* it will also be damaged. Off by default.
1623
*/
24+
public static final String DAMAGE_PSD_ITEMS_ON_ROOM_EXIT_KEY = CompactMachines.dotPrefix("damage_psd_on_exit");
1725
public static GameRules.Key<GameRules.BooleanValue> DAMAGE_PSD_ITEMS_ON_ROOM_EXIT;
1826

1927
public static void register() {
20-
ALLOW_SURVIVAL_OUT_OF_BOUNDS = GameRules.register(CompactMachines.dotPrefix("allow_survival_oob"), GameRules.Category.PLAYER, GameRules.BooleanValue.create(false));
21-
ALLOW_CREATIVE_OUT_OF_BOUNDS = GameRules.register(CompactMachines.dotPrefix("allow_creative_oob"), GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
22-
ALLOW_SPECTATORS_OUT_OF_BOUNDS = GameRules.register(CompactMachines.dotPrefix("allow_spectator_oob"), GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
23-
DAMAGE_OOB_PLAYERS = GameRules.register(CompactMachines.dotPrefix("damage_oob"), GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
28+
ALLOW_SURVIVAL_OUT_OF_BOUNDS = GameRules.register(ALLOW_SURVIVAL_OUT_OF_BOUNDS_KEY, GameRules.Category.PLAYER, GameRules.BooleanValue.create(false));
29+
ALLOW_CREATIVE_OUT_OF_BOUNDS = GameRules.register(ALLOW_CREATIVE_OUT_OF_BOUNDS_KEY, GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
30+
ALLOW_SPECTATORS_OUT_OF_BOUNDS = GameRules.register(ALLOW_SPECTATORS_OUT_OF_BOUNDS_KEY, GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
31+
DAMAGE_OOB_PLAYERS = GameRules.register(DAMAGE_OOB_PLAYERS_KEY, GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
2432

25-
DAMAGE_PSD_ITEMS_ON_ROOM_EXIT = GameRules.register(CompactMachines.dotPrefix("damage_psd_on_exit"), GameRules.Category.PLAYER, GameRules.BooleanValue.create(false));
33+
DAMAGE_PSD_ITEMS_ON_ROOM_EXIT = GameRules.register(DAMAGE_PSD_ITEMS_ON_ROOM_EXIT_KEY, GameRules.Category.PLAYER, GameRules.BooleanValue.create(false));
2634
}
2735
}

0 commit comments

Comments
 (0)