Commits

md_5 authored a327d9f1da4
SPIGOT-2504: Save structure info for secondary worlds
No tags

nms-patches/WorldServer.patch

Modified
506 506
507 507 + // CraftBukkit start - Save secondary data for nether/end
508 508 + if (this instanceof SecondaryWorldServer) {
509 509 + ((SecondaryWorldServer) this).c();
510 510 + }
511 511 + // CraftBukkit end
512 512 +
513 513 this.worldData.a(this.getWorldBorder().getSize());
514 514 this.worldData.d(this.getWorldBorder().getCenterX());
515 515 this.worldData.c(this.getWorldBorder().getCenterZ());
516 -@@ -809,8 +1047,12 @@
517 - this.worldData.k(this.getWorldBorder().getWarningTime());
518 - this.worldData.b(this.getWorldBorder().j());
519 - this.worldData.e(this.getWorldBorder().i());
520 -+ // CraftBukkit start - save worldMaps once, rather than once per shared world
521 -+ if (!(this instanceof SecondaryWorldServer)) {
522 -+ this.worldMaps.a();
523 -+ }
524 - this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().t());
525 -- this.worldMaps.a();
526 -+ // CraftBukkit end
527 - }
528 -
529 - public boolean addEntity(Entity entity) {
530 -@@ -834,7 +1076,7 @@
516 +@@ -834,7 +1072,7 @@
531 517
532 518 private boolean i(Entity entity) {
533 519 if (entity.dead) {
534 520 - WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.b(entity)});
535 521 + // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.b(entity)}); // CraftBukkit
536 522 return false;
537 523 } else {
538 524 UUID uuid = entity.getUniqueID();
539 -@@ -846,7 +1088,7 @@
525 +@@ -846,7 +1084,7 @@
540 526 this.f.remove(entity1);
541 527 } else {
542 528 if (!(entity instanceof EntityHuman)) {
543 529 - WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.b(entity1), uuid.toString()});
544 530 + // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.b(entity1), uuid.toString()}); // CraftBukkit
545 531 return false;
546 532 }
547 533
548 -@@ -899,8 +1141,16 @@
534 +@@ -899,8 +1137,16 @@
549 535 }
550 536
551 537 public boolean strikeLightning(Entity entity) {
552 538 + // CraftBukkit start
553 539 + LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
554 540 + this.getServer().getPluginManager().callEvent(lightning);
555 541 +
556 542 + if (lightning.isCancelled()) {
557 543 + return false;
558 544 + }
559 545 + // CraftBukkit end
560 546 if (super.strikeLightning(entity)) {
561 547 - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutSpawnEntityWeather(entity));
562 548 + this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension
563 549 return true;
564 550 } else {
565 551 return false;
566 -@@ -916,10 +1166,20 @@
552 +@@ -916,10 +1162,20 @@
567 553 }
568 554
569 555 public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
570 556 + // CraftBukkit start
571 557 + Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag, flag1);
572 558 +
573 559 + if (explosion.wasCanceled) {
574 560 + return explosion;
575 561 + }
576 562 +
577 563 + /* Remove
578 564 Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, flag1);
579 565
580 566 explosion.a();
581 567 explosion.a(false);
582 568 + */
583 569 + // CraftBukkit end - TODO: Check if explosions are still properly implemented
584 570 if (!flag1) {
585 571 explosion.clearBlocks();
586 572 }
587 -@@ -965,7 +1225,8 @@
573 +@@ -965,7 +1221,8 @@
588 574 BlockActionData blockactiondata = (BlockActionData) iterator.next();
589 575
590 576 if (this.a(blockactiondata)) {
591 577 - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c()));
592 578 + // CraftBukkit - this.worldProvider.dimension -> this.dimension
593 579 + 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.d(), blockactiondata.b(), blockactiondata.c()));
594 580 }
595 581 }
596 582
597 -@@ -988,6 +1249,7 @@
583 +@@ -988,6 +1245,7 @@
598 584 boolean flag = this.W();
599 585
600 586 super.t();
601 587 + /* CraftBukkit start
602 588 if (this.n != this.o) {
603 589 this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID());
604 590 }
605 -@@ -1006,6 +1268,21 @@
591 +@@ -1006,6 +1264,21 @@
606 592 this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o));
607 593 this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q));
608 594 }
609 595 + // */
610 596 + if (flag != this.W()) {
611 597 + // Only send weather packets to those affected
612 598 + for (int i = 0; i < this.players.size(); ++i) {
613 599 + if (((EntityPlayer) this.players.get(i)).world == this) {
614 600 + ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
615 601 + }
616 602 + }
617 603 + }
618 604 + for (int i = 0; i < this.players.size(); ++i) {
619 605 + if (((EntityPlayer) this.players.get(i)).world == this) {
620 606 + ((EntityPlayer) this.players.get(i)).updateWeather(this.n, this.o, this.p, this.q);
621 607 + }
622 608 + }
623 609 + // CraftBukkit end
624 610
625 611 }
626 612
627 -@@ -1035,10 +1312,20 @@
613 +@@ -1035,10 +1308,20 @@
628 614 }
629 615
630 616 public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
631 617 + // CraftBukkit - visibility api support
632 618 + sendParticles(null, enumparticle, flag, d0, d1, d2, i, d3, d4, d5, d6, aint);
633 619 + }
634 620 +
635 621 + public void sendParticles(EntityPlayer sender, EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
636 622 + // CraftBukkit end
637 623 PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(enumparticle, flag, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i, aint);

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

Add shortcut