Skip to content

Commit dc30ca9

Browse files
committed
Add missing functions from Packet additions
1 parent 4d7e409 commit dc30ca9

11 files changed

Lines changed: 497 additions & 495 deletions

data/mcswitch_functions.csv

Lines changed: 471 additions & 471 deletions
Large diffs are not rendered by default.

src/Minecraft.Network/protocol/game/ClientboundAddGlobalEntityPacket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ClientboundAddGlobalEntityPacket::ClientboundAddGlobalEntityPacket(std::shared_p
2222
x = Mth::floor(entity->mX * 32.0);
2323
y = Mth::floor(entity->mY * 32.0);
2424
z = Mth::floor(entity->mZ * 32.0);
25-
type = (entity->GetType() == 0xB000001);
25+
type = (entity->isType(eLightningBolt));
2626
}
2727

2828
int ClientboundAddGlobalEntityPacket::getEstimatedSize() {

src/Minecraft.Network/protocol/game/ClientboundContainerAckPacket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ ClientboundContainerAckPacket::ClientboundContainerAckPacket() {
1616

1717
ClientboundContainerAckPacket::ClientboundContainerAckPacket(int containerId, short uid, bool accepted) {
1818
mContainerId = containerId;
19-
mAccepted = accepted;
2019
mUid = uid;
20+
mAccepted = accepted;
2121
}
2222

2323
int ClientboundContainerAckPacket::getEstimatedSize() {

src/Minecraft.Network/protocol/game/ClientboundEntityEventPacket.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ std::shared_ptr<Packet> ClientboundEntityEventPacket::create() {
88
return std::shared_ptr<Packet>(new ClientboundEntityEventPacket());
99
}
1010

11-
ClientboundEntityEventPacket::ClientboundEntityEventPacket(std::shared_ptr<Entity> entity, unsigned char eventId, int data) {
12-
mEventId = eventId;
11+
ClientboundEntityEventPacket::ClientboundEntityEventPacket(std::shared_ptr<Entity> entity,
12+
unsigned char eventId, int data) {
1313
mEntityId = entity->getId();
14+
mEventId = eventId;
1415
mData = data;
1516
}
1617

src/Minecraft.Network/protocol/game/ClientboundRotateHeadPacket.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ std::shared_ptr<Packet> ClientboundRotateHeadPacket::create() {
1111

1212
ClientboundRotateHeadPacket::ClientboundRotateHeadPacket() {}
1313

14-
ClientboundRotateHeadPacket::ClientboundRotateHeadPacket(std::shared_ptr<Entity> entity, unsigned char yHeadRot) {
15-
mYHeadRot = yHeadRot;
14+
ClientboundRotateHeadPacket::ClientboundRotateHeadPacket(std::shared_ptr<Entity> entity,
15+
unsigned char yHeadRot) {
1616
entityId = entity->getId();
17+
mYHeadRot = yHeadRot;
1718
}
1819

1920
int ClientboundRotateHeadPacket::getEstimatedSize() {

src/Minecraft.Network/protocol/game/DebugOptionsPacket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ DebugOptionsPacket::DebugOptionsPacket() {
1212
dword18 = 0;
1313
}
1414

15-
DebugOptionsPacket::DebugOptionsPacket(unsigned int unk1) {
16-
dword18 = unk1;
17-
}
15+
// DebugOptionsPacket::DebugOptionsPacket(unsigned int unk1) {
16+
// dword18 = unk1;
17+
// }
1818

1919
int DebugOptionsPacket::getEstimatedSize() {
2020
return 4;

src/Minecraft.Network/protocol/game/DebugOptionsPacket.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
#include "Minecraft.Network/protocol/Packet.h"
44

5-
class DebugOptionsPacket : public Packet,
6-
public std::enable_shared_from_this<DebugOptionsPacket> {
5+
class DebugOptionsPacket : public Packet, public std::enable_shared_from_this<DebugOptionsPacket> {
76
public:
87
static std::shared_ptr<Packet> create();
98

109
DebugOptionsPacket();
11-
DebugOptionsPacket(unsigned int unk1);
10+
// DebugOptionsPacket(unsigned int unk1); // unused in switch edition
1211
int getEstimatedSize() override;
1312
EPacketType getPacketId() override;
1413
void read(DataInputStream* input) override;

src/Minecraft.Network/protocol/game/ServerboundContainerAckPacket.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ ServerboundContainerAckPacket::ServerboundContainerAckPacket() {}
1212

1313
ServerboundContainerAckPacket::ServerboundContainerAckPacket(int containerId, short uid, bool accepted) {
1414
mContainerId = containerId;
15-
mAccepted = accepted;
1615
mUid = uid;
17-
}
18-
19-
int ServerboundContainerAckPacket::getEstimatedSize() {
20-
return 4;
16+
mAccepted = accepted;
2117
}
2218

2319
EPacketType ServerboundContainerAckPacket::getPacketId() {

src/Minecraft.Network/protocol/game/ServerboundContainerAckPacket.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
#include "Minecraft.Network/protocol/Packet.h"
55

66
class ServerboundContainerAckPacket : public Packet,
7-
public std::enable_shared_from_this<ServerboundContainerAckPacket> {
7+
public std::enable_shared_from_this<ServerboundContainerAckPacket> {
88
public:
99
static std::shared_ptr<Packet> create();
1010

1111
ServerboundContainerAckPacket();
1212
ServerboundContainerAckPacket(int containerId, short uid, bool accepted);
13-
int getEstimatedSize() override;
1413
EPacketType getPacketId() override;
1514
void read(DataInputStream* input) override;
1615
void write(DataOutputStream* output) override;

src/Minecraft.Network/protocol/game/ServerboundInteractPacket.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,25 @@ ServerboundInteractPacket::ServerboundInteractPacket() {
1717

1818
ServerboundInteractPacket::ServerboundInteractPacket(std::shared_ptr<Entity> target) {
1919
mTarget = target->getId();
20-
mAction = eAction::Interact;
20+
mAction = eAction::Attack;
21+
mHand = InteractionHand::MAIN_HAND;
22+
mLocation = 0;
2123
}
2224

23-
ServerboundInteractPacket::ServerboundInteractPacket(std::shared_ptr<Entity> target, InteractionHand::EInteractionHand hand) {
25+
ServerboundInteractPacket::ServerboundInteractPacket(std::shared_ptr<Entity> target,
26+
InteractionHand::EInteractionHand hand) {
2427
mTarget = target->getId();
2528
mAction = eAction::Interact;
2629
mHand = hand;
30+
mLocation = 0;
2731
}
2832

29-
ServerboundInteractPacket::ServerboundInteractPacket(std::shared_ptr<Entity> target, InteractionHand::EInteractionHand hand, Vec3* location) {
33+
ServerboundInteractPacket::ServerboundInteractPacket(std::shared_ptr<Entity> target,
34+
InteractionHand::EInteractionHand hand, Vec3* location) {
3035
mTarget = target->getId();
3136
mAction = eAction::InteractAt;
3237
mHand = hand;
33-
mLocation = location;
38+
mLocation = Vec3::newPermanent(location->x, location->y, location->z);
3439
}
3540

3641
int ServerboundInteractPacket::getEstimatedSize() {
@@ -85,5 +90,5 @@ InteractionHand::EInteractionHand ServerboundInteractPacket::getHand() {
8590
}
8691

8792
Vec3* ServerboundInteractPacket::getLocation() {
88-
return mLocation;
93+
return Vec3::newTemp(mLocation);
8994
}

0 commit comments

Comments
 (0)