Skip to content

Commit 01deea9

Browse files
Merge pull request #106 from Polaris-Bears-MC/dev/Viola-Siemens
木材类 i18n 修复
2 parents d5449cd + ab12aaf commit 01deea9

File tree

5 files changed

+96
-16
lines changed

5 files changed

+96
-16
lines changed

processor/annotation/src/main/java/org/polaris2023/annotation/language/I18n.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
String en_us();
1212
String zh_cn();
1313
String zh_tw();
14+
String descriptionId() default "";
1415
Other[] other() default {};
1516
@interface Other {
1617
String value();

processor/src/main/java/org/polaris2023/processor/clazz/datagen/I18nProcessor.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ public void classDef(TypeElement typeElement) {
3131
VariableElement variableElement = (VariableElement) element;
3232
I18n i18n = variableElement.getAnnotation(I18n.class);
3333
if (i18n != null) {
34-
add("en_us", ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), i18n.en_us()));
35-
add("zh_cn", ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), i18n.zh_cn()));
36-
add("zh_tw", ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), i18n.zh_tw()));
34+
String name;
35+
if(i18n.descriptionId().isEmpty()) {
36+
name = typeElement.getQualifiedName() + "." + variableElement.getSimpleName();
37+
} else {
38+
name = "\"" + i18n.descriptionId() + "\"";
39+
}
40+
add("en_us", ".add(%s, \"%s\")".formatted(name, i18n.en_us()));
41+
add("zh_cn", ".add(%s, \"%s\")".formatted(name, i18n.zh_cn()));
42+
add("zh_tw", ".add(%s, \"%s\")".formatted(name, i18n.zh_tw()));
3743
for (I18n.Other other : i18n.other()) {
38-
add(other.value(), ".add(%s, \"%s\")".formatted(typeElement.getQualifiedName() + "." + variableElement.getSimpleName(), other.translate()));
44+
add(other.value(), ".add(%s, \"%s\")".formatted(name, other.translate()));
3945
}
4046
}
4147
}

src/main/java/org/polaris2023/wild_wind/client/ModTranslateKey.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ public enum ModTranslateKey implements Supplier<TranslatableContents> {
5353

5454
ModTranslateKey(String... keys) {
5555
StringBuilder key = new StringBuilder();
56-
for (int i = 0; i < keys.length; i++) {
57-
String k = keys[i];
58-
if (i == 1) {
59-
key.append(k);
60-
} else {
61-
key.append(".").append(k);
56+
if(keys.length != 0) {
57+
key.append(keys[0]);
58+
for (int i = 1; i < keys.length; i++) {
59+
key.append(".").append(keys[i]);
6260
}
6361
}
6462
translatable = Component.translatable(key.toString());

src/main/java/org/polaris2023/wild_wind/common/init/ModBlocks.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ public class ModBlocks {
215215
@I18n(en_us = "Azalea Sign", zh_cn = "杜鹃木告示牌", zh_tw = "杜鵑木告示牌")
216216
public static final DeferredBlock<StandingSignBlock> AZALEA_SIGN =
217217
register("azalea_sign", props -> new StandingSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_SIGN));
218-
@I18n(en_us = "Azalea Wall Sign", zh_cn = "墙上的杜鹃木告示牌", zh_tw = "牆上的杜鵑木告示牌")
218+
@I18n(en_us = "Azalea Wall Sign", zh_cn = "墙上的杜鹃木告示牌", zh_tw = "牆上的杜鵑木告示牌", descriptionId = "block.wild_wind.azalea_wall_sign")
219219
public static final DeferredBlock<WallSignBlock> AZALEA_WALL_SIGN =
220220
register("azalea_wall_sign", props -> new WallSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_WALL_SIGN).lootFrom(AZALEA_SIGN));
221221
@I18n(en_us = "Azalea Hanging Sign", zh_cn = "悬挂式杜鹃木告示牌", zh_tw = "懸挂式杜鵑木告示牌")
222222
public static final DeferredBlock<CeilingHangingSignBlock> AZALEA_HANGING_SIGN =
223223
register("azalea_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_HANGING_SIGN));
224-
@I18n(en_us = "Azalea Wall Hanging Sign", zh_cn = "墙上的杜鹃木悬挂式告示牌", zh_tw = "牆上的杜鵑木懸挂式告示牌")
224+
@I18n(en_us = "Azalea Wall Hanging Sign", zh_cn = "墙上的杜鹃木悬挂式告示牌", zh_tw = "牆上的杜鵑木懸挂式告示牌", descriptionId = "block.wild_wind.azalea_wall_hanging_sign")
225225
public static final DeferredBlock<WallHangingSignBlock> AZALEA_WALL_HANGING_SIGN =
226226
register("azalea_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.AZALEA.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.MANGROVE_WALL_HANGING_SIGN).lootFrom(AZALEA_HANGING_SIGN));
227227
public static final DeferredItem<BlockItem> AZALEA_LOG_ITEM =
@@ -298,13 +298,13 @@ public class ModBlocks {
298298
@I18n(en_us = "Palm Sign", zh_cn = "棕榈木告示牌", zh_tw = "棕櫚木告示牌")
299299
public static final DeferredBlock<StandingSignBlock> PALM_SIGN =
300300
register("palm_sign", props -> new StandingSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_SIGN));
301-
@I18n(en_us = "Palm Wall Sign", zh_cn = "墙上的棕榈木告示牌", zh_tw = "牆上的棕櫚木告示牌")
301+
@I18n(en_us = "Palm Wall Sign", zh_cn = "墙上的棕榈木告示牌", zh_tw = "牆上的棕櫚木告示牌", descriptionId = "block.wild_wind.palm_wall_sign")
302302
public static final DeferredBlock<WallSignBlock> PALM_WALL_SIGN =
303303
register("palm_wall_sign", props -> new WallSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_WALL_SIGN).lootFrom(PALM_SIGN));
304304
@I18n(en_us = "Palm Hanging Sign", zh_cn = "棕榈木悬挂式告示牌", zh_tw = "棕櫚木懸挂式告示牌")
305305
public static final DeferredBlock<CeilingHangingSignBlock> PALM_HANGING_SIGN =
306306
register("palm_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_HANGING_SIGN));
307-
@I18n(en_us = "Palm Wall Hanging Sign", zh_cn = "墙上的棕榈木悬挂式告示牌", zh_tw = "牆上的棕櫚木懸挂式告示牌")
307+
@I18n(en_us = "Palm Wall Hanging Sign", zh_cn = "墙上的棕榈木悬挂式告示牌", zh_tw = "牆上的棕櫚木懸挂式告示牌", descriptionId = "block.wild_wind.palm_wall_hanging_sign")
308308
public static final DeferredBlock<WallHangingSignBlock> PALM_WALL_HANGING_SIGN =
309309
register("palm_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.PALM.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.SPRUCE_WALL_HANGING_SIGN).lootFrom(PALM_HANGING_SIGN));
310310
public static final DeferredItem<BlockItem> PALM_LOG_ITEM =
@@ -388,13 +388,13 @@ public class ModBlocks {
388388
@I18n(en_us = "Baobab Sign", zh_cn = "猴面包木告示牌", zh_tw = "猴麵包木告示牌")
389389
public static final DeferredBlock<StandingSignBlock> BAOBAB_SIGN =
390390
register("baobab_sign", props -> new StandingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_SIGN));
391-
@I18n(en_us = "Baobab Wall Sign", zh_cn = "墙上的猴面包木告示牌", zh_tw = "牆上的猴麵包木告示牌")
391+
@I18n(en_us = "Baobab Wall Sign", zh_cn = "墙上的猴面包木告示牌", zh_tw = "牆上的猴麵包木告示牌", descriptionId = "block.wild_wind.baobab_wall_sign")
392392
public static final DeferredBlock<WallSignBlock> BAOBAB_WALL_SIGN =
393393
register("baobab_wall_sign", props -> new WallSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_WALL_SIGN).lootFrom(BAOBAB_SIGN));
394394
@I18n(en_us = "Baobab Hanging Sign", zh_cn = "猴面包木悬挂式告示牌", zh_tw = "猴麵包木懸挂式告示牌")
395395
public static final DeferredBlock<CeilingHangingSignBlock> BAOBAB_HANGING_SIGN =
396396
register("baobab_hanging_sign", props -> new CeilingHangingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_HANGING_SIGN));
397-
@I18n(en_us = "Baobab Wall Hanging Sign", zh_cn = "墙上的猴面包木悬挂式告示牌", zh_tw = "牆上的猴麵包木懸挂式告示牌")
397+
@I18n(en_us = "Baobab Wall Hanging Sign", zh_cn = "墙上的猴面包木悬挂式告示牌", zh_tw = "牆上的猴麵包木懸挂式告示牌", descriptionId = "block.wild_wind.baobab_wall_hanging_sign")
398398
public static final DeferredBlock<WallHangingSignBlock> BAOBAB_WALL_HANGING_SIGN =
399399
register("baobab_wall_hanging_sign", props -> new WallHangingSignBlock(ModWoodSettings.BAOBAB.woodType, props), BlockBehaviour.Properties.ofFullCopy(Blocks.ACACIA_WALL_HANGING_SIGN).lootFrom(BAOBAB_HANGING_SIGN));
400400
public static final DeferredItem<BlockItem> BAOBAB_LOG_ITEM =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"type": "minecraft:tree",
3+
"config": {
4+
"decorators": [],
5+
"dirt_provider": {
6+
"type": "minecraft:simple_state_provider",
7+
"state": {
8+
"Name": "minecraft:rooted_dirt"
9+
}
10+
},
11+
"foliage_placer": {
12+
"type": "minecraft:random_spread_foliage_placer",
13+
"foliage_height": 2,
14+
"leaf_placement_attempts": 50,
15+
"offset": 0,
16+
"radius": 3
17+
},
18+
"foliage_provider": {
19+
"type": "minecraft:weighted_state_provider",
20+
"entries": [
21+
{
22+
"data": {
23+
"Name": "minecraft:azalea_leaves",
24+
"Properties": {
25+
"distance": "7",
26+
"persistent": "false",
27+
"waterlogged": "false"
28+
}
29+
},
30+
"weight": 3
31+
},
32+
{
33+
"data": {
34+
"Name": "minecraft:flowering_azalea_leaves",
35+
"Properties": {
36+
"distance": "7",
37+
"persistent": "false",
38+
"waterlogged": "false"
39+
}
40+
},
41+
"weight": 1
42+
}
43+
]
44+
},
45+
"force_dirt": true,
46+
"ignore_vines": false,
47+
"minimum_size": {
48+
"type": "minecraft:two_layers_feature_size",
49+
"limit": 1,
50+
"lower_size": 0,
51+
"upper_size": 1
52+
},
53+
"trunk_placer": {
54+
"type": "minecraft:bending_trunk_placer",
55+
"base_height": 4,
56+
"bend_length": {
57+
"type": "minecraft:uniform",
58+
"max_inclusive": 2,
59+
"min_inclusive": 1
60+
},
61+
"height_rand_a": 2,
62+
"height_rand_b": 0,
63+
"min_height_for_leaves": 3
64+
},
65+
"trunk_provider": {
66+
"type": "minecraft:simple_state_provider",
67+
"state": {
68+
"Name": "wild_wind:azalea_log",
69+
"Properties": {
70+
"axis": "y"
71+
}
72+
}
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)