Skip to content

Commit 881b5af

Browse files
committed
Add rule blockStateParserFutureVersionInputCompact
1 parent e4884cb commit 881b5af

3 files changed

Lines changed: 50 additions & 5 deletions

File tree

patches/net/minecraft/command/arguments/BlockStateParser.java.patch

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
11
--- a/net/minecraft/command/arguments/BlockStateParser.java
22
+++ b/net/minecraft/command/arguments/BlockStateParser.java
3-
@@ -1,5 +1,7 @@
3+
@@ -1,5 +1,8 @@
44
package net.minecraft.command.arguments;
55

66
+import carpet.helpers.DummyPropertyEnum;
77
+import carpet.settings.CarpetSettings;
8+
+import com.google.common.collect.ImmutableMap;
89
import com.google.common.collect.Maps;
910
import com.mojang.brigadier.StringReader;
1011
import com.mojang.brigadier.exceptions.CommandSyntaxException;
11-
@@ -448,6 +450,20 @@
12+
@@ -400,11 +403,25 @@
13+
return builder.buildFuture();
14+
}
15+
16+
+ // TISCM blockStateParserFutureVersionInputCompact
17+
+ private static final Map<ResourceLocation, ResourceLocation> TISCM_BLOCK_ID_COMPACT_MAPPING = ImmutableMap.<ResourceLocation, ResourceLocation>builder().
18+
+ put(new ResourceLocation("minecraft:oak_sign"), new ResourceLocation("minecraft:sign")).
19+
+ put(new ResourceLocation("minecraft:smooth_stone_slab"), new ResourceLocation("minecraft:stone_slab")).
20+
+ build();
21+
+ // TISCM blockStateParserFutureVersionInputCompact ends
22+
+
23+
public void readBlock() throws CommandSyntaxException
24+
{
25+
int i = this.reader.getCursor();
26+
this.blockID = ResourceLocation.read(this.reader);
27+
28+
+ // TISCM blockStateParserFutureVersionInputCompact
29+
+ if (CarpetSettings.blockStateParserFutureVersionInputCompact)
30+
+ {
31+
+ this.blockID = TISCM_BLOCK_ID_COMPACT_MAPPING.getOrDefault(this.blockID, this.blockID);
32+
+ }
33+
+ // TISCM blockStateParserFutureVersionInputCompact ends
34+
+
35+
if (IRegistry.BLOCK.containsKey(this.blockID))
36+
{
37+
Block block = IRegistry.BLOCK.getOrDefault(this.blockID);
38+
@@ -448,6 +465,20 @@
1239
String s = this.reader.readString();
1340
IProperty<?> iproperty = this.blockStateContainer.getProperty(s);
1441

@@ -29,7 +56,7 @@
2956
if (iproperty == null)
3057
{
3158
this.reader.setCursor(i);
32-
@@ -470,9 +486,10 @@
59+
@@ -470,9 +501,10 @@
3360

3461
this.reader.skip();
3562
this.reader.skipWhitespace();
@@ -41,7 +68,7 @@
4168
};
4269
int j = this.reader.getCursor();
4370
this.parseValue(iproperty, this.reader.readString(), j);
44-
@@ -598,6 +615,12 @@
71+
@@ -598,6 +630,12 @@
4572
}
4673
else
4774
{

src/main/java/carpet/settings/CarpetSettings.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CarpetSettings
2626
public static final int SHULKERBOX_MAX_STACK_AMOUNT = 64;
2727
public static boolean isEpsActive = false;
2828

29-
private static class ValidateVoxelOpt extends Validator<Boolean>
29+
private static class ValidateVoxelOpt extends Validator<Boolean>
3030
{
3131
@Override
3232
public Boolean validate(CommandSource source, ParsedRule<Boolean> currentRule, Boolean newValue, String string)
@@ -950,6 +950,17 @@ public String validate(CommandSource source, ParsedRule<String> currentRule, Str
950950
)
951951
public static double spawnJockeyProbably = -1;
952952

953+
@Rule(
954+
desc = "Enable the automatic future MC version compatibility mode on block states for the BlockStateParser which is used in command parsing",
955+
extra = {
956+
"Included mappings:",
957+
"- minecraft:oak_sign -> minecraft:sign",
958+
"- minecraft:smooth_stone_slab -> minecraft:stone_slab",
959+
},
960+
category = {CREATIVE}
961+
)
962+
public static boolean blockStateParserFutureVersionInputCompact;
963+
953964

954965
// /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$
955966
//|__ $$__/|_ $$_/ /$$__ $$ /$$__ $$| $$$ /$$$

src/main/resources/assets/carpet/lang/zh_cn.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ rule:
1212
desc: 方块可放置时无视实体碰撞检测,也就是你可以将方块放在实体内
1313
extra:
1414
'0': 仅对创造模式玩家有效
15+
blockStateParserFutureVersionInputCompact:
16+
name: 方块状态解析器兼容未来版本输入
17+
desc: 在命令解析过程中使用的 BlockStateParser 组件里,启用对未来版本方块 ID 的输入兼容
18+
extra:
19+
'0': 包含的映射:
20+
'1': '- minecraft:oak_sign -> minecraft:sign'
21+
'2': '- minecraft:smooth_stone_slab -> minecraft:stone_slab'
1522
cauldronBlockItemInteractFix:
1623
name: 炼药锅方块类物品交互修复
1724
desc: 让玩家可以对着填充有水的炼药锅放置方块

0 commit comments

Comments
 (0)