Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Almost works
Dieser Commit ist enthalten in:
Ursprung
14b11bdd10
Commit
2154f0a2cf
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
@ -34,6 +34,8 @@ import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||
import com.viaversion.viaversion.api.type.types.ByteArrayType;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
@ -175,7 +177,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
final int gamemode = wrapper.read(Type.VAR_INT);
|
||||
final int ping = wrapper.read(Type.VAR_INT);
|
||||
final JsonElement displayName = wrapper.passthrough(Type.BOOLEAN) ? wrapper.read(Type.COMPONENT) : null;
|
||||
final JsonElement displayName = wrapper.read(Type.BOOLEAN) ? wrapper.read(Type.COMPONENT) : null;
|
||||
final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY);
|
||||
|
||||
// Salvage signed chat
|
||||
@ -223,7 +225,6 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
component = GsonComponentSerializer.gson().serializeToTree(Component.text(plainText));
|
||||
}
|
||||
|
||||
|
||||
// Store message signature for last seen
|
||||
if (!signature.uuid().equals(ZERO_UUID) && signature.signatureBytes().length != 0) {
|
||||
final ReceivedMessagesStorage messagesStorage = wrapper.user().get(ReceivedMessagesStorage.class);
|
||||
@ -318,11 +319,22 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
entityRewriter.onMappingDataLoaded();
|
||||
Types1_19_3.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION)
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);
|
||||
Entity1_19_3Types.initialize(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final UserConnection user) {
|
||||
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19Types.PLAYER));
|
||||
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_3Types.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
|
||||
public class RecipeRewriter1_19_3 extends RecipeRewriter1_16 {
|
||||
|
||||
public RecipeRewriter1_19_3(final Protocol protocol) {
|
||||
super(protocol);
|
||||
recipeHandlers.put("crafting_special_armordye", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_bookcloning", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_mapcloning", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_mapextending", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_firework_rocket", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_firework_star", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_firework_star_fade", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_tippedarrow", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_bannerduplicate", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_shielddecoration", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_shulkerboxcoloring", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_suspiciousstew", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_repairitem", this::handleSimpleRecipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCraftingShapeless(final PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
final int ingredients = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredients; j++) {
|
||||
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (final Item item : items) {
|
||||
rewrite(item);
|
||||
}
|
||||
}
|
||||
rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCraftingShaped(final PacketWrapper wrapper) throws Exception {
|
||||
final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
for (int j = 0; j < ingredients; j++) {
|
||||
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (final Item item : items) {
|
||||
rewrite(item);
|
||||
}
|
||||
}
|
||||
rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSmelting(final PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (final Item item : items) {
|
||||
rewrite(item);
|
||||
}
|
||||
rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
|
||||
public void handleSimpleRecipe(final PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.VAR_INT); // Crafting book category
|
||||
}
|
||||
}
|
@ -17,11 +17,14 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
@ -29,7 +32,9 @@ import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public final class InventoryPackets extends ItemRewriter<Protocol1_19_3To1_19_1> {
|
||||
|
||||
public InventoryPackets(Protocol1_19_3To1_19_1 protocol) {
|
||||
private static final int MISC_CRAFTING_BOOK_CATEGORY = 0;
|
||||
|
||||
public InventoryPackets(final Protocol1_19_3To1_19_1 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@ -54,7 +59,85 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19_3To1_19_1>
|
||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_1.WINDOW_PROPERTY);
|
||||
registerSpawnParticle1_19(ClientboundPackets1_19_1.SPAWN_PARTICLE);
|
||||
|
||||
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_19_1.DECLARE_RECIPES);
|
||||
final RecipeRewriter1_16 recipeRewriter = new RecipeRewriter1_16(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
// Also enable vanilla features
|
||||
final PacketWrapper enableFeaturesPacket = wrapper.create(ClientboundPackets1_19_3.UPDATE_ENABLED_FEATURES);
|
||||
enableFeaturesPacket.write(Type.VAR_INT, 1);
|
||||
enableFeaturesPacket.write(Type.STRING, "minecraft:vanilla");
|
||||
enableFeaturesPacket.send(Protocol1_19_3To1_19_1.class);
|
||||
|
||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY);
|
||||
final int ingredients = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredients; j++) {
|
||||
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (final Item item : items) {
|
||||
handleItemToClient(item);
|
||||
}
|
||||
}
|
||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
final int ingredients = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY);
|
||||
for (int j = 0; j < ingredients; j++) {
|
||||
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (final Item item : items) {
|
||||
handleItemToClient(item);
|
||||
}
|
||||
}
|
||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
break;
|
||||
}
|
||||
case "smelting":
|
||||
case "campfire_cooking":
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY);
|
||||
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (final Item item : items) {
|
||||
handleItemToClient(item);
|
||||
}
|
||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
break;
|
||||
case "crafting_special_armordye":
|
||||
case "crafting_special_bookcloning":
|
||||
case "crafting_special_mapcloning":
|
||||
case "crafting_special_mapextending":
|
||||
case "crafting_special_firework_rocket":
|
||||
case "crafting_special_firework_star":
|
||||
case "crafting_special_firework_star_fade":
|
||||
case "crafting_special_tippedarrow":
|
||||
case "crafting_special_bannerduplicate":
|
||||
case "crafting_special_shielddecoration":
|
||||
case "crafting_special_shulkerboxcoloring":
|
||||
case "crafting_special_suspiciousstew":
|
||||
case "crafting_special_repairitem":
|
||||
wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY);
|
||||
break;
|
||||
default:
|
||||
recipeRewriter.handle(wrapper, type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_1.EXPLOSION, new PacketRemapper() {
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren