use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.
the class NetworkConnectionAIHandler method onSlotHack.
@Override
public void onSlotHack(int slot, boolean nuked) {
if (!simulating && station.getStackInSlot(slot) != null && station.getStackInSlot(slot).getItemDamage() == ItemNetworkComponents.NETWORK_IO_PORT) {
FMLClientHandler.instance().getClient().thePlayer.closeScreen();
FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "Hacking unsuccessful! The Diagnostic Subroutine traced to your location!"));
if (gui instanceof GuiSecurityStationHacking)
((GuiSecurityStationHacking) gui).removeUpdatesOnConnectionHandlers();
}
}
use of net.minecraft.util.ChatComponentTranslation in project Engine by VoltzEngine-Project.
the class PermissionsCommandManager method executeCommand.
@Override
public int executeCommand(ICommandSender sender, String cmd) {
// Clean up command string
cmd = cmd.trim();
if (cmd.startsWith("/")) {
cmd = cmd.substring(1);
}
// Get command name and arguments
String[] args = cmd.split(" ");
String command_name = args[0];
args = dropFirstString(args);
ICommand icommand = (ICommand) this.getCommands().get(command_name);
int usernameIndex = this.getUsernameIndex(icommand, args);
int j = 0;
ChatComponentTranslation chatcomponenttranslation;
try {
if (icommand == null) {
throw new CommandNotFoundException();
}
// Checks if the user can use the command
if (hasPermissionForCommand(sender, icommand, args)) {
CommandEvent event = new CommandEvent(icommand, sender, args);
if (MinecraftForge.EVENT_BUS.post(event)) {
if (event.exception != null) {
throw event.exception;
}
return 1;
}
if (usernameIndex > -1) {
// Executes the command on several players if listed
EntityPlayerMP[] players = PlayerSelector.matchPlayers(sender, args[usernameIndex]);
String s2 = args[usernameIndex];
int k = players.length;
for (int l = 0; l < k; ++l) {
EntityPlayerMP entityplayermp = players[l];
args[usernameIndex] = entityplayermp.getCommandSenderName();
try {
icommand.processCommand(sender, args);
++j;
} catch (CommandException commandexception1) {
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation(commandexception1.getMessage(), commandexception1.getErrorOjbects());
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(chatcomponenttranslation1);
}
}
args[usernameIndex] = s2;
} else {
try {
icommand.processCommand(sender, args);
++j;
} catch (CommandException commandexception) {
chatcomponenttranslation = new ChatComponentTranslation(commandexception.getMessage(), commandexception.getErrorOjbects());
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(chatcomponenttranslation);
}
}
} else {
ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.generic.permission");
chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(chatcomponenttranslation2);
}
} catch (WrongUsageException wrongusageexception) {
chatcomponenttranslation = new ChatComponentTranslation("commands.generic.usage", new ChatComponentTranslation(wrongusageexception.getMessage(), wrongusageexception.getErrorOjbects()));
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(chatcomponenttranslation);
} catch (CommandException commandexception2) {
chatcomponenttranslation = new ChatComponentTranslation(commandexception2.getMessage(), commandexception2.getErrorOjbects());
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(chatcomponenttranslation);
} catch (Throwable throwable) {
chatcomponenttranslation = new ChatComponentTranslation("commands.generic.exception");
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(chatcomponenttranslation);
Engine.instance.logger().error("Failed to process command: \'" + cmd + "\'", throwable);
}
return j;
}
use of net.minecraft.util.ChatComponentTranslation in project watson by totemo.
the class Screenshot method save.
// --------------------------------------------------------------------------
/**
* Save a screenshot.
*
* @param file the file to write.
* @param width the screen width.
* @param height the screen height.
*/
public static IChatComponent save(File file, int width, int height) {
try {
file.getParentFile().mkdirs();
ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4);
GL11.glReadBuffer(GL11.GL_FRONT);
// GL11.glReadBuffer() unexpectedly sets an error state (invalid enum).
GL11.glGetError();
GL11.glReadPixels(0, 0, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int i = (x + width * y) * 4;
int r = buffer.get(i) & 0xFF;
int g = buffer.get(i + 1) & 0xFF;
int b = buffer.get(i + 2) & 0xFF;
image.setRGB(x, (height - 1) - y, (0xFF << 24) | (r << 16) | (g << 8) | b);
}
}
ImageIO.write(image, "png", file);
ChatComponentText text = new ChatComponentText(file.getName());
text.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()));
text.getChatStyle().setUnderlined(Boolean.valueOf(true));
return new ChatComponentTranslation("screenshot.success", new Object[] { text });
} catch (Exception ex) {
return new ChatComponentTranslation("screenshot.failure", new Object[] { ex.getMessage() });
}
}
use of net.minecraft.util.ChatComponentTranslation in project BetterStorage by copygirl.
the class TileBackpack method onBlockClicked.
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if (world.isRemote && player.isSneaking() && !ItemBackpack.canEquipBackpack(player) && BetterStorage.globalConfig.getBoolean(GlobalConfig.enableHelpTooltips) && (System.currentTimeMillis() > lastHelpMessage + 10 * 1000)) {
boolean backpack = (ItemBackpack.getBackpack(player) != null);
player.addChatMessage(new ChatComponentTranslation("tile.betterstorage.backpack.cantEquip." + (backpack ? "backpack" : "chestplate")));
lastHelpMessage = System.currentTimeMillis();
}
}
use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class TileEntityTrackSideSniffer method configure.
public static boolean configure(World world, int x, int y, int z, EntityPlayer player) {
if (world.getTileEntity(x, y, z) == null)
return false;
if (world.getTileEntity(x, y, z) instanceof TileEntityTrackSideSniffer) {
TileEntityTrackSideSniffer sniffer = (TileEntityTrackSideSniffer) world.getTileEntity(x, y, z);
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null) {
NBTTagList list = Util.getTagListFromNGT(stack);
if (list == null)
return false;
if (!world.isRemote) {
String code = NSASM.getCodeString(list);
sniffer.nsasmState = TileEntityTrackSideSniffer.NSASM_IDLE;
sniffer.nsasmCode = code;
player.addChatComponentMessage(new ChatComponentTranslation("info.sniffer.set"));
}
return true;
}
}
return false;
}
Aggregations