Skip to content

Commit

Permalink
updated tree grower/virtual farm code, fixed storage unit error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooy1 committed Mar 27, 2021
1 parent b1f4838 commit 4cf7e32
Show file tree
Hide file tree
Showing 43 changed files with 404 additions and 788 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>io.github.mooy1</groupId>
<artifactId>InfinityLib</artifactId>
<version>fbed2fe</version>
<version>78bab21</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.github.mooy1.infinityexpansion.commands.GiveRecipe;
import io.github.mooy1.infinityexpansion.commands.PrintItem;
import io.github.mooy1.infinityexpansion.commands.SetData;
import io.github.mooy1.infinityexpansion.implementation.Setup;
import io.github.mooy1.infinitylib.AbstractAddon;
import io.github.mooy1.infinitylib.bstats.bukkit.Metrics;
import io.github.mooy1.infinitylib.commands.AbstractCommand;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.mooy1.infinityexpansion.implementation;
package io.github.mooy1.infinityexpansion;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.SlimefunExtension;
import io.github.mooy1.infinityexpansion.implementation.blocks.AdvancedAnvil;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.blocks.Strainer;
Expand All @@ -15,14 +16,13 @@
import io.github.mooy1.infinityexpansion.implementation.machines.ConversionMachine;
import io.github.mooy1.infinityexpansion.implementation.machines.GearTransformer;
import io.github.mooy1.infinityexpansion.implementation.machines.GeoQuarry;
import io.github.mooy1.infinityexpansion.implementation.machines.GrowingMachine;
import io.github.mooy1.infinityexpansion.implementation.machines.MaterialGenerator;
import io.github.mooy1.infinityexpansion.implementation.machines.PoweredBedrock;
import io.github.mooy1.infinityexpansion.implementation.machines.Quarry;
import io.github.mooy1.infinityexpansion.implementation.machines.ResourceSynthesizer;
import io.github.mooy1.infinityexpansion.implementation.machines.SingularityConstructor;
import io.github.mooy1.infinityexpansion.implementation.machines.StoneworksFactory;
import io.github.mooy1.infinityexpansion.implementation.machines.TreeGrower;
import io.github.mooy1.infinityexpansion.implementation.machines.VirtualFarm;
import io.github.mooy1.infinityexpansion.implementation.machines.VoidHarvester;
import io.github.mooy1.infinityexpansion.implementation.materials.EnderEssence;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
Expand Down Expand Up @@ -86,8 +86,7 @@ public static void setup(@Nonnull InfinityExpansion plugin) {
VoidHarvester.setup(plugin);
SingularityConstructor.setup(plugin);
ConversionMachine.setup(plugin);
VirtualFarm.setup(plugin);
TreeGrower.setup(plugin);
GrowingMachine.setup(plugin);
MaterialGenerator.setup(plugin);
MobDataCard.setup(plugin);
new MobDataInfuser().register(plugin);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.mooy1.infinityexpansion.implementation;
package io.github.mooy1.infinityexpansion.categories;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinitylib.slimefun.utils.MultiCategory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.mooy1.infinityexpansion.implementation;
package io.github.mooy1.infinityexpansion.categories;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.mooy1.infinityexpansion.implementation;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.implementation.materials.Singularity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.mooy1.infinityexpansion.implementation.abstracts;

import io.github.mooy1.infinityexpansion.utils.Util;
import io.github.mooy1.infinitylib.recipes.largestrict.StrictLargeOutput;
import io.github.mooy1.infinitylib.recipes.largestrict.StrictLargeRecipeMap;
import io.github.mooy1.infinitylib.slimefun.abstracts.TickingContainer;
import io.github.mooy1.infinitylib.slimefun.presets.MenuPreset;
import io.github.mooy1.infinitylib.slimefun.recipes.AdvancedRecipeMap;
import io.github.mooy1.infinitylib.slimefun.recipes.RecipeMap;
import io.github.mooy1.infinitylib.slimefun.recipes.inputs.StrictMultiInput;
import io.github.mooy1.infinitylib.slimefun.recipes.outputs.StrictMultiOutput;
import io.github.mooy1.infinitylib.slimefun.utils.DelayedRecipeType;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
Expand Down Expand Up @@ -41,11 +43,11 @@ public abstract class AbstractCrafter extends TickingContainer {
private static final int[] STATUS_BORDER = {14, 32};
private static final int STATUS_SLOT = 23;

private final StrictLargeRecipeMap recipes = new StrictLargeRecipeMap(9);
private final RecipeMap<StrictMultiInput, StrictMultiOutput> recipes = new AdvancedRecipeMap<>();

public AbstractCrafter(Category category, SlimefunItemStack stack, DelayedRecipeType recipeType, RecipeType type, ItemStack[] recipe) {
super(category, stack, type, recipe);
recipeType.accept(this.recipes::put);
recipeType.accept((stacks, itemStack) -> this.recipes.put(new StrictMultiInput(stacks), new StrictMultiOutput(itemStack)));
}

@Override
Expand Down Expand Up @@ -159,7 +161,7 @@ private void craft(@Nonnull BlockMenu inv, @Nonnull Player p) {

@Nullable
private Pair<ItemStack, int[]> getOutput(@Nonnull BlockMenu inv) {
StrictLargeOutput output = this.recipes.get(inv, INPUT_SLOTS);
StrictMultiOutput output = this.recipes.get(new StrictMultiInput(inv, INPUT_SLOTS));
if (output == null) {
return null;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.abstracts.AbstractEnergyCrafter;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.utils.Util;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.github.mooy1.infinityexpansion.implementation.blocks;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.implementation.InfinityCategory;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.categories.InfinityCategory;
import io.github.mooy1.infinityexpansion.implementation.abstracts.AbstractEnergyCrafter;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.utils.Util;
import io.github.mooy1.infinitylib.recipes.large.LargeRecipeMap;
import io.github.mooy1.infinitylib.slimefun.presets.LorePreset;
import io.github.mooy1.infinitylib.slimefun.presets.MenuPreset;
import io.github.mooy1.infinitylib.slimefun.recipes.RecipeMap;
import io.github.mooy1.infinitylib.slimefun.recipes.SimpleRecipeMap;
import io.github.mooy1.infinitylib.slimefun.recipes.inputs.MultiInput;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
Expand Down Expand Up @@ -61,13 +63,13 @@ public final class InfinityWorkbench extends AbstractEnergyCrafter {
private static final int[] STATUS_BORDER = {6, 8, 15, 17, 24, 25, 26};
private static final int RECIPE_SLOT = 7;

public static final LargeRecipeMap RECIPES = new LargeRecipeMap(36);
public static final RecipeMap<MultiInput, ItemStack> RECIPES = new SimpleRecipeMap<>();
public static final LinkedHashMap<String, Pair<SlimefunItemStack, ItemStack[]>> ITEMS = new LinkedHashMap<>();
public static final List<String> IDS = new ArrayList<>();

public static final RecipeType TYPE = new RecipeType(InfinityExpansion.inst().getKey("infinity_forge"), ITEM, (stacks, stack) -> {
SlimefunItemStack item = (SlimefunItemStack) stack;
RECIPES.put(stacks, item);
RECIPES.put(new MultiInput(stacks), item);
ITEMS.put(item.getItemId(), new Pair<>(item, stacks));
IDS.add(item.getItemId());
}, "", "&cUse the infinity recipes category to see the correct recipe!");
Expand Down Expand Up @@ -121,7 +123,7 @@ public void craft(@Nonnull Block b, @Nonnull BlockMenu inv, @Nonnull Player p)
return;
}

ItemStack output = RECIPES.get(inv, INPUT_SLOTS);
ItemStack output = RECIPES.get(new MultiInput(inv, INPUT_SLOTS));

if (output == null) { //invalid
p.sendMessage( ChatColor.RED + "Invalid Recipe!");
Expand Down Expand Up @@ -149,7 +151,7 @@ public void craft(@Nonnull Block b, @Nonnull BlockMenu inv, @Nonnull Player p)
@Override
public void update(@Nonnull BlockMenu inv) {

ItemStack output = RECIPES.get(inv, INPUT_SLOTS);
ItemStack output = RECIPES.get(new MultiInput(inv, INPUT_SLOTS));

if (output == null) { //invalid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mooy1.infinityexpansion.implementation.blocks;

import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.utils.Util;
import io.github.mooy1.infinitylib.slimefun.abstracts.TickingContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.mooy1.infinityexpansion.implementation.gear;

import io.github.mooy1.infinityexpansion.implementation.materials.EnderEssence;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.mooy1.infinityexpansion.implementation.gear;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.mooy1.infinityexpansion.implementation.gear;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.mooy1.infinityexpansion.implementation.gear;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinitylib.items.LoreUtils;
import io.github.mooy1.infinitylib.players.CoolDownMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package io.github.mooy1.infinityexpansion.implementation.generators;

import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.implementation.abstracts.AbstractGenerator;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinityexpansion.utils.Util;
import io.github.mooy1.infinitylib.slimefun.abstracts.AbstractContainer;
import io.github.mooy1.infinitylib.slimefun.presets.LorePreset;
import io.github.mooy1.infinitylib.slimefun.presets.MenuPreset;
import io.github.mooy1.infinitylib.slimefun.utils.SlimefunConstants;
import io.github.mooy1.infinitylib.slimefun.utils.TickerUtils;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
Expand Down Expand Up @@ -40,7 +41,7 @@
*
* Thanks to panda for some stuff to work off of
*/
public final class EnergyGenerator extends AbstractGenerator {
public final class EnergyGenerator extends AbstractContainer implements EnergyNetProvider {

private static final int HYDRO_ENERGY = 5;
private static final int ADVANCED_HYDRO_ENERGY = 45;
Expand Down Expand Up @@ -239,7 +240,7 @@ public int getGeneratedOutput(@Nonnull Location l, @Nonnull Config data) {
Material.GREEN_STAINED_GLASS_PANE,
"&aGeneration",
"&7Type: &6" + type.status,
"&7Generating: &6" + LorePreset.roundHundreds(gen * SlimefunConstants.TICKER_TPS) + " J/s ",
"&7Generating: &6" + LorePreset.roundHundreds(gen * TickerUtils.TPS) + " J/s ",
"&7Stored: &6" + LorePreset.format(getCharge(l)) + " J"
));
}
Expand Down Expand Up @@ -306,11 +307,6 @@ public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.GENERATOR;
}

@Override
public int getStatus() {
return 4;
}

@AllArgsConstructor
private enum Type {
WATER("Hydroelectric", false),
Expand All @@ -325,5 +321,5 @@ private enum Type {
private final boolean more;

}

}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package io.github.mooy1.infinityexpansion.implementation.generators;

import io.github.mooy1.infinityexpansion.implementation.Categories;
import io.github.mooy1.infinityexpansion.categories.Categories;
import io.github.mooy1.infinityexpansion.implementation.SlimefunExtension;
import io.github.mooy1.infinityexpansion.implementation.abstracts.AbstractGenerator;
import io.github.mooy1.infinityexpansion.implementation.blocks.InfinityWorkbench;
import io.github.mooy1.infinityexpansion.implementation.materials.Items;
import io.github.mooy1.infinitylib.items.LoreUtils;
import io.github.mooy1.infinitylib.items.StackUtils;
import io.github.mooy1.infinitylib.slimefun.abstracts.AbstractContainer;
import io.github.mooy1.infinitylib.slimefun.presets.LorePreset;
import io.github.mooy1.infinitylib.slimefun.presets.MenuPreset;
import io.github.mooy1.infinitylib.slimefun.utils.SlimefunConstants;
import io.github.mooy1.infinitylib.slimefun.utils.TickerUtils;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
Expand All @@ -36,7 +37,7 @@
*
* @author Mooy1
*/
public final class InfinityReactor extends AbstractGenerator implements RecipeDisplayItem {
public final class InfinityReactor extends AbstractContainer implements EnergyNetProvider, RecipeDisplayItem {

public static final SlimefunItemStack ITEM = new SlimefunItemStack(
"INFINITY_REACTOR",
Expand All @@ -51,8 +52,8 @@ public final class InfinityReactor extends AbstractGenerator implements RecipeDi

public static final int ENERGY = 90_000;
public static final int STORAGE = 90_000_000;
public static final int INFINITY_INTERVAL = (int) (86400 * SlimefunConstants.TICKER_TPS);
public static final int VOID_INTERVAL = (int) (14400 * SlimefunConstants.TICKER_TPS);
public static final int INFINITY_INTERVAL = (int) (86400 * TickerUtils.TPS);
public static final int VOID_INTERVAL = (int) (14400 * TickerUtils.TPS);
public static final int[] INPUT_SLOTS = {
MenuPreset.slot1, MenuPreset.slot3
};
Expand Down Expand Up @@ -203,11 +204,6 @@ public int getGeneratedOutput(@Nonnull Location l, @Nonnull Config config) {
return ENERGY;
}

@Override
public int getStatus() {
return STATUS_SLOT;
}

@Override
public int getCapacity() {
return STORAGE;
Expand Down

0 comments on commit 4cf7e32

Please sign in to comment.