Search in sources :

Example 6 with StorageScannerTileEntity

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);
            }
        }
    }
}
Also used : StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) SidedConsumer(mcjty.xnet.api.keys.SidedConsumer) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity)

Example 7 with StorageScannerTileEntity

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);
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 8 with StorageScannerTileEntity

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;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) Nullable(javax.annotation.Nullable)

Example 9 with StorageScannerTileEntity

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;
}
Also used : StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) World(net.minecraft.world.World) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity)

Example 10 with StorageScannerTileEntity

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);
}
Also used : StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity)

Aggregations

StorageScannerTileEntity (mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity)15 ItemStack (net.minecraft.item.ItemStack)12 TileEntity (net.minecraft.tileentity.TileEntity)11 BlockPos (net.minecraft.util.math.BlockPos)9 WorldServer (net.minecraft.world.WorldServer)5 StorageScannerContainer (mcjty.rftools.blocks.storagemonitor.StorageScannerContainer)4 Block (net.minecraft.block.Block)4 TextComponentString (net.minecraft.util.text.TextComponentString)4 IBlockState (net.minecraft.block.state.IBlockState)3 GenericBlock (mcjty.lib.container.GenericBlock)2 LogicTileEntity (mcjty.rftools.blocks.logic.generic.LogicTileEntity)2 ModularStorageItemContainer (mcjty.rftools.blocks.storage.ModularStorageItemContainer)2 RemoteStorageItemContainer (mcjty.rftools.blocks.storage.RemoteStorageItemContainer)2 GuiStorageScanner (mcjty.rftools.blocks.storagemonitor.GuiStorageScanner)2 ModifierContainer (mcjty.rftools.items.modifier.ModifierContainer)2 StorageFilterContainer (mcjty.rftools.items.storage.StorageFilterContainer)2 SPacketUpdateTileEntity (net.minecraft.network.play.server.SPacketUpdateTileEntity)2 World (net.minecraft.world.World)2 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1