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

Ok so i have been trying to update my code for this tiny server side mod for a while but i can't figure out why im needing the mod client side when its all server side code.

I probably just need a fresh set of eyes to see my issue :P

 

heres a copy of the 2 main code handlers

import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;

public class WorldHandler {

    public static TextFormatting Color;
    public String prefix;
    public String pjgsave;



    public WorldHandler() {
        StringBuilder var10001 = new StringBuilder();
        //TextFormatting var10002 = Color;
        var10001 = var10001.append(TextFormatting.WHITE).append("[");
        //var10002 = Color;
        var10001 = var10001.append(TextFormatting.DARK_BLUE).append("PJG");
        //var10002 = Color;
        var10001 = var10001.append(TextFormatting.WHITE).append("-");
        //var10002 = Color;
        var10001 = var10001.append(TextFormatting.GOLD).append("Save");
        //var10002 = Color;
        this.prefix = var10001.append(TextFormatting.WHITE).append("]").toString();
        var10001 = (new StringBuilder()).append(this.prefix);
        //var10002 = Color;
        this.pjgsave = var10001.append(TextFormatting.RED).append(" Saving PlayerData, Expect Minor Lag . . .").toString();
    }


}

 

import net.minecraft.nbt.CompressedStreamTools;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class PlayerHandler {

    @SideOnly(Side.SERVER)
    @SubscribeEvent
    public void playerJoined(PlayerEvent.PlayerLoggedInEvent event) {
        PJGSave.loggedInPlayers.add(event.player.getPersistentID().toString());
        PJGSave.loggedOffPlayers.remove(event.player.getPersistentID().toString());
}
}

  • Author

Sure

@Mod(modid = RefStrings.MOD_ID, name = RefStrings.MOD_NAME, version = RefStrings.VERSION)
public class PJGSave {

    public static final String sessionID = Long.toString(System.currentTimeMillis());
    public static HashSet loggedInPlayers = new HashSet();
    public static HashSet loggedOffPlayers = new HashSet();
    public static org.apache.logging.log4j.Logger logger;

    @SideOnly(Side.SERVER)
    @EventHandler
    public void preinit(FMLPreInitializationEvent event) {
        FMLLog.info("PJG-Save has been enabled, playerdata will be saved at the same time as the world from now on!", new Object[0]);
        MinecraftForge.EVENT_BUS.register(new WorldHandler());
        FMLCommonHandler.instance().bus().register(new PlayerHandler());
        logger = event.getModLog();

    }
}

Hi

 

The @SideOnly(Side.SERVER) probably aren't doing what you think they are.

Side.Server means "load this class only when installed in a dedicated server".

If you need these classes in a local server (when the user is doing single player) then they won't be there.

 

Apart from that I don't see an obvious problem.

 

What are the symptoms?

I.e. you install your mod on the server, connect to it with a vanilla Forge client, and you get an error message?  If so what is it?

 

-TGG

 

 

 

 

 

  • Author

I added the server side stuff just to see if it would throw any errors because something its doing was client side but it didnt.

 

But yeah the only error it gives is when i join with a vanilla forge client it says i'm missing the mod.

The code is almost a complete copy from 1.7 which worked fine so its kinda confusing :P

Set the

acceptedMinecraftVersions

property of your

@Mod

annotation to

"*"

, i.e. accept any remote version including none.

 

Set the

serverSideOnly

property to

true

if you only want the mod to load on the dedicated server and not the integrated server.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.