mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
[CI skip] Reduced technical debt and tweaked Magnesium Salt
This commit is contained in:
parent
331b9b64a7
commit
f7fa6e2972
@ -4,13 +4,17 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.Categories;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
|
||||
/**
|
||||
* Statically handles categories.
|
||||
@ -25,9 +29,9 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
*/
|
||||
public class Category {
|
||||
|
||||
private ItemStack item;
|
||||
private List<SlimefunItem> items;
|
||||
private int tier;
|
||||
private final ItemStack item;
|
||||
private final List<SlimefunItem> items;
|
||||
private final int tier;
|
||||
|
||||
/**
|
||||
* Constructs a Category with the given display item.
|
||||
|
@ -15,9 +15,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
|
||||
|
||||
private int speed;
|
||||
private int efficiency;
|
||||
private int fortune;
|
||||
private final int speed;
|
||||
private final int efficiency;
|
||||
private final int fortune;
|
||||
|
||||
public EnhancedFurnace(int speed, int efficiency, int fortune, SlimefunItemStack item, ItemStack[] recipe) {
|
||||
super(Categories.MACHINES_1, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
|
||||
@ -36,11 +36,11 @@ public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
|
||||
}
|
||||
|
||||
public int getOutput() {
|
||||
int fortune = this.fortune;
|
||||
fortune = new Random().nextInt(fortune + 2) - 1;
|
||||
if (fortune <= 0) fortune = 0;
|
||||
fortune++;
|
||||
return fortune;
|
||||
int bonus = this.fortune;
|
||||
bonus = new Random().nextInt(bonus + 2) - 1;
|
||||
if (bonus <= 0) bonus = 0;
|
||||
bonus++;
|
||||
return bonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||
* @since 4.1.10
|
||||
*/
|
||||
public enum ItemState {
|
||||
|
||||
/**
|
||||
* This SlimefunItem is enabled.
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class JetBoots extends DamagableChargableItem {
|
||||
|
||||
private double speed;
|
||||
private final double speed;
|
||||
|
||||
public JetBoots(SlimefunItemStack item, ItemStack[] recipe, double speed) {
|
||||
super(Categories.TECH, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe, "Jet Boots");
|
||||
|
@ -9,7 +9,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SlimefunArmorPiece extends SlimefunItem {
|
||||
|
||||
private PotionEffect[] effects;
|
||||
private final PotionEffect[] effects;
|
||||
|
||||
public SlimefunArmorPiece(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) {
|
||||
super(category, item, id, recipeType, recipe);
|
||||
|
@ -8,7 +8,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SlimefunBackpack extends SlimefunItem {
|
||||
|
||||
private int size;
|
||||
private final int size;
|
||||
|
||||
public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
@ -12,6 +12,7 @@ public class SlimefunBow extends SlimefunItem {
|
||||
super(Categories.WEAPONS, item, id, RecipeType.MAGIC_WORKBENCH, recipe);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SlimefunBow(SlimefunItemStack item, ItemStack[] recipe) {
|
||||
super(Categories.WEAPONS, item, RecipeType.MAGIC_WORKBENCH, recipe);
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ public class Talisman extends SlimefunItem {
|
||||
public void install() {
|
||||
EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(upgrade());
|
||||
Research research = Research.getByID(112);
|
||||
|
||||
if (talisman != null) {
|
||||
Slimefun.addOfficialWikiPage(talisman.getID(), "Talismans");
|
||||
if (research != null) talisman.bindToResearch(research);
|
||||
|
@ -27,6 +27,7 @@ public class VanillaItem extends SlimefunItem {
|
||||
*/
|
||||
public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, id, recipeType, recipe);
|
||||
|
||||
useableInWorkbench = true;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.inventory.BlockInventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -77,7 +77,7 @@ public class BlockPlacer extends SimpleSlimefunItem<AutonomousMachineHandler> {
|
||||
//Changing the inventory of the block based on the inventory of the block's itemstack (Currently only applies to shulker boxes)
|
||||
//Inventory has to be changed after blockState.update() as updating it will create a different Inventory for the object
|
||||
if (block.getState() instanceof BlockInventoryHolder) {
|
||||
((BlockInventoryHolder) block.getState()).getInventory().setContents(((BlockInventoryHolder) itemBlockState).getInventory().getContents());;
|
||||
((BlockInventoryHolder) block.getState()).getInventory().setContents(((BlockInventoryHolder) itemBlockState).getInventory().getContents());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,11 +73,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem implements InventoryBl
|
||||
|
||||
@Override
|
||||
public void tick(Block b, SlimefunItem sf, Config data) {
|
||||
try {
|
||||
AnimalGrowthAccelerator.this.tick(b);
|
||||
} catch (Exception x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking an Animal Growth Accelerator for Slimefun " + Slimefun.getVersion(), x);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,6 +99,7 @@ public abstract class AutoAnvil extends AContainer {
|
||||
for (int slot : getInputSlots()) {
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
}
|
||||
|
||||
processing.put(b, recipe);
|
||||
progress.put(b, recipe.getTicks());
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class AutoDisenchanter extends AContainer {
|
||||
else {
|
||||
MachineRecipe recipe = null;
|
||||
Map<Enchantment, Integer> enchantments = new HashMap<>();
|
||||
Set<ItemEnchantment> enchantments2 = new HashSet<>();
|
||||
Set<ItemEnchantment> emeraldEnchantments = new HashSet<>();
|
||||
|
||||
for (int slot : getInputSlots()) {
|
||||
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
|
||||
@ -108,15 +108,15 @@ public class AutoDisenchanter extends AContainer {
|
||||
if (item != null && target != null && target.getType() == Material.BOOK) {
|
||||
int amount = 0;
|
||||
|
||||
for (Map.Entry<Enchantment, Integer> e : item.getEnchantments().entrySet()) {
|
||||
enchantments.put(e.getKey(), e.getValue());
|
||||
for (Map.Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) {
|
||||
enchantments.put(entry.getKey(), entry.getValue());
|
||||
amount++;
|
||||
}
|
||||
|
||||
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
|
||||
for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
||||
amount++;
|
||||
enchantments2.add(enchantment);
|
||||
emeraldEnchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,16 +136,16 @@ public class AutoDisenchanter extends AContainer {
|
||||
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
|
||||
|
||||
for (Map.Entry<Enchantment,Integer> e : enchantments.entrySet()) {
|
||||
newItem.removeEnchantment(e.getKey());
|
||||
meta.addStoredEnchant(e.getKey(), e.getValue(), true);
|
||||
for (Map.Entry<Enchantment,Integer> entry : enchantments.entrySet()) {
|
||||
newItem.removeEnchantment(entry.getKey());
|
||||
meta.addStoredEnchant(entry.getKey(), entry.getValue(), true);
|
||||
}
|
||||
|
||||
book.setItemMeta(meta);
|
||||
|
||||
for (ItemEnchantment e : enchantments2) {
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, e.getEnchantment(), e.getLevel());
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), 0);
|
||||
for (ItemEnchantment ench : emeraldEnchantments) {
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, ench.getEnchantment(), ench.getLevel());
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, ench.getEnchantment(), 0);
|
||||
}
|
||||
|
||||
recipe = new MachineRecipe(100 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, book});
|
||||
|
@ -85,7 +85,7 @@ public class AutoEnchanter extends AContainer {
|
||||
// Enchant
|
||||
if (item != null && item.getType() == Material.ENCHANTED_BOOK && target != null) {
|
||||
Map<Enchantment, Integer> enchantments = new HashMap<>();
|
||||
Set<ItemEnchantment> enchantments2 = new HashSet<>();
|
||||
Set<ItemEnchantment> emeraldEnchantments = new HashSet<>();
|
||||
int amount = 0;
|
||||
int specialAmount = 0;
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
|
||||
@ -102,7 +102,7 @@ public class AutoEnchanter extends AContainer {
|
||||
if (EmeraldEnchants.getInstance().getRegistry().isApplicable(target, enchantment.getEnchantment()) && EmeraldEnchants.getInstance().getRegistry().getEnchantmentLevel(target, enchantment.getEnchantment().getName()) < enchantment.getLevel()) {
|
||||
amount++;
|
||||
specialAmount++;
|
||||
enchantments2.add(enchantment);
|
||||
emeraldEnchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
specialAmount += EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size();
|
||||
@ -110,12 +110,13 @@ public class AutoEnchanter extends AContainer {
|
||||
|
||||
if (amount > 0 && specialAmount <= SlimefunPlugin.getSettings().emeraldEnchantsLimit) {
|
||||
ItemStack newItem = target.clone();
|
||||
for (Map.Entry<Enchantment, Integer> e: enchantments.entrySet()) {
|
||||
newItem.addUnsafeEnchantment(e.getKey(), e.getValue());
|
||||
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
newItem.addUnsafeEnchantment(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (ItemEnchantment e: enchantments2) {
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), e.getLevel());
|
||||
for (ItemEnchantment ench: emeraldEnchantments) {
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, ench.getEnchantment(), ench.getLevel());
|
||||
}
|
||||
|
||||
recipe = new MachineRecipe(75 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, new ItemStack(Material.BOOK)});
|
||||
|
@ -39,6 +39,7 @@ public class ChargingBench extends AContainer {
|
||||
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
||||
|
||||
BlockMenu menu = BlockStorage.getInventory(b);
|
||||
|
||||
for (int slot : getInputSlots()) {
|
||||
ItemStack stack = menu.getItemInSlot(slot);
|
||||
if (ItemEnergy.getMaxEnergy(stack) > 0) {
|
||||
@ -46,6 +47,7 @@ public class ChargingBench extends AContainer {
|
||||
|
||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||
float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2F);
|
||||
|
||||
if (rest > 0F) {
|
||||
if (menu.fits(stack, getOutputSlots())) {
|
||||
menu.pushItem(stack, getOutputSlots());
|
||||
|
@ -88,11 +88,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
|
||||
|
||||
@Override
|
||||
public void tick(Block b, SlimefunItem sf, Config data) {
|
||||
try {
|
||||
CropGrowthAccelerator.this.tick(b);
|
||||
} catch (Exception x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking a Crop Growth Accelerator for Slimefun " + Slimefun.getVersion(), x);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,8 +73,8 @@ public abstract class ElectricDustWasher extends AContainer {
|
||||
if (!SlimefunPlugin.getSettings().legacyDustWasher) {
|
||||
boolean emptySlot = false;
|
||||
|
||||
for (int output_slot: getOutputSlots()) {
|
||||
if (menu.getItemInSlot(output_slot) == null) {
|
||||
for (int outputSlot : getOutputSlots()) {
|
||||
if (menu.getItemInSlot(outputSlot) == null) {
|
||||
emptySlot = true;
|
||||
break;
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public abstract class ElectricFurnace extends AContainer {
|
||||
}
|
||||
|
||||
//Bukkit Recipe Iterator does not seem to include _LOG's of any type for charcoal... Manually adding them all.
|
||||
for (Material mat:Tag.LOGS.getValues()) {
|
||||
registerRecipe(4, new ItemStack[] {new ItemStack(mat,1)}, new ItemStack[] {new ItemStack(Material.CHARCOAL, 1)});
|
||||
for (Material log : Tag.LOGS.getValues()) {
|
||||
registerRecipe(4, new ItemStack[] {new ItemStack(log, 1)}, new ItemStack[] {new ItemStack(Material.CHARCOAL, 1)});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ public class FluidPump extends SlimefunItem implements InventoryBlock {
|
||||
|
||||
if (output != null && ChargableBlock.getCharge(b) >= energyConsumption) {
|
||||
BlockMenu menu = BlockStorage.getInventory(b);
|
||||
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
if (!menu.fits(output, getOutputSlots())) return;
|
||||
|
@ -95,7 +95,7 @@ public abstract class HeatedPressureChamber extends AContainer {
|
||||
registerRecipe(90, new ItemStack[] {SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM}, new ItemStack[] {SlimefunItems.BOOSTED_URANIUM});
|
||||
registerRecipe(60, new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM}, new ItemStack[] {new CustomItem(SlimefunItems.ENRICHED_NETHER_ICE, 4)});
|
||||
registerRecipe(45, new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE}, new ItemStack[] {new CustomItem(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8)});
|
||||
registerRecipe(12, new ItemStack[] {SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT}, new ItemStack[] {SlimefunItems.MAGNESIUM_SALT});
|
||||
registerRecipe(8, new ItemStack[] {SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT}, new ItemStack[] {SlimefunItems.MAGNESIUM_SALT});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,9 @@ public abstract class Refinery extends AContainer implements RecipeDisplayItem {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) {
|
||||
MachineRecipe r = new MachineRecipe(40, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_FUEL});
|
||||
|
||||
if (!menu.fits(SlimefunItems.BUCKET_OF_FUEL, getOutputSlots())) return;
|
||||
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
processing.put(b, r);
|
||||
progress.put(b, r.getTicks());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -52,7 +50,6 @@ public class WitherAssembler extends SlimefunItem {
|
||||
|
||||
@Override
|
||||
public void newInstance(final BlockMenu menu, final Block b) {
|
||||
try {
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) {
|
||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
|
||||
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
|
||||
@ -79,9 +76,6 @@ public class WitherAssembler extends SlimefunItem {
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
});
|
||||
} catch(Exception x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while creating a Wither Assembler for Slimefun " + Slimefun.getVersion(), x);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,11 +81,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
|
||||
|
||||
@Override
|
||||
public void tick(Block b, SlimefunItem sf, Config data) {
|
||||
try {
|
||||
XPCollector.this.tick(b);
|
||||
} catch (Exception x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking an Exp Collector for Slimefun " + Slimefun.getVersion(), x);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,7 @@ public abstract class MagnesiumGenerator extends AGenerator {
|
||||
|
||||
@Override
|
||||
public void registerDefaultRecipes() {
|
||||
registerFuel(new MachineFuel(10, SlimefunItems.MAGNESIUM_SALT));
|
||||
registerFuel(new MachineFuel(12, SlimefunItems.MAGNESIUM_SALT));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,6 +109,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
||||
@Override
|
||||
public List<ItemStack> getDisplayRecipes() {
|
||||
List<ItemStack> displayRecipes = new LinkedList<>();
|
||||
|
||||
for (OreGenResource resource : OreGenSystem.listResources()) {
|
||||
if (!resource.isLiquid()) {
|
||||
displayRecipes.add(new CustomItem(resource.getItem(), "&r" + resource.getName()));
|
||||
@ -182,6 +183,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
||||
}
|
||||
else {
|
||||
int supplies = OreGenSystem.getSupplies(resource, chunk, false);
|
||||
|
||||
if (supplies > 0) {
|
||||
MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], new ItemStack[] {resource.getItem().clone()});
|
||||
if (!menu.fits(r.getOutput()[0], getOutputSlots())) return;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -44,6 +44,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (e.getClickedBlock() == null) return false;
|
||||
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (id == null || !id.equals(getID())) return false;
|
||||
|
@ -52,8 +52,10 @@ public class ArmorForge extends MultiBlockMachine {
|
||||
|
||||
if (craft) {
|
||||
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||
|
||||
if (Slimefun.hasUnlocked(p, adding, true)) {
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
|
||||
if (outputInv != null) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
ItemStack item = inv.getContents()[j];
|
||||
@ -64,6 +66,7 @@ public class ArmorForge extends MultiBlockMachine {
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int current = j;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
|
||||
if (current < 3) {
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F);
|
||||
|
@ -46,15 +46,18 @@ public class Compressor extends MultiBlockMachine {
|
||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
||||
Inventory inv = disp.getInventory();
|
||||
|
||||
for (ItemStack current : inv.getContents()) {
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
final ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
|
||||
if (outputInv != null) {
|
||||
ItemStack removing = current.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
inv.removeItem(removing);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int j = i;
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
||||
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
boolean craft = true;
|
||||
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
|
||||
@ -92,6 +93,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String id = "";
|
||||
int size = ((SlimefunBackpack) sfItem).getSize();
|
||||
|
||||
@ -131,6 +133,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
||||
|
||||
for (int j = 0; j < 9; j++) {
|
||||
ItemStack item = inv.getContents()[j];
|
||||
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
ItemUtils.consumeItem(item, true);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public class Juicer extends MultiBlockMachine {
|
||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
||||
Inventory inv = disp.getInventory();
|
||||
|
||||
for (ItemStack current : inv.getContents()) {
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
|
@ -52,11 +52,12 @@ public class MagicWorkbench extends MultiBlockMachine {
|
||||
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) dispBlock = b.getRelative(0, 0, -1);
|
||||
|
||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
||||
final Inventory inv = disp.getInventory();
|
||||
Inventory inv = disp.getInventory();
|
||||
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
|
||||
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
boolean craft = true;
|
||||
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
|
||||
@ -73,7 +74,8 @@ public class MagicWorkbench extends MultiBlockMachine {
|
||||
}
|
||||
|
||||
if (craft) {
|
||||
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||
ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||
|
||||
if (Slimefun.hasUnlocked(p, adding, true)) {
|
||||
Inventory inv2 = Bukkit.createInventory(null, 9, "test");
|
||||
|
||||
@ -137,14 +139,17 @@ public class MagicWorkbench extends MultiBlockMachine {
|
||||
else inv.setItem(j, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int current = j;
|
||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
|
||||
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
|
||||
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
|
||||
|
||||
if (current < 3) {
|
||||
p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||
outputInv.addItem(adding);
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
Block dispBlock = b.getRelative(BlockFace.DOWN);
|
||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
||||
Inventory inv = disp.getInventory();
|
||||
|
||||
for (ItemStack current : inv.getContents()) {
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
|
@ -132,7 +132,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.Electric
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricPress;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricSmeltery;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectrifiedCrucible;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElevatorPlate;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.EnergyRegulator;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FluidPump;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FoodComposter;
|
||||
@ -151,6 +150,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOM
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOScannerBlock;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.NetherDrill;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.OilPump;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.ElevatorPlate;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.ArmorForge;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.AutomatedPanningMachine;
|
||||
|
@ -158,8 +158,10 @@ public class BlockStorage {
|
||||
else f.mkdirs();
|
||||
|
||||
File chunks = new File(path_chunks + "chunks.sfc");
|
||||
|
||||
if (chunks.exists()) {
|
||||
FileConfiguration cfg = YamlConfiguration.loadConfiguration(chunks);
|
||||
|
||||
for (String key : cfg.getKeys(false)) {
|
||||
try {
|
||||
if (world.getName().equals(key.split(";")[0])) {
|
||||
@ -180,6 +182,7 @@ public class BlockStorage {
|
||||
|
||||
try {
|
||||
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
|
||||
|
||||
if (preset == null) {
|
||||
preset = BlockMenuPreset.getPreset(checkID(l));
|
||||
}
|
||||
@ -342,6 +345,7 @@ public class BlockStorage {
|
||||
if (json != null && json.length() > 2) {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject obj = parser.parse(json).getAsJsonObject();
|
||||
|
||||
for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue().getAsString());
|
||||
}
|
||||
@ -367,9 +371,11 @@ public class BlockStorage {
|
||||
|
||||
private static String serializeBlockInfo(Config cfg) {
|
||||
JsonObject json = new JsonObject();
|
||||
|
||||
for (String key : cfg.getKeys()) {
|
||||
json.add(key, new JsonPrimitive(cfg.getString(key)));
|
||||
}
|
||||
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
@ -426,6 +432,7 @@ public class BlockStorage {
|
||||
public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) {
|
||||
BlockStorage storage = getStorage(l.getWorld());
|
||||
storage.storage.put(l, cfg);
|
||||
|
||||
if (BlockMenuPreset.isInventory(cfg.getString("id"))) {
|
||||
if (BlockMenuPreset.isUniversalInventory(cfg.getString("id"))) {
|
||||
if (!SlimefunPlugin.getUtilities().universalInventories.containsKey(cfg.getString("id"))) {
|
||||
@ -439,6 +446,7 @@ public class BlockStorage {
|
||||
else storage.loadInventory(l, BlockMenuPreset.getPreset(cfg.getString("id")));
|
||||
}
|
||||
}
|
||||
|
||||
refreshCache(getStorage(l.getWorld()), l, cfg.getString("id"), serializeBlockInfo(cfg), updateTicker);
|
||||
}
|
||||
|
||||
@ -470,6 +478,7 @@ public class BlockStorage {
|
||||
|
||||
public static void _integrated_removeBlockInfo(Location l, boolean destroy) {
|
||||
BlockStorage storage = getStorage(l.getWorld());
|
||||
|
||||
if (hasBlockInfo(l)) {
|
||||
refreshCache(storage, l, getLocationInfo(l).getString("id"), null, destroy);
|
||||
storage.storage.remove(l);
|
||||
@ -477,14 +486,17 @@ public class BlockStorage {
|
||||
|
||||
if (destroy) {
|
||||
if (storage.hasInventory(l)) storage.clearInventory(l);
|
||||
|
||||
if (storage.hasUniversalInventory(l)) {
|
||||
storage.getUniversalInventory(l).close();
|
||||
storage.getUniversalInventory(l).save();
|
||||
}
|
||||
|
||||
String chunkString = locationToChunkString(l);
|
||||
if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) {
|
||||
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
|
||||
locations.remove(l);
|
||||
|
||||
if (locations.isEmpty()) {
|
||||
SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString);
|
||||
SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString);
|
||||
@ -513,6 +525,7 @@ public class BlockStorage {
|
||||
BlockStorage storage = getStorage(from.getWorld());
|
||||
|
||||
setBlockInfo(to, getLocationInfo(from), true);
|
||||
|
||||
if (storage.inventories.containsKey(from)) {
|
||||
BlockMenu menu = storage.inventories.get(from);
|
||||
storage.inventories.put(to, menu);
|
||||
@ -524,9 +537,11 @@ public class BlockStorage {
|
||||
storage.storage.remove(from);
|
||||
|
||||
String chunkString = locationToChunkString(from);
|
||||
|
||||
if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) {
|
||||
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
|
||||
locations.remove(from);
|
||||
|
||||
if (locations.isEmpty()) {
|
||||
SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString);
|
||||
SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString);
|
||||
@ -541,8 +556,10 @@ public class BlockStorage {
|
||||
|
||||
if (updateTicker) {
|
||||
SlimefunItem item = SlimefunItem.getByID(key);
|
||||
|
||||
if (item != null && item.isTicking()) {
|
||||
String chunkString = locationToChunkString(l);
|
||||
|
||||
if (value != null) {
|
||||
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
|
||||
if (locations == null) locations = new HashSet<>();
|
||||
@ -615,9 +632,11 @@ public class BlockStorage {
|
||||
@Deprecated
|
||||
public static Set<Block> getTickingBlocks(String chunk) {
|
||||
Set<Block> ret = new HashSet<>();
|
||||
|
||||
for (Location l : getTickingLocations(chunk)) {
|
||||
ret.add(l.getBlock());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
@Deprecated
|
||||
public interface GuideHandler {
|
||||
|
||||
public abstract void addEntry(List<String> texts, List<String> tooltips);
|
||||
|
Loading…
Reference in New Issue
Block a user