use of gregtech.common.terminal.hardware.DeviceHardware in project GregTech by GregTechCEu.
the class TerminalRegistry method init.
public static void init() {
// register hardware
registerHardware(new BatteryHardware());
int deviceSize = DeviceHardware.DEVICE.values().length;
for (int i = 1; i < deviceSize; i++) {
registerHardware(new DeviceHardware(i));
}
// register applications
AppRegistryBuilder.create(new SimpleMachineGuideApp()).defaultApp().build();
AppRegistryBuilder.create(new MultiBlockGuideApp()).defaultApp().build();
AppRegistryBuilder.create(new ItemGuideApp()).defaultApp().build();
AppRegistryBuilder.create(new TutorialGuideApp()).defaultApp().build();
AppRegistryBuilder.create(new GuideEditorApp()).defaultApp().build();
AppRegistryBuilder.create(new SettingsApp()).defaultApp().build();
AppRegistryBuilder.create(new PongApp()).battery(GTValues.LV, 75).build();
AppRegistryBuilder.create(new MazeApp()).battery(GTValues.LV, 150).build();
AppRegistryBuilder.create(new MinesweeperApp()).battery(GTValues.LV, 150).build();
AppRegistryBuilder.create(new ProspectorApp(0)).battery(0, GTValues.LV, 640).battery(1, GTValues.LV, 640).battery(2, GTValues.MV, 1000).battery(3, GTValues.HV, 1500).battery(4, GTValues.HV, 1500).upgrade(0, MetaItems.SENSOR_LV.getStackForm(1)).upgrade(1, MetaItems.SENSOR_HV.getStackForm(1)).upgrade(2, MetaItems.SENSOR_EV.getStackForm(1)).upgrade(3, MetaItems.SENSOR_IV.getStackForm(1)).upgrade(4, MetaItems.SENSOR_LuV.getStackForm(1)).device(0, DeviceHardware.DEVICE.PROSPECTOR_LV).device(1, DeviceHardware.DEVICE.PROSPECTOR_LV).device(2, DeviceHardware.DEVICE.PROSPECTOR_LV).device(3, DeviceHardware.DEVICE.PROSPECTOR_HV).device(4, DeviceHardware.DEVICE.PROSPECTOR_HV).build();
AppRegistryBuilder.create(new ProspectorApp(1)).battery(0, GTValues.MV, 1000).battery(1, GTValues.MV, 1000).battery(2, GTValues.HV, 1500).battery(3, GTValues.HV, 1500).battery(4, GTValues.HV, 1500).upgrade(0, MetaItems.SENSOR_HV.getStackForm(1)).upgrade(1, MetaItems.SENSOR_HV.getStackForm(3)).upgrade(2, MetaItems.SENSOR_EV.getStackForm(1)).upgrade(3, MetaItems.SENSOR_IV.getStackForm(1)).upgrade(4, MetaItems.SENSOR_LuV.getStackForm(1)).device(DeviceHardware.DEVICE.PROSPECTOR_HV).build();
AppRegistryBuilder.create(new MultiBlockPreviewARApp()).battery(GTValues.LV, 128).device(DeviceHardware.DEVICE.CAMERA).upgrade(1, MetaItems.EMITTER_HV.getStackForm(4), MetaItems.WORKSTATION_EV.getStackForm(2)).defaultApp().build();
if (Loader.isModLoaded(GTValues.MODID_JEI)) {
AppRegistryBuilder.create(new RecipeChartApp()).battery(GTValues.LV, 160).upgrade(0, new ItemStack(Items.PAPER, 32)).upgrade(1, new ItemStack(Items.PAPER, 64)).upgrade(2, MetaItems.RANDOM_ACCESS_MEMORY.getStackForm(16)).upgrade(3, MetaItems.RANDOM_ACCESS_MEMORY.getStackForm(32)).build();
}
AppRegistryBuilder.create(new ConsoleApp()).battery(GTValues.LV, 500).device(DeviceHardware.DEVICE.WIRELESS).build();
AppRegistryBuilder.create(new BatteryManagerApp()).defaultApp().battery(GTValues.ULV, 0).build();
AppRegistryBuilder.create(new HardwareManagerApp()).defaultApp().build();
AppRegistryBuilder.create(new AppStoreApp()).defaultApp().build();
AppRegistryBuilder.create(new WorldProspectorARApp()).battery(GTValues.LV, 320).upgrade(0, MetaItems.EMITTER_LV.getStackForm(2)).upgrade(1, MetaItems.EMITTER_MV.getStackForm(2)).upgrade(2, MetaItems.EMITTER_HV.getStackForm(2)).device(DeviceHardware.DEVICE.CAMERA).build();
AppRegistryBuilder.create(new VirtualTankApp()).battery(GTValues.MV, 500).device(DeviceHardware.DEVICE.WIRELESS).build();
AppRegistryBuilder.create(new CapeSelectorApp()).battery(GTValues.ULV, 8).build();
if (Loader.isModLoaded(GTValues.MODID_CT)) {
// handle CT register
CTTerminalRegistry.register();
}
}
use of gregtech.common.terminal.hardware.DeviceHardware in project GregTech by GregTechCEu.
the class TerminalOSWidget method disCharge.
private long disCharge() {
IElectricItem electricItem = hardwareProvider.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
if (electricItem != null && !TerminalBehaviour.isCreative(itemStack)) {
AtomicLong costs = new AtomicLong(0);
List<AbstractApplication> charged = new ArrayList<>();
for (AbstractApplication openedApp : openedApps) {
TerminalRegistry.getAppHardwareDemand(openedApp.getRegistryName(), openedApp.getAppTier()).stream().filter(i -> i instanceof BatteryHardware).findFirst().ifPresent(battery -> {
costs.addAndGet(((BatteryHardware) battery).getCharge());
charged.add(openedApp);
});
}
for (DeviceHardware hardware : getHardware(DeviceHardware.class)) {
if (hardware.getDevice() == DeviceHardware.DEVICE.SOLAR_LV) {
costs.addAndGet(-200);
}
}
if (costs.get() > 0 && electricItem.discharge(costs.get(), 999, true, false, false) != costs.get()) {
charged.forEach(app -> closeApplication(app, false));
} else if (costs.get() < 0) {
electricItem.charge(-costs.get(), 999, true, false);
}
return electricItem.getCharge();
}
return lastCharge;
}
Aggregations