use of io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine in project Slimefun4 by Slimefun.
the class GiveCommand method giveItem.
private void giveItem(CommandSender sender, Player p, SlimefunItem sfItem, String[] args) {
if (sfItem instanceof MultiBlockMachine) {
Slimefun.getLocalization().sendMessage(sender, "guide.cheat.no-multiblocks");
} else {
int amount = parseAmount(args);
if (amount > 0) {
Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
Map<Integer, ItemStack> excess = p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount));
if (Slimefun.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) {
for (ItemStack is : excess.values()) {
p.getWorld().dropItem(p.getLocation(), is);
}
}
Slimefun.getLocalization().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
} else {
Slimefun.getLocalization().sendMessage(sender, "messages.invalid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3]));
}
}
}
use of io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine in project SupplementalServiceableness by NCBPFluffyBear.
the class SupServItemSetup method setup.
public static void setup(@Nonnull SupServPlugin plugin) {
new LavaSponge(SupServItems.SUPSERV_CATEGORY, SupServItems.LAVA_SPONGE, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { null, new ItemStack(Material.BROWN_WOOL), null, new ItemStack(Material.BROWN_WOOL), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.BROWN_WOOL), null, new ItemStack(Material.BROWN_WOOL), null }, new SlimefunItemStack(SupServItems.LAVA_SPONGE, 8)).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.CHIPPED_WITHER_SKELETON_SKULL, RecipeType.MAGIC_WORKBENCH, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, new ItemStack(Material.SKELETON_SKULL), SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON }).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.FRAGMENTED_WITHER_SKELETON_SKULL, RecipeType.MAGIC_WORKBENCH, Utils.build3x3Recipe(SupServItems.CHIPPED_WITHER_SKELETON_SKULL)).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.WITHER_SKELETON_SKULL, RecipeType.MAGIC_WORKBENCH, new ItemStack[] { SupServItems.FRAGMENTED_WITHER_SKELETON_SKULL, SupServItems.FRAGMENTED_WITHER_SKELETON_SKULL, null, SupServItems.FRAGMENTED_WITHER_SKELETON_SKULL, SupServItems.FRAGMENTED_WITHER_SKELETON_SKULL, null, null, null, null }, new ItemStack(Material.WITHER_SKELETON_SKULL)).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.CONDENSED_NETHER_STAR_BLOCK, RecipeType.ENHANCED_CRAFTING_TABLE, Utils.build3x3Recipe(new ItemStack(Material.NETHER_STAR))).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.INGOT_OF_AFTERLIFE, RecipeType.MAGIC_WORKBENCH, Utils.build3x3Recipe(SlimefunItems.ESSENCE_OF_AFTERLIFE)).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.DRAGON_ESSENCE, RecipeType.ANCIENT_ALTAR, new ItemStack[] { SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.DRAGON_BREATH), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.DRAGON_BREATH), new ItemStack(Material.NETHER_STAR), new ItemStack(Material.DRAGON_BREATH), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.DRAGON_BREATH), SlimefunItems.ENDER_LUMP_3 }).register(plugin);
new NonInteractableItem(SupServItems.SUPSERV_CATEGORY, SupServItems.DRAGON_EGG, RecipeType.ANCIENT_ALTAR, new ItemStack[] { SupServItems.INGOT_OF_AFTERLIFE, SupServItems.DRAGON_ESSENCE, SupServItems.INGOT_OF_AFTERLIFE, SupServItems.DRAGON_ESSENCE, SupServItems.CONDENSED_NETHER_STAR_BLOCK, SupServItems.DRAGON_ESSENCE, SupServItems.INGOT_OF_AFTERLIFE, SupServItems.DRAGON_ESSENCE, SupServItems.INGOT_OF_AFTERLIFE }, new ItemStack(Material.DRAGON_EGG)).register(plugin);
// Tools
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.STONE), null, new ItemStack(Material.STONE), new ItemStack(Material.STONE), new ItemStack(Material.WATER_BUCKET), new ItemStack(Material.STONE), null, new ItemStack(Material.STONE), null }, WateringCan.canType.STONE).register(plugin);
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN_IRON, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), SupServItems.WATERING_CAN, new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT), null }, WateringCan.canType.IRON).register(plugin);
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN_GOLD, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.GOLD_16K, null, SlimefunItems.GOLD_16K, SlimefunItems.GOLD_16K, SupServItems.WATERING_CAN_IRON, SlimefunItems.GOLD_16K, null, SlimefunItems.GOLD_16K, null }, WateringCan.canType.GOLD).register(plugin);
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN_DIAMOND, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.SYNTHETIC_DIAMOND, null, SlimefunItems.SYNTHETIC_DIAMOND, SlimefunItems.SYNTHETIC_DIAMOND, SupServItems.WATERING_CAN_GOLD, SlimefunItems.SYNTHETIC_DIAMOND, null, SlimefunItems.SYNTHETIC_DIAMOND, null }, WateringCan.canType.DIAMOND).register(plugin);
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN_EMERALD, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.SYNTHETIC_EMERALD, null, SlimefunItems.SYNTHETIC_EMERALD, SlimefunItems.SYNTHETIC_EMERALD, SupServItems.WATERING_CAN_DIAMOND, SlimefunItems.SYNTHETIC_EMERALD, null, SlimefunItems.SYNTHETIC_EMERALD, null }, WateringCan.canType.EMERALD).register(plugin);
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN_NETHERITE, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { null, null, null, null, SupServItems.WATERING_CAN_EMERALD, new ItemStack(Material.NETHERITE_INGOT), null, null, null }, WateringCan.canType.NETHERITE).register(plugin);
// Extra recipe watering can to accept watering can Fluffymachines
if (plugin.getServer().getPluginManager().isPluginEnabled("FluffyMachines")) {
new WateringCan(SupServItems.SUPSERV_CATEGORY, SupServItems.WATERING_CAN_IRON_FM, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), SlimefunItem.getById("WATERING_CAN").getItem(), new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT), null }, WateringCan.canType.IRON, SupServItems.WATERING_CAN_IRON.clone()).register(plugin);
}
new FarmersHoe(SupServItems.SUPSERV_CATEGORY, SupServItems.FARMERS_HOE, RecipeType.ANCIENT_ALTAR, new ItemStack[] { SlimefunItems.EARTH_RUNE, SlimefunItems.WATER_RUNE, SlimefunItems.EARTH_RUNE, new ItemStack(Material.BONE_BLOCK), new ItemStack(Material.IRON_HOE), new ItemStack(Material.BONE_BLOCK), SlimefunItems.EARTH_RUNE, SlimefunItems.WATER_RUNE, SlimefunItems.EARTH_RUNE }).register(plugin);
new AdvancedElectricComposter(SupServItems.SUPSERV_CATEGORY, SupServItems.ADVANCED_ELECTRIC_COMPOSTER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.NETHER_BRICK_SLAB), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.NETHER_BRICK_SLAB), new ItemStack(Material.NETHER_BRICK_SLAB), SlimefunItem.getById("ELECTRIC_COMPOSTER_2").getItem(), new ItemStack(Material.NETHER_BRICK_SLAB), new ItemStack(Material.NETHER_BRICK_SLAB), SlimefunItems.ADVANCED_CIRCUIT_BOARD, new ItemStack(Material.NETHER_BRICK_SLAB) }).register(plugin);
new ExpGenerator(SupServItems.SUPSERV_CATEGORY, SupServItems.EXP_GENERATOR, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.OBSIDIAN), SlimefunItems.ELECTRO_MAGNET, new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), SlimefunItems.EXP_COLLECTOR, new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.OBSIDIAN) }).register(plugin);
new Baler(SupServItems.SUPSERV_CATEGORY, SupServItems.BALER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.OAK_PLANKS), SlimefunItems.ELECTRO_MAGNET, new ItemStack(Material.OAK_PLANKS), new ItemStack(Material.PISTON), SlimefunItems.CRAFTING_MOTOR, new ItemStack(Material.PISTON), new ItemStack(Material.OAK_PLANKS), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.OAK_PLANKS) }).register(plugin);
new EndermanTether(SupServItems.SUPSERV_CATEGORY, SupServItems.ENDERMAN_TETHER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.ENDER_RUNE, new ItemStack(Material.CRYING_OBSIDIAN), SlimefunItems.ENDER_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.INFUSED_MAGNET, SlimefunItems.ENDER_LUMP_3, SlimefunItems.ENDER_RUNE, new ItemStack(Material.CRYING_OBSIDIAN), SlimefunItems.ENDER_RUNE }).register(plugin);
new HeadGrinder(SupServItems.SUPSERV_CATEGORY, SupServItems.HEAD_GRINDER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.PISTON), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.PISTON), new ItemStack(Material.IRON_BLOCK), SlimefunItems.MEDIUM_CAPACITOR, new ItemStack(Material.IRON_BLOCK) }).register(plugin);
new Voltmeter(SupServItems.SUPSERV_CATEGORY, SupServItems.VOLTMETER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, new ItemStack(Material.CLOCK), SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new ItemStack(Material.COBBLESTONE, 9) }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.DOUBLE_COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new CustomItemStack(SupServItems.COMPRESSED_COBBLESTONE, 9) }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.TRIPLE_COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new CustomItemStack(SupServItems.DOUBLE_COMPRESSED_COBBLESTONE, 9) }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new CustomItemStack(SupServItems.TRIPLE_COMPRESSED_COBBLESTONE, 9) }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.QUINTUPLE_COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new CustomItemStack(SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, 9) }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.SEXTUPLE_COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new CustomItemStack(SupServItems.QUINTUPLE_COMPRESSED_COBBLESTONE, 9) }).register(plugin);
new SlimefunItem(SupServItems.SUPSERV_CATEGORY, SupServItems.SEPTUPLE_COMPRESSED_COBBLESTONE, RecipeType.COMPRESSOR, new ItemStack[] { new CustomItemStack(SupServItems.SEXTUPLE_COMPRESSED_COBBLESTONE, 9) }).register(plugin);
// Grind Stone
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.COMPRESSED_COBBLESTONE, 1) }, new ItemStack(Material.COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.DOUBLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.COMPRESSED_COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.TRIPLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.DOUBLE_COMPRESSED_COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.TRIPLE_COMPRESSED_COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.QUINTUPLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.SEXTUPLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.QUINTUPLE_COMPRESSED_COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.SEPTUPLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.SEXTUPLE_COMPRESSED_COBBLESTONE, 9));
((MultiBlockMachine) SlimefunItems.GRIND_STONE.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.OCTUPLE_COMPRESSED_COBBLESTONE, 1) }, new SlimefunItemStack(SupServItems.SEPTUPLE_COMPRESSED_COBBLESTONE, 9));
// Compressor
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new ItemStack(Material.COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.DOUBLE_COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.DOUBLE_COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.TRIPLE_COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.TRIPLE_COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.QUINTUPLE_COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.QUINTUPLE_COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.SEXTUPLE_COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.SEXTUPLE_COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.SEPTUPLE_COMPRESSED_COBBLESTONE, 1));
((MultiBlockMachine) SlimefunItems.COMPRESSOR.getItem()).addRecipe(new ItemStack[] { new SlimefunItemStack(SupServItems.SEPTUPLE_COMPRESSED_COBBLESTONE, 9) }, new SlimefunItemStack(SupServItems.QUADRUPLE_COMPRESSED_COBBLESTONE, 1));
new WitherProofBlock(SupServItems.SUPSERV_CATEGORY, SupServItems.WITHER_PROOF_SEA_LANTERN, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, new ItemStack(Material.SEA_LANTERN), SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN }, new SlimefunItemStack(SupServItems.WITHER_PROOF_SEA_LANTERN, 16)).register(plugin);
new WitherProofBlock(SupServItems.SUPSERV_CATEGORY, SupServItems.WITHER_PROOF_GLOWSTONE, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, new ItemStack(Material.GLOWSTONE), SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN }, new SlimefunItemStack(SupServItems.WITHER_PROOF_GLOWSTONE, 16)).register(plugin);
new WitherProofBlock(SupServItems.SUPSERV_CATEGORY, SupServItems.WITHER_PROOF_SHROOMLIGHT, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, new ItemStack(Material.SHROOMLIGHT), SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_GLASS, SlimefunItems.WITHER_PROOF_OBSIDIAN }, new SlimefunItemStack(SupServItems.WITHER_PROOF_SHROOMLIGHT, 16)).register(plugin);
}
use of io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine in project Slimefun4 by Slimefun.
the class SurvivalSlimefunGuide method displayItem.
private void displayItem(ChestMenu menu, PlayerProfile profile, Player p, Object item, ItemStack output, RecipeType recipeType, ItemStack[] recipe, AsyncRecipeChoiceTask task) {
addBackButton(menu, 0, p, profile);
MenuClickHandler clickHandler = (pl, slot, itemstack, action) -> {
try {
if (itemstack != null && itemstack.getType() != Material.BARRIER) {
displayItem(profile, itemstack, 0, true);
}
} catch (Exception | LinkageError x) {
printErrorMessage(pl, x);
}
return false;
};
boolean isSlimefunRecipe = item instanceof SlimefunItem;
for (int i = 0; i < 9; i++) {
ItemStack recipeItem = getDisplayItem(p, isSlimefunRecipe, recipe[i]);
menu.addItem(recipeSlots[i], recipeItem, clickHandler);
if (recipeItem != null && item instanceof MultiBlockMachine) {
for (Tag<Material> tag : MultiBlock.getSupportedTags()) {
if (tag.isTagged(recipeItem.getType())) {
task.add(recipeSlots[i], tag);
break;
}
}
}
}
menu.addItem(10, recipeType.getItem(p), ChestMenuUtils.getEmptyClickHandler());
menu.addItem(16, output, ChestMenuUtils.getEmptyClickHandler());
}
use of io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine in project Slimefun4 by Slimefun.
the class SurvivalSlimefunGuide method displaySlimefunItem.
private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, PlayerProfile profile, SlimefunItem sfitem, int page, int index) {
Research research = sfitem.getResearch();
if (isSurvivalMode() && !hasPermission(p, sfitem)) {
List<String> message = Slimefun.getPermissionsService().getLore(sfitem);
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0])));
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
} else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) {
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
research.unlockFromGuide(this, p, profile, sfitem, itemGroup, page);
return false;
});
} else {
menu.addItem(index, sfitem.getItem());
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
try {
if (isSurvivalMode()) {
displayItem(profile, sfitem, true);
} else {
if (sfitem instanceof MultiBlockMachine) {
Slimefun.getLocalization().sendMessage(pl, "guide.cheat.no-multiblocks");
} else {
ItemStack clonedItem = sfitem.getItem().clone();
if (action.isShiftClicked()) {
clonedItem.setAmount(clonedItem.getMaxStackSize());
}
pl.getInventory().addItem(clonedItem);
}
}
} catch (Exception | LinkageError x) {
printErrorMessage(pl, x);
}
return false;
});
}
}
use of io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine in project SupremeExpansion by RelativoBR.
the class MultiBlockGearFabricator method interactGearMachine.
public static void interactGearMachine(SupremeExpansion plugin, MultiBlockMachine machine, Player p, Block b) {
Block dispenser = b.getRelative(BlockFace.UP);
if (!dispenser.isEmpty()) {
BlastFurnace blastFurnace = (BlastFurnace) PaperLib.getBlockState(b.getRelative(BlockFace.DOWN), false).getState();
FurnaceInventory furnaceInventory = blastFurnace.getInventory();
Inventory inv = ((Dispenser) dispenser.getState()).getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(machine);
recipe: for (ItemStack[] input : inputs) {
for (int i = 0; i < inv.getContents().length; i++) {
if (!SlimefunUtils.isItemSimilar(inv.getContents()[i], input[i], false, true)) {
continue recipe;
}
}
ItemStack output = RecipeType.getRecipeOutputList(machine, input);
SlimefunItem outputItem = SlimefunItem.getByItem(output);
if (outputItem == null || outputItem.canUse(p, true)) {
if (furnaceInventory.getResult() != null) {
Slimefun.getLocalization().sendMessage(p, "machines.full-inventory", true);
return;
}
for (int i = 0; i < inv.getContents().length; i++) {
ItemStack item = inv.getItem(i);
if (item != null) {
ItemUtils.consumeItem(item, input[i].getAmount(), false);
}
}
Bukkit.getScheduler().runTaskLater(plugin, () -> p.getWorld().playSound(dispenser.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F), 55L);
for (int i = 1; i < 7; i++) {
Bukkit.getScheduler().runTaskLater(plugin, () -> p.getWorld().playSound(dispenser.getLocation(), Sound.BLOCK_METAL_PLACE, 7F, 1F), i * 5L);
}
if (furnaceInventory.getResult() == null) {
furnaceInventory.setResult(output);
}
}
return;
}
}
Slimefun.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
}
Aggregations