Commits

md_5 authored 516a408f4a4
Remove redundant CraftBukkit change for secondary world data

The above loop would always save this data
No tags

nms-patches/WorldServer.patch

Modified
397 397 @@ -639,7 +841,8 @@
398 398 }
399 399
400 400 chunkproviderserver.a(flag);
401 401 - List<Chunk> list = Lists.newArrayList(chunkproviderserver.a());
402 402 + // CraftBukkit - ArrayList -> Collection
403 403 + java.util.Collection<Chunk> list = chunkproviderserver.a();
404 404 Iterator iterator = list.iterator();
405 405
406 406 while (iterator.hasNext()) {
407 -@@ -673,6 +876,12 @@
408 - }
409 - }
410 -
411 -+ // CraftBukkit start - Save secondary data for nether/end
412 -+ if (this instanceof SecondaryWorldServer) {
413 -+ ((SecondaryWorldServer) this).c(); // As above
414 -+ }
415 -+ // CraftBukkit end
416 -+
417 - this.worldData.a(this.getWorldBorder().getSize());
418 - this.worldData.d(this.getWorldBorder().getCenterX());
419 - this.worldData.c(this.getWorldBorder().getCenterZ());
420 -@@ -687,9 +896,13 @@
407 +@@ -687,9 +890,13 @@
421 408 this.h().a();
422 409 }
423 410
424 411 - public boolean addEntity(Entity entity) {
425 412 - return this.j(entity) ? super.addEntity(entity) : false;
426 413 + // CraftBukkit start
427 414 + public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
428 415 + // World.addEntity(Entity) will call this, and we still want to perform
429 416 + // existing entity checking when it's called with a SpawnReason
430 417 + return this.j(entity) ? super.addEntity(entity, spawnReason) : false;
431 418 }
432 419 + // CraftBukkit end
433 420
434 421 public void a(Stream<Entity> stream) {
435 422 stream.forEach((entity) -> {
436 -@@ -703,7 +916,7 @@
423 +@@ -703,7 +910,7 @@
437 424
438 425 private boolean j(Entity entity) {
439 426 if (entity.dead) {
440 427 - WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P()));
441 428 + // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P())); // CraftBukkit
442 429 return false;
443 430 } else {
444 431 UUID uuid = entity.getUniqueID();
445 -@@ -715,7 +928,7 @@
432 +@@ -715,7 +922,7 @@
446 433 this.g.remove(entity1);
447 434 } else {
448 435 if (!(entity instanceof EntityHuman)) {
449 436 - WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString());
450 437 + // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString()); // CraftBukkit
451 438 return false;
452 439 }
453 440
454 -@@ -767,9 +980,21 @@
441 +@@ -767,9 +974,21 @@
455 442
456 443 }
457 444
458 445 + // CraftBukkit start
459 446 public boolean strikeLightning(Entity entity) {
460 447 + return this.strikeLightning(entity, LightningStrikeEvent.Cause.UNKNOWN);
461 448 + }
462 449 +
463 450 + public boolean strikeLightning(Entity entity, LightningStrikeEvent.Cause cause) {
464 451 + LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity(), cause);
467 454 + if (lightning.isCancelled()) {
468 455 + return false;
469 456 + }
470 457 + // CraftBukkit end
471 458 if (super.strikeLightning(entity)) {
472 459 - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entity));
473 460 + this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension
474 461 return true;
475 462 } else {
476 463 return false;
477 -@@ -785,6 +1010,14 @@
464 +@@ -785,6 +1004,14 @@
478 465 }
479 466
480 467 public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
481 468 + // CraftBukkit start
482 469 + Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, flag1);
483 470 +
484 471 + if (explosion.wasCanceled) {
485 472 + return explosion;
486 473 + }
487 474 +
488 475 + /* Remove
489 476 Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, flag1);
490 477
491 478 if (damagesource != null) {
492 -@@ -793,6 +1026,8 @@
479 +@@ -793,6 +1020,8 @@
493 480
494 481 explosion.a();
495 482 explosion.a(false);
496 483 + */
497 484 + // CraftBukkit end - TODO: Check if explosions are still properly implemented
498 485 if (!flag1) {
499 486 explosion.clearBlocks();
500 487 }
501 -@@ -819,7 +1054,8 @@
488 +@@ -819,7 +1048,8 @@
502 489 BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst();
503 490
504 491 if (this.a(blockactiondata)) {
505 492 - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
506 493 + // CraftBukkit - this.worldProvider.dimension -> this.dimension
507 494 + this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
508 495 }
509 496 }
510 497
511 -@@ -840,6 +1076,7 @@
498 +@@ -840,6 +1070,7 @@
512 499 boolean flag = this.isRaining();
513 500
514 501 super.w();
515 502 + /* CraftBukkit start
516 503 if (this.o != this.p) {
517 504 this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.p)), this.worldProvider.getDimensionManager());
518 505 }
519 -@@ -858,6 +1095,21 @@
506 +@@ -858,6 +1089,21 @@
520 507 this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p));
521 508 this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r));
522 509 }
523 510 + // */
524 511 + if (flag != this.isRaining()) {
525 512 + // Only send weather packets to those affected
526 513 + for (int i = 0; i < this.players.size(); ++i) {
527 514 + if (((EntityPlayer) this.players.get(i)).world == this) {
528 515 + ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
529 516 + }
530 517 + }
531 518 + }
532 519 + for (int i = 0; i < this.players.size(); ++i) {
533 520 + if (((EntityPlayer) this.players.get(i)).world == this) {
534 521 + ((EntityPlayer) this.players.get(i)).updateWeather(this.o, this.p, this.q, this.r);
535 522 + }
536 523 + }
537 524 + // CraftBukkit end
538 525
539 526 }
540 527
541 -@@ -891,13 +1143,20 @@
528 +@@ -891,13 +1137,20 @@
542 529 }
543 530
544 531 public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
545 532 - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
546 533 + // CraftBukkit - visibility api support
547 534 + return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false);
548 535 + }
549 536 +
550 537 + public <T extends ParticleParam> int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
551 538 + PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut