Skip to content

Commit

Permalink
Merge pull request Sefiraat#164 from balugaq/master
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
balugaq authored Nov 4, 2024
2 parents e0bff01 + 8881ea6 commit 9014cc5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.balugaq.netex.api.helpers.Icon;
import com.balugaq.netex.utils.BlockMenuUtil;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import com.ytdd9527.networksexpansion.core.items.unusable.AbstractBlueprint;
import com.ytdd9527.networksexpansion.implementation.ExpansionItems;
import io.github.sefiraat.networks.Networks;
Expand All @@ -15,6 +16,7 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
Expand All @@ -24,10 +26,12 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;

public class NetworkBlueprintDecoder extends NetworkObject {
Expand Down Expand Up @@ -56,6 +60,31 @@ public static int getDecodeSlot() {
return DECODE_SLOT;
}

@Override
public void preRegister() {
addItemHandler(new BlockBreakHandler(false, false) {
@Override
public void onPlayerBreak(@Nonnull BlockBreakEvent blockBreakEvent, @Nonnull ItemStack itemStack, @Nonnull List<ItemStack> list) {
BlockMenu blockMenu = StorageCacheUtils.getMenu(blockBreakEvent.getBlock().getLocation());
if (blockMenu == null) {
return;
}

for (int slot : getOutputSlots()) {
ItemStack item = blockMenu.getItemInSlot(slot);
if (item != null && item.getType() != Material.AIR) {
blockMenu.getLocation().getWorld().dropItemNaturally(blockMenu.getLocation(), item);
}
}

ItemStack input = blockMenu.getItemInSlot(getInputSlot());
if (input != null && input.getType() != Material.AIR) {
blockMenu.getLocation().getWorld().dropItemNaturally(blockMenu.getLocation(), input);
}
}
});
}

@Override
public void postRegister() {
new BlockMenuPreset(this.getId(), this.getItemName()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.balugaq.netex.api.data.ItemWrapper;
import com.balugaq.netex.utils.NetworksVersionedEnchantment;
import io.github.sefiraat.networks.utils.StackUtils;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair;
import io.github.thebusybiscuit.slimefun4.libraries.dough.items.nms.ItemNameAdapter;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
Expand Down

0 comments on commit 9014cc5

Please sign in to comment.