Skip to content

Erroneous version of net.minecraftforge.fml.relauncher.Side.class used as marker #12

@Rongmario

Description

@Rongmario

Currently, MergeTool uses a different version of net.minecraftforge.fml.relauncher.Side.class as the marker that includes a BUKKIT side, AFAIK this was never the case before the transition to the newer toolchains after ForgeGradle 2.3.
This affects environments that uses MergeTool with the net.minecraftforge:mergetool-fml:1.0 marker from Minecraft 14w02a to Minecraft 1.12.2.

Currently, you'll get a crash in dev looking like this:

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Forge Mod Loader (FML)
Caused by: java.lang.NullPointerException
  at net.minecraftforge.fml.common.network.NetworkRegistry.newChannel(NetworkRegistry.java:207)
  at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.registerChannel(FMLNetworkHandler.java:185)
  at net.minecraftforge.fml.common.FMLContainer.modConstruction(FMLContainer.java:92)
  ...

Because the NetworkRegistry only registers two channels for Side.CLIENT and Side.SERVER:

private NetworkRegistry()
{
    channels.put(Side.CLIENT, Maps.<String,FMLEmbeddedChannel>newConcurrentMap());
    channels.put(Side.SERVER, Maps.<String,FMLEmbeddedChannel>newConcurrentMap());
}

and later on NetworkRegistry#newChannel queries the channels via Side.values() where the array contains a Side.BUKKIT:

for (Side side : Side.values())
{
    FMLEmbeddedChannel channel = new FMLEmbeddedChannel(name, side, handlers);
    channels.get(side).put(name,channel);
    result.put(side, channel);
}

The fix is to use the same Side.class as the one found in MinecraftForge's repository instead of one that is erroneous containing a BUKKIT side:

/*
 * Minecraft Forge
 * Copyright (c) 2016-2020.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation version 2.1
 * of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

package net.minecraftforge.fml.relauncher;

public enum Side {

    /**
     * The client side. Specifically, an environment where rendering capability exists.
     * Usually in the game client.
     */
    CLIENT,
    /**
     * The server side. Specifically, an environment where NO rendering capability exists.
     * Usually on the dedicated server.
     */
    SERVER;

    /**
     * @return If this is the server environment
     */
    public boolean isServer()
    {
        return !isClient();
    }

    /**
     * @return if this is the Client environment
     */
    public boolean isClient()
    {
        return this == CLIENT;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions