Skip to content

Commit 0b6249a

Browse files
committed
work on all-args constructors, fix no-arg constructors
1 parent 1375dec commit 0b6249a

121 files changed

Lines changed: 622 additions & 565 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PacketWrappers.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Cover these scenarios for each wrapper:
265265
* testNoArgsCreate
266266
* Construct a fresh wrapper using the no-args constructor
267267
* Get the NMS handle packet via `getHandle()`
268-
* Assert that all fields in the NMS handle are default/empty values (e.g. 0, null, empty list)
268+
* Assert that all fields in the NMS handle are not null
269269
* testModifyExistingPacket
270270
* Create the NMS handle packet directly from its constructor, passing known test values
271271
* Create a packet container from the NMS handle via `PacketContainer.fromPacket()`
@@ -278,6 +278,12 @@ Cover these scenarios for each wrapper:
278278
* Attempt to construct the wrapper using this incorrect packet container
279279
* Assert that an appropriate exception is thrown (e.g. IllegalArgumentException)
280280
281+
### Appropriate test values
282+
283+
* For numeric fields, use a mix of positive, negative, and zero values (e.g. -5, 0, 3)
284+
* For enum fields, prefer the 2nd or 3rd constant rather than the first, to ensure the wrapper correctly handles non-default enum values
285+
* Additionally, if the enum constant is @Deprecated, do not use it
286+
281287
Here's a good example of a complete test class for `WrappedClientboundSetExperiencePacket`:
282288

283289
```java

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundAddEntityPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public class WrappedClientboundAddEntityPacket extends AbstractPacket {
3131

3232
public WrappedClientboundAddEntityPacket() {
3333
super(new PacketContainer(TYPE), TYPE);
34-
handle.getModifier().writeDefaults();
35-
}
34+
}
3635

3736
public WrappedClientboundAddEntityPacket(PacketContainer packet) {
3837
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundAnimatePacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public class WrappedClientboundAnimatePacket extends AbstractPacket {
2828

2929
public WrappedClientboundAnimatePacket() {
3030
super(new PacketContainer(TYPE), TYPE);
31-
handle.getModifier().writeDefaults();
32-
}
31+
}
3332

3433
public WrappedClientboundAnimatePacket(PacketContainer packet) {
3534
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundBlockChangedAckPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public class WrappedClientboundBlockChangedAckPacket extends AbstractPacket {
1818

1919
public WrappedClientboundBlockChangedAckPacket() {
2020
super(new PacketContainer(TYPE), TYPE);
21-
handle.getModifier().writeDefaults();
22-
}
21+
}
2322

2423
public WrappedClientboundBlockChangedAckPacket(PacketContainer packet) {
2524
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundBlockDestructionPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public class WrappedClientboundBlockDestructionPacket extends AbstractPacket {
2323

2424
public WrappedClientboundBlockDestructionPacket() {
2525
super(new PacketContainer(TYPE), TYPE);
26-
handle.getModifier().writeDefaults();
27-
}
26+
}
2827

2928
public WrappedClientboundBlockDestructionPacket(PacketContainer packet) {
3029
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundBlockEventPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public class WrappedClientboundBlockEventPacket extends AbstractPacket {
2323

2424
public WrappedClientboundBlockEventPacket() {
2525
super(new PacketContainer(TYPE), TYPE);
26-
handle.getModifier().writeDefaults();
27-
}
26+
}
2827

2928
public WrappedClientboundBlockEventPacket(PacketContainer packet) {
3029
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundBlockUpdatePacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public class WrappedClientboundBlockUpdatePacket extends AbstractPacket {
2121

2222
public WrappedClientboundBlockUpdatePacket() {
2323
super(new PacketContainer(TYPE), TYPE);
24-
handle.getModifier().writeDefaults();
25-
}
24+
}
2625

2726
public WrappedClientboundBlockUpdatePacket(PacketContainer packet) {
2827
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundChangeDifficultyPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class WrappedClientboundChangeDifficultyPacket extends AbstractPacket {
2020

2121
public WrappedClientboundChangeDifficultyPacket() {
2222
super(new PacketContainer(TYPE), TYPE);
23-
handle.getModifier().writeDefaults();
24-
}
23+
}
2524

2625
public WrappedClientboundChangeDifficultyPacket(PacketContainer packet) {
2726
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundChunkBatchFinishedPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public class WrappedClientboundChunkBatchFinishedPacket extends AbstractPacket {
1818

1919
public WrappedClientboundChunkBatchFinishedPacket() {
2020
super(new PacketContainer(TYPE), TYPE);
21-
handle.getModifier().writeDefaults();
22-
}
21+
}
2322

2423
public WrappedClientboundChunkBatchFinishedPacket(PacketContainer packet) {
2524
super(packet, TYPE);

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundChunkBatchStartPacket.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public class WrappedClientboundChunkBatchStartPacket extends AbstractPacket {
1515

1616
public WrappedClientboundChunkBatchStartPacket() {
1717
super(new PacketContainer(TYPE), TYPE);
18-
handle.getModifier().writeDefaults();
19-
}
18+
}
2019

2120
public WrappedClientboundChunkBatchStartPacket(PacketContainer packet) {
2221
super(packet, TYPE);

0 commit comments

Comments
 (0)