Use raw data filler in 1.12->1.13

This commit is contained in:
Nassim Jahnke 2024-04-27 10:23:04 +02:00
parent 798b70cbe6
commit c9733948b3
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
2 changed files with 11 additions and 2 deletions

View File

@ -22,6 +22,7 @@
*/
package com.viaversion.viaversion.api.type.types.misc;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.type.Type;
@ -58,6 +59,10 @@ public abstract class DynamicType<T extends IdHolder> extends Type<T> {
}
}
public RawDataFiller rawFiller() {
return new RawDataFiller();
}
public final class DataFiller {
private final FullMappings mappings;
@ -65,6 +70,7 @@ public abstract class DynamicType<T extends IdHolder> extends Type<T> {
private DataFiller(final Protocol<?, ?, ?, ?> protocol, final boolean useMappedNames) {
this.mappings = mappings(protocol);
Preconditions.checkNotNull(mappings, "Mappings for %s are null", protocol.getClass());
this.useMappedNames = useMappedNames;
}
@ -72,8 +78,11 @@ public abstract class DynamicType<T extends IdHolder> extends Type<T> {
readers.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader);
return this;
}
}
public DataFiller reader(final int id, final DataReader<T> reader) {
public final class RawDataFiller {
public RawDataFiller reader(final int id, final DataReader<T> reader) {
readers.put(id, reader);
return this;
}

View File

@ -845,7 +845,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
RecipeData.init();
BlockIdData.init();
Types1_13.PARTICLE.filler(this)
Types1_13.PARTICLE.rawFiller()
.reader(3, ParticleType.Readers.BLOCK)
.reader(20, ParticleType.Readers.DUST)
.reader(11, ParticleType.Readers.DUST)