mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Added Iron Golem Assembler (experimental)
This commit is contained in:
commit
1f7b75b823
@ -27,6 +27,8 @@
|
|||||||
* Added Bee protection to Hazmat Suit
|
* Added Bee protection to Hazmat Suit
|
||||||
* Added Enchantment Rune
|
* Added Enchantment Rune
|
||||||
* Added Tape Measure
|
* Added Tape Measure
|
||||||
|
* Added "Bone Block -> Bone meal" recipe to the Grind Stone
|
||||||
|
* Added Iron Golem Assembler
|
||||||
|
|
||||||
#### Changes
|
#### Changes
|
||||||
* Refactored and reworked the Generator API
|
* Refactored and reworked the Generator API
|
||||||
@ -36,11 +38,16 @@
|
|||||||
* Changed recipe of Hazmat Suits
|
* Changed recipe of Hazmat Suits
|
||||||
* Uranium can no longer be placed down
|
* Uranium can no longer be placed down
|
||||||
* Huge performance improvements when using Paper
|
* Huge performance improvements when using Paper
|
||||||
|
* Optimized Cargo networks for Paper
|
||||||
|
* Optimized Multiblocks for Paper
|
||||||
|
* Optimized Enhanced Furnaces for Paper
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed Slimefun Armor sometimes not applying its effects
|
* Fixed Slimefun Armor sometimes not applying its effects
|
||||||
* Fixed #2075
|
* Fixed #2075
|
||||||
* Fixed #2093
|
* Fixed #2093
|
||||||
|
* Fixed #2086
|
||||||
|
* Fixed #1894
|
||||||
|
|
||||||
## Release Candidate 14 (12 Jul 2020)
|
## Release Candidate 14 (12 Jul 2020)
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player player;
|
private final Player player;
|
||||||
private Research research;
|
private final Research research;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -28,8 +28,8 @@ public class Waypoint {
|
|||||||
|
|
||||||
private final PlayerProfile profile;
|
private final PlayerProfile profile;
|
||||||
private final String id;
|
private final String id;
|
||||||
private String name;
|
private final String name;
|
||||||
private Location location;
|
private final Location location;
|
||||||
|
|
||||||
public Waypoint(PlayerProfile profile, String id, Location l, String name) {
|
public Waypoint(PlayerProfile profile, String id, Location l, String name) {
|
||||||
Validate.notNull(profile, "Profile must never be null!");
|
Validate.notNull(profile, "Profile must never be null!");
|
||||||
|
@ -29,7 +29,7 @@ public abstract class Network {
|
|||||||
|
|
||||||
private final NetworkManager manager;
|
private final NetworkManager manager;
|
||||||
protected Location regulator;
|
protected Location regulator;
|
||||||
private Queue<Location> nodeQueue = new ArrayDeque<>();
|
private final Queue<Location> nodeQueue = new ArrayDeque<>();
|
||||||
|
|
||||||
protected final Set<Location> connectedLocations = new HashSet<>();
|
protected final Set<Location> connectedLocations = new HashSet<>();
|
||||||
protected final Set<Location> regulatorNodes = new HashSet<>();
|
protected final Set<Location> regulatorNodes = new HashSet<>();
|
||||||
|
@ -446,9 +446,7 @@ public final class PlayerProfile {
|
|||||||
fromUUID(UUID.fromString(uuid), profile -> {
|
fromUUID(UUID.fromString(uuid), profile -> {
|
||||||
Optional<PlayerBackpack> backpack = profile.getBackpack(number);
|
Optional<PlayerBackpack> backpack = profile.getBackpack(number);
|
||||||
|
|
||||||
if (backpack.isPresent()) {
|
backpack.ifPresent(callback);
|
||||||
callback.accept(backpack.get());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutomatedCraftingChamber;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -196,10 +197,6 @@ public class SlimefunRegistry {
|
|||||||
return mobDrops;
|
return mobDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ItemStack> getMobDrops(EntityType entity) {
|
|
||||||
return mobDrops.get(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<SlimefunItem> getRadioactiveItems() {
|
public Set<SlimefunItem> getRadioactiveItems() {
|
||||||
return radioactive;
|
return radioactive;
|
||||||
}
|
}
|
||||||
@ -256,6 +253,13 @@ public class SlimefunRegistry {
|
|||||||
return geoResources;
|
return geoResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of recipes for the {@link AutomatedCraftingChamber}
|
||||||
|
*
|
||||||
|
* @deprecated This just a really bad way to do this. Someone needs to rewrite this.
|
||||||
|
*
|
||||||
|
* @return A list of recipes for the {@link AutomatedCraftingChamber}
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Map<String, ItemStack> getAutomatedCraftingChamberRecipes() {
|
public Map<String, ItemStack> getAutomatedCraftingChamberRecipes() {
|
||||||
return automatedCraftingChamberRecipes;
|
return automatedCraftingChamberRecipes;
|
||||||
|
@ -29,7 +29,7 @@ final class RechargeableHelper {
|
|||||||
|
|
||||||
private static final NamespacedKey CHARGE_KEY = new NamespacedKey(SlimefunPlugin.instance(), "item_charge");
|
private static final NamespacedKey CHARGE_KEY = new NamespacedKey(SlimefunPlugin.instance(), "item_charge");
|
||||||
private static final String LORE_PREFIX = ChatColors.color("&8\u21E8 &e\u26A1 &7");
|
private static final String LORE_PREFIX = ChatColors.color("&8\u21E8 &e\u26A1 &7");
|
||||||
private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9\\.]+ \\/ [0-9\\.]+ J");
|
private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9.]+ / [0-9.]+ J");
|
||||||
|
|
||||||
private RechargeableHelper() {}
|
private RechargeableHelper() {}
|
||||||
|
|
||||||
|
@ -54,6 +54,16 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace
|
|||||||
this.displayRecipes = new ArrayList<>();
|
this.displayRecipes = new ArrayList<>();
|
||||||
this.displayRecipes.addAll(Arrays.asList(machineRecipes));
|
this.displayRecipes.addAll(Arrays.asList(machineRecipes));
|
||||||
this.multiblock = new MultiBlock(this, convertItemStacksToMaterial(recipe), trigger);
|
this.multiblock = new MultiBlock(this, convertItemStacksToMaterial(recipe), trigger);
|
||||||
|
|
||||||
|
registerDefaultRecipes(displayRecipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiBlockMachine(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) {
|
||||||
|
this(category, item, recipe, new ItemStack[0], trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void registerDefaultRecipes(List<ItemStack> recipes) {
|
||||||
|
// Override this method to register some default recipes
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack[]> getRecipes() {
|
public List<ItemStack[]> getRecipes() {
|
||||||
|
@ -68,9 +68,7 @@ class CargoNetworkTask implements Runnable {
|
|||||||
Location input = entry.getKey();
|
Location input = entry.getKey();
|
||||||
Optional<Block> attachedBlock = network.getAttachedBlock(input);
|
Optional<Block> attachedBlock = network.getAttachedBlock(input);
|
||||||
|
|
||||||
if (attachedBlock.isPresent()) {
|
attachedBlock.ifPresent(block -> routeItems(input, block, entry.getValue(), outputs));
|
||||||
routeItems(input, attachedBlock.get(), entry.getValue(), outputs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This will prevent this timings from showing up for the Cargo Manager
|
// This will prevent this timings from showing up for the Cargo Manager
|
||||||
timestamp += SlimefunPlugin.getProfiler().closeEntry(entry.getKey(), SlimefunItems.CARGO_INPUT_NODE.getItem(), nodeTimestamp);
|
timestamp += SlimefunPlugin.getProfiler().closeEntry(entry.getKey(), SlimefunItems.CARGO_INPUT_NODE.getItem(), nodeTimestamp);
|
||||||
|
@ -226,9 +226,7 @@ abstract class ChestTerminalNetwork extends Network {
|
|||||||
if (menu.getItemInSlot(17) != null) {
|
if (menu.getItemInSlot(17) != null) {
|
||||||
Optional<Block> target = getAttachedBlock(bus);
|
Optional<Block> target = getAttachedBlock(bus);
|
||||||
|
|
||||||
if (target.isPresent()) {
|
target.ifPresent(block -> menu.replaceExistingItem(17, CargoUtils.insert(inventories, bus.getBlock(), block, menu.getItemInSlot(17))));
|
||||||
menu.replaceExistingItem(17, CargoUtils.insert(inventories, bus.getBlock(), target.get(), menu.getItemInSlot(17)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu.getItemInSlot(17) == null) {
|
if (menu.getItemInSlot(17) == null) {
|
||||||
|
@ -41,7 +41,7 @@ public class Research implements Keyed {
|
|||||||
|
|
||||||
private final NamespacedKey key;
|
private final NamespacedKey key;
|
||||||
private final int id;
|
private final int id;
|
||||||
private String name;
|
private final String name;
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
private int cost;
|
private int cost;
|
||||||
|
|
||||||
|
@ -206,9 +206,7 @@ public class GitHubService {
|
|||||||
for (Contributor contributor : contributors.values()) {
|
for (Contributor contributor : contributors.values()) {
|
||||||
Optional<UUID> uuid = contributor.getUniqueId();
|
Optional<UUID> uuid = contributor.getUniqueId();
|
||||||
|
|
||||||
if (uuid.isPresent()) {
|
uuid.ifPresent(value -> uuidCache.setValue(contributor.getName(), value));
|
||||||
uuidCache.setValue(contributor.getName(), uuid.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contributor.hasTexture()) {
|
if (contributor.hasTexture()) {
|
||||||
String texture = contributor.getTexture();
|
String texture = contributor.getTexture();
|
||||||
|
@ -116,9 +116,7 @@ class GitHubTask implements Runnable {
|
|||||||
if (!uuid.isPresent()) {
|
if (!uuid.isPresent()) {
|
||||||
uuid = MinecraftAccount.getUUID(contributor.getMinecraftName());
|
uuid = MinecraftAccount.getUUID(contributor.getMinecraftName());
|
||||||
|
|
||||||
if (uuid.isPresent()) {
|
uuid.ifPresent(contributor::setUniqueId);
|
||||||
contributor.setUniqueId(uuid.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uuid.isPresent()) {
|
if (uuid.isPresent()) {
|
||||||
|
@ -815,6 +815,7 @@ public final class SlimefunItems {
|
|||||||
public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack("FLUID_PUMP", Material.BLUE_TERRACOTTA, "&9Fluid Pump", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &732 J/Block");
|
public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack("FLUID_PUMP", Material.BLUE_TERRACOTTA, "&9Fluid Pump", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &732 J/Block");
|
||||||
public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack("CHARGING_BENCH", Material.CRAFTING_TABLE, "&6Charging Bench", "", "&fCharges Items such as Jetpacks", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), "&8\u21E8 &e\u26A1 &7Energy Loss: &c50%");
|
public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack("CHARGING_BENCH", Material.CRAFTING_TABLE, "&6Charging Bench", "", "&fCharges Items such as Jetpacks", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), "&8\u21E8 &e\u26A1 &7Energy Loss: &c50%");
|
||||||
|
|
||||||
|
public static final SlimefunItemStack IRON_GOLEM_ASSEMBLER = new SlimefunItemStack("IRON_GOLEM_ASSEMBLER", Material.IRON_BLOCK, "&6Iron Golem Assembler", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Cooldown: &b30 Seconds", LoreBuilder.powerBuffer(4096), "&8\u21E8 &e\u26A1 &72048 J/Golem");
|
||||||
public static final SlimefunItemStack WITHER_ASSEMBLER = new SlimefunItemStack("WITHER_ASSEMBLER", Material.OBSIDIAN, "&5Wither Assembler", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Cooldown: &b30 Seconds", LoreBuilder.powerBuffer(4096), "&8\u21E8 &e\u26A1 &74096 J/Wither");
|
public static final SlimefunItemStack WITHER_ASSEMBLER = new SlimefunItemStack("WITHER_ASSEMBLER", Material.OBSIDIAN, "&5Wither Assembler", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Cooldown: &b30 Seconds", LoreBuilder.powerBuffer(4096), "&8\u21E8 &e\u26A1 &74096 J/Wither");
|
||||||
|
|
||||||
public static final SlimefunItemStack TRASH_CAN = new SlimefunItemStack("TRASH_CAN_BLOCK", HeadTexture.TRASH_CAN, "&3Trash Can", "", "&fWill destroy all Items put into it");
|
public static final SlimefunItemStack TRASH_CAN = new SlimefunItemStack("TRASH_CAN_BLOCK", HeadTexture.TRASH_CAN, "&3Trash Can", "", "&fWill destroy all Items put into it");
|
||||||
|
@ -31,7 +31,7 @@ class RecipeChoiceTask implements Runnable {
|
|||||||
|
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private int id;
|
private int id;
|
||||||
private Map<Integer, LoopIterator<Material>> iterators = new HashMap<>();
|
private final Map<Integer, LoopIterator<Material>> iterators = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will start this task for the given {@link Inventory}.
|
* This will start this task for the given {@link Inventory}.
|
||||||
|
@ -69,9 +69,7 @@ public abstract class WoodcutterAndroid extends ProgrammableAndroid {
|
|||||||
if (log.getY() == android.getRelative(face).getY()) {
|
if (log.getY() == android.getRelative(face).getY()) {
|
||||||
Optional<Material> sapling = MaterialConverter.getSaplingFromLog(log.getType());
|
Optional<Material> sapling = MaterialConverter.getSaplingFromLog(log.getType());
|
||||||
|
|
||||||
if (sapling.isPresent()) {
|
sapling.ifPresent(log::setType);
|
||||||
log.setType(sapling.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.setType(Material.AIR);
|
log.setType(Material.AIR);
|
||||||
|
@ -31,7 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
|
|
||||||
public class BlockPlacer extends SimpleSlimefunItem<BlockDispenseHandler> {
|
public class BlockPlacer extends SimpleSlimefunItem<BlockDispenseHandler> {
|
||||||
|
|
||||||
private ItemSetting<List<String>> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList()));
|
private final ItemSetting<List<String>> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList()));
|
||||||
|
|
||||||
public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
@ -46,7 +46,7 @@ public class CargoManager extends SlimefunItem {
|
|||||||
|
|
||||||
}, new BlockUseHandler() {
|
}, new BlockUseHandler() {
|
||||||
|
|
||||||
private String visualizerKey = "visualizer";
|
private final String visualizerKey = "visualizer";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRightClick(PlayerRightClickEvent e) {
|
public void onRightClick(PlayerRightClickEvent e) {
|
||||||
|
@ -0,0 +1,293 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an abstract super class for Entity Assemblers.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see WitherAssembler
|
||||||
|
* @see IronGolemAssembler
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class AbstractEntityAssembler extends SimpleSlimefunItem<BlockTicker> implements EnergyNetComponent {
|
||||||
|
|
||||||
|
private final int[] border = { 0, 2, 3, 4, 5, 6, 8, 12, 14, 21, 23, 30, 32, 39, 40, 41 };
|
||||||
|
private final int[] inputSlots = { 19, 28, 25, 34 };
|
||||||
|
|
||||||
|
private final int[] headSlots = { 19, 28 };
|
||||||
|
private final int[] headBorder = { 9, 10, 11, 18, 20, 27, 29, 36, 37, 38 };
|
||||||
|
|
||||||
|
private final int[] bodySlots = { 25, 34 };
|
||||||
|
private final int[] bodyBorder = { 15, 16, 17, 24, 26, 33, 35, 42, 43, 44 };
|
||||||
|
|
||||||
|
private int lifetime = 0;
|
||||||
|
|
||||||
|
public AbstractEntityAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
super(category, item, recipeType, recipe);
|
||||||
|
|
||||||
|
new BlockMenuPreset(getID(), item.getImmutableMeta().getDisplayName().orElse("Entity Assembler")) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
for (int i : border) {
|
||||||
|
addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i : headBorder) {
|
||||||
|
addItem(i, new CustomItem(getHeadBorder(), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i : bodyBorder) {
|
||||||
|
addItem(i, new CustomItem(getBodyBorder(), " "), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
constructMenu(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void newInstance(BlockMenu menu, Block b) {
|
||||||
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals(String.valueOf(false))) {
|
||||||
|
menu.replaceExistingItem(22, new CustomItem(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
|
||||||
|
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
||||||
|
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(true));
|
||||||
|
newInstance(menu, b);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
menu.replaceExistingItem(22, new CustomItem(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
|
||||||
|
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
||||||
|
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false));
|
||||||
|
newInstance(menu, b);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F : Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
||||||
|
|
||||||
|
menu.replaceExistingItem(31, new CustomItem(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
||||||
|
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
||||||
|
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
|
||||||
|
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
|
||||||
|
newInstance(menu, b);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canOpen(Block b, Player p) {
|
||||||
|
return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
|
||||||
|
if (flow == ItemTransportFlow.INSERT) {
|
||||||
|
return inputSlots;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new int[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) {
|
||||||
|
if (flow == ItemTransportFlow.INSERT && item != null) {
|
||||||
|
if (item.getType() == getBody().getType()) {
|
||||||
|
return bodySlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType() == getHead().getType()) {
|
||||||
|
return headSlots;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new int[0];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
registerBlockHandler(getID(), new SlimefunBlockHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||||
|
BlockStorage.addBlockInfo(b, "offset", "3.0");
|
||||||
|
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||||
|
if (reason == UnregisterReason.EXPLODE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
|
|
||||||
|
if (inv != null) {
|
||||||
|
for (int slot : bodySlots) {
|
||||||
|
if (inv.getItemInSlot(slot) != null) {
|
||||||
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
|
inv.replaceExistingItem(slot, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int slot : headSlots) {
|
||||||
|
if (inv.getItemInSlot(slot) != null) {
|
||||||
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
|
inv.replaceExistingItem(slot, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockTicker getItemHandler() {
|
||||||
|
return new BlockTicker() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick(Block b, SlimefunItem sf, Config data) {
|
||||||
|
if (String.valueOf(false).equals(BlockStorage.getLocationInfo(b.getLocation(), "enabled"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lifetime % 60 == 0 && ChargableBlock.getCharge(b) >= getEnergyConsumption()) {
|
||||||
|
BlockMenu menu = BlockStorage.getInventory(b);
|
||||||
|
|
||||||
|
boolean hasBody = findResource(menu, getBody(), bodySlots);
|
||||||
|
boolean hasHead = findResource(menu, getHead(), headSlots);
|
||||||
|
|
||||||
|
if (hasBody && hasHead) {
|
||||||
|
consumeResources(menu);
|
||||||
|
|
||||||
|
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||||
|
double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
||||||
|
|
||||||
|
Slimefun.runSync(() -> {
|
||||||
|
Location loc = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D);
|
||||||
|
b.getWorld().spawnEntity(loc, EntityType.WITHER);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uniqueTick() {
|
||||||
|
lifetime++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSynchronized() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean findResource(BlockMenu menu, ItemStack item, int[] slots) {
|
||||||
|
Material resource = item.getType();
|
||||||
|
int required = item.getAmount();
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
for (int slot : slots) {
|
||||||
|
if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(resource), true, false)) {
|
||||||
|
found += menu.getItemInSlot(slot).getAmount();
|
||||||
|
|
||||||
|
if (found > required) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void consumeResources(BlockMenu inv) {
|
||||||
|
int bodyCount = getBody().getAmount();
|
||||||
|
int headCount = getHead().getAmount();
|
||||||
|
|
||||||
|
for (int slot : bodySlots) {
|
||||||
|
if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(getBody().getType()), true, false)) {
|
||||||
|
int amount = inv.getItemInSlot(slot).getAmount();
|
||||||
|
|
||||||
|
if (amount >= bodyCount) {
|
||||||
|
inv.consumeItem(slot, bodyCount);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bodyCount -= amount;
|
||||||
|
inv.replaceExistingItem(slot, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int slot : headSlots) {
|
||||||
|
if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(getHead().getType()), true, false)) {
|
||||||
|
int amount = inv.getItemInSlot(slot).getAmount();
|
||||||
|
|
||||||
|
if (amount >= headCount) {
|
||||||
|
inv.consumeItem(slot, headCount);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
headCount -= amount;
|
||||||
|
inv.replaceExistingItem(slot, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void constructMenu(BlockMenuPreset preset) {
|
||||||
|
preset.addItem(1, new CustomItem(getHead(), "&7Head Slot", "", "&rThis Slot accepts the head type"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
preset.addItem(7, new CustomItem(getBody(), "&7Body Slot", "", "&rThis Slot accepts the body type"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnergyNetComponentType getEnergyComponentType() {
|
||||||
|
return EnergyNetComponentType.CONSUMER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract int getEnergyConsumption();
|
||||||
|
|
||||||
|
public abstract ItemStack getHead();
|
||||||
|
|
||||||
|
public abstract ItemStack getBody();
|
||||||
|
|
||||||
|
public abstract Material getHeadBorder();
|
||||||
|
|
||||||
|
public abstract Material getBodyBorder();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.IronGolem;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link IronGolemAssembler} is an electrical machine that can automatically spawn
|
||||||
|
* a {@link IronGolem} if the required ingredients have been provided.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see WitherAssembler
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IronGolemAssembler extends AbstractEntityAssembler {
|
||||||
|
|
||||||
|
public IronGolemAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
super(category, item, recipeType, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCapacity() {
|
||||||
|
return 4096;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyConsumption() {
|
||||||
|
return 2048;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getHead() {
|
||||||
|
return new ItemStack(Material.PUMPKIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getHeadBorder() {
|
||||||
|
return Material.ORANGE_STAINED_GLASS_PANE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getBody() {
|
||||||
|
return new ItemStack(Material.IRON_BLOCK, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getBodyBorder() {
|
||||||
|
return Material.WHITE_STAINED_GLASS_PANE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void constructMenu(BlockMenuPreset preset) {
|
||||||
|
preset.addItem(1, new CustomItem(getHead(), "&7Pumpkin Slot", "", "&rThis Slot accepts Pumpkins"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
preset.addItem(7, new CustomItem(getBody(), "&7Iron Block Slot", "", "&rThis Slot accepts Iron Blocks"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,37 +1,15 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Wither;
|
import org.bukkit.entity.Wither;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
|
||||||
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.SlimefunBlockHandler;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link WitherAssembler} is an electrical machine that can automatically spawn
|
* The {@link WitherAssembler} is an electrical machine that can automatically spawn
|
||||||
@ -39,158 +17,13 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
|||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
|
* @see IronGolemAssembler
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class WitherAssembler extends SimpleSlimefunItem<BlockTicker> implements EnergyNetComponent {
|
public class WitherAssembler extends AbstractEntityAssembler {
|
||||||
|
|
||||||
private static final int ENERGY_CONSUMPTION = 4096;
|
|
||||||
|
|
||||||
private final int[] border = { 0, 2, 3, 4, 5, 6, 8, 12, 14, 21, 23, 30, 32, 39, 40, 41 };
|
|
||||||
private final int[] skullBorder = { 9, 10, 11, 18, 20, 27, 29, 36, 37, 38 };
|
|
||||||
private final int[] sandBorder = { 15, 16, 17, 24, 26, 33, 35, 42, 43, 44 };
|
|
||||||
|
|
||||||
private int lifetime = 0;
|
|
||||||
|
|
||||||
public WitherAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public WitherAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
|
||||||
new BlockMenuPreset(getID(), "&5Wither Assembler") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
constructMenu(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void newInstance(BlockMenu menu, Block b) {
|
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals(String.valueOf(false))) {
|
|
||||||
menu.replaceExistingItem(22, new CustomItem(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
|
|
||||||
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
|
||||||
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(true));
|
|
||||||
newInstance(menu, b);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
menu.replaceExistingItem(22, new CustomItem(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
|
|
||||||
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
|
||||||
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false));
|
|
||||||
newInstance(menu, b);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F : Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
|
||||||
|
|
||||||
menu.replaceExistingItem(31, new CustomItem(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
|
||||||
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
|
||||||
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
|
|
||||||
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
|
|
||||||
newInstance(menu, b);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canOpen(Block b, Player p) {
|
|
||||||
return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
|
|
||||||
if (flow == ItemTransportFlow.INSERT) {
|
|
||||||
return getInputSlots();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new int[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) {
|
|
||||||
if (flow == ItemTransportFlow.INSERT && item != null) {
|
|
||||||
if (item.getType() == Material.SOUL_SAND) {
|
|
||||||
return getSoulSandSlots();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.getType() == Material.WITHER_SKELETON_SKULL) {
|
|
||||||
return getWitherSkullSlots();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new int[0];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
registerBlockHandler(getID(), new SlimefunBlockHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
|
||||||
BlockStorage.addBlockInfo(b, "offset", "3.0");
|
|
||||||
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
|
||||||
if (reason == UnregisterReason.EXPLODE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockMenu inv = BlockStorage.getInventory(b);
|
|
||||||
|
|
||||||
if (inv != null) {
|
|
||||||
for (int slot : getSoulSandSlots()) {
|
|
||||||
if (inv.getItemInSlot(slot) != null) {
|
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
|
||||||
inv.replaceExistingItem(slot, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int slot : getWitherSkullSlots()) {
|
|
||||||
if (inv.getItemInSlot(slot) != null) {
|
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
|
||||||
inv.replaceExistingItem(slot, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void constructMenu(BlockMenuPreset preset) {
|
|
||||||
for (int i : border) {
|
|
||||||
preset.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i : skullBorder) {
|
|
||||||
preset.addItem(i, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i : sandBorder) {
|
|
||||||
preset.addItem(i, new CustomItem(Material.BROWN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
preset.addItem(1, new CustomItem(Material.WITHER_SKELETON_SKULL, "&7Wither Skull Slot", "", "&rThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler());
|
|
||||||
preset.addItem(7, new CustomItem(Material.SOUL_SAND, "&7Soul Sand Slot", "", "&rThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler());
|
|
||||||
preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getInputSlots() {
|
|
||||||
return new int[] { 19, 28, 25, 34 };
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getWitherSkullSlots() {
|
|
||||||
return new int[] { 19, 28 };
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getSoulSandSlots() {
|
|
||||||
return new int[] { 25, 34 };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnergyNetComponentType getEnergyComponentType() {
|
|
||||||
return EnergyNetComponentType.CONSUMER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,93 +32,35 @@ public class WitherAssembler extends SimpleSlimefunItem<BlockTicker> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockTicker getItemHandler() {
|
public int getEnergyConsumption() {
|
||||||
return new BlockTicker() {
|
return 4096;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(Block b, SlimefunItem sf, Config data) {
|
|
||||||
if (String.valueOf(false).equals(BlockStorage.getLocationInfo(b.getLocation(), "enabled"))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lifetime % 60 == 0 && ChargableBlock.getCharge(b) >= ENERGY_CONSUMPTION) {
|
|
||||||
BlockMenu menu = BlockStorage.getInventory(b);
|
|
||||||
|
|
||||||
boolean soulsand = findResource(menu, Material.SOUL_SAND, 4, getSoulSandSlots());
|
|
||||||
boolean skulls = findResource(menu, Material.WITHER_SKELETON_SKULL, 3, getWitherSkullSlots());
|
|
||||||
|
|
||||||
if (soulsand && skulls) {
|
|
||||||
consumeResources(menu);
|
|
||||||
|
|
||||||
ChargableBlock.addCharge(b, -ENERGY_CONSUMPTION);
|
|
||||||
double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
|
|
||||||
|
|
||||||
Slimefun.runSync(() -> b.getWorld().spawnEntity(new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D), EntityType.WITHER));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uniqueTick() {
|
public ItemStack getHead() {
|
||||||
lifetime++;
|
return new ItemStack(Material.WITHER_SKELETON_SKULL, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSynchronized() {
|
public Material getHeadBorder() {
|
||||||
return false;
|
return Material.BLACK_STAINED_GLASS_PANE;
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean findResource(BlockMenu menu, Material resource, int required, int[] slots) {
|
@Override
|
||||||
int found = 0;
|
public ItemStack getBody() {
|
||||||
|
return new ItemStack(Material.SOUL_SAND, 4);
|
||||||
for (int slot : slots) {
|
|
||||||
if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(resource), true, false)) {
|
|
||||||
found += menu.getItemInSlot(slot).getAmount();
|
|
||||||
|
|
||||||
if (found > required) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
@Override
|
||||||
|
public Material getBodyBorder() {
|
||||||
|
return Material.BROWN_STAINED_GLASS_PANE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void consumeResources(BlockMenu inv) {
|
@Override
|
||||||
int soulsand = 4;
|
protected void constructMenu(BlockMenuPreset preset) {
|
||||||
int skulls = 3;
|
preset.addItem(1, new CustomItem(getHead(), "&7Wither Skeleton Skull Slot", "", "&rThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
preset.addItem(7, new CustomItem(getBody(), "&7Soul Sand Slot", "", "&rThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
for (int slot : getSoulSandSlots()) {
|
preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler());
|
||||||
if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, false)) {
|
|
||||||
int amount = inv.getItemInSlot(slot).getAmount();
|
|
||||||
|
|
||||||
if (amount >= soulsand) {
|
|
||||||
inv.consumeItem(slot, soulsand);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
soulsand -= amount;
|
|
||||||
inv.replaceExistingItem(slot, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int slot : getWitherSkullSlots()) {
|
|
||||||
if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true, false)) {
|
|
||||||
int amount = inv.getItemInSlot(slot).getAmount();
|
|
||||||
|
|
||||||
if (amount >= skulls) {
|
|
||||||
inv.consumeItem(slot, skulls);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skulls -= amount;
|
|
||||||
inv.replaceExistingItem(slot, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
*/
|
*/
|
||||||
public class MeatJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
public class MeatJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||||
|
|
||||||
private ItemSetting<Integer> saturation = new ItemSetting<>("saturation-level", 6);
|
private final ItemSetting<Integer> saturation = new ItemSetting<>("saturation-level", 6);
|
||||||
|
|
||||||
public MeatJerky(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public MeatJerky(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
@ -24,9 +24,7 @@ public class PortableGEOScanner extends SimpleSlimefunItem<ItemUseHandler> {
|
|||||||
Optional<Block> block = e.getClickedBlock();
|
Optional<Block> block = e.getClickedBlock();
|
||||||
e.cancel();
|
e.cancel();
|
||||||
|
|
||||||
if (block.isPresent()) {
|
block.ifPresent(value -> SlimefunPlugin.getGPSNetwork().getResourceManager().scan(e.getPlayer(), value, 0));
|
||||||
SlimefunPlugin.getGPSNetwork().getResourceManager().scan(e.getPlayer(), block.get(), 0);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractSmeltery extends MultiBlockMachine {
|
abstract class AbstractSmeltery extends MultiBlockMachine {
|
||||||
|
|
||||||
public AbstractSmeltery(Category category, SlimefunItemStack item, ItemStack[] recipe, ItemStack[] machineRecipes, BlockFace trigger) {
|
public AbstractSmeltery(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) {
|
||||||
super(category, item, recipe, machineRecipes, trigger);
|
super(category, item, recipe, trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ 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[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, new ItemStack[0], BlockFace.SELF);
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine {
|
|||||||
private final GoldPan netherGoldPan = (GoldPan) SlimefunItems.NETHER_GOLD_PAN.getItem();
|
private final GoldPan netherGoldPan = (GoldPan) SlimefunItems.NETHER_GOLD_PAN.getItem();
|
||||||
|
|
||||||
public AutomatedPanningMachine(Category category, SlimefunItemStack item) {
|
public AutomatedPanningMachine(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, new ItemStack[0], BlockFace.SELF);
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,8 +26,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
|
|
||||||
abstract class BackpackCrafter extends MultiBlockMachine {
|
abstract class BackpackCrafter extends MultiBlockMachine {
|
||||||
|
|
||||||
public BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, ItemStack[] machineRecipes, BlockFace trigger) {
|
public BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) {
|
||||||
super(category, item, recipe, machineRecipes, trigger);
|
super(category, item, recipe, trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Inventory createVirtualInventory(Inventory inv) {
|
protected Inventory createVirtualInventory(Inventory inv) {
|
||||||
@ -92,9 +92,7 @@ abstract class BackpackCrafter extends MultiBlockMachine {
|
|||||||
PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> {
|
PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> {
|
||||||
Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1]));
|
Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1]));
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
optional.ifPresent(playerBackpack -> playerBackpack.setSize(size));
|
||||||
optional.get().setSize(size);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return Optional.of(id);
|
return Optional.of(id);
|
||||||
|
@ -27,7 +27,16 @@ 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, 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);
|
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) }, BlockFace.SELF);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerDefaultRecipes(List<ItemStack> recipes) {
|
||||||
|
recipes.add(new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 4));
|
||||||
|
recipes.add(new ItemStack(Material.COBBLESTONE));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.FLINT, 8));
|
||||||
|
recipes.add(new ItemStack(Material.COBBLESTONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class EnhancedCraftingTable extends BackpackCrafter {
|
public class EnhancedCraftingTable extends BackpackCrafter {
|
||||||
|
|
||||||
public EnhancedCraftingTable(Category category, SlimefunItemStack item) {
|
public EnhancedCraftingTable(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, new ItemStack[0], BlockFace.SELF);
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, BlockFace.SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,52 @@ 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, 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);
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerDefaultRecipes(List<ItemStack> recipes) {
|
||||||
|
recipes.add(new ItemStack(Material.BLAZE_ROD));
|
||||||
|
recipes.add(new ItemStack(Material.BLAZE_POWDER, 4));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.BONE));
|
||||||
|
recipes.add(new ItemStack(Material.BONE_MEAL, 4));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.BONE_BLOCK));
|
||||||
|
recipes.add(new ItemStack(Material.BONE_MEAL, 9));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.GRAVEL));
|
||||||
|
recipes.add(new ItemStack(Material.FLINT));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.ENDER_EYE));
|
||||||
|
recipes.add(new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 2));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.COBBLESTONE));
|
||||||
|
recipes.add(new ItemStack(Material.GRAVEL));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.ANDESITE));
|
||||||
|
recipes.add(new ItemStack(Material.GRAVEL));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.DIORITE));
|
||||||
|
recipes.add(new ItemStack(Material.GRAVEL));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.GRANITE));
|
||||||
|
recipes.add(new ItemStack(Material.GRAVEL));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.DIRT));
|
||||||
|
recipes.add(SlimefunItems.STONE_CHUNK);
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.SANDSTONE));
|
||||||
|
recipes.add(new ItemStack(Material.SAND, 4));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.RED_SANDSTONE));
|
||||||
|
recipes.add(new ItemStack(Material.RED_SAND, 4));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.PRISMARINE_BRICKS));
|
||||||
|
recipes.add(new ItemStack(Material.PRISMARINE, 2));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.PRISMARINE));
|
||||||
|
recipes.add(new ItemStack(Material.PRISMARINE_SHARD, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ 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, 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);
|
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 }, BlockFace.SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class MagicWorkbench extends BackpackCrafter {
|
public class MagicWorkbench extends BackpackCrafter {
|
||||||
|
|
||||||
public MagicWorkbench(Category category, SlimefunItemStack item) {
|
public MagicWorkbench(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, new ItemStack[0], BlockFace.UP);
|
super(category, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, BlockFace.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
public class MakeshiftSmeltery extends AbstractSmeltery {
|
public class MakeshiftSmeltery extends AbstractSmeltery {
|
||||||
|
|
||||||
public MakeshiftSmeltery(Category category, SlimefunItemStack item) {
|
public MakeshiftSmeltery(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, new ItemStack[0], BlockFace.DOWN);
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,11 +32,26 @@ public class OreCrusher extends MultiBlockMachine {
|
|||||||
private final DoubleOreSetting doubleOres = new DoubleOreSetting();
|
private final DoubleOreSetting doubleOres = new DoubleOreSetting();
|
||||||
|
|
||||||
public OreCrusher(Category category, SlimefunItemStack item) {
|
public OreCrusher(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, new ItemStack[] { new ItemStack(Material.COBBLESTONE, 8), new ItemStack(Material.SAND, 1), SlimefunItems.GOLD_4K, SlimefunItems.GOLD_DUST, new ItemStack(Material.GRAVEL), new ItemStack(Material.SAND), new ItemStack(Material.MAGMA_BLOCK, 4), SlimefunItems.SULFATE }, BlockFace.SELF);
|
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF);
|
||||||
|
|
||||||
addItemSetting(doubleOres);
|
addItemSetting(doubleOres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerDefaultRecipes(List<ItemStack> recipes) {
|
||||||
|
recipes.add(new ItemStack(Material.COBBLESTONE, 8));
|
||||||
|
recipes.add(new ItemStack(Material.SAND, 1));
|
||||||
|
|
||||||
|
recipes.add(SlimefunItems.GOLD_4K);
|
||||||
|
recipes.add(SlimefunItems.GOLD_DUST);
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.GRAVEL));
|
||||||
|
recipes.add(new ItemStack(Material.SAND));
|
||||||
|
|
||||||
|
recipes.add(new ItemStack(Material.MAGMA_BLOCK, 4));
|
||||||
|
recipes.add(SlimefunItems.SULFATE);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOreDoublingEnabled() {
|
public boolean isOreDoublingEnabled() {
|
||||||
return doubleOres.getValue();
|
return doubleOres.getValue();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class OreWasher extends MultiBlockMachine {
|
|||||||
private final ItemStack[] dusts;
|
private final ItemStack[] dusts;
|
||||||
|
|
||||||
public OreWasher(Category category, SlimefunItemStack item) {
|
public OreWasher(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, new ItemStack[0], BlockFace.SELF);
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF);
|
||||||
|
|
||||||
legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer");
|
legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer");
|
||||||
dusts = new ItemStack[] { SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.TIN_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST };
|
dusts = new ItemStack[] { SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.TIN_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST };
|
||||||
|
@ -29,7 +29,7 @@ public class PressureChamber extends MultiBlockMachine {
|
|||||||
|
|
||||||
public PressureChamber(Category category, SlimefunItemStack item) {
|
public PressureChamber(Category category, SlimefunItemStack item) {
|
||||||
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()
|
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()
|
||||||
.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);
|
.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) }, BlockFace.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,11 +34,17 @@ public class Smeltery extends AbstractSmeltery {
|
|||||||
private final ItemSetting<Integer> fireBreakingChance = new ItemSetting<>("fire-breaking-chance", 34);
|
private final ItemSetting<Integer> fireBreakingChance = new ItemSetting<>("fire-breaking-chance", 34);
|
||||||
|
|
||||||
public Smeltery(Category category, SlimefunItemStack item) {
|
public Smeltery(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, new ItemStack[] { SlimefunItems.IRON_DUST, new ItemStack(Material.IRON_INGOT) }, BlockFace.DOWN);
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN);
|
||||||
|
|
||||||
addItemSetting(fireBreakingChance);
|
addItemSetting(fireBreakingChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerDefaultRecipes(List<ItemStack> recipes) {
|
||||||
|
recipes.add(SlimefunItems.IRON_DUST);
|
||||||
|
recipes.add(new ItemStack(Material.IRON_INGOT));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
|
@ -36,7 +36,7 @@ public class TableSaw extends MultiBlockMachine {
|
|||||||
private final List<ItemStack> displayedRecipes = new ArrayList<>();
|
private final List<ItemStack> displayedRecipes = new ArrayList<>();
|
||||||
|
|
||||||
public TableSaw(Category category, SlimefunItemStack item) {
|
public TableSaw(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, null, null, new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, new ItemStack[0], BlockFace.SELF);
|
super(category, item, new ItemStack[] { null, null, null, new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, BlockFace.SELF);
|
||||||
|
|
||||||
for (Material log : Tag.LOGS.getValues()) {
|
for (Material log : Tag.LOGS.getValues()) {
|
||||||
Optional<Material> planks = MaterialConverter.getPlanksFromLog(log);
|
Optional<Material> planks = MaterialConverter.getPlanksFromLog(log);
|
||||||
|
@ -49,7 +49,7 @@ public class IndustrialMiner extends MultiBlockMachine {
|
|||||||
private final boolean silkTouch;
|
private final boolean silkTouch;
|
||||||
|
|
||||||
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
|
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
|
||||||
super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? Material.BLAST_FURNACE : Material.FURNACE), new ItemStack(baseMaterial) }, new ItemStack[0], BlockFace.UP);
|
super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? Material.BLAST_FURNACE : Material.FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP);
|
||||||
|
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.silkTouch = silkTouch;
|
this.silkTouch = silkTouch;
|
||||||
|
@ -2,17 +2,20 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||||
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
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.blocks.EnhancedFurnace;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -33,31 +36,44 @@ public class EnhancedFurnaceListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFuelBurn(FurnaceBurnEvent e) {
|
public void onFuelBurn(FurnaceBurnEvent e) {
|
||||||
|
if (e.getBlock().getType() != Material.FURNACE) {
|
||||||
|
// We don't care about Smokers, Blast Furnaces and all that fancy stuff
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SlimefunItem furnace = BlockStorage.check(e.getBlock());
|
SlimefunItem furnace = BlockStorage.check(e.getBlock());
|
||||||
|
|
||||||
if (furnace instanceof EnhancedFurnace && ((EnhancedFurnace) furnace).getFuelEfficiency() > 0) {
|
if (furnace instanceof EnhancedFurnace && ((EnhancedFurnace) furnace).getFuelEfficiency() > 0) {
|
||||||
int burnTime = e.getBurnTime();
|
int burnTime = e.getBurnTime();
|
||||||
int newBurnTime = ((EnhancedFurnace) furnace).getFuelEfficiency() * burnTime;
|
int newBurnTime = ((EnhancedFurnace) furnace).getFuelEfficiency() * burnTime;
|
||||||
e.setBurnTime(Math.min(newBurnTime, Short.MAX_VALUE));
|
|
||||||
|
e.setBurnTime(Math.min(newBurnTime, Short.MAX_VALUE - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onItemSmelt(FurnaceSmeltEvent e) {
|
public void onItemSmelt(FurnaceSmeltEvent e) {
|
||||||
|
if (e.getBlock().getType() != Material.FURNACE) {
|
||||||
|
// We don't care about Smokers, Blast Furnaces and all that fancy stuff
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
|
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
|
||||||
|
|
||||||
if (sfItem instanceof EnhancedFurnace) {
|
if (sfItem instanceof EnhancedFurnace) {
|
||||||
Furnace furnace = (Furnace) e.getBlock().getState();
|
BlockState state = PaperLib.getBlockState(e.getBlock(), false).getState();
|
||||||
int amount = furnace.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getOutput() : 1;
|
|
||||||
Optional<ItemStack> result = Optional.ofNullable(furnace.getInventory().getResult());
|
|
||||||
|
|
||||||
if (!result.isPresent()) {
|
if (state instanceof Furnace) {
|
||||||
result = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(furnace.getInventory().getSmelting());
|
FurnaceInventory inventory = ((Furnace) state).getInventory();
|
||||||
}
|
int amount = inventory.getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getOutput() : 1;
|
||||||
|
Optional<ItemStack> result = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(inventory.getSmelting());
|
||||||
|
|
||||||
if (result.isPresent()) {
|
if (result.isPresent()) {
|
||||||
ItemStack item = result.get();
|
ItemStack item = result.get();
|
||||||
furnace.getInventory().setResult(new CustomItem(item, Math.min(item.getAmount() + amount, item.getMaxStackSize())));
|
int previous = inventory.getResult() != null ? inventory.getResult().getAmount() : 0;
|
||||||
|
amount = Math.min(item.getMaxStackSize() - previous, amount);
|
||||||
|
e.setResult(new ItemStack(item.getType(), amount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,20 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link Listener} is responsible for handling any custom mob drops.
|
||||||
|
* These drops can also be randomized using the interface {@link RandomMobDrop}, otherwise
|
||||||
|
* they will be handled via {@link RecipeType}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see RandomMobDrop
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class MobDropListener implements Listener {
|
public class MobDropListener implements Listener {
|
||||||
|
|
||||||
public MobDropListener(SlimefunPlugin plugin) {
|
public MobDropListener(SlimefunPlugin plugin) {
|
||||||
@ -29,7 +40,7 @@ public class MobDropListener implements Listener {
|
|||||||
Player p = e.getEntity().getKiller();
|
Player p = e.getEntity().getKiller();
|
||||||
ItemStack item = p.getInventory().getItemInMainHand();
|
ItemStack item = p.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
Set<ItemStack> customDrops = SlimefunPlugin.getRegistry().getMobDrops(e.getEntityType());
|
Set<ItemStack> customDrops = SlimefunPlugin.getRegistry().getMobDrops().get(e.getEntityType());
|
||||||
|
|
||||||
if (customDrops != null && !customDrops.isEmpty()) {
|
if (customDrops != null && !customDrops.isEmpty()) {
|
||||||
for (ItemStack drop : customDrops) {
|
for (ItemStack drop : customDrops) {
|
||||||
|
@ -31,9 +31,7 @@ public class PlayerProfileListener implements Listener {
|
|||||||
Optional<PlayerProfile> profile = PlayerProfile.find(e.getPlayer());
|
Optional<PlayerProfile> profile = PlayerProfile.find(e.getPlayer());
|
||||||
|
|
||||||
// if we still have a profile of this Player in memory, delete it
|
// if we still have a profile of this Player in memory, delete it
|
||||||
if (profile.isPresent()) {
|
profile.ifPresent(PlayerProfile::markForDeletion);
|
||||||
profile.get().markForDeletion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
@ -41,9 +39,7 @@ public class PlayerProfileListener implements Listener {
|
|||||||
Optional<PlayerProfile> profile = PlayerProfile.find(e.getPlayer());
|
Optional<PlayerProfile> profile = PlayerProfile.find(e.getPlayer());
|
||||||
|
|
||||||
// if we still have a profile of this Player in memory, delete it
|
// if we still have a profile of this Player in memory, delete it
|
||||||
if (profile.isPresent()) {
|
profile.ifPresent(PlayerProfile::markForDeletion);
|
||||||
profile.get().markForDeletion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -270,6 +270,7 @@ public final class ResearchSetup {
|
|||||||
register("enchantment_rune", 259, "Ancient Enchanting", 24, SlimefunItems.MAGICAL_GLASS, SlimefunItems.ENCHANTMENT_RUNE);
|
register("enchantment_rune", 259, "Ancient Enchanting", 24, SlimefunItems.MAGICAL_GLASS, SlimefunItems.ENCHANTMENT_RUNE);
|
||||||
register("lead_clothing", 260, "Lead Clothing", 14, SlimefunItems.REINFORCED_CLOTH);
|
register("lead_clothing", 260, "Lead Clothing", 14, SlimefunItems.REINFORCED_CLOTH);
|
||||||
register("tape_measure", 261, "Tape Measure", 7, SlimefunItems.TAPE_MEASURE);
|
register("tape_measure", 261, "Tape Measure", 7, SlimefunItems.TAPE_MEASURE);
|
||||||
|
register("iron_golem_assembler", 262, "Automated Iron Golems", 30, SlimefunItems.IRON_GOLEM_ASSEMBLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(String key, int id, String name, int defaultCost, ItemStack... items) {
|
private static void register(String key, int id, String name, int defaultCost, ItemStack... items) {
|
||||||
|
@ -97,6 +97,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodFabricator;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodFabricator;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Freezer;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Freezer;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.HeatedPressureChamber;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.HeatedPressureChamber;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.IronGolemAssembler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Refinery;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Refinery;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.TreeGrowthAccelerator;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.TreeGrowthAccelerator;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.WitherAssembler;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.WitherAssembler;
|
||||||
@ -3223,6 +3224,10 @@ public final class SlimefunItemSetup {
|
|||||||
|
|
||||||
}.register(plugin);
|
}.register(plugin);
|
||||||
|
|
||||||
|
new IronGolemAssembler(categories.electricity, SlimefunItems.IRON_GOLEM_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
|
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.ADVANCED_CIRCUIT_BOARD, SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.IRON_BLOCK), SlimefunItems.ANDROID_MEMORY_CORE, new ItemStack(Material.IRON_BLOCK), SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR})
|
||||||
|
.register(plugin);
|
||||||
|
|
||||||
new WitherAssembler(categories.electricity, SlimefunItems.WITHER_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
new WitherAssembler(categories.electricity, SlimefunItems.WITHER_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR})
|
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR})
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
@ -77,7 +77,8 @@ public class ArmorTask implements Runnable {
|
|||||||
if (armorpiece.hasDiverged(item)) {
|
if (armorpiece.hasDiverged(item)) {
|
||||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||||
|
|
||||||
if (!(sfItem instanceof SlimefunArmorPiece) || !Slimefun.hasUnlocked(p, sfItem, true)) {
|
if (!(sfItem instanceof SlimefunArmorPiece)) {
|
||||||
|
// If it isn't actually Armor, then we won't care about it.
|
||||||
sfItem = null;
|
sfItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,10 +87,14 @@ public class ArmorTask implements Runnable {
|
|||||||
|
|
||||||
if (item != null && armorpiece.getItem().isPresent()) {
|
if (item != null && armorpiece.getItem().isPresent()) {
|
||||||
Slimefun.runSync(() -> {
|
Slimefun.runSync(() -> {
|
||||||
for (PotionEffect effect : armorpiece.getItem().get().getPotionEffects()) {
|
SlimefunArmorPiece slimefunArmor = armorpiece.getItem().get();
|
||||||
|
|
||||||
|
if (Slimefun.hasUnlocked(p, slimefunArmor, true)) {
|
||||||
|
for (PotionEffect effect : slimefunArmor.getPotionEffects()) {
|
||||||
p.removePotionEffect(effect.getType());
|
p.removePotionEffect(effect.getType());
|
||||||
p.addPotionEffect(effect);
|
p.addPotionEffect(effect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public final class NumberUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String number = roundDecimalNumber(nanoseconds / 1000000.0);
|
String number = roundDecimalNumber(nanoseconds / 1000000.0);
|
||||||
String[] parts = PatternUtils.NUMBER_SEPERATOR.split(number);
|
String[] parts = PatternUtils.NUMBER_SEPARATOR.split(number);
|
||||||
|
|
||||||
if (parts.length == 1) {
|
if (parts.length == 1) {
|
||||||
return parts[0] + "ms";
|
return parts[0] + "ms";
|
||||||
|
@ -26,6 +26,5 @@ public final class PatternUtils {
|
|||||||
public static final Pattern ALPHANUMERIC = Pattern.compile("[A-Fa-f0-9]+");
|
public static final Pattern ALPHANUMERIC = Pattern.compile("[A-Fa-f0-9]+");
|
||||||
public static final Pattern NUMERIC = Pattern.compile("[0-9]+");
|
public static final Pattern NUMERIC = Pattern.compile("[0-9]+");
|
||||||
|
|
||||||
public static final Pattern NUMBER_SEPERATOR = Pattern.compile(",|\\.");
|
public static final Pattern NUMBER_SEPARATOR = Pattern.compile("[,.]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class MachineRecipe {
|
public class MachineRecipe {
|
||||||
|
|
||||||
private int ticks;
|
private int ticks;
|
||||||
private ItemStack[] input;
|
private final ItemStack[] input;
|
||||||
private ItemStack[] output;
|
private final ItemStack[] output;
|
||||||
|
|
||||||
public MachineRecipe(int seconds, ItemStack[] input, ItemStack[] output) {
|
public MachineRecipe(int seconds, ItemStack[] input, ItemStack[] output) {
|
||||||
this.ticks = seconds * 2;
|
this.ticks = seconds * 2;
|
||||||
|
@ -25,7 +25,7 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
// -1 means "automatically update according to the contents"
|
// -1 means "automatically update according to the contents"
|
||||||
private int size = -1;
|
private int size = -1;
|
||||||
|
|
||||||
private boolean universal;
|
private final boolean universal;
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
|
|
||||||
private ItemManipulationEvent event;
|
private ItemManipulationEvent event;
|
||||||
|
@ -143,8 +143,8 @@ public class DirtyChestMenu extends ChestMenu {
|
|||||||
|
|
||||||
public static class SaveHandler implements MenuOpeningHandler {
|
public static class SaveHandler implements MenuOpeningHandler {
|
||||||
|
|
||||||
private DirtyChestMenu menu;
|
private final DirtyChestMenu menu;
|
||||||
private MenuOpeningHandler handler;
|
private final MenuOpeningHandler handler;
|
||||||
|
|
||||||
public SaveHandler(DirtyChestMenu menu, MenuOpeningHandler handler) {
|
public SaveHandler(DirtyChestMenu menu, MenuOpeningHandler handler) {
|
||||||
this.menu = menu;
|
this.menu = menu;
|
||||||
|
@ -238,3 +238,4 @@ slimefun:
|
|||||||
enchantment_rune: Ancient Enchanting
|
enchantment_rune: Ancient Enchanting
|
||||||
lead_clothing: Lead Clothing
|
lead_clothing: Lead Clothing
|
||||||
tape_measure: Tape Measure
|
tape_measure: Tape Measure
|
||||||
|
iron_golem_assembler: Automated Iron Golems
|
@ -41,7 +41,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
|
|
||||||
public class TestBackpackListener {
|
public class TestBackpackListener {
|
||||||
|
|
||||||
private static int BACKPACK_SIZE = 27;
|
private static final int BACKPACK_SIZE = 27;
|
||||||
private static ServerMock server;
|
private static ServerMock server;
|
||||||
private static SlimefunPlugin plugin;
|
private static SlimefunPlugin plugin;
|
||||||
private static BackpackListener listener;
|
private static BackpackListener listener;
|
||||||
|
Loading…
Reference in New Issue
Block a user