Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Jul 4, 2024
1 parent 25b9f25 commit 350f1df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Color;
Expand All @@ -24,11 +25,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.*;
import java.util.function.Consumer;

/**
Expand All @@ -37,7 +34,6 @@
*
* @author TheBusyBiscuit
* @author Walshy
*
*/
@SerializableAs("ItemStack")
public class SlimefunItemStack extends ItemStack {
Expand All @@ -48,6 +44,9 @@ public class SlimefunItemStack extends ItemStack {
private boolean locked = false;
private String texture = null;

@Getter
private final List<ItemStack> drops = new ArrayList(List.of(this));

public SlimefunItemStack(String id, ItemStack item) {
super(item);

Expand Down Expand Up @@ -227,15 +226,12 @@ public final String getItemId() {
/**
* This method returns the associated {@link SlimefunItem} and casts it to the provided
* {@link Class}.
*
* <p>
* If no item was found or the found {@link SlimefunItem} is not of the requested type,
* the method will return null.
*
* @param <T>
* The type of {@link SlimefunItem} to cast this to
* @param type
* The {@link Class} of the target {@link SlimefunItem}
*
* @param <T> The type of {@link SlimefunItem} to cast this to
* @param type The {@link Class} of the target {@link SlimefunItem}
* @return The {@link SlimefunItem} this {@link SlimefunItem} represents, casted to the given type
*/
public @Nullable <T extends SlimefunItem> T getItem(Class<T> type) {
Expand Down Expand Up @@ -338,4 +334,8 @@ public final int hashCode() {
// We don't want people to override this, it should use the super method
return super.hashCode();
}

public void addDrop(ItemStack itemStack) {
this.drops.add(itemStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public static boolean isDust(ItemStack item) {
public static Collection<ItemStack> getDrops(SlimefunItem sfItem, Location loc) {
Collection<ItemStack> tempDrops = new ArrayList<>(sfItem.getDrops());
tempDrops.remove(sfItem.getItem());
tempDrops.add(Slimefun.getDatabaseManager().getBlockDataController().getBlockData(loc).getSfItemStack());
tempDrops.addAll(Slimefun.getDatabaseManager().getBlockDataController().getBlockData(loc).getSfItemStack().getDrops());
return tempDrops;
}

Expand All @@ -654,7 +654,7 @@ public static Collection<ItemStack> getDrops(Location loc) {
SlimefunItem sfItem = SlimefunItem.getById(blockData.getSfId());
Collection<ItemStack> tempDrops = new ArrayList<>(sfItem.getDrops());
tempDrops.remove(sfItem.getItem());
tempDrops.add(blockData.getSfItemStack());
tempDrops.addAll(blockData.getSfItemStack().getDrops());
return tempDrops;
}
}

0 comments on commit 350f1df

Please sign in to comment.