1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

[CI skip] Refactoring

This commit is contained in:
TheBusyBiscuit 2020-03-18 15:52:36 +01:00
parent 3cd31e2c2f
commit 4744fbac56
10 changed files with 319 additions and 320 deletions

View File

@ -50,6 +50,9 @@
* Added Makeshift Smeltery * Added Makeshift Smeltery
* Added Tree Growth Accelerator * Added Tree Growth Accelerator
* Added "Glass to Glass Panes" recipe to the Electric Press * Added "Glass to Glass Panes" recipe to the Electric Press
* Added "Snowballs to Snow blocks" recipe to the Electric Press
* Added "Snow blocks to Ice" recipe to the Freezer
* You can now use Cooked Salmon in an Auto Drier to craft Fish Jerky
* The Lumber Axe can now strip logs too * The Lumber Axe can now strip logs too
#### Changes #### Changes

View File

@ -4,6 +4,7 @@ We got everything from magical wands to nuclear reactors.<br>
We feature a magical altar, an electric power grid and even item transport systems. We feature a magical altar, an electric power grid and even item transport systems.
This project originally started back in 2013 and has grown ever since.<br> This project originally started back in 2013 and has grown ever since.<br>
From one single person working on this plugin back then, we grew to a community of thousands of players and over 100 of contributors to this project.<br>
It currently adds over **500 new items and recipes** to Minecraft ([Read more about the history of this project](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Slimefun-in-a-nutshell)). It currently adds over **500 new items and recipes** to Minecraft ([Read more about the history of this project](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Slimefun-in-a-nutshell)).
But it also comes with a lot of Addons too!<br> But it also comes with a lot of Addons too!<br>
@ -98,9 +99,11 @@ Slimefun4 has recently added suport for translations, note that translations are
So not everything may be available for translation yet.<br> So not everything may be available for translation yet.<br>
[Read more...](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Translating-Slimefun) [Read more...](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Translating-Slimefun)
## Data Collection ## Disclaimer
Slimefun4 uses various systems that collect or download data.<br> Slimefun4 uses various systems that collect usage information or download automatic updates as well as the latest information about the project.<br>
We do not collect any personal information from you but here is a full list of what services may collect or download other kind of data. We do __not__ collect any personal information from you but here is a full list of what services may collect or download other kinds of data.
You can opt-out of the Auto-Updater and stats collection at any time.
### Auto-Updates ### Auto-Updates
Slimefun4 uses an Auto-Updater which connects to https://thebusybiscuit.github.io/builds/ to check for and download updates.<br> Slimefun4 uses an Auto-Updater which connects to https://thebusybiscuit.github.io/builds/ to check for and download updates.<br>

View File

@ -75,6 +75,9 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem {
recipeList.add(new ItemStack(Material.COOKED_COD)); recipeList.add(new ItemStack(Material.COOKED_COD));
recipeList.add(SlimefunItems.FISH_JERKY); recipeList.add(SlimefunItems.FISH_JERKY);
recipeList.add(new ItemStack(Material.COOKED_SALMON));
recipeList.add(SlimefunItems.FISH_JERKY);
} }
@Override @Override

View File

@ -59,6 +59,7 @@ public class AutoEnchanter extends AContainer {
@Override @Override
protected void tick(Block b) { protected void tick(Block b) {
BlockMenu menu = BlockStorage.getInventory(b.getLocation()); BlockMenu menu = BlockStorage.getInventory(b.getLocation());
if (isProcessing(b)) { if (isProcessing(b)) {
int timeleft = progress.get(b); int timeleft = progress.get(b);
@ -85,7 +86,8 @@ public class AutoEnchanter extends AContainer {
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1] : getInputSlots()[0]); ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1] : getInputSlots()[0]);
// Check if enchantable
// Check if the item is enchantable
SlimefunItem sfTarget = SlimefunItem.getByItem(target); SlimefunItem sfTarget = SlimefunItem.getByItem(target);
if (sfTarget != null && !sfTarget.isEnchantable()) return; if (sfTarget != null && !sfTarget.isEnchantable()) return;

View File

@ -25,12 +25,14 @@ public abstract class ElectricFurnace extends AContainer {
public void registerDefaultRecipes() { public void registerDefaultRecipes() {
Iterator<Recipe> iterator = Bukkit.recipeIterator(); Iterator<Recipe> iterator = Bukkit.recipeIterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Recipe r = iterator.next(); Recipe recipe = iterator.next();
if (r instanceof CookingRecipe) {
RecipeChoice choice = ((CookingRecipe<?>) r).getInputChoice(); if (recipe instanceof CookingRecipe) {
RecipeChoice choice = ((CookingRecipe<?>) recipe).getInputChoice();
if (choice instanceof MaterialChoice) { if (choice instanceof MaterialChoice) {
for (Material input : ((MaterialChoice) choice).getChoices()) { for (Material input : ((MaterialChoice) choice).getChoices()) {
registerRecipe(4, new ItemStack[] { new ItemStack(input) }, new ItemStack[] { r.getResult() }); registerRecipe(4, new ItemStack[] { new ItemStack(input) }, new ItemStack[] { recipe.getResult() });
} }
} }
} }

View File

@ -8,7 +8,6 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
@ -39,19 +38,6 @@ public class ElectricIngotPulverizer extends AContainer implements RecipeDisplay
return new ItemStack(Material.IRON_PICKAXE); return new ItemStack(Material.IRON_PICKAXE);
} }
@Override
protected void registerDefaultRecipes() {
registerRecipe(3, new ItemStack[] { SlimefunItems.ALUMINUM_INGOT }, new ItemStack[] { SlimefunItems.ALUMINUM_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.COPPER_INGOT }, new ItemStack[] { SlimefunItems.COPPER_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.GOLD_4K }, new ItemStack[] { SlimefunItems.GOLD_DUST });
registerRecipe(3, new ItemStack[] { new ItemStack(Material.IRON_INGOT) }, new ItemStack[] { SlimefunItems.IRON_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.LEAD_INGOT }, new ItemStack[] { SlimefunItems.LEAD_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.MAGNESIUM_INGOT }, new ItemStack[] { SlimefunItems.MAGNESIUM_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.SILVER_INGOT }, new ItemStack[] { SlimefunItems.SILVER_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.TIN_INGOT }, new ItemStack[] { SlimefunItems.TIN_DUST });
registerRecipe(3, new ItemStack[] { SlimefunItems.ZINC_INGOT }, new ItemStack[] { SlimefunItems.ZINC_DUST });
}
@Override @Override
public List<ItemStack> getDisplayRecipes() { public List<ItemStack> getDisplayRecipes() {
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2); List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);

View File

@ -22,6 +22,7 @@ public abstract class ElectricPress extends AContainer implements RecipeDisplayI
addRecipe(4, new CustomItem(SlimefunItems.STONE_CHUNK, 3), new ItemStack(Material.COBBLESTONE)); addRecipe(4, new CustomItem(SlimefunItems.STONE_CHUNK, 3), new ItemStack(Material.COBBLESTONE));
addRecipe(4, new ItemStack(Material.FLINT, 6), new ItemStack(Material.COBBLESTONE)); addRecipe(4, new ItemStack(Material.FLINT, 6), new ItemStack(Material.COBBLESTONE));
addRecipe(5, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS_PANE, 3)); addRecipe(5, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS_PANE, 3));
addRecipe(4, new ItemStack(Material.SNOWBALL, 4), new ItemStack(Material.SNOW_BLOCK));
addRecipe(6, SlimefunItems.COPPER_INGOT, new CustomItem(SlimefunItems.COPPER_WIRE, 3)); addRecipe(6, SlimefunItems.COPPER_INGOT, new CustomItem(SlimefunItems.COPPER_WIRE, 3));
addRecipe(16, new CustomItem(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE); addRecipe(16, new CustomItem(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE);

View File

@ -27,6 +27,7 @@ public abstract class Freezer extends AContainer implements RecipeDisplayItem {
registerRecipe(4, new ItemStack[] { new ItemStack(Material.ICE) }, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }); registerRecipe(4, new ItemStack[] { new ItemStack(Material.ICE) }, new ItemStack[] { new ItemStack(Material.PACKED_ICE) });
registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }); registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }, new ItemStack[] { new ItemStack(Material.BLUE_ICE) });
registerRecipe(8, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }, new ItemStack[] { SlimefunItems.REACTOR_COOLANT_CELL }); registerRecipe(8, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }, new ItemStack[] { SlimefunItems.REACTOR_COOLANT_CELL });
registerRecipe(6, new ItemStack[] { new ItemStack(Material.SNOW_BLOCK, 2) }, new ItemStack[] { new ItemStack(Material.ICE) });
} }
@Override @Override

View File

@ -183,7 +183,9 @@ public final class PostSetup {
// We want to exclude Dust to Ingot Recipes // We want to exclude Dust to Ingot Recipes
if (inputs.size() == 1 && isDust(inputs.get(0))) { if (inputs.size() == 1 && isDust(inputs.get(0))) {
((MakeshiftSmeltery) SlimefunItems.MAKESHIFT_SMELTERY.getItem()).addRecipe(new ItemStack[] { inputs.get(0) }, recipe[0]); ((MakeshiftSmeltery) SlimefunItems.MAKESHIFT_SMELTERY.getItem()).addRecipe(new ItemStack[] { inputs.get(0) }, recipe[0]);
registerMachineRecipe("ELECTRIC_INGOT_FACTORY", 8, new ItemStack[] { inputs.get(0) }, new ItemStack[] { recipe[0] }); registerMachineRecipe("ELECTRIC_INGOT_FACTORY", 8, new ItemStack[] { inputs.get(0) }, new ItemStack[] { recipe[0] });
registerMachineRecipe("ELECTRIC_INGOT_PULVERIZER", 3, new ItemStack[] { recipe[0] }, new ItemStack[] { inputs.get(0) });
} }
else { else {
registerMachineRecipe("ELECTRIC_SMELTERY", 12, inputs.toArray(new ItemStack[0]), new ItemStack[] { recipe[0] }); registerMachineRecipe("ELECTRIC_SMELTERY", 12, inputs.toArray(new ItemStack[0]), new ItemStack[] { recipe[0] });

View File

@ -44,8 +44,8 @@ public class CargoNet extends Network {
private static final int[] slots = { 19, 20, 21, 28, 29, 30, 37, 38, 39 }; private static final int[] slots = { 19, 20, 21, 28, 29, 30, 37, 38, 39 };
// Chest Terminal Stuff // Chest Terminal Stuff
public static final int[] TERMINAL_SLOTS = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42 }; private static final int[] TERMINAL_SLOTS = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42 };
public static final int TERMINAL_OUT_SLOT = 17; private static final int TERMINAL_OUT_SLOT = 17;
private final ItemStack terminalPlaceholderItem = new CustomItem(new ItemStack(Material.BARRIER), "&4No Item cached"); private final ItemStack terminalPlaceholderItem = new CustomItem(new ItemStack(Material.BARRIER), "&4No Item cached");
@ -75,11 +75,6 @@ public class CargoNet extends Network {
return cargoNetwork; return cargoNetwork;
} }
@Deprecated
public static boolean isConnected(Block b) {
return getNetworkFromLocation(b.getLocation()) != null;
}
protected CargoNet(Location l) { protected CargoNet(Location l) {
super(l); super(l);
} }
@ -197,8 +192,11 @@ public class CargoNet extends Network {
} }
} }
Slimefun.runSync(() -> { Slimefun.runSync(() -> run(b, providers, destinations, output));
}
}
private void run(Block b, Set<Location> providers, Set<Location> destinations, Map<Integer, List<Location>> output) {
if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) { if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) {
display(); display();
} }
@ -514,8 +512,6 @@ public class CargoNet extends Network {
} }
} }
} }
});
}
} }
private static Block getAttachedBlock(Block block) { private static Block getAttachedBlock(Block block) {