package us.myles.ViaVersion.api.type.types.minecraft;

import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;

public class Particle1_17Type extends Type<Particle> {

    public Particle1_17Type() {
        super("Particle", Particle.class);
    }

    @Override
    public void write(ByteBuf buffer, Particle object) throws Exception {
        Type.VAR_INT.writePrimitive(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.readPrimitive(buffer);
        Particle particle = new Particle(type);

        switch (type) {
            // Block / Falling Dust
            case 3:
            case 24:
                particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Flat Block
                break;
            // Dust
            case 14:
            case 15:
                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.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 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
                }
                break;
            // Item
            case 33:
                particle.getArguments().add(new Particle.ParticleData(Type.FLAT_VAR_INT_ITEM, Type.FLAT_VAR_INT_ITEM.read(buffer))); // Flat item
                break;
            case 36:

        }
        return particle;
    }
}


@@ -80,16 +80,52 @@
 yteBuf;%0A
+import us.myles.ViaVersion.api.Via;%0A
 import u
@@ -859,72 +859,61 @@
     
-// Block / Falling Dust%0A            case 3:%0A            case 24:
+case 3: // Block%0A            case 24: // Falling dust
 %0A   
@@ -1075,24 +1075,33 @@
 %0A           
+ case 14:
  // Dust%0A   
@@ -1119,31 +1119,29 @@
 se 1
-4:%0A            case 15:
+5: // Dust transition
 %0A   
@@ -1866,38 +1866,32 @@
 uffer))); // Red
- 0 - 1
 %0A               
@@ -1997,38 +1997,32 @@
 fer))); // Green
- 0 - 1
 %0A               
@@ -2127,38 +2127,32 @@
 ffer))); // Blue
- 0 - 1
 %0A               
@@ -2193,36 +2193,16 @@
     
-// Item%0A            
 case 33:
 %0A   
@@ -2197,16 +2197,24 @@
 case 33:
+ // Item
 %0A       
@@ -2395,17 +2395,966 @@
 case 36:
-%0A
+ // Vibration path%0A                particle.getArguments().add(new Particle.ParticleData(Type.POSITION1_14, Type.POSITION1_14.read(buffer))); // From block pos%0A                String resourceLocation = Type.STRING.read(buffer);%0A                if (resourceLocation.equals(%22block%22)) %7B%0A                    particle.getArguments().add(new Particle.ParticleData(Type.POSITION1_14, Type.POSITION1_14.read(buffer))); // Target block pos%0A                %7D else if (resourceLocation.equals(%22entity%22)) %7B%0A                    particle.getArguments().add(new Particle.ParticleData(Type.POSITION1_14, Type.POSITION1_14.read(buffer))); // Target entity%0A                %7D else %7B%0A                    Via.getPlatform().getLogger().warning(%22Unknown vibration path position source type: %22 + resourceLocation);%0A                %7D%0A                particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Arrival in ticks
 %0A       

Complete vibration particle reading