mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Merge pull request #2106 from TheBusyBiscuit/paper
Optimizations for Paper (cargo network optimizations)
This commit is contained in:
commit
a1952edde3
@ -27,6 +27,7 @@
|
|||||||
* Small performance improvements to Energy networks
|
* Small performance improvements to Energy networks
|
||||||
* Big performance improvements to Cargo networks when using ChestTerminal
|
* Big performance improvements to Cargo networks when using ChestTerminal
|
||||||
* Slight changes to /sf timings
|
* Slight changes to /sf timings
|
||||||
|
* Huge performance improvements when using Paper
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed #2075
|
* Fixed #2075
|
||||||
|
11
pom.xml
11
pom.xml
@ -169,6 +169,10 @@
|
|||||||
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
||||||
<shadedPattern>me.mrCookieSlime.Slimefun.cscorelib2</shadedPattern>
|
<shadedPattern>me.mrCookieSlime.Slimefun.cscorelib2</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>io.papermc.lib</pattern>
|
||||||
|
<shadedPattern>io.github.thebusybiscuit.slimefun4.libraries.paperlib</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
|
|
||||||
<!-- Exclude unneeded metadata files from shaded dependencies -->
|
<!-- Exclude unneeded metadata files from shaded dependencies -->
|
||||||
@ -323,6 +327,12 @@
|
|||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.4</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Third party plugin integrations -->
|
<!-- Third party plugin integrations -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -339,6 +349,7 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
@ -21,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
@ -58,10 +59,21 @@ public final class TeleportationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slot = teleporterInventory[index];
|
int slot = teleporterInventory[index];
|
||||||
|
|
||||||
Location l = waypoint.getLocation();
|
Location l = waypoint.getLocation();
|
||||||
menu.addItem(slot,
|
double time = DoubleHandler.fixDouble(0.5 * getTeleportationTime(complexity, source, l));
|
||||||
new CustomItem(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "", "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + DoubleHandler.fixDouble(0.5 * getTeleportationTime(complexity, source, l)) + "s", "", "&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip")));
|
|
||||||
|
String[] lore = {
|
||||||
|
"",
|
||||||
|
"&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(),
|
||||||
|
"&8\u21E8 &7X: &f" + l.getX(),
|
||||||
|
"&8\u21E8 &7Y: &f" + l.getY(),
|
||||||
|
"&8\u21E8 &7Z: &f" + l.getZ(),
|
||||||
|
"&8\u21E8 &7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s",
|
||||||
|
"",
|
||||||
|
"&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip")
|
||||||
|
};
|
||||||
|
|
||||||
|
menu.addItem(slot, new CustomItem(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore));
|
||||||
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
|
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
|
||||||
pl.closeInventory();
|
pl.closeInventory();
|
||||||
teleport(pl.getUniqueId(), complexity, source, l, false);
|
teleport(pl.getUniqueId(), complexity, source, l, false);
|
||||||
@ -117,16 +129,24 @@ public final class TeleportationManager {
|
|||||||
if (isValid(p, source)) {
|
if (isValid(p, source)) {
|
||||||
if (progress > 99) {
|
if (progress > 99) {
|
||||||
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20);
|
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20);
|
||||||
p.teleport(destination);
|
|
||||||
|
|
||||||
if (resistance) {
|
PaperLib.teleportAsync(p, destination).thenAccept(teleported -> {
|
||||||
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
|
if (teleported.booleanValue()) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
|
// This needs to run on the main Thread so we force it, as the
|
||||||
}
|
// async teleportation might happen on a seperate Thread.
|
||||||
|
Slimefun.runSync(() -> {
|
||||||
|
if (resistance) {
|
||||||
|
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
|
||||||
|
}
|
||||||
|
|
||||||
destination.getWorld().spawnParticle(Particle.PORTAL, new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()), progress * 2, 0.2F, 0.8F, 0.2F);
|
Location loc = new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ());
|
||||||
destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F);
|
destination.getWorld().spawnParticle(Particle.PORTAL, loc, progress * 2, 0.2F, 0.8F, 0.2F);
|
||||||
teleporterUsers.remove(uuid);
|
destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F);
|
||||||
|
teleporterUsers.remove(uuid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0);
|
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0);
|
||||||
|
@ -13,6 +13,7 @@ import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
class VersionsCommand extends SubCommand {
|
class VersionsCommand extends SubCommand {
|
||||||
|
|
||||||
@ -33,7 +34,10 @@ class VersionsCommand extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(CommandSender sender, String[] args) {
|
||||||
if (sender.hasPermission("slimefun.command.versions") || sender instanceof ConsoleCommandSender) {
|
if (sender.hasPermission("slimefun.command.versions") || sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage(ChatColors.color("&a" + Bukkit.getName() + " &2" + ReflectionUtils.getVersion()));
|
// After all these years... Spigot still displays as "CraftBukkit"
|
||||||
|
// so we will just fix this inconsistency for them :)
|
||||||
|
String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName();
|
||||||
|
sender.sendMessage(ChatColors.color("&a" + serverSoftware + " &2" + ReflectionUtils.getVersion()));
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion()));
|
sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion()));
|
||||||
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion()));
|
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion()));
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.data.type.Dispenser;
|
import org.bukkit.block.data.type.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -22,6 +23,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -153,10 +155,14 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace
|
|||||||
|
|
||||||
if (id != null && id.equals("OUTPUT_CHEST")) {
|
if (id != null && id.equals("OUTPUT_CHEST")) {
|
||||||
// Found the output chest! Now, let's check if we can fit the product in it.
|
// Found the output chest! Now, let's check if we can fit the product in it.
|
||||||
Inventory inv = ((Chest) potentialOutput.getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(potentialOutput, false).getState();
|
||||||
|
|
||||||
if (InvUtils.fits(inv, output)) {
|
if (state instanceof Chest) {
|
||||||
return inv;
|
Inventory inv = ((Chest) state).getInventory();
|
||||||
|
|
||||||
|
if (InvUtils.fits(inv, output)) {
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -93,7 +94,7 @@ final class CargoUtils {
|
|||||||
return withdrawFromVanillaInventory(node, template, inventory);
|
return withdrawFromVanillaInventory(node, template, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
inventory = ((InventoryHolder) state).getInventory();
|
inventory = ((InventoryHolder) state).getInventory();
|
||||||
@ -181,7 +182,7 @@ final class CargoUtils {
|
|||||||
return withdrawFromVanillaInventory(node, inventory);
|
return withdrawFromVanillaInventory(node, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
inventory = ((InventoryHolder) state).getInventory();
|
inventory = ((InventoryHolder) state).getInventory();
|
||||||
@ -233,7 +234,7 @@ final class CargoUtils {
|
|||||||
return insertIntoVanillaInventory(stack, inventory);
|
return insertIntoVanillaInventory(stack, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
inventory = ((InventoryHolder) state).getInventory();
|
inventory = ((InventoryHolder) state).getInventory();
|
||||||
@ -249,7 +250,7 @@ final class CargoUtils {
|
|||||||
|
|
||||||
for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.INSERT, wrapper)) {
|
for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.INSERT, wrapper)) {
|
||||||
ItemStack itemInSlot = menu.getItemInSlot(slot);
|
ItemStack itemInSlot = menu.getItemInSlot(slot);
|
||||||
|
|
||||||
if (itemInSlot == null) {
|
if (itemInSlot == null) {
|
||||||
menu.replaceExistingItem(slot, stack);
|
menu.replaceExistingItem(slot, stack);
|
||||||
return null;
|
return null;
|
||||||
|
@ -32,6 +32,7 @@ import io.github.thebusybiscuit.slimefun4.api.network.Network;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -382,7 +383,7 @@ abstract class ChestTerminalNetwork extends Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CargoUtils.hasInventory(target)) {
|
else if (CargoUtils.hasInventory(target)) {
|
||||||
BlockState state = target.getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
if (state instanceof InventoryHolder) {
|
if (state instanceof InventoryHolder) {
|
||||||
Inventory inv = ((InventoryHolder) state).getInventory();
|
Inventory inv = ((InventoryHolder) state).getInventory();
|
||||||
|
@ -89,6 +89,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||||
@ -164,6 +165,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
}
|
}
|
||||||
else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
||||||
long timestamp = System.nanoTime();
|
long timestamp = System.nanoTime();
|
||||||
|
|
||||||
|
PaperLib.suggestPaper(this);
|
||||||
|
|
||||||
// We wanna ensure that the Server uses a compatible version of Minecraft
|
// We wanna ensure that the Server uses a compatible version of Minecraft
|
||||||
if (isVersionUnsupported()) {
|
if (isVersionUnsupported()) {
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Rotatable;
|
import org.bukkit.block.data.Rotatable;
|
||||||
@ -36,6 +37,7 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
|
||||||
@ -689,19 +691,23 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
|
|
||||||
protected void depositItems(BlockMenu menu, Block facedBlock) {
|
protected void depositItems(BlockMenu menu, Block facedBlock) {
|
||||||
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_ITEMS")) {
|
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_ITEMS")) {
|
||||||
Dispenser d = (Dispenser) facedBlock.getState();
|
BlockState state = PaperLib.getBlockState(facedBlock, false).getState();
|
||||||
|
|
||||||
for (int slot : getOutputSlots()) {
|
if (state instanceof Dispenser) {
|
||||||
ItemStack stack = menu.getItemInSlot(slot);
|
Dispenser d = (Dispenser) state;
|
||||||
|
|
||||||
if (stack != null) {
|
for (int slot : getOutputSlots()) {
|
||||||
Optional<ItemStack> optional = d.getInventory().addItem(stack).values().stream().findFirst();
|
ItemStack stack = menu.getItemInSlot(slot);
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
if (stack != null) {
|
||||||
menu.replaceExistingItem(slot, optional.get());
|
Optional<ItemStack> optional = d.getInventory().addItem(stack).values().stream().findFirst();
|
||||||
}
|
|
||||||
else {
|
if (optional.isPresent()) {
|
||||||
menu.replaceExistingItem(slot, null);
|
menu.replaceExistingItem(slot, optional.get());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
menu.replaceExistingItem(slot, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,13 +716,17 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
|||||||
|
|
||||||
protected void refuel(BlockMenu menu, Block facedBlock) {
|
protected void refuel(BlockMenu menu, Block facedBlock) {
|
||||||
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_FUEL")) {
|
if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_FUEL")) {
|
||||||
Dispenser d = (Dispenser) facedBlock.getState();
|
BlockState state = PaperLib.getBlockState(facedBlock, false).getState();
|
||||||
|
|
||||||
for (int slot = 0; slot < 9; slot++) {
|
if (state instanceof Dispenser) {
|
||||||
ItemStack item = d.getInventory().getItem(slot);
|
Dispenser d = (Dispenser) state;
|
||||||
|
|
||||||
if (item != null) {
|
for (int slot = 0; slot < 9; slot++) {
|
||||||
insertFuel(menu, d.getInventory(), slot, menu.getItemInSlot(43), item);
|
ItemStack item = d.getInventory().getItem(slot);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
insertFuel(menu, d.getInventory(), slot, menu.getItemInSlot(43), item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -24,6 +25,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -129,10 +131,14 @@ public class Composter extends SimpleSlimefunItem<BlockUseHandler> implements Re
|
|||||||
|
|
||||||
if (id != null && id.equals("OUTPUT_CHEST")) {
|
if (id != null && id.equals("OUTPUT_CHEST")) {
|
||||||
// Found the output chest! Now, let's check if we can fit the product in it.
|
// Found the output chest! Now, let's check if we can fit the product in it.
|
||||||
Inventory inv = ((Chest) potentialOutput.getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(potentialOutput, false).getState();
|
||||||
|
|
||||||
if (InvUtils.fits(inv, output)) {
|
if (state instanceof Chest) {
|
||||||
return Optional.of(inv);
|
Inventory inv = ((Chest) state).getInventory();
|
||||||
|
|
||||||
|
if (InvUtils.fits(inv, output)) {
|
||||||
|
return Optional.of(inv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
@ -134,8 +135,12 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
yaw = -180 + (yaw - 180);
|
yaw = -180 + (yaw - 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.teleport(new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch()));
|
Location destination = new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch());
|
||||||
player.sendTitle(ChatColor.WHITE + ChatColors.color(floor), " ", 20, 60, 20);
|
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
|
||||||
|
if (teleported.booleanValue()) {
|
||||||
|
player.sendTitle(ChatColor.WHITE + ChatColors.color(floor), null, 20, 60, 20);
|
||||||
|
}
|
||||||
|
});
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Effect;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -15,6 +16,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -35,30 +37,34 @@ abstract class AbstractSmeltery extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
|
||||||
|
|
||||||
for (int i = 0; i < inputs.size(); i++) {
|
if (state instanceof Dispenser) {
|
||||||
if (canCraft(inv, inputs, i)) {
|
Dispenser disp = (Dispenser) state;
|
||||||
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
Inventory inv = disp.getInventory();
|
||||||
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
|
|
||||||
if (Slimefun.hasUnlocked(p, output, true)) {
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
if (canCraft(inv, inputs, i)) {
|
||||||
|
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||||
|
|
||||||
if (outputInv != null) {
|
if (Slimefun.hasUnlocked(p, output, true)) {
|
||||||
craft(p, b, inv, inputs.get(i), output, outputInv);
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
}
|
|
||||||
else {
|
if (outputInv != null) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
craft(p, b, inv, inputs.get(i), output, outputInv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canCraft(Inventory inv, List<ItemStack[]> inputs, int i) {
|
private boolean canCraft(Inventory inv, List<ItemStack[]> inputs, int i) {
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -16,6 +17,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -24,40 +26,40 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class ArmorForge extends MultiBlockMachine {
|
public class ArmorForge extends MultiBlockMachine {
|
||||||
|
|
||||||
public ArmorForge(Category category, SlimefunItemStack item) {
|
public ArmorForge(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] {
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[0], BlockFace.SELF);
|
||||||
null, null, null,
|
|
||||||
null, new ItemStack(Material.ANVIL), null,
|
|
||||||
null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null
|
|
||||||
}, new ItemStack[0], BlockFace.SELF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
|
||||||
|
|
||||||
for (int i = 0; i < inputs.size(); i++) {
|
if (state instanceof Dispenser) {
|
||||||
if (isCraftable(inv, inputs.get(i))) {
|
Dispenser disp = (Dispenser) state;
|
||||||
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
Inventory inv = disp.getInventory();
|
||||||
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
|
|
||||||
if (Slimefun.hasUnlocked(p, output, true)) {
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
if (isCraftable(inv, inputs.get(i))) {
|
||||||
|
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||||
|
|
||||||
if (outputInv != null) {
|
if (Slimefun.hasUnlocked(p, output, true)) {
|
||||||
craft(p, output, inv, outputInv);
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
}
|
|
||||||
else {
|
if (outputInv != null) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
craft(p, output, inv, outputInv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCraftable(Inventory inv, ItemStack[] recipe) {
|
private boolean isCraftable(Inventory inv, ItemStack[] recipe) {
|
||||||
@ -73,7 +75,7 @@ public class ArmorForge extends MultiBlockMachine {
|
|||||||
private void craft(Player p, ItemStack output, Inventory inv, Inventory outputInv) {
|
private void craft(Player p, ItemStack output, Inventory inv, Inventory outputInv) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
ItemStack item = inv.getContents()[j];
|
ItemStack item = inv.getContents()[j];
|
||||||
|
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
ItemUtils.consumeItem(item, true);
|
ItemUtils.consumeItem(item, true);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine {
|
|||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
ItemStack input = p.getInventory().getItemInMainHand();
|
ItemStack input = p.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.GRAVEL), true) || SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SOUL_SAND), true)) {
|
if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.GRAVEL), true, false) || SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SOUL_SAND), true, false)) {
|
||||||
Material material = input.getType();
|
Material material = input.getType();
|
||||||
|
|
||||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,6 +18,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
@ -24,61 +26,58 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
|
|
||||||
public class Compressor extends MultiBlockMachine {
|
public class Compressor extends MultiBlockMachine {
|
||||||
|
|
||||||
public Compressor(Category category, SlimefunItemStack item) {
|
public Compressor(Category category, SlimefunItemStack item) {
|
||||||
super(category, item,
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, new ItemStack[] { new CustomItem(SlimefunItems.STONE_CHUNK, 4), new ItemStack(Material.COBBLESTONE), new ItemStack(Material.FLINT, 8), new ItemStack(Material.COBBLESTONE) }, BlockFace.SELF);
|
||||||
new ItemStack[] {null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON)},
|
}
|
||||||
new ItemStack[] {
|
|
||||||
new CustomItem(SlimefunItems.STONE_CHUNK, 4), new ItemStack(Material.COBBLESTONE),
|
|
||||||
new ItemStack(Material.FLINT, 8), new ItemStack(Material.COBBLESTONE)
|
|
||||||
},
|
|
||||||
BlockFace.SELF
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
|
||||||
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInteract(Player p, Block b) {
|
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
|
||||||
for (ItemStack item : inv.getContents()) {
|
|
||||||
for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) {
|
|
||||||
if (recipeInput != null && SlimefunUtils.isItemSimilar(item, recipeInput, true)) {
|
|
||||||
ItemStack output = RecipeType.getRecipeOutput(this, recipeInput);
|
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
|
||||||
|
|
||||||
if (outputInv != null) {
|
|
||||||
ItemStack removing = item.clone();
|
|
||||||
removing.setAmount(recipeInput.getAmount());
|
|
||||||
inv.removeItem(removing);
|
|
||||||
|
|
||||||
craft(p, output, outputInv);
|
@Override
|
||||||
}
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
else {
|
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
return;
|
public void onInteract(Player p, Block b) {
|
||||||
}
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
}
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
}
|
|
||||||
|
if (state instanceof Dispenser) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
Dispenser disp = (Dispenser) state;
|
||||||
}
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
|
for (ItemStack item : inv.getContents()) {
|
||||||
|
for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) {
|
||||||
|
if (recipeInput != null && SlimefunUtils.isItemSimilar(item, recipeInput, true)) {
|
||||||
|
ItemStack output = RecipeType.getRecipeOutput(this, recipeInput);
|
||||||
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
|
if (outputInv != null) {
|
||||||
|
ItemStack removing = item.clone();
|
||||||
|
removing.setAmount(recipeInput.getAmount());
|
||||||
|
inv.removeItem(removing);
|
||||||
|
|
||||||
|
craft(p, output, outputInv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void craft(Player p, ItemStack output, Inventory outputInv) {
|
private void craft(Player p, ItemStack output, Inventory outputInv) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
|
||||||
Slimefun.runSync(() -> {
|
Slimefun.runSync(() -> {
|
||||||
if (j < 3) {
|
if (j < 3) {
|
||||||
p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F);
|
p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||||
outputInv.addItem(output);
|
outputInv.addItem(output);
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -15,6 +16,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -30,22 +32,26 @@ public class EnhancedCraftingTable extends BackpackCrafter {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispenser = b.getRelative(BlockFace.DOWN);
|
Block dispenser = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispenser.getState();
|
BlockState state = PaperLib.getBlockState(dispenser, false).getState();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
if (state instanceof Dispenser) {
|
||||||
|
Dispenser disp = (Dispenser) state;
|
||||||
|
Inventory inv = disp.getInventory();
|
||||||
|
|
||||||
for (int i = 0; i < inputs.size(); i++) {
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
if (isCraftable(inv, inputs.get(i))) {
|
|
||||||
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
if (Slimefun.hasUnlocked(p, output, true)) {
|
if (isCraftable(inv, inputs.get(i))) {
|
||||||
craft(inv, dispenser, p, b, output);
|
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||||
|
if (Slimefun.hasUnlocked(p, output, true)) {
|
||||||
|
craft(inv, dispenser, p, b, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,67 +18,54 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
public class GrindStone extends MultiBlockMachine {
|
public class GrindStone extends MultiBlockMachine {
|
||||||
|
|
||||||
public GrindStone(Category category, SlimefunItemStack item) {
|
public GrindStone(Category category, SlimefunItemStack item) {
|
||||||
super(category, item,
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[] { new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4), new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4), new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT), new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2), new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL), new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL), new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL), new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL), new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK, new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4), new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4), new ItemStack(Material.PRISMARINE_BRICKS), new ItemStack(Material.PRISMARINE, 2), new ItemStack(Material.PRISMARINE), new ItemStack(Material.PRISMARINE_SHARD, 4) }, BlockFace.SELF);
|
||||||
new ItemStack[] {null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null},
|
}
|
||||||
new ItemStack[] {
|
|
||||||
new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4),
|
@Override
|
||||||
new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4),
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT),
|
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
||||||
new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2),
|
}
|
||||||
new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL),
|
|
||||||
new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL),
|
@Override
|
||||||
new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL),
|
public void onInteract(Player p, Block b) {
|
||||||
new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL),
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK,
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4),
|
|
||||||
new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4),
|
if (state instanceof Dispenser) {
|
||||||
new ItemStack(Material.PRISMARINE_BRICKS), new ItemStack(Material.PRISMARINE, 2),
|
Dispenser disp = (Dispenser) state;
|
||||||
new ItemStack(Material.PRISMARINE), new ItemStack(Material.PRISMARINE_SHARD, 4)
|
Inventory inv = disp.getInventory();
|
||||||
},
|
|
||||||
BlockFace.SELF
|
for (ItemStack current : inv.getContents()) {
|
||||||
);
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
}
|
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
||||||
|
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
||||||
@Override
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
|
||||||
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
if (outputInv != null) {
|
||||||
}
|
ItemStack removing = current.clone();
|
||||||
|
removing.setAmount(1);
|
||||||
@Override
|
inv.removeItem(removing);
|
||||||
public void onInteract(Player p, Block b) {
|
outputInv.addItem(output);
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
}
|
||||||
Inventory inv = disp.getInventory();
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
for (ItemStack current : inv.getContents()) {
|
}
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
|
||||||
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
return;
|
||||||
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
}
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
}
|
||||||
|
}
|
||||||
if (outputInv != null) {
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
ItemStack removing = current.clone();
|
}
|
||||||
removing.setAmount(1);
|
}
|
||||||
inv.removeItem(removing);
|
|
||||||
outputInv.addItem(output);
|
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,53 +18,56 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
public class Juicer extends MultiBlockMachine {
|
public class Juicer extends MultiBlockMachine {
|
||||||
|
|
||||||
public Juicer(Category category, SlimefunItemStack item) {
|
public Juicer(Category category, SlimefunItemStack item) {
|
||||||
super(category, item,
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[0], BlockFace.SELF);
|
||||||
new ItemStack[] {null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null},
|
}
|
||||||
new ItemStack[0],
|
|
||||||
BlockFace.SELF
|
@Override
|
||||||
);
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
}
|
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
@Override
|
||||||
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
public void onInteract(Player p, Block b) {
|
||||||
}
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
@Override
|
|
||||||
public void onInteract(Player p, Block b) {
|
if (state instanceof Dispenser) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Dispenser disp = (Dispenser) state;
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
Inventory inv = disp.getInventory();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
for (ItemStack current : inv.getContents()) {
|
||||||
for (ItemStack current : inv.getContents()) {
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
||||||
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||||
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
|
||||||
|
if (outputInv != null) {
|
||||||
if (outputInv != null) {
|
ItemStack removing = current.clone();
|
||||||
ItemStack removing = current.clone();
|
removing.setAmount(1);
|
||||||
removing.setAmount(1);
|
inv.removeItem(removing);
|
||||||
inv.removeItem(removing);
|
outputInv.addItem(adding);
|
||||||
outputInv.addItem(adding);
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK);
|
}
|
||||||
}
|
else {
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
return;
|
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
|
||||||
}
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -17,6 +17,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -38,21 +39,27 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv = ((Dispenser) dispenser.getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(dispenser, false).getState();
|
||||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
|
||||||
|
|
||||||
for (int i = 0; i < inputs.size(); i++) {
|
if (state instanceof Dispenser) {
|
||||||
if (isCraftable(inv, inputs.get(i))) {
|
Dispenser disp = (Dispenser) state;
|
||||||
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
Inventory inv = disp.getInventory();
|
||||||
|
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||||
|
|
||||||
if (Slimefun.hasUnlocked(p, output, true)) {
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
craft(inv, dispenser, p, b, output);
|
if (isCraftable(inv, inputs.get(i))) {
|
||||||
|
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||||
|
|
||||||
|
if (Slimefun.hasUnlocked(p, output, true)) {
|
||||||
|
craft(inv, dispenser, p, b, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) {
|
||||||
@ -68,20 +75,26 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
|
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) {
|
if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) {
|
||||||
if (inv.getContents()[j].getAmount() > 1) inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1));
|
if (inv.getContents()[j].getAmount() > 1) {
|
||||||
else inv.setItem(j, null);
|
inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inv.setItem(j, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startAnimation(p, b, outputInv, output);
|
startAnimation(p, b, outputInv, output);
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) {
|
private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) {
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
int current = j;
|
int current = j;
|
||||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance(), () -> {
|
Slimefun.runSync(() -> {
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
|
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
|
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
|
||||||
|
|
||||||
@ -99,10 +112,18 @@ public class MagicWorkbench extends BackpackCrafter {
|
|||||||
private Block locateDispenser(Block b) {
|
private Block locateDispenser(Block b) {
|
||||||
Block block = null;
|
Block block = null;
|
||||||
|
|
||||||
if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) block = b.getRelative(1, 0, 0);
|
if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) {
|
||||||
else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) block = b.getRelative(0, 0, 1);
|
block = b.getRelative(1, 0, 0);
|
||||||
else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) block = b.getRelative(-1, 0, 0);
|
}
|
||||||
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) block = b.getRelative(0, 0, -1);
|
else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) {
|
||||||
|
block = b.getRelative(0, 0, 1);
|
||||||
|
}
|
||||||
|
else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) {
|
||||||
|
block = b.getRelative(-1, 0, 0);
|
||||||
|
}
|
||||||
|
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) {
|
||||||
|
block = b.getRelative(0, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.Effect;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -20,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -62,29 +64,35 @@ public class OreCrusher extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
if (state instanceof Dispenser) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
Dispenser disp = (Dispenser) state;
|
||||||
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
Inventory inv = disp.getInventory();
|
||||||
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
|
||||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
for (ItemStack current : inv.getContents()) {
|
||||||
if (outputInv != null) {
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
ItemStack removing = current.clone();
|
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
||||||
removing.setAmount(convert.getAmount());
|
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||||
inv.removeItem(removing);
|
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||||
outputInv.addItem(adding);
|
if (outputInv != null) {
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1);
|
ItemStack removing = current.clone();
|
||||||
|
removing.setAmount(convert.getAmount());
|
||||||
|
inv.removeItem(removing);
|
||||||
|
outputInv.addItem(adding);
|
||||||
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DoubleOreSetting extends ItemSetting<Boolean> {
|
private class DoubleOreSetting extends ItemSetting<Boolean> {
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -18,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
@ -41,57 +43,62 @@ public class OreWasher extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.UP);
|
Block dispBlock = b.getRelative(BlockFace.UP);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
|
||||||
for (ItemStack input : inv.getContents()) {
|
if (state instanceof Dispenser) {
|
||||||
if (input != null) {
|
Dispenser disp = (Dispenser) state;
|
||||||
if (SlimefunUtils.isItemSimilar(input, SlimefunItems.SIFTED_ORE, true)) {
|
Inventory inv = disp.getInventory();
|
||||||
ItemStack output = getRandomDust();
|
|
||||||
Inventory outputInv = null;
|
|
||||||
|
|
||||||
if (!legacyMode) {
|
for (ItemStack input : inv.getContents()) {
|
||||||
// This is a fancy way of checking if there is empty space in the inv; by checking if an
|
if (input != null) {
|
||||||
// unobtainable item could fit in it.
|
if (SlimefunUtils.isItemSimilar(input, SlimefunItems.SIFTED_ORE, true)) {
|
||||||
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will never
|
ItemStack output = getRandomDust();
|
||||||
// actually be added to the real inventory,
|
Inventory outputInv = null;
|
||||||
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH
|
|
||||||
// however, signals that it's
|
if (!legacyMode) {
|
||||||
// not supposed to be given to the player.
|
// This is a fancy way of checking if there is empty space in the inv; by checking if an
|
||||||
ItemStack dummyAdding = SlimefunItems.DEBUG_FISH;
|
// unobtainable item could fit in it.
|
||||||
outputInv = findOutputInventory(dummyAdding, dispBlock, inv);
|
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will
|
||||||
|
// never
|
||||||
|
// actually be added to the real inventory,
|
||||||
|
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH
|
||||||
|
// however, signals that it's
|
||||||
|
// not supposed to be given to the player.
|
||||||
|
ItemStack dummyAdding = SlimefunItems.DEBUG_FISH;
|
||||||
|
outputInv = findOutputInventory(dummyAdding, dispBlock, inv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeItem(p, b, inv, outputInv, input, output, 1);
|
||||||
|
|
||||||
|
if (outputInv != null) {
|
||||||
|
outputInv.addItem(SlimefunItems.STONE_CHUNK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) {
|
||||||
outputInv = findOutputInventory(output, dispBlock, inv);
|
ItemStack output = SlimefunItems.SALT;
|
||||||
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
|
removeItem(p, b, inv, outputInv, input, output, 2);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) {
|
||||||
|
ItemStack output = SlimefunItems.PURE_ORE_CLUSTER;
|
||||||
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
removeItem(p, b, inv, outputInv, input, output, 1);
|
removeItem(p, b, inv, outputInv, input, output, 1);
|
||||||
|
|
||||||
if (outputInv != null) {
|
return;
|
||||||
outputInv.addItem(SlimefunItems.STONE_CHUNK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) {
|
|
||||||
ItemStack output = SlimefunItems.SALT;
|
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
|
||||||
|
|
||||||
removeItem(p, b, inv, outputInv, input, output, 2);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) {
|
|
||||||
ItemStack output = SlimefunItems.PURE_ORE_CLUSTER;
|
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
|
||||||
|
|
||||||
removeItem(p, b, inv, outputInv, input, output, 1);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputInv, ItemStack input, ItemStack output, int amount) {
|
private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputInv, ItemStack input, ItemStack output, int amount) {
|
||||||
|
@ -3,12 +3,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -19,18 +19,17 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
public class PressureChamber extends MultiBlockMachine {
|
public class PressureChamber extends MultiBlockMachine {
|
||||||
|
|
||||||
public PressureChamber(Category category, SlimefunItemStack item) {
|
public PressureChamber(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] {
|
super(category, item, new ItemStack[] { SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion()
|
||||||
SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB),
|
.isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, new ItemStack[0], BlockFace.UP);
|
||||||
new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON),
|
|
||||||
new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON)
|
|
||||||
}, new ItemStack[0], BlockFace.UP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,36 +40,42 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(Player p, Block b) {
|
||||||
Block dispBlock = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
|
Block dispBlock = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
if (state instanceof Dispenser) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
Dispenser disp = (Dispenser) state;
|
||||||
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
Inventory inv = disp.getInventory();
|
||||||
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
|
||||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
|
||||||
|
|
||||||
if (outputInv != null) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
ItemStack removing = current.clone();
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
removing.setAmount(convert.getAmount());
|
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
|
||||||
inv.removeItem(removing);
|
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
||||||
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
craft(p, b, output, outputInv);
|
if (outputInv != null) {
|
||||||
|
ItemStack removing = current.clone();
|
||||||
|
removing.setAmount(convert.getAmount());
|
||||||
|
inv.removeItem(removing);
|
||||||
|
|
||||||
|
craft(p, b, output, outputInv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
||||||
}
|
}
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void craft(Player p, Block b, ItemStack output, Inventory outputInv) {
|
private void craft(Player p, Block b, ItemStack output, Inventory outputInv) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance(), () -> {
|
Slimefun.runSync(() -> {
|
||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
||||||
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
||||||
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dropper;
|
import org.bukkit.block.Dropper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -22,6 +23,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -97,7 +99,11 @@ public class Smeltery extends AbstractSmeltery {
|
|||||||
private Inventory findIgnitionChamber(Block b) {
|
private Inventory findIgnitionChamber(Block b) {
|
||||||
for (BlockFace face : faces) {
|
for (BlockFace face : faces) {
|
||||||
if (b.getRelative(face).getType() == Material.DROPPER && BlockStorage.check(b.getRelative(face), "IGNITION_CHAMBER")) {
|
if (b.getRelative(face).getType() == Material.DROPPER && BlockStorage.check(b.getRelative(face), "IGNITION_CHAMBER")) {
|
||||||
return ((Dropper) b.getRelative(face).getState()).getInventory();
|
BlockState state = PaperLib.getBlockState(b.getRelative(face), false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dropper) {
|
||||||
|
return ((Dropper) state).getInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.Particle;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.data.type.Piston;
|
import org.bukkit.block.data.type.Piston;
|
||||||
import org.bukkit.block.data.type.PistonHead;
|
import org.bukkit.block.data.type.PistonHead;
|
||||||
@ -24,6 +25,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
|
import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
@ -251,14 +253,22 @@ class ActiveMiner implements Runnable {
|
|||||||
// Check if there is enough fuel to run
|
// Check if there is enough fuel to run
|
||||||
if (fuel > 0) {
|
if (fuel > 0) {
|
||||||
if (chest.getType() == Material.CHEST) {
|
if (chest.getType() == Material.CHEST) {
|
||||||
Inventory inv = ((Chest) chest.getState()).getBlockInventory();
|
BlockState state = PaperLib.getBlockState(chest, false).getState();
|
||||||
|
|
||||||
if (InvUtils.fits(inv, item)) {
|
if (state instanceof Chest) {
|
||||||
inv.addItem(item);
|
Inventory inv = ((Chest) state).getBlockInventory();
|
||||||
return true;
|
|
||||||
|
if (InvUtils.fits(inv, item)) {
|
||||||
|
inv.addItem(item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stop("machines.INDUSTRIAL_MINER.chest-full");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stop("machines.INDUSTRIAL_MINER.chest-full");
|
// I won't question how this happened...
|
||||||
|
stop("machines.INDUSTRIAL_MINER.destroyed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -280,20 +290,24 @@ class ActiveMiner implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private int consumeFuel() {
|
private int consumeFuel() {
|
||||||
if (chest.getType() == Material.CHEST) {
|
if (chest.getType() == Material.CHEST) {
|
||||||
Inventory inv = ((Chest) chest.getState()).getBlockInventory();
|
BlockState state = PaperLib.getBlockState(chest, false).getState();
|
||||||
|
|
||||||
for (int i = 0; i < inv.getSize(); i++) {
|
if (state instanceof Chest) {
|
||||||
for (MachineFuel fuelType : miner.fuelTypes) {
|
Inventory inv = ((Chest) state).getBlockInventory();
|
||||||
ItemStack item = inv.getContents()[i];
|
|
||||||
|
|
||||||
if (fuelType.test(item)) {
|
for (int i = 0; i < inv.getSize(); i++) {
|
||||||
ItemUtils.consumeItem(item, false);
|
for (MachineFuel fuelType : miner.fuelTypes) {
|
||||||
|
ItemStack item = inv.getContents()[i];
|
||||||
|
|
||||||
if (miner instanceof AdvancedIndustrialMiner) {
|
if (fuelType.test(item)) {
|
||||||
inv.addItem(new ItemStack(Material.BUCKET));
|
ItemUtils.consumeItem(item, false);
|
||||||
|
|
||||||
|
if (miner instanceof AdvancedIndustrialMiner) {
|
||||||
|
inv.addItem(new ItemStack(Material.BUCKET));
|
||||||
|
}
|
||||||
|
|
||||||
|
return fuelType.getTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
return fuelType.getTicks();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -15,6 +17,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunIte
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -65,7 +68,10 @@ public class PickaxeOfContainment extends SimpleSlimefunItem<BlockBreakHandler>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (e.getBlock().getType() == Material.SPAWNER) e.setDropItems(false);
|
if (e.getBlock().getType() == Material.SPAWNER) {
|
||||||
|
e.setDropItems(false);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,15 +90,24 @@ public class PickaxeOfContainment extends SimpleSlimefunItem<BlockBreakHandler>
|
|||||||
ItemMeta im = spawner.getItemMeta();
|
ItemMeta im = spawner.getItemMeta();
|
||||||
List<String> lore = im.getLore();
|
List<String> lore = im.getLore();
|
||||||
|
|
||||||
for (int i = 0; i < lore.size(); i++) {
|
BlockState state = PaperLib.getBlockState(b, false).getState();
|
||||||
if (lore.get(i).contains("<Type>")) {
|
|
||||||
lore.set(i, lore.get(i).replace("<Type>", ChatUtils.humanize(((CreatureSpawner) b.getState()).getSpawnedType().toString())));
|
if (state instanceof CreatureSpawner) {
|
||||||
|
EntityType entityType = ((CreatureSpawner) state).getSpawnedType();
|
||||||
|
|
||||||
|
for (int i = 0; i < lore.size(); i++) {
|
||||||
|
if (lore.get(i).contains("<Type>")) {
|
||||||
|
lore.set(i, lore.get(i).replace("<Type>", ChatUtils.humanize(entityType.name())));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
im.setLore(lore);
|
||||||
|
spawner.setItemMeta(im);
|
||||||
|
return spawner;
|
||||||
}
|
}
|
||||||
|
|
||||||
im.setLore(lore);
|
return new ItemStack(Material.SPAWNER);
|
||||||
spawner.setItemMeta(im);
|
|
||||||
return spawner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.block.data.Directional;
|
import org.bukkit.block.data.Directional;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -11,6 +12,7 @@ import org.bukkit.event.block.BlockDispenseEvent;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
|
||||||
@ -39,10 +41,14 @@ public class DispenserListener implements Listener {
|
|||||||
|
|
||||||
if (machine != null) {
|
if (machine != null) {
|
||||||
machine.callItemHandler(BlockDispenseHandler.class, handler -> {
|
machine.callItemHandler(BlockDispenseHandler.class, handler -> {
|
||||||
Dispenser dispenser = (Dispenser) b.getState();
|
BlockState state = PaperLib.getBlockState(b, false).getState();
|
||||||
BlockFace face = ((Directional) b.getBlockData()).getFacing();
|
|
||||||
Block block = b.getRelative(face);
|
if (state instanceof Dispenser) {
|
||||||
handler.onBlockDispense(e, dispenser, block, machine);
|
Dispenser dispenser = (Dispenser) state;
|
||||||
|
BlockFace face = ((Directional) b.getBlockData()).getFacing();
|
||||||
|
Block block = b.getRelative(face);
|
||||||
|
handler.onBlockDispense(e, dispenser, block, machine);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user