/* * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion * Copyright (C) 2016-2021 ViaVersion and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types; import io.netty.buffer.ByteBuf; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.Particle; @Deprecated public class Particle1_13Type extends Type { public Particle1_13Type() { 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 20: particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Flat Block break; // Dust case 11: 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 break; // Item case 27: particle.getArguments().add(new Particle.ParticleData(Type.FLAT_ITEM, Type.FLAT_ITEM.read(buffer))); // Flat item break; } return particle; } }