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);
}
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);
}
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;
}
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;
}
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);
}
Aggregations