3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 01:00:15 +01:00

New meta types (oh no)

Dieser Commit ist enthalten in:
Nassim Jahnke 2022-04-06 20:16:00 +02:00
Ursprung 4693b95bea
Commit dd189411e6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
6 geänderte Dateien mit 195 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,83 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 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;
public final class GlobalPosition {
private final String dimension;
private final int x;
private final int y;
private final int z;
public GlobalPosition(final String dimension, final int x, final int y, final int z) {
this.dimension = dimension;
this.x = x;
this.y = y;
this.z = z;
}
public int x() {
return x;
}
public int y() {
return y;
}
public int z() {
return z;
}
public String dimension() {
return dimension;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final GlobalPosition position = (GlobalPosition) o;
if (x != position.x) return false;
if (y != position.y) return false;
if (z != position.z) return false;
return dimension.equals(position.dimension);
}
@Override
public int hashCode() {
int result = dimension.hashCode();
result = 31 * result + x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
@Override
public String toString() {
return "GlobalPosition{" +
"dimension='" + dimension + '\'' +
", x=" + x +
", y=" + y +
", z=" + z +
'}';
}
}

Datei anzeigen

@ -0,0 +1,58 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 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_19 extends AbstractMetaTypes {
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 final MetaType catVariantType = add(19, Type.VAR_INT);
public final MetaType frogVariantType = add(20, Type.VAR_INT);
public final MetaType optionalGlobalPosition = add(21, Type.OPTIONAL_GLOBAL_POSITION);
public MetaTypes1_19(final ParticleType particleType) {
super(22);
this.particleType = add(15, particleType);
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.gson.JsonElement;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.EulerAngle;
import com.viaversion.viaversion.api.minecraft.GlobalPosition;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.Vector;
import com.viaversion.viaversion.api.minecraft.VillagerData;
@ -66,6 +67,7 @@ import com.viaversion.viaversion.api.type.types.minecraft.OptPosition1_14Type;
import com.viaversion.viaversion.api.type.types.minecraft.OptPositionType;
import com.viaversion.viaversion.api.type.types.minecraft.OptUUIDType;
import com.viaversion.viaversion.api.type.types.minecraft.OptionalComponentType;
import com.viaversion.viaversion.api.type.types.minecraft.OptionalGlobalPositionType;
import com.viaversion.viaversion.api.type.types.minecraft.OptionalVarIntType;
import com.viaversion.viaversion.api.type.types.minecraft.Position1_14Type;
import com.viaversion.viaversion.api.type.types.minecraft.PositionType;
@ -154,6 +156,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
public static final Type<Position> OPTIONAL_POSITION = new OptPositionType();
public static final Type<Position> OPTIONAL_POSITION_1_14 = new OptPosition1_14Type();
public static final Type<GlobalPosition> OPTIONAL_GLOBAL_POSITION = new OptionalGlobalPositionType();
public static final Type<BlockChangeRecord> BLOCK_CHANGE_RECORD = new BlockChangeRecordType();
public static final Type<BlockChangeRecord[]> BLOCK_CHANGE_RECORD_ARRAY = new ArrayType<>(Type.BLOCK_CHANGE_RECORD);

Datei anzeigen

@ -0,0 +1,48 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 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.minecraft.GlobalPosition;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.ByteBuf;
public class OptionalGlobalPositionType extends Type<GlobalPosition> {
public OptionalGlobalPositionType() {
super(GlobalPosition.class);
}
@Override
public GlobalPosition read(ByteBuf buffer) throws Exception {
boolean present = buffer.readBoolean();
return present ? Type.OPTIONAL_GLOBAL_POSITION.read(buffer) : null;
}
@Override
public void write(ByteBuf buffer, GlobalPosition object) throws Exception {
buffer.writeBoolean(object != null);
if (object != null) {
Type.OPTIONAL_GLOBAL_POSITION.write(buffer, object);
}
}
}

Datei anzeigen

@ -23,7 +23,7 @@
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.minecraft.metadata.types.MetaTypes1_19;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.minecraft.MetaListType;
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
@ -33,7 +33,7 @@ import java.util.List;
public final class Types1_19 {
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 MetaTypes1_19 META_TYPES = new MetaTypes1_19(PARTICLE);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
}

Datei anzeigen

@ -141,6 +141,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
});
filter().type(Entity1_19Types.PLAYER).addIndex(19); // Last death location
filter().type(Entity1_19Types.CAT).index(19).handler((event, meta) -> meta.setMetaType(Types1_19.META_TYPES.catVariantType));
}
@Override