From c1969caf95c1267e68b4cfcfde3829ef70c1b166 Mon Sep 17 00:00:00 2001
From: Mooy1 <69326411+Mooy1@users.noreply.github.com>
Date: Wed, 30 Dec 2020 21:48:34 -0600
Subject: [PATCH] Fixes
---
pom.xml | 2 +-
.../infinityexpansion/InfinityExpansion.java | 20 +-
.../implementation/abstracts/Crafter.java | 7 +
.../{items => blocks}/AdvancedAnvil.java | 2 +-
.../{items => blocks}/InfinityWorkbench.java | 23 +-
.../{storage => blocks}/StorageForge.java | 2 +-
.../{storage => blocks}/StorageUnit.java | 2 +-
.../{items => blocks}/Strainer.java | 2 +-
.../{items => blocks}/StrainerBase.java | 2 +-
.../implementation/gear/VeinMinerRune.java | 19 +-
.../EnergyGenerator.java | 2 +-
.../InfinityReactor.java | 2 +-
.../machines/ConversionMachine.java | 112 ++---
.../machines/PoweredBedrock.java | 2 +-
.../machines/SingularityConstructor.java | 2 +-
.../machines/VoidHarvester.java | 4 +-
.../implementation/mobdata/MobDataCard.java | 130 +++---
.../mobdata/MobDataInfuser.java | 4 +-
.../mobdata/MobSimulationChamber.java | 9 +-
.../infinityexpansion/lists/Categories.java | 16 +-
.../lists/InfinityRecipes.java | 164 ++++----
.../mooy1/infinityexpansion/lists/Items.java | 14 +-
.../setup/InfinityCategory.java | 382 ++++++++----------
.../infinityexpansion/setup/MainCategory.java | 4 +-
.../mooy1/infinityexpansion/setup/Setup.java | 16 +-
.../{HiddenCategory.java => SubCategory.java} | 4 +-
26 files changed, 437 insertions(+), 511 deletions(-)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{items => blocks}/AdvancedAnvil.java (99%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{items => blocks}/InfinityWorkbench.java (89%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{storage => blocks}/StorageForge.java (97%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{storage => blocks}/StorageUnit.java (99%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{items => blocks}/Strainer.java (97%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{items => blocks}/StrainerBase.java (99%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{machines => generators}/EnergyGenerator.java (99%)
rename src/main/java/io/github/mooy1/infinityexpansion/implementation/{machines => generators}/InfinityReactor.java (99%)
rename src/main/java/io/github/mooy1/infinityexpansion/setup/{HiddenCategory.java => SubCategory.java} (80%)
diff --git a/pom.xml b/pom.xml
index e3ba9929..e62319e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
io.github.mooy1
InfinityLib
- 4c37d7b
+ 4d619f6
compile
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/InfinityExpansion.java b/src/main/java/io/github/mooy1/infinityexpansion/InfinityExpansion.java
index 5639d6d0..60e8e5ed 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/InfinityExpansion.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/InfinityExpansion.java
@@ -1,7 +1,7 @@
package io.github.mooy1.infinityexpansion;
import io.github.mooy1.infinityexpansion.implementation.mobdata.MobSimulationChamber;
-import io.github.mooy1.infinityexpansion.implementation.storage.StorageUnit;
+import io.github.mooy1.infinityexpansion.implementation.blocks.StorageUnit;
import io.github.mooy1.infinityexpansion.lists.InfinityRecipes;
import io.github.mooy1.infinityexpansion.setup.Setup;
import io.github.mooy1.infinityexpansion.setup.commands.Changelog;
@@ -34,32 +34,26 @@ public class InfinityExpansion extends JavaPlugin implements SlimefunAddon {
@Override
public void onEnable() {
instance = this;
-
- //config
+
PluginUtils.setup(this, "Mooy1/InfinityExpansion/master", getFile());
MessageUtils.setPrefix(ChatColor.DARK_GRAY + "[" + ChatColor.AQUA + "Infinity" + ChatColor.GRAY + "Expansion" + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + " ");
new CommandLib(this, "infinityexpansion", "infinityexpansion.admin", "/ie, /ix, /infinity");
CommandLib.addCommands(new Changelog(), new GiveRecipe(), new ResetConfig());
setupConfigOptions(getConfig());
- //stats
@SuppressWarnings("unused")
final Metrics metrics = new Metrics(this, 8991);
- //items
+ InfinityRecipes.preItems();
+
Setup.setup(this);
-
- //set enabled infinity recipes
- InfinityRecipes.setup(this);
-
- //spam console
+
+ InfinityRecipes.postItems(this);
+
for (String line : getChangeLog()) {
getLogger().log(Level.INFO, line);
}
- PluginUtils.runSync(() -> PluginUtils.log("Infinity Expansion will soon be moving some content to another addon! keep an eye out for its release!"), 300);
-
- //ticker
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
if (currentTick < 60) {
currentTick++;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/abstracts/Crafter.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/abstracts/Crafter.java
index b64501f9..801286c3 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/abstracts/Crafter.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/abstracts/Crafter.java
@@ -2,6 +2,7 @@
import io.github.mooy1.infinityexpansion.utils.RecipeUtils;
import io.github.mooy1.infinitylib.filter.FilterType;
+import io.github.mooy1.infinitylib.filter.ItemFilter;
import io.github.mooy1.infinitylib.filter.MultiFilter;
import io.github.mooy1.infinitylib.objects.AbstractContainer;
import io.github.mooy1.infinitylib.player.MessageUtils;
@@ -62,6 +63,8 @@ public abstract class Crafter extends AbstractContainer {
};
private static final int STATUS_SLOT = 23;
+ private static final int EMPTY = new MultiFilter(FilterType.MIN_AMOUNT, new ItemFilter[9]).hashCode();
+
public Crafter(Category category, SlimefunItemStack stack, RecipeType recipeType, ItemStack[] recipe) {
super(category, stack, recipeType, recipe);
@@ -189,6 +192,10 @@ private void craft(@Nonnull BlockMenu inv, @Nonnull Player p) {
private Pair getOutput(@Nonnull BlockMenu inv) {
MultiFilter input = MultiFilter.fromMenu(FilterType.MIN_AMOUNT, inv, INPUT_SLOTS);
+
+ if (input.hashCode() == EMPTY) {
+ return null;
+ }
SlimefunItemStack output = this.recipes.get(input);
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/AdvancedAnvil.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/AdvancedAnvil.java
similarity index 99%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/items/AdvancedAnvil.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/AdvancedAnvil.java
index db8e36fa..bd771a02 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/AdvancedAnvil.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/AdvancedAnvil.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.items;
+package io.github.mooy1.infinityexpansion.implementation.blocks;
import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/InfinityWorkbench.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/InfinityWorkbench.java
similarity index 89%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/items/InfinityWorkbench.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/InfinityWorkbench.java
index 479677a7..65343033 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/InfinityWorkbench.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/InfinityWorkbench.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.items;
+package io.github.mooy1.infinityexpansion.implementation.blocks;
import io.github.mooy1.infinityexpansion.lists.Categories;
import io.github.mooy1.infinityexpansion.lists.InfinityRecipes;
@@ -6,6 +6,7 @@
import io.github.mooy1.infinityexpansion.setup.InfinityCategory;
import io.github.mooy1.infinityexpansion.utils.RecipeUtils;
import io.github.mooy1.infinitylib.filter.FilterType;
+import io.github.mooy1.infinitylib.filter.ItemFilter;
import io.github.mooy1.infinitylib.filter.MultiFilter;
import io.github.mooy1.infinitylib.objects.AbstractContainer;
import io.github.mooy1.infinitylib.player.MessageUtils;
@@ -16,10 +17,10 @@
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
+import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
-import me.mrCookieSlime.Slimefun.cscorelib2.inventory.ItemUtils;
import me.mrCookieSlime.Slimefun.cscorelib2.item.CustomItem;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -58,6 +59,7 @@ public class InfinityWorkbench extends AbstractContainer implements EnergyNetCom
24, 25, 26
};
private static final int RECIPE_SLOT = 7;
+ private static final int EMPTY = new MultiFilter(FilterType.MIN_AMOUNT, new ItemFilter[36]).hashCode();
public InfinityWorkbench() {
super(Categories.MAIN_MATERIALS, Items.INFINITY_WORKBENCH, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {
@@ -102,7 +104,7 @@ public void onNewInstance(@Nonnull BlockMenu menu, @Nonnull Block b) {
return false;
});
menu.addMenuClickHandler(RECIPE_SLOT, (p, slot, item, action) -> {
- InfinityCategory.openFromWorkBench(p, menu);
+ InfinityCategory.open(p, new InfinityCategory.BackEntry(menu, null, null), true);
return false;
});
}
@@ -154,7 +156,7 @@ public void craft(@Nonnull Block b, @Nonnull BlockMenu inv, @Nonnull Player p)
return;
}
- ItemStack output = getOutput(inv);
+ SlimefunItemStack output = getOutput(inv);
if (output == null) { //invalid
MessageUtils.messageWithCD(p, 1000, ChatColor.RED + "Invalid Recipe!");
@@ -171,9 +173,10 @@ public void craft(@Nonnull Block b, @Nonnull BlockMenu inv, @Nonnull Player p)
inv.consumeItem(slot);
}
}
- MessageUtils.message(p, ChatColor.GREEN + "Successfully crafted: " + ChatColor.WHITE + ItemUtils.getItemName(output));
+
+ MessageUtils.message(p, ChatColor.GREEN + "Successfully crafted: " + ChatColor.WHITE + output.getDisplayName());
- inv.pushItem(output, OUTPUT_SLOTS);
+ inv.pushItem(output.clone(), OUTPUT_SLOTS);
setCharge(b.getLocation(), 0);
}
@@ -185,8 +188,12 @@ public void craft(@Nonnull Block b, @Nonnull BlockMenu inv, @Nonnull Player p)
* @return output if any
*/
@Nullable
- public ItemStack getOutput(@Nonnull BlockMenu inv) {
- return InfinityRecipes.RECIPES.inverse().get(MultiFilter.fromMenu(FilterType.MIN_AMOUNT, inv, INPUT_SLOTS));
+ public SlimefunItemStack getOutput(@Nonnull BlockMenu inv) {
+ MultiFilter filter = MultiFilter.fromMenu(FilterType.MIN_AMOUNT, inv, INPUT_SLOTS);
+ if (filter.hashCode() == EMPTY) {
+ return null;
+ }
+ return InfinityRecipes.RECIPES.get(filter);
}
@Nonnull
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/storage/StorageForge.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StorageForge.java
similarity index 97%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/storage/StorageForge.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StorageForge.java
index 3d8637a9..ac666a24 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/storage/StorageForge.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StorageForge.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.storage;
+package io.github.mooy1.infinityexpansion.implementation.blocks;
import io.github.mooy1.infinityexpansion.implementation.abstracts.Crafter;
import io.github.mooy1.infinityexpansion.lists.Categories;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/storage/StorageUnit.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StorageUnit.java
similarity index 99%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/storage/StorageUnit.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StorageUnit.java
index a26b625a..2a55c22c 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/storage/StorageUnit.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StorageUnit.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.storage;
+package io.github.mooy1.infinityexpansion.implementation.blocks;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.abstracts.LoreStorage;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/Strainer.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/Strainer.java
similarity index 97%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/items/Strainer.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/Strainer.java
index f1d1038d..915e9383 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/Strainer.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/Strainer.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.items;
+package io.github.mooy1.infinityexpansion.implementation.blocks;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.lists.Items;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/StrainerBase.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StrainerBase.java
similarity index 99%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/items/StrainerBase.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StrainerBase.java
index 0220010d..b02f5f15 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/items/StrainerBase.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/blocks/StrainerBase.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.items;
+package io.github.mooy1.infinityexpansion.implementation.blocks;
import io.github.mooy1.infinityexpansion.lists.Categories;
import io.github.mooy1.infinityexpansion.lists.Items;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/gear/VeinMinerRune.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/gear/VeinMinerRune.java
index 8673a59a..f8dd9266 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/gear/VeinMinerRune.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/gear/VeinMinerRune.java
@@ -7,6 +7,7 @@
import io.github.mooy1.infinitylib.general.LocationUtils;
import io.github.mooy1.infinitylib.items.LoreUtils;
import io.github.mooy1.infinitylib.math.RandomUtils;
+import io.github.mooy1.infinitylib.player.LeaveListener;
import io.github.mooy1.infinitylib.player.MessageUtils;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
@@ -31,7 +32,6 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
@@ -48,6 +48,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import java.util.UUID;
/**
* A VeinMiner rune, most code from {@link SoulboundRune}
@@ -61,7 +62,7 @@ public class VeinMinerRune extends SlimefunItem implements Listener, NotPlaceabl
private static final int MAX = 64;
private static final long CD = 1000;
private static NamespacedKey key = null;
- private static final Map CDS = new HashMap<>();
+ private static final Map CDS = new HashMap<>();
private static final String[] LORE = {"", ChatColor.AQUA + "Veinminer - Crouch to use"};
private static final Set ALLOWED = new HashSet<>(Arrays.asList(
"_ORE", "_LOG", "_WOOD", "GILDED", "SOUL", "GRAVEL",
@@ -76,7 +77,7 @@ public VeinMinerRune(InfinityExpansion plugin) {
new ItemStack(Material.REDSTONE_ORE), SlimefunItems.BLANK_RUNE, new ItemStack(Material.LAPIS_ORE),
Items.MAGSTEEL, SlimefunItems.MAGIC_LUMP_3, Items.MAGSTEEL,
});
-
+ new LeaveListener(CDS);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
key = new NamespacedKey(plugin, "vein_miner");
}
@@ -207,11 +208,12 @@ public void onBlockBreak(BlockBreakEvent e) {
if (BlockStorage.hasBlockInfo(l)) return;
- if (CDS.containsKey(p) && System.currentTimeMillis() - CDS.get(p) < CD) {
- MessageUtils.messageWithCD(p, 500, ChatColor.GOLD + "Wait " + ChatColor.YELLOW + (CD - (System.currentTimeMillis() - CDS.get(p))) + ChatColor.GOLD + " ms before using again!");
+ Long prev = CDS.get(p.getUniqueId());
+ if (prev != null && System.currentTimeMillis() - prev < CD) {
+ MessageUtils.messageWithCD(p, 500, ChatColor.GOLD + "Wait " + ChatColor.YELLOW + (CD - (System.currentTimeMillis() - prev)) + ChatColor.GOLD + " ms before using again!");
return;
}
- CDS.put(p, System.currentTimeMillis());
+ CDS.put(p.getUniqueId(), System.currentTimeMillis());
Set found = new HashSet<>();
Set checked = new HashSet<>();
@@ -273,9 +275,4 @@ private void getVein(Set checked, Set found, Location l, Block
}
}
- @EventHandler
- private void onPlayerLeave(PlayerQuitEvent e) {
- CDS.remove(e.getPlayer());
- }
-
}
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/EnergyGenerator.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/generators/EnergyGenerator.java
similarity index 99%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/EnergyGenerator.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/generators/EnergyGenerator.java
index 1954d847..847d0269 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/EnergyGenerator.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/generators/EnergyGenerator.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.machines;
+package io.github.mooy1.infinityexpansion.implementation.generators;
import io.github.mooy1.infinityexpansion.lists.Categories;
import io.github.mooy1.infinityexpansion.lists.InfinityRecipes;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/InfinityReactor.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/generators/InfinityReactor.java
similarity index 99%
rename from src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/InfinityReactor.java
rename to src/main/java/io/github/mooy1/infinityexpansion/implementation/generators/InfinityReactor.java
index d220bb9a..5fd17303 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/InfinityReactor.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/generators/InfinityReactor.java
@@ -1,4 +1,4 @@
-package io.github.mooy1.infinityexpansion.implementation.machines;
+package io.github.mooy1.infinityexpansion.implementation.generators;
import io.github.mooy1.infinityexpansion.lists.Categories;
import io.github.mooy1.infinityexpansion.lists.InfinityRecipes;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/ConversionMachine.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/ConversionMachine.java
index f44d546e..dee9ef26 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/ConversionMachine.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/ConversionMachine.java
@@ -14,7 +14,6 @@
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
-import lombok.Getter;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
@@ -22,6 +21,7 @@
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
+import me.mrCookieSlime.Slimefun.cscorelib2.collections.Pair;
import me.mrCookieSlime.Slimefun.cscorelib2.item.CustomItem;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -31,7 +31,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
/**
@@ -40,8 +39,7 @@
* @author Mooy1
*/
public class ConversionMachine extends AbstractContainer implements RecipeDisplayItem, EnergyNetComponent {
-
- public static final int TIME = 4;
+
public static final int FREEZER_SPEED = 2;
public static final int FREEZER_ENERGY = 120;
public static final int URANIUM_SPEED = 1;
@@ -49,31 +47,25 @@ public class ConversionMachine extends AbstractContainer implements RecipeDispla
public static final int DUST_SPEED = 4;
public static final int DUST_ENERGY = 300;
public static final int DECOM_SPEED = 4;
- public static final int DECOM_ENERGY = 180;
+ public static final int DECOM_ENERGY = 90;
private static final int[] INPUT_SLOTS = {MenuPreset.slot1};
private static final int[] OUTPUT_SLOTS = {MenuPreset.slot3};
private static final int STATUS_SLOT = MenuPreset.slot2;
private final Type type;
-
- private final HashMap progress = new HashMap<>();
public ConversionMachine(Type type) {
- super(type.getCategory(), type.getItem(), type.getRecipeType(), type.getRecipe());
+ super(type.category, type.item, type.recipeType, type.recipe);
this.type = type;
registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
-
- this.progress.remove(b.getLocation());
-
+
if (inv != null) {
Location l = b.getLocation();
inv.dropItems(l, OUTPUT_SLOTS);
inv.dropItems(l, INPUT_SLOTS);
}
- this.progress.remove(b.getLocation());
-
return true;
});
}
@@ -91,11 +83,6 @@ public void setupInv(@Nonnull BlockMenuPreset blockMenuPreset) {
blockMenuPreset.addItem(STATUS_SLOT, MenuPreset.loadingItemRed, ChestMenuUtils.getEmptyClickHandler());
}
- @Override
- public void onNewInstance(@Nonnull BlockMenu menu, @Nonnull Block b) {
- this.progress.put(b.getLocation(), 0);
- }
-
@Override
public int[] getTransportSlots(@Nonnull ItemTransportFlow flow) {
if (flow == ItemTransportFlow.INSERT) {
@@ -109,10 +96,9 @@ public int[] getTransportSlots(@Nonnull ItemTransportFlow flow) {
@Override
public void tick(@Nonnull Block b, @Nonnull BlockMenu inv) {
- int energy = this.type.getEnergy();
- int charge = getCharge(b.getLocation());
+ int energy = this.type.energy;
- if (charge < energy) { //not enough energy
+ if (getCharge(b.getLocation()) < energy) { //not enough energy
if (inv.hasViewer()) {
inv.replaceExistingItem(STATUS_SLOT, MenuPreset.notEnoughEnergy);
}
@@ -128,35 +114,22 @@ public void tick(@Nonnull Block b, @Nonnull BlockMenu inv) {
return;
}
- ItemStack output = getOutput(input);
+ Pair pair = getOutput(input);
- if (output == null) {
+ if (pair == null) {
if (inv.hasViewer()) {
inv.replaceExistingItem(STATUS_SLOT, MenuPreset.invalidInput);
}
return;
}
-
- int progress = this.progress.computeIfAbsent(b.getLocation(), k -> 0);
- if (progress < TIME) {
- inv.consumeItem(INPUT_SLOTS[0], 1);
- this.progress.put(b.getLocation(), progress + this.type.getSpeed());
+ if (inv.fits(pair.getFirstValue(), OUTPUT_SLOTS)) {
+ inv.consumeItem(INPUT_SLOTS[0], pair.getSecondValue());
+ inv.pushItem(pair.getFirstValue(), OUTPUT_SLOTS);
removeCharge(b.getLocation(), energy);
if (inv.hasViewer()) {
inv.replaceExistingItem(STATUS_SLOT, new CustomItem(Material.LIME_STAINED_GLASS_PANE, "&aConverting..."));
}
- return;
- }
-
- if (inv.fits(output, OUTPUT_SLOTS)) {
- inv.pushItem(output, OUTPUT_SLOTS);
- removeCharge(b.getLocation(), energy);
- inv.consumeItem(INPUT_SLOTS[0], 1);
- this.progress.put(b.getLocation(), this.type.getSpeed());
- if (inv.hasViewer()) {
- inv.replaceExistingItem(STATUS_SLOT, new CustomItem(Material.LIME_STAINED_GLASS_PANE, "&aConverted!"));
- }
} else if (inv.hasViewer()) {
inv.replaceExistingItem(STATUS_SLOT, MenuPreset.notEnoughRoom);
@@ -171,7 +144,7 @@ public EnergyNetComponentType getEnergyComponentType() {
@Override
public int getCapacity() {
- return this.type.getEnergy() * 2;
+ return this.type.energy;
}
@Nonnull
@@ -179,8 +152,8 @@ public int getCapacity() {
public List getDisplayRecipes() {
List items = new ArrayList<>();
- ItemFilter[] inputs = this.type.getInput();
- ItemStack[] outputs = this.type.getOutput();
+ ItemFilter[] inputs = this.type.input;
+ ItemStack[] outputs = this.type.output;
if (inputs.length == outputs.length) { //1 to 1
for (int i = 0 ; i < inputs.length ; i++) {
@@ -200,69 +173,66 @@ public List getDisplayRecipes() {
}
@Nullable
- private ItemStack getOutput(@Nonnull ItemStack input) {
- int i = 0;
- for (ItemFilter filter : this.type.getInput()) {
- if (filter.matches(new ItemFilter(input, FilterType.MIN_AMOUNT), FilterType.MIN_AMOUNT)) {
- if (this.type.isRandom()) {
- return RandomUtils.randomOutput(this.type.getOutput());
+ private Pair getOutput(@Nonnull ItemStack input) {
+ for (int i = 0 ; i < this.type.input.length ; i ++) {
+ ItemFilter filter = this.type.input[i];
+ if (filter.fits(new ItemFilter(input, FilterType.MIN_AMOUNT), FilterType.MIN_AMOUNT)) {
+ if (this.type.random) {
+ return new Pair<>(RandomUtils.randomOutput(this.type.output), filter.getAmount());
} else {
- return this.type.output[i].clone();
+ return new Pair<>(this.type.output[i].clone(), filter.getAmount());
}
}
- i++;
}
return null;
}
-
- @Getter
+
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum Type {
- FREEZER(Categories.ADVANCED_MACHINES, Items.EXTREME_FREEZER, FREEZER_ENERGY, FREEZER_SPEED, FREEZER_INPUT, FREEZER_OUTPUT,
+ FREEZER(Categories.ADVANCED_MACHINES, Items.EXTREME_FREEZER, FREEZER_ENERGY, FREEZER_INPUT, FREEZER_OUTPUT,
RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[]{
SlimefunItems.FREEZER_2, SlimefunItems.FREEZER_2, SlimefunItems.FREEZER_2,
new ItemStack(Material.WATER_BUCKET), SlimefunItems.FLUID_PUMP, new ItemStack(Material.WATER_BUCKET),
Items.MACHINE_CIRCUIT, Items.MACHINE_CORE, Items.MACHINE_CIRCUIT,
}, false),
- DECOM(Categories.ADVANCED_MACHINES, Items.DECOMPRESSOR, DECOM_ENERGY, DECOM_SPEED, DECOM_INPUT, DECOM_OUTPUT,
+ DECOM(Categories.ADVANCED_MACHINES, Items.DECOMPRESSOR, DECOM_ENERGY, DECOM_INPUT, DECOM_OUTPUT,
RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {
Items.MAGSTEEL_PLATE, Items.MAGSTEEL_PLATE, Items.MAGSTEEL_PLATE,
new ItemStack(Material.STICKY_PISTON), SlimefunItems.ELECTRIC_PRESS_2, new ItemStack(Material.STICKY_PISTON),
Items.MACHINE_CIRCUIT, Items.MACHINE_CORE, Items.MACHINE_CIRCUIT,
}, false),
- DUST(Categories.ADVANCED_MACHINES, Items.DUST_EXTRACTOR, DUST_ENERGY, DUST_SPEED, DUST_INPUT, DUST_OUTPUT,
+ DUST(Categories.ADVANCED_MACHINES, Items.DUST_EXTRACTOR, DUST_ENERGY, DUST_INPUT, DUST_OUTPUT,
RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[]{
SlimefunItems.ELECTRIC_ORE_GRINDER_2, SlimefunItems.ELECTRIC_GOLD_PAN_3, SlimefunItems.ELECTRIC_DUST_WASHER_3,
SlimefunItems.ELECTRIC_ORE_GRINDER_2, SlimefunItems.ELECTRIC_GOLD_PAN_3, SlimefunItems.ELECTRIC_DUST_WASHER_3,
Items.MACHINE_CIRCUIT, Items.MACHINE_CORE, Items.MACHINE_CIRCUIT,
}, true),
- URANIUM(Categories.ADVANCED_MACHINES, Items.URANIUM_EXTRACTOR, URANIUM_ENERGY, URANIUM_SPEED, URANIUM_INPUT, URANIUM_OUTPUT,
+ URANIUM(Categories.ADVANCED_MACHINES, Items.URANIUM_EXTRACTOR, URANIUM_ENERGY, URANIUM_INPUT, URANIUM_OUTPUT,
RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[]{
SlimefunItems.ELECTRIC_ORE_GRINDER_2, SlimefunItems.ELECTRIC_ORE_GRINDER_2, SlimefunItems.ELECTRIC_ORE_GRINDER_2,
SlimefunItems.ELECTRIC_GOLD_PAN_3, SlimefunItems.ELECTRIC_DUST_WASHER_3, SlimefunItems.AUTOMATED_CRAFTING_CHAMBER,
Items.MACHINE_CIRCUIT, Items.MACHINE_CORE, Items.MACHINE_CIRCUIT,
}, false);
-
- @Nonnull
+
private final Category category;
private final SlimefunItemStack item;
private final int energy;
- private final int speed;
private final ItemFilter[] input;
private final ItemStack[] output;
private final RecipeType recipeType;
private final ItemStack[] recipe;
private final boolean random;
+
}
private static final ItemFilter[] URANIUM_INPUT = {
- new ItemFilter(Material.COBBLESTONE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.ANDESITE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.STONE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.DIORITE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.GRANITE, 1, FilterType.MIN_AMOUNT)
+ new ItemFilter(Material.COBBLESTONE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.ANDESITE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.STONE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.DIORITE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.GRANITE, 4, FilterType.MIN_AMOUNT)
};
private static final ItemStack[] URANIUM_OUTPUT = {
@@ -270,8 +240,8 @@ public enum Type {
};
private static final ItemFilter[] FREEZER_INPUT = {
- new ItemFilter(Material.ICE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.MAGMA_BLOCK, 1, FilterType.MIN_AMOUNT)
+ new ItemFilter(Material.ICE, 2, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.MAGMA_BLOCK, 2, FilterType.MIN_AMOUNT)
};
private static final ItemStack[] FREEZER_OUTPUT = {
@@ -280,11 +250,11 @@ public enum Type {
};
private static final ItemFilter[] DUST_INPUT = {
- new ItemFilter(Material.COBBLESTONE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.ANDESITE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.STONE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.DIORITE, 1, FilterType.MIN_AMOUNT),
- new ItemFilter(Material.GRANITE, 1, FilterType.MIN_AMOUNT)
+ new ItemFilter(Material.COBBLESTONE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.ANDESITE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.STONE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.DIORITE, 4, FilterType.MIN_AMOUNT),
+ new ItemFilter(Material.GRANITE, 4, FilterType.MIN_AMOUNT)
};
private static final ItemStack[] DUST_OUTPUT = {
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/PoweredBedrock.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/PoweredBedrock.java
index dfd233d8..a56472a5 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/PoweredBedrock.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/PoweredBedrock.java
@@ -22,7 +22,7 @@
*/
public class PoweredBedrock extends SlimefunItem implements EnergyNetComponent {
- public static final int ENERGY = 30_000;
+ public static final int ENERGY = 10_000;
public PoweredBedrock() {
super (Categories.INFINITY_CHEAT, Items.POWERED_BEDROCK, RecipeTypes.INFINITY_WORKBENCH, InfinityRecipes.getRecipe(Items.POWERED_BEDROCK));
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/SingularityConstructor.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/SingularityConstructor.java
index 51d41157..d2888579 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/SingularityConstructor.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/SingularityConstructor.java
@@ -45,7 +45,7 @@ public class SingularityConstructor extends AbstractContainer implements EnergyN
public static final int BASIC_ENERGY = 120;
public static final int BASIC_SPEED = 1;
public static final int INFINITY_ENERGY = 1200;
- public static final int INFINITY_SPEED = 10;
+ public static final int INFINITY_SPEED = 32;
private final Type type;
private static final int STATUS_SLOT = 13;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/VoidHarvester.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/VoidHarvester.java
index 55501c7b..42bf7c26 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/VoidHarvester.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/machines/VoidHarvester.java
@@ -41,13 +41,13 @@ public class VoidHarvester extends AbstractContainer implements EnergyNetCompone
public static final int BASIC_ENERGY = 120;
public static final int BASIC_SPEED = 1;
public static final int INFINITY_ENERGY = 1200;
- public static final int INFINITY_SPEED = 10;
+ public static final int INFINITY_SPEED = 32;
private static final int[] OUTPUT_SLOTS = {
13
};
private static final int STATUS_SLOT = 4;
- private static final int TIME = 1000;
+ private static final int TIME = 960;
private final Type type;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataCard.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataCard.java
index 0847691a..0191f1c1 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataCard.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataCard.java
@@ -8,7 +8,6 @@
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
-import lombok.Getter;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import org.bukkit.Material;
@@ -23,15 +22,14 @@
import java.util.Map;
public class MobDataCard extends SlimefunItem implements RecipeDisplayItem, NotPlaceable {
-
- @Getter
- private final Type type;
+
public static final Map CARDS = new HashMap<>();
-
+ private final Type type;
+
public MobDataCard(Type type) {
- super(Categories.MOB_SIMULATION, type.getItem(), RecipeTypes.DATA_INFUSER, type.getRecipe());
+ super(Categories.MOB_SIMULATION, type.item, RecipeTypes.DATA_INFUSER, type.recipe);
this.type = type;
- CARDS.put(type.getItem().getItemId(), type);
+ CARDS.put(type.item.getItemId(), type);
}
@Nonnull
@@ -39,109 +37,115 @@ public MobDataCard(Type type) {
public List getDisplayRecipes() {
List items = new ArrayList<>();
- for (int i : this.type.getDrops().keySet()) {
+ for (int i : this.type.drops.keySet()) {
items.add(null);
- items.add(this.type.getDrops().get(i));
+ items.add(this.type.drops.get(i));
}
return items;
}
-
- @Getter
+
public enum Type {
- ZOMBIE("Zombie", 60, 1, false, new ItemStack[]{
+ ZOMBIE("Zombie", 60, 1, 2, new ItemStack[]{
new ItemStack(Material.IRON_SWORD, 1), new ItemStack(Material.ROTTEN_FLESH, 16), new ItemStack(Material.IRON_SHOVEL, 1),
- new ItemStack(Material.IRON_INGOT, 1), Items.EMPTY_DATA_CARD, new ItemStack(Material.IRON_INGOT, 1),
- new ItemStack(Material.CARROT, 1), new ItemStack(Material.ROTTEN_FLESH, 16), new ItemStack(Material.POTATO, 1)
- }, ImmutableMap.of(1, new ItemStack(Material.ROTTEN_FLESH, 2), 8, new ItemStack(Material.IRON_INGOT))),
-
- SPIDER("Spider", 90, 1, false, new ItemStack[]{
- new ItemStack(Material.COBWEB, 1), new ItemStack(Material.STRING, 16), new ItemStack(Material.COBWEB, 1),
- new ItemStack(Material.SPIDER_EYE, 8), Items.EMPTY_DATA_CARD, new ItemStack(Material.SPIDER_EYE, 8),
- new ItemStack(Material.COBWEB, 1), new ItemStack(Material.STRING, 16), new ItemStack(Material.COBWEB, 1)
+ new ItemStack(Material.IRON_INGOT, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.IRON_INGOT, 1),
+ new ItemStack(Material.CARROT, 64), new ItemStack(Material.ROTTEN_FLESH, 16), new ItemStack(Material.POTATO, 64)
+ }, ImmutableMap.of(1, new ItemStack(Material.ROTTEN_FLESH, 1), 8, new ItemStack(Material.IRON_INGOT))),
+
+ COW("Cow", 30, 1, 1, new ItemStack[]{
+ new ItemStack(Material.LEATHER, 64), new ItemStack(Material.BEEF, 64), new ItemStack(Material.LEATHER, 64),
+ new ItemStack(Material.COOKED_BEEF, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.COOKED_BEEF, 64),
+ new ItemStack(Material.LEATHER, 64), new ItemStack(Material.BEEF, 64), new ItemStack(Material.LEATHER, 64)
+ }, ImmutableMap.of(1, new ItemStack(Material.BEEF, 1), 2, new ItemStack(Material.LEATHER, 2))),
+
+ SHEEP("Sheep", 30, 1, 1, new ItemStack[]{
+ new ItemStack(Material.WHITE_WOOL, 64), new ItemStack(Material.MUTTON, 64), new ItemStack(Material.WHITE_WOOL, 64),
+ new ItemStack(Material.COOKED_MUTTON, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.COOKED_MUTTON, 64),
+ new ItemStack(Material.WHITE_WOOL, 64), new ItemStack(Material.MUTTON, 64), new ItemStack(Material.WHITE_WOOL, 64)
+ }, ImmutableMap.of(1, new ItemStack(Material.MUTTON, 1), 2, new ItemStack(Material.WHITE_WOOL, 2))),
+
+ SPIDER("Spider", 90, 1, 2, new ItemStack[]{
+ new ItemStack(Material.COBWEB, 8), new ItemStack(Material.STRING, 64), new ItemStack(Material.COBWEB, 8),
+ new ItemStack(Material.SPIDER_EYE, 32), Items.EMPTY_DATA_CARD, new ItemStack(Material.SPIDER_EYE, 32),
+ new ItemStack(Material.COBWEB, 8), new ItemStack(Material.STRING, 64), new ItemStack(Material.COBWEB, 8)
}, ImmutableMap.of(1, new ItemStack(Material.STRING, 2), 2, new ItemStack(Material.SPIDER_EYE))),
- SKELLY("Skeleton", 90, 1, false, new ItemStack[]{
- new ItemStack(Material.LEATHER_HELMET, 1), new ItemStack(Material.BONE, 16), new ItemStack(Material.LEATHER_HELMET, 1),
- new ItemStack(Material.ARROW, 16), Items.EMPTY_DATA_CARD, new ItemStack(Material.ARROW, 16),
- new ItemStack(Material.BOW, 1), new ItemStack(Material.BONE, 16), new ItemStack(Material.BOW, 1)
+ SKELLY("Skeleton", 90, 1, 2, new ItemStack[]{
+ new ItemStack(Material.LEATHER_HELMET, 1), new ItemStack(Material.BONE, 64), new ItemStack(Material.LEATHER_HELMET, 1),
+ new ItemStack(Material.ARROW, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.ARROW, 64),
+ new ItemStack(Material.BOW, 1), new ItemStack(Material.BONE, 64), new ItemStack(Material.BOW, 1)
}, ImmutableMap.of(1, new ItemStack(Material.BONE, 2), 2, new ItemStack(Material.ARROW, 2), 16, new ItemStack(Material.BOW))),
- WITHER_SKELLY("Wither Skeleton", 150, 3, false, new ItemStack[]{
- new ItemStack(Material.WITHER_SKELETON_SKULL, 1), new ItemStack(Material.BONE, 16), new ItemStack(Material.WITHER_SKELETON_SKULL, 1),
- new ItemStack(Material.COAL, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.COAL, 64),
- new ItemStack(Material.STONE_SWORD, 1), new ItemStack(Material.BONE, 16), new ItemStack(Material.STONE_SWORD, 1)
+ WITHER_SKELLY("Wither Skeleton", 150, 3, 2, new ItemStack[]{
+ new ItemStack(Material.WITHER_SKELETON_SKULL, 8), new ItemStack(Material.BONE, 64), new ItemStack(Material.WITHER_SKELETON_SKULL, 8),
+ new ItemStack(Material.COAL_BLOCK, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.COAL_BLOCK, 64),
+ new ItemStack(Material.STONE_SWORD, 1), new ItemStack(Material.BONE, 64), new ItemStack(Material.STONE_SWORD, 1)
}, ImmutableMap.of(1, new ItemStack(Material.COAL, 1), 2, new ItemStack(Material.BONE, 2),
3, new ItemStack(Material.COAL, 2), 12, new ItemStack(Material.WITHER_SKELETON_SKULL))),
- ENDERMEN("Endermen", 240, 5, false, new ItemStack[]{
- new ItemStack(Material.ENDER_EYE, 1), new ItemStack(Material.OBSIDIAN, 16), new ItemStack(Material.ENDER_EYE, 1),
+ ENDERMEN("Endermen", 240, 5, 2, new ItemStack[]{
+ new ItemStack(Material.ENDER_EYE, 16), new ItemStack(Material.OBSIDIAN, 64), new ItemStack(Material.ENDER_EYE, 16),
new ItemStack(Material.ENDER_PEARL, 16), Items.EMPTY_DATA_CARD, new ItemStack(Material.ENDER_PEARL, 16),
- new ItemStack(Material.ENDER_EYE, 1), new ItemStack(Material.OBSIDIAN, 16), new ItemStack(Material.ENDER_EYE, 1)
+ new ItemStack(Material.ENDER_EYE, 16), new ItemStack(Material.OBSIDIAN, 64), new ItemStack(Material.ENDER_EYE, 16)
}, ImmutableMap.of(1, new ItemStack(Material.ENDER_PEARL, 1), 2, new ItemStack(Material.ENDER_PEARL, 1), 3, Items.ENDER_ESSENCE)),
- CREEPER("Creeper", 120, 2, false, new ItemStack[]{
- new ItemStack(Material.TNT, 1), new ItemStack(Material.GREEN_DYE, 16), new ItemStack(Material.TNT, 1),
+ CREEPER("Creeper", 120, 2, 2, new ItemStack[]{
+ new ItemStack(Material.TNT, 16), new ItemStack(Material.GREEN_DYE, 64), new ItemStack(Material.TNT, 16),
new ItemStack(Material.GUNPOWDER, 16), Items.EMPTY_DATA_CARD, new ItemStack(Material.GUNPOWDER, 16),
- new ItemStack(Material.TNT, 1), new ItemStack(Material.GREEN_DYE, 16), new ItemStack(Material.TNT, 1)
+ new ItemStack(Material.TNT, 16), new ItemStack(Material.GREEN_DYE, 64), new ItemStack(Material.TNT, 16)
}, ImmutableMap.of(1, new ItemStack(Material.GUNPOWDER, 1), 2, new ItemStack(Material.GUNPOWDER, 1))),
- GUARDIAN("Guardian", 240, 2, false, new ItemStack[]{
- new ItemStack(Material.COD, 16), new ItemStack(Material.PRISMARINE_SHARD, 32), new ItemStack(Material.PRISMARINE_CRYSTALS, 16),
+ GUARDIAN("Guardian", 240, 2, 2, new ItemStack[]{
+ new ItemStack(Material.COD, 16), new ItemStack(Material.PRISMARINE_SHARD, 64), new ItemStack(Material.PRISMARINE_CRYSTALS, 64),
new ItemStack(Material.SPONGE, 4), Items.EMPTY_DATA_CARD, new ItemStack(Material.PUFFERFISH, 4),
- new ItemStack(Material.PRISMARINE_CRYSTALS, 16), new ItemStack(Material.PRISMARINE_SHARD, 32), new ItemStack(Material.COOKED_COD, 16)
+ new ItemStack(Material.PRISMARINE_CRYSTALS, 64), new ItemStack(Material.PRISMARINE_SHARD, 64), new ItemStack(Material.COOKED_COD, 16)
}, ImmutableMap.of(1, new ItemStack(Material.PRISMARINE_SHARD), 2, new ItemStack(Material.PRISMARINE_CRYSTALS),
3, new ItemStack(Material.COD), 8, new ItemStack(Material.PUFFERFISH), 16, new ItemStack(Material.SPONGE))),
- CHICKEN("Chicken", 60, 1, false, new ItemStack[]{
- new ItemStack(Material.CHICKEN, 16), new ItemStack(Material.FEATHER, 16), new ItemStack(Material.TNT, 1),
- new ItemStack(Material.EGG, 8), Items.EMPTY_DATA_CARD, new ItemStack(Material.EGG, 8),
- new ItemStack(Material.COOKED_CHICKEN, 16), new ItemStack(Material.FEATHER, 16), new ItemStack(Material.CHICKEN, 16)
+ CHICKEN("Chicken", 60, 1, 1, new ItemStack[]{
+ new ItemStack(Material.CHICKEN, 64), new ItemStack(Material.FEATHER, 64), new ItemStack(Material.COOKED_CHICKEN, 64),
+ new ItemStack(Material.EGG, 16), Items.EMPTY_DATA_CARD, new ItemStack(Material.EGG, 16),
+ new ItemStack(Material.COOKED_CHICKEN, 64), new ItemStack(Material.FEATHER, 64), new ItemStack(Material.CHICKEN, 64)
}, ImmutableMap.of(1, new ItemStack(Material.CHICKEN, 1), 2, new ItemStack(Material.FEATHER, 2),
3, new ItemStack(Material.CHICKEN, 1), 12, new ItemStack(Material.EGG))),
- IRON("Iron Golem", 180, 1, false, new ItemStack[]{
- new ItemStack(Material.IRON_INGOT, 64), new ItemStack(Material.PUMPKIN, 16), new ItemStack(Material.IRON_INGOT, 64),
+ IRON("Iron Golem", 180, 1, 2, new ItemStack[]{
+ new ItemStack(Material.IRON_BLOCK, 64), new ItemStack(Material.PUMPKIN, 16), new ItemStack(Material.IRON_BLOCK, 64),
new ItemStack(Material.POPPY, 16), Items.EMPTY_DATA_CARD, new ItemStack(Material.POPPY, 16),
- new ItemStack(Material.IRON_INGOT, 64), new ItemStack(Material.PUMPKIN, 16), new ItemStack(Material.IRON_INGOT, 64)
+ new ItemStack(Material.IRON_BLOCK, 64), new ItemStack(Material.PUMPKIN, 16), new ItemStack(Material.IRON_BLOCK, 64)
}, ImmutableMap.of(1, new ItemStack(Material.IRON_INGOT, 2), 3, SlimefunItems.BASIC_CIRCUIT_BOARD, 4, new ItemStack(Material.POPPY, 1))),
- BLAZE("Blaze", 150, 5, false, new ItemStack[]{
- new ItemStack(Material.MAGMA_BLOCK, 64), new ItemStack(Material.BLAZE_ROD, 8), new ItemStack(Material.MAGMA_BLOCK, 64),
- new ItemStack(Material.BLAZE_ROD, 8), Items.EMPTY_DATA_CARD, new ItemStack(Material.BLAZE_ROD, 8),
- new ItemStack(Material.MAGMA_BLOCK, 64), new ItemStack(Material.BLAZE_ROD, 8), new ItemStack(Material.MAGMA_BLOCK, 64)
+ BLAZE("Blaze", 150, 5, 2, new ItemStack[]{
+ new ItemStack(Material.MAGMA_BLOCK, 64), new ItemStack(Material.BLAZE_ROD, 64), new ItemStack(Material.MAGMA_BLOCK, 64),
+ new ItemStack(Material.BLAZE_ROD, 64), Items.EMPTY_DATA_CARD, new ItemStack(Material.BLAZE_ROD, 64),
+ new ItemStack(Material.MAGMA_BLOCK, 64), new ItemStack(Material.BLAZE_ROD, 64), new ItemStack(Material.MAGMA_BLOCK, 64)
}, ImmutableMap.of(1, new ItemStack(Material.BLAZE_ROD, 1), 2, new ItemStack(Material.BLAZE_ROD, 1))),
- DRAGON("Ender Dragon", 9000, 150, true, new ItemStack[]{
+ DRAGON("Ender Dragon", 9000, 150, 3, new ItemStack[]{
new ItemStack(Material.END_CRYSTAL, 64), new ItemStack(Material.DRAGON_EGG), new ItemStack(Material.CHORUS_FLOWER, 64),
SlimefunItems.INFUSED_ELYTRA, Items.EMPTY_DATA_CARD, new ItemStack(Material.DRAGON_HEAD, 1),
new SlimefunItemStack(SlimefunItems.ENDER_LUMP_3, 64), Items.VOID_INGOT, new ItemStack(Material.DRAGON_BREATH, 64)
}, ImmutableMap.of(1, new ItemStack(Material.ENDER_PEARL, 3), 2, new ItemStack(Material.DRAGON_BREATH, 2), 8, Items.VOID_BIT));
@Nonnull
- private final String name;
- private final int energy;
- private final int xp;
- private final boolean upgraded;
+ final ItemStack[] recipe;
@Nonnull
- private final ItemStack[] recipe;
+ final Map drops;
@Nonnull
- private final Map drops;
- @Nonnull
- private final SlimefunItemStack item;
+ final SlimefunItemStack item;
+ final int xp;
+ final int energy;
@ParametersAreNonnullByDefault
- Type(String name, int energy, int xp, boolean upgraded, ItemStack[] recipe, Map drops) {
- this.name = name;
- this.energy = energy;
- this.xp = xp;
- this.upgraded = upgraded;
+ Type(String name, int energy, int xp, int tier, ItemStack[] recipe, Map drops) {
this.recipe = recipe;
+ this.xp = xp;
+ this.energy = energy;
this.drops = drops;
this.item = new SlimefunItemStack(
name.toUpperCase(Locale.ROOT).replace(" ", "_") + "_DATA_CARD",
- upgraded ? Material.NETHERITE_CHESTPLATE : Material.DIAMOND_CHESTPLATE,
+ tier == 1 ? Material.IRON_CHESTPLATE : tier == 2 ? Material.DIAMOND_CHESTPLATE : Material.NETHERITE_CHESTPLATE,
"&b" + name + " Data Card",
"&7Place in a mob simulation chamber to activate",
"",
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataInfuser.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataInfuser.java
index 022ca85a..8830c106 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataInfuser.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobDataInfuser.java
@@ -36,7 +36,7 @@ public MobDataInfuser() {
public SlimefunItemStack[] getOutputs() {
List OUTPUTS = new ArrayList<>();
for (MobDataCard.Type card : MobDataCard.CARDS.values()) {
- OUTPUTS.add(card.getItem());
+ OUTPUTS.add(card.item);
}
return OUTPUTS.toArray(new SlimefunItemStack[0]);
}
@@ -45,7 +45,7 @@ public SlimefunItemStack[] getOutputs() {
public ItemStack[][] getRecipes() {
List recipes = new ArrayList<>();
for (MobDataCard.Type card : MobDataCard.CARDS.values()) {
- recipes.add(card.getRecipe());
+ recipes.add(card.recipe);
}
return recipes.toArray(new ItemStack[0][]);
}
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobSimulationChamber.java b/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobSimulationChamber.java
index de967cec..80634432 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobSimulationChamber.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/implementation/mobdata/MobSimulationChamber.java
@@ -76,7 +76,7 @@ public void tick(@Nonnull Block b, @Nonnull BlockMenu inv) {
return;
}
- int energy = card.getEnergy() + ENERGY;
+ int energy = card.energy + ENERGY;
if (getCharge(b.getLocation()) < energy) {
if (inv.hasViewer()) {
@@ -93,16 +93,15 @@ public void tick(@Nonnull Block b, @Nonnull BlockMenu inv) {
if (!InfinityExpansion.progressEvery(INTERVAL)) return;
if (RandomUtils.chanceIn(CHANCE)) {
- int xp = getXP(b.getLocation()) + card.getXp();
+ int xp = getXP(b.getLocation()) + card.xp;
setXp(b.getLocation(), xp);
}
- for (Map.Entry entry : card.getDrops().entrySet()) {
+ for (Map.Entry entry : card.drops.entrySet()) {
if (RandomUtils.chanceIn(entry.getKey())) {
ItemStack output = entry.getValue();
if (inv.fits(output, OUTPUT_SLOTS)) {
- output = output.clone();
- inv.pushItem(output, OUTPUT_SLOTS);
+ inv.pushItem(output.clone(), OUTPUT_SLOTS);
} else if (inv.hasViewer()) {
inv.replaceExistingItem(STATUS_SLOT, MenuPreset.notEnoughRoom);
}
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/lists/Categories.java b/src/main/java/io/github/mooy1/infinityexpansion/lists/Categories.java
index 8d35fde9..f7df2f98 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/lists/Categories.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/lists/Categories.java
@@ -1,7 +1,7 @@
package io.github.mooy1.infinityexpansion.lists;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
-import io.github.mooy1.infinityexpansion.setup.HiddenCategory;
+import io.github.mooy1.infinityexpansion.setup.SubCategory;
import io.github.mooy1.infinityexpansion.setup.InfinityCategory;
import io.github.mooy1.infinityexpansion.setup.MainCategory;
import me.mrCookieSlime.Slimefun.Objects.Category;
@@ -22,27 +22,27 @@ public final class Categories {
new CustomItem(Material.NETHER_STAR, "&bInfinity &7Expansion"), -1
);
- public static final Category MAIN_MATERIALS = new HiddenCategory(new NamespacedKey(instance, "main_materials"),
+ public static final Category MAIN_MATERIALS = new SubCategory(new NamespacedKey(instance, "main_materials"),
new CustomItem(Material.NETHER_STAR, "&bInfinity &7Expansion"), 2
);
- public static final Category BASIC_MACHINES = new HiddenCategory(new NamespacedKey(instance, "basic_machines"),
+ public static final Category BASIC_MACHINES = new SubCategory(new NamespacedKey(instance, "basic_machines"),
new CustomItem(Material.LOOM, "&9Basic &7Powered Machines"), 2
);
- public static final Category ADVANCED_MACHINES = new HiddenCategory(new NamespacedKey(instance, "advanced_machines"),
+ public static final Category ADVANCED_MACHINES = new SubCategory(new NamespacedKey(instance, "advanced_machines"),
new CustomItem(Material.BLAST_FURNACE, "&cAdvanced &7Powered Machines"), 2
);
- public static final Category STORAGE_TRANSPORT = new HiddenCategory(new NamespacedKey(instance, "storage_transport"),
+ public static final Category STORAGE_TRANSPORT = new SubCategory(new NamespacedKey(instance, "storage_transport"),
new CustomItem(Material.ENDER_CHEST, "&6Storage and Transport"), 2
);
- public static final Category MOB_SIMULATION = new HiddenCategory(new NamespacedKey(instance, "mob_simulation"),
+ public static final Category MOB_SIMULATION = new SubCategory(new NamespacedKey(instance, "mob_simulation"),
new CustomItem(Material.SPAWNER, "&bMob Simulation"), 2
);
- public static final Category INFINITY_MATERIALS = new HiddenCategory(new NamespacedKey(instance, "infinity_materials"),
+ public static final Category INFINITY_MATERIALS = new SubCategory(new NamespacedKey(instance, "infinity_materials"),
new CustomItem(Material.NETHERITE_BLOCK, "&bInfinity &aMaterials"), 2
);
@@ -50,7 +50,7 @@ public final class Categories {
new CustomItem(Material.SMITHING_TABLE, "&bInfinity &7Recipes"), 2
);
- public static final Category INFINITY_CHEAT = new HiddenCategory(new NamespacedKey(instance, "infinity_cheat"),
+ public static final Category INFINITY_CHEAT = new SubCategory(new NamespacedKey(instance, "infinity_cheat"),
new CustomItem(Material.SMITHING_TABLE, "&bInfinity &7Recipes &c- NOT REAL RECIPES"), 2
);
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/lists/InfinityRecipes.java b/src/main/java/io/github/mooy1/infinityexpansion/lists/InfinityRecipes.java
index 043895fd..5f782a05 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/lists/InfinityRecipes.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/lists/InfinityRecipes.java
@@ -2,24 +2,19 @@
import com.google.common.collect.HashBiMap;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
-import io.github.mooy1.infinitylib.PluginUtils;
import io.github.mooy1.infinitylib.filter.FilterType;
-import io.github.mooy1.infinitylib.filter.ItemFilter;
import io.github.mooy1.infinitylib.filter.MultiFilter;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.cscorelib2.collections.Pair;
-import me.mrCookieSlime.Slimefun.cscorelib2.inventory.ItemUtils;
-import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import javax.annotation.Nonnull;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
@@ -34,7 +29,7 @@
* - setting the RecipeType to RecipeTypes.INFINITY_WORKBENCH
* - setting the Recipe to InfinityRecipes.getRecipe(item)
*/
-public class InfinityRecipes {
+public final class InfinityRecipes {
private static final ItemStack m_circuit = Items.MACHINE_CIRCUIT;
private static final ItemStack m_plate = Items.MACHINE_PLATE;
@@ -63,253 +58,242 @@ public class InfinityRecipes {
private static final ItemStack podzol = new ItemStack(Material.PODZOL);
private static final ItemStack grass = new ItemStack(Material.GRASS_BLOCK);
- public static final HashBiMap RECIPES = HashBiMap.create();
- public static final Map STRINGS = new HashMap<>();
- public static final List> IDS = new ArrayList<>();
+ public static final HashBiMap RECIPES = HashBiMap.create();
+ public static final LinkedHashMap> ITEMS = new LinkedHashMap<>();
+ public static final List IDS = new ArrayList<>();
/**
* This method gets the enabled infinity items and
* adds them and their recipe to the machine
*/
- public static void setup(@Nonnull InfinityExpansion instance) {
+ public static void postItems(@Nonnull InfinityExpansion instance) {
instance.getLogger().log(Level.INFO, "Loading Infinity Recipes...");
//check for disabled items
- try {
- int i = 0;
- for (SlimefunItemStack stack : new HashSet<>(RECIPES.keySet())) {
- if (Objects.requireNonNull(stack.getItem()).isDisabled()) {
- RECIPES.remove(stack);
- instance.getLogger().log(Level.INFO, ChatColor.RED + "Infinity Item " + ItemUtils.getItemName(stack) + " disabled!");
- } else {
- STRINGS.put(stack.getItemId(), i);
- IDS.add(new Pair<>(stack, getRecipe(Objects.requireNonNull(RECIPES.get(stack)))));
- i++;
- }
+ Iterator iterator = RECIPES.values().iterator();
+ while (iterator.hasNext()) {
+ SlimefunItemStack stack = iterator.next();
+ if (Objects.requireNonNull(stack.getItem()).isDisabled()) {
+ iterator.remove();
+ ITEMS.remove(stack.getItemId());
+ IDS.remove(stack.getItemId());
+ instance.getLogger().log(Level.INFO, "Infinity Item " + stack.getItemId() + " disabled!");
}
- } catch (Exception e) {
- PluginUtils.log(Level.SEVERE, "There was an error Loading Infinity Recipes");
}
}
-
- @Nonnull
- private static ItemStack[] getRecipe(@Nonnull MultiFilter filter) {
- ItemFilter[] filters = filter.getFilters();
- ItemStack[] recipe = new ItemStack[filters.length];
- for (int i = 0 ; i < filters.length ; i++) {
- if (filters[i] != null) {
- recipe[i] = filters[i].getItem();
- }
- }
- return recipe;
- }
@Nonnull
public static ItemStack[] getRecipe(@Nonnull SlimefunItemStack stack) {
- return getRecipe(Objects.requireNonNull(RECIPES.get(stack)));
+ return ITEMS.get(stack.getItemId()).getSecondValue();
}
-
- static {
- RECIPES.put(Items.INFINITE_MACHINE_CORE, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+
+ public static void preItems() {
+ addRecipe(new ItemStack[] {
m_plate, m_core, infinite, infinite, m_core, m_plate,
m_core, m_plate, m_circuit, m_circuit, m_plate, m_core,
infinite, m_circuit, infinite, infinite, m_circuit, infinite,
infinite, m_circuit, infinite, infinite, m_circuit, infinite,
m_core, m_plate, m_circuit, m_circuit, m_plate, m_core,
m_plate, m_core, infinite, infinite, m_core, m_plate
- ));
- RECIPES.put(Items.INFINITE_MACHINE_CIRCUIT, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITE_MACHINE_CORE);
+ addRecipe(new ItemStack[] {
m_circuit, infinite, m_circuit, m_circuit, infinite, m_circuit,
voidIng, m_circuit, voidIng, voidIng, m_circuit, voidIng,
infinite, voidIng, m_circuit, m_circuit, voidIng, infinite,
infinite, voidIng, m_circuit, m_circuit, voidIng, infinite,
voidIng, m_circuit, voidIng, voidIng, m_circuit, voidIng,
m_circuit, infinite, m_circuit, m_circuit, infinite, m_circuit
- ));
- RECIPES.put(Items.INFINITE_PANEL, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITE_MACHINE_CIRCUIT);
+ addRecipe(new ItemStack[] {
c_panel, c_panel, c_panel, c_panel, c_panel, c_panel,
c_panel, c_panel, c_panel, c_panel, c_panel, c_panel,
infinite, infinite, infinite, infinite, infinite, infinite,
infinite, i_circuit, i_core, i_core, i_circuit, infinite,
infinite, infinite, infinite, infinite, infinite, infinite,
v_panel, v_panel, v_panel, v_panel, v_panel, v_panel
- ));
- RECIPES.put(Items.POWERED_BEDROCK, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITE_PANEL);
+ addRecipe(new ItemStack[] {
c_5, c_5, c_5, c_5, c_5, c_5,
c_5, m_plate, voidIng, voidIng, m_plate, c_5,
c_5, voidIng, e_c, e_c, voidIng, c_5,
c_5, voidIng, i_core, i_circuit, voidIng, c_5,
c_5, m_plate, voidIng, voidIng, m_plate, c_5,
c_5, c_5, c_5, c_5, c_5, c_5
- ));
- RECIPES.put(Items.INFINITY_REACTOR, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.POWERED_BEDROCK);
+ addRecipe(new ItemStack[] {
null, infinite, infinite, infinite, infinite, null,
infinite, infinite, voidIng, voidIng, infinite, infinite,
infinite, m_plate, m_plate, m_plate, m_plate, infinite,
infinite, m_plate, reactor, reactor, m_plate, infinite,
infinite, m_plate, m_plate, m_plate, m_plate, infinite,
infinite, i_circuit, i_core, i_core, i_circuit, infinite
- ));
- RECIPES.put(Items.INFINITY_QUARRY, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_REACTOR);
+ addRecipe(new ItemStack[] {
null, m_plate, m_plate, m_plate, m_plate, null,
m_plate, i_pick, i_circuit, i_circuit, i_pick, m_plate,
m_plate, voidIng, i_core, i_core, voidIng, m_plate,
voidIng, null, infinite, infinite, null, voidIng,
voidIng, null, infinite, infinite, null, voidIng,
voidIng, null, infinite, infinite, null, voidIng
- ));
- RECIPES.put(Items.INFINITY_CONSTRUCTOR, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_QUARRY);
+ addRecipe(new ItemStack[] {
null, m_plate, m_plate, m_plate, m_plate, null,
null, voidIng, i_circuit, i_circuit, voidIng, null,
null, voidIng, s_c, s_c, voidIng, null,
null, voidIng, s_c, s_c, voidIng, null,
null, infinite, i_core, i_core, infinite, null,
infinite, infinite, infinite, infinite, infinite, infinite
- ));
- RECIPES.put(Items.INFINITY_TREE_GROWER, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_CONSTRUCTOR);
+ addRecipe(new ItemStack[] {
glass, glass, glass, glass, glass, glass,
glass, tree, null, null, tree, glass,
glass, grower, null, null, grower, glass,
glass, tree, null, null, tree, glass,
m_plate, podzol, podzol, podzol, podzol, m_plate,
m_plate, i_circuit, i_core, i_core, i_circuit, m_plate
- ));
- RECIPES.put(Items.INFINITY_VIRTUAL_FARM, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_TREE_GROWER);
+ addRecipe(new ItemStack[] {
glass, glass, glass, glass, glass, glass,
glass, null, null, null, null, glass,
glass, null, null, null, null, glass,
glass, grass, grass, grass, grass, glass,
m_plate, crop, virtual, virtual, crop, m_plate,
m_plate, i_circuit, i_core, i_core, i_circuit, m_plate
- ));
- RECIPES.put(Items.INFINITE_VOID_HARVESTER, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_VIRTUAL_FARM);
+ addRecipe(new ItemStack[] {
m_plate, m_plate, m_plate, m_plate, m_plate, m_plate,
mag, voidIng, voidIng, voidIng, voidIng, mag,
mag, voidIng, i_circuit, i_circuit, voidIng, mag,
mag, voidIng, i_core, i_core, voidIng, mag,
mag, voidIng, voidIng, voidIng, voidIng, mag,
m_plate, m_plate, m_plate, m_plate, m_plate, m_plate
- ));
- RECIPES.put(Items.INFINITY_CAPACITOR, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITE_VOID_HARVESTER);
+ addRecipe(new ItemStack[] {
null, infinite, voidIng, voidIng, infinite, null,
null, infinite, i_circuit, i_circuit, infinite, null,
null, infinite, e_c, e_c, infinite, null,
null, infinite, e_c, e_c, infinite, null,
null, infinite, i_circuit, i_circuit, infinite, null,
null, infinite, voidIng, voidIng, infinite, null
- ));
- RECIPES.put(Items.INFINITY_ENCHANTER, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_CAPACITOR);
+ addRecipe(new ItemStack[] {
null, null, null, null, null, null,
voidIng, null, null, null, null, voidIng,
voidIng, voidIng, en, en, voidIng, voidIng,
m_plate, voidIng, i_circuit, i_circuit, voidIng, m_plate,
m_plate, voidIng, i_core, i_core, voidIng, m_plate,
m_plate, infinite, infinite, infinite, infinite, m_plate
- ));
- RECIPES.put(Items.INFINITY_DISENCHANTER, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_ENCHANTER);
+ addRecipe(new ItemStack[] {
null, null, null, null, null, null,
voidIng, null, null, null, null, voidIng,
voidIng, voidIng, dis, dis, voidIng, voidIng,
m_plate, voidIng, i_circuit, i_circuit, voidIng, m_plate,
m_plate, voidIng, i_core, i_core, voidIng, m_plate,
m_plate, infinite, infinite, infinite, infinite, m_plate
- ));
- RECIPES.put(Items.INFINITY_CHARGER, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_DISENCHANTER);
+ addRecipe(new ItemStack[] {
null, null, null, null, null, null,
voidIng, m_circuit, m_circuit, m_circuit, m_circuit, voidIng,
voidIng, m_circuit, charger, charger, m_circuit, voidIng,
voidIng, m_circuit, charger, charger, m_circuit, voidIng,
voidIng, i_circuit, i_core, i_core, i_circuit, voidIng,
infinite, infinite, infinite, infinite, infinite, infinite
- ));
- RECIPES.put(Items.INFINITY_BLADE, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_CHARGER);
+ addRecipe(new ItemStack[] {
null, null, null, null, infinite, infinite,
null, null, null, infinite, voidIng, infinite,
null, null, infinite, voidIng, infinite, null,
infinite, infinite, voidIng, infinite, null, null,
null, voidIng, infinite, null, null, null,
voidIng, null, infinite, null, null, null
- ));
- RECIPES.put(Items.INFINITY_BOW, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_BLADE);
+ addRecipe(new ItemStack[] {
null, infinite, infinite, voidIng, null, null,
infinite, null, infinite, infinite, voidIng, null,
voidIng, null, null, Items.ENDER_FLAME, infinite, voidIng,
null, voidIng, null, null, infinite, infinite,
null, null, voidIng, null, null, infinite,
null, null, null, voidIng, infinite, null
- ));
- RECIPES.put(Items.INFINITY_PICKAXE, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_BOW);
+ addRecipe(new ItemStack[] {
null, voidIng, infinite, infinite, infinite, null,
null, null, null, infinite, voidIng, infinite,
null, null, null, voidIng, infinite, infinite,
null, null, voidIng, null, null, infinite,
null, voidIng, null, null, null, voidIng,
voidIng, null, null, null, null, null
- ));
- RECIPES.put(Items.INFINITY_AXE, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_PICKAXE);
+ addRecipe(new ItemStack[] {
null, voidIng, infinite, infinite, null, null,
voidIng, infinite, infinite, infinite, voidIng, null,
null, infinite, infinite, voidIng, infinite, infinite,
null, null, voidIng, infinite, infinite, infinite,
null, voidIng, null, infinite, infinite, voidIng,
voidIng, null, null, null, voidIng, null
- ));
- RECIPES.put(Items.INFINITY_SHOVEL, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_AXE);
+ addRecipe(new ItemStack[] {
null, null, null, infinite, infinite, infinite,
null, null, infinite, infinite, infinite, infinite,
null, null, infinite, voidIng, infinite, infinite,
null, null, voidIng, infinite, infinite, null,
null, voidIng, null, null, null, null,
voidIng, null, null, null, null, null
- ));
- RECIPES.put(Items.INFINITY_CROWN, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_SHOVEL);
+ addRecipe(new ItemStack[] {
null, infinite, infinite, infinite, infinite, null,
infinite, infinite, infinite, infinite, infinite, infinite,
infinite, voidIng, infinite, infinite, voidIng, infinite,
null, infinite, null, null, infinite, null,
null, null, null, null, null, null,
null, null, null, null, null, null
- ));
- RECIPES.put(Items.INFINITY_CHESTPLATE, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_CROWN);
+ addRecipe(new ItemStack[] {
null, infinite, null, null, infinite, null,
infinite, voidIng, infinite, infinite, voidIng, infinite,
voidIng, infinite, infinite, infinite, infinite, voidIng,
voidIng, infinite, voidIng, voidIng, infinite, voidIng,
null, infinite, infinite, infinite, infinite, null,
null, infinite, infinite, infinite, infinite, null
- ));
- RECIPES.put(Items.INFINITY_LEGGINGS, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_CHESTPLATE);
+ addRecipe(new ItemStack[] {
null, infinite, infinite, infinite, infinite, null,
infinite, infinite, infinite, infinite, infinite, infinite,
voidIng, infinite, null, null, infinite, voidIng,
voidIng, infinite, null, null, infinite, voidIng,
voidIng, infinite, null, null, infinite, voidIng,
null, infinite, null, null, infinite, null
- ));
- RECIPES.put(Items.INFINITY_BOOTS, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_LEGGINGS);
+ addRecipe(new ItemStack[] {
null, null, null, null, null, null,
infinite, infinite, null, null, infinite, infinite,
infinite, infinite, null, null, infinite, infinite,
voidIng, voidIng, null, null, voidIng, voidIng,
infinite, infinite, null, null, infinite, infinite,
infinite, infinite, null, null, infinite, infinite
- ));
- RECIPES.put(Items.INFINITY_MATRIX, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_BOOTS);
+ addRecipe(new ItemStack[] {
infinite, null, infinite, infinite, null, infinite,
infinite, voidIng, voidIng, voidIng, voidIng, infinite,
voidIng, voidIng, elytra, elytra, voidIng, voidIng,
voidIng, voidIng, infinite, infinite, voidIng, voidIng,
infinite, voidIng, voidIng, voidIng, voidIng, infinite,
infinite, null, infinite, infinite, null, infinite
- ));
- RECIPES.put(Items.INFINITY_SHIELD, MultiFilter.fromStacks(FilterType.MIN_AMOUNT,
+ }, Items.INFINITY_MATRIX);
+ addRecipe(new ItemStack[] {
infinite, infinite, null, null, infinite, infinite,
infinite, voidIng, infinite, infinite, voidIng, infinite,
infinite, voidIng, infinite, infinite, voidIng, infinite,
infinite, voidIng, infinite, infinite, voidIng, infinite,
null, infinite, voidIng, voidIng, infinite, null,
null, infinite, voidIng, voidIng, infinite, null
- ));
+ }, Items.INFINITY_SHIELD);
+ }
+
+ private static void addRecipe(ItemStack[] recipe, SlimefunItemStack stack) {
+ RECIPES.put(MultiFilter.fromStacks(FilterType.MIN_AMOUNT , recipe), stack);
+ ITEMS.put(stack.getItemId(), new Pair<>(stack, recipe));
+ IDS.add(stack.getItemId());
}
}
\ No newline at end of file
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/lists/Items.java b/src/main/java/io/github/mooy1/infinityexpansion/lists/Items.java
index 7d2ebe17..3c9209c4 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/lists/Items.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/lists/Items.java
@@ -1,13 +1,13 @@
package io.github.mooy1.infinityexpansion.lists;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
-import io.github.mooy1.infinityexpansion.implementation.items.AdvancedAnvil;
-import io.github.mooy1.infinityexpansion.implementation.items.InfinityWorkbench;
-import io.github.mooy1.infinityexpansion.implementation.items.Strainer;
+import io.github.mooy1.infinityexpansion.implementation.blocks.AdvancedAnvil;
+import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
+import io.github.mooy1.infinityexpansion.implementation.blocks.Strainer;
import io.github.mooy1.infinityexpansion.implementation.machines.ConversionMachine;
-import io.github.mooy1.infinityexpansion.implementation.machines.EnergyGenerator;
+import io.github.mooy1.infinityexpansion.implementation.generators.EnergyGenerator;
import io.github.mooy1.infinityexpansion.implementation.machines.GearTransformer;
-import io.github.mooy1.infinityexpansion.implementation.machines.InfinityReactor;
+import io.github.mooy1.infinityexpansion.implementation.generators.InfinityReactor;
import io.github.mooy1.infinityexpansion.implementation.machines.ItemUpdater;
import io.github.mooy1.infinityexpansion.implementation.machines.MaterialGenerator;
import io.github.mooy1.infinityexpansion.implementation.machines.PoweredBedrock;
@@ -20,7 +20,7 @@
import io.github.mooy1.infinityexpansion.implementation.machines.VoidHarvester;
import io.github.mooy1.infinityexpansion.implementation.mobdata.MobDataInfuser;
import io.github.mooy1.infinityexpansion.implementation.mobdata.MobSimulationChamber;
-import io.github.mooy1.infinityexpansion.implementation.storage.StorageUnit;
+import io.github.mooy1.infinityexpansion.implementation.blocks.StorageUnit;
import io.github.mooy1.infinityexpansion.setup.SlimefunConstructors;
import io.github.mooy1.infinitylib.PluginUtils;
import io.github.mooy1.infinitylib.presets.LorePreset;
@@ -601,7 +601,7 @@ public final class Items {
);
public static final SlimefunItemStack EMPTY_DATA_CARD = new SlimefunItemStack(
"EMPTY_DATA_CARD",
- Material.IRON_CHESTPLATE,
+ Material.CHAINMAIL_CHESTPLATE,
"&8Empty Data Card",
"&7Infuse with a mob's items to fill"
);
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/setup/InfinityCategory.java b/src/main/java/io/github/mooy1/infinityexpansion/setup/InfinityCategory.java
index 1e850daa..587d0c25 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/setup/InfinityCategory.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/setup/InfinityCategory.java
@@ -1,6 +1,6 @@
package io.github.mooy1.infinityexpansion.setup;
-import io.github.mooy1.infinityexpansion.implementation.items.InfinityWorkbench;
+import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.lists.Categories;
import io.github.mooy1.infinityexpansion.lists.InfinityRecipes;
import io.github.mooy1.infinityexpansion.lists.Items;
@@ -8,13 +8,14 @@
import io.github.mooy1.infinitylib.PluginUtils;
import io.github.mooy1.infinitylib.filter.FilterType;
import io.github.mooy1.infinitylib.filter.ItemFilter;
-import io.github.mooy1.infinitylib.items.StackUtils;
+import io.github.mooy1.infinitylib.player.LeaveListener;
import io.github.mooy1.infinitylib.presets.MenuPreset;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
+import lombok.AllArgsConstructor;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -27,11 +28,17 @@
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.Objects;
+import java.util.UUID;
import java.util.logging.Level;
/**
@@ -39,9 +46,9 @@
*
* @author Mooy1
*/
-public class InfinityCategory extends FlexCategory {
+public class InfinityCategory extends FlexCategory implements Listener {
- private static final int[] RECIPE_SLOTS = {
+ private static final int[] INFINITY_RECIPE_SLOTS = {
1, 2, 3, 4, 5, 6,
10, 11, 12, 13, 14, 15,
19, 20, 21, 22, 23, 24,
@@ -58,25 +65,34 @@ public class InfinityCategory extends FlexCategory {
private static final int NORMAL_RECIPE_OUTPUT = 25;
private static final int[] NORMAL_RECIPE_BACKGROUND = {
1, 2, 3, 4, 5, 6, 7, 8,
- 36, 37, 38 ,39 ,40, 41 ,42 ,43, 44
+ 36, 37, 38, 39, 40, 41, 42, 43, 44
};
- private static final int[] OUTPUT_BORDER = {
+ private static final int[] INFINITY_OUTPUT_BORDER = {
25, 26, 34, 43, 44
};
- private static final int[] BACKGROUND = {
- 9, 18, 27, 36, 52
+ private static final int[] INFINITY_BACKGROUND = {
+ 9, 18, 27, 36, 53
};
- private static final int OUTPUT = 35;
+ private static final int INFINITY_OUTPUT = 35;
private static final int BACK = 0;
- private static final int PREVIOUS = 45;
- private static final int NEXT = 53;
- private static final int WORKBENCH = 8;
+ private static final int NEXT = 52;
+ private static final int PREV = 45;
+ private static final int INFINITY_BENCH = 8;
private static final int[] WORKBENCH_BORDER = {
7, 16, 17
};
+ private static final ItemStack BENCH = new CustomItem(Material.NETHER_STAR,
+ "&bCreate the recipe from items in your inventory: ",
+ "&aLeft-Click to move 1 set",
+ "&aRight-Click to move as many sets as possible"
+ );
+ private static final ItemStack INFO = new CustomItem(Material.CYAN_STAINED_GLASS_PANE, "&3Info");
+
+ private static final HashMap history = new HashMap<>();
public InfinityCategory(NamespacedKey key, ItemStack item, int tier) {
super(key, item, tier);
+ new LeaveListener(history);
}
@Override
@@ -86,156 +102,168 @@ public boolean isVisible(@Nonnull Player player, @Nonnull PlayerProfile playerPr
@Override
public void open(@Nonnull Player player, @Nonnull PlayerProfile playerProfile, @Nonnull SlimefunGuideLayout slimefunGuideLayout) {
- ChestMenu menu = new ChestMenu("&bInfinity Recipes");
+ open(player, new BackEntry(null, playerProfile, slimefunGuideLayout), true);
+ playerProfile.getGuideHistory().add(this, 1);
+ }
+
+ public static void open(@Nonnull Player player, @Nonnull BackEntry entry, boolean useHistory) {
+
+ if (useHistory) {
+ String id = history.get(player.getUniqueId());
- setupMain(menu, player);
- menu.addItem(1, ChestMenuUtils.getBackButton(player, "",
- ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(player, "guide.back.guide"))
- );
- menu.addMenuClickHandler(1, (p, slot, item, action) -> {
- Categories.MAIN.open(p, playerProfile, slimefunGuideLayout);
- return false;
- });
+ if (id != null) {
+ openInfinityRecipe(player, id, entry);
+ return;
+ }
+ }
+
+ ChestMenu menu = new ChestMenu("&bInfinity Recipes");
- int i = 9;
- for (ItemStack output : InfinityRecipes.RECIPES.keySet()) {
- menu.addItem(i, output, (p, slot, item, action) -> {
- openInfinityRecipe(p, slot - 9, playerProfile, slimefunGuideLayout);
+ if (entry.layout != null && entry.profile != null) {
+ menu.addMenuClickHandler(1, (player1, i, itemStack, clickAction) -> {
+ Categories.MAIN.open(player1, entry.profile, entry.layout);
return false;
});
-
- i++;
- if (i == 45) break;
+ } else if (entry.workBench != null) {
+ menu.addMenuClickHandler(1, (player1, i, itemStack, clickAction) -> {
+ entry.workBench.open(player1);
+ return false;
+ });
+ } else {
+ error("MAIN");
+ return;
}
- player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
- playerProfile.getGuideHistory().add(this, 1);
-
- menu.open(player);
- }
-
- private static void setupMain(@Nonnull ChestMenu menu, @Nonnull Player player) {
- int i;
menu.addItem(0, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
menu.setEmptySlotsClickable(false);
-
- for (i = 2 ; i < 9 ; i++) {
+ for (int i = 2 ; i < 9 ; i++) {
menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
-
menu.addItem(45, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
-
- menu.addItem(46, ChestMenuUtils.getPreviousButton(player,1, 1), ChestMenuUtils.getEmptyClickHandler());
-
- for (i = 47 ; i < 52 ; i++) {
+ menu.addItem(46, ChestMenuUtils.getPreviousButton(player, 1, 1), ChestMenuUtils.getEmptyClickHandler());
+ for (int i = 47 ; i < 52 ; i++) {
menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
-
- menu.addItem(52, ChestMenuUtils.getNextButton(player,1, 1), ChestMenuUtils.getEmptyClickHandler());
-
+ menu.addItem(52, ChestMenuUtils.getNextButton(player, 1, 1), ChestMenuUtils.getEmptyClickHandler());
menu.addItem(53, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
- }
- public static void openFromWorkBench(@Nonnull Player player, @Nonnull BlockMenu inv) {
- ChestMenu menu = new ChestMenu("&bInfinity Recipes");
-
- setupMain(menu, player);
- menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(player, "",
- ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(player, "guide.back.guide")))
- );
- menu.addMenuClickHandler(1, (p, slot, item, action) -> {
- inv.open(player);
- return false;
- });
+ menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(player, "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(player, "guide.back.guide"))));
int i = 9;
- for (ItemStack items : InfinityRecipes.RECIPES.keySet()) {
- menu.addItem(i, items, (p, slot, item, action) -> {
- openRecipeFromWorkBench(player, inv, slot - 9);
+ for (SlimefunItemStack item : InfinityRecipes.RECIPES.values()) {
+ if (i == 45) break;
+
+ menu.addItem(i, item, (p, slot, item1, action) -> {
+ openInfinityRecipe(p, item.getItemId(), entry);
return false;
});
i++;
- if (i == 45) break;
}
player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
+ history.put(player.getUniqueId(), null);
+
menu.open(player);
}
- private static void openRecipeFromWorkBench(@Nonnull Player player, @Nonnull BlockMenu inv, int id) {
- Pair pair = InfinityRecipes.IDS.get(id);
+ @ParametersAreNonnullByDefault
+ private static void openInfinityRecipe(Player player, String id, BackEntry entry) {
+ Pair pair = InfinityRecipes.ITEMS.get(id);
+
if (pair == null) {
- PluginUtils.log(Level.WARNING, "Error opening recipe for Infinity Item id: " + id + " Report this on Discord or Github!");
+ error("ID NOT FOUND");
return;
}
- SlimefunItemStack output = pair.getFirstValue();
- ChestMenu menu = new ChestMenu(Objects.requireNonNull(output.getDisplayName()));
+ ChestMenu menu = new ChestMenu(Objects.requireNonNull(pair.getFirstValue().getDisplayName()));
menu.setEmptySlotsClickable(false);
-
- menu.addItem(BACK, ChestMenuUtils.getBackButton(player, ""), (p, slot, item, action) -> {
- openFromWorkBench(player, inv);
- return false;
- });
-
- menu.addItem(PREVIOUS, ChestMenuUtils.getPreviousButton(player, id + 1, InfinityRecipes.RECIPES.size()), (p, slot, item, action) -> {
- if (id > 0) {
- openRecipeFromWorkBench(p, inv, id - 1);
- }
- return false;
- });
- menu.addItem(NEXT, ChestMenuUtils.getNextButton(player, id + 1, InfinityRecipes.RECIPES.size()), (p, slot, item, action) -> {
- if (id + 1< InfinityRecipes.RECIPES.size()) {
- openRecipeFromWorkBench(p, inv, id + 1);
- }
- return false;
- });
-
- menu.addItem(WORKBENCH, new CustomItem(Material.NETHER_STAR,
- "&bCreate the recipe from items in your inventory: ",
- "&aLeft-Click to move 1 set",
- "&aRight-Click to move as many sets as possible"
- ), (p, slot, item, action) -> {
- makeRecipe(p, inv, pair, action.isRightClicked());
+
+ menu.addItem(BACK, ChestMenuUtils.getBackButton(player, ""), (player12, i, itemStack, clickAction) -> {
+ open(player12, entry, false);
return false;
});
-
- int i = 0;
- ItemStack[] recipe = pair.getSecondValue();
- for (int recipeSlot : RECIPE_SLOTS) {
- ItemStack recipeItem = recipe[i];
+
+ for (int i = 0 ; i < INFINITY_RECIPE_SLOTS.length ; i++) {
+ ItemStack recipeItem = pair.getSecondValue()[i];
if (recipeItem != null) {
- menu.addItem(recipeSlot, recipeItem, (p, slot, item, action) -> {
+ menu.addItem(INFINITY_RECIPE_SLOTS[i], recipeItem, (p, slot, item, action) -> {
SlimefunItem slimefunItem = SlimefunItem.getByItem(recipeItem);
-
- if (slimefunItem != null ) {
+ if (slimefunItem != null && !slimefunItem.isDisabled()) {
if (slimefunItem.getRecipeType() == RecipeTypes.INFINITY_WORKBENCH) {
- openRecipeFromWorkBench(player, inv, InfinityRecipes.STRINGS.get(slimefunItem.getId()));
+ openInfinityRecipe(p, slimefunItem.getId(), entry);
+ } else {
+ LinkedList list = new LinkedList<>();
+ list.add(slimefunItem);
+ openSlimefunRecipe(p, entry, id, list);
}
}
return false;
});
}
- i++;
}
- setupInfinityRecipeMenu(menu, output);
+ if (entry.workBench == null) {
+ menu.addItem(INFINITY_BENCH, Items.INFINITY_WORKBENCH, (p, slot, item, action) -> {
+ SlimefunItem slimefunItem = Items.INFINITY_WORKBENCH.getItem();
+ if (slimefunItem != null) {
+ LinkedList list = new LinkedList<>();
+ list.add(slimefunItem);
+ openSlimefunRecipe(p, entry, id, list);
+ }
+ return false;
+ });
+ } else {
+ menu.addItem(INFINITY_BENCH, BENCH, (p, slot, item, action) -> {
+ moveRecipe(p, entry.workBench, pair, action.isRightClicked());
+ return false;
+ });
+ }
+
+ int page = InfinityRecipes.IDS.indexOf(id);
+
+ menu.addItem(PREV, ChestMenuUtils.getPreviousButton(player, page + 1, InfinityRecipes.IDS.size()), (player1, i, itemStack, clickAction) -> {
+ if (page > 0) {
+ openInfinityRecipe(player1, InfinityRecipes.IDS.get(page - 1), entry);
+ }
+ return false;
+ });
+
+ menu.addItem(NEXT, ChestMenuUtils.getNextButton(player, page + 1, InfinityRecipes.IDS.size()), (player1, i, itemStack, clickAction) -> {
+ if (page < InfinityRecipes.IDS.size() - 1) {
+ openInfinityRecipe(player1, InfinityRecipes.IDS.get(page + 1), entry);
+ }
+ return false;
+ });
+
+ for (int slot : INFINITY_BACKGROUND) {
+ menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
+ }
+ for (int slot : INFINITY_OUTPUT_BORDER) {
+ menu.addItem(slot, MenuPreset.borderItemOutput, ChestMenuUtils.getEmptyClickHandler());
+ }
+ menu.addItem(INFINITY_OUTPUT, pair.getFirstValue(), ChestMenuUtils.getEmptyClickHandler());
+ for (int slot : WORKBENCH_BORDER) {
+ menu.addItem(slot, INFO, ChestMenuUtils.getEmptyClickHandler());
+ }
player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
+ history.put(player.getUniqueId(), id);
+
menu.open(player);
+
}
+
/**
* This method attempts to move items from the players inventories to the correct spots in the table
*
* @param player player
- * @param menu workbench menu
+ * @param menu workbench menu
*/
-
- private static void makeRecipe(@Nonnull Player player, @Nonnull BlockMenu menu, Pair pair, boolean max) {
+ private static void moveRecipe(@Nonnull Player player, @Nonnull BlockMenu menu, Pair pair, boolean max) {
ItemStack[] recipe = pair.getSecondValue();
PlayerInventory inv = player.getInventory();
@@ -250,7 +278,7 @@ private static void makeRecipe(@Nonnull Player player, @Nonnull BlockMenu menu,
ItemFilter filter = new ItemFilter(recipe[slot], FilterType.IGNORE_AMOUNT);
for (ItemStack item : inv.getContents()) { //each slot in their inv
- if (item != null && filter.matches(new ItemFilter(item, FilterType.IGNORE_AMOUNT), FilterType.IGNORE_AMOUNT)) { //matches recipe
+ if (item != null && filter.fits(new ItemFilter(item, FilterType.IGNORE_AMOUNT), FilterType.IGNORE_AMOUNT)) { //matches recipe
//get item
ItemStack output = item.clone();
output.setAmount(1);
@@ -266,144 +294,80 @@ private static void makeRecipe(@Nonnull Player player, @Nonnull BlockMenu menu,
}
}
}
-
+
menu.open(player);
}
- private void openInfinityRecipe(@Nonnull Player player, int id, @Nonnull PlayerProfile playerProfile, @Nonnull SlimefunGuideLayout slimefunGuideLayout) {
- Pair pair = InfinityRecipes.IDS.get(id);
- if (pair == null) {
- PluginUtils.log(Level.WARNING, "Error opening recipe for Infinity Item id: " + id, "Report this on Discord or Github!");
- return;
- }
-
- ChestMenu menu = new ChestMenu(Objects.requireNonNull(pair.getFirstValue().getDisplayName()));
- menu.setEmptySlotsClickable(false);
-
- menu.addItem(BACK, ChestMenuUtils.getBackButton(player, ""), (p, slot, item, action) -> {
- open(player, playerProfile, slimefunGuideLayout);
- return false;
- });
-
- menu.addItem(PREVIOUS, ChestMenuUtils.getPreviousButton(player, id + 1, InfinityRecipes.RECIPES.size()), (p, slot, item, action) -> {
- if (id > 0) {
- openInfinityRecipe(p, id - 1, playerProfile, slimefunGuideLayout);
- }
- return false;
- });
- menu.addItem(NEXT, ChestMenuUtils.getNextButton(player, id + 1, InfinityRecipes.RECIPES.size()), (p, slot, item, action) -> {
- if (id + 1< InfinityRecipes.RECIPES.size()) {
- openInfinityRecipe(p, id + 1, playerProfile, slimefunGuideLayout);
- }
- return false;
- });
+ @ParametersAreNonnullByDefault
+ private static void openSlimefunRecipe(Player player, BackEntry entry, String backID, LinkedList slimefunHistory) {
+ SlimefunItem slimefunItem = slimefunHistory.peekLast();
- int i = 0;
- for (int recipeSlot : RECIPE_SLOTS) {
- ItemStack recipeItem = pair.getSecondValue()[i];
-
- if (recipeItem != null) {
-
- menu.addItem(recipeSlot, recipeItem, (p, slot, item, action) -> {
- SlimefunItem slimefunItem = SlimefunItem.getByItem(recipeItem);
-
- if (slimefunItem != null ) {
- if (slimefunItem.getRecipeType() == RecipeTypes.INFINITY_WORKBENCH) {
- openInfinityRecipe(player, InfinityRecipes.STRINGS.get(StackUtils.getItemID(recipeItem, false)), playerProfile, slimefunGuideLayout);
- } else {
- openSlimefunRecipe(player, id, new SlimefunItem[] {slimefunItem}, playerProfile, slimefunGuideLayout);
- }
- }
- return false;
- });
- }
- i++;
+ if (slimefunItem == null) {
+ error("NULL SF ITEM");
+ return;
}
-
- menu.addItem(WORKBENCH, Items.INFINITY_WORKBENCH, (p, slot, item, action) -> {
- openSlimefunRecipe(player, id, new SlimefunItem[]{SlimefunItem.getByItem(Items.INFINITY_WORKBENCH)}, playerProfile, slimefunGuideLayout);
- return false;
- });
-
- setupInfinityRecipeMenu(menu, pair.getFirstValue());
-
- player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
- menu.open(player);
- }
-
- private void openSlimefunRecipe(@Nonnull Player player, int backID, @Nonnull SlimefunItem[] slimefunHistory, @Nonnull PlayerProfile playerProfile, @Nonnull SlimefunGuideLayout slimefunGuideLayout) {
- int length = slimefunHistory.length;
-
- SlimefunItem slimefunItem = slimefunHistory[length - 1];
ItemStack output = slimefunItem.getRecipeOutput().clone();
ChestMenu menu = new ChestMenu(ItemUtils.getItemName(output));
menu.setEmptySlotsClickable(false);
+ int length = slimefunHistory.size();
+
menu.addItem(0, ChestMenuUtils.getBackButton(player, ""), (p, slot, item, action) -> {
if (length == 1) {
- openInfinityRecipe(player, backID, playerProfile, slimefunGuideLayout);
+ openInfinityRecipe(player, backID, entry);
} else {
- SlimefunItem[] backHistory = new SlimefunItem[length - 1];
- System.arraycopy(slimefunHistory, 0, backHistory, 0, length - 1);
- openSlimefunRecipe(player, backID, backHistory, playerProfile, slimefunGuideLayout);
+ slimefunHistory.removeLast();
+ openSlimefunRecipe(player, entry, backID, slimefunHistory);
}
return false;
});
-
- int i = 0;
- for (int recipeSlot : NORMAL_RECIPE_SLOTS) {
+
+ for (int i = 0 ; i < NORMAL_RECIPE_SLOTS.length ; i++) {
ItemStack recipeItem = slimefunItem.getRecipe()[i];
if (recipeItem != null) {
-
- menu.addItem(recipeSlot, recipeItem, (p, slot, item, action) -> {
+ menu.addItem(NORMAL_RECIPE_SLOTS[i], recipeItem, (p, slot, item, action) -> {
SlimefunItem recipeSlimefunItem = SlimefunItem.getByItem(recipeItem);
if (recipeSlimefunItem != null) {
- SlimefunItem[] newHistory = new SlimefunItem[length + 1];
- System.arraycopy(slimefunHistory, 0, newHistory, 0, length);
- newHistory[length] = recipeSlimefunItem;
-
- openSlimefunRecipe(player, backID, newHistory, playerProfile, slimefunGuideLayout);
+ slimefunHistory.add(recipeSlimefunItem);
+ openSlimefunRecipe(player, entry, backID, slimefunHistory);
}
return false;
});
}
+
+ }
- i++;
+ menu.addItem(NORMAL_RECIPE_TYPE, slimefunItem.getRecipeType().toItem(), ChestMenuUtils.getEmptyClickHandler());
+
+ for (int slot : NORMAL_RECIPE_BACKGROUND) {
+ menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
- setupNormalRecipeMenu(menu, output, slimefunItem.getRecipeType().toItem());
+ menu.addItem(NORMAL_RECIPE_OUTPUT, output, ChestMenuUtils.getEmptyClickHandler());
player.playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1, 1);
menu.open(player);
}
-
- private static final ItemStack recipe = new CustomItem(Material.CYAN_STAINED_GLASS_PANE, "&aRecipe Type");
- private static void setupInfinityRecipeMenu(@Nonnull ChestMenu menu, @Nonnull ItemStack output) {
- for (int slot : BACKGROUND) {
- menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
- }
- for (int slot : OUTPUT_BORDER) {
- menu.addItem(slot, MenuPreset.borderItemOutput, ChestMenuUtils.getEmptyClickHandler());
- }
- menu.addItem(OUTPUT, output, ChestMenuUtils.getEmptyClickHandler());
- for (int slot : WORKBENCH_BORDER) {
- menu.addItem(slot, recipe, ChestMenuUtils.getEmptyClickHandler());
- }
+ private static void error(String msg) {
+ PluginUtils.log(Level.WARNING, "Error opening infinity category: " + msg + " Report this on Discord or Github!");
}
-
- private static void setupNormalRecipeMenu(@Nonnull ChestMenu menu, @Nonnull ItemStack output, @Nonnull ItemStack recipeType) {
- menu.addItem(NORMAL_RECIPE_TYPE, recipeType, ChestMenuUtils.getEmptyClickHandler());
-
- for (int slot : NORMAL_RECIPE_BACKGROUND) {
- menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
- }
-
- menu.addItem(NORMAL_RECIPE_OUTPUT, output, ChestMenuUtils.getEmptyClickHandler());
+
+ @AllArgsConstructor
+ public static class BackEntry {
+
+ @Nullable
+ private final BlockMenu workBench;
+ @Nullable
+ private final PlayerProfile profile;
+ @Nullable
+ private final SlimefunGuideLayout layout;
+
}
+
}
\ No newline at end of file
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/setup/MainCategory.java b/src/main/java/io/github/mooy1/infinityexpansion/setup/MainCategory.java
index e784eac6..7e468b2d 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/setup/MainCategory.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/setup/MainCategory.java
@@ -24,10 +24,10 @@
* @author Mooy1
*
*/
-public class MainCategory extends FlexCategory {
+public final class MainCategory extends FlexCategory {
public final List categories = new ArrayList<>();
-
+
public MainCategory(NamespacedKey key, ItemStack item, int tier) {
super(key, item, tier);
}
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/setup/Setup.java b/src/main/java/io/github/mooy1/infinityexpansion/setup/Setup.java
index 92e647dc..13ae0061 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/setup/Setup.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/setup/Setup.java
@@ -6,14 +6,14 @@
import io.github.mooy1.infinityexpansion.implementation.gear.InfinityMatrix;
import io.github.mooy1.infinityexpansion.implementation.gear.InfinityTool;
import io.github.mooy1.infinityexpansion.implementation.gear.VeinMinerRune;
-import io.github.mooy1.infinityexpansion.implementation.items.AdvancedAnvil;
-import io.github.mooy1.infinityexpansion.implementation.items.InfinityWorkbench;
-import io.github.mooy1.infinityexpansion.implementation.items.Strainer;
-import io.github.mooy1.infinityexpansion.implementation.items.StrainerBase;
+import io.github.mooy1.infinityexpansion.implementation.blocks.AdvancedAnvil;
+import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
+import io.github.mooy1.infinityexpansion.implementation.blocks.Strainer;
+import io.github.mooy1.infinityexpansion.implementation.blocks.StrainerBase;
import io.github.mooy1.infinityexpansion.implementation.machines.ConversionMachine;
-import io.github.mooy1.infinityexpansion.implementation.machines.EnergyGenerator;
+import io.github.mooy1.infinityexpansion.implementation.generators.EnergyGenerator;
import io.github.mooy1.infinityexpansion.implementation.machines.GearTransformer;
-import io.github.mooy1.infinityexpansion.implementation.machines.InfinityReactor;
+import io.github.mooy1.infinityexpansion.implementation.generators.InfinityReactor;
import io.github.mooy1.infinityexpansion.implementation.machines.ItemUpdater;
import io.github.mooy1.infinityexpansion.implementation.machines.MaterialGenerator;
import io.github.mooy1.infinityexpansion.implementation.machines.PoweredBedrock;
@@ -30,8 +30,8 @@
import io.github.mooy1.infinityexpansion.implementation.mobdata.MobDataCard;
import io.github.mooy1.infinityexpansion.implementation.mobdata.MobDataInfuser;
import io.github.mooy1.infinityexpansion.implementation.mobdata.MobSimulationChamber;
-import io.github.mooy1.infinityexpansion.implementation.storage.StorageForge;
-import io.github.mooy1.infinityexpansion.implementation.storage.StorageUnit;
+import io.github.mooy1.infinityexpansion.implementation.blocks.StorageForge;
+import io.github.mooy1.infinityexpansion.implementation.blocks.StorageUnit;
import io.github.mooy1.infinityexpansion.lists.Categories;
import io.github.mooy1.infinityexpansion.lists.InfinityRecipes;
import io.github.mooy1.infinityexpansion.lists.Items;
diff --git a/src/main/java/io/github/mooy1/infinityexpansion/setup/HiddenCategory.java b/src/main/java/io/github/mooy1/infinityexpansion/setup/SubCategory.java
similarity index 80%
rename from src/main/java/io/github/mooy1/infinityexpansion/setup/HiddenCategory.java
rename to src/main/java/io/github/mooy1/infinityexpansion/setup/SubCategory.java
index 2cd7b04e..97b9b9e9 100644
--- a/src/main/java/io/github/mooy1/infinityexpansion/setup/HiddenCategory.java
+++ b/src/main/java/io/github/mooy1/infinityexpansion/setup/SubCategory.java
@@ -12,9 +12,9 @@
*
* @author Mooy1
*/
-public class HiddenCategory extends Category {
+public class SubCategory extends Category {
- public HiddenCategory(NamespacedKey key, ItemStack item, int tier) {
+ public SubCategory(NamespacedKey key, ItemStack item, int tier) {
super(key, item, tier);
}