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

Merge branch 'master' into master

This commit is contained in:
LinoxGH 2020-08-31 20:34:15 +03:00 committed by GitHub
commit 6dba662d4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 234 additions and 291 deletions

74
.github/CODE_OF_CONDUCT.md vendored Normal file
View File

@ -0,0 +1,74 @@
# Slimefun4 - Code of Conduct
### What is a Code of Conduct?
> A code of conduct is a document that establishes expectations for behavior for your projects participants.
> Adopting, and enforcing, a code of conduct can help create a positive social atmosphere for your community.
<br>\- *Source: [https://opensource.guide](https://opensource.guide/code-of-conduct/#why-do-i-need-a-code-of-conduct)*
This document should serve the purpose of outlining the behaviour we expect from any participant of the project.
## Scope
This Code of Conduct applies to all sections of the [Slimefun4 GitHub repository](https://github.com/TheBusyBiscuit/Slimefun4), our [Slimefun GitHub organization](https://github.com/Slimefun) and all repositories owned by said organization.<br>
For our official Discord server, please refer to our article on [Discord Rules](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Discord-Rules).
Everyone who engages with this project on any of these repositories is expected to follow the Code of Conduct.<br>
This includes maintainers, contributors, sponsors and anyone who engages in the "Issues" section on GitHub.
## Engagement
This is an Open-Source project, anyone is welcome to engage and contribute!<br>
We generally expect users to engage in the Issues section by reporting bugs or commenting on bug reports to give additional context, help, guidance or to propose possible solutions and fixes.
Pull Requests are very much welcome and encouraged! They keep the project alive, so if you see an Issue and know how to fix it, feel free to create a Pull Request!
Issues that are considered "good first issues", indicated by the [good first issue](https://github.com/TheBusyBiscuit/Slimefun4/labels/good%20first%20issue) label, are generally expected to be beginner-friendly.
And even if you shouldn't know where to start or how to proceed, our [Discord Server](https://github.com/TheBusyBiscuit/Slimefun4#discord) and its community will be there for you!
When commenting, please keep in mind that this software is offered for **free**. Don't expect to receive lightning-fast replies 24 hours a day.
Everyone here works on this project in their free time and usually has work, school, university or family to take care of, so we appreciate patience and understanding.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include but are not limited to:
* Demonstrating empathy and kindness towards other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community
* Having patience and understanding for contributors, even if reply times are slow
<hr>
Examples of unacceptable behavior include but are not limited to:
* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Impatient, aggresive and toxic behaviour
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Enforcement Responsibilities
Our project maintainers are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
You can see a list of people who are recognized as "project maintainers" for Slimefun on the Slimefun GitHub organization:<br>
https://github.com/orgs/Slimefun/people
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders (labelled on Discord as "Admins" or "Moderators") responsible for enforcement on our [Discord Server](https://github.com/TheBusyBiscuit/Slimefun4#discord).
If you want your issue to be handled discreetly, message `TheBusyBiscuit#2610` or `Walshy#9709` privately on Discord and state your concerns.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Attribution
This Code of Conduct is a **modified version** of the original [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org),
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
The Contributor Covenant was created by Coraline Ada Ehmke in 2014 and is released under the [CC BY 4.0 License](https://github.com/ContributorCovenant/contributor_covenant/blob/release/LICENSE.md).

View File

@ -1,37 +0,0 @@
# Slimefun Community Guidelines
Slimefun is a community project, everyone is welcome to open Issues, make Pull Requests or make Pull Requests for an opened Issue.
Without your help, this project is going to die.
## General Guidelines
Rules for all types of posts:
1. Follow our Templates for Issues and Pull Request, they are designed to tell you what exact Information we need and how you should present it to us.
2. Be nice and give constructive critism. Insulting, Harassment, Racism, Sexism or any form of bullying or discrimination is not tolerated.
3. Try to engage in conversations by pointing out scenarios to replicate Issues, providing fix approaches or other kind of help.
4. Advertisement is inappropriate and will be removed, especially advertisement for Minecraft Servers is completely unaccepted.
## GitHub Issues
Rules for posting an Issue on GitHub:
1. This Issue Section is ONLY for Slimefun-related Issues, Issues about other Plugins or Slimefun Addons should not be posted here.
2. Please consult our [Troubleshooting Guide](https://github.com/TheBusyBiscuit/Slimefun4/wiki/How-to-report-bugs) before posting.
3. Check other Issues before posting to make sure you are not posting a duplicate.
4. Please do not put any Tags inside your title like [IMPORTANT], [URGENT] or [SUGGESTION]. Try to be professional by making your title as short as possible, we will assign it the required labels if necessary.
5. Do not post your Issue more than once, this is considered spam and does not benefit our community in any way. Do not repost your Issue if it was closed either, just leave a comment stating that the issue has still persisted and give more context on it.
6. Give us all available information right away, it may be a bit of time-wasting for us to keep asking for more Info. And this includes any Information to reproduce your Issue step-by-step.
7. Check whether there are newer versions available than the ones you are using, it might be that your Issue has been fixed already.
8. All text logs must be posted via a link to https://pastebin.com/ or similiar websites, long logs are very hard to read and get weirdly formatted when you post them on here. Using a proper pasting site allows us to keep things clean and easy to read.
Your Issue will be CLOSED WITHOUT WARNING if we think you violated these Rules.
## Pull Requests
Guidelines for making a Pull Request on GitHub:
1. Try to be reasonable with your additions. No, a Bacon flavoured unicorn that flies on a rainbow while dancing Gangnam Style is NOT a reasonable addition to this Project.
2. Try to make your values configurable in the config.yml / Items.yml or any additional file. This may not be necessary at every instance but it does give the end-users a way to customize their experience.
3. If your Pull Request is made in response to an Issue opened on GitHub, comment on that Issue and reference your Pull Request to show that you are proposing a fix for it.
4. Name your commits appropriately. Standards like "Add files via upload" or "Update Readme.md" are lame. Make sure that the commit message stands for it's changes. (e.g. "Fixed Furnaces duplicating Items")

View File

@ -93,6 +93,7 @@
* Fixed #2260 * Fixed #2260
* Fixed #2263 * Fixed #2263
* Fixed #2265 * Fixed #2265
* Fixed #2269
## Release Candidate 15 (01 Aug 2020) ## Release Candidate 15 (01 Aug 2020)

View File

@ -116,6 +116,7 @@ public class EnergyNet extends Network {
if (!regulator.equals(b.getLocation())) { if (!regulator.equals(b.getLocation())) {
SimpleHologram.update(b, "&4Multiple Energy Regulators connected"); SimpleHologram.update(b, "&4Multiple Energy Regulators connected");
SlimefunPlugin.getProfiler().closeEntry(b.getLocation(), SlimefunItems.ENERGY_REGULATOR.getItem(), timestamp.get());
return; return;
} }

View File

@ -23,9 +23,9 @@ import net.md_5.bungee.api.chat.hover.content.Text;
class PerformanceSummary { class PerformanceSummary {
// The threshold at which a Block or Chunk is significant enough to appear in /sf timings // The threshold at which a Block or Chunk is significant enough to appear in /sf timings
private static final int VISIBILITY_THRESHOLD = 300_000; private static final int VISIBILITY_THRESHOLD = 260_000;
private static final int MIN_ITEMS = 4; private static final int MIN_ITEMS = 6;
private static final int MAX_ITEMS = 12; private static final int MAX_ITEMS = 20;
private final SlimefunProfiler profiler; private final SlimefunProfiler profiler;
private final PerformanceRating rating; private final PerformanceRating rating;

View File

@ -77,27 +77,26 @@ abstract class AbstractCargoNode extends SlimefunItem {
protected void addChannelSelector(Block b, BlockMenu menu, int slotPrev, int slotCurrent, int slotNext) { protected void addChannelSelector(Block b, BlockMenu menu, int slotPrev, int slotCurrent, int slotNext) {
boolean isChestTerminalInstalled = SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled(); boolean isChestTerminalInstalled = SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled();
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY) == null) ? 0 : (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY))));
menu.replaceExistingItem(slotPrev, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CARGO_ARROW_LEFT.getTexture()), "&bPrevious Channel", "", "&e> Click to decrease the Channel ID by 1")); menu.replaceExistingItem(slotPrev, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CARGO_ARROW_LEFT.getTexture()), "&bPrevious Channel", "", "&e> Click to decrease the Channel ID by 1"));
menu.addMenuClickHandler(slotPrev, (p, slot, item, action) -> { menu.addMenuClickHandler(slotPrev, (p, slot, item, action) -> {
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) - 1; int newChannel = channel + 1;
if (channel < 0) { if (channel < 0) {
if (isChestTerminalInstalled) { if (isChestTerminalInstalled) {
channel = 16; newChannel = 16;
} }
else { else {
channel = 15; newChannel = 15;
} }
} }
BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channel)); BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(newChannel));
updateBlockMenu(menu, b); updateBlockMenu(menu, b);
return false; return false;
}); });
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY) == null) ? 0 : (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY))));
if (channel == 16) { if (channel == 16) {
menu.replaceExistingItem(slotCurrent, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CHEST_TERMINAL.getTexture()), "&bChannel ID: &3" + (channel + 1))); menu.replaceExistingItem(slotCurrent, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CHEST_TERMINAL.getTexture()), "&bChannel ID: &3" + (channel + 1)));
menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler());
@ -109,18 +108,18 @@ abstract class AbstractCargoNode extends SlimefunItem {
menu.replaceExistingItem(slotNext, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CARGO_ARROW_RIGHT.getTexture()), "&bNext Channel", "", "&e> Click to increase the Channel ID by 1")); menu.replaceExistingItem(slotNext, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.CARGO_ARROW_RIGHT.getTexture()), "&bNext Channel", "", "&e> Click to increase the Channel ID by 1"));
menu.addMenuClickHandler(slotNext, (p, slot, item, action) -> { menu.addMenuClickHandler(slotNext, (p, slot, item, action) -> {
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY)) + 1; int newChannel = channel + 1;
if (isChestTerminalInstalled) { if (isChestTerminalInstalled) {
if (channeln > 16) { if (newChannel > 16) {
channeln = 0; newChannel = 0;
} }
} }
else if (channeln > 15) { else if (newChannel > 15) {
channeln = 0; newChannel = 0;
} }
BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(channeln)); BlockStorage.addBlockInfo(b, FREQUENCY, String.valueOf(newChannel));
updateBlockMenu(menu, b); updateBlockMenu(menu, b);
return false; return false;
}); });

View File

@ -8,13 +8,26 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* The {@link SolarGenerator} is a simple {@link EnergyNetProvider} which generates energy if
* it has direct contact with sunlight.
*
* Some versions of the {@link SolarGenerator} will even generate energy at night, this is determined by
* {@link #getNightEnergy()}.
*
* @author TheBusyBiscuit
*
* @see EnergyNet
* @see EnergyNetProvider
*
*/
public class SolarGenerator extends SlimefunItem implements EnergyNetProvider { public class SolarGenerator extends SlimefunItem implements EnergyNetProvider {
private final int dayEnergy; private final int dayEnergy;
@ -47,11 +60,6 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider {
return nightEnergy; return nightEnergy;
} }
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.GENERATOR;
}
@Override @Override
public int getCapacity() { public int getCapacity() {
return 0; return 0;
@ -64,23 +72,20 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider {
if (world.getEnvironment() != Environment.NORMAL) { if (world.getEnvironment() != Environment.NORMAL) {
return 0; return 0;
} }
else {
boolean isDaytime = isDaytime(world); boolean isDaytime = isDaytime(world);
// Performance optimization for daytime-only solar generators // Performance optimization for daytime-only solar generators
if (!isDaytime && getNightEnergy() < 0.1) { if (!isDaytime && getNightEnergy() < 1) {
return 0; return 0;
} }
else if (!world.isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() < 15) {
if (!world.isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) {
return 0; return 0;
} }
else {
if (isDaytime) { return isDaytime ? getDayEnergy() : getNightEnergy();
return getDayEnergy(); }
} }
return getNightEnergy();
} }
/** /**
@ -93,7 +98,8 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider {
* @return Whether the given {@link World} has daytime and no active thunderstorm * @return Whether the given {@link World} has daytime and no active thunderstorm
*/ */
private boolean isDaytime(World world) { private boolean isDaytime(World world) {
return !world.hasStorm() && !world.isThundering() && (world.getTime() < 12300 || world.getTime() > 23850); long time = world.getTime();
return !world.hasStorm() && !world.isThundering() && (time < 12300 || time > 23850);
} }
@Override @Override

View File

@ -1,32 +1,34 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
/**
* The {@link AutoAnvil} is an electric machine which can repair any {@link ItemStack} using
* Duct tape.
*
* @author TheBusyBiscuit
*
*/
public abstract class AutoAnvil extends AContainer { public abstract class AutoAnvil extends AContainer {
public AutoAnvil(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { private final int repairFactor;
super(category, item, recipeType, recipe);
}
@Override public AutoAnvil(Category category, int repairFactor, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
public String getInventoryTitle() { super(category, item, recipeType, recipe);
return "Auto-Anvil";
this.repairFactor = repairFactor;
} }
@Override @Override
@ -44,61 +46,32 @@ public abstract class AutoAnvil extends AContainer {
return "AUTO_ANVIL"; return "AUTO_ANVIL";
} }
public abstract int getRepairFactor();
@Override @Override
protected void tick(Block b) { protected MachineRecipe findNextRecipe(BlockMenu menu) {
BlockMenu menu = BlockStorage.getInventory(b);
if (isProcessing(b)) {
int timeleft = progress.get(b);
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
if (getCharge(b.getLocation()) < getEnergyConsumption()) {
return;
}
removeCharge(b.getLocation(), getEnergyConsumption());
progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
progress.remove(b);
processing.remove(b);
}
}
else {
MachineRecipe recipe = null;
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1] : getInputSlots()[0]); ItemStack ductTape = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1] : getInputSlots()[0]);
ItemStack item = menu.getItemInSlot(slot); ItemStack item = menu.getItemInSlot(slot);
if (item != null && item.getType().getMaxDurability() > 0 && ((Damageable) item.getItemMeta()).getDamage() > 0) { if (item != null && item.getType().getMaxDurability() > 0 && ((Damageable) item.getItemMeta()).getDamage() > 0) {
if (SlimefunUtils.isItemSimilar(target, SlimefunItems.DUCT_TAPE, true)) { if (SlimefunUtils.isItemSimilar(ductTape, SlimefunItems.DUCT_TAPE, true, false)) {
ItemStack repaired = repair(item); ItemStack repairedItem = repair(item);
recipe = new MachineRecipe(30, new ItemStack[] { target, item }, new ItemStack[] { repaired });
if (!menu.fits(repairedItem, getOutputSlots())) {
return null;
}
for (int inputSlot : getInputSlots()) {
menu.consumeItem(inputSlot);
}
return new MachineRecipe(30, new ItemStack[] { ductTape, item }, new ItemStack[] { repairedItem });
} }
break; break;
} }
} }
if (recipe != null) { return null;
if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
for (int slot : getInputSlots()) {
menu.consumeItem(slot);
}
processing.put(b, recipe);
progress.put(b, recipe.getTicks());
}
}
} }
private ItemStack repair(ItemStack item) { private ItemStack repair(ItemStack item) {
@ -106,7 +79,8 @@ public abstract class AutoAnvil extends AContainer {
ItemMeta meta = repaired.getItemMeta(); ItemMeta meta = repaired.getItemMeta();
short maxDurability = item.getType().getMaxDurability(); short maxDurability = item.getType().getMaxDurability();
short durability = (short) (((Damageable) meta).getDamage() - (maxDurability / getRepairFactor())); int repairPercentage = 100 / repairFactor;
short durability = (short) (((Damageable) meta).getDamage() - (maxDurability / repairPercentage));
if (durability < 0) { if (durability < 0) {
durability = 0; durability = 0;

View File

@ -21,8 +21,11 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public abstract class GPSTransmitter extends SimpleSlimefunItem<BlockTicker> implements EnergyNetComponent { public abstract class GPSTransmitter extends SimpleSlimefunItem<BlockTicker> implements EnergyNetComponent {
public GPSTransmitter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { private final int capacity;
public GPSTransmitter(Category category, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
this.capacity = 4 << (2 * tier);
addItemHandler(onPlace()); addItemHandler(onPlace());
registerBlockHandler(getID(), (p, b, stack, reason) -> { registerBlockHandler(getID(), (p, b, stack, reason) -> {
@ -32,6 +35,11 @@ public abstract class GPSTransmitter extends SimpleSlimefunItem<BlockTicker> imp
}); });
} }
@Override
public int getCapacity() {
return capacity;
}
private BlockPlaceHandler onPlace() { private BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) { return new BlockPlaceHandler(false) {

View File

@ -1,46 +1,19 @@
package io.github.thebusybiscuit.slimefun4.implementation.resources; package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.bukkit.NamespacedKey;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class NetherIceResource implements GEOResource { class NetherIceResource extends SlimefunResource {
private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "nether_ice"); NetherIceResource() {
super("nether_ice", "Nether Ice", SlimefunItems.NETHER_ICE, 6, true);
}
@Override @Override
public int getDefaultSupply(Environment environment, Biome biome) { public int getDefaultSupply(Environment environment, Biome biome) {
return environment == Environment.NETHER ? 32 : 0; return environment == Environment.NETHER ? 32 : 0;
} }
@Override
public NamespacedKey getKey() {
return key;
}
@Override
public int getMaxDeviation() {
return 6;
}
@Override
public String getName() {
return "Nether Ice";
}
@Override
public ItemStack getItem() {
return SlimefunItems.NETHER_ICE.clone();
}
@Override
public boolean isObtainableFromGEOMiner() {
return true;
}
} }

View File

@ -1,17 +1,15 @@
package io.github.thebusybiscuit.slimefun4.implementation.resources; package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.bukkit.NamespacedKey;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class OilResource implements GEOResource { class OilResource extends SlimefunResource {
private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "oil"); OilResource() {
super("oil", "Oil", SlimefunItems.OIL_BUCKET, 8, false);
}
@Override @Override
public int getDefaultSupply(Environment environment, Biome biome) { public int getDefaultSupply(Environment environment, Biome biome) {
@ -74,29 +72,4 @@ class OilResource implements GEOResource {
} }
} }
@Override
public NamespacedKey getKey() {
return key;
}
@Override
public int getMaxDeviation() {
return 8;
}
@Override
public String getName() {
return "Oil";
}
@Override
public ItemStack getItem() {
return SlimefunItems.OIL_BUCKET.clone();
}
@Override
public boolean isObtainableFromGEOMiner() {
return false;
}
} }

View File

@ -1,17 +1,15 @@
package io.github.thebusybiscuit.slimefun4.implementation.resources; package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.bukkit.NamespacedKey;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class SaltResource implements GEOResource { class SaltResource extends SlimefunResource {
private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "salt"); SaltResource() {
super("salt", "Salt", SlimefunItems.SALT, 18, true);
}
@Override @Override
public int getDefaultSupply(Environment environment, Biome biome) { public int getDefaultSupply(Environment environment, Biome biome) {
@ -51,29 +49,4 @@ class SaltResource implements GEOResource {
} }
} }
@Override
public int getMaxDeviation() {
return 18;
}
@Override
public NamespacedKey getKey() {
return key;
}
@Override
public String getName() {
return "Salt";
}
@Override
public ItemStack getItem() {
return SlimefunItems.SALT.clone();
}
@Override
public boolean isObtainableFromGEOMiner() {
return true;
}
} }

View File

@ -0,0 +1,55 @@
package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.apache.commons.lang.Validate;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
abstract class SlimefunResource implements GEOResource {
private final NamespacedKey key;
private final String defaultName;
private final ItemStack item;
private final int maxDeviation;
private final boolean geoMiner;
SlimefunResource(String key, String defaultName, ItemStack item, int maxDeviation, boolean geoMiner) {
Validate.notNull(key, "NamespacedKey cannot be null!");
Validate.notNull(defaultName, "The default name cannot be null!");
Validate.notNull(item, "item cannot be null!");
this.key = new NamespacedKey(SlimefunPlugin.instance(), key);
this.defaultName = defaultName;
this.item = item;
this.maxDeviation = maxDeviation;
this.geoMiner = geoMiner;
}
@Override
public NamespacedKey getKey() {
return key;
}
@Override
public String getName() {
return defaultName;
}
@Override
public ItemStack getItem() {
return item.clone();
}
@Override
public int getMaxDeviation() {
return maxDeviation;
}
@Override
public boolean isObtainableFromGEOMiner() {
return geoMiner;
}
}

View File

@ -1,17 +1,15 @@
package io.github.thebusybiscuit.slimefun4.implementation.resources; package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.bukkit.NamespacedKey;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class UraniumResource implements GEOResource { class UraniumResource extends SlimefunResource {
private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "uranium"); UraniumResource() {
super("uranium", "Small Chunks of Uranium", SlimefunItems.SMALL_URANIUM, 2, true);
}
@Override @Override
public int getDefaultSupply(Environment envionment, Biome biome) { public int getDefaultSupply(Environment envionment, Biome biome) {
@ -22,29 +20,4 @@ class UraniumResource implements GEOResource {
return 0; return 0;
} }
@Override
public NamespacedKey getKey() {
return key;
}
@Override
public int getMaxDeviation() {
return 2;
}
@Override
public String getName() {
return "Small Chunks of Uranium";
}
@Override
public ItemStack getItem() {
return SlimefunItems.SMALL_URANIUM.clone();
}
@Override
public boolean isObtainableFromGEOMiner() {
return true;
}
} }

View File

@ -2047,14 +2047,9 @@ public final class SlimefunItemSetup {
new ItemStack[] {new ItemStack(Material.REDSTONE), new ItemStack(Material.ANVIL), new ItemStack(Material.REDSTONE), SlimefunItems.CARBONADO, SlimefunItems.AUTO_ENCHANTER, SlimefunItems.CARBONADO, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN}) new ItemStack[] {new ItemStack(Material.REDSTONE), new ItemStack(Material.ANVIL), new ItemStack(Material.REDSTONE), SlimefunItems.CARBONADO, SlimefunItems.AUTO_ENCHANTER, SlimefunItems.CARBONADO, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.WITHER_PROOF_OBSIDIAN})
.register(plugin); .register(plugin);
new AutoAnvil(categories.electricity, SlimefunItems.AUTO_ANVIL, RecipeType.ENHANCED_CRAFTING_TABLE, new AutoAnvil(categories.electricity, 10, SlimefunItems.AUTO_ANVIL, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.ANVIL), null, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK)}) { new ItemStack[] {null, new ItemStack(Material.ANVIL), null, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK)}) {
@Override
public int getRepairFactor() {
return 10;
}
@Override @Override
public int getCapacity() { public int getCapacity() {
return 128; return 128;
@ -2067,14 +2062,9 @@ public final class SlimefunItemSetup {
}.register(plugin); }.register(plugin);
new AutoAnvil(categories.electricity, SlimefunItems.AUTO_ANVIL_2, RecipeType.ENHANCED_CRAFTING_TABLE, new AutoAnvil(categories.electricity, 25, SlimefunItems.AUTO_ANVIL_2, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, SlimefunItems.AUTO_ANVIL, null, SlimefunItems.STEEL_PLATE, SlimefunItems.HEATING_COIL, SlimefunItems.STEEL_PLATE, new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK)}) { new ItemStack[] {null, SlimefunItems.AUTO_ANVIL, null, SlimefunItems.STEEL_PLATE, SlimefunItems.HEATING_COIL, SlimefunItems.STEEL_PLATE, new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK), new ItemStack(Material.IRON_BLOCK)}) {
@Override
public int getRepairFactor() {
return 4;
}
@Override @Override
public int getCapacity() { public int getCapacity() {
return 256; return 256;
@ -2100,7 +2090,7 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.BRASS_INGOT, new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT, SlimefunItems.POWER_CRYSTAL, SlimefunItems.TIN_DUST, SlimefunItems.POWER_CRYSTAL, SlimefunItems.BRASS_INGOT, new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT}) new ItemStack[] {SlimefunItems.BRASS_INGOT, new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT, SlimefunItems.POWER_CRYSTAL, SlimefunItems.TIN_DUST, SlimefunItems.POWER_CRYSTAL, SlimefunItems.BRASS_INGOT, new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT})
.register(plugin); .register(plugin);
new GPSTransmitter(categories.gps, SlimefunItems.GPS_TRANSMITTER, RecipeType.ENHANCED_CRAFTING_TABLE, new GPSTransmitter(categories.gps, 1, SlimefunItems.GPS_TRANSMITTER, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, null, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.STEEL_INGOT, SlimefunItems.ADVANCED_CIRCUIT_BOARD, SlimefunItems.STEEL_INGOT, SlimefunItems.STEEL_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.STEEL_INGOT}) { new ItemStack[] {null, null, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.STEEL_INGOT, SlimefunItems.ADVANCED_CIRCUIT_BOARD, SlimefunItems.STEEL_INGOT, SlimefunItems.STEEL_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.STEEL_INGOT}) {
@Override @Override
@ -2108,11 +2098,6 @@ public final class SlimefunItemSetup {
return y; return y;
} }
@Override
public int getCapacity() {
return 16;
}
@Override @Override
public int getEnergyConsumption() { public int getEnergyConsumption() {
return 1; return 1;
@ -2120,7 +2105,7 @@ public final class SlimefunItemSetup {
}.register(plugin); }.register(plugin);
new GPSTransmitter(categories.gps, SlimefunItems.GPS_TRANSMITTER_2, RecipeType.ENHANCED_CRAFTING_TABLE, new GPSTransmitter(categories.gps, 2, SlimefunItems.GPS_TRANSMITTER_2, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.CARBON, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER}) { new ItemStack[] {SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.CARBON, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER}) {
@Override @Override
@ -2128,11 +2113,6 @@ public final class SlimefunItemSetup {
return y * 4 + 100; return y * 4 + 100;
} }
@Override
public int getCapacity() {
return 64;
}
@Override @Override
public int getEnergyConsumption() { public int getEnergyConsumption() {
return 3; return 3;
@ -2140,7 +2120,7 @@ public final class SlimefunItemSetup {
}.register(plugin); }.register(plugin);
new GPSTransmitter(categories.gps, SlimefunItems.GPS_TRANSMITTER_3, RecipeType.ENHANCED_CRAFTING_TABLE, new GPSTransmitter(categories.gps, 3, SlimefunItems.GPS_TRANSMITTER_3, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.CARBONADO, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2}) { new ItemStack[] {SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.CARBONADO, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2}) {
@Override @Override
@ -2148,11 +2128,6 @@ public final class SlimefunItemSetup {
return y * 16 + 500; return y * 16 + 500;
} }
@Override
public int getCapacity() {
return 256;
}
@Override @Override
public int getEnergyConsumption() { public int getEnergyConsumption() {
return 11; return 11;
@ -2160,7 +2135,7 @@ public final class SlimefunItemSetup {
}.register(plugin); }.register(plugin);
new GPSTransmitter(categories.gps, SlimefunItems.GPS_TRANSMITTER_4, RecipeType.ENHANCED_CRAFTING_TABLE, new GPSTransmitter(categories.gps, 4, SlimefunItems.GPS_TRANSMITTER_4, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.NICKEL_INGOT, SlimefunItems.CARBONADO, SlimefunItems.NICKEL_INGOT, SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.GPS_TRANSMITTER_3}) { new ItemStack[] {SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.NICKEL_INGOT, SlimefunItems.CARBONADO, SlimefunItems.NICKEL_INGOT, SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.GPS_TRANSMITTER_3}) {
@Override @Override
@ -2168,11 +2143,6 @@ public final class SlimefunItemSetup {
return y * 64 + 600; return y * 64 + 600;
} }
@Override
public int getCapacity() {
return 1024;
}
@Override @Override
public int getEnergyConsumption() { public int getEnergyConsumption() {
return 46; return 46;