Search in sources :

Example 26 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project Overloaded by CJ-MC-Mods.

the class ToggleButton method toggle.

public void toggle() {
    booleanState = !booleanState;
    this.setMessage(new StringTextComponent(String.format("%s %b", baseText, booleanState)));
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 27 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent 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:"));
}
Also used : Default(com.cjm721.overloaded.item.functional.armor.MultiArmorConstants.Default) OverloadedConfig(com.cjm721.overloaded.config.OverloadedConfig) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) DataKeys(com.cjm721.overloaded.item.functional.armor.MultiArmorConstants.DataKeys) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Overloaded(com.cjm721.overloaded.Overloaded) MultiArmorSettingsMessage(com.cjm721.overloaded.network.packets.MultiArmorSettingsMessage) GenericSlider(com.cjm721.overloaded.client.gui.button.GenericSlider) ToggleButton(com.cjm721.overloaded.client.gui.button.ToggleButton) GENERIC_DATA_STORAGE(com.cjm721.overloaded.capabilities.CapabilityGenericDataStorage.GENERIC_DATA_STORAGE) Dist(net.minecraftforge.api.distmarker.Dist) LazyOptional(net.minecraftforge.common.util.LazyOptional) GuiPositiveFloatTextField(com.cjm721.overloaded.client.gui.button.GuiPositiveFloatTextField) ItemStack(net.minecraft.item.ItemStack) ItemMultiHelmet(com.cjm721.overloaded.item.functional.armor.ItemMultiHelmet) Screen(net.minecraft.client.gui.screen.Screen) Minecraft(net.minecraft.client.Minecraft) IGenericDataStorage(com.cjm721.overloaded.storage.IGenericDataStorage) Button(net.minecraft.client.gui.widget.button.Button) Map(java.util.Map) StringTextComponent(net.minecraft.util.text.StringTextComponent) Nonnull(javax.annotation.Nonnull) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) Nullable(javax.annotation.Nullable) ToggleButton(com.cjm721.overloaded.client.gui.button.ToggleButton) GuiPositiveFloatTextField(com.cjm721.overloaded.client.gui.button.GuiPositiveFloatTextField) IGenericDataStorage(com.cjm721.overloaded.storage.IGenericDataStorage) ToggleButton(com.cjm721.overloaded.client.gui.button.ToggleButton) Button(net.minecraft.client.gui.widget.button.Button) GenericSlider(com.cjm721.overloaded.client.gui.button.GenericSlider) StringTextComponent(net.minecraft.util.text.StringTextComponent) MultiArmorSettingsMessage(com.cjm721.overloaded.network.packets.MultiArmorSettingsMessage)

Example 28 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project Overloaded by CJ-MC-Mods.

the class RenderMultiToolAssist method onMouseEvent.

@SubscribeEvent
public static void onMouseEvent(InputEvent.MouseScrollEvent event) {
    ClientPlayerEntity player = Minecraft.getInstance().player;
    if (event.getScrollDelta() != 0 && player != null && player.isShiftKeyDown()) {
        ItemStack stack = player.getMainHandItem();
        if (player.isShiftKeyDown() && !stack.isEmpty() && stack.getItem() == ModItems.multiTool) {
            changeHelpMode((int) Math.round(event.getScrollDelta()));
            player.displayClientMessage(new StringTextComponent("Assist Mode: " + getAssistMode().getName()), true);
            event.setCanceled(true);
        }
    }
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 29 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class AnvilHandler method onAnvilUpdate.

@SubscribeEvent
@SuppressWarnings("unused")
public void onAnvilUpdate(AnvilUpdateEvent event) {
    ItemStack armor = ItemStack.EMPTY;
    if (event.getLeft().getItem() == AgriCraft.instance.getModItemRegistry().magnifying_glass) {
        armor = event.getRight();
    } else if (event.getRight().getItem() == AgriCraft.instance.getModItemRegistry().magnifying_glass) {
        armor = event.getLeft();
    }
    if (CapabilityGeneInspector.getInstance().shouldApplyCapability(armor)) {
        if (CapabilityGeneInspector.getInstance().hasInspectionCapability(armor)) {
            return;
        }
        ItemStack output = armor.copy();
        if (CapabilityGeneInspector.getInstance().applyInspectionCapability(output)) {
            // Set the name
            String inputName = event.getName();
            if (inputName == null || inputName.isEmpty()) {
                output.clearCustomName();
            } else {
                output.setDisplayName(new StringTextComponent(inputName));
            }
            // set output and cost
            event.setOutput(output);
            event.setCost(1);
        }
    }
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 30 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class JournalDataDrawerIntroduction method drawRightSheet.

@Override
public void drawRightSheet(IntroductionPage page, IPageRenderContext context, MatrixStack transforms, ItemStack stack, IAgriJournalItem journal) {
    float dy = 10;
    float dx = 6;
    float spacing = 4;
    // Title
    dy += context.drawText(transforms, INTRODUCTION, dx, dy);
    dy += spacing;
    // First paragraph
    dy += context.drawText(transforms, PARAGRAPH_1, dx, dy, 0.70F);
    dy += spacing;
    // Second paragraph
    dy += context.drawText(transforms, PARAGRAPH_2, dx, dy, 0.70F);
    dy += spacing;
    // Third paragraph
    dy += context.drawText(transforms, PARAGRAPH_3, dx, dy, 0.70F);
    dy += spacing;
    dy += spacing;
    // Final paragraph:
    ITextComponent discovered = new StringTextComponent("").appendSibling(DISCOVERED).appendString(": " + journal.getDiscoveredSeeds(stack).size() + " / " + AgriApi.getPlantRegistry().count());
    context.drawText(transforms, discovered, dx, dy, 0.70F);
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Aggregations

StringTextComponent (net.minecraft.util.text.StringTextComponent)31 ItemStack (net.minecraft.item.ItemStack)17 CompoundNBT (net.minecraft.nbt.CompoundNBT)7 TileEntity (net.minecraft.tileentity.TileEntity)5 Nonnull (javax.annotation.Nonnull)4 BlockPos (net.minecraft.util.math.BlockPos)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)4 IGenericDataStorage (com.cjm721.overloaded.storage.IGenericDataStorage)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 IEnergyStorage (net.minecraftforge.energy.IEnergyStorage)3 TileBPMicroblock (com.bluepowermod.tile.TileBPMicroblock)2 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)2 ItemSeedBag (com.infinityraider.agricraft.content.tools.ItemSeedBag)2 BlockState (net.minecraft.block.BlockState)2 Minecraft (net.minecraft.client.Minecraft)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2