Posted November 30, 201410 yr Hi forum i have a question! Is there a way to set a distance limit to the chat. For example: If Player1 is more then 64blocks away from Player2 then Player1 can not read the things that Player 2 wrote. Without effecting commands ore thing that the server says? Thanks for everybody who can help me.
November 30, 201410 yr Just send a packet to any client within the range that does when received creates a client-only chat message. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
November 30, 201410 yr Just send a packet to any client within the range that does when received creates a client-only chat message. Yes but he wishes to rework the system so that the vanilla chat is distance based. OP, you can't do that without editing the base code, sorry. [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
November 30, 201410 yr To prevent chat messages to arrive, you can use ServerChatEvent and event.setCanceled(true) Than send a chat message to every player that is close enough to that player.
November 30, 201410 yr Author How to i send the message to the players who are close enough, and that i can edit the distance with items. For Example a megaphone which at 20 blocks more distance. I got this(only with same coordinates): import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraftforge.event.ServerChatEvent; import java.util.List; public class Shortchat { @SubscribeEvent public void onServerChatEvent(ServerChatEvent event) { event.setCanceled(true); EntityPlayerMP sender = event.player; List<EntityPlayerMP> players = MinecraftServer.getServer().getConfigurationManager().playerEntityList; for (EntityPlayerMP receiver : players){ if (receiver.getPlayerCoordinates().equals(sender.getPlayerCoordinates()) ){ receiver.addChatMessage(new ChatComponentText("["+event.username+"]"+event.message)); } } } }
November 30, 201410 yr Author found it, this one? public void sendToAllNearExcept(EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11_) { for (int j = 0; j < this.playerEntityList.size(); ++j) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); if (entityplayermp != p_148543_1_ && entityplayermp.dimension == p_148543_10_) { double d4 = p_148543_2_ - entityplayermp.posX; double d5 = p_148543_4_ - entityplayermp.posY; double d6 = p_148543_6_ - entityplayermp.posZ; if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_) { entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_); } } } }{
November 30, 201410 yr Author like you sad i do something wrong. how do i use this? that is the first thing i dont get to work while programing.
November 30, 201410 yr Author I tried this,because sendToAllNearExcept is nonstatic: What goes in "X"? ServerConfigurationManager send1 =new ServerConfigurationManager(X) { @Override public void sendToAllNearExcept(EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11_) { super.sendToAllNearExcept(p_148543_1_, p_148543_2_, p_148543_4_, p_148543_6_, p_148543_8_, p_148543_10_, p_148543_11_); } }; I only tiped this ServerConfigurationManager send1 =new ServerConfigurationManager() IDEA added the rest. And how can items modify the talking range.
December 1, 201410 yr Author Ups what do i have to fill in for these: EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11
December 1, 201410 yr Well the first parameter is the player you're not sending the packet to ( entityplayermp != p_148543_1_ ). The last one is the packet to send. The integer right before the packet is the dimension ( entityplayermp.dimension == p_148543_10_ ). The double right before that is the radius ( d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_ -> the distance formula, minus the square root). The remaining three parameters are the coordinates to send around (x, y, and z in order). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 1, 201410 yr Make that parameter a variable that changes based on [whatever you want]. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 1, 201410 yr Author The last one is the packet to send. It's to late. I have to sleep. I can not create a Packet.
December 2, 201410 yr Author public void sendChatMsgImpl(IChatComponent p_148544_1_, boolean p_148544_2_) { this.mcServer.addChatMessage(p_148544_1_); this.sendPacketToAllPlayers(new S02PacketChat(p_148544_1_, p_148544_2_)); } p_148544_1_ ist the Mesage? And what is p_148544_2_ ?
December 2, 201410 yr Author MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent p_148539_1_, true); What is p_148539_1_ ?
December 2, 201410 yr Author I feel stupid. What Please help me! X = error String Message2 = new String("[" + event.username + "] " + event.message); MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent X Message2, true);
December 2, 201410 yr Author IChatComponent test = new ChatComponentText("test"); Packet message = MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent test ); ?
December 2, 201410 yr That function returns void. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 2, 201410 yr Author MinecraftServer.getServer().getConfigurationManager().sendToAllNear(event.player.serverPosX, event.player.serverPosY, event.player.serverPosZ, event.player.worldObj.provider.dimensionId, rar, MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent test )); Don't kill me.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.