use of me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow in project FluffyMachines by NCBPFluffyBear.
the class AutoCrafter method constructMenu.
private void constructMenu(String displayName) {
new BlockMenuPreset(getId(), displayName) {
@Override
public void init() {
constructMenu(this);
}
@Override
public void newInstance(@Nonnull BlockMenu menu, @Nonnull Block b) {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals(String.valueOf(false))) {
menu.replaceExistingItem(6, new CustomItemStack(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
menu.addMenuClickHandler(6, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(true));
newInstance(menu, b);
return false;
});
} else {
menu.replaceExistingItem(6, new CustomItemStack(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
menu.addMenuClickHandler(6, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false));
newInstance(menu, b);
return false;
});
}
}
@Override
public boolean canOpen(@Nonnull Block b, @Nonnull Player p) {
return p.hasPermission("slimefun.inventory.bypass") || Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK);
}
@Override
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
return new int[0];
}
@Override
public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) {
return getCustomItemTransport(menu, flow, item);
}
};
}
Aggregations