mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-13 17:04:15 +00:00
Add API for fractional drawers (compacting drawers)
This commit is contained in:
1 parent
dad0a5bdc2
commit
a6d2973a88
6 files changed
+62
-7
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.7.10-1.5.2"
|
||||
version = "1.7.10-1.5.3"
|
||||
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "StorageDrawers"
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.storage;
|
||||
|
||||
/**
|
||||
* Represents a drawer with items that are a fractional component of another item within the drawer group. Compacting
|
||||
* Drawers are a primary example of this drawer type.
|
||||
*/
|
||||
public interface IFractionalDrawer extends IDrawer
|
||||
{
|
||||
/**
|
||||
* Gets the storage ratio between the held item and the most compressed item within the drawer group.
|
||||
*
|
||||
* For example, most ingots have a conversion rate of 9 compared to metal blocks, and nuggets a rate of 81.
|
||||
* Actual conversion rates are implementation-defined.
|
||||
*/
|
||||
int getConversionRate ();
|
||||
|
||||
/**
|
||||
* Gets the number of items left in the drawer if the maximum number of equivalent compressed items had been removed.
|
||||
* The equivalency is determined by the conversion rate.
|
||||
*/
|
||||
int getStoredItemRemainder ();
|
||||
}
|
||||
@@ -486,6 +486,19 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
return getMaxCapacity(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConversionRate (int slot) {
|
||||
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
|
||||
return 0;
|
||||
|
||||
return convRate[0] / convRate[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredItemRemainder (int slot) {
|
||||
return TileEntityDrawersComp.this.getStoredItemRemainder(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoidSlot (int slot) {
|
||||
return isVoid();
|
||||
|
||||
@@ -3,10 +3,11 @@ package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaTooltipHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IFractionalDrawer;
|
||||
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.TileEntityDrawersComp;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
@@ -60,10 +61,14 @@ public class Waila extends IntegrationModule
|
||||
public List<String> getWailaBody (ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
TileEntityDrawers tile = (TileEntityDrawers) accessor.getTileEntity();
|
||||
|
||||
for (int i = 0; i < tile.getDrawerCount(); i++) {
|
||||
IDrawerGroup group = tile;
|
||||
for (int i = 0; i < group.getDrawerCount(); i++) {
|
||||
if (!group.isDrawerEnabled(i))
|
||||
continue;
|
||||
|
||||
String name = StatCollector.translateToLocal("storageDrawers.waila.empty");
|
||||
|
||||
IDrawer drawer = tile.getDrawer(i);
|
||||
IDrawer drawer = group.getDrawer(i);
|
||||
ItemStack stack = drawer.getStoredItemPrototype();
|
||||
if (stack != null && stack.getItem() != null) {
|
||||
String stackName = stack.getDisplayName();
|
||||
@@ -71,8 +76,8 @@ public class Waila extends IntegrationModule
|
||||
for (int j = 0, n = handlers.size(); j < n; j++)
|
||||
stackName = handlers.get(j).transformItemName(drawer, stackName);
|
||||
|
||||
if (tile instanceof TileEntityDrawersComp)
|
||||
name = stackName + ((i == 0) ? " [" : " [+") + ((TileEntityDrawersComp) tile).getStoredItemRemainder(i) + "]";
|
||||
if (drawer instanceof IFractionalDrawer && ((IFractionalDrawer) drawer).getConversionRate() > 1)
|
||||
name = stackName + ((i == 0) ? " [" : " [+") + ((IFractionalDrawer) drawer).getStoredItemRemainder() + "]";
|
||||
else
|
||||
name = stackName + " [" + drawer.getStoredItemCount() + "]";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.storage;
|
||||
|
||||
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.IShroudable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
|
||||
@@ -8,7 +9,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class CompDrawerData extends BaseDrawerData implements IVoidable, IShroudable, ILockable
|
||||
public class CompDrawerData extends BaseDrawerData implements IFractionalDrawer, IVoidable, IShroudable, ILockable
|
||||
{
|
||||
private static final ItemStack nullStack = new ItemStack((Item)null);
|
||||
|
||||
@@ -97,6 +98,16 @@ public class CompDrawerData extends BaseDrawerData implements IVoidable, IShroud
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConversionRate () {
|
||||
return central.getConversionRate(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredItemRemainder () {
|
||||
return central.getStoredItemRemainder(slot);
|
||||
}
|
||||
|
||||
public void refresh () {
|
||||
reset();
|
||||
refreshOreDictMatches();
|
||||
|
||||
@@ -24,6 +24,10 @@ public interface ICentralInventory
|
||||
|
||||
public int getItemCapacityForInventoryStack (int slot);
|
||||
|
||||
public int getConversionRate (int slot);
|
||||
|
||||
public int getStoredItemRemainder (int slot);
|
||||
|
||||
public boolean isVoidSlot (int slot);
|
||||
|
||||
public boolean isShroudedSlot (int slot);
|
||||
|
||||
Reference in new issue
Block a user