Search in sources :

Example 1 with ModularStorageItemContainer

use of mcjty.rftools.blocks.storage.ModularStorageItemContainer 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 2 with ModularStorageItemContainer

use of mcjty.rftools.blocks.storage.ModularStorageItemContainer 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)

Example 3 with ModularStorageItemContainer

use of mcjty.rftools.blocks.storage.ModularStorageItemContainer in project RFTools by McJty.

the class StorageCraftingTools method requestGridSync.

public static void requestGridSync(EntityPlayer player, BlockPos pos) {
    World world = player.getEntityWorld();
    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) {
        RFToolsMessages.INSTANCE.sendTo(new PacketGridToClient(pos, provider.getCraftingGrid()), (EntityPlayerMP) player);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) ModularStorageItemContainer(mcjty.rftools.blocks.storage.ModularStorageItemContainer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) RemoteStorageItemContainer(mcjty.rftools.blocks.storage.RemoteStorageItemContainer)

Example 4 with ModularStorageItemContainer

use of mcjty.rftools.blocks.storage.ModularStorageItemContainer in project RFTools by McJty.

the class GuiProxy method getClientGuiElement.

@Override
public Object getClientGuiElement(int guiid, EntityPlayer entityPlayer, World world, int x, int y, int z) {
    if (guiid == RFTools.GUI_MANUAL_MAIN) {
        return new GuiRFToolsManual(GuiRFToolsManual.MANUAL_MAIN);
    } else if (guiid == RFTools.GUI_MANUAL_SHAPE) {
        return new GuiRFToolsManual(GuiRFToolsManual.MANUAL_SHAPE);
    } else if (guiid == RFTools.GUI_TELEPORTPROBE) {
        return new GuiTeleportProbe();
    } else if (guiid == RFTools.GUI_ADVANCEDPORTER) {
        return new GuiAdvancedPorter();
    } else if (guiid == RFTools.GUI_LIST_BLOCKS) {
        return new GuiNetworkMonitor();
    } else if (guiid == RFTools.GUI_DEVELOPERS_DELIGHT) {
        return new GuiDevelopersDelight();
    } else if (guiid == RFTools.GUI_REMOTE_STORAGE_ITEM) {
        return new GuiModularStorage(new RemoteStorageItemContainer(entityPlayer));
    } else if (guiid == RFTools.GUI_REMOTE_STORAGESCANNER_ITEM) {
        ItemStack tablet = entityPlayer.getHeldItemMainhand();
        int monitordim = RFToolsTools.getDimensionFromModule(tablet);
        BlockPos pos = RFToolsTools.getPositionFromModule(tablet);
        StorageScannerTileEntity te = new StorageScannerTileEntity(entityPlayer, monitordim) {

            @Override
            public BlockPos getCraftingGridContainerPos() {
                // We are a handheld so we return a null pos for the craftinggrid
                return null;
            }

            @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));
    } else if (guiid == RFTools.GUI_MODULAR_STORAGE_ITEM) {
        return new GuiModularStorage(new ModularStorageItemContainer(entityPlayer));
    } else if (guiid == RFTools.GUI_STORAGE_FILTER) {
        return new GuiStorageFilter(new StorageFilterContainer(entityPlayer));
    } else if (guiid == RFTools.GUI_MODIFIER_MODULE) {
        return new GuiModifier(new ModifierContainer(entityPlayer));
    } else if (guiid == RFTools.GUI_SHAPECARD) {
        return new GuiShapeCard(false);
    } else if (guiid == RFTools.GUI_SHAPECARD_COMPOSER) {
        return new GuiShapeCard(true);
    } else if (guiid == RFTools.GUI_CHAMBER_DETAILS) {
        return new GuiChamberDetails();
    }
    // if (guiid == RFTools.GUI_LIST_BLOCKS) {
    // return new GuiNetworkMonitor();
    // } else if (guiid == RFTools.GUI_DEVELOPERS_DELIGHT) {
    // return new GuiDevelopersDelight();
    // } else if (guiid == RFTools.GUI_MANUAL_DIMENSION) {
    // return new GuiRFToolsManual(GuiRFToolsManual.MANUAL_DIMENSION);
    // }
    BlockPos pos = new BlockPos(x, y, z);
    Block block = world.getBlockState(pos).getBlock();
    if (block instanceof GenericBlock) {
        GenericBlock<?, ?> genericBlock = (GenericBlock<?, ?>) block;
        TileEntity te = world.getTileEntity(pos);
        return genericBlock.createClientGui(entityPlayer, te);
    }
    return null;
}
Also used : GuiModularStorage(mcjty.rftools.blocks.storage.GuiModularStorage) GuiStorageScanner(mcjty.rftools.blocks.storagemonitor.GuiStorageScanner) GuiAdvancedPorter(mcjty.rftools.items.teleportprobe.GuiAdvancedPorter) GuiModifier(mcjty.rftools.items.modifier.GuiModifier) GuiShapeCard(mcjty.rftools.items.builder.GuiShapeCard) ModularStorageItemContainer(mcjty.rftools.blocks.storage.ModularStorageItemContainer) GuiStorageFilter(mcjty.rftools.items.storage.GuiStorageFilter) StorageFilterContainer(mcjty.rftools.items.storage.StorageFilterContainer) GuiTeleportProbe(mcjty.rftools.items.teleportprobe.GuiTeleportProbe) RemoteStorageItemContainer(mcjty.rftools.blocks.storage.RemoteStorageItemContainer) GuiChamberDetails(mcjty.rftools.items.builder.GuiChamberDetails) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) GenericBlock(mcjty.lib.container.GenericBlock) GuiDevelopersDelight(mcjty.rftools.items.creativeonly.GuiDevelopersDelight) GuiNetworkMonitor(mcjty.rftools.items.netmonitor.GuiNetworkMonitor) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) GenericBlock(mcjty.lib.container.GenericBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) GuiRFToolsManual(mcjty.rftools.items.manual.GuiRFToolsManual) ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) ModifierContainer(mcjty.rftools.items.modifier.ModifierContainer)

Example 5 with ModularStorageItemContainer

use of mcjty.rftools.blocks.storage.ModularStorageItemContainer in project RFTools by McJty.

the class GuiProxy method getServerGuiElement.

@Override
public Object getServerGuiElement(int guiid, EntityPlayer entityPlayer, World world, int x, int y, int z) {
    if (guiid == RFTools.GUI_MANUAL_MAIN || guiid == RFTools.GUI_MANUAL_SHAPE || guiid == RFTools.GUI_TELEPORTPROBE || guiid == RFTools.GUI_ADVANCEDPORTER || guiid == RFTools.GUI_SHAPECARD || guiid == RFTools.GUI_SHAPECARD_COMPOSER || guiid == RFTools.GUI_CHAMBER_DETAILS || guiid == RFTools.GUI_DEVELOPERS_DELIGHT || guiid == RFTools.GUI_LIST_BLOCKS) {
        return null;
    } else if (guiid == RFTools.GUI_REMOTE_STORAGE_ITEM) {
        return new RemoteStorageItemContainer(entityPlayer);
    } else if (guiid == RFTools.GUI_REMOTE_STORAGESCANNER_ITEM) {
        // We are in a tablet
        ItemStack tablet = entityPlayer.getHeldItemMainhand();
        int monitordim = RFToolsTools.getDimensionFromModule(tablet);
        BlockPos pos = RFToolsTools.getPositionFromModule(tablet);
        WorldServer w = DimensionManager.getWorld(monitordim);
        if (w == null) {
            return null;
        }
        TileEntity te = w.getTileEntity(pos);
        if (!(te instanceof StorageScannerTileEntity)) {
            return null;
        }
        return new StorageScannerContainer(entityPlayer, (IInventory) te);
    } else if (guiid == RFTools.GUI_MODULAR_STORAGE_ITEM) {
        return new ModularStorageItemContainer(entityPlayer);
    } else if (guiid == RFTools.GUI_STORAGE_FILTER) {
        return new StorageFilterContainer(entityPlayer);
    } else if (guiid == RFTools.GUI_MODIFIER_MODULE) {
        return new ModifierContainer(entityPlayer);
    }
    // if (guiid == RFTools.GUI_LIST_BLOCKS || guiid == RFTools.GUI_DEVELOPERS_DELIGHT ||
    // guiid == RFTools.GUI_MANUAL_DIMENSION || guiid == RFTools.GUI_CHAMBER_DETAILS || guiid == RFTools.GUI_SHAPECARD) {
    // return null;
    // }
    BlockPos pos = new BlockPos(x, y, z);
    Block block = world.getBlockState(pos).getBlock();
    if (block instanceof GenericBlock) {
        GenericBlock<?, ?> genericBlock = (GenericBlock<?, ?>) block;
        TileEntity te = world.getTileEntity(pos);
        return genericBlock.createServerContainer(entityPlayer, te);
    }
    return null;
}
Also used : WorldServer(net.minecraft.world.WorldServer) ModularStorageItemContainer(mcjty.rftools.blocks.storage.ModularStorageItemContainer) StorageFilterContainer(mcjty.rftools.items.storage.StorageFilterContainer) RemoteStorageItemContainer(mcjty.rftools.blocks.storage.RemoteStorageItemContainer) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) GenericBlock(mcjty.lib.container.GenericBlock) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) GenericBlock(mcjty.lib.container.GenericBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) ModifierContainer(mcjty.rftools.items.modifier.ModifierContainer)

Aggregations

ModularStorageItemContainer (mcjty.rftools.blocks.storage.ModularStorageItemContainer)5 RemoteStorageItemContainer (mcjty.rftools.blocks.storage.RemoteStorageItemContainer)5 StorageScannerContainer (mcjty.rftools.blocks.storagemonitor.StorageScannerContainer)5 ItemStack (net.minecraft.item.ItemStack)5 TileEntity (net.minecraft.tileentity.TileEntity)5 GenericBlock (mcjty.lib.container.GenericBlock)2 StorageScannerTileEntity (mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity)2 ModifierContainer (mcjty.rftools.items.modifier.ModifierContainer)2 StorageFilterContainer (mcjty.rftools.items.storage.StorageFilterContainer)2 Block (net.minecraft.block.Block)2 BlockPos (net.minecraft.util.math.BlockPos)2 GuiModularStorage (mcjty.rftools.blocks.storage.GuiModularStorage)1 GuiStorageScanner (mcjty.rftools.blocks.storagemonitor.GuiStorageScanner)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 GuiNetworkMonitor (mcjty.rftools.items.netmonitor.GuiNetworkMonitor)1 GuiStorageFilter (mcjty.rftools.items.storage.GuiStorageFilter)1