mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2025-01-07 19:39:00 +01:00
24w45a (mostly)
This commit is contained in:
parent
2456b05ea6
commit
402aff9656
@ -32,8 +32,10 @@ import com.viaversion.viaversion.api.minecraft.HolderSet;
|
|||||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.CustomModelData1_21_4;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -88,8 +90,19 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
|||||||
item.setIdentifier(mappedItem.id());
|
item.setIdentifier(mappedItem.id());
|
||||||
|
|
||||||
// Add custom model data
|
// Add custom model data
|
||||||
if (mappedItem.customModelData() != null && !dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA)) {
|
if (mappedItem.customModelData() != null) {
|
||||||
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA, mappedItem.customModelData());
|
if (connection.getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_4)) {
|
||||||
|
if (!dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4)) {
|
||||||
|
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, new CustomModelData1_21_4(
|
||||||
|
new float[]{mappedItem.customModelData().floatValue()},
|
||||||
|
new boolean[0],
|
||||||
|
new String[0],
|
||||||
|
new int[0]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else if (!dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5)) {
|
||||||
|
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5, mappedItem.customModelData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set custom name - only done if there is no original one
|
// Set custom name - only done if there is no original one
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
|||||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.BlockItemPacketRewriter1_21_4;
|
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.BlockItemPacketRewriter1_21_4;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.ComponentRewriter1_21_4;
|
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.ComponentRewriter1_21_4;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.EntityPacketRewriter1_99;
|
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.EntityPacketRewriter1_21_4;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.ParticleRewriter1_21_4;
|
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.ParticleRewriter1_21_4;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
@ -54,7 +54,7 @@ import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
|||||||
public final class Protocol1_21_4To1_21_2 extends BackwardsProtocol<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_4, ServerboundPacket1_21_2> {
|
public final class Protocol1_21_4To1_21_2 extends BackwardsProtocol<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_4, ServerboundPacket1_21_2> {
|
||||||
|
|
||||||
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.21.4", "1.21.2", Protocol1_21_2To1_21_4.class);
|
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.21.4", "1.21.2", Protocol1_21_2To1_21_4.class);
|
||||||
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
|
private final EntityPacketRewriter1_21_4 entityRewriter = new EntityPacketRewriter1_21_4(this);
|
||||||
private final BlockItemPacketRewriter1_21_4 itemRewriter = new BlockItemPacketRewriter1_21_4(this);
|
private final BlockItemPacketRewriter1_21_4 itemRewriter = new BlockItemPacketRewriter1_21_4(this);
|
||||||
private final ParticleRewriter<ClientboundPacket1_21_2> particleRewriter = new ParticleRewriter1_21_4(this);
|
private final ParticleRewriter<ClientboundPacket1_21_2> particleRewriter = new ParticleRewriter1_21_4(this);
|
||||||
private final TranslatableRewriter<ClientboundPacket1_21_2> translatableRewriter = new ComponentRewriter1_21_4(this);
|
private final TranslatableRewriter<ClientboundPacket1_21_2> translatableRewriter = new ComponentRewriter1_21_4(this);
|
||||||
@ -148,7 +148,6 @@ public final class Protocol1_21_4To1_21_2 extends BackwardsProtocol<ClientboundP
|
|||||||
translatableRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.OPTIONAL_TAG));
|
translatableRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.OPTIONAL_TAG));
|
||||||
}
|
}
|
||||||
if (actions.get(6)) {
|
if (actions.get(6)) {
|
||||||
actions.clear(6);
|
|
||||||
wrapper.passthrough(Types.VAR_INT); // List order
|
wrapper.passthrough(Types.VAR_INT); // List order
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ public final class Protocol1_21_4To1_21_2 extends BackwardsProtocol<ClientboundP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketRewriter1_99 getEntityRewriter() {
|
public EntityPacketRewriter1_21_4 getEntityRewriter() {
|
||||||
return entityRewriter;
|
return entityRewriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter;
|
package com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter;
|
||||||
|
|
||||||
|
import com.viaversion.nbt.tag.ByteArrayTag;
|
||||||
|
import com.viaversion.nbt.tag.CompoundTag;
|
||||||
|
import com.viaversion.nbt.tag.IntArrayTag;
|
||||||
|
import com.viaversion.nbt.tag.ListTag;
|
||||||
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.Protocol1_21_4To1_21_2;
|
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.Protocol1_21_4To1_21_2;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.CustomModelData1_21_4;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||||
@ -30,6 +40,9 @@ import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPacke
|
|||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
|
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
|
||||||
|
|
||||||
|
import static com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.BlockItemPacketRewriter1_21_4.downgradeItemData;
|
||||||
|
import static com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.BlockItemPacketRewriter1_21_4.updateItemData;
|
||||||
|
|
||||||
public final class BlockItemPacketRewriter1_21_4 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21_2, ServerboundPacket1_21_2, Protocol1_21_4To1_21_2> {
|
public final class BlockItemPacketRewriter1_21_4 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21_2, ServerboundPacket1_21_2, Protocol1_21_4To1_21_2> {
|
||||||
|
|
||||||
public BlockItemPacketRewriter1_21_4(final Protocol1_21_4To1_21_2 protocol) {
|
public BlockItemPacketRewriter1_21_4(final Protocol1_21_4To1_21_2 protocol) {
|
||||||
@ -72,4 +85,83 @@ public final class BlockItemPacketRewriter1_21_4 extends BackwardsStructuredItem
|
|||||||
recipeRewriter.registerRecipeBookAdd(ClientboundPackets1_21_2.RECIPE_BOOK_ADD);
|
recipeRewriter.registerRecipeBookAdd(ClientboundPackets1_21_2.RECIPE_BOOK_ADD);
|
||||||
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_2.PLACE_GHOST_RECIPE);
|
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_2.PLACE_GHOST_RECIPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item handleItemToClient(final UserConnection connection, final Item item) {
|
||||||
|
super.handleItemToClient(connection, item);
|
||||||
|
|
||||||
|
final StructuredDataContainer dataContainer = item.dataContainer();
|
||||||
|
final CustomModelData1_21_4 modelData = dataContainer.get(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4);
|
||||||
|
if (modelData != null) {
|
||||||
|
saveTag(createCustomTag(item), customModelDataToTag(modelData), "custom_model_data");
|
||||||
|
}
|
||||||
|
|
||||||
|
updateItemData(item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item handleItemToServer(final UserConnection connection, final Item item) {
|
||||||
|
super.handleItemToServer(connection, item);
|
||||||
|
|
||||||
|
final StructuredDataContainer dataContainer = item.dataContainer();
|
||||||
|
final CompoundTag customData = dataContainer.get(StructuredDataKey.CUSTOM_DATA);
|
||||||
|
if (customData != null) {
|
||||||
|
if (customData.remove(nbtTagName("custom_model_data")) instanceof final CompoundTag customModelData) {
|
||||||
|
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, customModelDataFromTag(customModelData));
|
||||||
|
removeCustomTag(dataContainer, customData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
downgradeItemData(item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CustomModelData1_21_4 customModelDataFromTag(final CompoundTag tag) {
|
||||||
|
final IntArrayTag floatsTag = tag.getIntArrayTag("floats");
|
||||||
|
final float[] floats = new float[floatsTag.getValue().length];
|
||||||
|
for (int i = 0; i < floats.length; i++) {
|
||||||
|
floats[i] = Float.intBitsToFloat(floatsTag.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
final ByteArrayTag booleansTag = tag.getByteArrayTag("booleans");
|
||||||
|
final boolean[] booleans = new boolean[booleansTag.getValue().length];
|
||||||
|
for (int i = 0; i < booleans.length; i++) {
|
||||||
|
booleans[i] = booleansTag.get(i) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ListTag<StringTag> stringsTag = tag.getListTag("strings", StringTag.class);
|
||||||
|
final String[] strings = new String[stringsTag.size()];
|
||||||
|
for (int i = 0; i < strings.length; i++) {
|
||||||
|
strings[i] = stringsTag.get(i).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
final IntArrayTag colorsTag = tag.getIntArrayTag("colors");
|
||||||
|
return new CustomModelData1_21_4(floats, booleans, strings, colorsTag.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompoundTag customModelDataToTag(final CustomModelData1_21_4 customModelData) {
|
||||||
|
final CompoundTag tag = new CompoundTag();
|
||||||
|
final int[] floats = new int[customModelData.floats().length];
|
||||||
|
for (int i = 0; i < floats.length; i++) {
|
||||||
|
floats[i] = Float.floatToIntBits(customModelData.floats()[i]);
|
||||||
|
}
|
||||||
|
tag.put("floats", new IntArrayTag(floats));
|
||||||
|
|
||||||
|
final byte[] booleans = new byte[customModelData.booleans().length];
|
||||||
|
for (int i = 0; i < booleans.length; i++) {
|
||||||
|
booleans[i] = (byte) (customModelData.booleans()[i] ? 1 : 0);
|
||||||
|
}
|
||||||
|
tag.put("booleans", new ByteArrayTag(booleans));
|
||||||
|
|
||||||
|
final ListTag<StringTag> strings = new ListTag<>(StringTag.class);
|
||||||
|
for (final String string : customModelData.strings()) {
|
||||||
|
strings.add(new StringTag(string));
|
||||||
|
}
|
||||||
|
tag.put("strings", strings);
|
||||||
|
|
||||||
|
tag.put("colors", new IntArrayTag(customModelData.colors()));
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||||
import com.viaversion.viaversion.util.SerializerVersion;
|
import com.viaversion.viaversion.util.SerializerVersion;
|
||||||
|
import com.viaversion.viaversion.util.TagUtil;
|
||||||
|
|
||||||
public final class ComponentRewriter1_21_4 extends TranslatableRewriter<ClientboundPacket1_21_2> {
|
public final class ComponentRewriter1_21_4 extends TranslatableRewriter<ClientboundPacket1_21_2> {
|
||||||
|
|
||||||
@ -37,8 +38,7 @@ public final class ComponentRewriter1_21_4 extends TranslatableRewriter<Clientbo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove or update data from componentsTag
|
TagUtil.removeNamespaced(componentsTag, "custom_model_data");
|
||||||
// New added data which is not handled otherwise needs to be removed to prevent errors on the client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,18 +25,21 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_2;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_2;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
|
||||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPackets1_21_2;
|
||||||
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPacket1_21_2, Protocol1_21_4To1_21_2> {
|
public final class EntityPacketRewriter1_21_4 extends EntityRewriter<ClientboundPacket1_21_2, Protocol1_21_4To1_21_2> {
|
||||||
|
|
||||||
public EntityPacketRewriter1_99(final Protocol1_21_4To1_21_2 protocol) {
|
public EntityPacketRewriter1_21_4(final Protocol1_21_4To1_21_2 protocol) {
|
||||||
super(protocol, Types1_21_4.ENTITY_DATA_TYPES.optionalComponentType, Types1_21_4.ENTITY_DATA_TYPES.booleanType);
|
super(protocol, Types1_21_4.ENTITY_DATA_TYPES.optionalComponentType, Types1_21_4.ENTITY_DATA_TYPES.booleanType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +52,8 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol) {
|
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol) {
|
||||||
@Override
|
@Override
|
||||||
public RegistryEntry[] handle(final UserConnection connection, final String key, final RegistryEntry[] entries) {
|
public RegistryEntry[] handle(final UserConnection connection, final String key, final RegistryEntry[] entries) {
|
||||||
if (Key.stripMinecraftNamespace(key).equals("worldgen/biome")) {
|
final String strippedKey = Key.stripMinecraftNamespace(key);
|
||||||
|
if (strippedKey.equals("worldgen/biome")) {
|
||||||
for (final RegistryEntry entry : entries) {
|
for (final RegistryEntry entry : entries) {
|
||||||
if (entry.tag() == null) {
|
if (entry.tag() == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -70,6 +74,15 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
final CompoundTag musicTag = weightedMusicTags.get(0);
|
final CompoundTag musicTag = weightedMusicTags.get(0);
|
||||||
effectsTag.put("music", musicTag.get("data"));
|
effectsTag.put("music", musicTag.get("data"));
|
||||||
}
|
}
|
||||||
|
} else if (strippedKey.equals("trim_material")) {
|
||||||
|
for (final RegistryEntry entry : entries) {
|
||||||
|
if (entry.tag() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CompoundTag compoundTag = ((CompoundTag) entry.tag());
|
||||||
|
compoundTag.putFloat("item_model_index", itemModelIndex(entry.key()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.handle(connection, key, entries);
|
return super.handle(connection, key, entries);
|
||||||
@ -92,13 +105,44 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
final String world = wrapper.passthrough(Types.STRING);
|
final String world = wrapper.passthrough(Types.STRING);
|
||||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
||||||
trackPlayer(wrapper.user(), entityId);
|
trackPlayer(wrapper.user(), entityId);
|
||||||
|
|
||||||
|
final PacketWrapper playerLoadedPacket = wrapper.create(ServerboundPackets1_21_4.PLAYER_LOADED);
|
||||||
|
playerLoadedPacket.scheduleSendToServer(Protocol1_21_4To1_21_2.class);
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_21_2.RESPAWN, wrapper -> {
|
protocol.registerClientbound(ClientboundPackets1_21_2.RESPAWN, wrapper -> {
|
||||||
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||||
final String world = wrapper.passthrough(Types.STRING);
|
final String world = wrapper.passthrough(Types.STRING);
|
||||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
||||||
|
|
||||||
|
final PacketWrapper playerLoadedPacket = wrapper.create(ServerboundPackets1_21_4.PLAYER_LOADED);
|
||||||
|
playerLoadedPacket.scheduleSendToServer(Protocol1_21_4To1_21_2.class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
protocol.registerServerbound(ServerboundPackets1_21_2.MOVE_VEHICLE, wrapper -> {
|
||||||
|
wrapper.passthrough(Types.DOUBLE); // X
|
||||||
|
wrapper.passthrough(Types.DOUBLE); // Y
|
||||||
|
wrapper.passthrough(Types.DOUBLE); // Z
|
||||||
|
wrapper.passthrough(Types.FLOAT); // Yaw
|
||||||
|
wrapper.passthrough(Types.FLOAT); // Pitch
|
||||||
|
wrapper.write(Types.BOOLEAN, true); // On ground // TODO ...
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private float itemModelIndex(final String trim) {
|
||||||
|
return switch (Key.stripNamespace(trim)) {
|
||||||
|
case "amethyst" -> 1.0F;
|
||||||
|
case "copper" -> 0.5F;
|
||||||
|
case "diamond" -> 0.8F;
|
||||||
|
case "emerald" -> 0.7F;
|
||||||
|
case "gold" -> 0.6F;
|
||||||
|
case "iron" -> 0.2F;
|
||||||
|
case "lapis" -> 0.9F;
|
||||||
|
case "netherite" -> 0.3F;
|
||||||
|
case "quartz" -> 0.1F;
|
||||||
|
case "redstone" -> 0.4F;
|
||||||
|
default -> 1.0f;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
Loading…
Reference in New Issue
Block a user