mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-12 00:17:57 +00:00
Quantity key implementation (#40)
This commit is contained in:
22 files changed
+362
-2
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
|
||||
|
||||
public interface IQuantifiable {
|
||||
|
||||
/**
|
||||
* Gets whether the drawer has the quantifiable attribute. The quantifiable attribute instructs the drawer to render
|
||||
* the quantity of the item contained in the drawer.
|
||||
*/
|
||||
boolean isQuantified();
|
||||
|
||||
boolean setIsQuantified(boolean state);
|
||||
}
|
||||
@@ -141,6 +141,9 @@ public class BlockController extends BlockContainer implements INetworked {
|
||||
te.toggleProtection(player.getGameProfile(), provider);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (item.getItem() == ModItems.quantifyKey) {
|
||||
if (!world.isRemote) te.toggleQuantify(player.getGameProfile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,6 +392,9 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
} else if (item.getItem() == ModItems.shroudKey) {
|
||||
tileDrawers.setIsShrouded(!tileDrawers.isShrouded());
|
||||
return true;
|
||||
} else if (item.getItem() == ModItems.quantifyKey) {
|
||||
tileDrawers.setIsQuantified(!tileDrawers.isQuantified());
|
||||
return true;
|
||||
} else if (item.getItem() instanceof ItemPersonalKey) {
|
||||
String securityKey = ((ItemPersonalKey) item.getItem())
|
||||
.getSecurityProviderKey(item.getItemDamage());
|
||||
|
||||
+29
@@ -36,6 +36,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IPriorityGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.ISmartGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IQuantifiable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
@@ -300,6 +301,34 @@ public class TileEntityController extends TileEntity
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleQuantify(GameProfile profile) {
|
||||
IQuantifiable template = null;
|
||||
boolean state = false;
|
||||
|
||||
for (StorageRecord record : storage.values()) {
|
||||
if (record.storage == null) continue;
|
||||
|
||||
if (record.storage instanceof IProtectable) {
|
||||
if (!SecurityManager.hasAccess(profile, (IProtectable) record.storage)) continue;
|
||||
}
|
||||
|
||||
for (int i = 0, n = record.storage.getDrawerCount(); i < n; i++) {
|
||||
if (!record.storage.isDrawerEnabled(i)) continue;
|
||||
|
||||
IDrawer drawer = record.storage.getDrawer(i);
|
||||
if (!(drawer instanceof IQuantifiable)) continue;
|
||||
|
||||
IQuantifiable quantifiableStorage = (IQuantifiable) drawer;
|
||||
if (template == null) {
|
||||
template = quantifiableStorage;
|
||||
state = !template.isQuantified();
|
||||
}
|
||||
|
||||
quantifiableStorage.setIsQuantified(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleLock(EnumSet<LockAttribute> attributes, LockAttribute key, GameProfile profile) {
|
||||
ILockable template = null;
|
||||
boolean state = false;
|
||||
|
||||
@@ -49,6 +49,7 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
private int direction;
|
||||
private int drawerCapacity = 1;
|
||||
private boolean shrouded = false;
|
||||
private boolean quantified = false;
|
||||
private boolean taped = false;
|
||||
private boolean hideUpgrade = false;
|
||||
private boolean downgraded = false;
|
||||
@@ -243,6 +244,23 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isQuantified() {
|
||||
if (!StorageDrawers.config.cache.enableQuantifyUpgrades) return false;
|
||||
|
||||
return quantified;
|
||||
}
|
||||
|
||||
public void setIsQuantified(boolean quantified) {
|
||||
if (this.quantified != quantified) {
|
||||
this.quantified = quantified;
|
||||
|
||||
if (worldObj != null && !worldObj.isRemote) {
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwner() {
|
||||
if (!StorageDrawers.config.cache.enablePersonalUpgrades) return null;
|
||||
@@ -651,6 +669,9 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
shrouded = false;
|
||||
if (tag.hasKey("Shr")) shrouded = tag.getBoolean("Shr");
|
||||
|
||||
quantified = false;
|
||||
if (tag.hasKey("Qua")) quantified = tag.getBoolean("Qua");
|
||||
|
||||
owner = null;
|
||||
if (tag.hasKey("Own")) owner = UUID.fromString(tag.getString("Own"));
|
||||
|
||||
@@ -703,6 +724,8 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
|
||||
if (shrouded) tag.setBoolean("Shr", shrouded);
|
||||
|
||||
if (quantified) tag.setBoolean("Qua", quantified);
|
||||
|
||||
if (owner != null) tag.setString("Own", owner.toString());
|
||||
|
||||
if (securityKey != null) tag.setString("Sec", securityKey);
|
||||
|
||||
+11
@@ -649,6 +649,17 @@ public class TileEntityDrawersComp extends TileEntityDrawers {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuantifiedSlot(int slot) {
|
||||
return isQuantified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setIsSlotQuantifiable(int slot, boolean state) {
|
||||
setIsQuantified(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked(int slot, LockAttribute attr) {
|
||||
return TileEntityDrawersComp.this.isLocked(attr);
|
||||
|
||||
+11
@@ -68,6 +68,17 @@ public class TileEntityDrawersStandard extends TileEntityDrawers {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuantified(int slot) {
|
||||
return TileEntityDrawersStandard.this.isQuantified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setIsQuantified(int slot, boolean state) {
|
||||
TileEntityDrawersStandard.this.setIsQuantified(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageUnlimited(int slot) {
|
||||
return TileEntityDrawersStandard.this.isUnlimited();
|
||||
|
||||
+100
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -32,6 +33,7 @@ import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.util.CountFormatter;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -267,6 +269,27 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer {
|
||||
// Swallow exception
|
||||
}
|
||||
|
||||
if (StorageDrawers.config.cache.enableQuantifyUpgrades && tileDrawers.isQuantified()) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
double dx = tile.xCoord + 0.5 - player.posX;
|
||||
double dy = tile.yCoord + 0.5 - player.posY;
|
||||
double dz = tile.zCoord + 0.5 - player.posZ;
|
||||
double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
float alpha = 1.0f;
|
||||
if (distance > 4.0) {
|
||||
alpha = Math.max(1.0f - (float) ((distance - 4.0) / 6.0), 0.05f);
|
||||
}
|
||||
|
||||
if (distance < 10.0) {
|
||||
for (int i = 0; i < tileDrawers.getDrawerCount(); i++) {
|
||||
if (!tileDrawers.isDrawerEnabled(i)) continue;
|
||||
|
||||
drawDrawerTexts(tileDrawers, i, side, depth, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mc.gameSettings.fancyGraphics = cache;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
@@ -349,6 +372,83 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawDrawerTexts(TileEntityDrawers tile, int slot, ForgeDirection side, float depth, float alpha) {
|
||||
BlockDrawers block = (BlockDrawers) tile.getBlockType();
|
||||
int drawerCount = tile.getDrawerCount();
|
||||
|
||||
float offsetX = 8;
|
||||
float offsetY = 14;
|
||||
|
||||
switch (drawerCount) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
offsetY = (slot == 0) ? 6 : 14;
|
||||
break;
|
||||
case 3:
|
||||
switch (slot) {
|
||||
case 0:
|
||||
offsetY = 7;
|
||||
break;
|
||||
case 1:
|
||||
offsetX = 4;
|
||||
break;
|
||||
case 2:
|
||||
offsetX = 12;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch (slot) {
|
||||
case 0:
|
||||
offsetX = 4;
|
||||
offsetY = 6;
|
||||
break;
|
||||
case 1:
|
||||
offsetX = 4;
|
||||
break;
|
||||
case 2:
|
||||
offsetX = 12;
|
||||
offsetY = 6;
|
||||
break;
|
||||
case 3:
|
||||
offsetX = 12;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
renderText(
|
||||
CountFormatter.format(this.func_147498_b(), tile.getDrawer(slot)),
|
||||
side,
|
||||
offsetX,
|
||||
offsetY,
|
||||
1f - depth + block.getTrimDepth() - 0.005f,
|
||||
alpha);
|
||||
}
|
||||
|
||||
private void renderText(String renderString, ForgeDirection side, float offsetX, float offsetY, float offsetZ,
|
||||
float alpha) {
|
||||
int stringWidth = this.func_147498_b().getStringWidth(renderString);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
this.alignRendering(side);
|
||||
this.moveRendering(0.125f, offsetX, offsetY, offsetZ);
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
this.func_147498_b()
|
||||
.drawString(renderString, -stringWidth / 2, 0, (int) (255 * alpha) << 24 | 255 << 16 | 255 << 8 | 255);
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderFancyItem(ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side,
|
||||
float depth) {
|
||||
int drawerCount = tile.getDrawerCount();
|
||||
|
||||
@@ -62,6 +62,7 @@ public class ConfigManager {
|
||||
public boolean enableVoidUpgrades;
|
||||
public boolean enableCreativeUpgrades;
|
||||
public boolean enableShroudUpgrades;
|
||||
public boolean enableQuantifyUpgrades;
|
||||
public boolean enablePersonalUpgrades;
|
||||
public boolean enableSortingUpgrades;
|
||||
public boolean enableRedstoneUpgrades;
|
||||
@@ -341,6 +342,8 @@ public class ConfigManager {
|
||||
.setLanguageKey(LANG_PREFIX + "prop.enableCreativeUpgrades").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableShroudUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableShroudUpgrades", true)
|
||||
.setLanguageKey(LANG_PREFIX + "prop.enableShroudUpgrades").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableQuantifyUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableQuantifyUpgrades", true)
|
||||
.setLanguageKey(LANG_PREFIX + "prop.enableQuantifyUpgrades").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enablePersonalUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enablePersonalUpgrades", true)
|
||||
.setLanguageKey(LANG_PREFIX + "prop.enablePersonalUpgrades").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableSortingUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableSortingUpgrades", true)
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.item.Item;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemQuantifyKey;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemShroudKey;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemTape;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgrade;
|
||||
@@ -27,6 +28,7 @@ public class ModItems {
|
||||
public static ItemUpgradeRedstone upgradeRedstone;
|
||||
public static ItemShroudKey shroudKey;
|
||||
public static ItemPersonalKey personalKey;
|
||||
public static ItemQuantifyKey quantifyKey;
|
||||
public static ItemTape tape;
|
||||
public static ItemUpgradeDowngrade upgradeDowngrade;
|
||||
|
||||
@@ -44,6 +46,7 @@ public class ModItems {
|
||||
|
||||
shroudKey = new ItemShroudKey(makeName("shroudKey"));
|
||||
personalKey = new ItemPersonalKey(makeName("personalKey"));
|
||||
quantifyKey = new ItemQuantifyKey(makeName("quantifyKey"));
|
||||
tape = new ItemTape(makeName("tape"));
|
||||
|
||||
GameRegistry.registerItem(upgradeTemplate, "upgradeTemplate");
|
||||
@@ -58,6 +61,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(upgradeRedstone, "upgradeRedstone");
|
||||
if (StorageDrawers.config.cache.enableLockUpgrades) GameRegistry.registerItem(upgradeLock, "upgradeLock");
|
||||
if (StorageDrawers.config.cache.enableShroudUpgrades) GameRegistry.registerItem(shroudKey, "shroudKey");
|
||||
if (StorageDrawers.config.cache.enableQuantifyUpgrades) GameRegistry.registerItem(quantifyKey, "quantifyKey");
|
||||
if (StorageDrawers.config.cache.enablePersonalUpgrades) GameRegistry.registerItem(personalKey, "personalKey");
|
||||
if (StorageDrawers.config.cache.enableTape) GameRegistry.registerItem(tape, "tape");
|
||||
GameRegistry.registerItem(upgradeDowngrade, "upgradeDowngrade");
|
||||
|
||||
@@ -398,6 +398,11 @@ public class ModRecipes {
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.personalKey), ModItems.upgradeLock, Items.name_tag);
|
||||
}
|
||||
|
||||
if (config.cache.enableQuantifyUpgrades) {
|
||||
GameRegistry
|
||||
.addShapelessRecipe(new ItemStack(ModItems.quantifyKey), ModItems.upgradeLock, Items.writable_book);
|
||||
}
|
||||
|
||||
if (config.cache.enableTape) {
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(
|
||||
|
||||
@@ -200,6 +200,7 @@ public class ModRecipes {
|
||||
lockUpgradeRecipes(); // Drawer key
|
||||
shroudKeyUpgradeRecipes(); // Concealment Key
|
||||
personalKeyUpgradeRecipes(); // Personal Key
|
||||
quantifyKeyUpgradeRecipes(); // Quantify Key
|
||||
|
||||
// Packing Tape
|
||||
packingTapeRecipes(); // Packing Tape
|
||||
@@ -472,6 +473,7 @@ public class ModRecipes {
|
||||
|| config.cache.enablePersonalUpgrades
|
||||
|| config.cache.enableRedstoneUpgrades
|
||||
|| config.cache.enableShroudUpgrades
|
||||
|| config.cache.enableQuantifyUpgrades
|
||||
|| config.cache.enableSortingUpgrades
|
||||
|| config.cache.enableStorageUpgrades
|
||||
|| config.cache.enableVoidUpgrades))
|
||||
@@ -757,6 +759,15 @@ public class ModRecipes {
|
||||
.addTo(assemblerRecipes);
|
||||
}
|
||||
|
||||
private static void quantifyKeyUpgradeRecipes() {
|
||||
if (!config.cache.enableQuantifyUpgrades) return;
|
||||
|
||||
// Quantify Key
|
||||
GTValues.RA.stdBuilder().itemInputs(upgradeLock, new ItemStack(Items.writable_book))
|
||||
.itemOutputs(new ItemStack(ModItems.quantifyKey)).duration(5 * SECONDS).eut(TierEU.RECIPE_LV)
|
||||
.addTo(assemblerRecipes);
|
||||
}
|
||||
|
||||
private static void packingTapeRecipes() {
|
||||
if (!config.cache.enableTape) return;
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemQuantifyKey extends Item {
|
||||
|
||||
public ItemQuantifyKey(String name) {
|
||||
setUnlocalizedName(name);
|
||||
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
setTextureName(StorageDrawers.MOD_ID + ":drawer_key_quantify");
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
String name = getUnlocalizedName(itemStack);
|
||||
list.add(StatCollector.translateToLocalFormatted(name + ".description"));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap getAttributeModifiers(ItemStack item) {
|
||||
Multimap multimap = super.getAttributeModifiers(item);
|
||||
multimap.put(
|
||||
SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(field_111210_e, "Weapon modifier", (double) 2, 0));
|
||||
return multimap;
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IFractionalDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IQuantifiable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
|
||||
public class CompDrawerData extends BaseDrawerData implements IFractionalDrawer, IVoidable, IShroudable, ILockable {
|
||||
public class CompDrawerData extends BaseDrawerData
|
||||
implements IFractionalDrawer, IVoidable, IShroudable, ILockable, IQuantifiable {
|
||||
|
||||
private static final ItemStack nullStack = new ItemStack((Item) null);
|
||||
|
||||
@@ -142,6 +144,16 @@ public class CompDrawerData extends BaseDrawerData implements IFractionalDrawer,
|
||||
return central.setIsSlotShrouded(slot, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuantified() {
|
||||
return central.isQuantifiedSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setIsQuantified(boolean state) {
|
||||
return central.setIsSlotQuantifiable(slot, state);
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isLocked(LockAttribute attr) {
|
||||
return central.isLocked(slot, attr);
|
||||
|
||||
+10
@@ -63,6 +63,16 @@ public class DefaultStorageProvider implements IStorageProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuantified(int slot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setIsQuantified(int slot, boolean state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageUnlimited(int slot) {
|
||||
return false;
|
||||
|
||||
@@ -8,11 +8,12 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IQuantifiable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
|
||||
public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable, ILockable {
|
||||
public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable, ILockable, IQuantifiable {
|
||||
|
||||
private static final ItemStack nullStack = new ItemStack((Item) null);
|
||||
|
||||
@@ -207,6 +208,16 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
|
||||
return storageProvider.setIsShrouded(slot, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuantified() {
|
||||
return storageProvider.isQuantified(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setIsQuantified(boolean state) {
|
||||
return storageProvider.setIsQuantified(slot, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked(LockAttribute attr) {
|
||||
return storageProvider.isLocked(slot, attr);
|
||||
|
||||
@@ -38,6 +38,10 @@ public interface ICentralInventory {
|
||||
|
||||
public boolean setIsSlotShrouded(int slot, boolean state);
|
||||
|
||||
public boolean isQuantifiedSlot(int slot);
|
||||
|
||||
public boolean setIsSlotQuantifiable(int slot, boolean state);
|
||||
|
||||
public boolean isLocked(int slot, LockAttribute attr);
|
||||
|
||||
public void readFromNBT(int slot, NBTTagCompound tag);
|
||||
|
||||
@@ -22,6 +22,10 @@ public interface IStorageProvider {
|
||||
|
||||
public boolean setIsShrouded(int slot, boolean state);
|
||||
|
||||
public boolean isQuantified(int slot);
|
||||
|
||||
public boolean setIsQuantified(int slot, boolean state);
|
||||
|
||||
public boolean isStorageUnlimited(int slot);
|
||||
|
||||
public boolean isVendingUnlimited(int slot);
|
||||
|
||||
@@ -8,5 +8,7 @@ public interface IUpgradeProvider {
|
||||
|
||||
boolean isShrouded();
|
||||
|
||||
boolean isQuantified();
|
||||
|
||||
boolean isDowngraded();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.util;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
|
||||
public class CountFormatter {
|
||||
|
||||
public static String format(FontRenderer font, IDrawer drawer) {
|
||||
return formatApprox(font, drawer);
|
||||
}
|
||||
|
||||
public static String formatStackNotation(IDrawer drawer) {
|
||||
if (drawer == null || drawer.isEmpty()) return "";
|
||||
|
||||
String text;
|
||||
int stacks = drawer.getStoredItemCount() / drawer.getStoredItemStackSize();
|
||||
int remainder = drawer.getStoredItemCount() - (stacks * drawer.getStoredItemStackSize());
|
||||
|
||||
if (stacks > 0 && remainder > 0) text = stacks + "x" + drawer.getStoredItemStackSize() + "+" + remainder;
|
||||
else if (stacks > 0) text = stacks + "x" + drawer.getStoredItemStackSize();
|
||||
else text = String.valueOf(remainder);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String formatExact(IDrawer drawer) {
|
||||
if (drawer == null || drawer.isEmpty()) return "";
|
||||
|
||||
return String.valueOf(drawer.getStoredItemCount());
|
||||
}
|
||||
|
||||
public static String formatApprox(FontRenderer font, IDrawer drawer) {
|
||||
if (drawer == null || drawer.isEmpty()) return "";
|
||||
|
||||
return formatApprox(font, drawer.getStoredItemCount());
|
||||
}
|
||||
|
||||
public static String formatApprox(FontRenderer font, int count) {
|
||||
String text;
|
||||
|
||||
if (count >= 1000000000) text = String.format("%.1fG", count / 1000000000f);
|
||||
else if (count >= 100000000) text = String.format("%.0fM", count / 1000000f);
|
||||
else if (count >= 1000000) text = String.format("%.1fM", count / 1000000f);
|
||||
else if (count >= 100000) text = String.format("%.0fK", count / 1000f);
|
||||
else if (count >= 10000) text = String.format("%.1fK", count / 1000f);
|
||||
else text = String.valueOf(count);
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,8 @@ item.storagedrawers.upgradeSorting.name=Sorting Upgrade
|
||||
item.storagedrawers.upgradeSorting.description=For Refined Relocation
|
||||
item.storagedrawers.shroudKey.name=Concealment Key
|
||||
item.storagedrawers.shroudKey.description=Show or hide item labels
|
||||
item.storagedrawers.quantifyKey.name=Quantify Key
|
||||
item.storagedrawers.quantifyKey.description=Show or hide item quantities
|
||||
item.storagedrawers.personalKey.name=Personal Key
|
||||
item.storagedrawers.personalKey.default.name=Personal Key
|
||||
item.storagedrawers.personalKey.default.description=Protect access from other players
|
||||
@@ -167,6 +169,7 @@ storageDrawers.config.prop.enableIndicatorUpgrades=Enable Indicator Upgrades
|
||||
storageDrawers.config.prop.enableStorageUpgrades=Enable Storage Upgrades
|
||||
storageDrawers.config.prop.enableLockUpgrades=Enable Drawer Locking
|
||||
storageDrawers.config.prop.enableShroudUpgrades=Enable Item Concealing
|
||||
storageDrawers.config.prop.enableQuantifyUpgrades=Enable Show Drawer Quantities
|
||||
storageDrawers.config.prop.enablePersonalUpgrades=Enable Access Protection
|
||||
storageDrawers.config.prop.enableVoidUpgrades=Enable Void Upgrade
|
||||
storageDrawers.config.prop.enableCreativeUpgrades=Enable Creative Upgrade
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 333 B |
Reference in new issue
Block a user