3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Start working on particles

Dieser Commit ist enthalten in:
Matsv 2018-04-02 17:06:25 +02:00
Ursprung 4d38ca1b3c
Commit 70e106eeab
4 geänderte Dateien mit 74 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.ProtocolSnapshotTo1_12_2;
@RequiredArgsConstructor
@Getter
@ -23,7 +24,7 @@ public enum MetaType1_13 implements MetaType {
OptUUID(12, Type.OPTIONAL_UUID),
BlockID(13, Type.VAR_INT),
NBTTag(14, Type.NBT),
UNKNOWN(15, null), // TODO do research
PARTICLE(15, ProtocolSnapshotTo1_12_2.PARTICLE_TYPE),
Discontinued(99, null);
private final int typeID;

Datei anzeigen

@ -21,9 +21,11 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.Painting
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.TabCompleteTracker;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.type.Particle1_13Type;
// Development of 1.13 support!
public class ProtocolSnapshotTo1_12_2 extends Protocol {
public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type();
static {
MappingData.init();

Datei anzeigen

@ -0,0 +1,25 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
import lombok.AllArgsConstructor;
import lombok.Data;
import us.myles.ViaVersion.api.type.Type;
import java.util.Set;
import java.util.TreeSet;
@Data
public class Particle {
private int id;
private Set<ParticleData> arguments = new TreeSet<>();
public Particle(int id) {
this.id = id;
}
@lombok.Data
@AllArgsConstructor
public static class ParticleData {
private Type type;
private Object value;
}
}

Datei anzeigen

@ -0,0 +1,45 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.type;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.Particle;
// TODO make future proof
public class Particle1_13Type extends Type<Particle> {
public Particle1_13Type() {
super("Particle", Particle.class);
}
@Override
public void write(ByteBuf buffer, Particle object) throws Exception {
Type.VAR_INT.write(buffer, object.getId());
for (Particle.ParticleData data : object.getArguments())
data.getType().write(buffer, data.getValue());
}
@Override
public Particle read(ByteBuf buffer) throws Exception {
int type = Type.VAR_INT.read(buffer);
Particle particle = new Particle(type);
switch (type) {
// Block / Falling Dust /
case 3:
case 20:
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.read(buffer))); // Flat Block
break;
// Dust
case 11:
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer))); // Red 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer))); // Green 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer))); // Blue 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer)));// Scale 0.01 - 4
break;
// Item
case 27:
particle.getArguments().add(new Particle.ParticleData(Type.FLAT_ITEM, Type.FLAT_ITEM.read(buffer))); // Flat item
break;
}
return particle;
}
}