mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Some more refactoring
This commit is contained in:
parent
d1807bc39f
commit
6b4f914784
@ -101,6 +101,9 @@ public class EnergyNet extends Network {
|
||||
if (component instanceof EnergyNetProvider) {
|
||||
generators.put(l, (EnergyNetProvider) component);
|
||||
}
|
||||
else if (component instanceof SlimefunItem) {
|
||||
((SlimefunItem) component).warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -702,7 +702,7 @@ public final class SlimefunItems {
|
||||
public static final SlimefunItemStack GPS_GEO_SCANNER = new SlimefunItemStack("GPS_GEO_SCANNER", HeadTexture.GEO_SCANNER, "&bGPS Geo-Scanner", "", "&fScans a Chunk for natural Resources", "&fsuch as &8Oil");
|
||||
public static final SlimefunItemStack PORTABLE_GEO_SCANNER = new SlimefunItemStack("PORTABLE_GEO_SCANNER", Material.CLOCK, "&bPortable Geo-Scanner", "", "&fScans a Chunk for natural Resources", "", "&eRight Click&7 to scan");
|
||||
public static final SlimefunItemStack GEO_MINER = new SlimefunItemStack("GEO_MINER", HeadTexture.GEO_MINER, "&6GEO Miner", "", "&eMines up resources from the chunk", "&eThese Resources cannot be mined with a pickaxe", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(48), "", "&c&l! &cMake sure to Geo-Scan the Chunk first");
|
||||
public static final SlimefunItemStack OIL_PUMP = new SlimefunItemStack("OIL_PUMP", HeadTexture.OIL_PUMP, "&fOil Pump", "", "&7Pumps up Oil and fills it into Buckets", "", "&c&l! &cMake sure to Geo-Scan the Chunk first");
|
||||
public static final SlimefunItemStack OIL_PUMP = new SlimefunItemStack("OIL_PUMP", HeadTexture.OIL_PUMP, "&4Oil Pump", "", "&7Pumps up Oil and fills it into Buckets", "", "&c&l! &cMake sure to Geo-Scan the Chunk first");
|
||||
public static final SlimefunItemStack OIL_BUCKET = new SlimefunItemStack("BUCKET_OF_OIL", HeadTexture.OIL_BUCKET, "&fBucket of Oil");
|
||||
public static final SlimefunItemStack FUEL_BUCKET = new SlimefunItemStack("BUCKET_OF_FUEL", HeadTexture.FUEL_BUCKET, "&fBucket of Fuel");
|
||||
|
||||
|
@ -10,19 +10,16 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
||||
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;
|
||||
@ -80,62 +77,39 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem {
|
||||
return "OIL_PUMP";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryTitle() {
|
||||
return "&4Oil Pump";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getProgressBar() {
|
||||
return new ItemStack(Material.DIAMOND_SHOVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick(Block b) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
protected MachineRecipe findNextRecipe(BlockMenu inv) {
|
||||
if (inv.fits(SlimefunItems.OIL_BUCKET, getOutputSlots())) {
|
||||
Block b = inv.getBlock();
|
||||
|
||||
if (isProcessing(b)) {
|
||||
int timeleft = progress.get(b);
|
||||
|
||||
if (timeleft > 0) {
|
||||
ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
|
||||
|
||||
if (getCharge(b.getLocation()) < getEnergyConsumption()) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeCharge(b.getLocation(), getEnergyConsumption());
|
||||
progress.put(b, timeleft - 1);
|
||||
}
|
||||
else {
|
||||
inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
||||
inv.pushItem(SlimefunItems.OIL_BUCKET, getOutputSlots());
|
||||
|
||||
progress.remove(b);
|
||||
processing.remove(b);
|
||||
}
|
||||
}
|
||||
else if (inv.fits(SlimefunItems.OIL_BUCKET, getOutputSlots())) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.BUCKET), true, false)) {
|
||||
OptionalInt supplies = SlimefunPlugin.getGPSNetwork().getResourceManager().getSupplies(oil, b.getWorld(), b.getX() >> 4, b.getZ() >> 4);
|
||||
|
||||
if (supplies.isPresent() && supplies.getAsInt() > 0) {
|
||||
MachineRecipe r = new MachineRecipe(26, new ItemStack[0], new ItemStack[] { SlimefunItems.OIL_BUCKET });
|
||||
MachineRecipe recipe = new MachineRecipe(26, new ItemStack[0], new ItemStack[] { SlimefunItems.OIL_BUCKET });
|
||||
|
||||
inv.consumeItem(slot);
|
||||
processing.put(b, r);
|
||||
progress.put(b, r.getTicks());
|
||||
SlimefunPlugin.getGPSNetwork().getResourceManager().setSupplies(oil, b.getWorld(), b.getX() >> 4, b.getZ() >> 4, supplies.getAsInt() - 1);
|
||||
return recipe;
|
||||
}
|
||||
else {
|
||||
// Move the empty bucket to the output slot to prevent this
|
||||
// from immediately starting all over again (to prevent lag)
|
||||
ItemStack item = inv.getItemInSlot(slot).clone();
|
||||
inv.replaceExistingItem(slot, null);
|
||||
inv.pushItem(item, getOutputSlots());
|
||||
}
|
||||
break;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user