Search in sources :

Example 51 with TextComponentTranslation

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

the class MetaTileEntityDieselEngine method addDisplayText.

@Override
protected void addDisplayText(List<ITextComponent> textList) {
    if (isStructureFormed()) {
        FluidStack lubricantStack = importFluidHandler.drain(Materials.Lubricant.getFluid(Integer.MAX_VALUE), false);
        FluidStack oxygenStack = importFluidHandler.drain(Materials.Oxygen.getFluid(Integer.MAX_VALUE), false);
        FluidStack fuelStack = ((DieselEngineWorkableHandler) workableHandler).getFuelStack();
        int lubricantAmount = lubricantStack == null ? 0 : lubricantStack.amount;
        int oxygenAmount = oxygenStack == null ? 0 : oxygenStack.amount;
        int fuelAmount = fuelStack == null ? 0 : fuelStack.amount;
        ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName());
        textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.lubricant_amount", lubricantAmount));
        textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.fuel_amount", fuelAmount, fuelName));
        textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.oxygen_amount", oxygenAmount));
        textList.add(new TextComponentTranslation(oxygenAmount >= 2 ? "gregtech.multiblock.diesel_engine.oxygen_boosted" : "gregtech.multiblock.diesel_engine.supply_oxygen_to_boost"));
    }
    super.addDisplayText(textList);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) FluidStack(net.minecraftforge.fluids.FluidStack) ITextComponent(net.minecraft.util.text.ITextComponent)

Example 52 with TextComponentTranslation

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

the class ModeSwitchBehavior method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        T currentMode = getModeFromItemStack(itemStack);
        int currentModeIndex = ArrayUtils.indexOf(enumConstants, currentMode);
        T nextMode = enumConstants[(currentModeIndex + 1) % enumConstants.length];
        setModeForItemStack(itemStack, nextMode);
        ITextComponent newModeComponent = new TextComponentTranslation(nextMode.getUnlocalizedName());
        ITextComponent textComponent = new TextComponentTranslation("metaitem.behavior.mode_switch.mode_switched", newModeComponent);
        player.sendStatusMessage(textComponent, true);
        return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
    }
    return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ItemStack(net.minecraft.item.ItemStack)

Example 53 with TextComponentTranslation

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

the class ScannerBehavior method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, EntityPlayer player) {
    if (!player.world.isRemote) {
        Pair<BlockPos, IBlockState> hitBlock = getHitBlock(player);
        if (hitBlock != null && checkCanUseScanner(stack, player, false).getLeft() == null) {
            ITextComponent component = new TextComponentTranslation("behavior.scanner.analyzing_complete");
            component.getStyle().setColor(TextFormatting.GOLD);
            player.sendStatusMessage(component, true);
            IScannableBlock magnifiableBlock = ((IScannableBlock) hitBlock.getRight().getBlock());
            List<ITextComponent> text = magnifiableBlock.getMagnifyResults(player.world, hitBlock.getLeft(), hitBlock.getRight(), player);
            text.forEach(player::sendMessage);
        }
    }
    return stack;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBlockState(net.minecraft.block.state.IBlockState) IScannableBlock(gregtech.api.items.toolitem.IScannableBlock) ITextComponent(net.minecraft.util.text.ITextComponent) BlockPos(net.minecraft.util.math.BlockPos)

Example 54 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Tropicraft by Tropicraft.

the class EntityKoaBase method processInteract.

@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
    if (hand != EnumHand.MAIN_HAND)
        return false;
    boolean ret = false;
    try {
        boolean doTrade = false;
        if (!this.world.isRemote) {
            long diveTime = 0;
            // scan hotbar
            for (int i = 0; i < 9; i++) {
                ItemStack stackScan = player.inventory.getStackInSlot(i);
                if (!Util.isEmpty(stackScan) && stackScan.getItem() == ItemRegistry.diveComputer) {
                    // for testing
                    // ((ItemDiveComputer)stackScan.getItem()).setDiveTime(stackScan, 60 * 59);
                    diveTime = ((ItemDiveComputer) stackScan.getItem()).getDiveTime(stackScan);
                    break;
                }
            }
            if (diveTime >= DIVE_TIME_NEEDED) {
                if (world.getTotalWorldTime() > lastTradeTime + TRADE_COOLDOWN) {
                    if (player.inventory.addItemStackToInventory(new ItemStack(ItemRegistry.trimix, 1))) {
                        player.sendMessage(new TextComponentTranslation("entity.tropicraft.koa.trade.give"));
                        lastTradeTime = world.getTotalWorldTime();
                    } else {
                        player.sendMessage(new TextComponentTranslation("entity.tropicraft.koa.trade.space"));
                    }
                } else {
                    player.sendMessage(new TextComponentTranslation("entity.tropicraft.koa.trade.cooldown"));
                }
            } else {
                int timeLeft = (int) (DIVE_TIME_NEEDED - diveTime) / 60;
                if (timeLeft == 0)
                    timeLeft = 1;
                player.sendMessage(new TextComponentTranslation("entity.tropicraft.koa.trade.not_enough_time", timeLeft));
            }
            if (doTrade) {
                // Make the super method think this villager is already trading, to block the GUI from opening
                _buyingPlayer.set(this, player);
                ret = super.processInteract(player, hand);
                _buyingPlayer.set(this, null);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ret;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ItemStack(net.minecraft.item.ItemStack)

Example 55 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Tropicraft by Tropicraft.

the class ItemCoconutBomb method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemstack = player.getHeldItem(hand);
    if (!itemstack.isEmpty()) {
        itemstack.shrink(1);
    }
    world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 1f * 0.5F);
    if (!world.isRemote) {
        if (ArrayUtils.contains(TropicsConfigs.coconutBombWhitelist, player.getGameProfile().getName())) {
            world.spawnEntity(new EntityCoconutGrenade(world, player));
        } else {
            player.sendMessage(new TextComponentTranslation(I18n.translateToLocal("tropicraft.coconutBombWarning")));
        }
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityCoconutGrenade(net.tropicraft.core.common.entity.projectile.EntityCoconutGrenade) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)502 ItemStack (net.minecraft.item.ItemStack)134 ITextComponent (net.minecraft.util.text.ITextComponent)82 EntityPlayer (net.minecraft.entity.player.EntityPlayer)72 BlockPos (net.minecraft.util.math.BlockPos)70 TextComponentString (net.minecraft.util.text.TextComponentString)66 Style (net.minecraft.util.text.Style)60 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)58 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)33 ArrayList (java.util.ArrayList)32 World (net.minecraft.world.World)30 IBlockState (net.minecraft.block.state.IBlockState)28 EnumFacing (net.minecraft.util.EnumFacing)26 CommandException (net.minecraft.command.CommandException)25 Block (net.minecraft.block.Block)20 Nonnull (javax.annotation.Nonnull)19 WrongUsageException (net.minecraft.command.WrongUsageException)19 EnumActionResult (net.minecraft.util.EnumActionResult)19