1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Merge pull request #995 from dniym/ReactorFix

Reactor fix
This commit is contained in:
TheBusyBiscuit 2019-08-19 09:31:06 +02:00 committed by GitHub
commit 0a840ccea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 716 additions and 646 deletions

View File

@ -1,454 +1,475 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull; import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.SlimefunStartup;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.ReactorAccessPort; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.ReactorAccessPort;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker; import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import me.mrCookieSlime.Slimefun.holograms.ReactorHologram; import me.mrCookieSlime.Slimefun.holograms.ReactorHologram;
public abstract class AReactor extends SlimefunItem { public abstract class AReactor extends SlimefunItem {
public static Map<Location, MachineFuel> processing = new HashMap<Location, MachineFuel>(); public static Map<Location, MachineFuel> processing = new HashMap<Location, MachineFuel>();
public static Map<Location, Integer> progress = new HashMap<Location, Integer>(); public static Map<Location, Integer> progress = new HashMap<Location, Integer>();
private static final BlockFace[] cooling = private static final BlockFace[] cooling =
{ {
BlockFace.NORTH, BlockFace.NORTH,
BlockFace.NORTH_EAST, BlockFace.NORTH_EAST,
BlockFace.EAST, BlockFace.EAST,
BlockFace.SOUTH_EAST, BlockFace.SOUTH_EAST,
BlockFace.SOUTH, BlockFace.SOUTH,
BlockFace.SOUTH_WEST, BlockFace.SOUTH_WEST,
BlockFace.WEST, BlockFace.WEST,
BlockFace.NORTH_WEST BlockFace.NORTH_WEST
}; };
private Set<MachineFuel> recipes = new HashSet<MachineFuel>(); private Set<MachineFuel> recipes = new HashSet<MachineFuel>();
private static final int[] border = {0, 1, 2, 3, 5, 6, 7, 8, 12, 13, 14, 21, 23}; private static final int[] border = {0, 1, 2, 3, 5, 6, 7, 8, 12, 13, 14, 21, 23};
private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47}; private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47};
private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53}; private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53};
private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 49, 50}; private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 50};
private static final int[] border_4 = {25, 34, 43}; // No coolant border private static final int[] border_4 = {25, 34, 43}; // No coolant border
private static final int infoSlot = 49;
public AReactor(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, id, recipeType, recipe); public AReactor(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, id, recipeType, recipe);
new BlockMenuPreset(id, getInventoryTitle()) {
new BlockMenuPreset(id, getInventoryTitle()) {
@Override
public void init() { @Override
constructMenu(this); public void init() {
} constructMenu(this);
}
@Override
public void newInstance(final BlockMenu menu, final Block b) { @Override
try { public void newInstance(final BlockMenu menu, final Block b) {
if (BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode") == null){ try {
BlockStorage.addBlockInfo(b, "reactor-mode", "generator"); if (BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode") == null){
} BlockStorage.addBlockInfo(b, "reactor-mode", "generator");
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "reactor-mode").equals("generator")) { }
menu.replaceExistingItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&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(), "reactor-mode").equals("generator")) {
menu.addMenuClickHandler(4, (p, slot, item, action) -> { menu.replaceExistingItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&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"));
BlockStorage.addBlockInfo(b, "reactor-mode", "production"); menu.addMenuClickHandler(4, (p, slot, item, action) -> {
newInstance(menu, b); BlockStorage.addBlockInfo(b, "reactor-mode", "production");
return false; newInstance(menu, b);
}); return false;
} });
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")); else {
menu.addMenuClickHandler(4, (p, slot, item, action) -> { 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"));
BlockStorage.addBlockInfo(b, "reactor-mode", "generator"); menu.addMenuClickHandler(4, (p, slot, item, action) -> {
newInstance(menu, b); BlockStorage.addBlockInfo(b, "reactor-mode", "generator");
return false; newInstance(menu, b);
}); return false;
} });
} catch(Exception x) { }
} BlockMenu ap = getAccessPort(b.getLocation());
} if(ap != null) {
menu.replaceExistingItem(infoSlot, new CustomItem(new ItemStack(Material.GREEN_WOOL), "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port"));
@Override menu.addMenuClickHandler(infoSlot, (p, slot, item, action) -> {
public boolean canOpen(Block b, Player p) { ap.open(p);
return p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true); newInstance(menu, b);
}
return false;
@Override });
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { } else {
return new int[0]; menu.replaceExistingItem(infoSlot, new CustomItem(new ItemStack(Material.RED_WOOL), "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!"));
} menu.addMenuClickHandler(infoSlot, (p, slot, item, action) -> {
}; newInstance(menu, b);
menu.open(p);
registerBlockHandler(id, new SlimefunBlockHandler() { return false;
});
@Override }
public void onPlace(Player p, Block b, SlimefunItem item) {
} } catch(Exception x) {
}
@Override }
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { @Override
for (int slot : getFuelSlots()) { public boolean canOpen(Block b, Player p) {
if (inv.getItemInSlot(slot) != null) { return p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true);
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); }
inv.replaceExistingItem(slot, null);
} @Override
} public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
for (int slot : getCoolantSlots()) { return new int[0];
if (inv.getItemInSlot(slot) != null) { }
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); };
inv.replaceExistingItem(slot, null);
} registerBlockHandler(id, new SlimefunBlockHandler() {
}
for (int slot : getOutputSlots()) { @Override
if (inv.getItemInSlot(slot) != null) { public void onPlace(Player p, Block b, SlimefunItem item) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); }
inv.replaceExistingItem(slot, null);
} @Override
} public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
} BlockMenu inv = BlockStorage.getInventory(b);
progress.remove(b.getLocation()); if (inv != null) {
processing.remove(b.getLocation()); for (int slot : getFuelSlots()) {
ReactorHologram.remove(b.getLocation()); if (inv.getItemInSlot(slot) != null) {
return true; b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
} inv.replaceExistingItem(slot, null);
}); }
}
this.registerDefaultRecipes(); for (int slot : getCoolantSlots()) {
} if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
private void constructMenu(BlockMenuPreset preset) { inv.replaceExistingItem(slot, null);
for (int i : border) { }
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), }
(p, slot, item, action) -> false for (int slot : getOutputSlots()) {
); if (inv.getItemInSlot(slot) != null) {
} b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
for (int i : border_1) { }
preset.addItem(i, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), " "), }
(p, slot, item, action) -> false }
); progress.remove(b.getLocation());
} processing.remove(b.getLocation());
ReactorHologram.remove(b.getLocation());
for (int i : border_3) { return true;
preset.addItem(i, new CustomItem(new ItemStack(Material.GREEN_STAINED_GLASS_PANE), " "), }
(p, slot, item, action) -> false });
);
} this.registerDefaultRecipes();
}
preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
(p, slot, item, action) -> false private void constructMenu(BlockMenuPreset preset) {
); for (int i : border) {
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), (p, slot, item, action) -> false
(p, slot, item, action) -> false );
); }
for (int i : border_2) { for (int i : border_1) {
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), preset.addItem(i, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), " "),
(p, slot, item, action) -> false (p, slot, item, action) -> false
); );
} }
if (needsCooling()) { for (int i : border_3) {
preset.addItem(7, new CustomItem(this.getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); preset.addItem(i, new CustomItem(new ItemStack(Material.GREEN_STAINED_GLASS_PANE), " "),
} (p, slot, item, action) -> false
else { );
preset.addItem(7, new CustomItem(new ItemStack(Material.BARRIER), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells")); }
for (int i : border_4) { preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "),
preset.addItem(i, new CustomItem(new ItemStack(Material.BARRIER), "&cNo Coolant Required"), (p, slot, item, action) -> false
(p, slot, item, action) -> false );
);
} preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"),
} (p, slot, item, action) -> false
} );
public abstract String getInventoryTitle(); for (int i : border_2) {
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
public abstract void registerDefaultRecipes(); (p, slot, item, action) -> false
);
public abstract int getEnergyProduction(); }
public abstract void extraTick(Location l); if (needsCooling()) {
preset.addItem(7, new CustomItem(this.getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"));
public abstract ItemStack getCoolant(); }
else {
public boolean needsCooling() { preset.addItem(7, new CustomItem(new ItemStack(Material.BARRIER), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells"));
return getCoolant() != null;
} for (int i : border_4) {
preset.addItem(i, new CustomItem(new ItemStack(Material.BARRIER), "&cNo Coolant Required"),
public int[] getInputSlots() { (p, slot, item, action) -> false
return new int[] {19, 28, 37, 25, 34, 43}; );
} }
}
public int[] getFuelSlots() { }
return new int[] {19, 28, 37};
} public abstract String getInventoryTitle();
public int[] getCoolantSlots() { public abstract void registerDefaultRecipes();
return needsCooling() ? new int[] {25, 34, 43} : new int[]{};
} public abstract int getEnergyProduction();
public int[] getOutputSlots() { public abstract void extraTick(Location l);
return new int[] {40};
} public abstract ItemStack getCoolant();
public MachineFuel getProcessing(Location l) { public boolean needsCooling() {
return processing.get(l); return getCoolant() != null;
} }
public boolean isProcessing(Location l) { public int[] getInputSlots() {
return progress.containsKey(l); return new int[] {19, 28, 37, 25, 34, 43};
} }
public void registerFuel(MachineFuel fuel) { public int[] getFuelSlots() {
this.recipes.add(fuel); return new int[] {19, 28, 37};
} }
@Override public int[] getCoolantSlots() {
public void register(boolean slimefun) { return needsCooling() ? new int[] {25, 34, 43} : new int[]{};
addItemHandler(new EnergyTicker() { }
Set<Location> explode = new HashSet<Location>(); public int[] getOutputSlots() {
return new int[] {40};
@Override }
public double generateEnergy(final Location l, SlimefunItem sf, Config data) {
BlockMenu port = getAccessPort(l); public MachineFuel getProcessing(Location l) {
return processing.get(l);
if (isProcessing(l)) { }
extraTick(l);
int timeleft = progress.get(l); public boolean isProcessing(Location l) {
if (timeleft > 0) { return progress.containsKey(l);
int produced = getEnergyProduction(); }
int space = ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l);
if (space >= produced) { public void registerFuel(MachineFuel fuel) {
ChargableBlock.addCharge(l, getEnergyProduction()); this.recipes.add(fuel);
space -= produced; }
}
if (space >= produced || !BlockStorage.getLocationInfo(l, "reactor-mode").equals("generator")) { @Override
progress.put(l, timeleft - 1); public void register(boolean slimefun) {
addItemHandler(new EnergyTicker() {
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
if (!l.getBlock().getRelative(cooling[CSCoreLib.randomizer().nextInt(cooling.length)]).isLiquid()) explode.add(l); Set<Location> explode = new HashSet<Location>();
});
@Override
ItemStack item = getProgressBar().clone(); public double generateEnergy(final Location l, SlimefunItem sf, Config data) {
ItemMeta im = item.getItemMeta(); BlockMenu port = getAccessPort(l);
im.setDisplayName(" ");
List<String> lore = new ArrayList<String>(); if (isProcessing(l)) {
lore.add(MachineHelper.getProgress(timeleft, processing.get(l).getTicks())); extraTick(l);
lore.add(MachineHelper.getCoolant(timeleft, processing.get(l).getTicks())); int timeleft = progress.get(l);
lore.add(""); if (timeleft > 0) {
lore.add(MachineHelper.getTimeLeft(timeleft / 2)); int produced = getEnergyProduction();
im.setLore(lore); int space = ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l);
item.setItemMeta(im); if (space >= produced) {
ChargableBlock.addCharge(l, getEnergyProduction());
BlockStorage.getInventory(l).replaceExistingItem(22, item); space -= produced;
}
if (needsCooling()) { if (space >= produced || !BlockStorage.getLocationInfo(l, "reactor-mode").equals("generator")) {
boolean coolant = (processing.get(l).getTicks() - timeleft) % 25 == 0; progress.put(l, timeleft - 1);
if (coolant) { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
if (port != null) { if (!l.getBlock().getRelative(cooling[CSCoreLib.randomizer().nextInt(cooling.length)]).isLiquid()) explode.add(l);
for (int slot: getCoolantSlots()) { });
if (SlimefunManager.isItemSimiliar(port.getItemInSlot(slot), getCoolant(), true)) {
port.replaceExistingItem(slot, pushItems(l, port.getItemInSlot(slot), getCoolantSlots())); ItemStack item = getProgressBar().clone();
} ItemMeta im = item.getItemMeta();
} im.setDisplayName(" ");
} List<String> lore = new ArrayList<String>();
lore.add(MachineHelper.getProgress(timeleft, processing.get(l).getTicks()));
boolean explosion = true; lore.add(MachineHelper.getCoolant(timeleft, processing.get(l).getTicks()));
for (int slot: getCoolantSlots()) { lore.add("");
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(l).getItemInSlot(slot), getCoolant(), true)) { lore.add(MachineHelper.getTimeLeft(timeleft / 2));
BlockStorage.getInventory(l).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(l).getItemInSlot(slot), 1)); im.setLore(lore);
ReactorHologram.update(l, "&b\u2744 &7100%"); item.setItemMeta(im);
explosion = false;
break; BlockStorage.getInventory(l).replaceExistingItem(22, item);
}
} if (needsCooling()) {
boolean coolant = (processing.get(l).getTicks() - timeleft) % 25 == 0;
if (explosion) {
explode.add(l); if (coolant) {
return 0; if (port != null) {
} for (int slot: getCoolantSlots()) {
} if (SlimefunManager.isItemSimiliar(port.getItemInSlot(slot), getCoolant(), true)) {
else { port.replaceExistingItem(slot, pushItems(l, port.getItemInSlot(slot), getCoolantSlots()));
ReactorHologram.update(l, "&b\u2744 &7" + MachineHelper.getPercentage(timeleft, processing.get(l).getTicks()) + "%"); }
} }
} }
return ChargableBlock.getCharge(l); boolean explosion = true;
} for (int slot: getCoolantSlots()) {
return 0; if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(l).getItemInSlot(slot), getCoolant(), true)) {
} BlockStorage.getInventory(l).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(l).getItemInSlot(slot), 1));
else { ReactorHologram.update(l, "&b\u2744 &7100%");
BlockStorage.getInventory(l).replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); explosion = false;
if (processing.get(l).getOutput() != null) pushItems(l, processing.get(l).getOutput()); break;
}
if (port != null) { }
for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(l).getItemInSlot(slot) != null) BlockStorage.getInventory(l).replaceExistingItem(slot, ReactorAccessPort.pushItems(port.getLocation(), BlockStorage.getInventory(l).getItemInSlot(slot))); if (explosion) {
} explode.add(l);
} return 0;
}
progress.remove(l); }
processing.remove(l); else {
return 0; ReactorHologram.update(l, "&b\u2744 &7" + MachineHelper.getPercentage(timeleft, processing.get(l).getTicks()) + "%");
} }
} }
else {
MachineFuel r = null; return ChargableBlock.getCharge(l);
Map<Integer, Integer> found = new HashMap<Integer, Integer>(); }
return 0;
if (port != null) { }
refill: else {
for (int slot: getFuelSlots()) { BlockStorage.getInventory(l).replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
for (MachineFuel recipe: recipes) { if (processing.get(l).getOutput() != null) pushItems(l, processing.get(l).getOutput());
if (SlimefunManager.isItemSimiliar(port.getItemInSlot(slot), recipe.getInput(), true)) {
if (pushItems(l, new CustomItem(port.getItemInSlot(slot), 1), getFuelSlots()) == null) { if (port != null) {
port.replaceExistingItem(slot, InvUtils.decreaseItem(port.getItemInSlot(slot), 1)); for (int slot: getOutputSlots()) {
break refill; if (BlockStorage.getInventory(l).getItemInSlot(slot) != null) BlockStorage.getInventory(l).replaceExistingItem(slot, ReactorAccessPort.pushItems(port.getLocation(), BlockStorage.getInventory(l).getItemInSlot(slot)));
} }
} }
}
} progress.remove(l);
} processing.remove(l);
return 0;
outer: }
for (MachineFuel recipe: recipes) { }
for (int slot: getFuelSlots()) { else {
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(l).getItemInSlot(slot), recipe.getInput(), true)) { MachineFuel r = null;
found.put(slot, recipe.getInput().getAmount()); Map<Integer, Integer> found = new HashMap<Integer, Integer>();
r = recipe;
break outer; if (port != null) {
} refill:
} for (int slot: getFuelSlots()) {
} for (MachineFuel recipe: recipes) {
if (SlimefunManager.isItemSimiliar(port.getItemInSlot(slot), recipe.getInput(), true)) {
if (r != null) { if (pushItems(l, new CustomItem(port.getItemInSlot(slot), 1), getFuelSlots()) == null) {
for (Map.Entry<Integer, Integer> entry: found.entrySet()) { port.replaceExistingItem(slot, InvUtils.decreaseItem(port.getItemInSlot(slot), 1));
BlockStorage.getInventory(l).replaceExistingItem(entry.getKey(), InvUtils.decreaseItem(BlockStorage.getInventory(l).getItemInSlot(entry.getKey()), entry.getValue())); break refill;
} }
processing.put(l, r); }
progress.put(l, r.getTicks()); }
} }
return 0; }
}
} outer:
for (MachineFuel recipe: recipes) {
@Override for (int slot: getFuelSlots()) {
public boolean explode(final Location l) { if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(l).getItemInSlot(slot), recipe.getInput(), true)) {
final boolean explosion = explode.contains(l); found.put(slot, recipe.getInput().getAmount());
if (explosion) { r = recipe;
BlockStorage.getInventory(l).close(); break outer;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> { }
ReactorHologram.remove(l); }
}, 0);
if (r != null) {
explode.remove(l); for (Map.Entry<Integer, Integer> entry: found.entrySet()) {
processing.remove(l); BlockStorage.getInventory(l).replaceExistingItem(entry.getKey(), InvUtils.decreaseItem(BlockStorage.getInventory(l).getItemInSlot(entry.getKey()), entry.getValue()));
progress.remove(l); }
} processing.put(l, r);
return explosion; progress.put(l, r.getTicks());
} }
}); return 0;
}
super.register(slimefun); }
}
@Override
private Inventory inject(Location l) { public boolean explode(final Location l) {
int size = BlockStorage.getInventory(l).toInventory().getSize(); final boolean explosion = explode.contains(l);
Inventory inv = Bukkit.createInventory(null, size); if (explosion) {
for (int i = 0; i < size; i++) { BlockStorage.getInventory(l).close();
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US"));
} Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
for (int slot : getOutputSlots()) { ReactorHologram.remove(l);
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot)); }, 0);
}
return inv; explode.remove(l);
} processing.remove(l);
progress.remove(l);
private Inventory inject(Location l, int[] slots) { }
int size = BlockStorage.getInventory(l).toInventory().getSize(); return explosion;
Inventory inv = Bukkit.createInventory(null, size); }
for (int i = 0; i < size; i++) { });
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US"));
} super.register(slimefun);
for (int slot : slots) { }
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
} private Inventory inject(Location l) {
return inv; int size = BlockStorage.getInventory(l).toInventory().getSize();
} Inventory inv = Bukkit.createInventory(null, size);
for (int i = 0; i < size; i++) {
public void pushItems(Location l, ItemStack item) { inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US"));
Inventory inv = inject(l); }
inv.addItem(item); for (int slot : getOutputSlots()) {
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
for (int slot: getOutputSlots()) { }
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot)); return inv;
} }
}
private Inventory inject(Location l, int[] slots) {
public ItemStack pushItems(Location l, ItemStack item, int[] slots) { int size = BlockStorage.getInventory(l).toInventory().getSize();
Inventory inv = inject(l, slots); Inventory inv = Bukkit.createInventory(null, size);
Map<Integer, ItemStack> map = inv.addItem(item); for (int i = 0; i < size; i++) {
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US"));
for (int slot : slots) { }
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot)); for (int slot : slots) {
} inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
}
for (Map.Entry<Integer, ItemStack> entry : map.entrySet()) { return inv;
return entry.getValue(); }
}
public void pushItems(Location l, ItemStack item) {
return null; Inventory inv = inject(l);
} inv.addItem(item);
public abstract ItemStack getProgressBar(); for (int slot: getOutputSlots()) {
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
public Set<MachineFuel> getFuelTypes() { }
return this.recipes; }
}
public ItemStack pushItems(Location l, ItemStack item, int[] slots) {
public BlockMenu getAccessPort(Location l) { Inventory inv = inject(l, slots);
Location portL = new Location(l.getWorld(), l.getX(), l.getY() + 3, l.getZ()); Map<Integer, ItemStack> map = inv.addItem(item);
if (BlockStorage.check(portL, "REACTOR_ACCESS_PORT")) return BlockStorage.getInventory(portL);
return null; for (int slot : slots) {
} BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
}
}
for (Map.Entry<Integer, ItemStack> entry : map.entrySet()) {
return entry.getValue();
}
return null;
}
public abstract ItemStack getProgressBar();
public Set<MachineFuel> getFuelTypes() {
return this.recipes;
}
public BlockMenu getAccessPort(Location l) {
Location portL = new Location(l.getWorld(), l.getX(), l.getY() + 3, l.getZ());
if (BlockStorage.check(portL, "REACTOR_ACCESS_PORT")) return BlockStorage.getInventory(portL);
return null;
}
}

View File

@ -1,192 +1,241 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
public class ReactorAccessPort extends SlimefunItem {
public class ReactorAccessPort extends SlimefunItem {
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 21, 23};
private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47}; private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 21, 23};
private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53}; private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47};
private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 49, 50}; private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53};
private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 49, 50};
public ReactorAccessPort(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, name, recipeType, recipe); public ReactorAccessPort(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, name, recipeType, recipe);
new BlockMenuPreset(name, getInventoryTitle()) {
new BlockMenuPreset(name, getInventoryTitle()) {
@Override
public void init() { @Override
constructMenu(this); public void init() {
} constructMenu(this);
}
@Override
public void newInstance(BlockMenu menu, Block b) { @Override
} public void newInstance(BlockMenu menu, Block b) {
}
@Override
public boolean canOpen(Block b, Player p) { @Override
return p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true); public boolean canOpen(Block b, Player p) {
} if(p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(),b,true)) {
return false;
@Override }
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
if (flow.equals(ItemTransportFlow.INSERT)) return getInputSlots();
else return getOutputSlots(); AReactor reactor = getReactor(b.getLocation());
} if(reactor != null) {
boolean empty = true;
@Override BlockMenu bm = getReactorMenu(b.getLocation());
public int[] getSlotsAccessedByItemTransport(BlockMenu menu, ItemTransportFlow flow, ItemStack item) { if(bm != null) {
if (flow.equals(ItemTransportFlow.INSERT)) { for(int slot:reactor.getCoolantSlots())
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.REACTOR_COOLANT_CELL, true)) return getCoolantSlots(); if(bm.getItemInSlot(slot) != null)
else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.NETHER_ICE_COOLANT_CELL, true)) return getCoolantSlots(); empty = false;
else return getFuelSlots(); for(int slot:reactor.getFuelSlots())
} if(bm.getItemInSlot(slot) != null)
else return getOutputSlots(); empty = false;
}
}; if(!empty || !p.isSneaking()) {
//reactor is not empty, lets view it's inventory instead.
registerBlockHandler(name, new SlimefunBlockHandler() { bm.open(p);
return false;
@Override }
public void onPlace(Player p, Block b, SlimefunItem item) { }
}
@Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { }
BlockMenu inv = BlockStorage.getInventory(b); return p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true);
if (inv != null) { }
for (int slot : getFuelSlots()) {
if (inv.getItemInSlot(slot) != null) { @Override
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
inv.replaceExistingItem(slot, null); if (flow.equals(ItemTransportFlow.INSERT)) return getInputSlots();
} else return getOutputSlots();
} }
for (int slot : getCoolantSlots()) {
if (inv.getItemInSlot(slot) != null) { @Override
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); public int[] getSlotsAccessedByItemTransport(BlockMenu menu, ItemTransportFlow flow, ItemStack item) {
inv.replaceExistingItem(slot, null); if (flow.equals(ItemTransportFlow.INSERT)) {
} if (SlimefunManager.isItemSimiliar(item, SlimefunItems.REACTOR_COOLANT_CELL, true)) return getCoolantSlots();
} else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.NETHER_ICE_COOLANT_CELL, true)) return getCoolantSlots();
for (int slot : getOutputSlots()) { else return getFuelSlots();
if (inv.getItemInSlot(slot) != null) { }
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); else return getOutputSlots();
inv.replaceExistingItem(slot, null); }
} };
}
} registerBlockHandler(name, new SlimefunBlockHandler() {
return true;
} @Override
}); public void onPlace(Player p, Block b, SlimefunItem item) {
} }
private void constructMenu(BlockMenuPreset preset) { @Override
for (int i : border) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), BlockMenu inv = BlockStorage.getInventory(b);
(p, slot, item, action) -> false if (inv != null) {
); for (int slot : getFuelSlots()) {
} if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
for (int i : border_1) { inv.replaceExistingItem(slot, null);
preset.addItem(i, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), " "), }
(p, slot, item, action) -> false }
); for (int slot : getCoolantSlots()) {
} if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
for (int i : border_2) { inv.replaceExistingItem(slot, null);
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), }
(p, slot, item, action) -> false }
); for (int slot : getOutputSlots()) {
} if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
for (int i : border_3) { inv.replaceExistingItem(slot, null);
preset.addItem(i, new CustomItem(new ItemStack(Material.GREEN_STAINED_GLASS_PANE), " "), }
(p, slot, item, action) -> false }
); }
} return true;
}
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), });
(p, slot, item, action) -> false }
);
private void constructMenu(BlockMenuPreset preset) {
preset.addItem(22, new CustomItem(SlimefunItems.PLUTONIUM, "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"), for (int i : border) {
(p, slot, item, action) -> false preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
); (p, slot, item, action) -> false
);
preset.addItem(7, new CustomItem(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"), }
(p, slot, item, action) -> false
); for (int i : border_1) {
preset.addItem(i, new CustomItem(new ItemStack(Material.LIME_STAINED_GLASS_PANE), " "),
preset.addItem(7, new CustomItem(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"), (p, slot, item, action) -> false
(p, slot, item, action) -> false );
); }
}
for (int i : border_2) {
public String getInventoryTitle() { preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
return "&2Reactor Access Port"; (p, slot, item, action) -> false
} );
}
public int[] getInputSlots() {
return new int[] {19, 28, 37, 25, 34, 43}; for (int i : border_3) {
} preset.addItem(i, new CustomItem(new ItemStack(Material.GREEN_STAINED_GLASS_PANE), " "),
(p, slot, item, action) -> false
public int[] getFuelSlots() { );
return new int[] {19, 28, 37}; }
}
preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"),
public int[] getCoolantSlots() { (p, slot, item, action) -> false
return new int[] {25, 34, 43}; );
}
preset.addItem(22, new CustomItem(SlimefunItems.PLUTONIUM, "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"),
public static int[] getOutputSlots() { (p, slot, item, action) -> false
return new int[] {40}; );
}
preset.addItem(7, new CustomItem(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"),
private static Inventory inject(Location l) { (p, slot, item, action) -> false
int size = BlockStorage.getInventory(l).toInventory().getSize(); );
Inventory inv = Bukkit.createInventory(null, size);
for (int i = 0; i < size; i++) { preset.addItem(7, new CustomItem(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"),
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US")); (p, slot, item, action) -> false
} );
for (int slot : getOutputSlots()) { }
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
} public String getInventoryTitle() {
return inv; return "&2Reactor Access Port";
} }
public static ItemStack pushItems(Location l, ItemStack item) { public int[] getInputSlots() {
Inventory inv = inject(l); return new int[] {19, 28, 37, 25, 34, 43};
Map<Integer, ItemStack> map = inv.addItem(item); }
for (int slot: getOutputSlots()) { public int[] getFuelSlots() {
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot)); return new int[] {19, 28, 37};
} }
for (Map.Entry<Integer, ItemStack> entry: map.entrySet()) { public int[] getCoolantSlots() {
return entry.getValue(); return new int[] {25, 34, 43};
} }
return null;
} public static int[] getOutputSlots() {
return new int[] {40};
} }
public AReactor getReactor(Location l) {
Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
SlimefunItem item = BlockStorage.check(reactorL.getBlock());
if(item instanceof AReactor)
return (AReactor) item;
return null;
}
public BlockMenu getReactorMenu(Location l) {
Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
String id = BlockStorage.checkID(reactorL);
if(id.equals("NUCLEAR_REACTOR") || id.equals("NETHERSTAR_REACTOR"))
return BlockStorage.getInventory(reactorL);
return null;
}
private static Inventory inject(Location l) {
int size = BlockStorage.getInventory(l).toInventory().getSize();
Inventory inv = Bukkit.createInventory(null, size);
for (int i = 0; i < size; i++) {
inv.setItem(i, new CustomItem(Material.COMMAND_BLOCK, " &4ALL YOUR PLACEHOLDERS ARE BELONG TO US"));
}
for (int slot : getOutputSlots()) {
inv.setItem(slot, BlockStorage.getInventory(l).getItemInSlot(slot));
}
return inv;
}
public static ItemStack pushItems(Location l, ItemStack item) {
Inventory inv = inject(l);
Map<Integer, ItemStack> map = inv.addItem(item);
for (int slot: getOutputSlots()) {
BlockStorage.getInventory(l).replaceExistingItem(slot, inv.getItem(slot));
}
for (Map.Entry<Integer, ItemStack> entry: map.entrySet()) {
return entry.getValue();
}
return null;
}
}