Creative storage and vending upgrades

This commit is contained in:
Justin Aquadro committed 2015-11-27 02:24:15 -05:00
1 parent f23102c96e
commit bbad2a9a81
17 files changed
+187 -7

No files matched your search

@@ -24,6 +24,10 @@ item.storagedrawers.upgradeLock.name=Drawer Key
item.storagedrawers.upgradeLock.description=Locks and unlocks drawers
item.storagedrawers.upgradeVoid.name=Void Upgrade
item.storagedrawers.upgradeVoid.description=Destroys excess items
item.storagedrawers.upgradeCreative.store.name=Creative Storage Upgrade
item.storagedrawers.upgradeCreative.store.description=Near-infinite storage
item.storagedrawers.upgradeCreative.vend.name=Creative Vending Upgrade
item.storagedrawers.upgradeCreative.vend.description=Unlimited item withdrawal
item.storagedrawers.upgradeSorting.name=Sorting Upgrade
item.storagedrawers.upgradeSorting.description=For Refined Relocation
item.storagedrawers.shroudKey.name=Concealment Key
@@ -127,6 +131,7 @@ storageDrawers.config.prop.enableStorageUpgrades=Enable Storage Upgrades
storageDrawers.config.prop.enableLockUpgrades=Enable Drawer Locking
storageDrawers.config.prop.enableShroudUpgrades=Enable Item Concealing
storageDrawers.config.prop.enableVoidUpgrades=Enable Void Upgrade
storageDrawers.config.prop.enableCreativeUpgrades=Enable Creative Upgrade
storageDrawers.config.prop.enableSortingUpgrades=Enable Sorting Upgrade
storageDrawers.config.prop.enableSortingUpgrades.tooltip=Refined Relocation must be loaded.
storageDrawers.config.prop.renderStorageUpgrades=Render Storage Upgrades
Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

@@ -140,6 +140,22 @@ public class BlockController extends BlockContainer implements INetworked
return true;
}
@Override
public boolean rotateBlock (World world, int x, int y, int z, ForgeDirection axis) {
TileEntityController tile = getTileEntitySafe(world, x, y, z);
if (tile.getDirection() == axis.ordinal())
return false;
if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN)
return false;
tile.setDirection(axis.ordinal());
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if (getTileEntity(world, x, y, z) == null)
@@ -252,7 +252,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
if (item != null && item.getItem() != null) {
if (item.getItem() == ModItems.upgrade || item.getItem() == ModItems.upgradeStatus || item.getItem() == ModItems.upgradeVoid) {
if (item.getItem() == ModItems.upgrade || item.getItem() == ModItems.upgradeStatus || item.getItem() == ModItems.upgradeVoid || item.getItem() == ModItems.upgradeCreative) {
if (!tileDrawers.addUpgrade(item)) {
player.addChatMessage(new ChatComponentTranslation("storagedrawers.msg.maxUpgrades"));
return false;
@@ -275,6 +275,30 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
return false;
}
public boolean isUnlimited () {
if (!StorageDrawers.config.cache.enableCreativeUpgrades)
return false;
for (ItemStack stack : upgrades) {
if (stack != null && stack.getItem() == ModItems.upgradeCreative)
return true;
}
return false;
}
public boolean isVending () {
if (!StorageDrawers.config.cache.enableCreativeUpgrades)
return false;
for (ItemStack stack : upgrades) {
if (stack != null && stack.getItem() == ModItems.upgradeCreative && stack.getItemDamage() == 1)
return true;
}
return false;
}
public boolean isSorting () {
return false;
}
@@ -7,6 +7,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
import com.jaquadro.minecraft.storagedrawers.config.CompTierRegistry;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationModule;
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
import com.jaquadro.minecraft.storagedrawers.storage.*;
import cpw.mods.fml.common.FMLLog;
@@ -534,6 +535,9 @@ public class TileEntityDrawersComp extends TileEntityDrawers
if (convRate == null || convRate[slot] == 0)
return 0;
if (TileEntityDrawersComp.this.isVending())
return Integer.MAX_VALUE;
return pooledCount / convRate[slot];
}
@@ -542,6 +546,9 @@ public class TileEntityDrawersComp extends TileEntityDrawers
if (convRate == null || convRate[slot] == 0)
return;
if (TileEntityDrawersComp.this.isVending())
return;
int oldCount = pooledCount;
pooledCount = (pooledCount % convRate[slot]) + convRate[slot] * amount;
@@ -567,6 +574,12 @@ public class TileEntityDrawersComp extends TileEntityDrawers
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
return 0;
if (TileEntityDrawersComp.this.isUnlimited() || TileEntityDrawersComp.this.isVending()) {
if (convRate == null || protoStack[slot] == null || convRate[slot] == 0)
return Integer.MAX_VALUE;
return Integer.MAX_VALUE / convRate[slot];
}
return protoStack[slot].getItem().getItemStackLimit(protoStack[slot]) * getStackCapacity(slot);
}
@@ -575,6 +588,12 @@ public class TileEntityDrawersComp extends TileEntityDrawers
if (itemPrototype == null || itemPrototype.getItem() == null)
return 0;
if (TileEntityDrawersComp.this.isUnlimited() || TileEntityDrawersComp.this.isVending()) {
if (convRate == null || protoStack[slot] == null || convRate[slot] == 0)
return Integer.MAX_VALUE;
return Integer.MAX_VALUE / convRate[slot];
}
if (convRate == null || protoStack[0] == null || convRate[0] == 0)
return itemPrototype.getItem().getItemStackLimit(itemPrototype) * getBaseStackCapacity();
@@ -586,6 +605,9 @@ public class TileEntityDrawersComp extends TileEntityDrawers
@Override
public int getRemainingCapacity (int slot) {
if (TileEntityDrawersComp.this.isVending())
return Integer.MAX_VALUE;
return getMaxCapacity(slot) - getStoredItemCount(slot);
}
@@ -65,5 +65,15 @@ public class TileEntityDrawersStandard extends TileEntityDrawers
TileEntityDrawersStandard.this.setIsShrouded(state);
return true;
}
@Override
public boolean isStorageUnlimited (int slot) {
return TileEntityDrawersStandard.this.isUnlimited();
}
@Override
public boolean isVendingUnlimited (int slot) {
return TileEntityDrawersStandard.this.isVending();
}
}
}
@@ -338,7 +338,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
return x;
int step = block.getIndSteps() > 0 ? block.getIndSteps() : 1000;
float fillAmt = (float)(step * count / cap) / step;
float fillAmt = (float)((double)step * count / cap) / step;
return x + (w * fillAmt);
}
@@ -58,6 +58,7 @@ public class ConfigManager
public boolean enableStorageUpgrades;
public boolean enableLockUpgrades;
public boolean enableVoidUpgrades;
public boolean enableCreativeUpgrades;
public boolean enableShroudUpgrades;
public boolean enableSortingUpgrades;
public boolean renderStorageUpgrades;
@@ -224,6 +225,7 @@ public class ConfigManager
cache.enableStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableStorageUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableStorageUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableLockUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableLockUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableLockUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableVoidUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableVoidUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableVoidUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableCreativeUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableCreativeUpgrades", true).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.enableSortingUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableSortingUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableSortingUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableTape = config.get(Configuration.CATEGORY_GENERAL, "enableTape", true).setLanguageKey(LANG_PREFIX + "prop.enableTape").setRequiresMcRestart(true).getBoolean();
@@ -12,6 +12,7 @@ public class ModItems
public static ItemUpgradeStatus upgradeStatus;
public static ItemUpgradeLock upgradeLock;
public static ItemUpgradeVoid upgradeVoid;
public static ItemUpgradeCreative upgradeCreative;
public static ItemShroudKey shroudKey;
public static ItemTape tape;
@@ -21,6 +22,7 @@ public class ModItems
upgradeStatus = new ItemUpgradeStatus(makeName("upgradeStatus"));
upgradeLock = new ItemUpgradeLock(makeName("upgradeLock"));
upgradeVoid = new ItemUpgradeVoid(makeName("upgradeVoid"));
upgradeCreative = new ItemUpgradeCreative(makeName("upgradeCreative"));
shroudKey = new ItemShroudKey(makeName("shroudKey"));
tape = new ItemTape(makeName("tape"));
@@ -32,6 +34,8 @@ public class ModItems
GameRegistry.registerItem(upgradeStatus, "upgradeStatus");
if (StorageDrawers.config.cache.enableVoidUpgrades)
GameRegistry.registerItem(upgradeVoid, "upgradeVoid");
if (StorageDrawers.config.cache.enableCreativeUpgrades)
GameRegistry.registerItem(upgradeCreative, "upgradeCreative");
if (StorageDrawers.config.cache.enableLockUpgrades)
GameRegistry.registerItem(upgradeLock, "upgradeLock");
if (StorageDrawers.config.cache.enableShroudUpgrades)
@@ -76,7 +76,9 @@ public class Waila extends IntegrationModule
for (int j = 0, n = handlers.size(); j < n; j++)
stackName = handlers.get(j).transformItemName(drawer, stackName);
if (drawer instanceof IFractionalDrawer && ((IFractionalDrawer) drawer).getConversionRate() > 1)
if (drawer.getStoredItemCount() == Integer.MAX_VALUE)
name = stackName + " [\u221E]";
else if (drawer instanceof IFractionalDrawer && ((IFractionalDrawer) drawer).getConversionRate() > 1)
name = stackName + ((i == 0) ? " [" : " [+") + ((IFractionalDrawer) drawer).getStoredItemRemainder() + "]";
else if (StorageDrawers.config.cache.stackRemainderWaila) {
int stacks = drawer.getStoredItemCount() / drawer.getStoredItemStackSize();
@@ -0,0 +1,73 @@
package com.jaquadro.minecraft.storagedrawers.item;
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;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import java.util.List;
public class ItemUpgradeCreative extends Item
{
public static final String[] iconNames = new String[] { "store", "vend" };
@SideOnly(Side.CLIENT)
private IIcon[] icons;
public ItemUpgradeCreative (String name) {
setUnlocalizedName(name);
setHasSubtypes(true);
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
setMaxDamage(0);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage (int meta) {
return icons[MathHelper.clamp_int(meta, 0, iconNames.length - 1)];
}
@Override
public String getUnlocalizedName (ItemStack itemStack) {
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, iconNames.length - 1);
if (iconNames[meta] == null)
return super.getUnlocalizedName();
return super.getUnlocalizedName() + "." + iconNames[meta];
}
@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"));
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems (Item item, CreativeTabs creativeTabs, List list) {
for (int i = 0, n = iconNames.length; i < n; i++) {
if (iconNames[i] != null)
list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IIconRegister register) {
icons = new IIcon[iconNames.length];
for (int i = 0, n = iconNames.length; i < n; i++) {
if (iconNames[i] != null)
icons[i] = register.registerIcon(StorageDrawers.MOD_ID + ":upgrade_creative_" + iconNames[i]);
}
}
}
@@ -1,13 +1,9 @@
package com.jaquadro.minecraft.storagedrawers.item;
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;
import net.minecraft.entity.EntityLivingBase;
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;
@@ -57,6 +57,16 @@ public class DefaultStorageProvider implements IStorageProvider
return false;
}
@Override
public boolean isStorageUnlimited (int slot) {
return false;
}
@Override
public boolean isVendingUnlimited (int slot) {
return false;
}
@Override
public void markAmountDirty (int slot) {
if (tile.getWorldObj().isRemote)
@@ -71,6 +71,9 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
@Override
public int getStoredItemCount () {
if (protoStack != nullStack && storageProvider.isVendingUnlimited(slot))
return Integer.MAX_VALUE;
return count;
}
@@ -80,6 +83,9 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
}
public void setStoredItemCount (int amount, boolean mark, boolean clearOnEmpty) {
if (storageProvider.isVendingUnlimited(slot))
return;
count = amount;
if (count > getMaxCapacity())
count = getMaxCapacity();
@@ -106,6 +112,9 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
if (itemPrototype == null || itemPrototype.getItem() == null)
return 0;
if (storageProvider.isStorageUnlimited(slot) || storageProvider.isVendingUnlimited(slot))
return Integer.MAX_VALUE;
return itemPrototype.getItem().getItemStackLimit(itemPrototype) * storageProvider.getSlotStackCapacity(slot);
}
@@ -114,6 +123,9 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable
if (protoStack.getItem() == null)
return 0;
if (storageProvider.isVendingUnlimited(slot))
return Integer.MAX_VALUE;
return getMaxCapacity() - getStoredItemCount();
}
@@ -21,6 +21,10 @@ public interface IStorageProvider
public boolean setIsShrouded (int slot, boolean state);
public boolean isStorageUnlimited (int slot);
public boolean isVendingUnlimited (int slot);
public void markAmountDirty (int slot);
public void markDirty (int slot);