Search in sources :

Example 81 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project BloodMagic by WayofTime.

the class RitualLivingArmourDowngrade method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    BlockPos masterPos = masterRitualStone.getBlockPos();
    AreaDescriptor downgradeRange = getBlockRange(DOWNGRADE_RANGE);
    boolean isActivatorPresent = false;
    for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) {
        if (player.getGameProfile().getId().equals(masterRitualStone.getOwner())) {
            ItemStack keyStack = getStackFromItemFrame(world, masterPos, masterRitualStone.getDirection());
            if (keyStack.isEmpty()) {
                return;
            }
            List<ITextComponent> textList = LivingArmourDowngradeRecipeRegistry.getDialogForProcessTick(keyStack, internalTimer);
            if (textList != null) {
                ChatUtil.sendChat(player, textList.toArray(new ITextComponent[textList.size()]));
            }
            internalTimer++;
            if (player.isSneaking()) {
                double distance2 = masterPos.offset(EnumFacing.UP).distanceSqToCenter(player.posX, player.posY, player.posZ);
                if (distance2 > 1) {
                    return;
                }
                BlockPos chestPos = masterPos.offset(masterRitualStone.getDirection(), 2).offset(EnumFacing.UP);
                TileEntity tile = world.getTileEntity(chestPos);
                if (tile == null) {
                    return;
                }
                IItemHandler inv = Utils.getInventory(tile, null);
                if (inv != null) {
                    List<ItemStack> recipeList = new ArrayList<>();
                    for (int i = 0; i < inv.getSlots(); i++) {
                        ItemStack invStack = inv.getStackInSlot(i);
                        if (!invStack.isEmpty()) {
                            recipeList.add(invStack);
                        }
                    }
                    LivingArmourDowngradeRecipe recipe = LivingArmourDowngradeRecipeRegistry.getMatchingRecipe(keyStack, recipeList, world, masterPos);
                    if (recipe != null) {
                        LivingArmourUpgrade upgrade = recipe.getRecipeOutput();
                        if (LivingArmour.hasFullSet(player)) {
                            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
                            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
                            if (armour != null) {
                                if (armour.canApplyUpgrade(player, upgrade)) {
                                    if (armour.upgradeArmour(player, upgrade)) {
                                        ItemLivingArmour.setLivingArmour(chestStack, armour);
                                        recipe.consumeInventory(inv);
                                        EntityLightningBolt lightning = new EntityLightningBolt(world, chestPos.getX(), chestPos.getY(), chestPos.getZ(), true);
                                        world.spawnEntity(lightning);
                                        masterRitualStone.setActive(false);
                                    }
                                } else {
                                // TODO: You are not able to receive my blessing...
                                // TODO: Need to add a timer that will stop it from working.
                                }
                            }
                        }
                    }
                }
            }
            return;
        }
    }
    if (!isActivatorPresent) {
        internalTimer = 0;
    }
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) LivingArmourDowngradeRecipe(WayofTime.bloodmagic.recipe.LivingArmourDowngradeRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 82 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class MetaTileEntityLargeBoiler method addDisplayText.

@Override
protected void addDisplayText(List<ITextComponent> textList) {
    super.addDisplayText(textList);
    if (isStructureFormed()) {
        textList.add(new TextComponentTranslation("gregtech.multiblock.large_boiler.temperature", currentTemperature, boilerType.maxTemperature));
        textList.add(new TextComponentTranslation("gregtech.multiblock.large_boiler.steam_output", lastTickSteamOutput, boilerType.baseSteamOutput));
        ITextComponent heatEffText = new TextComponentTranslation("gregtech.multiblock.large_boiler.heat_efficiency", (int) (getHeatEfficiencyMultiplier() * 100));
        withHoverTextTranslate(heatEffText, "gregtech.multiblock.large_boiler.heat_efficiency.tooltip");
        textList.add(heatEffText);
        ITextComponent throttleText = new TextComponentTranslation("gregtech.multiblock.large_boiler.throttle", throttlePercentage, (int) (getThrottleEfficiency() * 100));
        withHoverTextTranslate(throttleText, "gregtech.multiblock.large_boiler.throttle.tooltip");
        textList.add(throttleText);
        ITextComponent buttonText = new TextComponentTranslation("gregtech.multiblock.large_boiler.throttle_modify");
        buttonText.appendText(" ");
        buttonText.appendSibling(withButton(new TextComponentString("[-]"), "sub"));
        buttonText.appendText(" ");
        buttonText.appendSibling(withButton(new TextComponentString("[+]"), "add"));
        textList.add(buttonText);
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 83 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class MultiblockWithDisplayBase method addDisplayText.

/**
 * Called serverside to obtain text displayed in GUI
 * each element of list is displayed on new line
 * to use translation, use TextComponentTranslation
 */
protected void addDisplayText(List<ITextComponent> textList) {
    if (!isStructureFormed()) {
        ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.invalid_structure.tooltip");
        tooltip.setStyle(new Style().setColor(TextFormatting.GRAY));
        textList.add(new TextComponentTranslation("gregtech.multiblock.invalid_structure").setStyle(new Style().setColor(TextFormatting.RED).setHoverEvent(new HoverEvent(Action.SHOW_TEXT, tooltip))));
    }
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style)

Example 84 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class BlockSurfaceRockNew method getMagnifyResults.

@Override
public List<ITextComponent> getMagnifyResults(IBlockAccess world, BlockPos pos, IBlockState blockState, EntityPlayer player) {
    TileEntitySurfaceRock tileEntity = getTileEntity(world, pos);
    if (tileEntity == null) {
        return Collections.emptyList();
    }
    List<Material> materials = tileEntity.getUndergroundMaterials();
    ITextComponent materialComponent = new TextComponentTranslation(tileEntity.getMaterial().getUnlocalizedName());
    materialComponent.getStyle().setColor(TextFormatting.GREEN);
    ITextComponent baseComponent = new TextComponentString("");
    ITextComponent separator = new TextComponentString(", ");
    separator.getStyle().setColor(TextFormatting.GRAY);
    for (int i = 0; i < materials.size(); i++) {
        ITextComponent extraComponent = new TextComponentTranslation(materials.get(i).getUnlocalizedName());
        extraComponent.getStyle().setColor(TextFormatting.YELLOW);
        baseComponent.appendSibling(extraComponent);
        if (i + 1 != materials.size())
            baseComponent.appendSibling(separator);
    }
    ArrayList<ITextComponent> result = new ArrayList<>();
    result.add(new TextComponentTranslation("gregtech.block.surface_rock.material", materialComponent));
    result.add(new TextComponentTranslation("gregtech.block.surface_rock.underground_materials", baseComponent));
    return result;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) Material(gregtech.api.unification.material.type.Material) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 85 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.

the class CoverFluidRegulator method getHoverString.

protected void getHoverString(List<ITextComponent> textList) {
    switch(this.transferMode) {
        case KEEP_EXACT:
            ITextComponent keepComponent = new TextComponentString(getTransferSizeString());
            TextComponentTranslation hoverKeep = new TextComponentTranslation("cover.fluid_regulator.keep_exact", this.keepAmount);
            keepComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverKeep));
            textList.add(keepComponent);
            break;
        case TRANSFER_EXACT:
            ITextComponent supplyComponent = new TextComponentString(getTransferSizeString());
            TextComponentTranslation hoverSupply = new TextComponentTranslation("cover.fluid_regulator.supply_exact", this.supplyAmount);
            supplyComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverSupply));
            textList.add(supplyComponent);
            break;
    }
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

ITextComponent (net.minecraft.util.text.ITextComponent)116 TextComponentString (net.minecraft.util.text.TextComponentString)53 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)43 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 ItemStack (net.minecraft.item.ItemStack)17 Style (net.minecraft.util.text.Style)17 ClickEvent (net.minecraft.util.text.event.ClickEvent)16 HoverEvent (net.minecraft.util.text.event.HoverEvent)9 ArrayList (java.util.ArrayList)8 BlockPos (net.minecraft.util.math.BlockPos)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 Minecraft (net.minecraft.client.Minecraft)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 Text (org.spongepowered.api.text.Text)4 MagicBook (cavern.magic.MagicBook)3 SpecialMagic (cavern.magic.SpecialMagic)3 Matcher (java.util.regex.Matcher)3 TileEntity (net.minecraft.tileentity.TileEntity)3 SoundEvent (net.minecraft.util.SoundEvent)3 TextFormatting (net.minecraft.util.text.TextFormatting)3