mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-18 19:39:15 +00:00
Improving quality of life when dealing with sealed drawers. (#48)
This commit is contained in:
1 parent
ac9fb71091
commit
dcc8e0abeb
8 files changed
+496
-51
No files matched your search
+2
-10
@@ -3,16 +3,11 @@ package com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemCompDrawers;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemSortingCompDrawers extends ItemCompDrawers {
|
||||
|
||||
public ItemSortingCompDrawers(Block block) {
|
||||
@@ -20,11 +15,8 @@ public class ItemSortingCompDrawers extends ItemCompDrawers {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(itemStack, player, list, par4);
|
||||
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
protected void addDescriptionInformation(int drawerCapacity, List list) {
|
||||
super.addDescriptionInformation(drawerCapacity, list);
|
||||
list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocalFormatted("storageDrawers.waila.sorting"));
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -3,8 +3,6 @@ package com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
@@ -13,9 +11,6 @@ import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.RefinedRelocation;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemBasicDrawers;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemSortingDrawers extends ItemBasicDrawers {
|
||||
|
||||
public ItemSortingDrawers(Block block) {
|
||||
@@ -23,11 +18,8 @@ public class ItemSortingDrawers extends ItemBasicDrawers {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(itemStack, player, list, par4);
|
||||
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
protected void addDescriptionInformation(int drawerCapacity, List list) {
|
||||
super.addDescriptionInformation(drawerCapacity, list);
|
||||
list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocalFormatted("storageDrawers.waila.sorting"));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,18 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCompDrawers extends ItemBlock {
|
||||
public class ItemCompDrawers extends ItemDrawers {
|
||||
|
||||
public ItemCompDrawers(Block block) {
|
||||
super(block);
|
||||
@@ -45,17 +43,34 @@ public class ItemCompDrawers extends ItemBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
protected void addDrawersInformation(NBTTagCompound tag, List list) {
|
||||
NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND);
|
||||
int totalCount = tag.getInteger("Count");
|
||||
|
||||
int count = config.getBlockBaseStorage("compdrawers");
|
||||
list.add(StatCollector.translateToLocalFormatted("storageDrawers.drawers.description", count));
|
||||
list.add(
|
||||
EnumChatFormatting.GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.compDrawerList"));
|
||||
|
||||
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("tile")) {
|
||||
list.add(
|
||||
EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocalFormatted("storageDrawers.drawers.sealed"));
|
||||
for (int i = 0; i < slots.tagCount(); i++) {
|
||||
NBTTagCompound slot = slots.getCompoundTagAt(i);
|
||||
ItemStack stack = getItemStackFromDrawer(slot);
|
||||
String slotCounter = EnumChatFormatting.YELLOW + " #" + (i + 1) + ": ";
|
||||
if (stack != null && tag.hasKey("Conv" + i)) {
|
||||
// "Convi" is the conversion rate, for example in vanilla nugget = 1, ingot = 9, block = 81
|
||||
int itemCount = totalCount / tag.getByte("Conv" + i);
|
||||
// Example of show in tooltips (if we have vanilla minecraft):
|
||||
// #1: Gold Block [1] - totalCount / 81
|
||||
// #2: Gold Ingot [9] - totalCount / 9
|
||||
// #3: Gold Nugget [1x64 + 17] - totalCount / 1
|
||||
list.add(
|
||||
slotCounter + getGoodDisplayName(stack)
|
||||
+ " "
|
||||
+ getItemCountDisplay(stack.getMaxStackSize(), itemCount));
|
||||
} else {
|
||||
list.add(
|
||||
slotCounter + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.drawerEmpty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
@@ -52,6 +56,90 @@ public class ItemCustomDrawers extends ItemDrawers {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAlternativeTagInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
// Add materials information for not sealed framed drawers.
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
this.addDescriptionInformation(getCapacityForBlock(block), list);
|
||||
this.addMaterialsInformation(itemStack.getTagCompound(), list); // safe to use without tags.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addNoneTagDescriptionInformation(int drawerCapacity, List list) {
|
||||
super.addNoneTagDescriptionInformation(drawerCapacity, list);
|
||||
list.add(
|
||||
EnumChatFormatting.GRAY + StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialList"));
|
||||
list.add(
|
||||
" " + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialNone"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSealedContentsInformation(NBTTagCompound tag, List list) {
|
||||
this.addMaterialsInformation(tag, list);
|
||||
}
|
||||
|
||||
/** Add to tooltip information about materials used in framed drawers */
|
||||
private void addMaterialsInformation(NBTTagCompound tag, List list) {
|
||||
ItemStack materialSide = null;
|
||||
ItemStack materialFront = null;
|
||||
ItemStack materialTrim = null;
|
||||
boolean hasMaterials = false;
|
||||
|
||||
// Logic copied from "readFromPortableNBT" method from "TileEntityDrawers".
|
||||
if (tag.hasKey("MatS")) {
|
||||
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
|
||||
hasMaterials = true;
|
||||
}
|
||||
if (tag.hasKey("MatF")) {
|
||||
materialFront = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatF"));
|
||||
hasMaterials = true;
|
||||
}
|
||||
if (tag.hasKey("MatT")) {
|
||||
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
|
||||
hasMaterials = true;
|
||||
}
|
||||
|
||||
list.add(
|
||||
EnumChatFormatting.GRAY + StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialList"));
|
||||
|
||||
if (hasMaterials) {
|
||||
// Display side material
|
||||
list.add(
|
||||
" " + EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialSide")
|
||||
+ " "
|
||||
+ getMaterialDisplayName(materialSide));
|
||||
// Display trim material
|
||||
list.add(
|
||||
" " + EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialTrim")
|
||||
+ " "
|
||||
+ getMaterialDisplayName(materialTrim));
|
||||
// Display front material
|
||||
list.add(
|
||||
" " + EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialFront")
|
||||
+ " "
|
||||
+ getMaterialDisplayName(materialFront));
|
||||
} else {
|
||||
// Display <None> ...
|
||||
list.add(
|
||||
" " + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialNone"));
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns good display name or in gray localised "sealed.materialNone". */
|
||||
private String getMaterialDisplayName(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
return getGoodDisplayName(stack);
|
||||
} else {
|
||||
return EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialNone");
|
||||
}
|
||||
}
|
||||
|
||||
private static NBTTagCompound getMaterialTag(ItemStack mat) {
|
||||
mat = mat.copy();
|
||||
mat.stackSize = 1;
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityTrim;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCustomTrim extends ItemBlock {
|
||||
|
||||
public ItemCustomTrim(Block block) {
|
||||
@@ -32,6 +39,90 @@ public class ItemCustomTrim extends ItemBlock {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
if (itemStack.hasTagCompound()) {
|
||||
NBTTagCompound tag = itemStack.getTagCompound();
|
||||
this.addMaterialsInformation(tag, list);
|
||||
} else {
|
||||
list.add(StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialList"));
|
||||
list.add(
|
||||
" " + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialNone"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to tooltip information about materials used in framed trim. Copied from ItemCustomDrawers method.
|
||||
*/
|
||||
private void addMaterialsInformation(NBTTagCompound tag, List list) {
|
||||
ItemStack materialSide = null;
|
||||
ItemStack materialFront = null;
|
||||
ItemStack materialTrim = null;
|
||||
boolean hasMaterials = false;
|
||||
|
||||
// Logic copied from "readFromPortableNBT" method from "TileEntityDrawers".
|
||||
if (tag.hasKey("MatS")) {
|
||||
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
|
||||
hasMaterials = true;
|
||||
}
|
||||
if (tag.hasKey("MatF")) {
|
||||
materialFront = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatF"));
|
||||
hasMaterials = true;
|
||||
}
|
||||
if (tag.hasKey("MatT")) {
|
||||
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
|
||||
hasMaterials = true;
|
||||
}
|
||||
|
||||
list.add(
|
||||
EnumChatFormatting.GRAY + StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialList"));
|
||||
|
||||
if (hasMaterials) {
|
||||
// Display side material
|
||||
list.add(
|
||||
" " + EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialSide")
|
||||
+ " "
|
||||
+ getMaterialDisplayName(materialSide));
|
||||
// Display trim material
|
||||
list.add(
|
||||
" " + EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialTrim")
|
||||
+ " "
|
||||
+ getMaterialDisplayName(materialTrim));
|
||||
// Display front material
|
||||
list.add(
|
||||
" " + EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialFront")
|
||||
+ " "
|
||||
+ getMaterialDisplayName(materialFront));
|
||||
} else {
|
||||
// Display <None> ...
|
||||
list.add(
|
||||
" " + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialNone"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns good display name or in gray localised "sealed.materialNone". Copied from ItemDrawers and
|
||||
* ItemCustomDrawers methods.
|
||||
*/
|
||||
private String getMaterialDisplayName(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
if (stack.hasDisplayName()) {
|
||||
return EnumChatFormatting.ITALIC.toString() + stack.getRarity().rarityColor + stack.getDisplayName();
|
||||
} else {
|
||||
return stack.getRarity().rarityColor.toString() + stack.getDisplayName();
|
||||
}
|
||||
} else {
|
||||
return EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.materialNone");
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack makeItemStack(Block block, int count, ItemStack matSide, ItemStack matTrim) {
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
if (!(item instanceof ItemCustomTrim)) return null;
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -53,18 +63,42 @@ public class ItemDrawers extends ItemBlock {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
list.add(
|
||||
StatCollector
|
||||
.translateToLocalFormatted("storageDrawers.drawers.description", getCapacityForBlock(block)));
|
||||
if (itemStack.hasTagCompound()) {
|
||||
NBTTagCompound tag = itemStack.getTagCompound();
|
||||
if (tag.hasKey("tile")) {
|
||||
NBTTagCompound tileTag = tag.getCompoundTag("tile");
|
||||
|
||||
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("tile")) {
|
||||
list.add(
|
||||
EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocalFormatted("storageDrawers.drawers.sealed"));
|
||||
// 5 - magic number used by TileEntityDrawers class representing number of upgrade slots.
|
||||
ItemStack[] upgrades = new ItemStack[5];
|
||||
int drawerCapacity = getUpgradesAndDrawerCapacity(tileTag, upgrades);
|
||||
|
||||
// Add to tooltip description + true stack storage space (if storage upgrades are applied).
|
||||
this.addDescriptionInformation(drawerCapacity, list);
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
||||
this.addStatsInformation(tileTag, player, list);
|
||||
this.addDrawersInformation(tileTag, list);
|
||||
this.addUpgradesInformation(upgrades, list);
|
||||
// Possible alternative drawer information from tag.
|
||||
this.addSealedContentsInformation(tileTag, list);
|
||||
} else {
|
||||
list.add(
|
||||
EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed"));
|
||||
list.add(
|
||||
EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.descriptionShift"));
|
||||
}
|
||||
} else {
|
||||
this.addAlternativeTagInformation(itemStack, player, list, par4);
|
||||
}
|
||||
} else {
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
this.addNoneTagDescriptionInformation(getCapacityForBlock(block), list);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns default drawers storage capacity of drawer block. If the block is not drawer returns 0. */
|
||||
protected int getCapacityForBlock(Block block) {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
int count = 0;
|
||||
@@ -82,4 +116,224 @@ public class ItemDrawers extends ItemBlock {
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// Add description information in different places
|
||||
|
||||
/** Add common description for all types of drawers, like sealed drawers and framed drawers with materials. */
|
||||
protected void addDescriptionInformation(int drawerCapacity, List list) {
|
||||
list.add(StatCollector.translateToLocalFormatted("storageDrawers.drawers.description", drawerCapacity));
|
||||
}
|
||||
|
||||
/** Add bonus description information for drawers without NBTTagCompound. */
|
||||
protected void addNoneTagDescriptionInformation(int drawerCapacity, List list) {
|
||||
this.addDescriptionInformation(drawerCapacity, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add information in the case if they are others tags to check. In this case itemStack has always an
|
||||
* NBTTagCompound.
|
||||
*/
|
||||
protected void addAlternativeTagInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {}
|
||||
|
||||
// Add sealed contents information.
|
||||
|
||||
/** Add to tooltip some drawers stats. */
|
||||
protected void addStatsInformation(NBTTagCompound tag, EntityPlayer player, List list) {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
|
||||
EnumSet<LockAttribute> lockAttributes = null; // Unlocked or Locked drawer.
|
||||
UUID owner = null; // Owner of drawer.
|
||||
boolean shrouded = false; // Hide or show item label.
|
||||
boolean quantified = false; // Hide or show item quantities.
|
||||
|
||||
// Logic for reading NBT are copied from "readFromPortableNBT" method from "TileEntityDrawers" class.
|
||||
|
||||
if (config.cache.enableLockUpgrades && tag.hasKey("Lock"))
|
||||
lockAttributes = LockAttribute.getEnumSet(tag.getByte("Lock"));
|
||||
if (config.cache.enablePersonalUpgrades && tag.hasKey("Own")) owner = UUID.fromString(tag.getString("Own"));
|
||||
if (config.cache.enableShroudUpgrades && tag.hasKey("Shr")) shrouded = tag.getBoolean("Shr");
|
||||
if (config.cache.enableQuantifyUpgrades && tag.hasKey("Qua")) quantified = tag.getBoolean("Qua");
|
||||
|
||||
String lockInfo; // Stat of the locked drawer.
|
||||
String accessInfo; // Stat of the owner.
|
||||
|
||||
// Show locked drawer status
|
||||
if (lockAttributes != null && lockAttributes.contains(LockAttribute.LOCK_POPULATED)) {
|
||||
lockInfo = EnumChatFormatting.YELLOW
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.locked");
|
||||
} else {
|
||||
lockInfo = EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.unlocked");
|
||||
}
|
||||
|
||||
// Show if drawer is Public or Protected
|
||||
if (owner != null) {
|
||||
if (player.getUniqueID().equals(owner)) {
|
||||
accessInfo = EnumChatFormatting.GREEN
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.access_owner");
|
||||
} else {
|
||||
accessInfo = EnumChatFormatting.RED
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.access_owner");
|
||||
}
|
||||
} else {
|
||||
accessInfo = EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.access_public");
|
||||
}
|
||||
|
||||
list.add(lockInfo + EnumChatFormatting.DARK_GRAY + ", " + accessInfo);
|
||||
|
||||
// In the next line show if drawer hide item label
|
||||
if (shrouded) {
|
||||
list.add(
|
||||
EnumChatFormatting.WHITE
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.hideItemLabel"));
|
||||
} else {
|
||||
list.add(
|
||||
EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.showItemLabel"));
|
||||
}
|
||||
|
||||
// In the next line show if drawer show item quantity
|
||||
if (quantified) {
|
||||
list.add(
|
||||
EnumChatFormatting.WHITE
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.showItemQuantity"));
|
||||
} else {
|
||||
list.add(
|
||||
EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.hideItemQuantity"));
|
||||
}
|
||||
}
|
||||
|
||||
/** Add to tooltip information about drawers content. */
|
||||
protected void addDrawersInformation(NBTTagCompound tag, List list) {
|
||||
NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND);
|
||||
list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("storageDrawers.drawers.sealed.drawerList"));
|
||||
for (int i = 0; i < slots.tagCount(); i++) {
|
||||
NBTTagCompound slot = slots.getCompoundTagAt(i);
|
||||
ItemStack stack = getItemStackFromDrawer(slot);
|
||||
String slotCounter = EnumChatFormatting.YELLOW + " #" + (i + 1) + ": ";
|
||||
if (stack != null) {
|
||||
list.add(
|
||||
slotCounter + getGoodDisplayName(stack)
|
||||
+ " "
|
||||
+ getItemCountDisplay(stack.getMaxStackSize(), slot.getInteger("Count")));
|
||||
} else {
|
||||
list.add(
|
||||
slotCounter + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.drawerEmpty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Add to tooltip information about upgrades. */
|
||||
protected void addUpgradesInformation(ItemStack[] upgrades, List list) {
|
||||
list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("storageDrawers.drawers.sealed.upgradeList"));
|
||||
boolean hasUpgrades = false;
|
||||
|
||||
for (int i = 0; i < upgrades.length; i++) { // 5 - upgrade count
|
||||
ItemStack upgrade = upgrades[i];
|
||||
if (upgrade != null) {
|
||||
list.add(EnumChatFormatting.YELLOW + " - " + getGoodDisplayName(upgrade));
|
||||
hasUpgrades = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasUpgrades) {
|
||||
list.add(
|
||||
" " + EnumChatFormatting.DARK_GRAY
|
||||
+ StatCollector.translateToLocal("storageDrawers.drawers.sealed.upgradeNone"));
|
||||
}
|
||||
}
|
||||
|
||||
/** Add information after Stats, Drawers and Upgrades information. */
|
||||
protected void addSealedContentsInformation(NBTTagCompound tag, List list) {}
|
||||
|
||||
// Functions for extracting data from NBT
|
||||
|
||||
/** Read ItemStack from NBT when representing drawer slot. */
|
||||
protected ItemStack getItemStackFromDrawer(NBTTagCompound slot) {
|
||||
// Logic copied from readNBT method of DrawerData class.
|
||||
ItemStack stack = null;
|
||||
if (slot.hasKey("Item") && slot.hasKey("Count")) {
|
||||
Item item = Item.getItemById(slot.getShort("Item"));
|
||||
if (item != null) { // p_i1881_2_ - stackSize
|
||||
stack = new ItemStack(item, 1, slot.getShort("Meta"));
|
||||
if (slot.hasKey("Tags")) stack.setTagCompound(slot.getCompoundTag("Tags"));
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
/** Read upgrades and drawer capacity from NBT when representing drawers. */
|
||||
protected int getUpgradesAndDrawerCapacity(NBTTagCompound tag, ItemStack[] upgrades) {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
|
||||
int multiplier = 0; // effective storage multiplier for calculating true storage space.
|
||||
boolean isDowngrade = false; // if downgrade upgrade is applied.
|
||||
|
||||
// Read upgrades in legacy format. Copied like in `readLegacyUpgradeNBT` method from "TileEntityDrawers" class.
|
||||
if (!tag.hasKey("Upgrades")) {
|
||||
int i = 0; // idk how it's worked in legacy, so maybe like this ?
|
||||
if (tag.hasKey("Lev") && tag.getByte("Lev") > 1) {
|
||||
upgrades[i] = new ItemStack(ModItems.upgrade, 1, tag.getByte("Lev"));
|
||||
multiplier += config.getStorageUpgradeMultiplier(upgrades[i++].getItemDamage());
|
||||
}
|
||||
if (tag.hasKey("Stat")) upgrades[i++] = new ItemStack(ModItems.upgradeStatus, 1, tag.getByte("Stat"));
|
||||
if (tag.hasKey("Void")) upgrades[i++] = new ItemStack(ModItems.upgradeVoid);
|
||||
if (tag.hasKey("Down")) {
|
||||
upgrades[i] = new ItemStack(ModItems.upgradeDowngrade);
|
||||
isDowngrade = true;
|
||||
}
|
||||
}
|
||||
// Read upgrades in new format. Copied like in `readFromPortableNBT` method from "TileEntityDrawers" class.
|
||||
else {
|
||||
NBTTagList upgradeList = tag.getTagList("Upgrades", Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < upgradeList.tagCount(); i++) {
|
||||
NBTTagCompound upgradeTag = upgradeList.getCompoundTagAt(i);
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(upgradeTag);
|
||||
if (stack != null) {
|
||||
if (stack.getItem() == ModItems.upgrade)
|
||||
multiplier += StorageDrawers.config.getStorageUpgradeMultiplier(stack.getItemDamage());
|
||||
// TODO: Add not implemented config check.
|
||||
if (stack.getItem() == ModItems.upgradeDowngrade) isDowngrade = true;
|
||||
}
|
||||
upgrades[i] = stack;
|
||||
}
|
||||
}
|
||||
|
||||
// Later when we calculate total storage it will not multiply by 0
|
||||
if (multiplier == 0) multiplier = 1;
|
||||
|
||||
// "Cap" tag is drawer capacity
|
||||
return isDowngrade ? multiplier : tag.getShort("Cap") * multiplier;
|
||||
}
|
||||
|
||||
// String functions for good displays.
|
||||
|
||||
/** Returns a colored display name of stack != null. Can be in italic format if stack has display tag. */
|
||||
protected String getGoodDisplayName(ItemStack stack) {
|
||||
if (stack.hasDisplayName()) {
|
||||
return EnumChatFormatting.ITALIC.toString() + stack.getRarity().rarityColor + stack.getDisplayName();
|
||||
} else {
|
||||
return stack.getRarity().rarityColor.toString() + stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns blue colored item count display with format like in WAILA. */
|
||||
protected String getItemCountDisplay(int maxStackSize, int itemCount) {
|
||||
int numStack = itemCount / maxStackSize;
|
||||
int remainder = itemCount - numStack * maxStackSize;
|
||||
|
||||
String itemCountDisplay;
|
||||
|
||||
if (numStack > 0) {
|
||||
if (remainder > 0) itemCountDisplay = "[" + numStack + "x" + maxStackSize + " + " + remainder + "]";
|
||||
else itemCountDisplay = "[" + numStack + "x" + maxStackSize + "]";
|
||||
} else {
|
||||
itemCountDisplay = "[" + remainder + "]";
|
||||
}
|
||||
|
||||
return EnumChatFormatting.BLUE + itemCountDisplay;
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -3,16 +3,11 @@ package com.jaquadro.minecraft.storagedrawers.item.pack;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.pack.BlockSortingDrawersPack;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemSortingDrawersPack extends ItemDrawersPack {
|
||||
|
||||
public ItemSortingDrawersPack(Block block) {
|
||||
@@ -25,9 +20,8 @@ public class ItemSortingDrawersPack extends ItemDrawersPack {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(itemStack, player, list, par4);
|
||||
protected void addDescriptionInformation(int drawerCapacity, List list) {
|
||||
super.addDescriptionInformation(drawerCapacity, list);
|
||||
list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocalFormatted("storageDrawers.waila.sorting"));
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,25 @@ tile.trim.big_oak.name=Dark Oak Trim
|
||||
|
||||
storageDrawers.drawers.description=Holds %d stacks per drawer
|
||||
storageDrawers.drawers.sealed=Contents sealed within
|
||||
storageDrawers.drawers.sealed.locked=Locked
|
||||
storageDrawers.drawers.sealed.unlocked=Unlocked
|
||||
storageDrawers.drawers.sealed.access_public=Public
|
||||
storageDrawers.drawers.sealed.access_owner=Protected
|
||||
storageDrawers.drawers.sealed.hideItemLabel=Hide item labels
|
||||
storageDrawers.drawers.sealed.showItemLabel=Show item labels
|
||||
storageDrawers.drawers.sealed.hideItemQuantity=Hide item quantities
|
||||
storageDrawers.drawers.sealed.showItemQuantity=Show item quantities
|
||||
storageDrawers.drawers.sealed.drawerList=Drawers:
|
||||
storageDrawers.drawers.sealed.compDrawerList=Compacting Drawers:
|
||||
storageDrawers.drawers.sealed.upgradeList=Upgrades:
|
||||
storageDrawers.drawers.sealed.materialList=Materials:
|
||||
storageDrawers.drawers.sealed.upgradeNone=<None>
|
||||
storageDrawers.drawers.sealed.drawerEmpty=<Empty>
|
||||
storageDrawers.drawers.sealed.materialNone=<None>
|
||||
storageDrawers.drawers.sealed.materialSide=Side:
|
||||
storageDrawers.drawers.sealed.materialFront=Front:
|
||||
storageDrawers.drawers.sealed.materialTrim=Trim:
|
||||
storageDrawers.drawers.sealed.descriptionShift=[Hold LSHIFT to see more info]
|
||||
storageDrawers.upgrade.description=Increases storage to %d times base value
|
||||
storageDrawers.controller.description=Interact with a bank of connected drawers
|
||||
storageDrawers.controllerSlave.description=Extra attach points for controllers
|
||||
|
||||
Reference in new issue
Block a user