Jump to content

[1.10.2] Can't see whats the issue/ serverside coding issues


Recommended Posts

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());
}
}

Posted

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

    }
}

Posted

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

 

 

 

 

 

Posted

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

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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