Skip to content

Commit

Permalink
Fixes #58
Browse files Browse the repository at this point in the history
(cherry picked from commit d2b915b)
  • Loading branch information
rolandoislas authored and austinv11 committed May 9, 2015
1 parent 9cec1a7 commit ccb8c89
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import appeng.api.networking.crafting.ICraftingCallback;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
Expand Down Expand Up @@ -36,7 +37,7 @@
import java.util.Iterator;

@Optional.InterfaceList(value = {@Optional.Interface(modid="appliedenergistics2",iface="appeng.api.networking.IGridHost", striprefs=true), @Optional.Interface(modid="appliedenergistics2",iface="appeng.api.networking.IGridBlock", striprefs=true)})
public class TileEntityMEBridge extends MountedTileEntity implements IGridHost, IGridBlock {
public class TileEntityMEBridge extends MountedTileEntity implements IActionHost, IGridBlock {

public static String publicName = "meBridge";
private String name = "tileEntityMEBridge";
Expand Down Expand Up @@ -133,12 +134,7 @@ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int me
amount = getRemainingSlots(item, inventory);
IAEItemStack stackToGet = stack.copy();
stackToGet.setStackSize(amount);
IAEItemStack resultant = monitor.extractItems(stackToGet, Actionable.MODULATE, new BaseActionSource() {
@Override
public boolean isMachine() {
return true;
}
});
IAEItemStack resultant = monitor.extractItems(stackToGet, Actionable.MODULATE, new MachineSource(this));
if (resultant != null) {
extracted = resultant.getStackSize();
int currentSlot = 0;
Expand Down Expand Up @@ -176,22 +172,18 @@ public boolean isMachine() {
throw new LuaException("Bad argument #1 (expected string)");
if (!(arguments[1] instanceof Double))
throw new LuaException("Bad argument #2 (expected number");
ICraftingGrid craftingGrid = node.getGrid().getCache(ICraftingGrid.class);
final ICraftingGrid craftingGrid = node.getGrid().getCache(ICraftingGrid.class);
Item toCraft = GameRegistry.findItem(((String) arguments[0]).split(":")[0], ((String) arguments[0]).split(":")[1].split(" ")[0]);
int meta_ = ((String) arguments[0]).contains(" ") ? Integer.valueOf(((String)arguments[0]).split(" ")[1]) : 0;
IAEItemStack aeToCraft_ = findAEStackFromItemStack(monitor, new ItemStack(toCraft, 1, meta_));
if (aeToCraft_ != null && aeToCraft_.isCraftable()) {
IAEItemStack aeToCraft = aeToCraft_.copy();
aeToCraft.setStackSize((long) (int) (double) (Double) arguments[1]);
synchronized (this) {
craftingGrid.beginCraftingJob(worldObj, node.getGrid(), new BaseActionSource() {
@Override
public boolean isMachine() {
return true;
}
}, aeToCraft, new ICraftingCallback() {
craftingGrid.beginCraftingJob(worldObj, node.getGrid(), new MachineSource(this), aeToCraft, new ICraftingCallback() {
@Override
public void calculationComplete(ICraftingJob job) {
craftingGrid.submitJob(job, null, null, false, new MachineSource((IActionHost) getMachine()));
for (IComputerAccess comp : computers.keySet())
comp.queueEvent("craftingComplete", new Object[]{Item.itemRegistry.getNameForObject(job.getOutput().getItem()), job.getOutput().getStackSize(), job.getByteTotal()});
}
Expand Down Expand Up @@ -360,4 +352,9 @@ public void securityBreak() {
computer.queueEvent("securityBreak", new Object[0]);
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
}

@Override
public IGridNode getActionableNode() {
return node;
}
}

0 comments on commit ccb8c89

Please sign in to comment.