Skip to content

Commit 10b81d6

Browse files
committed
chore: use extent instead of accessing the world directly
-> fix: rare exception when using CraftBlockEntityState#getSnapshotNBT async (with latest 1.21.10 Paper builds?)
1 parent fef6bef commit 10b81d6

14 files changed

Lines changed: 37 additions & 89 deletions

File tree

worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,16 +637,11 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
637637
}
638638

639639
@Override
640-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
640+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
641641
try {
642642
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
643643

644-
CompoundTag vanillaNBT;
645-
if (nbtData == null) {
646-
vanillaNBT = craftState.getSnapshotNBT();
647-
} else {
648-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
649-
}
644+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
650645

651646
((CraftPlayer) player).getHandle().connection.send((Packet<?>)
652647
blockEntityDataPacketConstructor.newInstance(

worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R3/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,11 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
636636
}
637637

638638
@Override
639-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
639+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
640640
try {
641641
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
642642

643-
CompoundTag vanillaNBT;
644-
if (nbtData == null) {
645-
vanillaNBT = craftState.getSnapshotNBT();
646-
} else {
647-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
648-
}
643+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
649644

650645
((CraftPlayer) player).getHandle().connection.send((Packet<?>)
651646
blockEntityDataPacketConstructor.newInstance(

worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,10 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
636636
}
637637

638638
@Override
639-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
639+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
640640
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
641641

642-
CompoundTag vanillaNBT;
643-
if (nbtData == null) {
644-
vanillaNBT = craftState.getSnapshotNBT();
645-
} else {
646-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
647-
}
642+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
648643

649644
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
650645
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,15 +616,10 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
616616
}
617617

618618
@Override
619-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
619+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
620620
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
621621

622-
CompoundTag vanillaNBT;
623-
if (nbtData == null) {
624-
vanillaNBT = craftState.getSnapshotNBT();
625-
} else {
626-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
627-
}
622+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
628623

629624
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
630625
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/adapters/adapter-1_21_11/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_11/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,10 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
592592
}
593593

594594
@Override
595-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
595+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
596596
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
597597

598-
CompoundTag vanillaNBT;
599-
if (nbtData == null) {
600-
vanillaNBT = craftState.getSnapshotNBT();
601-
} else {
602-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
603-
}
598+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
604599

605600
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
606601
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/adapters/adapter-1_21_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_4/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,15 +566,10 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
566566
}
567567

568568
@Override
569-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
569+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
570570
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
571571

572-
CompoundTag vanillaNBT;
573-
if (nbtData == null) {
574-
vanillaNBT = craftState.getSnapshotNBT();
575-
} else {
576-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
577-
}
572+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNativeLin(nbtData);
578573

579574
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
580575
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/adapters/adapter-1_21_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_5/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,15 +580,10 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
580580
}
581581

582582
@Override
583-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
583+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
584584
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
585585

586-
CompoundTag vanillaNBT;
587-
if (nbtData == null) {
588-
vanillaNBT = craftState.getSnapshotNBT();
589-
} else {
590-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
591-
}
586+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
592587

593588
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
594589
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/adapters/adapter-1_21_6/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_6/PaperweightAdapter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,15 +601,10 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
601601
}
602602

603603
@Override
604-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
604+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
605605
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
606606

607-
CompoundTag vanillaNBT;
608-
if (nbtData == null) {
609-
vanillaNBT = craftState.getSnapshotNBT();
610-
} else {
611-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
612-
}
607+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
613608

614609
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
615610
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/adapters/adapter-1_21_9/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_9/PaperweightAdapter.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,9 @@ public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData)
599599
}
600600

601601
@Override
602-
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
602+
public void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
603603
CraftBlockEntityState<?> craftState = (CraftBlockEntityState<?>) tileState;
604-
605-
CompoundTag vanillaNBT;
606-
if (nbtData == null) {
607-
vanillaNBT = craftState.getSnapshotNBT();
608-
} else {
609-
vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
610-
}
604+
CompoundTag vanillaNBT = (net.minecraft.nbt.CompoundTag) fromNative(nbtData);
611605

612606
((CraftPlayer) player).getHandle().connection.send(new ClientboundBlockEntityDataPacket(
613607
new BlockPos(pos.x(), pos.y(), pos.z()),

worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IDelegateBukkitImplAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ default void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData
8888
}
8989

9090
@Override
91-
default void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, @Nullable LinCompoundTag nbtData) {
91+
default void sendFakeNBT(Player player, BlockVector3 pos, TileState tileState, LinCompoundTag nbtData) {
9292
getParent().sendFakeNBT(player, pos, tileState, nbtData);
9393
}
9494

0 commit comments

Comments
 (0)