Skip to content

Commit

Permalink
Prevent extra BS check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sfiguz7 committed Feb 25, 2024
1 parent 9e96e76 commit 98b0840
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public void onBlockBreak(BlockBreakEvent e) {
}

ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
Block b = e.getBlock();
SlimefunItem sfItem = BlockStorage.check(b);

// If there is a Slimefun Block here, call our BreakEvent and, if cancelled, cancel this event and return
if (sfItem != null) {
Expand All @@ -175,7 +176,7 @@ public void onBlockBreak(BlockBreakEvent e) {

callBlockHandler(e, item, drops, sfItem);

dropItems(e, item, drops);
dropItems(e, item, b, sfItem==null, drops);

// Checks for vanilla sensitive blocks everywhere
checkForSensitiveBlocks(e.getBlock(), 0, e.isDropItems());
Expand Down Expand Up @@ -225,7 +226,7 @@ private void callBlockHandler(BlockBreakEvent e, ItemStack item, List<ItemStack>
}

@ParametersAreNonnullByDefault
private void dropItems(BlockBreakEvent e, ItemStack item, List<ItemStack> drops) {
private void dropItems(BlockBreakEvent e, ItemStack item, Block b, boolean isBlockstorageNull, List<ItemStack> drops) {
if (!drops.isEmpty()) {
// TODO: properly support loading inventories within unit tests
if (!Slimefun.instance().isUnitTest()) {
Expand All @@ -239,8 +240,7 @@ private void dropItems(BlockBreakEvent e, ItemStack item, List<ItemStack> drops)
e.setDropItems(false);

// Fixes #4051
Block b = e.getBlock();
if (BlockStorage.check(b) == null) {
if (isBlockstorageNull) {
b.breakNaturally(item);
}

Expand Down

0 comments on commit 98b0840

Please sign in to comment.