use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class OperationRegistry method queueOperation.
public static void queueOperation(Operation operation, ICommandSender commandSender) throws PlayerNotFoundException {
boolean instant = true;
if (commandSender instanceof EntityPlayer) {
EntityPlayer player = CommandBase.getCommandSenderAsPlayer(commandSender);
RCEntityInfo info = RCEntityInfo.get(player, null);
if (info != null) {
if (info.getPreviewType() != Operation.PreviewType.NONE) {
info.queueOperation(operation, player);
instant = false;
ITextComponent confirmComponent = new TextComponentString("/" + RCCommands.confirm.getName());
confirmComponent.getStyle().setColor(TextFormatting.GREEN);
confirmComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.confirm.getName()));
confirmComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcconfirm.run")));
ITextComponent cancelComponent = new TextComponentString("/" + RCCommands.cancel.getName());
cancelComponent.getStyle().setColor(TextFormatting.RED);
cancelComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.cancel.getName()));
cancelComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rccancel.run")));
commandSender.sendMessage(ServerTranslations.format("commands.rc.queuedOp", confirmComponent, cancelComponent));
}
}
}
if (instant)
operation.perform((WorldServer) commandSender.getEntityWorld());
}
use of net.minecraft.util.text.event.HoverEvent in project AgriCraft by AgriCraft.
the class DebugModeIGrowable method debugActionBlockClicked.
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return;
}
// Start with the position of the block that was clicked on. '7' is gray. Btw, the chat font is not fixed width. :(
StringBuilder outputRaw = new StringBuilder(String.format("`7%1$4d,%2$4d,%3$4d`r ", pos.getX(), pos.getY(), pos.getZ()));
// Check if the clicked on block has the IGrowable interface.
final IGrowable crop = WorldHelper.getBlock(world, pos, IGrowable.class).orElse(null);
if (crop == null) {
// If it does not, add a nicely formatted report, then skip onward.
outputRaw.append(chatNotIG);
} else {
// Otherwise run the tests and record the results.
IBlockState state = world.getBlockState(pos);
// canGrow
outputRaw.append(crop.canGrow(world, pos, state, false) ? chatTrue : chatFalse);
// canUseBonemeal
outputRaw.append(crop.canUseBonemeal(world, world.rand, pos, state) ? chatTrue : chatFalse);
// grow
crop.grow(world, world.rand, pos, state);
// It's also helpful to also make clear what block was being tested.
// '3' is dark aqua.
outputRaw.append("`3");
outputRaw.append(crop.toString().replaceFirst("Block", ""));
outputRaw.append("`r");
}
// Ellipsis are added as a clue that there's more text.
// '8' is dark gray.
outputRaw.append(" `8[...]`r");
// Create a hover box with explanatory information.
TextComponentString hoverComponent = new TextComponentString(MessageUtil.colorize(chatInfo));
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent);
// Turn the output String into a chat message.
TextComponentString outputComponent = new TextComponentString(MessageUtil.colorize(outputRaw.toString()));
// Add the hover box to the chat message.
outputComponent.getStyle().setHoverEvent(hoverEvent);
// Now send the completed chat message.
player.sendMessage(outputComponent);
}
use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class RCTextStyle method path.
@Nonnull
public static ITextComponent path(ResourceDirectory directory, String... path) {
ITextComponent pathComponent = new TextComponentString(String.format("%s%s%s", directory, path.length > 0 ? "/" : "", Strings.join(path, "/")));
pathComponent.getStyle().setColor(TextFormatting.GOLD);
pathComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Visit File")));
pathComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, directory.toFile().getAbsolutePath()));
return pathComponent;
}
use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class RCTextStyle method copy.
public static ITextComponent copy(String text) {
ITextComponent comp = new TextComponentString(text);
comp.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rccopy.suggest")));
comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, text));
return comp;
}
use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class RCTextStyle method biome.
@Nonnull
public static ITextComponent biome(Biome biome) {
ITextComponent component = new TextComponentString(biome.getBiomeName());
Style style = component.getStyle();
style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s types %s", RCCommands.biomeDict.getName(), biome.getRegistryName())));
style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.format("commands.biomedict.list.number", BiomeDictionary.getTypes(biome).size())));
style.setColor(TextFormatting.AQUA);
return component;
}
Aggregations