Skip to content

Commit 429f99c

Browse files
authored
Improve onHopperEvent by avoiding snapshots (#769)
1 parent 67dcbe1 commit 429f99c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Movecraft/src/main/java/net/countercraft/movecraft/listener/BlockListener.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,10 @@ public void onPistonEvent(@NotNull BlockPistonEvent e, final @NotNull List<Block
162162
// prevent hoppers on cruising crafts
163163
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
164164
public void onHopperEvent(@NotNull InventoryMoveItemEvent e) {
165-
if (!(e.getSource().getHolder() instanceof Hopper))
165+
if (!(e.getSource().getHolder(false) instanceof Hopper hopper))
166166
return;
167167

168-
Hopper block = (Hopper) e.getSource().getHolder();
169-
Location location = block.getLocation();
168+
Location location = hopper.getLocation();
170169
MovecraftLocation loc = MathUtils.bukkit2MovecraftLoc(location);
171170
for (Craft craft : MathUtils.craftsNearLocFast(CraftManager.getInstance().getCrafts(), location)) {
172171
if (craft.isNotProcessing() || !craft.getHitBox().contains(loc))

0 commit comments

Comments
 (0)