use of net.minecraft.util.text.Style in project Random-Things by lumien231.
the class BlockEnderMailbox method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
ItemStack heldItem = playerIn.getHeldItemMainhand();
if (playerIn.isSneaking() && heldItem.getItem() == ModItems.enderLetter) {
NBTTagCompound compound;
if ((compound = heldItem.getTagCompound()) != null) {
if (compound.hasKey("receiver") && !compound.getBoolean("received")) {
GameProfile playerProfile = worldIn.getMinecraftServer().getPlayerProfileCache().getGameProfileForUsername(compound.getString("receiver"));
if (playerProfile != null && playerProfile.getId() != null) {
EnderMailboxInventory mailboxInventory = EnderLetterHandler.get(worldIn).getOrCreateInventoryForPlayer(playerProfile.getId());
for (int slot = 0; slot < mailboxInventory.getSizeInventory(); slot++) {
if (mailboxInventory.getStackInSlot(slot).isEmpty()) {
ItemStack sendingLetter = heldItem.copy();
heldItem.shrink(1);
sendingLetter.getTagCompound().setBoolean("received", true);
sendingLetter.getTagCompound().setString("sender", playerIn.getGameProfile().getName());
mailboxInventory.setInventorySlotContents(slot, sendingLetter);
playerIn.world.playSound(null, pos, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1, 1);
return true;
}
}
playerIn.sendMessage(new TextComponentTranslation("item.enderLetter.noSpace").setStyle(new Style().setColor(TextFormatting.DARK_PURPLE)));
} else {
playerIn.sendMessage(new TextComponentTranslation("item.enderLetter.noPlayer", compound.getString("receiver")).setStyle(new Style().setColor(TextFormatting.DARK_PURPLE)));
}
}
}
return true;
}
TileEntityEnderMailbox te = (TileEntityEnderMailbox) worldIn.getTileEntity(pos);
if (te.getOwner() != null) {
if (te.getOwner().equals(playerIn.getGameProfile().getId())) {
playerIn.openGui(RandomThings.instance, GuiIds.ENDER_MAILBOX, worldIn, pos.getX(), pos.getY(), pos.getZ());
} else {
playerIn.sendMessage(new TextComponentTranslation("block.enderMailbox.owner").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
}
return true;
}
use of net.minecraft.util.text.Style in project BuildCraft by BuildCraft.
the class CommandHelpers method printHelp.
public static void printHelp(ICommandSender sender, IModCommand command) {
Style header = new Style();
header.setColor(TextFormatting.GRAY);
header.setBold(true);
sendLocalizedChatMessage(sender, header, "command.buildcraft." + command.getFullCommandString().replace(" ", ".") + ".format", command.getFullCommandString());
Style body = new Style();
body.setColor(TextFormatting.GRAY);
if (command.getCommandAliases().size() > 0) {
sendLocalizedChatMessage(sender, body, "command.buildcraft.aliases", command.getCommandAliases().toString().replace("[", "").replace("]", ""));
}
if (command.getMinimumPermissionLevel() > 0) {
sendLocalizedChatMessage(sender, body, "command.buildcraft.permlevel", command.getMinimumPermissionLevel());
}
sendLocalizedChatMessage(sender, body, "command.buildcraft." + command.getFullCommandString().replace(" ", ".") + ".help");
if (!command.getChildren().isEmpty()) {
sendLocalizedChatMessage(sender, "command.buildcraft.list");
for (SubCommand child : command.getChildren()) {
sendLocalizedChatMessage(sender, "command.buildcraft." + child.getFullCommandString().replace(" ", ".") + ".desc", child.getCommandName());
}
}
}
use of net.minecraft.util.text.Style in project BiomeTweaker by superckl.
the class CommandListBiomes method execute.
@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.listbiomes.output.text").setStyle(new Style().setColor(TextFormatting.AQUA)));
final Iterator<Biome> it = Biome.REGISTRY.iterator();
while (it.hasNext()) {
final Biome gen = it.next();
if (gen != null) {
final String message = new StringBuilder().append(Biome.getIdForBiome(gen)).append(" - ").append(gen.getBiomeName()).toString();
sender.sendMessage(new TextComponentString(message).setStyle(new Style().setColor(TextFormatting.GOLD)));
}
}
}
use of net.minecraft.util.text.Style in project BiomeTweaker by superckl.
the class CommandSetBiome method execute.
@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
final BlockPos coord = sender.getPosition();
final World world = sender.getEntityWorld();
if ((coord != null) && (world != null)) {
if ((args.length < 2) || (args.length > 3)) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
Biome gen = null;
Integer i = Ints.tryParse(args[0]);
if (i != null)
gen = Biome.getBiome(i);
else {
final Iterator<Biome> it = Biome.REGISTRY.iterator();
while (it.hasNext()) {
final Biome biome = it.next();
if ((biome != null) && biome.getBiomeName().equals(args[0])) {
gen = biome;
break;
}
}
}
if (gen == null) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
final int id = Biome.getIdForBiome(gen);
i = Ints.tryParse(args[1]);
if (i == null) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
boolean blocks = true;
if (args.length == 3)
if (args[2].equalsIgnoreCase("block"))
blocks = true;
else if (args[2].equalsIgnoreCase("chunk"))
blocks = false;
else {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.invalargs.text").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
int count = 0;
if (blocks) {
for (int x = coord.getX() - i; x <= (coord.getX() + i); x++) for (int z = coord.getZ() - i; z <= (coord.getZ() + i); z++) {
final int realX = x & 15;
final int realZ = z & 15;
/*if(x < 0)
realX = 15-realX;
if(z < 0)
realZ = 15-realZ;*/
final Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(x, 0, z));
chunk.getBiomeArray()[(realZ * 16) + realX] = (byte) id;
chunk.markDirty();
count++;
}
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.blocksuccess.text", count, gen.getBiomeName()).setStyle(new Style().setColor(TextFormatting.GOLD)));
} else {
final byte[] biomeArray = new byte[256];
Arrays.fill(biomeArray, (byte) id);
final int chunkX = coord.getX() >> 4;
final int chunkZ = coord.getZ() >> 4;
for (int x = chunkX - i; x <= (chunkX + i); x++) for (int z = chunkZ - i; z <= (chunkZ + i); z++) {
final Chunk chunk = world.getChunkFromChunkCoords(x, z);
chunk.setBiomeArray(Arrays.copyOf(biomeArray, biomeArray.length));
chunk.markDirty();
count++;
}
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.setbiome.chunksuccess.text", count, gen.getBiomeName()).setStyle(new Style().setColor(TextFormatting.GOLD)));
}
} else
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.info.invalsender.text").setStyle(new Style().setColor(TextFormatting.RED)));
}
use of net.minecraft.util.text.Style in project BiomeTweaker by superckl.
the class CommandOutput method execute.
@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
try {
BiomeTweaker.getInstance().generateOutputFiles();
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.output.success.text").setStyle(new Style().setColor(TextFormatting.AQUA)));
} catch (final IOException e) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.output.failure.text").setStyle(new Style().setColor(TextFormatting.RED)));
LogHelper.error("Failed to regenerate output files!");
e.printStackTrace();
}
}
Aggregations