Skip to content

Commit 061aec6

Browse files
committed
Fire FishingEvent.Stop even when empty
1 parent 4f262ba commit 061aec6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FishingHookMixin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public abstract class FishingHookMixin extends ProjectileMixin {
5959

6060
// @formatter:off
6161
@Shadow @Nullable private Entity hookedIn;
62+
@Shadow private int nibble;
6263
// @formatter:on
6364

6465
@Inject(method = "setHookedEntity", at = @At("HEAD"), cancellable = true)
@@ -90,6 +91,14 @@ public abstract class FishingHookMixin extends ProjectileMixin {
9091
.map(t -> (ItemStack) (Object) t.finalReplacement().asMutable()).collect(ObjectArrayList.toList());
9192
}
9293

94+
@Inject(method = "retrieve", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/projectile/FishingHook;onGround()Z"), cancellable = true)
95+
private void impl$onRetrieveEmpty(final ItemStack tool, final CallbackInfoReturnable<Integer> cir) {
96+
if (this.hookedIn == null && this.nibble <= 0
97+
&& SpongeCommon.post(SpongeEventFactory.createFishingEventStop(PhaseTracker.getInstance().currentCause(), ((FishingBobber) this), List.of()))) {
98+
cir.setReturnValue(0);
99+
}
100+
}
101+
93102
@WrapMethod(method = "retrieve")
94103
private int impl$wrapRetrieveWithCause(final ItemStack tool, final Operation<Integer> original) {
95104
final Entity owner = this.shadow$getOwner();

0 commit comments

Comments
 (0)