Search in sources :

Example 1 with ScreenModule

use of mcjty.rftools.blocks.screens.modules.ScreenModule in project RFTools by McJty.

the class ScreenTileEntity method hitScreenServer.

private void hitScreenServer(int x, int y, int module) {
    List<ScreenModule> screenModules = getScreenModules();
    ScreenModule screenModule = screenModules.get(module);
    if (screenModule != null) {
        screenModule.mouseClick(worldObj, x, y, true);
        clickedModules.add(new ActivatedModule(module, 5, x, y));
    }
}
Also used : ScreenModule(mcjty.rftools.blocks.screens.modules.ScreenModule) ComputerScreenModule(mcjty.rftools.blocks.screens.modules.ComputerScreenModule) ClientScreenModule(mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule)

Example 2 with ScreenModule

use of mcjty.rftools.blocks.screens.modules.ScreenModule in project RFTools by McJty.

the class ScreenTileEntity method getScreenModules.

// This is called server side.
public List<ScreenModule> getScreenModules() {
    if (screenModules == null) {
        totalRfPerTick = 0;
        screenModules = new ArrayList<ScreenModule>();
        for (int i = 0; i < inventoryHelper.getCount(); i++) {
            ItemStack itemStack = inventoryHelper.getStackInSlot(i);
            if (itemStack != null && itemStack.getItem() instanceof ModuleProvider) {
                ModuleProvider moduleProvider = (ModuleProvider) itemStack.getItem();
                ScreenModule screenModule;
                try {
                    screenModule = moduleProvider.getServerScreenModule().newInstance();
                } catch (InstantiationException e) {
                    e.printStackTrace();
                    continue;
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                    continue;
                }
                screenModule.setupFromNBT(itemStack.getTagCompound(), worldObj.provider.dimensionId, xCoord, yCoord, zCoord);
                screenModules.add(screenModule);
                totalRfPerTick += screenModule.getRfPerTick();
                if (screenModule instanceof ComputerScreenModule) {
                    ComputerScreenModule computerScreenModule = (ComputerScreenModule) screenModule;
                    String tag = computerScreenModule.getTag();
                    if (!computerModules.containsKey(tag)) {
                        computerModules.put(tag, new ArrayList<ComputerScreenModule>());
                    }
                    computerModules.get(tag).add(computerScreenModule);
                }
            } else {
                // To keep the indexing correct so that the modules correspond with there slot number.
                screenModules.add(null);
            }
        }
    }
    return screenModules;
}
Also used : ScreenModule(mcjty.rftools.blocks.screens.modules.ScreenModule) ComputerScreenModule(mcjty.rftools.blocks.screens.modules.ComputerScreenModule) ClientScreenModule(mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule) ItemStack(net.minecraft.item.ItemStack) ComputerScreenModule(mcjty.rftools.blocks.screens.modules.ComputerScreenModule)

Example 3 with ScreenModule

use of mcjty.rftools.blocks.screens.modules.ScreenModule in project RFTools by McJty.

the class ScreenTileEntity method getScreenData.

// This is called server side.
public Map<Integer, Object[]> getScreenData(long millis) {
    Map<Integer, Object[]> map = new HashMap<Integer, Object[]>();
    List<ScreenModule> screenModules = getScreenModules();
    int moduleIndex = 0;
    for (ScreenModule module : screenModules) {
        if (module != null) {
            Object[] data = module.getData(worldObj, millis);
            if (data != null) {
                map.put(moduleIndex, data);
            }
        }
        moduleIndex++;
    }
    return map;
}
Also used : ScreenModule(mcjty.rftools.blocks.screens.modules.ScreenModule) ComputerScreenModule(mcjty.rftools.blocks.screens.modules.ComputerScreenModule) ClientScreenModule(mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule)

Aggregations

ComputerScreenModule (mcjty.rftools.blocks.screens.modules.ComputerScreenModule)3 ScreenModule (mcjty.rftools.blocks.screens.modules.ScreenModule)3 ClientScreenModule (mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule)3 ItemStack (net.minecraft.item.ItemStack)1