Skip to content

Commit

Permalink
Fix AE and void upgrades through controllers too.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaquadro committed May 6, 2015
1 parent 0a36d48 commit df65da0
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.7.10-1.4.1"
version = "1.7.10-1.4.2"
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "StorageDrawers"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;

public interface IVoidable
{
/**
* Gets whether or not the drawer has a voiding attribute.
*/
boolean isVoid ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ public int getItemCapacityForInventoryStack (int slot) {
return getMaxCapacity(slot);
}

@Override
public boolean isVoidSlot (int slot) {
return isVoid();
}

@Override
public void writeToNBT (int slot, NBTTagCompound tag) {
ItemStack protoStack = getStoredItemPrototype(slot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import appeng.api.storage.data.IItemList;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider;
import net.minecraft.item.ItemStack;

Expand All @@ -32,6 +33,8 @@ public IAEItemStack injectItems (IAEItemStack input, Actionable type, BaseAction
if (itemProto != null) {
if (drawer.canItemBeStored(input.getItemStack())) {
itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type);
if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid())
itemsLeft = 0;
if (itemsLeft == 0)
return null;
}
Expand All @@ -49,16 +52,15 @@ public IAEItemStack injectItems (IAEItemStack input, Actionable type, BaseAction
if (drawer.canItemBeStored(itemProto)) {
drawer.setStoredItem(itemProto, 0);
itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type);
if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid())
itemsLeft = 0;
if (itemsLeft == 0)
return null;
}
}
}

if (itemsLeft > 0) {
if (group instanceof IUpgradeProvider && ((IUpgradeProvider) group).isVoid())
return null;

IAEItemStack overflow = AEApi.instance().storage().createItemStack(input.getItemStack());
overflow.setStackSize(itemsLeft);
return overflow;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.jaquadro.minecraft.storagedrawers.storage;

import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class CompDrawerData extends BaseDrawerData
public class CompDrawerData extends BaseDrawerData implements IVoidable
{
private static final ItemStack nullStack = new ItemStack((Item)null);

Expand Down Expand Up @@ -97,4 +98,9 @@ public void refresh () {
reset();
refreshOreDictMatches();
}

@Override
public boolean isVoid () {
return central.isVoidSlot(slot);
}
}
17 changes: 7 additions & 10 deletions src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package com.jaquadro.minecraft.storagedrawers.storage;

import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent;
import com.jaquadro.minecraft.storagedrawers.api.inventory.IInventoryAdapter;
import com.jaquadro.minecraft.storagedrawers.api.inventory.SlotType;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.inventory.InventoryStack;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;

import java.util.ArrayList;
import java.util.List;

public class DrawerData extends BaseDrawerData
public class DrawerData extends BaseDrawerData implements IVoidable
{
private static final ItemStack nullStack = new ItemStack((Item)null);

Expand Down Expand Up @@ -198,5 +190,10 @@ protected void reset () {
DrawerPopulatedEvent event = new DrawerPopulatedEvent(this);
MinecraftForge.EVENT_BUS.post(event);
}

@Override
public boolean isVoid () {
return storageProvider.isVoid(slot);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public interface ICentralInventory

public int getItemCapacityForInventoryStack (int slot);

public boolean isVoidSlot (int slot);

public void readFromNBT (int slot, NBTTagCompound tag);

public void writeToNBT (int slot, NBTTagCompound tag);
Expand Down

0 comments on commit df65da0

Please sign in to comment.