* Fix #12721

Track when knots are created and only fire the event then

* Use mutable boolean + check if actually spawned
This commit is contained in:
Owen
2025-06-25 14:16:03 -04:00
committed by GitHub
parent d7510efc16
commit 0caf75f839
2 changed files with 34 additions and 8 deletions

View File

@@ -27,3 +27,25 @@
}
}
@@ -120,7 +_,12 @@
return this.level().getBlockState(this.pos).is(BlockTags.FENCES);
}
+ // Paper start - Track if a knot was created
public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos) {
+ return getOrCreateKnot(level, pos, null);
+ }
+ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos, @Nullable org.apache.commons.lang3.mutable.MutableBoolean created) {
+ // Paper end - Track if a knot was created
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
@@ -134,7 +_,7 @@
}
LeashFenceKnotEntity leashFenceKnotEntity1 = new LeashFenceKnotEntity(level, pos);
- level.addFreshEntity(leashFenceKnotEntity1);
+ if (level.addFreshEntity(leashFenceKnotEntity1) && created != null) { created.setTrue(); } // Paper - Track if a knot was created
return leashFenceKnotEntity1;
}