mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 12:56:28 +00:00
fix(network): 修复 ServerboundContainerClickPacket 包处理
- 感谢 TheFloodDragon 的协助
This commit is contained in:
@@ -7,6 +7,7 @@ import com.mojang.datafixers.util.Either;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@@ -2248,23 +2249,12 @@ public class PacketConsumers {
|
|||||||
Object clickType = FastNMS.INSTANCE.field$ServerboundContainerClickPacket$clickType(packet);
|
Object clickType = FastNMS.INSTANCE.field$ServerboundContainerClickPacket$clickType(packet);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Int2ObjectMap<Object> changedSlots = FastNMS.INSTANCE.field$ServerboundContainerClickPacket$changedSlots(packet);
|
Int2ObjectMap<Object> changedSlots = FastNMS.INSTANCE.field$ServerboundContainerClickPacket$changedSlots(packet);
|
||||||
Int2ObjectMap<Object> newChangedSlots = new Int2ObjectOpenHashMap<>();
|
Int2ObjectMap<Object> newChangedSlots = new Int2ObjectOpenHashMap<>(changedSlots.size());
|
||||||
for (Int2ObjectMap.Entry<Object> entry : changedSlots.int2ObjectEntrySet()) {
|
for (Int2ObjectMap.Entry<Object> entry : changedSlots.int2ObjectEntrySet()) {
|
||||||
Object hashedStack = entry.getValue();
|
newChangedSlots.put(entry.getIntKey(), FastNMS.INSTANCE.constructor$InjectedHashedStack(entry.getValue(), player));
|
||||||
if (!NetworkReflections.clazz$HashedStack$ActualItem.isInstance(hashedStack)) continue;
|
|
||||||
Object item = FastNMS.INSTANCE.method$ActualItem$item(hashedStack);
|
|
||||||
int count = FastNMS.INSTANCE.method$ActualItem$count(hashedStack);
|
|
||||||
Object components = FastNMS.INSTANCE.method$ActualItem$components(hashedStack);
|
|
||||||
newChangedSlots.put(entry.getIntKey(), FastNMS.INSTANCE.constructor$InjectedHashedStack(item, count, components, player));
|
|
||||||
}
|
}
|
||||||
Object carriedItem = FastNMS.INSTANCE.field$ServerboundContainerClickPacket$carriedItem(packet);
|
Object carriedItem = FastNMS.INSTANCE.constructor$InjectedHashedStack(FastNMS.INSTANCE.field$ServerboundContainerClickPacket$carriedItem(packet), player);
|
||||||
if (NetworkReflections.clazz$HashedStack$ActualItem.isInstance(carriedItem)) {
|
event.replacePacket(FastNMS.INSTANCE.constructor$ServerboundContainerClickPacket(containerId, stateId, slotNum, buttonNum, clickType, Int2ObjectMaps.unmodifiable(newChangedSlots), carriedItem));
|
||||||
Object item = FastNMS.INSTANCE.method$ActualItem$item(carriedItem);
|
|
||||||
int count = FastNMS.INSTANCE.method$ActualItem$count(carriedItem);
|
|
||||||
Object components = FastNMS.INSTANCE.method$ActualItem$components(carriedItem);
|
|
||||||
carriedItem = FastNMS.INSTANCE.constructor$InjectedHashedStack(item, count, components, player);
|
|
||||||
}
|
|
||||||
event.replacePacket(FastNMS.INSTANCE.constructor$ServerboundContainerClickPacket(containerId, stateId, slotNum, buttonNum, clickType, newChangedSlots, carriedItem));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CraftEngine.instance().logger().warn("Failed to handle ServerboundContainerClickPacket", e);
|
CraftEngine.instance().logger().warn("Failed to handle ServerboundContainerClickPacket", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ byte_buddy_version=1.17.5
|
|||||||
ahocorasick_version=0.6.3
|
ahocorasick_version=0.6.3
|
||||||
snake_yaml_version=2.4
|
snake_yaml_version=2.4
|
||||||
anti_grief_version=0.18
|
anti_grief_version=0.18
|
||||||
nms_helper_version=1.0.53
|
nms_helper_version=1.0.54
|
||||||
evalex_version=3.5.0
|
evalex_version=3.5.0
|
||||||
reactive_streams_version=1.0.4
|
reactive_streams_version=1.0.4
|
||||||
amazon_awssdk_version=2.31.23
|
amazon_awssdk_version=2.31.23
|
||||||
|
|||||||
Reference in New Issue
Block a user