use of me.mrCookieSlime.Slimefun.api.inventory.BlockMenu in project FluffyMachines by NCBPFluffyBear.
the class AdvancedAutoDisenchanter method onBreak.
private BlockBreakHandler onBreak() {
return new BlockBreakHandler(false, false) {
@Override
public void onPlayerBreak(@Nonnull BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List<ItemStack> drops) {
Block b = e.getBlock();
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
inv.dropItems(b.getLocation(), ITEM_SLOT);
inv.dropItems(b.getLocation(), BOOK_SLOT);
inv.dropItems(b.getLocation(), OUTPUT_SLOTS);
}
}
};
}
use of me.mrCookieSlime.Slimefun.api.inventory.BlockMenu in project FluffyMachines by NCBPFluffyBear.
the class AdvancedChargingBench method tick.
@Override
protected void tick(Block b) {
if (getCharge(b.getLocation()) < getEnergyConsumption()) {
return;
}
BlockMenu inv = BlockStorage.getInventory(b);
tier = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "tier"));
for (int slot : getInputSlots()) {
ItemStack item = inv.getItemInSlot(slot);
if (charge(b, inv, slot, item, tier)) {
return;
}
}
}
use of me.mrCookieSlime.Slimefun.api.inventory.BlockMenu in project FluffyMachines by NCBPFluffyBear.
the class AutoAncientAltar method craftIfValid.
private void craftIfValid(Block block, boolean craftOnce) {
BlockMenu menu = BlockStorage.getInventory(block);
List<ItemStack> pedestalItems = new ArrayList<>();
// Make sure at least 1 slot is free
for (int outSlot : getOutputSlots()) {
ItemStack outItem = menu.getItemInSlot(outSlot);
if (outItem == null || outItem.getAmount() < outItem.getMaxStackSize()) {
break;
} else if (outSlot == getOutputSlots()[1]) {
return;
}
}
for (int slot : getInputSlots()) {
ItemStack slotItem = menu.getItemInSlot(slot);
if (slotItem == null) {
return;
}
Material type = slotItem.getType();
if (!craftOnce && type.getMaxStackSize() != 1 && slotItem.getAmount() == 1) {
return;
}
}
// Check and append altar items
for (int i = 0; i < 8; i++) {
int slot = mockPedestalSlots[i];
ItemStack pedestalItem = menu.getItemInSlot(slot);
SlimefunItem sfPedestalItem = SlimefunItem.getByItem(pedestalItem);
if (sfPedestalItem != null) {
SlimefunItemStack pedestalItemStack = new SlimefunItemStack(sfPedestalItem.getId(), pedestalItem);
pedestalItems.add(new SlimefunItemStack(pedestalItemStack, 1));
} else {
pedestalItems.add(new CustomItemStack(pedestalItem, 1));
}
}
// Check and append catalyst
int mockAltarSlot = 29;
ItemStack catalystItem = menu.getItemInSlot(mockAltarSlot);
SlimefunItem sfCatalyst = SlimefunItem.getByItem(catalystItem);
ItemStack catalyst;
if (sfCatalyst != null) {
SlimefunItemStack catalystStack = new SlimefunItemStack(sfCatalyst.getId(), catalystItem);
catalyst = new SlimefunItemStack(catalystStack, 1);
} else if (!catalystItem.hasItemMeta()) {
catalyst = new ItemStack(catalystItem.getType(), 1);
} else {
return;
}
if (Constants.isSoulJarsInstalled && sfCatalyst != null && sfCatalyst.getId().startsWith("FILLED") && sfCatalyst.getId().endsWith("SOUL_JAR")) {
try {
EntityType entityType = EntityType.valueOf(sfCatalyst.getId().replace("FILLED_", "").replace("_SOUL_JAR", ""));
if (entityType == EntityType.UNKNOWN) {
return;
}
BrokenSpawner brokenSpawner = SlimefunItems.BROKEN_SPAWNER.getItem(BrokenSpawner.class);
ItemStack spawnerItem = brokenSpawner.getItemForEntityType(entityType);
if (pedestalItems.equals(jarInputs)) {
removeCharge(block.getLocation(), ENERGY_CONSUMPTION);
for (int slot : getInputSlots()) {
menu.consumeItem(slot);
}
menu.pushItem(spawnerItem.clone(), getOutputSlots());
}
} catch (IllegalArgumentException ignored) {
}
} else if (SlimefunUtils.isItemSimilar(catalystItem, SlimefunItems.BROKEN_SPAWNER, false, false)) {
Optional<ItemStack> result = checkRecipe(SlimefunItems.BROKEN_SPAWNER, pedestalItems);
if (result.isPresent()) {
RepairedSpawner spawner = (RepairedSpawner) SlimefunItems.REPAIRED_SPAWNER.getItem();
ItemStack spawnerResult = spawner.getItemForEntityType(spawner.getEntityType(catalystItem).orElse(EntityType.PIG));
craft(block, menu, spawnerResult);
}
} else {
Optional<ItemStack> result = checkRecipe(catalyst, pedestalItems);
result.ifPresent(itemStack -> craft(block, menu, itemStack));
}
}
use of me.mrCookieSlime.Slimefun.api.inventory.BlockMenu in project FluffyMachines by NCBPFluffyBear.
the class AutoCraftingTable method onBreak.
private BlockBreakHandler onBreak() {
return new BlockBreakHandler(false, false) {
@Override
public void onPlayerBreak(@Nonnull BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List<ItemStack> drops) {
Block b = e.getBlock();
BlockMenu inv = BlockStorage.getInventory(b);
Location location = b.getLocation();
if (inv != null) {
inv.dropItems(location, getInputSlots());
inv.dropItems(location, getOutputSlots());
inv.dropItems(location, keySlot);
}
}
};
}
use of me.mrCookieSlime.Slimefun.api.inventory.BlockMenu in project FluffyMachines by NCBPFluffyBear.
the class AutoTableSaw method onBreak.
private BlockBreakHandler onBreak() {
return new BlockBreakHandler(false, false) {
@Override
public void onPlayerBreak(@Nonnull BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List<ItemStack> drops) {
Block b = e.getBlock();
BlockMenu inv = BlockStorage.getInventory(b);
Location location = b.getLocation();
if (inv != null) {
inv.dropItems(location, inputSlots);
inv.dropItems(location, outputSlots);
}
}
};
}
Aggregations