Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Dust particle rgb values are now written as doubles
Dieser Commit ist enthalten in:
Ursprung
72205a5414
Commit
459e3e68b8
@ -85,7 +85,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
|
||||
@Deprecated
|
||||
public static final Type<Integer[]> INT_ARRAY = new ArrayType<>(Type.INT);
|
||||
|
||||
public static final Type<Double> DOUBLE = new DoubleType();
|
||||
public static final DoubleType DOUBLE = new DoubleType();
|
||||
/**
|
||||
* @deprecated unreasonable overhead
|
||||
*/
|
||||
|
@ -5,20 +5,37 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.TypeConverter;
|
||||
|
||||
public class DoubleType extends Type<Double> implements TypeConverter<Double> {
|
||||
|
||||
public DoubleType() {
|
||||
super(Double.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #readPrimitive(ByteBuf)} for manual reading to avoid wrapping
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Double read(ByteBuf buffer) {
|
||||
return buffer.readDouble();
|
||||
}
|
||||
|
||||
public double readPrimitive(ByteBuf buffer) {
|
||||
return buffer.readDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #writePrimitive(ByteBuf, double)} for manual reading to avoid wrapping
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void write(ByteBuf buffer, Double object) {
|
||||
buffer.writeDouble(object);
|
||||
}
|
||||
|
||||
public void writePrimitive(ByteBuf buffer, double object) {
|
||||
buffer.writeDouble(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double from(Object o) {
|
||||
if (o instanceof Number) {
|
||||
|
@ -31,15 +31,15 @@ public class Particle1_17Type extends Type<Particle> {
|
||||
break;
|
||||
case 14: // Dust
|
||||
case 15: // Dust transition
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Red 0 - 1
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Green 0 - 1
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Blue 0 - 1
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.DOUBLE, Type.DOUBLE.readPrimitive(buffer))); // Red 0 - 1
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.DOUBLE, Type.DOUBLE.readPrimitive(buffer))); // Green 0 - 1
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.DOUBLE, Type.DOUBLE.readPrimitive(buffer))); // Blue 0 - 1
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Scale 0.01 - 4
|
||||
if (type == 15) {
|
||||
// Transition to color
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Red
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Green
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buffer))); // Blue
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.DOUBLE, Type.DOUBLE.readPrimitive(buffer))); // Red
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.DOUBLE, Type.DOUBLE.readPrimitive(buffer))); // Green
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.DOUBLE, Type.DOUBLE.readPrimitive(buffer))); // Blue
|
||||
}
|
||||
break;
|
||||
case 33: // Item
|
||||
@ -51,7 +51,7 @@ public class Particle1_17Type extends Type<Particle> {
|
||||
if (resourceLocation.equals("block")) {
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.POSITION1_14, Type.POSITION1_14.read(buffer))); // Target block pos
|
||||
} else if (resourceLocation.equals("entity")) {
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.read(buffer))); // Target entity
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Target entity
|
||||
} else {
|
||||
Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + resourceLocation);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ public class MetadataRewriter1_13_1To1_13 extends MetadataRewriter {
|
||||
// Convert to new block id
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (metadata.getMetaType() == MetaType1_13.PARTICLE) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
@ -39,8 +41,6 @@ public class MetadataRewriter1_13_1To1_13 extends MetadataRewriter {
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (type.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW) && metadata.getId() >= 7) {
|
||||
metadata.setId(metadata.getId() + 1); // New shooter UUID
|
||||
} else if (type.is(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD) && metadata.getId() == 10) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
// Convert to new block id
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (metadata.getMetaType() == MetaType1_14.PARTICLE) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
@ -146,10 +148,6 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
metadatas.remove(metadata); // "Is swinging arms"
|
||||
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
|
||||
}
|
||||
} else if (type.is(Entity1_14Types.EntityType.AREA_EFFECT_CLOUD)) {
|
||||
if (metadata.getId() == 10) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ILLAGER_BASE)) {
|
||||
|
@ -5,6 +5,7 @@ import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
@ -29,6 +30,8 @@ public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter {
|
||||
// Convert to new block id
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (metadata.getMetaType() == MetaType1_13.PARTICLE) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
@ -48,8 +51,6 @@ public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter {
|
||||
} else if (metadata.getId() > 18) {
|
||||
metadata.setId(metadata.getId() - 1);
|
||||
}
|
||||
} else if (type == Entity1_15Types.EntityType.AREA_EFFECT_CLOUD && metadata.getId() == 10) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@ public class MetadataRewriter1_16_2To1_16_1 extends MetadataRewriter {
|
||||
} else if (metadata.getMetaType() == MetaType1_14.BlockID) {
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (metadata.getMetaType() == MetaType1_14.PARTICLE) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
@ -39,10 +41,6 @@ public class MetadataRewriter1_16_2To1_16_1 extends MetadataRewriter {
|
||||
} else if (metadata.getId() == 16) {
|
||||
metadata.setId(15);
|
||||
}
|
||||
} else if (type.is(Entity1_16_2Types.EntityType.AREA_EFFECT_CLOUD)) {
|
||||
if (metadata.getId() == 10) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,15 +30,13 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
|
||||
} else if (metadata.getMetaType() == MetaType1_14.BlockID) {
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (metadata.getMetaType() == MetaType1_14.PARTICLE) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
|
||||
if (type == Entity1_16Types.EntityType.AREA_EFFECT_CLOUD) {
|
||||
if (metadata.getId() == 10) {
|
||||
rewriteParticle((Particle) metadata.getValue());
|
||||
}
|
||||
} else if (type.isOrHasParent(Entity1_16Types.EntityType.ABSTRACT_ARROW)) {
|
||||
if (type.isOrHasParent(Entity1_16Types.EntityType.ABSTRACT_ARROW)) {
|
||||
if (metadata.getId() == 8) {
|
||||
metadatas.remove(metadata);
|
||||
} else if (metadata.getId() > 8) {
|
||||
|
@ -5,8 +5,10 @@ import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_17;
|
||||
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.EntityTracker1_17;
|
||||
@ -21,11 +23,23 @@ public class MetadataRewriter1_17To1_16_4 extends MetadataRewriter {
|
||||
|
||||
@Override
|
||||
public void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
|
||||
if (metadata.getMetaType() == MetaType1_14.Slot) {
|
||||
metadata.setMetaType(MetaType1_17.byId(metadata.getMetaType().getTypeID()));
|
||||
if (metadata.getMetaType() == MetaType1_17.Slot) {
|
||||
InventoryPackets.toClient((Item) metadata.getValue());
|
||||
} else if (metadata.getMetaType() == MetaType1_14.BlockID) {
|
||||
} else if (metadata.getMetaType() == MetaType1_17.BlockID) {
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (metadata.getMetaType() == MetaType1_17.PARTICLE) {
|
||||
Particle particle = (Particle) metadata.getValue();
|
||||
if (particle.getId() == 14) {
|
||||
// RGB is now encoded as doubles
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Particle.ParticleData data = particle.getArguments().get(i);
|
||||
data.setValue(((Number) data.getValue()).doubleValue());
|
||||
data.setType(Type.DOUBLE);
|
||||
}
|
||||
}
|
||||
rewriteParticle(particle);
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
|
@ -33,7 +33,32 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Particle id
|
||||
map(Type.BOOLEAN); // Long distance
|
||||
map(Type.DOUBLE); // X
|
||||
map(Type.DOUBLE); // Y
|
||||
map(Type.DOUBLE); // Z
|
||||
map(Type.FLOAT); // Offset X
|
||||
map(Type.FLOAT); // Offset Y
|
||||
map(Type.FLOAT); // Offset Z
|
||||
map(Type.FLOAT); // Particle data
|
||||
map(Type.INT); // Particle count
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 14) { // Dust
|
||||
// RGB now written as doubles
|
||||
wrapper.write(Type.DOUBLE, wrapper.read(Type.FLOAT).doubleValue()); // R
|
||||
wrapper.write(Type.DOUBLE, wrapper.read(Type.FLOAT).doubleValue()); // G
|
||||
wrapper.write(Type.DOUBLE, wrapper.read(Type.FLOAT).doubleValue()); // B
|
||||
wrapper.passthrough(Type.FLOAT); // Scale
|
||||
}
|
||||
});
|
||||
handler(itemRewriter.getSpawnParticleHandler(Type.FLAT_VAR_INT_ITEM, Type.DOUBLE));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void toClient(Item item) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren