use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.
the class CraftingStationTileEntity method startCraft.
private void startCraft(int index, int amount) {
Pair<ProcessorTileEntity, ItemStack> pair = findCraftableItem(index);
if (pair == null) {
// Somehow not possible
System.out.println("What? Can't happen");
return;
}
String ticket = getNewTicket(null);
ItemStack stack = pair.getValue();
int count = (amount + stack.getCount() - 1) / stack.getCount();
CraftingRequest request = new CraftingRequest(ticket, stack, count);
if (!checkRequestAmount()) {
return;
}
activeCraftingRequests.add(request);
pair.getKey().fireCraftEvent(ticket, stack);
cleanupCounter--;
if (cleanupCounter <= 0) {
cleanupCounter = 50;
cleanupStaleRequests();
}
}
use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.
the class CraftingStationTileEntity method request.
public boolean request(ItemStack item, @Nullable Inventory destination) {
for (BlockPos p : processorList) {
TileEntity te = getWorld().getTileEntity(p);
if (te instanceof ProcessorTileEntity) {
ProcessorTileEntity processor = (ProcessorTileEntity) te;
ItemStackList items = ItemStackList.create();
processor.getCraftableItems(items);
for (ItemStack i : items) {
if (item.isItemEqual(i)) {
String ticket = getNewTicket(destination);
if (!checkRequestAmount()) {
return false;
}
activeCraftingRequests.add(new CraftingRequest(ticket, i, 1));
processor.fireCraftEvent(ticket, i);
return true;
}
}
}
}
return false;
}
use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.
the class CommandHandler method registerCommands.
public static void registerCommands() {
McJtyLib.registerCommand(RFToolsControl.MODID, CMD_TESTRECIPE, (player, arguments) -> {
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem.isEmpty()) {
return false;
}
if (heldItem.getItem() instanceof CraftingCardItem) {
CraftingCardItem.testRecipe(player.getEntityWorld(), heldItem);
}
return true;
});
McJtyLib.registerCommand(RFToolsControl.MODID, CMD_GETGRAPHICS, (player, arguments) -> {
TileEntity te = player.getEntityWorld().getTileEntity(arguments.getBlockPos());
if (te instanceof ProcessorTileEntity) {
ProcessorTileEntity processor = (ProcessorTileEntity) te;
RFToolsCtrlMessages.INSTANCE.sendTo(new PacketGraphicsReady(processor), (EntityPlayerMP) player);
}
return true;
});
}
use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.
the class CraftingStationTileEntity method findItem.
private int findItem(String itemName, int meta, String nbtString) {
int index = 0;
for (BlockPos p : processorList) {
TileEntity te = getWorld().getTileEntity(p);
if (te instanceof ProcessorTileEntity) {
ProcessorTileEntity processor = (ProcessorTileEntity) te;
ItemStackList items = ItemStackList.create();
processor.getCraftableItems(items);
for (ItemStack item : items) {
if (item.getItemDamage() == meta && itemName.equals(item.getItem().getRegistryName().toString())) {
if (item.hasTagCompound()) {
if (nbtString.equalsIgnoreCase(item.serializeNBT().toString())) {
return index;
}
} else {
return index;
}
}
index++;
}
}
}
return -1;
}
use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.
the class CraftingStationTileEntity method findCraftableItem.
private Pair<ProcessorTileEntity, ItemStack> findCraftableItem(int index) {
for (BlockPos p : processorList) {
TileEntity te = getWorld().getTileEntity(p);
if (te instanceof ProcessorTileEntity) {
ProcessorTileEntity processor = (ProcessorTileEntity) te;
ItemStackList items = ItemStackList.create();
processor.getCraftableItems(items);
for (ItemStack item : items) {
if (index == 0) {
// found!
return Pair.of(processor, item);
}
index--;
}
}
}
return null;
}
Aggregations