use of mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity in project RFTools by McJty.
the class StorageChannelSettings method tick.
@Override
public void tick(int channel, IControllerContext context) {
if (updateCache(channel, context)) {
// If cache was updated we send new state immediatelly
delay = 0;
}
delay--;
if (delay > 0) {
return;
}
delay = 10;
World world = context.getControllerWorld();
for (Pair<SidedConsumer, StorageConnectorSettings> entry : storageControllers) {
BlockPos extractorPos = context.findConsumerPosition(entry.getKey().getConsumerId());
if (extractorPos != null) {
EnumFacing side = entry.getKey().getSide();
BlockPos pos = extractorPos.offset(side);
if (!WorldTools.chunkLoaded(world, pos)) {
continue;
}
TileEntity te = world.getTileEntity(pos);
if (te instanceof StorageScannerTileEntity) {
StorageScannerTileEntity scanner = (StorageScannerTileEntity) te;
scanner.register(access);
}
}
}
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity in project RFTools by McJty.
the class StorageControlScreenModule method mouseClick.
@Override
public void mouseClick(World world, int hitx, int hity, boolean clicked, EntityPlayer player) {
if ((!clicked) || player == null) {
return;
}
if (BlockPosTools.INVALID.equals(coordinate)) {
player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Module is not linked to storage scanner!"), false);
return;
}
StorageScannerTileEntity scannerTileEntity = getStorageScanner(dim, coordinate);
if (scannerTileEntity == null) {
return;
}
if (hitx >= 0) {
boolean insertStackActive = hitx >= 0 && hitx < 60 && hity > 98;
if (insertStackActive) {
if (isShown(player.getHeldItem(EnumHand.MAIN_HAND))) {
ItemStack stack = scannerTileEntity.injectStackFromScreen(player.getHeldItem(EnumHand.MAIN_HAND), player);
player.setHeldItem(EnumHand.MAIN_HAND, stack);
}
player.openContainer.detectAndSendChanges();
return;
}
boolean insertAllActive = hitx >= 60 && hity > 98;
if (insertAllActive) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (isShown(player.inventory.getStackInSlot(i))) {
ItemStack stack = scannerTileEntity.injectStackFromScreen(player.inventory.getStackInSlot(i), player);
player.inventory.setInventorySlotContents(i, stack);
}
}
player.openContainer.detectAndSendChanges();
return;
}
int i = getHighlightedStack(hitx, hity);
if (i != -1) {
if (stacks.get(i).isEmpty()) {
ItemStack heldItem = player.getHeldItemMainhand();
if (!heldItem.isEmpty()) {
ItemStack stack = heldItem.copy();
stack.setCount(1);
stacks.set(i, stack);
dirty = i;
}
} else {
scannerTileEntity.giveToPlayerFromScreen(stacks.get(i), player.isSneaking(), player, oredict);
}
}
}
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity in project RFTools by McJty.
the class StorageScannerRecipeTransferHandler method transferRecipe.
@Nullable
@Override
public IRecipeTransferError transferRecipe(@Nonnull StorageScannerContainer container, @Nonnull IRecipeLayout recipeLayout, @Nonnull EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients = recipeLayout.getItemStacks().getGuiIngredients();
StorageScannerTileEntity te = container.getStorageScannerTileEntity();
BlockPos pos = te.getCraftingGridContainerPos();
if (doTransfer) {
RFToolsJeiPlugin.transferRecipe(guiIngredients, pos);
}
return null;
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity in project RFTools by McJty.
the class StorageControlScreenModule method getStorageScanner.
public static StorageScannerTileEntity getStorageScanner(int dim, BlockPos coordinate) {
World world = DimensionManager.getWorld(dim);
if (world == null) {
return null;
}
if (!RFToolsTools.chunkLoaded(world, coordinate)) {
return null;
}
TileEntity te = world.getTileEntity(coordinate);
if (te == null) {
return null;
}
if (!(te instanceof StorageScannerTileEntity)) {
return null;
}
return (StorageScannerTileEntity) te;
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity in project RFTools by McJty.
the class StorageControlScreenModule method getData.
@Override
public ModuleDataStacks getData(IScreenDataHelper helper, World worldObj, long millis) {
StorageScannerTileEntity scannerTileEntity = getStorageScanner(dim, coordinate);
if (scannerTileEntity == null) {
return null;
}
int[] amounts = new int[stacks.size()];
for (int i = 0; i < stacks.size(); i++) {
amounts[i] = scannerTileEntity.countItems(stacks.get(i), starred, oredict);
}
return new ModuleDataStacks(amounts);
}
Aggregations