use of net.minecraft.util.text.TextComponentString in project OpenModularTurrets by OpenModularTurretsTeam.
the class BlockExpander method clOnBlockActivated.
@Override
protected boolean clOnBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (hand.equals(EnumHand.OFF_HAND))
return true;
Expander expander = (Expander) worldIn.getTileEntity(pos);
if (expander == null) {
return true;
}
TurretBase base = expander.getBase();
if (base == null) {
worldIn.destroyBlock(pos, true);
return true;
}
TrustedPlayer trustedPlayer = PlayerUtil.getTrustedPlayer(playerIn, base);
if (trustedPlayer != null) {
if (base.getTrustedPlayer(playerIn.getUniqueID()).canOpenGUI && state.getValue(META) < 5) {
playerIn.openGui(OpenModularTurrets.instance, 7, worldIn, pos.getX(), pos.getY(), pos.getZ());
return true;
}
}
if (PlayerUtil.isPlayerOwner(playerIn, base)) {
if (playerIn.isSneaking() && playerIn.getHeldItemMainhand() == null) {
worldIn.destroyBlock(pos, true);
} else if (state.getValue(META) < 5) {
playerIn.openGui(OpenModularTurrets.instance, 7, worldIn, pos.getX(), pos.getY(), pos.getZ());
} else {
return true;
}
} else {
addChatMessage(playerIn, new TextComponentString(safeLocalize("status.ownership")));
}
return true;
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class AbstractCitizensCommands method execute.
@NotNull
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
if (args.length == 0) {
sender.getCommandSenderEntity().sendMessage(new TextComponentString(NO_ARGUMENTS));
return;
}
boolean firstArgumentColonyId = true;
int colonyId = -1;
if (args.length >= 2) {
colonyId = getIthArgument(args, 0, -1);
if (colonyId == -1) {
firstArgumentColonyId = false;
}
}
final Colony colony;
if (sender instanceof EntityPlayer && colonyId == -1) {
final IColony tempColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), (EntityPlayer) sender);
if (tempColony != null) {
colonyId = tempColony.getID();
firstArgumentColonyId = false;
}
}
colony = ColonyManager.getColony(colonyId);
if (colony == null) {
sender.getCommandSenderEntity().sendMessage(new TextComponentString(NO_ARGUMENTS));
return;
}
if (sender instanceof EntityPlayer) {
final EntityPlayer player = (EntityPlayer) sender;
if (!canPlayerUseCommand(player, getCommand(), colonyId)) {
sender.getCommandSenderEntity().sendMessage(new TextComponentString(NOT_PERMITTED));
return;
}
}
final int citizenId = getValidCitizenId(colony, firstArgumentColonyId, args);
if (citizenId == -1 || colony.getCitizen(citizenId) == null) {
sender.getCommandSenderEntity().sendMessage(new TextComponentString(NO_ARGUMENTS));
return;
}
executeSpecializedCode(server, sender, colony, citizenId);
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class SchematicSaveMessage method onMessage.
@Nullable
@Override
public IMessage onMessage(@NotNull final SchematicSaveMessage message, final MessageContext ctx) {
if (!MineColonies.isClient() && !Configurations.allowPlayerSchematics) {
Log.getLogger().info("SchematicSaveMessage: custom schematic is not allowed on this server.");
if (ctx.side.isServer()) {
ctx.getServerHandler().playerEntity.sendMessage(new TextComponentString("The server does not allow custom schematic!"));
}
return null;
}
final boolean schematicSent;
if (message.data == null) {
Log.getLogger().error("Received empty schematic file");
schematicSent = false;
} else {
schematicSent = Structures.handleSaveSchematicMessage(message.data);
}
if (ctx.side.isServer()) {
if (schematicSent) {
ctx.getServerHandler().playerEntity.sendMessage(new TextComponentString("Schematic successfully sent!"));
} else {
ctx.getServerHandler().playerEntity.sendMessage(new TextComponentString("Failed to send the Schematic!"));
}
}
return null;
}
use of net.minecraft.util.text.TextComponentString in project VoodooCraft by Mod-DevCafeTeam.
the class HexSpawnPoint method activeUse.
@Override
public ItemStack activeUse(ItemStack stackIn, World world, EntityPlayer player, EnumHand hand, int strength, @Nullable EntityLivingBase target) {
if (!world.isRemote) {
BlockPos pos = player.getPosition();
player.setSpawnPoint(new BlockPos(pos.getX(), pos.getY(), pos.getZ()), true);
player.sendStatusMessage(new TextComponentString("Spawn point set to {x: " + pos.getX() + ", y: " + pos.getY() + ", z: " + pos.getZ() + "} for " + player.getName()));
}
return super.activeUse(stackIn, world, player, hand, strength, target);
}
use of net.minecraft.util.text.TextComponentString in project ImmersiveEngineering by BluSunrize.
the class CommandHelp method perform.
@Override
public void perform(CommandHandler handler, MinecraftServer server, ICommandSender sender, String[] args) {
if (args.length > 1) {
String sub = "";
for (int i = 2; i < args.length; i++) sub += "." + args[i];
for (IESubCommand com : handler.commands) {
if (com.getIdent().equalsIgnoreCase(args[1])) {
String h = I18n.translateToLocal(com.getHelp(sub));
for (String s : h.split("<br>")) sender.addChatMessage(new TextComponentString(s));
}
}
} else {
String h = I18n.translateToLocal(getHelp(""));
for (String s : h.split("<br>")) sender.addChatMessage(new TextComponentString(s));
String sub = "";
int i = 0;
for (IESubCommand com : handler.commands) sub += ((i++) > 0 ? ", " : "") + com.getIdent();
sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + "available", sub));
}
}
Aggregations