Jump to content

Get serverworld on clientside.


Recommended Posts

I am quite new at Minecraft modding, and i wanted to create my first mod, which writes the contents of all nearby signs in a Minecraft world by pressing a key.
The code of my InputHandler here works for a singleplayer world.

public class InputHandler {
    public void onKeyInput(InputEvent.KeyInputEvent event) {
        if (KeyBind.test.isPressed()) {

            EntityPlayer player = Minecraft.getMinecraft().player;
            World world = Minecraft.getMinecraft().world;
            Iterable<BlockPos> spot = BlockPos.getAllInBox(new BlockPos(player.posX - 50, player.posY - 50, player.posZ - 50), new BlockPos(player.posX + 50, player.posY + 50, player.posZ + 50));
            File file = new File(Minecraft.getMinecraft().mcDataDir.getPath() + "/sign.txt");
            if (file.exists()) {
            try {
                for (BlockPos pos : spot) {
                    if (world.getTileEntity(pos) != null) {
                        TileEntity state = world.getTileEntity(pos);
                        if (state.getBlockType() instanceof BlockStandingSign) {
                            for (int i = 0; i < 4; i++) {
                                String t2 = ((TileEntitySign) world.getTileEntity(pos)).signText[i].toString();
                                String[] a = t2.split("'");
                                FileUtils.writeStringToFile(file, a[1] + "\n", "windows-1252", true);

                            FileUtils.writeStringToFile(file, "--------------------\n", "windows-1252", true);
            } catch (IOException e) {

But i want the mod to work on a server, so you have to get the world of the server, the player is connected to and check the blocks at the coords, like how i did it in my Code, but how do i do it, IF the Mod is clientside only?
I appreciate every single help :)

Link to comment
Share on other sites

You can't. This is basic server client logic. Act like the server doesnt exist on the physical client.

You need to send an appropriate message tot eh server to tell it to do what you want.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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