3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 17:10:13 +01:00

Handle particle id change in 1.16 metadata

Fixes #2551
Dieser Commit ist enthalten in:
KennyTV 2021-06-17 11:55:22 +02:00
Ursprung 40f87e9472
Commit 5cdaabeaec
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
24 geänderte Dateien mit 287 neuen und 286 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,72 @@
/*
* 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.version.Types1_16;
public enum MetaType1_16 implements MetaType {
BYTE(0, Type.BYTE),
VAR_INT(1, Type.VAR_INT),
FLOAT(2, Type.FLOAT),
STRING(3, Type.STRING),
COMPONENT(4, Type.COMPONENT),
OPT_COMPONENT(5, Type.OPTIONAL_COMPONENT),
ITEM(6, Type.FLAT_VAR_INT_ITEM),
BOOLEAN(7, Type.BOOLEAN),
ROTATION(8, Type.ROTATION),
POSITION(9, Type.POSITION1_14),
OPT_POSITION(10, Type.OPTIONAL_POSITION_1_14),
DIRECTION(11, Type.VAR_INT),
OPT_UUID(12, Type.OPTIONAL_UUID),
BLOCK_STATE(13, Type.VAR_INT),
NBT(14, Type.NBT),
PARTICLE(15, Types1_16.PARTICLE),
VILLAGER_DATA(16, Type.VILLAGER_DATA),
OPT_VAR_INT(17, Type.OPTIONAL_VAR_INT),
POSE(18, Type.VAR_INT);
private static final MetaType1_16[] VALUES = values();
private final int typeId;
private final Type type;
MetaType1_16(int typeId, Type type) {
this.typeId = typeId;
this.type = type;
}
public static MetaType1_16 byId(int id) {
return VALUES[id];
}
@Override
public int typeId() {
return typeId;
}
@Override
public Type type() {
return type;
}
}

Datei anzeigen

@ -32,17 +32,22 @@ public abstract class PartialType<T, X> extends Type<T> {
this.param = param; this.param = param;
} }
protected PartialType(X param, String name, Class<T> type) {
super(name, type);
this.param = param;
}
public abstract T read(ByteBuf buffer, X param) throws Exception; public abstract T read(ByteBuf buffer, X param) throws Exception;
public abstract void write(ByteBuf buffer, X param, T object) throws Exception; public abstract void write(ByteBuf buffer, X param, T object) throws Exception;
@Override @Override
public T read(ByteBuf buffer) throws Exception { public final T read(ByteBuf buffer) throws Exception {
return read(buffer, this.param); return read(buffer, this.param);
} }
@Override @Override
public void write(ByteBuf buffer, T object) throws Exception { public final void write(ByteBuf buffer, T object) throws Exception {
write(buffer, this.param, object); write(buffer, this.param, object);
} }
} }

Datei anzeigen

@ -0,0 +1,115 @@
/*
* 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.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.item.Item;
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.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public abstract class AbstractParticleType extends Type<Particle> {
protected final Int2ObjectMap<ParticleReader> readers = new Int2ObjectOpenHashMap<>();
protected AbstractParticleType() {
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);
ParticleReader reader = readers.get(type);
if (reader != null) {
reader.read(buffer, particle);
}
return particle;
}
protected ParticleReader blockHandler() {
return (buf, particle) -> {
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf))); // Flat Block
};
}
protected ParticleReader itemHandler(Type<Item> itemType) {
return (buf, particle) -> {
particle.getArguments().add(new Particle.ParticleData(itemType, itemType.read(buf))); // Flat item;
};
}
protected ParticleReader dustHandler() {
return (buf, particle) -> {
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Red 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Green 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Blue 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Scale 0.01 - 4
};
}
protected ParticleReader dustTransitionHandler() {
return (buf, particle) -> {
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Red 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Green 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Blue 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Scale 0.01 - 4
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Red
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Green
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.readPrimitive(buf))); // Blue
};
}
protected ParticleReader vibrationHandler(Type<Position> positionType) {
return (buf, particle) -> {
particle.getArguments().add(new Particle.ParticleData(positionType, positionType.read(buf))); // From block pos
String resourceLocation = Type.STRING.read(buf);
if (resourceLocation.equals("block")) {
particle.getArguments().add(new Particle.ParticleData(positionType, positionType.read(buf))); // Target block pos
} else if (resourceLocation.equals("entity")) {
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf))); // Target entity
} else {
Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + resourceLocation);
}
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf))); // Arrival in ticks
};
}
@FunctionalInterface
public interface ParticleReader {
void read(ByteBuf buf, Particle particle) throws Exception;
}
}

Datei anzeigen

@ -20,15 +20,22 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
package com.viaversion.viaversion.api.type.types.version; package com.viaversion.viaversion.api.type.types.minecraft;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
public class MetadataList1_13_2Type extends ModernMetaListType { public final class MetaListType extends ModernMetaListType {
private final Type<Metadata> type;
public MetaListType(Type<Metadata> type) {
Preconditions.checkNotNull(type);
this.type = type;
}
@Override @Override
protected Type<Metadata> getType() { protected Type<Metadata> getType() {
return Types1_13_2.METADATA; return type;
} }
} }

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
public abstract class MetaTypeTemplate extends Type<Metadata> { public abstract class MetaTypeTemplate extends Type<Metadata> {
public MetaTypeTemplate() { protected MetaTypeTemplate() {
super("Metadata type", Metadata.class); super("Metadata type", Metadata.class);
} }

Datei anzeigen

@ -23,45 +23,13 @@
package com.viaversion.viaversion.api.type.types.minecraft; package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import io.netty.buffer.ByteBuf;
public class Particle1_13Type extends Type<Particle> { public class Particle1_13Type extends AbstractParticleType {
public Particle1_13Type() { public Particle1_13Type() {
super("Particle", Particle.class); readers.put(3, blockHandler());
} readers.put(20, blockHandler());
readers.put(11, dustHandler());
@Override readers.put(27, itemHandler(Type.FLAT_ITEM));
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;
} }
} }

Datei anzeigen

@ -23,46 +23,13 @@
package com.viaversion.viaversion.api.type.types.minecraft; package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import io.netty.buffer.ByteBuf;
public class Particle1_14Type extends Type<Particle> { public class Particle1_14Type extends AbstractParticleType {
public Particle1_14Type() { public Particle1_14Type() {
super("Particle", Particle.class); readers.put(3, blockHandler());
} readers.put(23, blockHandler());
readers.put(14, dustHandler());
@Override readers.put(32, itemHandler(Type.FLAT_VAR_INT_ITEM));
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 23:
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Flat Block
break;
// Dust
case 14:
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 32:
particle.getArguments().add(new Particle.ParticleData(Type.FLAT_VAR_INT_ITEM, Type.FLAT_VAR_INT_ITEM.read(buffer))); // Flat item
break;
}
return particle;
} }
} }

Datei anzeigen

@ -20,15 +20,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
package com.viaversion.viaversion.api.type.types.version; package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
public class MetadataList1_9Type extends ModernMetaListType { public class Particle1_16Type extends AbstractParticleType {
@Override
protected Type<Metadata> getType() { public Particle1_16Type() {
return Types1_9.METADATA; readers.put(3, blockHandler());
readers.put(23, blockHandler());
readers.put(14, dustHandler());
readers.put(34, itemHandler(Type.FLAT_VAR_INT_ITEM));
} }
} }

Datei anzeigen

@ -22,64 +22,17 @@
*/ */
package com.viaversion.viaversion.api.type.types.minecraft; package com.viaversion.viaversion.api.type.types.minecraft;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import io.netty.buffer.ByteBuf;
public class Particle1_17Type extends Type<Particle> { public class Particle1_17Type extends AbstractParticleType {
public Particle1_17Type() { public Particle1_17Type() {
super("Particle", Particle.class); readers.put(4, blockHandler());
} readers.put(25, blockHandler());
readers.put(15, dustHandler());
@Override readers.put(16, dustTransitionHandler());
public void write(ByteBuf buffer, Particle object) throws Exception { readers.put(36, itemHandler(Type.FLAT_VAR_INT_ITEM));
Type.VAR_INT.writePrimitive(buffer, object.getId()); readers.put(37, vibrationHandler(Type.POSITION1_14));
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) {
case 3: // Block
case 24: // Falling dust
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Flat Block
break;
case 14: // Dust
case 15: // Dust transition
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.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
particle.getArguments().add(new Particle.ParticleData(Type.FLAT_VAR_INT_ITEM, Type.FLAT_VAR_INT_ITEM.read(buffer))); // Flat item
break;
case 36: // Vibration path
particle.getArguments().add(new Particle.ParticleData(Type.POSITION1_14, Type.POSITION1_14.read(buffer))); // From block pos
String resourceLocation = Type.STRING.read(buffer);
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.readPrimitive(buffer))); // Target entity
} else {
Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + resourceLocation);
}
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.readPrimitive(buffer))); // Arrival in ticks
}
return particle;
} }
} }

Datei anzeigen

@ -22,14 +22,14 @@
*/ */
package com.viaversion.viaversion.api.type.types.version; package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_16;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType; import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaType;
public class MetadataList1_17Type extends ModernMetaListType { public class Metadata1_16Type extends ModernMetaType {
@Override @Override
protected Type<Metadata> getType() { protected MetaType getType(final int index) {
return Types1_17.METADATA; return MetaType1_16.byId(index);
} }
} }

Datei anzeigen

@ -1,34 +0,0 @@
/*
* 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.Metadata;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
public class MetadataList1_12Type extends ModernMetaListType {
@Override
protected Type<Metadata> getType() {
return Types1_12.METADATA;
}
}

Datei anzeigen

@ -1,34 +0,0 @@
/*
* 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.Metadata;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
public class MetadataList1_13Type extends ModernMetaListType {
@Override
protected Type<Metadata> getType() {
return Types1_13.METADATA;
}
}

Datei anzeigen

@ -1,34 +0,0 @@
/*
* 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.Metadata;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
public class MetadataList1_14Type extends ModernMetaListType {
@Override
protected Type<Metadata> getType() {
return Types1_14.METADATA;
}
}

Datei anzeigen

@ -24,17 +24,18 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import java.util.List; import java.util.List;
public class Types1_12 { public class Types1_12 {
/**
* Metadata list type for 1.12
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_12Type();
/** /**
* Metadata type for 1.12 * Metadata type for 1.12
*/ */
public static final Type<Metadata> METADATA = new Metadata1_12Type(); public static final Type<Metadata> METADATA = new Metadata1_12Type();
/**
* Metadata list type for 1.12
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
} }

Datei anzeigen

@ -26,20 +26,20 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle; 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.Particle1_13Type;
import java.util.List; import java.util.List;
public class Types1_13 { public class Types1_13 {
/**
* Metadata list type for 1.13
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_13Type();
/** /**
* Metadata type for 1.13 * Metadata type for 1.13
*/ */
public static final Type<Metadata> METADATA = new Metadata1_13Type(); 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 static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_13(); public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_13();

Datei anzeigen

@ -25,20 +25,21 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle; 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.Particle1_13_2Type;
import java.util.List; import java.util.List;
public class Types1_13_2 { public class Types1_13_2 {
/**
* Metadata list type for 1.13
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_13_2Type();
/** /**
* Metadata type for 1.13 * Metadata type for 1.13
*/ */
public static final Type<Metadata> METADATA = new Metadata1_13_2Type(); public static final Type<Metadata> METADATA = new Metadata1_13_2Type();
/**
* Metadata list type for 1.13
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
/** /**
* Particle type for 1.13.2 * Particle type for 1.13.2

Datei anzeigen

@ -25,20 +25,21 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle; 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.Particle1_14Type;
import java.util.List; import java.util.List;
public class Types1_14 { public final class Types1_14 {
/**
* Metadata list type for 1.14
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_14Type();
/** /**
* Metadata type for 1.14 * Metadata type for 1.14
*/ */
public static final Type<Metadata> METADATA = new Metadata1_14Type(); public static final Type<Metadata> METADATA = new Metadata1_14Type();
/**
* Metadata list type for 1.14
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
/** /**
* Particle type for 1.14 * Particle type for 1.14

Datei anzeigen

@ -23,12 +23,22 @@
package com.viaversion.viaversion.api.type.types.version; package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; 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;
public class Types1_16 { import java.util.List;
public final class Types1_16 {
/** /**
* Chunk section type for 1.16 * Chunk section type for 1.16
*/ */
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_16(); public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_16();
public static final Type<Metadata> METADATA = new Metadata1_16Type();
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public static final Type<Particle> PARTICLE = new Particle1_16Type();
} }

Datei anzeigen

@ -25,13 +25,14 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle; 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.Particle1_17Type;
import java.util.List; import java.util.List;
public class Types1_17 { public final class Types1_17 {
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_17Type();
public static final Type<Metadata> METADATA = new Metadata1_17Type(); public static final Type<Metadata> METADATA = new Metadata1_17Type();
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public static final Type<Particle> PARTICLE = new Particle1_17Type(); public static final Type<Particle> PARTICLE = new Particle1_17Type();
} }

Datei anzeigen

@ -29,15 +29,15 @@ import com.viaversion.viaversion.api.type.Type;
import java.util.List; import java.util.List;
public class Types1_8 { public class Types1_8 {
/**
* Metadata list type for 1.8
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_8Type();
/** /**
* Metadata type for 1.8 * Metadata type for 1.8
*/ */
public static final Type<Metadata> METADATA = new Metadata1_8Type(); public static final Type<Metadata> METADATA = new Metadata1_8Type();
/**
* Metadata list type for 1.8
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_8Type();
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_8(); public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_8();
} }

Datei anzeigen

@ -25,19 +25,19 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import java.util.List; import java.util.List;
public class Types1_9 { public class Types1_9 {
/**
* Metadata list type for 1.9
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_9Type();
/** /**
* Metadata type for 1.9 * Metadata type for 1.9
*/ */
public static final Type<Metadata> METADATA = new Metadata1_9Type(); public static final Type<Metadata> METADATA = new Metadata1_9Type();
/**
* Metadata list type for 1.9
*/
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_9(); public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_9();
} }

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14; 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.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.metadata.MetadataRewriter1_16_2To1_16_1; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.metadata.MetadataRewriter1_16_2To1_16_1;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
@ -34,7 +34,7 @@ public class EntityPackets {
metadataRewriter.registerTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.FALLING_BLOCK); metadataRewriter.registerTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.FALLING_BLOCK);
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_MOB); metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_MOB);
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.PLAYER); metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.PLAYER);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST);
metadataRewriter.registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES); metadataRewriter.registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES);
protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() { protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() {

Datei anzeigen

@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
@ -174,7 +175,7 @@ public class EntityPackets {
metadataRewriter.registerTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.FALLING_BLOCK); metadataRewriter.registerTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.FALLING_BLOCK);
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_MOB); metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_MOB);
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.PLAYER); metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.PLAYER);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_16.METADATA_LIST);
metadataRewriter.registerRemoveEntities(ClientboundPackets1_15.DESTROY_ENTITIES); metadataRewriter.registerRemoveEntities(ClientboundPackets1_15.DESTROY_ENTITIES);
protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketRemapper() { protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketRemapper() {

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.api.type.types.version.Types1_17; import com.viaversion.viaversion.api.type.types.version.Types1_17;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
@ -45,7 +45,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_17To1_16_4> {
registerTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_17Types.FALLING_BLOCK); registerTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_17Types.FALLING_BLOCK);
registerTracker(ClientboundPackets1_16_2.SPAWN_MOB); registerTracker(ClientboundPackets1_16_2.SPAWN_MOB);
registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_17Types.PLAYER); registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_17Types.PLAYER);
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_17.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_17.METADATA_LIST);
protocol.registerClientbound(ClientboundPackets1_16_2.DESTROY_ENTITIES, null, new PacketRemapper() { protocol.registerClientbound(ClientboundPackets1_16_2.DESTROY_ENTITIES, null, new PacketRemapper() {
@Override @Override