Jump to content

Recommended Posts

Posted

Okay having some problems with the gui for a block.

 

 

 

Mod File on server.


public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
if(ID == 90)
{
return new ContainerWaterCollector(player.inventory, new TileEntityWaterCollector());
}
if(ID == 91)
{
return new ContainerJM(player.inventory, new TileEntityJM());
}
return null;
}

 

Mod File on Client:


public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
if(ID == 90)
{
return new GuiWaterCollector(player.inventory, new TileEntityWaterCollector());
}
if(ID == 91)
{
return new GuiJM(player.inventory, new TileEntityJM());
}
return null;
}

 

ContainerJM Server:


public boolean canInteractWith(EntityPlayer par1EntityPlayer)
    {
        return jm.isUseableByPlayer(par1EntityPlayer);
    }

 

TileEntityJM Server:

public boolean isUseableByPlayer(EntityPlayer entityplayer)
    {
     return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }

 

BlockJM Server:


public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
    {
        if (world.isRemote)
        {
            return true;
        }
        else
        {
            entityplayer.openGui(mod_ThirstMod.mod, 91, world, i, j, k);
            return true;
        }
    }

 

However when I run it, game crashes with the following error:


[WARNING] Failed to handle packet: java.lang.NullPointerException
java.lang.NullPointerException
at net.minecraft.src.ThirstMod.containers.TileEntityJM.isUseableByPlayer(TileEntityJM.java:268)
at net.minecraft.src.ThirstMod.containers.ContainerJM.canInteractWith(ContainerJM.java:86)
at net.minecraft.src.EntityPlayer.onUpdate(EntityPlayer.java:239)
at net.minecraft.src.EntityPlayerMP.localOnUpdateEntity(EntityPlayerMP.java:1066)
at net.minecraft.src.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:1060)
at net.minecraft.src.NetServerHandler.handleFlying(NetServerHandler.java:241)
at net.minecraft.src.Packet10Flying.processPacket(Packet10Flying.java:41)
at net.minecraft.src.NetworkManager.processReadPackets(NetworkManager.java:353)
at net.minecraft.src.NetServerHandler.handlePackets(NetServerHandler.java:73)
at net.minecraft.src.NetworkListenThread.handleNetworkListenThread(NetworkListenThread.java:113)
at net.minecraft.server.MinecraftServer.doTick(MinecraftServer.java:566)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)
at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:18)

 

 

 

If you need more code PM me.

This is also happening with the Water Collector

Posted

Seems fairly straight forward, something in your code is null at the time you try to access it.

Learn to debug your own code please, we are not a IDE.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Thanks mate, all working now. Turns out worldObj was null for some reason. But I do believe this may be a bug, when you put something into the TileEntity (similar to Furnace) it does not send the information back so that in this case the drink is never made. This is the exact same code as the MLMP version except with the Forge GUI, packets etc. So I have no clue why this is not working. Do you have to register TileEntities with some sort of Forge register method or use the MinecraftForge.registerEntity method.

Posted

You have to open the gui in whatever form that allows you to put items in.

And you need to do whatever you need to do to make sure the client sends the click events to the server.

Just like you've always had to, for any gui.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

How would you send back the so called "clicks" to the server. I'm not sure why or how because it was all working on MLMP and so far not impressed with the difficulty to port to or use FML. Anyways how would I send the "clicks" back. Packets possibly.

Posted

As long as you are doing things properly, as Minecraft does them, None of this should be an issue.

If you're having issues when converting, its MLMP, or your fault. Not ours.

Go look into how clicks are sent to the server for normal MC stuff, figure out why its not working for your GUI.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

No everything is working on MLMP version. You probably (or CPW) did not add a functionality that MLMP does for you already relating to Tile Entities. I'll have a good look at MLMP files to fix this problem BTW is everything in the code on the first post for the GUI alright?

 

Some methods in ModLoaderMp.class Server:

getTileEntityPacket

sendTileEntityPacket

 

I'll have a look at it myself.

 

Or maybe i'll just send some itemstack packets with things inside the container... Hm...

Posted

We specifically don't add those 1 line helper functions because they are stupid.

If you use them, move to the proper way of doing things.

But ya the bulk of the stuff in your first post looks fine.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Wait can you send ItemStack packets currently i'm sending integers and then changing the jmItemStacks when the packet is received on the server side. It is kinda working.

  • 4 weeks later...
Posted

Thanks mate, all working now. Turns out worldObj was null for some reason. But I do believe this may be a bug, when you put something into the TileEntity (similar to Furnace) it does not send the information back so that in this case the drink is never made. This is the exact same code as the MLMP version except with the Forge GUI, packets etc. So I have no clue why this is not working. Do you have to register TileEntities with some sort of Forge register method or use the MinecraftForge.registerEntity method.

 

Why was WorldObj Null?

I'm having the exact same problem.

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

    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } }  
    • All versions of Minecraft Forge suddenly black screen even without mods (tried reinstalling original Minecraft, Java, updating drivers doesn't work)
  • Topics

×
×
  • Create New...

Important Information

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