mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Added ReactorExplodeEvent to the API
This commit is contained in:
parent
907fb1566a
commit
4b38dd655d
@ -24,6 +24,7 @@
|
||||
#### Additions
|
||||
* Added a starting sound for the Ancient Altar
|
||||
* Added config option to disable backwards compatibility and improve performance
|
||||
* Added ReactorExplodeEvent to the API
|
||||
|
||||
#### Changes
|
||||
* Coolant Cells now last twice as long
|
||||
|
@ -0,0 +1,58 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* The {@link ReactorExplodeEvent} is called whenever a reactor explodes.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
public class ReactorExplodeEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Location location;
|
||||
private final Reactor reactor;
|
||||
|
||||
public ReactorExplodeEvent(Location l, Reactor reactor) {
|
||||
Validate.notNull(l, "A Location must be provided");
|
||||
Validate.notNull(reactor, "A Reactor cannot be null");
|
||||
|
||||
this.location = l;
|
||||
this.reactor = reactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the {@link Location} where the reactor exploded.
|
||||
*
|
||||
* @return The {@link Location} of this explosion
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link SlimefunItem} instance of the exploded reactor.
|
||||
*
|
||||
* @return The {@link SlimefunItem} instance
|
||||
*/
|
||||
public Reactor getReactor() {
|
||||
return reactor;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -13,11 +13,11 @@ import io.github.thebusybiscuit.slimefun4.api.ErrorReport;
|
||||
import io.github.thebusybiscuit.slimefun4.api.network.Network;
|
||||
import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
@ -226,8 +226,8 @@ public class EnergyNet extends Network {
|
||||
if (generator.explode(source)) {
|
||||
exploded.add(source);
|
||||
BlockStorage.clearBlockInfo(source);
|
||||
AReactor.processing.remove(source);
|
||||
AReactor.progress.remove(source);
|
||||
Reactor.processing.remove(source);
|
||||
Reactor.progress.remove(source);
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
source.getBlock().setType(Material.LAVA);
|
||||
|
@ -4,9 +4,9 @@ import org.bukkit.block.Block;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
||||
|
||||
/**
|
||||
* This enum contains the different types of components an {@link EnergyNet}
|
||||
|
@ -9,13 +9,13 @@ import org.bukkit.inventory.ItemStack;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
@ -160,7 +160,7 @@ public class ReactorAccessPort extends SlimefunItem {
|
||||
Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
|
||||
|
||||
SlimefunItem item = BlockStorage.check(reactorL.getBlock());
|
||||
if (item instanceof AReactor) return BlockStorage.getInventory(reactorL);
|
||||
if (item instanceof Reactor) return BlockStorage.getInventory(reactorL);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.electric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -14,19 +14,31 @@ import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
abstract class AbstractEnergyGenerator extends SlimefunItem implements InventoryBlock, RecipeDisplayItem, EnergyNetComponent {
|
||||
/**
|
||||
* This is an abstract super class for machines that produce energy.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see AGenerator
|
||||
* @see Reactor
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractEnergyProvider extends SlimefunItem implements InventoryBlock, RecipeDisplayItem, EnergyNetComponent {
|
||||
|
||||
protected final Set<MachineFuel> fuelTypes = new HashSet<>();
|
||||
|
||||
protected AbstractEnergyGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
protected AbstractEnergyProvider(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
@ -12,13 +12,12 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.holograms.ReactorHologram;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
* The {@link NetherStarReactor} is an implementation of {@link AReactor} that consumes
|
||||
* The {@link NetherStarReactor} is an implementation of {@link Reactor} that consumes
|
||||
* Nether Stars and adds Withering to any nearby {@link LivingEntity}
|
||||
*
|
||||
* @author John000708
|
||||
@ -26,7 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
* @see NuclearReactor
|
||||
*
|
||||
*/
|
||||
public abstract class NetherStarReactor extends AReactor {
|
||||
public abstract class NetherStarReactor extends Reactor {
|
||||
|
||||
public NetherStarReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
@ -7,12 +7,11 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
* The {@link NuclearReactor} is an implementation of {@link AReactor} that uses
|
||||
* The {@link NuclearReactor} is an implementation of {@link Reactor} that uses
|
||||
* any {@link Radioactive} material to generate energy.
|
||||
* It needs water coolant as well as a steady supply of Reactor Coolant Cells
|
||||
*
|
||||
@ -21,7 +20,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
* @see NetherStarReactor
|
||||
*
|
||||
*/
|
||||
public abstract class NuclearReactor extends AReactor {
|
||||
public abstract class NuclearReactor extends Reactor {
|
||||
|
||||
public NuclearReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -16,10 +17,10 @@ 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.events.ReactorExplodeEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.holograms.ReactorHologram;
|
||||
@ -29,6 +30,8 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
@ -39,7 +42,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
/**
|
||||
* The abstract {@link AReactor} class is very similar to {@link AGenerator} but is
|
||||
* The abstract {@link Reactor} class is very similar to {@link AGenerator} but is
|
||||
* exclusively used for Reactors.
|
||||
*
|
||||
* @author John000708
|
||||
@ -51,11 +54,12 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
* @see NetherStarReactor
|
||||
*
|
||||
*/
|
||||
public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
public abstract class Reactor extends AbstractEnergyProvider {
|
||||
|
||||
public static Map<Location, MachineFuel> processing = new HashMap<>();
|
||||
public static Map<Location, Integer> progress = new HashMap<>();
|
||||
|
||||
private static final String MODE = "reactor-mode";
|
||||
private static final int INFO_SLOT = 49;
|
||||
private static final int COOLANT_DURATION = 50;
|
||||
private static final BlockFace[] WATER_BLOCKS = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
|
||||
@ -68,7 +72,7 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
// No coolant border
|
||||
private static final int[] border_4 = { 25, 34, 43 };
|
||||
|
||||
public AReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
new BlockMenuPreset(getID(), getInventoryTitle()) {
|
||||
@ -80,14 +84,14 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
|
||||
@Override
|
||||
public void newInstance(BlockMenu menu, Block b) {
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode") == null) {
|
||||
BlockStorage.addBlockInfo(b, "reactor-mode", "generator");
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), MODE) == null) {
|
||||
BlockStorage.addBlockInfo(b, MODE, ReactorMode.GENERATOR.toString());
|
||||
}
|
||||
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode").equals("generator")) {
|
||||
menu.replaceExistingItem(4, new CustomItem(SlimefunUtils.getCustomHead("9343ce58da54c79924a2c9331cfc417fe8ccbbea9be45a7ac85860a6c730"), "&7Focus: &eElectricity", "", "&6Your Reactor will focus on Power Generation", "&6If your Energy Network doesn't need Power", "&6it will not produce any either", "", "&7> Click to change the Focus to &eProduction"));
|
||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), MODE).equals(ReactorMode.GENERATOR.toString())) {
|
||||
menu.replaceExistingItem(4, new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&7Focus: &eElectricity", "", "&6Your Reactor will focus on Power Generation", "&6If your Energy Network doesn't need Power", "&6it will not produce any either", "", "&7> Click to change the Focus to &eProduction"));
|
||||
menu.addMenuClickHandler(4, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "reactor-mode", "production");
|
||||
BlockStorage.addBlockInfo(b, MODE, ReactorMode.PRODUCTION.toString());
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
});
|
||||
@ -95,7 +99,7 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
else {
|
||||
menu.replaceExistingItem(4, new CustomItem(SlimefunItems.PLUTONIUM, "&7Focus: &eProduction", "", "&6Your Reactor will focus on producing goods", "&6If your Energy Network doesn't need Power", "&6it will continue to run and simply will", "&6not generate any Power in the mean time", "", "&7> Click to change the Focus to &ePower Generation"));
|
||||
menu.addMenuClickHandler(4, (p, slot, item, action) -> {
|
||||
BlockStorage.addBlockInfo(b, "reactor-mode", "generator");
|
||||
BlockStorage.addBlockInfo(b, MODE, ReactorMode.GENERATOR.toString());
|
||||
newInstance(menu, b);
|
||||
return false;
|
||||
});
|
||||
@ -203,10 +207,10 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
public abstract void extraTick(Location l);
|
||||
|
||||
/**
|
||||
* This method returns the {@link ItemStack} that is required to cool this {@link AReactor}.
|
||||
* This method returns the {@link ItemStack} that is required to cool this {@link Reactor}.
|
||||
* If it returns null, then no cooling is required.
|
||||
*
|
||||
* @return The {@link ItemStack} required to cool this {@link AReactor}
|
||||
* @return The {@link ItemStack} required to cool this {@link Reactor}
|
||||
*/
|
||||
public abstract ItemStack getCoolant();
|
||||
|
||||
@ -215,16 +219,16 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
* It should reflect the {@link ItemStack} used to power the reactor.
|
||||
* This method does <b>not</b> determine the fuel input, only the icon.
|
||||
*
|
||||
* @return The {@link ItemStack} used as the fuel icon for this {@link AReactor}.
|
||||
* @return The {@link ItemStack} used as the fuel icon for this {@link Reactor}.
|
||||
*/
|
||||
public abstract ItemStack getFuelIcon();
|
||||
|
||||
/**
|
||||
* This method returns whether this {@link AReactor} requires as some form of
|
||||
* This method returns whether this {@link Reactor} requires as some form of
|
||||
* coolant.
|
||||
* It is a not-null check performed on {@link #getCoolant()}
|
||||
*
|
||||
* @return Whether this {@link AReactor} requires cooling
|
||||
* @return Whether this {@link Reactor} requires cooling
|
||||
*/
|
||||
protected final boolean needsCooling() {
|
||||
return getCoolant() != null;
|
||||
@ -276,13 +280,13 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
int produced = getEnergyProduction();
|
||||
int space = ChargableBlock.getMaxCharge(l) - charge;
|
||||
|
||||
if (space >= produced || !"generator".equals(BlockStorage.getLocationInfo(l, "reactor-mode"))) {
|
||||
if (space >= produced || !ReactorMode.GENERATOR.toString().equals(BlockStorage.getLocationInfo(l, MODE))) {
|
||||
progress.put(l, timeleft - 1);
|
||||
checkForWaterBlocks(l);
|
||||
|
||||
ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(l).getTicks(), getProgressBar());
|
||||
|
||||
if (needsCooling() && !hasSufficientCoolant(l, inv, accessPort, timeleft)) {
|
||||
if (needsCooling() && !hasEnoughCoolant(l, inv, accessPort, timeleft)) {
|
||||
explosionsQueue.add(l);
|
||||
return 0;
|
||||
}
|
||||
@ -313,6 +317,9 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
|
||||
if (explosion) {
|
||||
Slimefun.runSync(() -> {
|
||||
ReactorExplodeEvent event = new ReactorExplodeEvent(l, Reactor.this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
BlockStorage.getInventory(l).close();
|
||||
SimpleHologram.remove(l.getBlock());
|
||||
});
|
||||
@ -377,23 +384,23 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cools the given {@link AReactor}.
|
||||
* This method cools the given {@link Reactor}.
|
||||
*
|
||||
* @param reactor
|
||||
* The {@link Location} of this {@link AReactor}
|
||||
* The {@link Location} of this {@link Reactor}
|
||||
* @param menu
|
||||
* The {@link Inventory} of this {@link AReactor}
|
||||
* The {@link Inventory} of this {@link Reactor}
|
||||
* @param accessPort
|
||||
* The {@link ReactorAccessPort}, if available
|
||||
* @param timeleft
|
||||
* The time left
|
||||
*
|
||||
* @return Whether the {@link AReactor} was successfully cooled, if not it should explode
|
||||
* @return Whether the {@link Reactor} was successfully cooled, if not it should explode
|
||||
*/
|
||||
private boolean hasSufficientCoolant(Location reactor, BlockMenu menu, BlockMenu accessPort, int timeleft) {
|
||||
boolean coolant = (processing.get(reactor).getTicks() - timeleft) % COOLANT_DURATION == 0;
|
||||
private boolean hasEnoughCoolant(Location reactor, BlockMenu menu, BlockMenu accessPort, int timeleft) {
|
||||
boolean requiresCoolant = (processing.get(reactor).getTicks() - timeleft) % COOLANT_DURATION == 0;
|
||||
|
||||
if (coolant) {
|
||||
if (requiresCoolant) {
|
||||
if (accessPort != null) {
|
||||
for (int slot : getCoolantSlots()) {
|
||||
if (SlimefunUtils.isItemSimilar(accessPort.getItemInSlot(slot), getCoolant(), true)) {
|
||||
@ -451,7 +458,7 @@ public abstract class AReactor extends AbstractEnergyGenerator {
|
||||
protected BlockMenu getAccessPort(Location l) {
|
||||
Location portL = new Location(l.getWorld(), l.getX(), l.getY() + 3, l.getZ());
|
||||
|
||||
if (BlockStorage.check(portL, "REACTOR_ACCESS_PORT")) {
|
||||
if (BlockStorage.check(portL, SlimefunItems.REACTOR_ACCESS_PORT.getItemId())) {
|
||||
return BlockStorage.getInventory(portL);
|
||||
}
|
||||
else {
|
@ -0,0 +1,34 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* This enum holds the various modes a {@link Reactor} can operate as.
|
||||
* Each mode has a different focus of operation.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
public enum ReactorMode {
|
||||
|
||||
/**
|
||||
* If a {@link Reactor} is operation in production mode, the focus will
|
||||
* be set on the production of nuclear byproducts, such as Neptunium or Plutonium.
|
||||
* The key difference here is that a {@link Reactor} in production mode will still
|
||||
* continue to operate, even if the energy buffer is full.
|
||||
*/
|
||||
PRODUCTION,
|
||||
|
||||
/**
|
||||
* If a {@link Reactor} is operating in generator mode, the focus will be the
|
||||
* generation of power. If the energy buffer is full, the {@link Reactor} will
|
||||
* no longer consume fuel.
|
||||
*/
|
||||
GENERATOR;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* This package contains the different implementations of
|
||||
* {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor}.
|
||||
* {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor}.
|
||||
*/
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors;
|
@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
@ -30,7 +31,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
|
||||
public abstract class AGenerator extends AbstractEnergyGenerator {
|
||||
public abstract class AGenerator extends AbstractEnergyProvider {
|
||||
|
||||
public static Map<Location, MachineFuel> processing = new HashMap<>();
|
||||
public static Map<Location, Integer> progress = new HashMap<>();
|
||||
|
@ -46,6 +46,7 @@ import io.github.thebusybiscuit.slimefun4.core.services.plugins.ThirdPartyPlugin
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.VampireBlade;
|
||||
@ -90,7 +91,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||
@ -418,8 +418,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
AGenerator.processing = null;
|
||||
AGenerator.progress = null;
|
||||
|
||||
AReactor.processing = null;
|
||||
AReactor.progress = null;
|
||||
Reactor.processing = null;
|
||||
Reactor.progress = null;
|
||||
|
||||
instance = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user