Minecraft 1.21.7

This commit is contained in:
LOOHP
2025-06-30 18:47:18 +01:00
parent 57473e5f57
commit 077595f0c2
19 changed files with 1998 additions and 1880 deletions
@@ -76,6 +76,7 @@ public class Channel implements AutoCloseable {
ensureOpen();
size = size < 0 ? DataTypeIO.readVarInt(input) : size;
int packetId = DataTypeIO.readVarInt(input);
System.out.println(packetId);
ChannelPacketRead read = new ChannelPacketRead(size, packetId, input);
for (Pair<Key, ChannelPacketHandler> pair : handlers) {
read = pair.getSecond().read(read);
@@ -29,14 +29,18 @@ public class PacketPlayInBlockPlace extends PacketIn {
private final EquipmentSlot hand;
private final int sequence;
private final float yRot;
private final float xRot;
public PacketPlayInBlockPlace(EquipmentSlot hand, int sequence) {
public PacketPlayInBlockPlace(EquipmentSlot hand, int sequence, float yRot, float xRot) {
this.hand = hand;
this.sequence = sequence;
}
this.yRot = yRot;
this.xRot = xRot;
}
public PacketPlayInBlockPlace(DataInputStream in) throws IOException {
this(EquipmentSlot.values()[DataTypeIO.readVarInt(in)], DataTypeIO.readVarInt(in));
public PacketPlayInBlockPlace(DataInputStream in, float yRot, float xRot) throws IOException {
this(EquipmentSlot.values()[DataTypeIO.readVarInt(in)], DataTypeIO.readVarInt(in), in.readFloat(), in.readFloat());
}
public EquipmentSlot getHand() {
@@ -46,4 +50,12 @@ public class PacketPlayInBlockPlace extends PacketIn {
public int getSequence() {
return sequence;
}
public float getYRot() {
return yRot;
}
public float getXRot() {
return xRot;
}
}
@@ -36,7 +36,7 @@ public class PacketPlayInSetCreativeSlot extends PacketIn {
}
public PacketPlayInSetCreativeSlot(DataInputStream in) throws IOException {
this(in.readShort(), DataTypeIO.readItemStack(in));
this(in.readShort(), DataTypeIO.readUntrustedItemStack(in));
}
public int getSlotNumber() {
@@ -20,14 +20,13 @@
package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.inventory.InventoryClickType;
import com.loohp.limbo.inventory.ItemStack;
import com.loohp.limbo.utils.DataTypeIO;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
public class PacketPlayInWindowClick extends PacketIn {
@@ -36,34 +35,32 @@ public class PacketPlayInWindowClick extends PacketIn {
private final int slotNum;
private final int buttonNum;
private final InventoryClickType clickType;
private final Map<Integer, ItemStack> changedSlots;
private final ItemStack carriedItem;
private final Set<Integer> changedSlots;
public PacketPlayInWindowClick(int containerId, int stateId, int slotNum, int buttonNum, InventoryClickType clickType, Map<Integer, ItemStack> changedSlots, ItemStack carriedItem) {
public PacketPlayInWindowClick(int containerId, int stateId, int slotNum, int buttonNum, InventoryClickType clickType, Set<Integer> changedSlots) {
this.containerId = containerId;
this.stateId = stateId;
this.slotNum = slotNum;
this.buttonNum = buttonNum;
this.clickType = clickType;
this.changedSlots = changedSlots;
this.carriedItem = carriedItem;
}
public PacketPlayInWindowClick(DataInputStream in) throws IOException {
this.containerId = in.readByte();
this.containerId = DataTypeIO.readVarInt(in);
this.stateId = DataTypeIO.readVarInt(in);
this.slotNum = in.readShort();
this.buttonNum = in.readByte();
this.clickType = InventoryClickType.values()[DataTypeIO.readVarInt(in)];
Map<Integer, ItemStack> changedSlots = new HashMap<>();
Set<Integer> changedSlots = new HashSet<>();
int size = DataTypeIO.readVarInt(in);
for (int i = 0; i < size; i++) {
int slot = in.readShort();
ItemStack itemStack = DataTypeIO.readItemStack(in);
changedSlots.put(slot, itemStack);
DataTypeIO.consumeHashedStack(in);
changedSlots.add(slot);
}
this.changedSlots = Collections.unmodifiableMap(changedSlots);
this.carriedItem = DataTypeIO.readItemStack(in);
this.changedSlots = Collections.unmodifiableSet(changedSlots);
DataTypeIO.consumeHashedStack(in);
}
public int getContainerId() {
@@ -86,11 +83,11 @@ public class PacketPlayInWindowClick extends PacketIn {
return clickType;
}
public Map<Integer, ItemStack> getChangedSlots() {
public Set<Integer> getChangedSlots() {
return changedSlots;
}
public ItemStack getCarriedItem() {
return carriedItem;
}
// public ItemStack getCarriedItem() {
// return carriedItem;
// }
}
@@ -64,7 +64,7 @@ public class PacketPlayOutSetSlot extends PacketOut {
DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(containerId);
DataTypeIO.writeVarInt(output, containerId);
DataTypeIO.writeVarInt(output, stateId);
output.writeShort(slot);
DataTypeIO.writeItemStack(output, itemStack);
@@ -65,7 +65,7 @@ public class PacketPlayOutWindowItems extends PacketOut {
DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(containerId);
DataTypeIO.writeVarInt(output, containerId);
DataTypeIO.writeVarInt(output, stateId);
DataTypeIO.writeVarInt(output, items.size());
for (ItemStack itemStack : items) {