Search in sources :

Example 1 with StorageScannerContainer

use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.

the class StorageTerminalBlock method createServerContainer.

@Override
public Container createServerContainer(EntityPlayer entityPlayer, TileEntity tileEntity) {
    if (!entityPlayer.isSneaking()) {
        if (tileEntity instanceof StorageTerminalTileEntity) {
            StorageTerminalTileEntity terminalTileEntity = (StorageTerminalTileEntity) tileEntity;
            ItemStack module = terminalTileEntity.getStackInSlot(StorageTerminalContainer.SLOT_MODULE);
            if (!module.isEmpty()) {
                int dimension = RFToolsTools.getDimensionFromModule(module);
                BlockPos pos = RFToolsTools.getPositionFromModule(module);
                WorldServer world = DimensionManager.getWorld(dimension);
                if (!RFToolsTools.chunkLoaded(world, pos)) {
                    entityPlayer.sendStatusMessage(new TextComponentString(TextFormatting.YELLOW + "Storage scanner out of range!"), false);
                    return null;
                }
                TileEntity scannerTE = world.getTileEntity(pos);
                if (!(scannerTE instanceof StorageScannerTileEntity)) {
                    entityPlayer.sendStatusMessage(new TextComponentString(TextFormatting.YELLOW + "Storage scanner is missing!"), false);
                    return null;
                }
                return new StorageScannerContainer(entityPlayer, (IInventory) scannerTE, terminalTileEntity);
            }
        }
    }
    return super.createServerContainer(entityPlayer, tileEntity);
}
Also used : StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer) ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with StorageScannerContainer

use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.

the class StorageTools method clearGrid.

public static void clearGrid(EntityPlayer player) {
    ItemStack mainhand = player.getHeldItemMainhand();
    if (!mainhand.isEmpty() && mainhand.getItem() == ModularStorageSetup.storageModuleTabletItem) {
        if (player.openContainer instanceof ModularStorageItemContainer) {
            ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) player.openContainer;
            storageItemContainer.clearGrid();
            mainhand.getTagCompound().removeTag("grid");
        } else if (player.openContainer instanceof RemoteStorageItemContainer) {
            RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) player.openContainer;
            storageItemContainer.clearGrid();
            mainhand.getTagCompound().removeTag("grid");
        } else if (player.openContainer instanceof StorageScannerContainer) {
            StorageScannerContainer storageItemContainer = (StorageScannerContainer) player.openContainer;
            storageItemContainer.clearGrid();
            mainhand.getTagCompound().removeTag("grid");
        }
    }
}
Also used : StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) ItemStack(net.minecraft.item.ItemStack)

Example 3 with StorageScannerContainer

use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.

the class StorageCraftingTools method craftFromGrid.

public static void craftFromGrid(EntityPlayer player, int count, boolean test, BlockPos pos) {
    player.addStat(StatList.CRAFTING_TABLE_INTERACTION);
    int[] testResult = new int[0];
    if (pos == null) {
        // Handle tablet version
        ItemStack mainhand = player.getHeldItemMainhand();
        if (!mainhand.isEmpty() && mainhand.getItem() == ModularStorageSetup.storageModuleTabletItem) {
            if (player.openContainer instanceof ModularStorageItemContainer) {
                ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) player.openContainer;
                testResult = storageItemContainer.getCraftingGridProvider().craft(player, count, test);
            } else if (player.openContainer instanceof RemoteStorageItemContainer) {
                RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) player.openContainer;
                testResult = storageItemContainer.getCraftingGridProvider().craft(player, count, test);
            } else if (player.openContainer instanceof StorageScannerContainer) {
                StorageScannerContainer storageItemContainer = (StorageScannerContainer) player.openContainer;
                testResult = storageItemContainer.getStorageScannerTileEntity().craft(player, count, test);
            }
        }
    } else {
        TileEntity te = player.getEntityWorld().getTileEntity(pos);
        if (te instanceof CraftingGridProvider) {
            testResult = ((CraftingGridProvider) te).craft(player, count, test);
        }
    }
    if (testResult.length > 0) {
        RFToolsMessages.INSTANCE.sendTo(new PacketCraftTestResultToClient(testResult), (EntityPlayerMP) player);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) ModularStorageItemContainer(mcjty.rftools.blocks.storage.ModularStorageItemContainer) ItemStack(net.minecraft.item.ItemStack) RemoteStorageItemContainer(mcjty.rftools.blocks.storage.RemoteStorageItemContainer)

Example 4 with StorageScannerContainer

use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.

the class StorageTerminalBlock method createClientGui.

@SideOnly(Side.CLIENT)
@Override
public GuiContainer createClientGui(EntityPlayer entityPlayer, TileEntity tileEntity) {
    if (!entityPlayer.isSneaking()) {
        ItemStack module = getModule(tileEntity);
        if (!module.isEmpty()) {
            int monitordim = RFToolsTools.getDimensionFromModule(module);
            BlockPos pos = RFToolsTools.getPositionFromModule(module);
            StorageScannerTileEntity te = new StorageScannerTileEntity(entityPlayer, monitordim) {

                @Override
                public BlockPos getCraftingGridContainerPos() {
                    // for this terminal itself.
                    return tileEntity.getPos();
                }

                @Override
                public CraftingGridProvider getCraftingGridProvider() {
                    return (CraftingGridProvider) tileEntity;
                }

                @Override
                public boolean isOpenWideView() {
                    TileEntity realTe = RFTools.proxy.getClientWorld().getTileEntity(pos);
                    if (realTe instanceof StorageScannerTileEntity) {
                        return ((StorageScannerTileEntity) realTe).isOpenWideView();
                    }
                    return true;
                }

                @Override
                public BlockPos getStorageScannerPos() {
                    return pos;
                }
            };
            // The position of the actual storage scanner is set on the dummy te
            te.setPos(pos);
            return new GuiStorageScanner(te, new StorageScannerContainer(entityPlayer, te, (CraftingGridProvider) tileEntity));
        }
    }
    return super.createClientGui(entityPlayer, tileEntity);
}
Also used : StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) GuiStorageScanner(mcjty.rftools.blocks.storagemonitor.GuiStorageScanner) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) CraftingGridProvider(mcjty.rftools.craftinggrid.CraftingGridProvider) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with StorageScannerContainer

use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.

the class PacketGridSync method handleMessage.

protected CraftingGridProvider handleMessage(World world, EntityPlayer player) {
    CraftingGridProvider provider = null;
    if (pos == null) {
        // Handle tablet version
        ItemStack mainhand = player.getHeldItemMainhand();
        if (!mainhand.isEmpty() && mainhand.getItem() == ModularStorageSetup.storageModuleTabletItem) {
            if (player.openContainer instanceof ModularStorageItemContainer) {
                ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) player.openContainer;
                provider = storageItemContainer.getCraftingGridProvider();
            } else if (player.openContainer instanceof RemoteStorageItemContainer) {
                RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) player.openContainer;
                provider = storageItemContainer.getCraftingGridProvider();
            } else if (player.openContainer instanceof StorageScannerContainer) {
                StorageScannerContainer storageItemContainer = (StorageScannerContainer) player.openContainer;
                provider = storageItemContainer.getStorageScannerTileEntity();
            }
        }
    } else {
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof CraftingGridProvider) {
            provider = ((CraftingGridProvider) te);
        }
    }
    if (provider != null) {
        for (int i = 0; i < recipes.size(); i++) {
            provider.setRecipe(i, recipes.get(i));
        }
    }
    return provider;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) ModularStorageItemContainer(mcjty.rftools.blocks.storage.ModularStorageItemContainer) ItemStack(net.minecraft.item.ItemStack) RemoteStorageItemContainer(mcjty.rftools.blocks.storage.RemoteStorageItemContainer)

Aggregations

StorageScannerContainer (mcjty.rftools.blocks.storagemonitor.StorageScannerContainer)8 ItemStack (net.minecraft.item.ItemStack)8 TileEntity (net.minecraft.tileentity.TileEntity)7 ModularStorageItemContainer (mcjty.rftools.blocks.storage.ModularStorageItemContainer)5 RemoteStorageItemContainer (mcjty.rftools.blocks.storage.RemoteStorageItemContainer)5 StorageScannerTileEntity (mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity)4 BlockPos (net.minecraft.util.math.BlockPos)4 GenericBlock (mcjty.lib.container.GenericBlock)2 GuiStorageScanner (mcjty.rftools.blocks.storagemonitor.GuiStorageScanner)2 ModifierContainer (mcjty.rftools.items.modifier.ModifierContainer)2 StorageFilterContainer (mcjty.rftools.items.storage.StorageFilterContainer)2 Block (net.minecraft.block.Block)2 WorldServer (net.minecraft.world.WorldServer)2 GuiModularStorage (mcjty.rftools.blocks.storage.GuiModularStorage)1 CraftingGridProvider (mcjty.rftools.craftinggrid.CraftingGridProvider)1 GuiChamberDetails (mcjty.rftools.items.builder.GuiChamberDetails)1 GuiShapeCard (mcjty.rftools.items.builder.GuiShapeCard)1 GuiDevelopersDelight (mcjty.rftools.items.creativeonly.GuiDevelopersDelight)1 GuiRFToolsManual (mcjty.rftools.items.manual.GuiRFToolsManual)1 GuiModifier (mcjty.rftools.items.modifier.GuiModifier)1