WallPropertyFix .java

net.minecraft.util.datafix.fixes.WallPropertyFix (class): members: WALL_BLOCKS, makeRule. strings: "minecraft:mossy_stone_brick_wall", "east", "west".

net.minecraft.util.datafix.fixesclass61 linescommonextends DataFix2.1 KB

API Surface (1)

TypeRewriteRule makeRule()

Fields & Constants (1)

WALL_BLOCKS

String literals (20)

"minecraft:andesite_wall"
"minecraft:brick_wall"
"minecraft:cobblestone_wall"
"minecraft:diorite_wall"
"minecraft:end_stone_brick_wall"
"minecraft:granite_wall"
"minecraft:mossy_cobblestone_wall"
"minecraft:mossy_stone_brick_wall"
"minecraft:nether_brick_wall"
"minecraft:prismarine_wall"
"minecraft:red_nether_brick_wall"
"minecraft:red_sandstone_wall"
"minecraft:sandstone_wall"
"minecraft:stone_brick_wall"
"none"
"Properties"
"east"
"west"
"north"
"south"

Full Source

WallPropertyFix.java61 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.google.common.collect.ImmutableSet;
4
import com.mojang.datafixers.DSL;
5
import com.mojang.datafixers.DataFix;
6
import com.mojang.datafixers.DataFixUtils;
7
import com.mojang.datafixers.TypeRewriteRule;
8
import com.mojang.datafixers.schemas.Schema;
9
import com.mojang.serialization.Dynamic;
10
import java.util.Set;
11
12
public class WallPropertyFix extends DataFix {
13
	private static final Set<String> WALL_BLOCKS = ImmutableSet.of(
14
		"minecraft:andesite_wall",
15
		"minecraft:brick_wall",
16
		"minecraft:cobblestone_wall",
17
		"minecraft:diorite_wall",
18
		"minecraft:end_stone_brick_wall",
19
		"minecraft:granite_wall",
20
		"minecraft:mossy_cobblestone_wall",
21
		"minecraft:mossy_stone_brick_wall",
22
		"minecraft:nether_brick_wall",
23
		"minecraft:prismarine_wall",
24
		"minecraft:red_nether_brick_wall",
25
		"minecraft:red_sandstone_wall",
26
		"minecraft:sandstone_wall",
27
		"minecraft:stone_brick_wall"
28
	);
29
30
	public WallPropertyFix(final Schema outputSchema, final boolean changesType) {
31
		super(outputSchema, changesType);
32
	}
33
34
	@Override
35
	public TypeRewriteRule makeRule() {
36
		return this.fixTypeEverywhereTyped(
37
			"WallPropertyFix",
38
			this.getInputSchema().getType(References.BLOCK_STATE),
39
			input -> input.update(DSL.remainderFinder(), WallPropertyFix::upgradeBlockStateTag)
40
		);
41
	}
42
43
	private static String mapProperty(final String value) {
44
		return "true".equals(value) ? "low" : "none";
45
	}
46
47
	private static <T> Dynamic<T> fixWallProperty(final Dynamic<T> state, final String property) {
48
		return state.update(property, value -> DataFixUtils.orElse(value.asString().result().map(WallPropertyFix::mapProperty).map(value::createString), value));
49
	}
50
51
	private static <T> Dynamic<T> upgradeBlockStateTag(final Dynamic<T> state) {
52
		boolean isWall = state.get("Name").asString().result().filter(WALL_BLOCKS::contains).isPresent();
53
		return !isWall ? state : state.update("Properties", properties -> {
54
			Dynamic<?> newState = fixWallProperty(properties, "east");
55
			newState = fixWallProperty(newState, "west");
56
			newState = fixWallProperty(newState, "north");
57
			return fixWallProperty(newState, "south");
58
		});
59
	}
60
}
61

Decompiled Minecraft 26.3 source of WallPropertyFix (net/minecraft/util/datafix/fixes/WallPropertyFix.java) with Mojang official mappings, stored verbatim on the site.