SignsOpFlagFix .java

net.minecraft.util.datafix.fixes.SignsOpFlagFix (class, 32 lines): members: makeRule. strings: "Add allow-op flag to ", "allow_op_features". imports: Type.

net.minecraft.util.datafix.fixesclass32 linescommonextends DataFix1.1 KB

API Surface (1)

TypeRewriteRule makeRule()

String literals (4)

"Add allow-op flag to "
"allow_op_features"
"minecraft:sign"
"minecraft:hanging_sign"

Full Source

SignsOpFlagFix.java32 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.DataFix;
5
import com.mojang.datafixers.OpticFinder;
6
import com.mojang.datafixers.TypeRewriteRule;
7
import com.mojang.datafixers.schemas.Schema;
8
import com.mojang.datafixers.types.Type;
9
10
public class SignsOpFlagFix extends DataFix {
11
	public SignsOpFlagFix(final Schema outputSchema) {
12
		super(outputSchema, false);
13
	}
14
15
	private TypeRewriteRule makeRuleForType(final String entityName) {
16
		Type<?> entityType = this.getInputSchema().getChoiceType(References.BLOCK_ENTITY, entityName);
17
		OpticFinder<?> entityF = DSL.namedChoice(entityName, entityType);
18
		return this.fixTypeEverywhereTyped(
19
			"Add allow-op flag to " + entityName,
20
			this.getInputSchema().getType(References.BLOCK_ENTITY),
21
			input -> input.updateTyped(
22
				entityF, entityType, entity -> entity.update(DSL.remainderFinder(), remainder -> remainder.set("allow_op_features", remainder.createBoolean(true)))
23
			)
24
		);
25
	}
26
27
	@Override
28
	protected TypeRewriteRule makeRule() {
29
		return TypeRewriteRule.seq(this.makeRuleForType("minecraft:sign"), this.makeRuleForType("minecraft:hanging_sign"));
30
	}
31
}
32

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