Hopefully this solves it for you. I was just trying to figure out this 'Failed to create screen for menu type' issue that happened to me. I forgot to registered my Container with Screen inside ClientProxy.init().
ClientProxy.java
Spoiler
public class ClientProxy implements IProxy {
@Override
public void init() {
// Initialize your Container and Screen for block UI to appear.
ScreenManager.registerFactory(<YourBlockContainer>.TYPE, <YourBlockScreen>::new);
}
@Override
public World getClientWorld() {
return Minecraft.getInstance().world;
}
@Override
public PlayerEntity getClientPlayer() {
return Minecraft.getInstance().player;
}
}
ServerProxy.java
Spoiler
public class ServerProxy implements IProxy {
@Override
public void init() {
}
@Override
public World getClientWorld() {
throw new IllegalStateException("Only run this on the client!");
}
@Override
public PlayerEntity getClientPlayer() {
throw new IllegalStateException("Only run this on the client!");
}
[UNSOLVED] [1.14.2] GUI isn't opening on right click
in Modder Support
Posted
Hopefully this solves it for you. I was just trying to figure out this 'Failed to create screen for menu type' issue that happened to me. I forgot to registered my Container with Screen inside ClientProxy.init().
ClientProxy.java
public class ClientProxy implements IProxy {
@Override
public void init() {
// Initialize your Container and Screen for block UI to appear.
ScreenManager.registerFactory(<YourBlockContainer>.TYPE, <YourBlockScreen>::new);
}
@Override
public World getClientWorld() {
return Minecraft.getInstance().world;
}
@Override
public PlayerEntity getClientPlayer() {
return Minecraft.getInstance().player;
}
}
ServerProxy.java
public class ServerProxy implements IProxy {
@Override
public void init() {
}
@Override
public World getClientWorld() {
throw new IllegalStateException("Only run this on the client!");
}
@Override
public PlayerEntity getClientPlayer() {
throw new IllegalStateException("Only run this on the client!");
}
}
IProxy.java
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
public interface IProxy {
void init();
World getClientWorld();
PlayerEntity getClientPlayer();
}
Make sure you call the client init from within your main mod class in setup(...).
Main.java
public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
...
private void setup(final FMLCommonSetupEvent event) {
...
proxy.init();
}