mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-22 13:09:47 +00:00
Work on void upgrade
This commit is contained in:
1 parent
4593c6d7a6
commit
6a9ca57be5
14 files changed
+121
-6
No files matched your search
@@ -13,6 +13,8 @@ item.upgradeStatus.level2.name=Status Upgrade (II)
|
||||
item.upgradeStatus.level2.description=Shows fill level
|
||||
item.upgradeLock.name=Drawer Key
|
||||
item.upgradeLock.description=Locks and unlocks drawers
|
||||
item.upgradeVoid.name=Void Upgrade
|
||||
item.upgradeVoid.description=Destroys excess items
|
||||
|
||||
# Blocks
|
||||
tile.fullDrawers1.oak.name=Oak Drawer
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 482 B After Width: | Height: | Size: 482 B |
@@ -226,6 +226,17 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
tileDrawers.setIsLocked(!tileDrawers.isLocked());
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (item.getItem() == ModItems.upgradeVoid && !tileDrawers.isVoid()) {
|
||||
tileDrawers.setVoid(true);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
if (player != null && !player.capabilities.isCreativeMode) {
|
||||
if (--item.stackSize <= 0)
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroupInteractive
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.ISideManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.inventory.StorageInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
|
||||
import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -28,7 +29,7 @@ import org.apache.logging.log4j.Level;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class TileEntityDrawers extends TileEntity implements IDrawerGroupInteractive, ISidedInventory
|
||||
public abstract class TileEntityDrawers extends TileEntity implements IDrawerGroupInteractive, ISidedInventory, IUpgradeProvider
|
||||
{
|
||||
private IDrawer[] drawers;
|
||||
private IDrawerInventory inventory;
|
||||
@@ -40,6 +41,7 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
private int storageLevel = 1;
|
||||
private int statusLevel = 0;
|
||||
private boolean locked = false;
|
||||
private boolean voidUpgrade = false;
|
||||
|
||||
private long lastClickTime;
|
||||
private UUID lastClickUUID;
|
||||
@@ -61,7 +63,7 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
for (int i = 0; i < drawerCount; i++)
|
||||
drawers[i] = createDrawer(i);
|
||||
|
||||
inventory = new StorageInventory(this, getSideManager());
|
||||
inventory = new StorageInventory(this, getSideManager(), this);
|
||||
}
|
||||
|
||||
public int getDirection () {
|
||||
@@ -125,6 +127,17 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVoid () {
|
||||
if (!StorageDrawers.config.cache.enableVoidUpgrades)
|
||||
return false;
|
||||
|
||||
return voidUpgrade;
|
||||
}
|
||||
|
||||
public void setVoid (boolean isVoid) {
|
||||
this.voidUpgrade = isVoid;
|
||||
}
|
||||
|
||||
public ItemStack takeItemsFromSlot (int slot, int count) {
|
||||
if (slot < 0 || slot >= getDrawerCount())
|
||||
return null;
|
||||
@@ -252,6 +265,10 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
if (tag.hasKey("Lock"))
|
||||
locked = tag.getBoolean("Lock");
|
||||
|
||||
voidUpgrade = false;
|
||||
if (tag.hasKey("Void"))
|
||||
voidUpgrade = tag.getBoolean("Void");
|
||||
|
||||
NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND);
|
||||
int drawerCount = slots.tagCount();
|
||||
drawers = new IDrawer[slots.tagCount()];
|
||||
@@ -262,7 +279,7 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
drawers[i].readFromNBT(slot);
|
||||
}
|
||||
|
||||
inventory = new StorageInventory(this, getSideManager());
|
||||
inventory = new StorageInventory(this, getSideManager(), this);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
trapLoadFailure(t, tag);
|
||||
@@ -288,6 +305,9 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
if (locked)
|
||||
tag.setBoolean("Lock", locked);
|
||||
|
||||
if (voidUpgrade)
|
||||
tag.setBoolean("Void", voidUpgrade);
|
||||
|
||||
NBTTagList slots = new NBTTagList();
|
||||
for (IDrawer drawer : drawers) {
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
|
||||
@@ -48,5 +48,10 @@ public class TileEntityDrawersStandard extends TileEntityDrawers
|
||||
public boolean isLocked (int slot) {
|
||||
return TileEntityDrawersStandard.this.isLocked();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoid (int slot) {
|
||||
return TileEntityDrawersStandard.this.isVoid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public class ConfigManager
|
||||
public boolean enableIndicatorUpgrades;
|
||||
public boolean enableStorageUpgrades;
|
||||
public boolean enableLockUpgrades;
|
||||
public boolean enableVoidUpgrades;
|
||||
public boolean renderStorageUpgrades;
|
||||
public String itemRenderType;
|
||||
public boolean creativeTabVanillaWoods;
|
||||
@@ -115,6 +116,7 @@ public class ConfigManager
|
||||
cache.enableIndicatorUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableIndicatorUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableIndicatorUpgrades").setRequiresMcRestart(true).getBoolean();
|
||||
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.itemRenderType = config.get(Configuration.CATEGORY_GENERAL, "itemRenderType", "fast", null, new String[] { "fancy", "fast" }).setLanguageKey(LANG_PREFIX + "prop.itemRenderType").getString();
|
||||
cache.renderStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "renderStorageUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.renderStorageUpgrades").getBoolean();
|
||||
cache.creativeTabVanillaWoods = config.get(Configuration.CATEGORY_GENERAL, "creativeTabVanillaWoods", true).setLanguageKey(LANG_PREFIX + "prop.creativeTabVanillaWoods").getBoolean();
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgrade;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgradeLock;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgradeStatus;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgradeVoid;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@@ -13,12 +14,14 @@ public class ModItems
|
||||
public static ItemUpgrade upgrade;
|
||||
public static ItemUpgradeStatus upgradeStatus;
|
||||
public static ItemUpgradeLock upgradeLock;
|
||||
public static ItemUpgradeVoid upgradeVoid;
|
||||
|
||||
public void init () {
|
||||
upgradeTemplate = new Item().setUnlocalizedName("upgradeTemplate").setTextureName(StorageDrawers.MOD_ID + ":upgrade_template").setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
upgrade = new ItemUpgrade("upgrade");
|
||||
upgradeStatus = new ItemUpgradeStatus("upgradeStatus");
|
||||
upgradeLock = new ItemUpgradeLock("upgradeLock");
|
||||
upgradeVoid = new ItemUpgradeVoid("upgradeVoid");
|
||||
|
||||
GameRegistry.registerItem(upgradeTemplate, "upgradeTemplate");
|
||||
|
||||
@@ -28,5 +31,7 @@ public class ModItems
|
||||
GameRegistry.registerItem(upgradeStatus, "upgradeStatus");
|
||||
if (StorageDrawers.config.cache.enableLockUpgrades)
|
||||
GameRegistry.registerItem(upgradeLock, "upgradeLock");
|
||||
if (StorageDrawers.config.cache.enableVoidUpgrades)
|
||||
GameRegistry.registerItem(upgradeVoid, "upgradeVoid");
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.jaquadro.minecraft.storagedrawers.api.inventory.SlotType;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -15,12 +16,14 @@ public class StorageInventory implements IDrawerInventory
|
||||
|
||||
private final IDrawerGroup group;
|
||||
private final ISideManager sideMan;
|
||||
private final IUpgradeProvider upgrade;
|
||||
|
||||
private final int[] inventorySlots;
|
||||
|
||||
public StorageInventory (IDrawerGroup drawerGroup, ISideManager sideManager) {
|
||||
public StorageInventory (IDrawerGroup drawerGroup, ISideManager sideManager, IUpgradeProvider upgradeProvider) {
|
||||
group = drawerGroup;
|
||||
sideMan = sideManager;
|
||||
upgrade = upgradeProvider;
|
||||
|
||||
inventorySlots = new int[group.getDrawerCount() * SlotType.values.length];
|
||||
for (int i = 0, n = inventorySlots.length; i < n; i++)
|
||||
@@ -224,7 +227,11 @@ public class StorageInventory implements IDrawerInventory
|
||||
insertCount = drawer.getMaxCapacity();
|
||||
|
||||
drawer.setStoredItemCount(insertCount);
|
||||
item.stackSize -= insertCount;
|
||||
|
||||
if (upgrade.isVoid())
|
||||
item.stackSize = 0;
|
||||
else
|
||||
item.stackSize -= insertCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemUpgradeVoid extends Item
|
||||
{
|
||||
public ItemUpgradeVoid (String name) {
|
||||
setUnlocalizedName(name);
|
||||
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
setTextureName(StorageDrawers.MOD_ID + ":upgrade_void");
|
||||
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"));
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,10 @@ public abstract class BaseDrawerData implements IDrawer, IInventoryAdapter
|
||||
auxData.put(key, data);
|
||||
}
|
||||
|
||||
protected int getItemCapacityForInventoryStack () {
|
||||
return getMaxCapacity();
|
||||
}
|
||||
|
||||
public boolean areItemsEqual (ItemStack item) {
|
||||
ItemStack protoStack = getStoredItemPrototype();
|
||||
if (protoStack == null || item == null)
|
||||
@@ -197,7 +201,7 @@ public abstract class BaseDrawerData implements IDrawer, IInventoryAdapter
|
||||
|
||||
@Override
|
||||
protected int getItemCapacity () {
|
||||
return getMaxCapacity();
|
||||
return getItemCapacityForInventoryStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,6 +41,11 @@ public class DefaultStorageProvider implements IStorageProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoid (int slot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markAmountDirty (int slot) {
|
||||
if (tile.getWorldObj().isRemote)
|
||||
|
||||
@@ -86,6 +86,9 @@ public class DrawerData extends BaseDrawerData
|
||||
|
||||
public void setStoredItemCount (int amount, boolean mark, boolean clearOnEmpty) {
|
||||
count = amount;
|
||||
if (count > getMaxCapacity())
|
||||
count = getMaxCapacity();
|
||||
|
||||
if (amount == 0) {
|
||||
if (clearOnEmpty) {
|
||||
if (!storageProvider.isLocked(slot))
|
||||
@@ -127,6 +130,14 @@ public class DrawerData extends BaseDrawerData
|
||||
return protoStack.getItem().getItemStackLimit(protoStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getItemCapacityForInventoryStack () {
|
||||
if (storageProvider.isVoid(slot))
|
||||
return Integer.MAX_VALUE;
|
||||
else
|
||||
return getMaxCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canItemBeStored (ItemStack itemPrototype) {
|
||||
if (protoStack == nullStack)
|
||||
|
||||
@@ -14,6 +14,8 @@ public interface IStorageProvider
|
||||
|
||||
public boolean isLocked (int slot);
|
||||
|
||||
public boolean isVoid (int slot);
|
||||
|
||||
public void markAmountDirty (int slot);
|
||||
|
||||
public void markDirty (int slot);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.storage;
|
||||
|
||||
public interface IUpgradeProvider
|
||||
{
|
||||
boolean isLocked ();
|
||||
|
||||
boolean isVoid ();
|
||||
}
|
||||
Reference in new issue
Block a user