Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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]

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.

  • 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));

            }
        }
    }
}

  • Author

Don't hate me i don't program for so long.

What exectly do you say?

  • Author

I understand that but i can't find sendToAllNearExcept.

  • 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_);
                }
            }
        }
    }{

  • 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.

  • 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.

  • 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

 

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.

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.

  • Author
The last one is the packet to send.

It's to late. I have to sleep. I can not create a Packet.

  • Author

How does a normal chat Packet lookalike. I can not get it to work.

  • 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_ ?

 

  • Author

MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent p_148539_1_, true);

 

What is p_148539_1_ ?

  • 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);

 

  • Author

IChatComponent test = new ChatComponentText("test");
            Packet message = MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent test );

 

?

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.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.