Jump to content

[1.7.10]Server crashes after changing a Gui class variable from a block class


Recommended Posts

Posted

My Block class:

 

public class LobbyBlock extends Block {

public LobbyBlock(Material rock) {
	super(rock);
	this.setBlockName("LobbyBlock");
	this.setBlockTextureName(Main.MODID + ":" + "0");
	this.setCreativeTab(Tabs.CreativeTab);
	this.setLightLevel(1F);
	this.setLightOpacity(2555);
}

public TileEntity createTileEntity(World world, int metadata) {
	return new TileEntityData();
}

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7,
		float par8, float par9) {

	GuiLobby.blockPosX = x;
	GuiLobby.blockPosY = y;
	GuiLobby.blockPosZ = z;
	GuiLobby.player = player;
	GuiLobby.world = world;

	TileEntityData tile = (TileEntityData) world.getTileEntity(x, y, z);

	if (tile.IsGuiOpen == false) {
		tile.IsGuiOpen = true;
		FMLNetworkHandler.openGui(player, Main.instance, 0, world, x, y, z);
	}

	return true;
}
}

 

My Gui class:

 

public class GuiLobby extends GuiScreen {

public static int blockPosX;
public static int blockPosY;
public static int blockPosZ;
public static EntityPlayer player;
public static World world;

public boolean doesGuiPauseGame() {
	return false;
}

int guiWidth = 256;
int guiHeight = 168;

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

	this.buttonList.clear();
	this.buttonList.add(new GuiButton(0, guiX + 5, guiY + 5, 98, 20, I18n.format("Host Game", new Object[0])));

	GL11.glColor4f(1, 1, 1, 1);
	drawDefaultBackground();
	mc.renderEngine.bindTexture(new ResourceLocation(Main.MODID + ":" + "textures/gui/Lobby.png"));
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);

	super.drawScreen(x, y, ticks);
}

@Override
protected void keyTyped(char letter, int number) {
	switch (number) {
	case 1:
		this.mc.displayGuiScreen((GuiScreen) null);
		this.mc.setIngameFocus();
		TileEntityData tile = (TileEntityData) world.getTileEntity(blockPosX, blockPosY, blockPosZ);
		tile.IsGuiOpen = false;
		break;
	}

	switch (letter) {
	case 'e':
	case 'E':
		this.mc.displayGuiScreen((GuiScreen) null);
		this.mc.setIngameFocus();
		TileEntityData tile = (TileEntityData) world.getTileEntity(blockPosX, blockPosY, blockPosZ);
		tile.IsGuiOpen = false;
		break;
	}
}

@Override
protected void actionPerformed(GuiButton button) {
	if (button.id == 0) {

		TileEntityData tile = (TileEntityData) world.getTileEntity(blockPosX, blockPosY, blockPosZ);
		tile.Name = player.getDisplayName();

		world.setBlock(blockPosX, blockPosY, blockPosZ, Blocks.LobbyBlock1);

		this.mc.displayGuiScreen((GuiScreen) null);
		this.mc.setIngameFocus();
	}
}

@Override
public void onGuiClosed() {
	TileEntityData tile = (TileEntityData) world.getTileEntity(blockPosX, blockPosY, blockPosZ);
	tile.IsGuiOpen = false;
}
}

 

My Main class:

 

@Mod(modid = Main.MODID, name = Main.NAME, version = "PreAlpha 0.0.3")
public class Main {
@Instance(Main.MODID)
public static Main instance;

public static final String MODID = "PAYDAY2";
public static final String NAME = "PAYDAY 2";
public static final String VERSION = "PreAlpha 0.0.3";

public Main() {

}

@EventHandler
@SideOnly(Side.CLIENT)
public void preInit(FMLPreInitializationEvent event) {
	FMLCommonHandler.instance().bus().register(new Events());
	Events.init();
}

@EventHandler
public void Init(FMLInitializationEvent event) {
	NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new GuiHandler());
	GameRegistry.registerTileEntity(TileEntityData.class, "Host");
	GameRegistry.registerTileEntity(TileEntityData.class, "IsGuiOpen");
	Blocks.registerBlocks();
	Items.registerItems();
	Recipes.initShapedRecipes();
	Recipes.initShalessRecipes();
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {

}
}

 

My GuiHandler class:

 

public class GuiHandler implements IGuiHandler {

public GuiHandler() {
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (ID == 0) {
		return new GuiLobby();
	}
	if (ID == 1) {
		return new GuiLobbyHosted();
	}
	if (ID == 2) {
		return new GuiLobbyHost();
	}
	return null;
}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	// TODO Auto-generated method stub
	return null;
}
}

 

And the class I register blocks with:

 

public class Blocks {
public static Block LobbyBlock = new LobbyBlock(Material.rock);
public static Block LobbyBlock1 = new LobbyBlock1(Material.rock);
public static Block LobbyBlock2 = new LobbyBlock2(Material.rock);
public static Block LobbyBlock3 = new LobbyBlock3(Material.rock);
public static Block LobbyBlock4 = new LobbyBlock4(Material.rock);
public static Block LobbyBlockHosted = new LobbyBlockHosted(Material.rock);
public static Block LobbyBlockOccupied = new LobbyBlockOccupied(Material.rock);

public static List<Block> blockList = new ArrayList<Block>();

public static void registerBlocks() {
	blockList.add(LobbyBlock.setCreativeTab(Tabs.CreativeTab));
	blockList.add(LobbyBlock1);
	blockList.add(LobbyBlock2);
	blockList.add(LobbyBlock3);
	blockList.add(LobbyBlock4);
	blockList.add(LobbyBlockHosted);
	blockList.add(LobbyBlockOccupied);

	for (Block block : blockList) {
		GameRegistry.registerBlock(block, block.getUnlocalizedName());
	}
}
}

 

What I want is to change the blockPosX, blockPosY, blockPosZ, player and world variables that are in the GuiLobby class from the LobbyBlock class ON THE SERVER.

 

Here you have the crash log:

 

---- Minecraft Crash Report ----

// Shall we play a game?

 

Time: 9.9.15 17:13

Description: Exception in server tick loop

 

java.lang.NoClassDefFoundError: com/tominocz/PAYDAY2/gui/GuiLobby

at com.tominocz.PAYDAY2.blocks.LobbyBlock.onBlockActivated(LobbyBlock.java:34)

at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)

at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:349)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

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

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

Caused by: java.lang.ClassNotFoundException: com.tominocz.PAYDAY2.gui.GuiLobby

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

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 12 more

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

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:760)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

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

... 14 more

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

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

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 18 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 10 (amd64) version 10.0

Java Version: 1.8.0_60, Oracle Corporation

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

Memory: 929853040 bytes (886 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: 12, tallocated: 94

FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1492 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

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

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

UCHIJAAAA Forge{10.13.4.1492} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar)

UCHIJAAAA PAYDAY2{PreAlpha 0.0.3} [PAYDAY 2] (bin)

Profiler Position: N/A (disabled)

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

Player Count: 1 / 20; [EntityPlayerMP['Player32'/365, l='world', x=128,50, y=67,00, z=246,50]]

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

Type: Dedicated Server (map_server.txt)

 

Posted

That's exactly what I need to do - send data from client to server and the opposite.. But how can I make such a packet? :////

From what I've found, the packet handling was separated in more than 5 classes... so how do I create/send one?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • been getting this error and followed the old tick loop post however i cant figure out what file to delete Description: Exception in server tick loop java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.LevelAccessor.m_7654_()" because the return value of "net.minecraftforge.event.level.LevelEvent$Unload.getLevel()" is null     at com.lion.graveyard.platform.forge.HordeSpawner.onWorldUnload(HordeSpawner.java:41) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading}     at com.lion.graveyard.platform.forge.__HordeSpawner_onWorldUnload_Unload.invoke(.dynamic) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.mehvahdjukaar.moonlight.api.platform.forge.PlatHelperImpl.invokeLevelUnload(PlatHelperImpl.java:279) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.moonlight.api.platform.PlatHelper.invokeLevelUnload(PlatHelper.java) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.moonlight.core.misc.FakeLevelManager.invalidate(FakeLevelManager.java:29) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.utils.fake_level.BlockTestLevel.invalidate(BlockTestLevel.java:34) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.block.faucet.FaucetBehaviorsManager.onReloadWithLevel(FaucetBehaviorsManager.java:129) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.ServerEvents.onServerStart(ServerEvents.java:160) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.ServerEventsForge.onServerStart(ServerEventsForge.java:119) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.__ServerEventsForge_onServerStart_ServerStartedEvent.invoke(.dynamic) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(ServerLifecycleHooks.java:115) ~[forge-1.20.1-47.3.29-universal.jar%23212!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:638) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) ~[?:?] {}  
    • Online forums in general seem to be declining in popularity imo. There’s still value here for certain types of content, such as written tutorials and blog posts which would otherwise get lost in the chat history fairly quickly on Discord. Also for those that prefer the forums format ofc. But for faster support related topics, I agree that the Discord is probably your best bet at the moment. The speed of responses is also down to the ratio of volunteers - the player support forum still seems pretty active, but the coding ones much less so. Once you’re feeling more confident in your modding skills, be the change you want to see
    • try the same link, i swapped logs after sitting in the world for a few minutes then leaving. Lmk if it keeps happening then ill just send a video of the live log on modrinth
    • It is an issue with chimes
  • Topics

×
×
  • Create New...

Important Information

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