3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-04 23:30:24 +01:00

Make changes in particles easier to handle

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-11-10 10:30:17 +01:00
Ursprung ad7f782a1a
Commit a49c395486
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
54 geänderte Dateien mit 698 neuen und 156 gelöschten Zeilen

Datei anzeigen

@ -23,42 +23,71 @@
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
public class ParticleMappings {
private final Object2IntMap<String> stringToId;
private final Mappings mappings;
private final int blockId;
private final int fallingDustId;
private final int blockMarkerId;
private final int itemId;
private final IntList itemParticleIds = new IntArrayList(2);
private final IntList blockParticleIds = new IntArrayList(4);
public ParticleMappings(JsonArray oldMappings, Mappings mappings) {
this.mappings = mappings;
Object2IntMap<String> map = MappingDataLoader.arrayToMap(oldMappings);
blockId = map.getInt("block");
fallingDustId = map.getInt("falling_dust");
blockMarkerId = map.getInt("block_marker");
itemId = map.getInt("item");
stringToId = MappingDataLoader.arrayToMap(oldMappings);
stringToId.defaultReturnValue(-1);
addBlockParticle("block");
addBlockParticle("falling_dust");
addBlockParticle("block_marker");
addItemParticle("item");
}
/**
* Returns the unmapped integer id for the given identifier, or -1 if not found.
*
* @param identifier unmapped string identifier
* @return unmapped int id, or -1 if not found
*/
public int id(String identifier) {
return stringToId.getInt(identifier);
}
public Mappings getMappings() {
return mappings;
}
public boolean addItemParticle(final String identifier) {
final int id = id(identifier);
return id != -1 && itemParticleIds.add(id);
}
public boolean addBlockParticle(final String identifier) {
final int id = id(identifier);
return id != -1 && blockParticleIds.add(id);
}
public boolean isBlockParticle(final int id) {
return blockParticleIds.contains(id);
}
public boolean isItemParticle(final int id) {
return itemParticleIds.contains(id);
}
@Deprecated/*(forRemoval = true)*/
public int getBlockId() {
return blockId;
return id("block");
}
@Deprecated/*(forRemoval = true)*/
public int getFallingDustId() {
return fallingDustId;
}
public int getBlockmarkerid() {
return blockMarkerId;
return id("falling_dust");
}
@Deprecated/*(forRemoval = true)*/
public int getItemId() {
return itemId;
return id("item");
}
}

Datei anzeigen

@ -39,4 +39,44 @@ public interface MetaType {
* @return Type id as an integer
*/
int typeId();
static MetaType create(final int typeId, final Type<?> type) {
return new MetaTypeImpl(typeId, type);
}
final class MetaTypeImpl implements MetaType {
private final int typeId;
private final Type type;
MetaTypeImpl(final int typeId, final Type type) {
this.typeId = typeId;
this.type = type;
}
@Override
public int typeId() {
return typeId;
}
@Override
public Type type() {
return type;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final MetaTypeImpl metaType = (MetaTypeImpl) o;
if (typeId != metaType.typeId) return false;
return type.equals(metaType.type);
}
@Override
public int hashCode() {
int result = typeId;
result = 31 * result + type.hashCode();
return result;
}
}
}

Datei anzeigen

@ -105,7 +105,7 @@ public final class Metadata {
Preconditions.checkNotNull(metaType);
if (value != null && !metaType.type().getOutputClass().isAssignableFrom(value.getClass())) {
throw new IllegalArgumentException("Metadata value and metaType are incompatible. Type=" + metaType
+ ", value=" + (value != null ? value + " (" + value.getClass().getSimpleName() + ")" : "null"));
+ ", value=" + value + " (" + value.getClass().getSimpleName() + ")");
}
return value;
}

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
@Deprecated/*(forRemoval = true)*/
public enum MetaType1_13 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
@Deprecated/*(forRemoval = true)*/
public enum MetaType1_13_2 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
@Deprecated/*(forRemoval = true)*/
public enum MetaType1_14 implements MetaType {
Byte(0, Type.BYTE),
VarInt(1, Type.VAR_INT),

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
@Deprecated/*(forRemoval = true)*/
public enum MetaType1_16 implements MetaType {
BYTE(0, Type.BYTE),
VAR_INT(1, Type.VAR_INT),

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_17;
@Deprecated/*(forRemoval = true)*/
public enum MetaType1_17 implements MetaType {
BYTE(0, Type.BYTE),
VAR_INT(1, Type.VAR_INT),

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_18;
@Deprecated/*(forRemoval = true)*/
public enum MetaType1_18 implements MetaType {
BYTE(0, Type.BYTE),
VAR_INT(1, Type.VAR_INT),

Datei anzeigen

@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
public interface MetaTypes {
/**
* Returns the meta type by the given id.
*
* @param id type id
* @return meta type by id
* @throws IndexOutOfBoundsException if id is out of bounds
*/
MetaType byId(int id);
/**
* Returns an array of meta types.
*
* @return array of meta types
*/
MetaType[] values();
}

Datei anzeigen

@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
public final class MetaTypes1_13 implements MetaTypes {
private final MetaType[] values = new MetaType[16];
public final MetaType byteType = add(0, Type.BYTE);
public final MetaType varIntType = add(1, Type.VAR_INT);
public final MetaType floatType = add(2, Type.FLOAT);
public final MetaType stringType = add(3, Type.STRING);
public final MetaType componentType = add(4, Type.COMPONENT);
public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT);
public final MetaType itemType = add(6, Type.FLAT_ITEM);
public final MetaType booleanType = add(7, Type.BOOLEAN);
public final MetaType rotationType = add(8, Type.ROTATION);
public final MetaType positionType = add(9, Type.POSITION);
public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION);
public final MetaType directionType = add(11, Type.VAR_INT);
public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID);
public final MetaType blockStateType = add(13, Type.VAR_INT);
public final MetaType nbtType = add(14, Type.NBT);
public final MetaType particleType;
public MetaTypes1_13(final ParticleType particleType) {
this.particleType = add(15, particleType);
}
@Override
public MetaType byId(final int id) {
return values[id];
}
@Override
public MetaType[] values() {
return values;
}
private MetaType add(final int typeId, final Type type) {
final MetaType metaType = MetaType.create(typeId, type);
values[typeId] = metaType;
return metaType;
}
}

Datei anzeigen

@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
public final class MetaTypes1_13_2 implements MetaTypes {
private final MetaType[] values = new MetaType[16];
public final MetaType byteType = add(0, Type.BYTE);
public final MetaType varIntType = add(1, Type.VAR_INT);
public final MetaType floatType = add(2, Type.FLOAT);
public final MetaType stringType = add(3, Type.STRING);
public final MetaType componentType = add(4, Type.COMPONENT);
public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT);
public final MetaType itemType = add(6, Type.FLAT_VAR_INT_ITEM);
public final MetaType booleanType = add(7, Type.BOOLEAN);
public final MetaType rotationType = add(8, Type.ROTATION);
public final MetaType positionType = add(9, Type.POSITION);
public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION);
public final MetaType directionType = add(11, Type.VAR_INT);
public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID);
public final MetaType blockStateType = add(13, Type.VAR_INT);
public final MetaType nbtType = add(14, Type.NBT);
public final MetaType particleType;
public MetaTypes1_13_2(final ParticleType particleType) {
this.particleType = add(15, particleType);
}
@Override
public MetaType byId(final int id) {
return values[id];
}
@Override
public MetaType[] values() {
return values;
}
private MetaType add(final int typeId, final Type type) {
final MetaType metaType = MetaType.create(typeId, type);
values[typeId] = metaType;
return metaType;
}
}

Datei anzeigen

@ -0,0 +1,71 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
public final class MetaTypes1_14 implements MetaTypes {
private final MetaType[] values = new MetaType[19];
public final MetaType byteType = add(0, Type.BYTE);
public final MetaType varIntType = add(1, Type.VAR_INT);
public final MetaType floatType = add(2, Type.FLOAT);
public final MetaType stringType = add(3, Type.STRING);
public final MetaType componentType = add(4, Type.COMPONENT);
public final MetaType optionalComponentType = add(5, Type.OPTIONAL_COMPONENT);
public final MetaType itemType = add(6, Type.FLAT_VAR_INT_ITEM);
public final MetaType booleanType = add(7, Type.BOOLEAN);
public final MetaType rotationType = add(8, Type.ROTATION);
public final MetaType positionType = add(9, Type.POSITION1_14);
public final MetaType optionalPositionType = add(10, Type.OPTIONAL_POSITION_1_14);
public final MetaType directionType = add(11, Type.VAR_INT);
public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID);
public final MetaType blockStateType = add(13, Type.VAR_INT);
public final MetaType nbtType = add(14, Type.NBT);
public final MetaType particleType;
public final MetaType villagerDatatType = add(16, Type.VILLAGER_DATA);
public final MetaType optionalVarIntType = add(17, Type.OPTIONAL_VAR_INT);
public final MetaType poseType = add(18, Type.VAR_INT);
public MetaTypes1_14(final ParticleType particleType) {
this.particleType = add(15, particleType);
}
@Override
public MetaType byId(final int id) {
return values[id];
}
@Override
public MetaType[] values() {
return values;
}
private MetaType add(final int typeId, final Type type) {
final MetaType metaType = MetaType.create(typeId, type);
values[typeId] = metaType;
return metaType;
}
}

Datei anzeigen

@ -24,12 +24,13 @@ package com.viaversion.viaversion.api.type.types;
import com.viaversion.viaversion.api.type.Type;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class Particle {
private List<ParticleData> arguments = new ArrayList<>(4);
private int id;
private List<ParticleData> arguments = new LinkedList<>();
public Particle(int id) {
this.id = id;
@ -47,10 +48,15 @@ public class Particle {
return arguments;
}
@Deprecated/*(forRemoval = true)*/
public void setArguments(List<ParticleData> arguments) {
this.arguments = arguments;
}
public <T> void add(Type<T> type, T value) {
arguments.add(new ParticleData(type, value));
}
public static class ParticleData {
private Type type;
private Object value;

Datei anzeigen

@ -31,6 +31,7 @@ import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@Deprecated/*(forRemoval = true)*/
public abstract class AbstractParticleType extends Type<Particle> {
protected final Int2ObjectMap<ParticleReader> readers = new Int2ObjectOpenHashMap<>();

Datei anzeigen

@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type;
@Deprecated/*(forRemoval = true)*/
public class Particle1_13Type extends AbstractParticleType {
public Particle1_13Type() {

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import io.netty.buffer.ByteBuf;
@Deprecated/*(forRemoval = true)*/
public class Particle1_13_2Type extends Type<Particle> {
public Particle1_13_2Type() {

Datei anzeigen

@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type;
@Deprecated/*(forRemoval = true)*/
public class Particle1_14Type extends AbstractParticleType {
public Particle1_14Type() {

Datei anzeigen

@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type;
@Deprecated/*(forRemoval = true)*/
public class Particle1_16Type extends AbstractParticleType {
public Particle1_16Type() {

Datei anzeigen

@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type;
@Deprecated/*(forRemoval = true)*/
public class Particle1_17Type extends AbstractParticleType {
public Particle1_17Type() {

Datei anzeigen

@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type;
@Deprecated/*(forRemoval = true)*/
public class Particle1_18Type extends AbstractParticleType {
public Particle1_18Type() {

Datei anzeigen

@ -0,0 +1,143 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
public class ParticleType extends Type<Particle> {
private final Int2ObjectMap<ParticleReader> readers;
public ParticleType(final Int2ObjectMap<ParticleReader> readers) {
super("Particle", Particle.class);
this.readers = readers;
}
public ParticleType() {
this(new Int2ObjectArrayMap<>());
}
public ParticleTypeFiller filler(final Protocol<?, ?, ?, ?> protocol) {
return this.new ParticleTypeFiller(protocol);
}
@Override
public void write(final ByteBuf buffer, final Particle object) throws Exception {
Type.VAR_INT.writePrimitive(buffer, object.getId());
for (final Particle.ParticleData data : object.getArguments()) {
data.getType().write(buffer, data.getValue());
}
}
@Override
public Particle read(final ByteBuf buffer) throws Exception {
final int type = Type.VAR_INT.readPrimitive(buffer);
final Particle particle = new Particle(type);
final ParticleReader reader = readers.get(type);
if (reader != null) {
reader.read(buffer, particle);
}
return particle;
}
public static ParticleReader itemHandler(final Type<Item> itemType) {
return (buf, particle) -> particle.add(itemType, itemType.read(buf));
}
public static final class Readers {
public static final ParticleReader BLOCK = (buf, particle) -> {
particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Flat Block
};
public static final ParticleReader ITEM = itemHandler(Type.FLAT_ITEM);
public static final ParticleReader VAR_INT_ITEM = itemHandler(Type.FLAT_VAR_INT_ITEM);
public static final ParticleReader DUST = (buf, particle) -> {
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Red 0-1
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green 0-1
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue 0-1
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Scale 0.01-4
};
public static final ParticleReader DUST_TRANSITION = (buf, particle) -> {
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Red 0-1
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green 0-1
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue 0-1
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Scale 0.01-4
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Red
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Green
particle.add(Type.FLOAT, Type.FLOAT.readPrimitive(buf)); // Blue
};
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);
if (resourceLocation.equals("block")) {
particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // Target block pos
} else if (resourceLocation.equals("entity")) {
particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Target entity
} else {
Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + resourceLocation);
}
particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Arrival in ticks
};
}
public final class ParticleTypeFiller {
private final ParticleMappings mappings;
private ParticleTypeFiller(final Protocol<?, ?, ?, ?> protocol) {
this.mappings = protocol.getMappingData().getParticleMappings();
}
public ParticleTypeFiller reader(final String identifier, final ParticleReader reader) {
readers.put(mappings.id(identifier), reader);
return this;
}
public ParticleTypeFiller reader(final int id, final ParticleReader reader) {
readers.put(id, reader);
return this;
}
}
@FunctionalInterface
public interface ParticleReader {
/**
* Reads particle data from the buffer and adds it to the particle data.
*
* @param buf buffer
* @param particle particle
* @throws Exception if an error occurs during buffer reading
*/
void read(ByteBuf buf, Particle particle) throws Exception;
}
}

Datei anzeigen

@ -23,12 +23,12 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
@Deprecated/*(forRemoval = true)*/
public class Metadata1_13Type extends ModernMetaType {
@Override
protected MetaType getType(final int index) {
return MetaType1_13.byId(index);
return Types1_13.META_TYPES.byId(index);
}
}

Datei anzeigen

@ -23,12 +23,12 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13_2;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
@Deprecated/*(forRemoval = true)*/
public class Metadata1_13_2Type extends ModernMetaType {
@Override
protected MetaType getType(final int index) {
return MetaType1_13_2.byId(index);
return Types1_13_2.META_TYPES.byId(index);
}
}

Datei anzeigen

@ -23,12 +23,12 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
@Deprecated/*(forRemoval = true)*/
public class Metadata1_14Type extends ModernMetaType {
@Override
protected MetaType getType(final int index) {
return MetaType1_14.byId(index);
return Types1_14.META_TYPES.byId(index);
}
}

Datei anzeigen

@ -23,13 +23,13 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_16;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
@Deprecated/*(forRemoval = true)*/
public class Metadata1_16Type extends ModernMetaType {
@Override
protected MetaType getType(final int index) {
return MetaType1_16.byId(index);
return Types1_16.META_TYPES.byId(index);
}
}

Datei anzeigen

@ -23,13 +23,13 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_17;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
@Deprecated/*(forRemoval = true)*/
public class Metadata1_17Type extends ModernMetaType {
@Override
protected MetaType getType(final int index) {
return MetaType1_17.byId(index);
return Types1_17.META_TYPES.byId(index);
}
}

Datei anzeigen

@ -23,13 +23,13 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_18;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
@Deprecated/*(forRemoval = true)*/
public class Metadata1_18Type extends ModernMetaType {
@Override
protected MetaType getType(final int index) {
return MetaType1_18.byId(index);
return Types1_18.META_TYPES.byId(index);
}
}

Datei anzeigen

@ -0,0 +1,41 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
public final class MetadataType extends ModernMetaType {
private final MetaTypes metaTypes;
public MetadataType(final MetaTypes metaTypes) {
this.metaTypes = metaTypes;
}
@Override
protected MetaType getType(final int index) {
return metaTypes.byId(index);
}
}

Datei anzeigen

@ -24,27 +24,18 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_13;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.Particle1_13Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import java.util.List;
public class Types1_13 {
/**
* Metadata type for 1.13
*/
public static final Type<Metadata> METADATA = new Metadata1_13Type();
/**
* Metadata list type for 1.13
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public final class Types1_13 {
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_13();
/**
* Particle type for 1.13
*/
public static final Type<Particle> PARTICLE = new Particle1_13Type();
public static final ParticleType PARTICLE = new ParticleType();
public static final MetaTypes1_13 META_TYPES = new MetaTypes1_13(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
}

Datei anzeigen

@ -23,26 +23,17 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_13_2;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.Particle1_13_2Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import java.util.List;
public class Types1_13_2 {
public final class Types1_13_2 {
/**
* Metadata type for 1.13
*/
public static final Type<Metadata> METADATA = new Metadata1_13_2Type();
/**
* Metadata list type for 1.13
*/
public static final ParticleType PARTICLE = new ParticleType();
public static final MetaTypes1_13_2 META_TYPES = new MetaTypes1_13_2(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
/**
* Particle type for 1.13.2
*/
public static final Type<Particle> PARTICLE = new Particle1_13_2Type();
}

Datei anzeigen

@ -23,26 +23,17 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_14;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.Particle1_14Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import java.util.List;
public final class Types1_14 {
/**
* Metadata type for 1.14
*/
public static final Type<Metadata> METADATA = new Metadata1_14Type();
/**
* Metadata list type for 1.14
*/
public static final ParticleType PARTICLE = new ParticleType();
public static final MetaTypes1_14 META_TYPES = new MetaTypes1_14(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
/**
* Particle type for 1.14
*/
public static final Type<Particle> PARTICLE = new Particle1_14Type();
}

Datei anzeigen

@ -24,21 +24,18 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_14;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.Particle1_16Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import java.util.List;
public final class Types1_16 {
/**
* Chunk section type for 1.16
*/
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_16();
public static final Type<Metadata> METADATA = new Metadata1_16Type();
public static final ParticleType PARTICLE = new ParticleType(); // Only safe to use after protocol loading
public static final MetaTypes1_14 META_TYPES = new MetaTypes1_14(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public static final Type<Particle> PARTICLE = new Particle1_16Type();
}

Datei anzeigen

@ -23,16 +23,17 @@
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_14;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.Particle1_17Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import java.util.List;
public final class Types1_17 {
public static final Type<Metadata> METADATA = new Metadata1_17Type();
public static final ParticleType PARTICLE = new ParticleType(); // Only safe to use after protocol loading
public static final MetaTypes1_14 META_TYPES = new MetaTypes1_14(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public static final Type<Particle> PARTICLE = new Particle1_17Type();
}

Datei anzeigen

@ -24,17 +24,18 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_14;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.Particle1_18Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import java.util.List;
public final class Types1_18 {
public static final Type<BlockEntity> BLOCK_ENTITY = new BlockEntityType1_18();
public static final Type<Metadata> METADATA = new Metadata1_18Type();
public static final ParticleType PARTICLE = new ParticleType(); // Only safe to use after protocol loading
public static final MetaTypes1_14 META_TYPES = new MetaTypes1_14(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public static final Type<Particle> PARTICLE = new Particle1_18Type();
}

Datei anzeigen

@ -19,7 +19,6 @@ package com.viaversion.viaversion.bukkit.listeners.protocol1_15to1_14_4;
import com.viaversion.viaversion.ViaVersionPlugin;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
@ -83,7 +82,7 @@ public class EntityToggleGlideListener extends ViaBukkitListener {
}
// leave 0x80 as 0 to stop gliding
packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, MetaType1_14.Byte, bitmask)));
packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, Types1_14.META_TYPES.byteType, bitmask)));
packet.scheduleSend(Protocol1_15To1_14_4.class);
} catch (Exception e) {
e.printStackTrace();

Datei anzeigen

@ -22,8 +22,8 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.rewriter.EntityRewriter;
@ -38,13 +38,13 @@ public class MetadataRewriter1_13_1To1_13 extends EntityRewriter<Protocol1_13_1T
@Override
protected void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) {
// 1.13 changed item to flat item (no data)
if (metadata.metaType() == MetaType1_13.Slot) {
if (metadata.metaType() == Types1_13.META_TYPES.itemType) {
protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue());
} else if (metadata.metaType() == MetaType1_13.BlockID) {
} else if (metadata.metaType() == Types1_13.META_TYPES.blockStateType) {
// Convert to new block id
int data = (int) metadata.getValue();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.metaType() == MetaType1_13.PARTICLE) {
} else if (metadata.metaType() == Types1_13.META_TYPES.particleType) {
rewriteParticle((Particle) metadata.getValue());
}

Datei anzeigen

@ -18,7 +18,6 @@
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13_2;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
@ -32,7 +31,7 @@ public class EntityPackets {
public static void register(Protocol protocol) {
final PacketHandler metaTypeHandler = wrapper -> {
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
metadata.setMetaType(MetaType1_13_2.byId(metadata.metaType().typeId()));
metadata.setMetaType(Types1_13_2.META_TYPES.byId(metadata.metaType().typeId()));
}
};

Datei anzeigen

@ -37,6 +37,8 @@ import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
@ -1037,6 +1039,12 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
ConnectionData.init();
RecipeData.init();
BlockIdData.init();
Types1_13.PARTICLE.filler(this)
.reader(3, ParticleType.Readers.BLOCK)
.reader(20, ParticleType.Readers.DUST)
.reader(11, ParticleType.Readers.DUST)
.reader(27, ParticleType.Readers.ITEM);
}
@Override

Datei anzeigen

@ -22,8 +22,8 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
@ -43,17 +43,17 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<Protocol1_13To1
protected void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
// Handle new MetaTypes
if (metadata.metaType().typeId() > 4) {
metadata.setMetaType(MetaType1_13.byId(metadata.metaType().typeId() + 1));
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId() + 1));
} else {
metadata.setMetaType(MetaType1_13.byId(metadata.metaType().typeId()));
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
}
// Handle String -> Chat DisplayName
if (metadata.id() == 2) {
if (metadata.getValue() != null && !((String) metadata.getValue()).isEmpty()) {
metadata.setTypeAndValue(MetaType1_13.OptChat, ChatRewriter.legacyTextToJson((String) metadata.getValue()));
metadata.setTypeAndValue(Types1_13.META_TYPES.optionalComponentType, ChatRewriter.legacyTextToJson((String) metadata.getValue()));
} else {
metadata.setTypeAndValue(MetaType1_13.OptChat, null);
metadata.setTypeAndValue(Types1_13.META_TYPES.optionalComponentType, null);
}
}
@ -66,10 +66,10 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<Protocol1_13To1
}
// 1.13 changed item to flat item (no data)
if (metadata.metaType() == MetaType1_13.Slot) {
metadata.setMetaType(MetaType1_13.Slot);
if (metadata.metaType() == Types1_13.META_TYPES.itemType) {
metadata.setMetaType(Types1_13.META_TYPES.itemType);
protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue());
} else if (metadata.metaType() == MetaType1_13.BlockID) {
} else if (metadata.metaType() == Types1_13.META_TYPES.blockStateType) {
// Convert to new block id
metadata.setValue(WorldPackets.toNewId((int) metadata.getValue()));
}
@ -108,7 +108,7 @@ public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<Protocol1_13To1
Particle particle = ParticleRewriter.rewriteParticle(particleId, new Integer[]{parameter1, parameter2});
if (particle != null && particle.getId() != -1) {
metadatas.add(new Metadata(9, MetaType1_13.PARTICLE, particle));
metadatas.add(new Metadata(9, Types1_13.META_TYPES.particleType, particle));
}
}

Datei anzeigen

@ -25,6 +25,9 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.CommandRewriter1_14;
@ -145,6 +148,17 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
WorldPackets.air = getMappingData().getBlockStateMappings().getNewId(0);
WorldPackets.voidAir = getMappingData().getBlockStateMappings().getNewId(8591);
WorldPackets.caveAir = getMappingData().getBlockStateMappings().getNewId(8592);
Types1_13_2.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
.reader("falling_dust", ParticleType.Readers.DUST)
.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("item", ParticleType.Readers.VAR_INT_ITEM);
}
@Override

Datei anzeigen

@ -26,10 +26,10 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
@ -47,17 +47,17 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
@Override
protected void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
metadata.setMetaType(MetaType1_14.byId(metadata.metaType().typeId()));
metadata.setMetaType(Types1_14.META_TYPES.byId(metadata.metaType().typeId()));
EntityTracker1_14 tracker = tracker(connection);
if (metadata.metaType() == MetaType1_14.Slot) {
if (metadata.metaType() == Types1_14.META_TYPES.itemType) {
protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue());
} else if (metadata.metaType() == MetaType1_14.BlockID) {
} else if (metadata.metaType() == Types1_14.META_TYPES.blockStateType) {
// Convert to new block id
int data = (int) metadata.getValue();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.metaType() == MetaType1_14.PARTICLE) {
} else if (metadata.metaType() == Types1_14.META_TYPES.particleType) {
rewriteParticle((Particle) metadata.getValue());
}
@ -97,7 +97,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
tracker.setRiptide(entityId, (((Number) metadata.getValue()).byteValue() & 0x4) != 0);
}
if (metadata.id() == 0 || metadata.id() == 7) {
metadatas.add(new Metadata(6, MetaType1_14.Pose, recalculatePlayerPose(entityId, tracker)));
metadatas.add(new Metadata(6, Types1_14.META_TYPES.poseType, recalculatePlayerPose(entityId, tracker)));
}
}
} else if (type.isOrHasParent(Entity1_14Types.ZOMBIE)) {
@ -105,7 +105,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
metadatas.remove(metadata); // "Are hands held up"
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
metadatas.add(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
} else if (metadata.id() > 16) {
metadata.setId(metadata.id() - 1);
}
@ -140,12 +140,12 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
} else if (type.is(Entity1_14Types.VILLAGER)) {
if (metadata.id() == 15) {
// plains
metadata.setTypeAndValue(MetaType1_14.VillagerData, new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
metadata.setTypeAndValue(Types1_14.META_TYPES.villagerDatatType, new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
}
} else if (type.is(Entity1_14Types.ZOMBIE_VILLAGER)) {
if (metadata.id() == 18) {
// plains
metadata.setTypeAndValue(MetaType1_14.VillagerData, new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
metadata.setTypeAndValue(Types1_14.META_TYPES.villagerDatatType, new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
}
} else if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ARROW)) {
if (metadata.id() >= 9) { // New piercing
@ -153,7 +153,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
}
} else if (type.is(Entity1_14Types.FIREWORK_ROCKET)) {
if (metadata.id() == 8) {
metadata.setMetaType(MetaType1_14.OptVarInt);
metadata.setMetaType(Types1_14.META_TYPES.optionalVarIntType);
if (metadata.getValue().equals(0)) {
metadata.setValue(null); // https://bugs.mojang.com/browse/MC-111480
}
@ -163,7 +163,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
metadatas.remove(metadata); // "Is swinging arms"
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
metadatas.add(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
}
}
@ -172,7 +172,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| (((Number) metadata.getValue()).byteValue() != 0 ? 0x4 : 0))); // New attacking
metadatas.remove(metadata); // "Has target (aggressive state)"
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
metadatas.add(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
}
}

Datei anzeigen

@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
@ -185,9 +184,9 @@ public class EntityPackets {
metadataPacket.write(Type.VAR_INT, entityId);
List<Metadata> metadataList = new LinkedList<>();
if (tracker.clientEntityId() != entityId) {
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter1_14To1_13_2.recalculatePlayerPose(entityId, tracker)));
metadataList.add(new Metadata(6, Types1_14.META_TYPES.poseType, MetadataRewriter1_14To1_13_2.recalculatePlayerPose(entityId, tracker)));
}
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, null));
metadataList.add(new Metadata(12, Types1_14.META_TYPES.optionalPositionType, null));
metadataPacket.write(Types1_14.METADATA_LIST, metadataList);
metadataPacket.scheduleSend(Protocol1_14To1_13_2.class);
}
@ -209,9 +208,9 @@ public class EntityPackets {
Position position = wrapper.read(Type.POSITION);
List<Metadata> metadataList = new LinkedList<>();
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, position));
metadataList.add(new Metadata(12, Types1_14.META_TYPES.optionalPositionType, position));
if (tracker.clientEntityId() != entityId) {
metadataList.add(new Metadata(6, MetaType1_14.Pose, MetadataRewriter1_14To1_13_2.recalculatePlayerPose(entityId, tracker)));
metadataList.add(new Metadata(6, Types1_14.META_TYPES.poseType, MetadataRewriter1_14To1_13_2.recalculatePlayerPose(entityId, tracker)));
}
wrapper.write(Types1_14.METADATA_LIST, metadataList);
}

Datei anzeigen

@ -22,9 +22,8 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_13;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
import com.viaversion.viaversion.rewriter.EntityRewriter;
@ -39,13 +38,13 @@ public class MetadataRewriter1_15To1_14_4 extends EntityRewriter<Protocol1_15To1
@Override
public void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
if (metadata.metaType() == MetaType1_14.Slot) {
if (metadata.metaType() == Types1_14.META_TYPES.itemType) {
protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue());
} else if (metadata.metaType() == MetaType1_14.BlockID) {
} else if (metadata.metaType() == Types1_14.META_TYPES.blockStateType) {
// Convert to new block id
int data = (int) metadata.getValue();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.metaType() == MetaType1_13.PARTICLE) {
} else if (metadata.metaType() == Types1_14.META_TYPES.particleType) {
rewriteParticle((Particle) metadata.getValue());
}

Datei anzeigen

@ -23,8 +23,8 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_16;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import com.viaversion.viaversion.rewriter.EntityRewriter;
@ -39,12 +39,12 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<Protocol1_16_
@Override
public void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
if (metadata.metaType() == MetaType1_16.ITEM) {
if (metadata.metaType() == Types1_16.META_TYPES.itemType) {
protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue());
} else if (metadata.metaType() == MetaType1_16.BLOCK_STATE) {
} else if (metadata.metaType() == Types1_16.META_TYPES.blockStateType) {
int data = (int) metadata.getValue();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.metaType() == MetaType1_16.PARTICLE) {
} else if (metadata.metaType() == Types1_16.META_TYPES.particleType) {
rewriteParticle((Particle) metadata.getValue());
}

Datei anzeigen

@ -23,6 +23,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.State;
@ -30,6 +31,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
@ -41,7 +44,6 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.Inventor
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.WorldPackets;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.rewriter.SoundRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
@ -271,6 +273,12 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
tagRewriter.addEmptyTags(RegistryType.ENTITY, "minecraft:arrows", "minecraft:beehive_inhabitors", "minecraft:raiders", "minecraft:skeletons");
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:beds", "minecraft:coals", "minecraft:fences", "minecraft:flowers",
"minecraft:lectern_books", "minecraft:music_discs", "minecraft:small_flowers", "minecraft:tall_flowers", "minecraft:trapdoors", "minecraft:walls", "minecraft:wooden_fences");
Types1_16.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
.reader("falling_dust", ParticleType.Readers.DUST)
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
}
@Override

Datei anzeigen

@ -23,8 +23,8 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_16;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viaversion.rewriter.EntityRewriter;
@ -40,13 +40,13 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<Protocol1_16To1
@Override
public void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
metadata.setMetaType(MetaType1_16.byId(metadata.metaType().typeId()));
if (metadata.metaType() == MetaType1_16.ITEM) {
metadata.setMetaType(Types1_16.META_TYPES.byId(metadata.metaType().typeId()));
if (metadata.metaType() == Types1_16.META_TYPES.itemType) {
protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue());
} else if (metadata.metaType() == MetaType1_16.BLOCK_STATE) {
} else if (metadata.metaType() == Types1_16.META_TYPES.blockStateType) {
int data = (int) metadata.getValue();
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (metadata.metaType() == MetaType1_16.PARTICLE) {
} else if (metadata.metaType() == Types1_16.META_TYPES.particleType) {
rewriteParticle((Particle) metadata.getValue());
}
@ -71,7 +71,7 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<Protocol1_16To1
if (metadata.id() == 16) {
byte mask = metadata.value();
int angerTime = (mask & 0x02) != 0 ? Integer.MAX_VALUE : 0;
metadatas.add(new Metadata(20, MetaType1_16.VAR_INT, angerTime));
metadatas.add(new Metadata(20, Types1_16.META_TYPES.varIntType, angerTime));
}
}
}

Datei anzeigen

@ -29,6 +29,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_17;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
@ -222,6 +224,14 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
"minecraft:features_cannot_replace", "minecraft:lava_pool_stone_replaceables", "minecraft:geode_invalid_blocks");
tagRewriter.addEmptyTags(RegistryType.ENTITY, "minecraft:powder_snow_walkable_mobs", "minecraft:axolotl_always_hostiles", "minecraft:axolotl_tempted_hostiles",
"minecraft:axolotl_hunt_targets", "minecraft:freeze_hurts_extra_types", "minecraft:freeze_immune_entity_types");
Types1_17.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
.reader("falling_dust", ParticleType.Readers.DUST)
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
.reader("vibration", ParticleType.Readers.VIBRATION);
}
@Override

Datei anzeigen

@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_17;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
@ -128,9 +127,9 @@ public final class EntityPackets extends EntityRewriter<Protocol1_17To1_16_4> {
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(MetaType1_17.byId(meta.metaType().typeId()));
meta.setMetaType(Types1_17.META_TYPES.byId(meta.metaType().typeId()));
if (meta.metaType() == MetaType1_17.POSE) {
if (meta.metaType() == Types1_17.META_TYPES.poseType) {
int pose = meta.value();
if (pose > 5) {
// Added LONG_JUMP at 6
@ -138,7 +137,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_17To1_16_4> {
}
}
});
registerMetaTypeHandler(MetaType1_17.ITEM, MetaType1_17.BLOCK_STATE, MetaType1_17.PARTICLE);
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, Types1_17.META_TYPES.particleType);
// Ticks frozen added with id 7
filter().filterFamily(Entity1_17Types.ENTITY).addIndex(7);

Datei anzeigen

@ -23,6 +23,8 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_18;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
@ -70,6 +72,18 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
});
}
@Override
protected void onMappingDataLoaded() {
Types1_18.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
.reader("falling_dust", ParticleType.Readers.DUST)
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
.reader("vibration", ParticleType.Readers.VIBRATION);
}
@Override
protected void registerPackets() {
entityRewriter.register();

Datei anzeigen

@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_18;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
@ -88,8 +87,8 @@ public final class EntityPackets extends EntityRewriter<Protocol1_18To1_17_1> {
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(MetaType1_18.byId(meta.metaType().typeId()));
if (meta.metaType() == MetaType1_18.PARTICLE) {
meta.setMetaType(Types1_18.META_TYPES.byId(meta.metaType().typeId()));
if (meta.metaType() == Types1_18.META_TYPES.particleType) {
Particle particle = (Particle) meta.getValue();
if (particle.getId() == 2) { // Barrier
particle.setId(3); // Block marker
@ -102,7 +101,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_18To1_17_1> {
}
});
registerMetaTypeHandler(MetaType1_18.ITEM, null, null);
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null);
/*filter().filterFamily(Entity1_17Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { //TODO check id
// Convert to new block id

Datei anzeigen

@ -66,10 +66,10 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_18To1_17_1> {
}
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
if (mappings.isBlockParticle(id)) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == mappings.getItemId()) {
} else if (mappings.isItemParticle(id)) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
}

Datei anzeigen

@ -479,11 +479,10 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
protected void rewriteParticle(Particle particle) {
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
int id = particle.getId();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()
|| (mappings.getBlockmarkerid() != -1 && id == mappings.getBlockmarkerid())) {
if (mappings.isBlockParticle(id)) {
Particle.ParticleData data = particle.getArguments().get(0);
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
} else if (id == mappings.getItemId()) {
} else if (mappings.isItemParticle(id)) {
Particle.ParticleData data = particle.getArguments().get(0);
data.setValue(protocol.getMappingData().getNewItemId(data.get()));
}

Datei anzeigen

@ -329,10 +329,10 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
if (id == -1) return;
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
if (mappings.isBlockParticle(id)) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == mappings.getItemId()) {
} else if (mappings.isItemParticle(id)) {
handleItemToClient(wrapper.passthrough(itemType));
}