Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicPlayerA10 authored Jun 26, 2021
2 parents 0d58702 + 25dea3d commit be4a4df
Show file tree
Hide file tree
Showing 27 changed files with 290 additions and 120 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
## Release Candidate 26 (TBD)

#### Additions
* Diamonds can now be ground into Carbon using a Grind Stone
* Deepslate ores can now be doubled using an Ore Crusher

#### Changes

#### Fixes
* Fixed #2966

## Release Candidate 25 (20 Jun 2021)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#25
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.16</artifactId>
<version>1.3.0</version>
<version>1.3.2</version>
<scope>test</scope>

<exclusions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest;

import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
Expand Down Expand Up @@ -67,17 +68,16 @@ protected void registerDefaultRecipes(@Nonnull List<ItemStack> recipes) {
// Override this method to register some default recipes
}

public List<ItemStack[]> getRecipes() {
public @Nonnull List<ItemStack[]> getRecipes() {
return recipes;
}

@Override
public List<ItemStack> getDisplayRecipes() {
public @Nonnull List<ItemStack> getDisplayRecipes() {
return displayRecipes;
}

@Nonnull
public MultiBlock getMultiBlock() {
public @Nonnull MultiBlock getMultiBlock() {
return multiblock;
}

Expand Down Expand Up @@ -112,8 +112,7 @@ public void load() {
}
}

@Nonnull
protected MultiBlockInteractionHandler getInteractionHandler() {
protected @Nonnull MultiBlockInteractionHandler getInteractionHandler() {
return (p, mb, b) -> {
if (mb.equals(getMultiBlock())) {
if (canUse(p, true) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.INTERACT_BLOCK)) {
Expand Down Expand Up @@ -144,15 +143,14 @@ protected MultiBlockInteractionHandler getInteractionHandler() {
*
* @return The target {@link Inventory}
*/
@Nullable

@ParametersAreNonnullByDefault
protected Inventory findOutputInventory(ItemStack adding, Block dispBlock, Inventory dispInv) {
protected @Nullable Inventory findOutputInventory(ItemStack adding, Block dispBlock, Inventory dispInv) {
return findOutputInventory(adding, dispBlock, dispInv, dispInv);
}

@Nullable
@ParametersAreNonnullByDefault
protected Inventory findOutputInventory(ItemStack product, Block dispBlock, Inventory dispInv, Inventory placeCheckerInv) {
protected @Nullable Inventory findOutputInventory(ItemStack product, Block dispBlock, Inventory dispInv, Inventory placeCheckerInv) {
Optional<Inventory> outputChest = OutputChest.findOutputChestFor(dispBlock, product);

/*
Expand All @@ -167,8 +165,7 @@ protected Inventory findOutputInventory(ItemStack product, Block dispBlock, Inve
}
}

@Nonnull
private static Material[] convertItemStacksToMaterial(@Nonnull ItemStack[] items) {
private static @Nonnull Material[] convertItemStacksToMaterial(@Nonnull ItemStack[] items) {
List<Material> materials = new ArrayList<>();

for (ItemStack item : items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.inventory.ItemStack;

import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;

import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
Expand Down Expand Up @@ -51,7 +52,6 @@ public void preRegister() {
*
* @return The {@link ItemHandler} that should be added to this {@link SlimefunItem}
*/
@Nonnull
public abstract T getItemHandler();
public abstract @Nonnull T getItemHandler();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
Expand Down Expand Up @@ -115,8 +114,7 @@ protected void upgradeBackpack(Player p, Inventory inv, SlimefunBackpack backpac
}
}

@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("#")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ protected void registerDefaultRecipes(@Nonnull List<ItemStack> recipes) {

recipes.add(SlimefunItems.ENDER_LUMP_3);
recipes.add(new SlimefunItemStack(SlimefunItems.ENDER_LUMP_2, 4));

recipes.add(new ItemStack(Material.DIAMOND));
recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 4));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -107,8 +108,18 @@ public boolean isOreDoublingEnabled() {
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());
Expand All @@ -117,6 +128,7 @@ public void postRegister() {
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);
Expand All @@ -127,6 +139,19 @@ public void postRegister() {
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
Expand Down Expand Up @@ -180,7 +205,7 @@ private class DoubleOreSetting extends ItemSetting<Boolean> {
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);
}

Expand All @@ -195,12 +220,12 @@ private void apply(boolean value) {

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));
}
}

Expand All @@ -216,31 +241,31 @@ public void reload() {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
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;
Expand All @@ -20,26 +24,56 @@
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 {

// @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;
private final ItemStack[] dusts;

@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);

Expand Down Expand Up @@ -68,14 +102,15 @@ public void onInteract(Player p, Block b) {
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 {
Expand Down Expand Up @@ -110,7 +145,8 @@ public void onInteract(Player p, Block b) {
}
}

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);
Expand All @@ -129,7 +165,7 @@ private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputI
*
* @return A randomly picked dust item
*/
public ItemStack getRandomDust() {
public @Nonnull ItemStack getRandomDust() {
int index = ThreadLocalRandom.current().nextInt(dusts.length);
return dusts[index].clone();
}
Expand Down
Loading

0 comments on commit be4a4df

Please sign in to comment.