13
0
geforkt von Mirrors/Paper

Prevent NPE if hooked entity was cleared

Dieser Commit ist enthalten in:
Jake Potrebic 2024-05-12 21:57:23 -07:00
Ursprung c6f962ba54
Commit acdfeeea3d

Datei anzeigen

@ -175,7 +175,7 @@
public boolean calculateOpenWater(BlockPos pos) {
FishingHook.OpenWaterType entityfishinghook_waterposition = FishingHook.OpenWaterType.INVALID;
@@ -445,13 +487,29 @@
@@ -445,17 +487,35 @@
@Override
public void readAdditionalSaveData(CompoundTag nbt) {}
@ -202,11 +202,17 @@
+ if (playerFishEvent.isCancelled()) {
+ return 0;
+ }
+ if (this.hookedIn != null) { // Paper - re-check to see if there is a hooked entity
+ // CraftBukkit end
this.pullEntity(this.hookedIn);
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, Collections.emptyList());
this.level().broadcastEntityEvent(this, (byte) 31);
@@ -466,15 +524,38 @@
i = this.hookedIn instanceof ItemEntity ? 3 : 5;
+ } // Paper - re-check to see if there is a hooked entity
} else if (this.nibble > 0) {
LootParams lootparams = (new LootParams.Builder((ServerLevel) this.level())).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, usedItem).withParameter(LootContextParams.THIS_ENTITY, this).withLuck((float) this.luck + entityhuman.getLuck()).create(LootContextParamSets.FISHING);
LootTable loottable = this.level().getServer().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING);
@@ -466,15 +526,38 @@
while (iterator.hasNext()) {
ItemStack itemstack1 = (ItemStack) iterator.next();
@ -249,7 +255,7 @@
if (itemstack1.is(ItemTags.FISHES)) {
entityhuman.awardStat(Stats.FISH_CAUGHT, 1);
}
@@ -484,10 +565,27 @@
@@ -484,10 +567,27 @@
}
if (this.onGround()) {
@ -278,7 +284,7 @@
return i;
} else {
return 0;
@@ -496,7 +594,7 @@
@@ -496,7 +596,7 @@
@Override
public void handleEntityEvent(byte status) {
@ -287,7 +293,7 @@
this.pullEntity(this.hookedIn);
}
@@ -520,8 +618,15 @@
@@ -520,8 +620,15 @@
@Override
public void remove(Entity.RemovalReason reason) {
@ -304,7 +310,7 @@
}
@Override
@@ -536,7 +641,7 @@
@@ -536,7 +643,7 @@
}
private void updateOwnerInfo(@Nullable FishingHook fishingBobber) {
@ -313,7 +319,7 @@
if (entityhuman != null) {
entityhuman.fishing = fishingBobber;
@@ -545,10 +650,10 @@
@@ -545,10 +652,10 @@
}
@Nullable
@ -326,7 +332,7 @@
}
@Nullable
@@ -575,7 +680,7 @@
@@ -575,7 +682,7 @@
int i = packet.getData();
FishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i);