mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Deepslate ores can now be doubled using an Ore Crusher
This commit is contained in:
parent
65142d1204
commit
b9f64bdebc
@ -30,6 +30,7 @@
|
||||
|
||||
#### Additions
|
||||
* Diamonds can now be ground into Carbon using a Grind Stone
|
||||
* Deepslate ores can now be doubled using an Ore Crusher
|
||||
|
||||
#### Changes
|
||||
|
||||
|
@ -47,14 +47,13 @@ abstract class AbstractCraftingTable extends MultiBlockMachine {
|
||||
super(category, item, recipe, trigger);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected Inventory createVirtualInventory(@Nonnull Inventory inv) {
|
||||
protected @Nonnull Inventory createVirtualInventory(@Nonnull Inventory inv) {
|
||||
Inventory fakeInv = Bukkit.createInventory(null, 9, "Fake Inventory");
|
||||
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
ItemStack stack = inv.getContents()[j];
|
||||
|
||||
/**
|
||||
/*
|
||||
* Fixes #2103 - Properly simulating the consumption
|
||||
* (which may leave behind empty buckets or glass bottles)
|
||||
*/
|
||||
@ -115,8 +114,7 @@ abstract class AbstractCraftingTable extends MultiBlockMachine {
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Optional<String> retrieveID(@Nullable ItemStack backpack, int size) {
|
||||
private @Nonnull Optional<String> retrieveID(@Nullable ItemStack backpack, int size) {
|
||||
if (backpack != null) {
|
||||
for (String line : backpack.getItemMeta().getLore()) {
|
||||
if (line.startsWith(ChatColors.color("&7ID: ")) && line.contains("#")) {
|
||||
|
@ -25,6 +25,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
@ -107,8 +108,18 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
public void postRegister() {
|
||||
super.postRegister();
|
||||
|
||||
displayRecipes.addAll(Arrays.asList(new ItemStack(Material.COAL_ORE), doubleOres.getCoal(), new ItemStack(Material.LAPIS_ORE), doubleOres.getLapisLazuli(), new ItemStack(Material.REDSTONE_ORE), doubleOres.getRedstone(), new ItemStack(Material.DIAMOND_ORE), doubleOres.getDiamond(), new ItemStack(Material.EMERALD_ORE), doubleOres.getEmerald(), new ItemStack(Material.NETHER_QUARTZ_ORE), doubleOres.getNetherQuartz()));
|
||||
// @formatter:off
|
||||
displayRecipes.addAll(Arrays.asList(
|
||||
new ItemStack(Material.COAL_ORE), doubleOres.getCoal(),
|
||||
new ItemStack(Material.LAPIS_ORE), doubleOres.getLapisLazuli(),
|
||||
new ItemStack(Material.REDSTONE_ORE), doubleOres.getRedstone(),
|
||||
new ItemStack(Material.DIAMOND_ORE), doubleOres.getDiamond(),
|
||||
new ItemStack(Material.EMERALD_ORE), doubleOres.getEmerald(),
|
||||
new ItemStack(Material.NETHER_QUARTZ_ORE), doubleOres.getNetherQuartz()
|
||||
));
|
||||
// @formatter:on
|
||||
|
||||
// Gold ore variants (1.16+)
|
||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||
displayRecipes.add(new ItemStack(Material.NETHER_GOLD_ORE));
|
||||
displayRecipes.add(doubleOres.getGoldNuggets());
|
||||
@ -117,6 +128,7 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
displayRecipes.add(doubleOres.getGoldNuggets());
|
||||
}
|
||||
|
||||
// Raw metal ores (1.17+)
|
||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
|
||||
displayRecipes.add(new ItemStack(Material.RAW_IRON));
|
||||
displayRecipes.add(SlimefunItems.IRON_DUST);
|
||||
@ -127,6 +139,19 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
displayRecipes.add(new ItemStack(Material.RAW_GOLD));
|
||||
displayRecipes.add(SlimefunItems.GOLD_DUST);
|
||||
}
|
||||
|
||||
// Deepslate Ores (1.17+)
|
||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
|
||||
// @formatter:off
|
||||
displayRecipes.addAll(Arrays.asList(
|
||||
new ItemStack(Material.DEEPSLATE_COAL_ORE), doubleOres.getCoal(),
|
||||
new ItemStack(Material.DEEPSLATE_LAPIS_ORE), doubleOres.getLapisLazuli(),
|
||||
new ItemStack(Material.DEEPSLATE_REDSTONE_ORE), doubleOres.getRedstone(),
|
||||
new ItemStack(Material.DEEPSLATE_DIAMOND_ORE), doubleOres.getDiamond(),
|
||||
new ItemStack(Material.DEEPSLATE_EMERALD_ORE), doubleOres.getEmerald()
|
||||
));
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -180,7 +205,7 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
private final ItemStack quartz = new ItemStack(Material.QUARTZ, 1);
|
||||
private final ItemStack goldNuggets = new ItemStack(Material.GOLD_NUGGET, 4);
|
||||
|
||||
public DoubleOreSetting(@Nonnull OreCrusher oreCrusher) {
|
||||
DoubleOreSetting(@Nonnull OreCrusher oreCrusher) {
|
||||
super(oreCrusher, "double-ores", true);
|
||||
}
|
||||
|
||||
@ -195,12 +220,12 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
|
||||
SlimefunItem ironDust = SlimefunItem.getByID("IRON_DUST");
|
||||
if (ironDust != null) {
|
||||
ironDust.setRecipeOutput(new CustomItem(SlimefunItems.IRON_DUST, value ? 2 : 1));
|
||||
ironDust.setRecipeOutput(new SlimefunItemStack(SlimefunItems.IRON_DUST, value ? 2 : 1));
|
||||
}
|
||||
|
||||
SlimefunItem goldDust = SlimefunItem.getByID("GOLD_DUST");
|
||||
if (goldDust != null) {
|
||||
goldDust.setRecipeOutput(new CustomItem(SlimefunItems.GOLD_DUST, value ? 2 : 1));
|
||||
goldDust.setRecipeOutput(new SlimefunItemStack(SlimefunItems.GOLD_DUST, value ? 2 : 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,31 +241,31 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
apply(getValue());
|
||||
}
|
||||
|
||||
public ItemStack getCoal() {
|
||||
public @Nonnull ItemStack getCoal() {
|
||||
return coal;
|
||||
}
|
||||
|
||||
public ItemStack getLapisLazuli() {
|
||||
public @Nonnull ItemStack getLapisLazuli() {
|
||||
return lapis;
|
||||
}
|
||||
|
||||
public ItemStack getRedstone() {
|
||||
public @Nonnull ItemStack getRedstone() {
|
||||
return redstone;
|
||||
}
|
||||
|
||||
public ItemStack getDiamond() {
|
||||
public @Nonnull ItemStack getDiamond() {
|
||||
return diamond;
|
||||
}
|
||||
|
||||
public ItemStack getEmerald() {
|
||||
public @Nonnull ItemStack getEmerald() {
|
||||
return emerald;
|
||||
}
|
||||
|
||||
public ItemStack getNetherQuartz() {
|
||||
public @Nonnull ItemStack getNetherQuartz() {
|
||||
return quartz;
|
||||
}
|
||||
|
||||
public ItemStack getGoldNuggets() {
|
||||
public @Nonnull ItemStack getGoldNuggets() {
|
||||
return goldNuggets;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,10 @@ import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -20,26 +24,56 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
* The {@link OreWasher} is a special {@link MultiBlockMachine} which allows you to
|
||||
* turn Sifted Ore into ore dusts.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
* @author Sfiguz7
|
||||
*
|
||||
*/
|
||||
public class OreWasher extends MultiBlockMachine {
|
||||
|
||||
private final boolean legacyMode;
|
||||
private final ItemStack[] dusts;
|
||||
// @formatter:off
|
||||
private final ItemStack[] dusts = new ItemStack[] {
|
||||
SlimefunItems.IRON_DUST,
|
||||
SlimefunItems.GOLD_DUST,
|
||||
SlimefunItems.COPPER_DUST,
|
||||
SlimefunItems.TIN_DUST,
|
||||
SlimefunItems.ZINC_DUST,
|
||||
SlimefunItems.ALUMINUM_DUST,
|
||||
SlimefunItems.MAGNESIUM_DUST,
|
||||
SlimefunItems.LEAD_DUST,
|
||||
SlimefunItems.SILVER_DUST
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
private final boolean legacyMode;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public OreWasher(Category category, SlimefunItemStack item) {
|
||||
super(category, item, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF);
|
||||
// @formatter:off
|
||||
super(category, item, new ItemStack[] {
|
||||
null, new ItemStack(Material.DISPENSER), null,
|
||||
null, new ItemStack(Material.OAK_FENCE), null,
|
||||
null, new ItemStack(Material.CAULDRON), null
|
||||
}, BlockFace.SELF);
|
||||
// @formatter:on
|
||||
|
||||
legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer");
|
||||
dusts = new ItemStack[] { SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.TIN_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerDefaultRecipes(List<ItemStack> recipes) {
|
||||
// Iron and Gold are displayed as Ore Crusher recipes, as that is their primary
|
||||
// way of obtaining them. But we also wanna display them here, so we just
|
||||
// add these two recipes manually
|
||||
/*
|
||||
* Iron and Gold are displayed as Ore Crusher recipes, as that is their primary
|
||||
* way of obtaining them. But we also wanna display them here, so we just
|
||||
* add these two recipes manually
|
||||
*/
|
||||
recipes.add(SlimefunItems.SIFTED_ORE);
|
||||
recipes.add(SlimefunItems.IRON_DUST);
|
||||
|
||||
@ -68,14 +102,15 @@ public class OreWasher extends MultiBlockMachine {
|
||||
Inventory outputInv = null;
|
||||
|
||||
if (!legacyMode) {
|
||||
// This is a fancy way of checking if there is empty space in the inv; by checking if an
|
||||
// unobtainable item could fit in it.
|
||||
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will
|
||||
// never
|
||||
// actually be added to the real inventory,
|
||||
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH
|
||||
// however, signals that it's
|
||||
// not supposed to be given to the player.
|
||||
/*
|
||||
* This is a fancy way of checking if there is empty space in the inv
|
||||
* by checking if an unobtainable item could fit in it.
|
||||
* However, due to the way the method findValidOutputInv() functions,
|
||||
* the dummyAdding will never actually be added to the real inventory,
|
||||
* so it really doesn't matter what item the ItemStack is made by.
|
||||
* SlimefunItems.DEBUG_FISH however, signals that it's not supposed
|
||||
* to be given to the player.
|
||||
*/
|
||||
ItemStack dummyAdding = SlimefunItems.DEBUG_FISH;
|
||||
outputInv = findOutputInventory(dummyAdding, dispBlock, inv);
|
||||
} else {
|
||||
@ -110,7 +145,8 @@ public class OreWasher extends MultiBlockMachine {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputInv, ItemStack input, ItemStack output, int amount) {
|
||||
@ParametersAreNonnullByDefault
|
||||
private void removeItem(Player p, Block b, Inventory inputInv, @Nullable Inventory outputInv, ItemStack input, ItemStack output, int amount) {
|
||||
if (outputInv != null) {
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(amount);
|
||||
@ -129,7 +165,7 @@ public class OreWasher extends MultiBlockMachine {
|
||||
*
|
||||
* @return A randomly picked dust item
|
||||
*/
|
||||
public ItemStack getRandomDust() {
|
||||
public @Nonnull ItemStack getRandomDust() {
|
||||
int index = ThreadLocalRandom.current().nextInt(dusts.length);
|
||||
return dusts[index].clone();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user