Jump to content

[1.7.10] My Custom GUI is crashing the server


Elrol_Arrowsend

Recommended Posts

I have an elevator mod that works fine on clients but crashes servers. Here is the crash report

 

 

---- Minecraft Crash Report ----

// But it works on my machine.

 

Time: 2/1/16 2:16 PM

Description: Exception in server tick loop

 

cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen

at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:739)

at cpw.mods.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:97)

at cpw.mods.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:319)

at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:213)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen

at elrol.guiElevator.main.ElevatorMain.init(ElevatorMain.java:37)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)

... 5 more

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiScreen

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 33 more

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/GuiScreen for invalid side SERVER

at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50)

at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279)

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176)

... 35 more

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.8.0_60, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 982809800 bytes (937 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)

UCHI FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)

UCHI Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)

UCHE guielevator{1.1} [Elrol's GUI Elevator] (bin)

Profiler Position: N/A (disabled)

Is Modded: Definitely; Server brand changed to 'fml,forge'

Type: Dedicated Server (map_server.txt)

 

 

 

Here is my Elevator Block:

 

package elrol.guiElevator.main;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

public class Elevator extends BlockContainer implements ElevatorPacketHandler{


public IIcon side;
protected IIcon field_150164_N;
    
public Elevator(String name, CreativeTabs tab, float hardness, float resistance, SoundType stepSound) {
	super(Material.iron);
	this.setBlockName(name);
	this.setHardness(hardness);
	this.setResistance(resistance);
	this.setBlockTextureName(ModInfo.MODID + ":" + name);
	this.setCreativeTab(tab);
	this.setStepSound(stepSound);

}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par1, float par2, float par3, float par4)
    {
	if(world.isRemote){
		if(player.isSneaking()){
			Minecraft.getMinecraft().displayGuiScreen(new ElevatorNamingGUI(world, x, y, z, player));
			return false;
		}else{
			if(player.getCurrentEquippedItem() == null){
				Minecraft.getMinecraft().displayGuiScreen(new FloorSelectGUI(world, x, y, z, player));
				return true;
			}else{
				return false;
			}

		}

	}
	else{
		return false;	
	}
    }

@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
	try{
		return new TileEntityElevator();	
	}catch (Exception var3){
		throw new RuntimeException(var3);
	}

}

public boolean hasTileEntity(int meta){
	return true;
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon){
	this.blockIcon = icon.registerIcon(this.textureName);
	this.side = icon.registerIcon(this.textureName + "_face");
}

@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
	if(side == meta){
		return this.side;
	}else{
		return this.blockIcon;
	}
}

public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
    {
	world.setBlockMetadataWithNotify(x, y, z, side, 2);
	return side;
    }

public void HandlePacket(EntityPlayer player, int x, int y, int z, String value, byte extra){
	TileEntity te = player.worldObj.getTileEntity(x, y, z);
	if(te != null && te instanceof TileEntityElevator){
		((TileEntityElevator)te).name = value;
		((TileEntityElevator)te).markDirty();;
	}
}

}

 

 

And my Naming GUI:

 

package elrol.guiElevator.main;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public class ElevatorNamingGUI extends GuiScreen{
public static ResourceLocation gui = new ResourceLocation(ModInfo.MODID, "textures/gui/floor_name.png");
public static int guiWidth = 248;
public static int guiHeight = 166;

GuiTextField nameInput;

GuiButton okButton;
GuiButton cancelButton;

public EntityPlayer player;

public int X;
public int Y;
public int Z;

public World world;

public ElevatorNamingGUI (World world, int x, int y, int z, EntityPlayer player){
	this.X = x;
	this.Y = y;
	this.Z = z;

	this.player = player;
	this.world = world;
}

@Override
public void drawScreen(int x, int y,float tick){
	int guiX = (width-guiWidth)/2;
	int guiY = (height-guiHeight)/2;

	GL11.glColor4f(1, 1, 1, 1);
	mc.renderEngine.bindTexture(gui);
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
	this.nameInput.drawTextBox();
	drawStrings(guiX, guiY);

	super.drawScreen(x, y, tick);

}

public void initGui(){
	int guiX = (width-guiWidth)/2;
	int guiY = (height-guiHeight)/2;

	buttonList.clear();
	this.nameInput = new GuiTextField(this.fontRendererObj, guiX+74, guiY+32, 100, 20);
        nameInput.setMaxStringLength(32);
	this.nameInput.setFocused(true);
	if(((TileEntityElevator)world.getTileEntity(X, Y, Z)).isNamed()){
		this.nameInput.setText(((TileEntityElevator)world.getTileEntity(X, Y, Z)).getName());
		System.out.println(((TileEntityElevator)world.getTileEntity(X, Y, Z)).getName());
	}else{
		this.nameInput.setText("");
	}
        
        buttonList.add(okButton = new GuiButton(Y, guiX+79, guiY+64, 40, 20, "Rename"));
        buttonList.add(cancelButton = new GuiButton(1, guiX+129, guiY+64, 40, 20, "Cancel"));
	super.initGui();
}

public void drawStrings(int guiX, int guiY){
	fontRendererObj.drawString("Name the floor", guiX+8,guiY+8, 0x000000);
}

protected void actionPerformed(GuiButton button){

	if(button.id == Y){
		NBTTagCompound tag = new NBTTagCompound();
		tag.setString("name", this.nameInput.getText().trim());
		tag.setBoolean("named", true);
		System.out.println(Y);
		((TileEntityElevator)world.getTileEntity(X, button.id, Z)).readFromNBT(tag);
		nameBlock(this.nameInput.getText().trim());
		PacketStringName.send(X, button.id, Z, this.nameInput.getText().trim(), (byte)0);
		mc.displayGuiScreen(null);
		return ;
	}else{
		mc.displayGuiScreen(null);	
	}
}

protected void keyTyped(char c, int key){
	this.nameInput.textboxKeyTyped(c, key);
        
	if(!this.nameInput.isFocused()){
		switch(key){
		case Keyboard.KEY_E:
			mc.displayGuiScreen(null);

		case Keyboard.KEY_ESCAPE:
			mc.displayGuiScreen(null);
		}
	}else{
		switch(key){
		case Keyboard.KEY_ESCAPE:
			this.nameInput.setFocused(false);
		}

	}

}

public void updateScreen()
    {
        super.updateScreen();
        this.nameInput.updateCursorCounter();
    }

protected void mouseClicked(int x, int y, int btn) {
        super.mouseClicked(x, y, btn);
        this.nameInput.mouseClicked(x, y, btn);
    }

public void nameBlock(String name){
	ByteArrayOutputStream bos = new ByteArrayOutputStream(;
	DataOutputStream dos = new DataOutputStream(bos);
	try{
		dos.writeUTF(name);
	}catch(Exception v){
		v.printStackTrace();
	}

}
}

 

 

and my Floor Select GUI:

 

package elrol.guiElevator.main;

import java.awt.List;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class FloorSelectGUI extends GuiScreen{

public static ResourceLocation gui = new ResourceLocation(ModInfo.MODID, "textures/gui/floor_select.png");
public static int guiWidth = 248;
public static int guiHeight = 166;

GuiButton floorButton;

public EntityPlayer player;

public int X;
public int Y;
public int Z;

public World world;

public FloorSelectGUI (World world, int x, int y, int z, EntityPlayer player){
	this.X = x;
	this.Y = y;
	this.Z = z;

	this.player = player;
	this.world = world;
}

@Override
public void drawScreen(int x, int y,float tick){
	int guiX = (width-guiWidth)/2;
	int guiY = (height-guiHeight)/2;

	GL11.glColor4f(1, 1, 1, 1);
	mc.renderEngine.bindTexture(gui);
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);

	drawStrings(guiX, guiY);

	super.drawScreen(x, y, tick);

}

public void initGui(){
	int guiX = (width-guiWidth)/2;
	int guiY = (height-guiHeight)/2;
	int floor = 0;
	int col = 0;
	buttonList.clear();

	for(int blockY = 0; blockY < 256; blockY++){
		if(world.getBlock(X, blockY, Z) == ElevatorMain.elevator){
			if(isFloorValid(world, X, blockY, Z, world.getBlockMetadata(X, blockY,Z))){
				if(floor < 24){
					if(((TileEntityElevator)world.getTileEntity(X, blockY, Z)).getName() != ""){
						buttonList.add(floorButton = new GuiButton(blockY, guiX + 9 + (83*col) , guiY + 20 + (16 * floor)-(16 * (8 * col)), 64, 16, ((TileEntityElevator)world.getTileEntity(X, blockY, Z)).getName()));
					}else{
						buttonList.add(floorButton = new GuiButton(blockY, guiX + 9 + (83*col) , guiY + 20 + (16 * floor)-(16 * (8 * col)), 64, 16, "Floor " + (floor+1)));	
					}
					System.out.println("<" + ((TileEntityElevator)world.getTileEntity(X, blockY, Z)).getName() + ">");
					floor++;
					if(floor > 7 && floor < 16){
						col = 1;
					}
					if(floor > 15){
						col = 2;
					}
					//System.out.println("elevator found at Y:" + blockY + "(" + floor + "[" + ((TileEntityElevator)world.getTileEntity(X, blockY, Z)).name +"]" +")");	
				}
			}
		}
	}

	super.initGui();
}

public void drawStrings(int guiX, int guiY){
	fontRendererObj.drawString("Select a floor", guiX+8,guiY+8, 0x000000);

}

protected void actionPerformed(GuiButton button){
	if(button.id > 0 && button.id < 256){
		System.out.println(button.id);
		switch(world.getBlockMetadata(X, button.id, Z)){
		case 0: player.setPositionAndUpdate((double)X + 0.5D, (double)button.id - 2D, (double)Z + 0.5D);
			break;
		case 1: player.setPositionAndUpdate((double)X + 0.5D, (double)button.id + 1D, (double)Z + 0.5D);
			break;
		case 2: player.setPositionAndUpdate((double)X + 0.5D, (double)button.id-1, (double)Z - 0.5D);
			break;
		case 3: player.setPositionAndUpdate((double)X + 0.5D, (double)button.id-1, (double)Z + 1.5D);
			break;
		case 4: player.setPositionAndUpdate((double)X - 0.5D, (double)button.id-1, (double)Z + 0.5D);
			break;
		case 5: player.setPositionAndUpdate((double)X + 1.5D, (double)button.id-1, (double)Z + 0.5D);
			break;
		default: System.out.println("ERROR WITH METADATA :" + world.getBlockMetadata(X, button.id, Y));
		}
	mc.displayGuiScreen(null);
	}
}

protected void keyTyped(char c, int key){
	switch(key){
	case Keyboard.KEY_E:
		mc.displayGuiScreen(null);

	case Keyboard.KEY_ESCAPE:
		mc.displayGuiScreen(null);
	}
}

public boolean isFloorValid(World world, int x, int y, int z, int meta){
	System.out.println(x + ", " + y + ", " + z + ", " + world.getBlockMetadata(x,y,z));
	if(world.getBlockPowerInput(x, y, z) == 0){
		switch(world.getBlockMetadata(x,y,z)){
		case 0:
			if(world.getBlock(x, y-1, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null && world.getBlock(x, y-2, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null ){
				System.out.println("has space");
				return true;
			}else{
				System.out.println(world.getBlock(x, y-1, z).getUnlocalizedName() + ", " + world.getBlock(x, y-2, z).getUnlocalizedName());
				return false;}
		case 1:
			if(world.getBlock(x, y+1, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null  && world.getBlock(x, y+2, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null ){
				System.out.println("has space");
				return true;
			}else{
				System.out.println(world.getBlock(x, y+1, z).getUnlocalizedName() + ", " + world.getBlock(x, y+2, z).getUnlocalizedName());
				return false;}
		case 2:
			if(world.getBlock(x, y, z-1).getCollisionBoundingBoxFromPool(world, x, y, z) == null  && world.getBlock(x, y-1, z-1).getCollisionBoundingBoxFromPool(world, x, y, z) == null ){
				System.out.println("has space");
				return true;
			}else{
				System.out.println(world.getBlock(x, y, z-1).getUnlocalizedName() + ", " + world.getBlock(x, y-1, z-1).getUnlocalizedName());
				return false;}
		case 3:
			if(world.getBlock(x, y, z+1).getCollisionBoundingBoxFromPool(world, x, y, z) == null  && world.getBlock(x, y-1, z+1).getCollisionBoundingBoxFromPool(world, x, y, z) == null ){
				System.out.println("has space");
				return true;
			}else{System.out.println(world.getBlock(x, y, z+1).getUnlocalizedName() + ", " + world.getBlock(x, y-1, z+1).getUnlocalizedName());
			return false;}
		case 4:
			if(world.getBlock(x-1, y, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null  && world.getBlock(x-1, y-1, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null ){
				System.out.println("has space");
				return true;
			}else{System.out.println(world.getBlock(x-1, y, z).getUnlocalizedName() + ", " + world.getBlock(x-1, y-1, z).getUnlocalizedName());
			return false;}
		case 5:
			if(world.getBlock(x+1, y, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null  && world.getBlock(x+1, y-1, z).getCollisionBoundingBoxFromPool(world, x, y, z) == null ){
				System.out.println("has space");
				return true;
			}else{System.out.println(world.getBlock(x+1, y, z).getUnlocalizedName() + ", " + world.getBlock(x+1, y-1, z).getUnlocalizedName());
			return false;}
		default: 
			System.out.println("ERROR: METADATA > 5");
			return false;
		}
	}else{
		return false;
	}


}
}

 

 

 

Link to comment
Share on other sites

And

player.openGui(...)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You're probably going to want to use a GuiHandler. Here's a base to start off with.

 

public class GuiHandler implements IGuiHandler{
    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        /**
          * Check IDs here, return container
          **/
        return null;
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int {
        /**
          * Check IDs here, return GUI
          **/
        return null;
    }

}

 

When you use player.openGui(...), the one of the parameters is an integer ID. In the GuiHandler, you're going to want to check the ID passed in through parameters against a reference GUI ID. This is how the game knows which GUI to open.

 

As a reference, you can check out the source of my mod here. It's for 1.8, but it should still be applicable for 1.7.10 if memory serves correctly.

  • Like 1

Did I help you? Don't be afraid to give that 'thank you' button a good smack for me!

It's been looking at me weirdly for a while now.

Link to comment
Share on other sites

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.