This commit is contained in:
WayofTime 2015-01-16 10:36:50 -05:00
parent 56ccd3188d
commit eb9284faf7
3 changed files with 95 additions and 52 deletions

View file

@ -5,13 +5,18 @@ import java.util.List;
import java.util.Random;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.Int3;
import WayofTime.alchemicalWizardry.common.items.routing.InputRoutingFocus;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class RitualEffectItemRouting extends RitualEffect
{
@ -43,16 +48,65 @@ public class RitualEffectItemRouting extends RitualEffect
{
return;
}
IInventory bufferInventory = (IInventory)bufferTile;
for(int i=0; i<4; i++)
{
Int3 inputChest = this.getInputBufferChestLocation(i);
TileEntity inputFocusInv = world.getTileEntity(x + inputChest.xCoord, y + inputChest.yCoord, z + inputChest.zCoord);
Int3 inputFocusChest = this.getInputBufferChestLocation(i);
TileEntity inputFocusInv = world.getTileEntity(x + inputFocusChest.xCoord, y + inputFocusChest.yCoord, z + inputFocusChest.zCoord);
if(inputFocusInv instanceof IInventory)
{
for(int j=0; j<((IInventory) inputFocusInv).getSizeInventory(); j++)
{
ItemStack stack = ((IInventory) inputFocusInv).getStackInSlot(j);
if(stack != null && stack.getItem() instanceof InputRoutingFocus)
{
InputRoutingFocus inputFocus = (InputRoutingFocus)stack.getItem();
TileEntity inputChest = world.getTileEntity(inputFocus.xCoord(stack), inputFocus.yCoord(stack), inputFocus.zCoord(stack));
if(inputChest instanceof IInventory)
{
IInventory inputChestInventory = (IInventory)inputChest;
ForgeDirection syphonDirection = inputFocus.getSetDirection(stack);
boolean[] canSyphonList = new boolean[inputChestInventory.getSizeInventory()];
if(inputChest instanceof ISidedInventory)
{
int[] validSlots = ((ISidedInventory) inputChest).getAccessibleSlotsFromSide(syphonDirection.ordinal());
for(int in : validSlots)
{
System.out.println("" + in);
canSyphonList[in] = true;
}
}else
{
for(int n=0; n<inputChestInventory.getSizeInventory(); n++)
{
canSyphonList[n] = true;
}
}
for(int n=0; n<inputChestInventory.getSizeInventory(); n++)
{
if(canSyphonList[n])
{
ItemStack syphonedStack = inputChestInventory.getStackInSlot(n);
if(syphonedStack == null)
{
continue;
}
ItemStack newStack = SpellHelper.insertStackIntoInventory(syphonedStack, bufferInventory, ForgeDirection.DOWN);
if(newStack != null && newStack.stackSize <= 0)
{
newStack = null;
}
inputChestInventory.setInventorySlotContents(n, newStack);
break;
}
}
}
}
}
}
}
}