Fixes
This commit is contained in:
@@ -47,7 +47,7 @@ public class MessageGridCraftingStart extends MessageHandlerPlayerToServer<Messa
|
||||
public void handle(MessageGridCraftingStart message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.gridX, message.gridY, message.gridZ));
|
||||
|
||||
if (tile instanceof TileGrid && ((TileGrid) tile).isConnected() && message.quantity > 0 && message.id >= 0) {
|
||||
if (tile instanceof TileGrid && ((TileGrid) tile).isConnected()) {
|
||||
((TileGrid) tile).getController().onCraftingRequested(message.id, message.quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,7 @@ public class MessageGridStoragePull extends MessageHandlerPlayerToServer<Message
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.gridX, message.gridY, message.gridZ));
|
||||
|
||||
if (tile instanceof TileGrid && ((TileGrid) tile).isConnected()) {
|
||||
TileController controller = ((TileGrid) tile).getController();
|
||||
|
||||
if (message.id >= 0 && message.id < controller.getItemGroups().size()) {
|
||||
controller.handleStoragePull(message.id, message.flags, player);
|
||||
}
|
||||
((TileController) tile).handleStoragePull(message.id, message.flags, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MessageWirelessGridCraftingStart extends MessageHandlerPlayerToServ
|
||||
public void handle(MessageWirelessGridCraftingStart message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.controllerX, message.controllerY, message.controllerZ));
|
||||
|
||||
if (tile instanceof TileController && ((TileController) tile).isActive() && message.quantity > 0 && message.id >= 0) {
|
||||
if (tile instanceof TileController && ((TileController) tile).isActive()) {
|
||||
((TileController) tile).onCraftingRequested(message.id, message.quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,7 @@ public class MessageWirelessGridStoragePull extends MessageHandlerPlayerToServer
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.controllerX, message.controllerY, message.controllerZ));
|
||||
|
||||
if (tile instanceof TileController && ((TileController) tile).isActive()) {
|
||||
TileController controller = (TileController) tile;
|
||||
|
||||
if (message.id >= 0 && message.id < controller.getItemGroups().size()) {
|
||||
controller.handleStoragePull(message.id, message.flags, player);
|
||||
}
|
||||
((TileController) tile).handleStoragePull(message.id, message.flags, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,6 +525,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
}
|
||||
|
||||
public void handleStoragePull(int id, int flags, EntityPlayerMP player) {
|
||||
if (id < 0 || id >= itemGroups.size() - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemGroup group = itemGroups.get(id);
|
||||
|
||||
int quantity = 64;
|
||||
@@ -608,6 +612,12 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
}
|
||||
|
||||
public void onCraftingRequested(int id, int quantity) {
|
||||
System.out.println("Requested crafting for item " + id + " with quantity of " + quantity);
|
||||
if (id >= 0 && id < itemGroups.size() && quantity > 0) {
|
||||
for (int i = 0; i < quantity; ++i) {
|
||||
ItemStack toCraft = itemGroups.get(id).toItemStack();
|
||||
toCraft.stackSize = 1;
|
||||
craftingTasks.add(CraftingTask.create(toCraft));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user