mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed #3084
This commit is contained in:
parent
343f47bdb6
commit
76dda9a439
@ -36,6 +36,7 @@
|
||||
* (API) Deprecated AsyncGeneratorProcessCompleteEvent
|
||||
* (API) Deprecated AsyncMachineProcessCompleteEvent
|
||||
* (API) Deprecated AsyncReactorProcessCompleteEvent
|
||||
* Error-Reports now show the date and time they were generated at
|
||||
* Some performance optimizations to Cargo networks
|
||||
|
||||
#### Fixes
|
||||
@ -46,6 +47,7 @@
|
||||
* Fixed #3053
|
||||
* Fixed #3075
|
||||
* Fixed recipe types showing missing string message
|
||||
* Fixed #3084
|
||||
|
||||
## Release Candidate 23 (19 May 2021)
|
||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#23
|
||||
|
@ -3,12 +3,16 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.NetherGoldPan;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -17,11 +21,25 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecip
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
|
||||
/**
|
||||
* The {@link ElectricGoldPan} is an electric machine based on the {@link GoldPan}.
|
||||
* It also serves as a {@link NetherGoldPan}.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see GoldPan
|
||||
* @see NetherGoldPan
|
||||
*
|
||||
*/
|
||||
public class ElectricGoldPan extends AContainer implements RecipeDisplayItem {
|
||||
|
||||
private final GoldPan goldPan = (GoldPan) SlimefunItems.GOLD_PAN.getItem();
|
||||
private final GoldPan netherGoldPan = (GoldPan) SlimefunItems.NETHER_GOLD_PAN.getItem();
|
||||
private final GoldPan goldPan = SlimefunItems.GOLD_PAN.getItem(GoldPan.class);
|
||||
private final GoldPan netherGoldPan = SlimefunItems.NETHER_GOLD_PAN.getItem(GoldPan.class);
|
||||
|
||||
private final ItemStack gravel = new ItemStack(Material.GRAVEL);
|
||||
private final ItemStack soulSand = new ItemStack(Material.SOUL_SAND);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public ElectricGoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
@ -48,17 +66,19 @@ public class ElectricGoldPan extends AContainer implements RecipeDisplayItem {
|
||||
}
|
||||
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true, false)) {
|
||||
ItemStack item = menu.getItemInSlot(slot);
|
||||
|
||||
if (SlimefunUtils.isItemSimilar(item, gravel, true, false)) {
|
||||
ItemStack output = goldPan.getRandomOutput();
|
||||
MachineRecipe recipe = new MachineRecipe(3 / getSpeed(), new ItemStack[0], new ItemStack[] { output });
|
||||
MachineRecipe recipe = new MachineRecipe(3 / getSpeed(), new ItemStack[] { gravel }, new ItemStack[] { output });
|
||||
|
||||
if (output.getType() != Material.AIR && menu.fits(output, getOutputSlots())) {
|
||||
menu.consumeItem(slot);
|
||||
return recipe;
|
||||
}
|
||||
} else if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, false)) {
|
||||
} else if (SlimefunUtils.isItemSimilar(item, soulSand, true, false)) {
|
||||
ItemStack output = netherGoldPan.getRandomOutput();
|
||||
MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] { output });
|
||||
MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[] { soulSand }, new ItemStack[] { output });
|
||||
|
||||
if (output.getType() != Material.AIR && menu.fits(output, getOutputSlots())) {
|
||||
menu.consumeItem(slot);
|
||||
@ -71,7 +91,7 @@ public class ElectricGoldPan extends AContainer implements RecipeDisplayItem {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasFreeSlot(BlockMenu menu) {
|
||||
private boolean hasFreeSlot(@Nonnull BlockMenu menu) {
|
||||
for (int slot : getOutputSlots()) {
|
||||
if (menu.getItemInSlot(slot) == null) {
|
||||
return true;
|
||||
|
@ -61,13 +61,11 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
||||
*
|
||||
* @return The {@link Material} this {@link GoldPan} can be used on
|
||||
*/
|
||||
@Nonnull
|
||||
protected Material getTargetMaterial() {
|
||||
public @Nonnull Material getInputMaterial() {
|
||||
return Material.GRAVEL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected Set<GoldPanDrop> getGoldPanDrops() {
|
||||
protected @Nonnull Set<GoldPanDrop> getGoldPanDrops() {
|
||||
Set<GoldPanDrop> settings = new HashSet<>();
|
||||
|
||||
settings.add(new GoldPanDrop(this, "chance.FLINT", 40, new ItemStack(Material.FLINT)));
|
||||
@ -130,7 +128,7 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
||||
Block b = block.get();
|
||||
|
||||
// Check the clicked block type and for protections
|
||||
if (b.getType() == getTargetMaterial() && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
if (b.getType() == getInputMaterial() && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
ItemStack output = getRandomOutput();
|
||||
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
@ -169,7 +167,7 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
||||
|
||||
for (GoldPanDrop drop : drops) {
|
||||
if (drop.getValue() > 0) {
|
||||
recipes.add(new ItemStack(getTargetMaterial()));
|
||||
recipes.add(new ItemStack(getInputMaterial()));
|
||||
recipes.add(drop.getOutput());
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,12 @@ public class NetherGoldPan extends GoldPan {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
protected Material getTargetMaterial() {
|
||||
public @Nonnull Material getInputMaterial() {
|
||||
return Material.SOUL_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
protected Set<GoldPanDrop> getGoldPanDrops() {
|
||||
protected @Nonnull Set<GoldPanDrop> getGoldPanDrops() {
|
||||
Set<GoldPanDrop> settings = new HashSet<>();
|
||||
|
||||
settings.add(new GoldPanDrop(this, "chance.QUARTZ", 50, new ItemStack(Material.QUARTZ)));
|
||||
|
Loading…
Reference in New Issue
Block a user