use of com.cjm721.overloaded.client.gui.button.ToggleButton in project Overloaded by CJ-MC-Mods.
the class MultiArmorGuiScreen method init.
@Override
protected void init() {
super.init();
LazyOptional<IGenericDataStorage> opData = getHelmetDataStorage(Minecraft.getInstance().player);
if (!opData.isPresent()) {
this.minecraft.setScreen(null);
this.minecraft.player.displayClientMessage(new StringTextComponent("Multi-Helmet not equipped."), true);
return;
}
IGenericDataStorage data = opData.orElseThrow(() -> new RuntimeException("Impossible Condition"));
Map<String, Float> floats = data.getFloatMap();
Map<String, Boolean> booleans = data.getBooleanMap();
addButton(new Button(this.width / 2, this.height / 4 + 100, 150, 20, new StringTextComponent("Save"), b -> {
MultiArmorSettingsMessage message = new MultiArmorSettingsMessage((float) flightSpeed.getEffectiveValue(), (float) groundSpeed.getEffectiveValue(), noClipFlightLock.getBooleanState(), this.flightEnabled.getBooleanState(), this.feedEnabled.getBooleanState(), this.healEnabled.getBooleanState(), this.removeHarmfulEnabled.getBooleanState(), this.giveAirEnabled.getBooleanState(), this.extinguishEnabled.getBooleanState());
Overloaded.proxy.networkWrapper.sendToServer(message);
this.minecraft.setScreen(null);
}));
addButton(new Button(this.width / 2 - 150, this.height / 4 + 100, 150, 20, new StringTextComponent("Cancel"), b -> this.minecraft.setScreen(null)));
float flightSpeedValue = floats.getOrDefault(DataKeys.FLIGHT_SPEED, Default.FLIGHT_SPEED);
this.flightSpeed = addButton(new GenericSlider(this.width / 2 - 150, this.height / 4, 0, (float) OverloadedConfig.INSTANCE.multiArmorConfig.maxFlightSpeed, flightSpeedValue, "Flight Speed:"));
this.flightSpeedTextBox = addButton(new GuiPositiveFloatTextField(this.font, this.flightSpeed.x, this.flightSpeed.y, this.flightSpeed.getWidth(), this.flightSpeed.getHeight(), flightSpeedValue, 0, (float) OverloadedConfig.INSTANCE.multiArmorConfig.maxFlightSpeed));
this.flightSpeedTextBox.setVisible(false);
this.flightEnabled = addButton(new ToggleButton(this.width / 2 - 150, this.height / 4 + 20, booleans.getOrDefault(DataKeys.FLIGHT, Default.FLIGHT), "Flight:"));
float groundSpeedValue = floats.getOrDefault(DataKeys.GROUND_SPEED, Default.GROUND_SPEED);
this.groundSpeed = addButton(new GenericSlider(this.width / 2, this.height / 4, 0, (float) OverloadedConfig.INSTANCE.multiArmorConfig.maxGroundSpeed, groundSpeedValue, "Ground Speed:"));
this.groundSpeedTextBox = addButton(new GuiPositiveFloatTextField(this.font, this.groundSpeed.x, this.groundSpeed.y, this.groundSpeed.getWidth(), this.groundSpeed.getHeight(), groundSpeedValue, 0, (float) OverloadedConfig.INSTANCE.multiArmorConfig.maxGroundSpeed));
this.groundSpeedTextBox.setVisible(false);
this.feedEnabled = addButton(new ToggleButton(this.width / 2, this.height / 4 + 20, booleans.getOrDefault(DataKeys.FEED, Default.FEED), "Feeder:"));
this.healEnabled = addButton(new ToggleButton(this.width / 2 - 150, this.height / 4 + 40, booleans.getOrDefault(DataKeys.HEAL, Default.HEAL), "Healer:"));
this.removeHarmfulEnabled = addButton(new ToggleButton(this.width / 2, this.height / 4 + 40, booleans.getOrDefault(DataKeys.REMOVE_HARMFUL, Default.REMOVE_HARMFUL), "Remove Harmful Potions:"));
this.giveAirEnabled = addButton(new ToggleButton(this.width / 2 - 150, this.height / 4 + 60, booleans.getOrDefault(DataKeys.GIVE_AIR, Default.GIVE_AIR), "Airer:"));
this.extinguishEnabled = addButton(new ToggleButton(this.width / 2, this.height / 4 + 60, booleans.getOrDefault(DataKeys.EXTINGUISH, Default.EXTINGUISH), "Extinguisher:"));
this.noClipFlightLock = addButton(new ToggleButton(this.width / 2 - 75, this.height / 4 + 80, booleans.getOrDefault(DataKeys.NOCLIP_FLIGHT_LOCK, Default.NOCLIP_FLIGHT_LOCK), "No Clip Flight Lock:"));
}
Aggregations