Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Fix bed rewriting and fix inconsistencies in item rewrite (#2729)
Dieser Commit ist enthalten in:
Ursprung
718614f81f
Commit
6bc7f911c3
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 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_12to1_11_1;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
|
||||
public class BedRewriter {
|
||||
|
||||
public static void toClientItem(Item item) {
|
||||
if (item == null) return;
|
||||
if (item.identifier() == 355 && item.data() == 0) {
|
||||
item.setData((short) 14);
|
||||
}
|
||||
}
|
||||
|
||||
public static void toServerItem(Item item) {
|
||||
if (item == null) return;
|
||||
if (item.identifier() == 355 && item.data() == 14) {
|
||||
item.setData((short) 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,10 +20,8 @@ package com.viaversion.viaversion.protocols.protocol1_12to1_11_1.metadata;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
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.protocols.protocol1_12to1_11_1.BedRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
@ -37,9 +35,9 @@ public class MetadataRewriter1_12To1_11_1 extends EntityRewriter<Protocol1_12To1
|
||||
|
||||
@Override
|
||||
protected void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) {
|
||||
if (metadata.getValue() instanceof DataItem) {
|
||||
if (metadata.getValue() instanceof Item) {
|
||||
// Apply rewrite
|
||||
BedRewriter.toClientItem((Item) metadata.getValue());
|
||||
metadata.setValue(protocol.getItemRewriter().handleItemToClient((Item) metadata.getValue()));
|
||||
}
|
||||
|
||||
if (type == null) return;
|
||||
|
@ -23,12 +23,12 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.BedRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
|
||||
@ -56,12 +56,12 @@ public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Input Item
|
||||
BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Output Item
|
||||
handleItemToClient(wrapper.passthrough(Type.ITEM)); // Input Item
|
||||
handleItemToClient(wrapper.passthrough(Type.ITEM)); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Second Item
|
||||
handleItemToClient(wrapper.passthrough(Type.ITEM)); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
@ -90,7 +90,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
if (!Via.getConfig().is1_12QuickMoveActionFix()) {
|
||||
BedRewriter.toServerItem(item);
|
||||
handleItemToServer(item);
|
||||
return;
|
||||
}
|
||||
byte button = wrapper.get(Type.BYTE, 0);
|
||||
@ -107,7 +107,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
}
|
||||
// otherwise just pass through so the server sends the PacketPlayOutTransaction packet.
|
||||
} else {
|
||||
BedRewriter.toServerItem(item);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -122,7 +122,10 @@ public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
@Override
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
BedRewriter.toServerItem(item);
|
||||
|
||||
if (item.identifier() == 355) { // Bed rewrite
|
||||
item.setData((short) 0);
|
||||
}
|
||||
|
||||
boolean newItem = item.identifier() >= 235 && item.identifier() <= 252;
|
||||
newItem |= item.identifier() == 453;
|
||||
@ -132,4 +135,13 @@ public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
if (item.identifier() == 355) { // Bed rewrite
|
||||
item.setData((short) 14);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren