mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 01:55:47 +01:00
parent
54724ac540
commit
20e9723d21
@ -78,7 +78,7 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
|
||||
if (particles != null) {
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), particles);
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), newMappings.getAsJsonArray("particles"), particles);
|
||||
}
|
||||
|
||||
if (loadItems && newMappings.has("items")) {
|
||||
|
@ -29,15 +29,17 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
|
||||
public class ParticleMappings {
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final Mappings mappings;
|
||||
private final IntList itemParticleIds = new IntArrayList(2);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(JsonArray oldMappings, Mappings mappings) {
|
||||
public ParticleMappings(JsonArray oldMappings, JsonArray newMappings, Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
|
||||
stringToId = MappingDataLoader.arrayToMap(oldMappings);
|
||||
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
|
||||
stringToId.defaultReturnValue(-1);
|
||||
mappedStringToId.defaultReturnValue(-1);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
@ -54,6 +56,16 @@ public class ParticleMappings {
|
||||
return stringToId.getInt(identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
public int mappedId(String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(mappedIdentifier);
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
@ -46,7 +46,11 @@ public class ParticleType extends Type<Particle> {
|
||||
}
|
||||
|
||||
public ParticleTypeFiller filler(final Protocol<?, ?, ?, ?> protocol) {
|
||||
return this.new ParticleTypeFiller(protocol);
|
||||
return filler(protocol, true);
|
||||
}
|
||||
|
||||
public ParticleTypeFiller filler(final Protocol<?, ?, ?, ?> protocol, final boolean useMappedNames) {
|
||||
return this.new ParticleTypeFiller(protocol, useMappedNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,7 +101,13 @@ public class ParticleType extends Type<Particle> {
|
||||
};
|
||||
public static final ParticleReader VIBRATION = (buf, particle) -> {
|
||||
particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // From block pos
|
||||
final String resourceLocation = Type.STRING.read(buf);
|
||||
|
||||
String resourceLocation = Type.STRING.read(buf);
|
||||
particle.add(Type.STRING, resourceLocation);
|
||||
if (resourceLocation.startsWith("minecraft:")) {
|
||||
resourceLocation = resourceLocation.substring(10);
|
||||
}
|
||||
|
||||
if (resourceLocation.equals("block")) {
|
||||
particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // Target block pos
|
||||
} else if (resourceLocation.equals("entity")) {
|
||||
@ -112,13 +122,15 @@ public class ParticleType extends Type<Particle> {
|
||||
public final class ParticleTypeFiller {
|
||||
|
||||
private final ParticleMappings mappings;
|
||||
private final boolean useMappedNames;
|
||||
|
||||
private ParticleTypeFiller(final Protocol<?, ?, ?, ?> protocol) {
|
||||
private ParticleTypeFiller(final Protocol<?, ?, ?, ?> protocol, final boolean useMappedNames) {
|
||||
this.mappings = protocol.getMappingData().getParticleMappings();
|
||||
this.useMappedNames = useMappedNames;
|
||||
}
|
||||
|
||||
public ParticleTypeFiller reader(final String identifier, final ParticleReader reader) {
|
||||
readers.put(mappings.id(identifier), reader);
|
||||
readers.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -149,15 +149,15 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
WorldPackets.voidAir = getMappingData().getBlockStateMappings().getNewId(8591);
|
||||
WorldPackets.caveAir = getMappingData().getBlockStateMappings().getNewId(8592);
|
||||
|
||||
Types1_13_2.PARTICLE.filler(this)
|
||||
Types1_13_2.PARTICLE.filler(this, false)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
Types1_14.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
Types1_16.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
Types1_17.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION);
|
||||
|
@ -90,7 +90,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION);
|
||||
|
@ -84,7 +84,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_18To1_17_1> {
|
||||
filter().handler((event, meta) -> {
|
||||
meta.setMetaType(Types1_18.META_TYPES.byId(meta.metaType().typeId()));
|
||||
if (meta.metaType() == Types1_18.META_TYPES.particleType) {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
final Particle particle = (Particle) meta.getValue();
|
||||
if (particle.getId() == 2) { // Barrier
|
||||
particle.setId(3); // Block marker
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, 7754)); // Barrier state
|
||||
|
@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.ParticleMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
@ -482,9 +483,10 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
if (mappings.isBlockParticle(id)) {
|
||||
Particle.ParticleData data = particle.getArguments().get(0);
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
|
||||
} else if (mappings.isItemParticle(id)) {
|
||||
} else if (mappings.isItemParticle(id) && protocol.getItemRewriter() != null) {
|
||||
Particle.ParticleData data = particle.getArguments().get(0);
|
||||
data.setValue(protocol.getMappingData().getNewItemId(data.get()));
|
||||
Item item = data.get();
|
||||
protocol.getItemRewriter().handleItemToClient(item);
|
||||
}
|
||||
|
||||
particle.setId(protocol.getMappingData().getNewParticleId(id));
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
Loading…
Reference in New Issue
Block a user