Skip to content

Commit cbafc05

Browse files
committed
Replace block state providers with dummy entries
They're never shown or used by the client. Closes #1357
1 parent e7b588b commit cbafc05

1 file changed

Lines changed: 13 additions & 36 deletions

File tree

‎common/src/main/java/com/viaversion/viabackwards/protocol/v26_3to26_2/rewriter/RegistryDataRewriter26_3.java‎

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public final class RegistryDataRewriter26_3 extends BackwardsRegistryRewriter {
3434

3535
public RegistryDataRewriter26_3(final Protocol26_3To26_2 protocol) {
3636
super(protocol);
37+
addEnchantmentEffectRewriter("replace_disk", this::replaceBlockStateProvider);
38+
addEnchantmentEffectRewriter("replace_block", this::replaceBlockStateProvider);
3739
}
3840

3941
@Override
@@ -86,31 +88,18 @@ public void updateEnchantmentTerm(final CompoundTag term) {
8688

8789
@Override
8890
public boolean updateBlockStateProvider(final CompoundTag tag) {
89-
String type = tag.getString("type");
90-
if (type == null) {
91-
// Move block state to a block provider
92-
final CompoundTag stateTag = tag.copy();
93-
handleFullBlockState(stateTag);
94-
tag.put("state", stateTag);
95-
tag.putString("type", "simple_state_provider");
96-
return true;
97-
}
91+
return false; // Handled in replaceBlockStateProvider, as providers can also be registry references now
92+
}
9893

99-
type = Key.stripMinecraftNamespace(type);
100-
switch (type) {
101-
case "simple_state_provider", "rotated_block_provider" -> {
102-
handleBlockState(tag, "state");
103-
}
104-
case "weighted_state_provider" -> {
105-
for (final CompoundTag entry : tag.getListTag("entries", CompoundTag.class)) {
106-
handleBlockState(entry, "data");
107-
}
108-
}
109-
case "noise_threshold_provider" -> {
110-
handleBlockState(tag, "default_state");
111-
}
112-
}
113-
return super.updateBlockStateProvider(tag);
94+
private void replaceBlockStateProvider(final CompoundTag effect) {
95+
// Provider types were renamed and reworked, but they're only actually used on the server
96+
final CompoundTag state = new CompoundTag();
97+
state.putString("Name", "minecraft:dirt");
98+
99+
final CompoundTag provider = new CompoundTag();
100+
provider.putString("type", "minecraft:simple_state_provider");
101+
provider.put("state", state);
102+
effect.put("block_state", provider);
114103
}
115104

116105
@Override
@@ -121,18 +110,6 @@ protected void handleParticleData(final CompoundTag particleData) {
121110
}
122111
}
123112

124-
private void handleBlockState(final CompoundTag parent, final String key) {
125-
final Tag blockStateTag = parent.get(key);
126-
if (blockStateTag instanceof CompoundTag compoundTag) {
127-
handleFullBlockState(compoundTag);
128-
} else if (blockStateTag instanceof StringTag stringTag) {
129-
// Needs to be a compound tag in older versions
130-
final CompoundTag updatedBlockStateTag = new CompoundTag();
131-
updatedBlockStateTag.putString("Name", stringTag.getValue());
132-
parent.put(key, updatedBlockStateTag);
133-
}
134-
}
135-
136113
private void handleFullBlockState(final CompoundTag tag) {
137114
final Tag id = tag.remove("id");
138115
tag.put("Name", id);

0 commit comments

Comments
 (0)