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

My mod is not loading on a dedicated server that I'm using for beta testing features the crash report is below.

Crash Report

I followed a tutorial to create the classes to run the networking.

My current code is below. One thing to note is that the mod runs on client side without an issue.

package org.multicoder.mcpaintball.network;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.simple.SimpleChannel;
import org.multicoder.mcpaintball.MCPaintball;
import org.multicoder.mcpaintball.network.packets.*;

public class Networking
{
    private static SimpleChannel INSTANCE;
    private static int id = 0;
    private static int ID(){
        return id++;
    }

    public static void Register()
    {
        SimpleChannel net = NetworkRegistry.ChannelBuilder.named(new ResourceLocation(MCPaintball.MODID,"messsage")).networkProtocolVersion(() -> "1.0.0").clientAcceptedVersions(s -> true)
                .serverAcceptedVersions(s -> true).simpleChannel();

        INSTANCE = net;

        net.messageBuilder(TeamPointS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(TeamPointS2CPacket::new).encoder(TeamPointS2CPacket::toBytes).consumerMainThread(TeamPointS2CPacket::Handle).add();
        net.messageBuilder(TeamUpdateS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(TeamUpdateS2CPacket::new).encoder(TeamUpdateS2CPacket::toBytes).consumerMainThread(TeamUpdateS2CPacket::Handle).add();
        net.messageBuilder(PlayLowClassSoundS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(PlayLowClassSoundS2CPacket::new).encoder(PlayLowClassSoundS2CPacket::toBytes).consumerMainThread(PlayLowClassSoundS2CPacket::Handle).add();
        net.messageBuilder(PlayHighClassSoundS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(PlayHighClassSoundS2CPacket::new).encoder(PlayHighClassSoundS2CPacket::toBytes).consumerMainThread(PlayHighClassSoundS2CPacket::Handle).add();
        net.messageBuilder(TeamUpdateC2SPacket.class,ID(),NetworkDirection.PLAY_TO_SERVER).decoder(TeamUpdateC2SPacket::new).encoder(TeamUpdateC2SPacket::toBytes).consumerMainThread(TeamUpdateC2SPacket::Handle).add();
    }

    public static <MSG> void SendToServer(MSG message)
    {
        INSTANCE.sendToServer(message);
    }

    public static <MSG> void sendToPlayer(MSG message, ServerPlayer player) {INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), message);}

    public static <MSG> void sendToClients(MSG message) {INSTANCE.send(PacketDistributor.ALL.noArg(), message);}
}
@Mod(MCPaintball.MODID)
public class MCPaintball
{
    public static final String MODID = "mcpaintball";
    public static final Logger LOG = LogManager.getLogger(MODID);
    public MCPaintball()
    {
        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, MCPaintballConfig.SPEC,"mcpaintball-common.toml");
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        bus.register(this);
        bus.addListener(this::OnCommon);
    }


    private void OnCommon(FMLCommonSetupEvent event)
    {
        event.enqueueWork(() -> {
            BlockHolder.AppendList();
        });
        Networking.Register();

    }

    // Removed Unnessacery things from file to shrink its size
}

ย 

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.