diff --git a/src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/machines/BigStorageUnit.java b/src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/machines/BigStorageUnit.java index 7fbeb5c8..e9c5e682 100644 --- a/src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/machines/BigStorageUnit.java +++ b/src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/machines/BigStorageUnit.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.sensibletoolbox.blocks.machines; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import javax.annotation.Nonnull; @@ -24,6 +26,7 @@ import org.bukkit.inventory.Recipe; import org.bukkit.inventory.RecipeChoice.MaterialChoice; import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.metadata.FixedMetadataValue; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; @@ -42,6 +45,7 @@ public class BigStorageUnit extends AbstractProcessingMachine { private static final String STB_LAST_BSU_INSERT = "STB_Last_BSU_Insert"; private static final long DOUBLE_CLICK_TIME = 250L; private ItemStack stored; + private ItemStack storedDisplay; private int storageAmount; private int outputAmount; private int maxCapacity; @@ -127,14 +131,34 @@ public void setStoredItemType(ItemStack stored) { if (stored != null) { this.stored = stored.clone(); this.stored.setAmount(1); + this.storedDisplay = getStoredItemDisplay(); } else if (!isLocked()) { this.stored = null; + this.storedDisplay = null; } maxCapacity = getStackCapacity() * (this.stored == null ? 64 : this.stored.getMaxStackSize()); updateSignItemLines(); } + @Nullable + private ItemStack getStoredItemDisplay() { + if (this.stored != null) { + ItemStack displayItemStack = stored.clone(); + ItemMeta meta = displayItemStack.getItemMeta(); + List newLore = new ArrayList<>(); + if (meta != null) { + List currentLore = meta.getLore(); + if (currentLore != null) {newLore.addAll(currentLore);} + } + newLore.add(ChatColor.GRAY + "Stored Item"); + meta.setLore(newLore); + displayItemStack.setItemMeta(meta); + return displayItemStack; + } + return null; + } + private void updateSignQuantityLine() { if (isLocked()) { signLabel[1] = ChatColor.DARK_RED + Integer.toString(getTotalAmount()); @@ -322,7 +346,7 @@ public void onServerTick() { Debugger.getInstance().debug(2, this + " amount changed! " + oldTotalAmount + " -> " + getTotalAmount()); getProgressMeter().setMaxProgress(maxCapacity); - setProcessing(stored); + setProcessing(storedDisplay); setProgress(maxCapacity - (double) getStorageAmount()); update(false); updateAttachedLabelSigns(); @@ -359,7 +383,7 @@ public void onBlockUnregistered(Location location) { @Override public void onBlockRegistered(Location location, boolean isPlacing) { getProgressMeter().setMaxProgress(maxCapacity); - setProcessing(stored); + setProcessing(storedDisplay); setProgress(maxCapacity - (double) storageAmount); ItemStack output = getOutputItem(); outputAmount = output == null ? 0 : output.getAmount();