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

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 {
    @SubscribeEvent
    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()) {
                file.delete();
            }
            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);
                                System.out.println(file.getAbsolutePath());
                            }

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

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 :)

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

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.