下面列出了怎么用net.minecraft.util.text.TextComponentTranslation的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
boolean flag = playerIn.capabilities.isCreativeMode;
if (flag || playerIn.getHeldItem(handIn).getItemDamage() <= playerIn.getHeldItem(handIn).getMaxDamage())
{
if (!worldIn.isRemote)
{
boolean isSpawnChunk = playerIn.dimension == TofuMain.TOFU_DIMENSION.getId() || EntityTofuSlime.isSpawnChunk(playerIn.world, playerIn.posX, playerIn.posZ);
if(isSpawnChunk) playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.success", new Object()));
else playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.failed", new Object()));
}
if (!playerIn.capabilities.isCreativeMode && playerIn.getHeldItem(handIn).isItemStackDamageable())
{
playerIn.getHeldItem(handIn).damageItem(1, playerIn);
}
playerIn.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5F, 1.0F);
}
return super.onItemRightClick(worldIn, playerIn, handIn);
}
/**
* Handles the servers ServerSideCheck.
* Checks both local and remote protocol versions for a mismatch.
* If no mismatch is found it does the following:
* Notifies ClientHandler of a world change.
* Resets all local data of that dimension.
* Requests the server for a LoginState.
* Finally it sets the availability of a ServerSide counterpart as true.
*
* @param serverProtocol The servers protocol version.
* @param worldName The dimension data to load.
* @param world The clients current world object.
*/
private void handleServerSideCheck(int serverProtocol, String worldName, World world) {
if (serverProtocol > NEIActions.protocol) {
NEIClientUtils.printChatMessage(new TextComponentTranslation("nei.chat.mismatch.client"));
} else if (serverProtocol < NEIActions.protocol) {
NEIClientUtils.printChatMessage(new TextComponentTranslation("nei.chat.mismatch.server"));
} else {
try {
ClientHandler.INSTANCE.loadWorld(world);
NEIClientConfig.loadWorld(getSaveName(worldName));
NEIClientConfig.setHasSMPCounterPart(true);
sendRequestLoginInfo();
} catch (Exception e) {
LogHelper.errorError("Error handling SMP Check", e);
}
}
}
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
if (stack.getItem() == null) {
player.sendMessage(setColour(new TextComponentTranslation("nei.chat.give.noitem"), TextFormatting.WHITE));
return;
}
int given = stack.getCount();
if (doGive) {
if (infinite) {
player.inventory.addItemStackToInventory(stack);
} else {
given -= InventoryUtils.insertItem(player.inventory, stack, false);
}
}
sendNotice(player, new TextComponentTranslation("commands.give.success", stack.getTextComponent(), infinite ? "\u221E" : Integer.toString(given), player.getName()), "notify-item");
player.openContainer.detectAndSendChanges();
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
if(worldIn.isRemote) return;
if(entityIn instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) entityIn;
ItemStack mainhand =player.getHeldItem(EnumHand.MAIN_HAND);
ItemStack offhand =player.getHeldItem(EnumHand.OFF_HAND);
boolean flag1 =!(mainhand.isEmpty())&&!(offhand.isEmpty()),
flag2 = mainhand.getItem() instanceof ItemShinai||offhand.getItem() instanceof ItemShinai;
if(flag1&&flag2) {
player.setItemStackToSlot((mainhand.getItem() instanceof ItemShinai)?EntityEquipmentSlot.OFFHAND:EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
player.dropItem((mainhand.getItem() instanceof ItemShinai)?offhand:mainhand, false);
player.sendStatusMessage(new TextComponentTranslation("sakura.katana.wrong_duel_shinai", new Object()), false);
}
}
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
if(worldIn.isRemote) return;
if(entityIn instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) entityIn;
ItemStack mainhand =player.getHeldItem(EnumHand.MAIN_HAND);
ItemStack offhand =player.getHeldItem(EnumHand.OFF_HAND);
boolean flag1 =!(mainhand.isEmpty())&&!(offhand.isEmpty()),
flag2 = mainhand.getItem() instanceof ItemKotachi && offhand.getItem() instanceof ItemKotachi;
if(flag1&&flag2) {
player.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
player.dropItem(offhand, false);
player.sendStatusMessage(new TextComponentTranslation("sakura.katana.wrong_duel", new Object()), false);
}
}
}
public static void setGamemode(EntityPlayerMP player, int mode) {
if (mode < 0 || mode >= NEIActions.gameModes.length || NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) && !NEIServerConfig.canPlayerPerformAction(player.getName(), NEIActions.gameModes[mode])) {
return;
}
//creative+
NEIServerConfig.getSaveForPlayer(player.getName()).changeActionState("creative+", mode == 2);
if (mode == 2 && !(player.openContainer instanceof ContainerCreativeInv))//open the container immediately for the client
{
NEIServerPacketHandler.processCreativeInv(player, true);
}
//change it on the server
player.interactionManager.setGameType(getGameType(mode));
//tell the client to change it
new PacketCustom(NEIServerPacketHandler.channel, 14).writeByte(mode).sendToPlayer(player);
player.sendMessage(new TextComponentTranslation("nei.chat.gamemode." + mode));
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if(!world.isRemote) {
String text = Math.random() >= 0.01 ? "Dab" : "Neat (is a mod by Vazkii)";
world.getMinecraftServer().getPlayerList().sendMessage(new TextComponentTranslation("chat.type.text", player.getName(), text));
if(Dabbbbb.whenUBoppin) {
for(int i = 0; i < 10; i++) {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1, (i / 10f) + 0.5f);
}
player.motionY += 10;
player.velocityChanged = true;
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException{
if(args.length == 0) throw new WrongUsageException("command.signals.noArgs");
String subCommand = args[0];
if(subCommand.equals("rebuildNetwork")) {
RailNetworkManager.getServerInstance().rebuildNetwork();
sender.sendMessage(new TextComponentTranslation("command.signals.networkCleared"));
} else if(subCommand.equals("debug") && sender.getName().startsWith("Player" /* Playerx */)) {
if(debug(server, sender, args)) {
sender.sendMessage(new TextComponentString("DEBUG EXECUTED"));
} else {
sender.sendMessage(new TextComponentString("Could not execute debug!"));
}
} else {
throw new WrongUsageException("command.signals.invalidSubCommand", subCommand);
}
}
@Override
public boolean onScrewdriverClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, CuboidRayTraceResult hitResult) {
if(facing == getOutputFacing()) {
if(!getWorld().isRemote) {
if(allowInputFromOutputSide) {
setAllowInputFromOutputSide(false);
playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.basic.input_from_output_side.disallow"));
} else {
setAllowInputFromOutputSide(true);
playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.basic.input_from_output_side.allow"));
}
}
return true;
}
return super.onScrewdriverClick(playerIn, hand, facing, hitResult);
}
@Override
protected void addDisplayText(List<ITextComponent> textList) {
if (isStructureFormed()) {
MetaTileEntityRotorHolder rotorHolder = getAbilities(ABILITY_ROTOR_HOLDER).get(0);
FluidStack fuelStack = ((LargeTurbineWorkableHandler) workableHandler).getFuelStack();
int fuelAmount = fuelStack == null ? 0 : fuelStack.amount;
ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName());
textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.fuel_amount", fuelAmount, fuelName));
if (rotorHolder.getRotorEfficiency() > 0.0) {
textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_speed", rotorHolder.getCurrentRotorSpeed(), rotorHolder.getMaxRotorSpeed()));
textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_efficiency", (int) (rotorHolder.getRotorEfficiency() * 100)));
int rotorDurability = (int) (rotorHolder.getRotorDurability() * 100);
if (rotorDurability > MIN_DURABILITY_TO_WARN) {
textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_durability", rotorDurability));
} else {
textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.low_rotor_durability",
MIN_DURABILITY_TO_WARN, rotorDurability).setStyle(new Style().setColor(TextFormatting.RED)));
}
}
}
super.addDisplayText(textList);
}
@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);
}
public static void sendNotice(ICommandSender sender, ITextComponent msg, String permission) {
TextComponentTranslation notice = new TextComponentTranslation("chat.type.admin", sender.getName(), msg.createCopy());
notice.getStyle().setColor(TextFormatting.GRAY).setItalic(true);
if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission)) {
ServerUtils.mc().sendMessage(notice);
}
for (EntityPlayer p : ServerUtils.getPlayers()) {
if (p == sender) {
p.sendMessage(msg);
} else if (NEIServerConfig.canPlayerPerformAction(p.getName(), permission)) {
p.sendMessage(notice);
}
}
}
@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);
}
}
@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;
}
/**
* Only allow destination positions when:
* 1. The position is similar to a portal position (it can't be used to cheese long distance travel)
* 2. The receiving end has a teleport rail, to specify the destination direction.
*/
@Override
protected boolean isDestinationValid(MCPos destination, EntityPlayer player){
if(getWorld().provider.getDimension() == destination.getDimID()) {
player.sendMessage(new TextComponentTranslation("signals.message.teleport_rail_failed_same_dimension", destination.getX(), destination.getY(), destination.getZ()));
return false;
}
Pair<MCPos, MCPos> allowedDestinationRange = getAllowedDestinationRange(destination.getWorld());
if(allowedDestinationRange == null) {
player.sendMessage(new TextComponentTranslation("signals.message.teleport_rail_failed_unloaded_destination_dimension", destination.getX(), destination.getY(), destination.getZ()));
return false;
} else if(destination.isInAABB(allowedDestinationRange.getLeft(), allowedDestinationRange.getRight())) {
return true;
} else {
player.sendMessage(new TextComponentTranslation("signals.message.teleport_rail_failed_invalid_location", destination.getX(), destination.getY(), destination.getZ(), allowedDestinationRange.getLeft().getX(), allowedDestinationRange.getRight().getX(), allowedDestinationRange.getLeft().getZ(), allowedDestinationRange.getRight().getZ()));
return false;
}
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem();
if (!stack.isEmpty()) {
String text = String.format("模组ID:%s\n非本地化名称:%s\n显示名称:%s", stack.getItem().getCreatorModId(stack), stack.getItem().getUnlocalizedName(), stack.getDisplayName());
String url = I18nConfig.key.reportURL;
try {
GuiScreen.setClipboardString(text);
Desktop.getDesktop().browse(new URI(url));
} catch (Exception urlException) {
urlException.printStackTrace();
}
} else {
Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_report.empty"));
}
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
// 参数为空,警告
if (args.length == 0) {
Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.empty"));
return;
}
// 参数存在,进行下一步判定
if (Minecraft.getMinecraft().getResourceManager().getResourceDomains().contains(args[0])) {
Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.right_start", args[0]));
// 同名资源包存在,直接返回
if (!cerateTempLangpack(args[0])) {
Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.error_create_folder"));
return;
}
// 主下载功能
langFileDownloader(args[0]);
}
// 参数不存在,警告
else {
Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.not_found", args[0]));
}
}
private static ITextComponent stripEvents(ITextComponent c) {
Style modi = c.getStyle();
if (modi != null) {
modi.setClickEvent(null);
modi.setHoverEvent(null);
}
c.setStyle(modi);
if (c instanceof TextComponentTranslation) {
TextComponentTranslation cm = (TextComponentTranslation) c;
Object[] oo = cm.getFormatArgs();
for (int i = 0; i < oo.length; i++) {
Object o = oo[i];
if (o instanceof ITextComponent) {
oo[i] = stripEvents((ITextComponent) o);
}
}
}
List<ITextComponent> ls = c.getSiblings();
if (ls != null) {
for (int i = 0; i < ls.size(); i++) {
ls.set(i, stripEvents(ls.get(i)));
}
}
return c;
}
public static void init() {
MANAPOOL = new Advancement(
new ResourceLocation(Wizardry.MODID, "advancement.manapool"),
null,
new DisplayInfo(
new ItemStack(ModItems.ORB),
new TextComponentTranslation("wizardry.advancement.begin.name"),
new TextComponentTranslation("wizardry.advancement.begin.desc"),
null, FrameType.GOAL, true, true, false),
AdvancementRewards.EMPTY, new HashMap<>(), new String[0][0]);
// ModAdvancement("manapool", 1, -2, ModItems.ORB, null);
// BOOK = new ModAdvancement("book", 3, 0, ModItems.BOOK, MANAPOOL);
// DEVILDUST = new ModAdvancement("devildust", -1, 0, ModItems.DEVIL_DUST, null);
// CRUNCH = new ModAdvancement("crunch", 1, 2, Blocks.BEDROCK, null);
//
// PAGE = new AchievementPage(Wizardry.MODNAME, ModAdvancement.achievements.toArray(new Achievement[ModAdvancement.achievements.size()]));
// AchievementPage.registerAchievementPage(PAGE);
//
}
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand){
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote) {
TileEntity te = world.getTileEntity(pos);
if(te instanceof TileEntityStationMarker) {
TileEntityStationMarker stationMarker = (TileEntityStationMarker)te;
String stationName = stationMarker.getStationName();
appendDestination(stack, stationName);
String concatDestinations = getConcattedDestinations(stack);
player.sendMessage(new TextComponentTranslation("signals.message.added_destination", TextFormatting.GOLD + stationName + TextFormatting.WHITE, TextFormatting.GOLD + concatDestinations + TextFormatting.WHITE));
return EnumActionResult.SUCCESS;
}
}
return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
}
@Override
public ITextComponent getDisplayName() {
String s1 = null;
switch (this.getTofuProfession()) {
case GUARD:
s1 = "guard";
break;
case TOFUCOOK:
s1 = "tofucrafter";
break;
case FISHERMAN:
s1 = "fisherman";
break;
case TOFUSMITH:
s1 = "tofusmith";
break;
}
ITextComponent itextcomponent = new TextComponentTranslation("entity.Tofunian." + s1, new Object[0]);
itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
itextcomponent.getStyle().setInsertion(this.getCachedUniqueIdString());
return itextcomponent;
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(playerIn.isSneaking()) {
if(!worldIn.isRemote) {
TileEntityTransportRail te = (TileEntityTransportRail)worldIn.getTileEntity(pos);
te.toggleForward();
playerIn.sendMessage(new TextComponentTranslation("signals.message.teleport_rail_toggled_direction"));
}
return true;
} else {
return false;
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand){
if(!worldIn.isRemote) {
ItemStack stack = playerIn.getHeldItem(hand);
if(playerIn.isSneaking()) {
setDestinations(stack, Collections.emptyList());
stack.clearCustomName();
playerIn.sendMessage(new TextComponentTranslation("signals.message.cleared_ticket"));
} else {
playerIn.openGui(Signals.instance, CommonProxy.EnumGuiId.TICKET_DESTINATION.ordinal(), worldIn, 0, 0, 0);
}
}
return super.onItemRightClick(worldIn, playerIn, hand);
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
ExNihiloAdscensio.loadConfigs();
Config.doNormalConfig(new File(ExNihiloAdscensio.configDirectory, "ExNihiloAdscensio.cfg"));
sender.sendMessage(new TextComponentTranslation("commands.enreloadconfig.confirm"));
}
public static void setHourForward(World world, int hour, boolean notify) {
long day = (getTime(world) / 24000L) * 24000L;
long newTime = day + 24000L + hour * 1000;
setTime(newTime, world);
if (notify) {
ServerUtils.sendChatToAll(new TextComponentTranslation("nei.chat.time", getTime(world) / 24000L, hour));
}
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(playerIn.isSneaking()) {
if(!worldIn.isRemote) {
worldIn.setBlockState(pos, state.cycleProperty(FORWARD));
playerIn.sendMessage(new TextComponentTranslation("signals.message.teleport_rail_toggled_direction"));
}
return true;
} else {
return false;
}
}
@Override
protected void addDisplayText(List<ITextComponent> textList) {
super.addDisplayText(textList);
if (isStructureFormed()) {
IEnergyContainer energyContainer = recipeMapWorkable.getEnergyContainer();
if (energyContainer != null && energyContainer.getEnergyCapacity() > 0) {
long maxVoltage = energyContainer.getInputVoltage();
String voltageName = GTValues.VN[GTUtility.getTierByVoltage(maxVoltage)];
textList.add(new TextComponentTranslation("gregtech.multiblock.max_energy_per_tick", maxVoltage, voltageName));
}
if (!recipeMapWorkable.isWorkingEnabled()) {
textList.add(new TextComponentTranslation("gregtech.multiblock.work_paused"));
} else if (recipeMapWorkable.isActive()) {
textList.add(new TextComponentTranslation("gregtech.multiblock.running"));
int currentProgress = (int) (recipeMapWorkable.getProgressPercent() * 100);
textList.add(new TextComponentTranslation("gregtech.multiblock.progress", currentProgress));
} else {
textList.add(new TextComponentTranslation("gregtech.multiblock.idling"));
}
if (recipeMapWorkable.isHasNotEnoughEnergy()) {
textList.add(new TextComponentTranslation("gregtech.multiblock.not_enough_energy").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
}
/**
* 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))));
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
if(electricItem != null && electricItem.canProvideChargeExternally() && player.isSneaking()) {
if(!world.isRemote) {
boolean isInDischargeMode = isInDishargeMode(itemStack);
String locale = "metaitem.electric.discharge_mode." + (isInDischargeMode ? "disabled" : "enabled");
player.sendStatusMessage(new TextComponentTranslation(locale), true);
setInDischargeMode(itemStack, !isInDischargeMode);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
}
return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
@Override
public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, CuboidRayTraceResult hitResult) {
ItemStack itemStack = playerIn.getHeldItem(hand);
if(!itemStack.isEmpty() && itemStack.hasCapability(GregtechCapabilities.CAPABILITY_MALLET, null)) {
ISoftHammerItem softHammerItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_MALLET, null);
if (getWorld().isRemote) {
return true;
}
if(!softHammerItem.damageItem(DamageValues.DAMAGE_FOR_SOFT_HAMMER, false)) {
return false;
}
if (isTransformUp) {
setTransformUp(false);
playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.transformer.message_transform_down",
energyContainer.getInputVoltage(), energyContainer.getInputAmperage(), energyContainer.getOutputVoltage(), energyContainer.getOutputAmperage()));
return true;
} else {
setTransformUp(true);
playerIn.sendMessage(new TextComponentTranslation("gregtech.machine.transformer.message_transform_up",
energyContainer.getInputVoltage(), energyContainer.getInputAmperage(), energyContainer.getOutputVoltage(), energyContainer.getOutputAmperage()));
return true;
}
}
return false;
}