Skip to content

Commit 7de850a

Browse files
committed
Fix exception cause from update before create
1 parent f6a81a6 commit 7de850a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

rectangles/networking/Packet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public Packet(PApplet inst, String serial) {
181181
case ("player"):
182182
this.obj = Player.deSerial(this.inst, objectSerial);
183183
Rectangles.movObjects.add(this.obj);
184+
//System.out.println(this.uuid + ": " + this.obj.getRend().getColorToString());
184185
if(this.type == PACKET_REGISTER) {
185186
Rectangles.player = (Player) this.obj;
186187
}
@@ -241,8 +242,12 @@ public Packet(PApplet inst, String serial) {
241242
break;
242243
}
243244
}
245+
try {
244246
Rectangles.objectMap.get(this.uuid).getPy().getLocation()
245247
.set(this.location[0], this.location[1]);
248+
} catch (NullPointerException e) {
249+
// Do nothing, update for object not yet created most likely
250+
}
246251
break;
247252
case (PACKET_KEY_PRESS):
248253
this.keyPress = Integer.parseInt(serialData[1].split(":")[1]);

0 commit comments

Comments
 (0)