Jump to content

Recommended Posts

Posted

I've been trying to get my mod to place blocks (using things like the Nether portal code for reference), and it seems to work. But when I reload the world, they're gone! I speculate that it's not sending the information to the server... Here's the process I use:

world.editBlocks = true;
world.setBlockWithNotify(x, y, z, Block.stone.blockID);
world.editBlocks = false;

I've even seen some vanilla code that doesn't do the whole

world.editBlocks

thing -- in fact, most of it doesn't! But in any case, I just can't get this to work... Please help! :)

I like to make mods, just like you. Here's one worth checking out

Posted

Only modify blocks from the client.

if (!world.isRemote)
{
world.editBlocks = true;
world.setBlockWithNotify(x, y, z, Block.stone.blockID);
world.editBlocks = false;
}

The enders are everywhere. You can't escape...

Posted

No, just make sure your doing it client side. That's what the

if (!world.isRemote)

is for. If isRemote returns true, it's running the code from the server (it runs from both client and server though). So the code only runs when the client runs the code.

 

And I have no idea about GUIs. There's bound to be a method for when you close them though.

The enders are everywhere. You can't escape...

Posted

wow ... StrangeOne101... im sorry but youre soooo wrong. every modification to the world MUST be done server side or else they will be erased.

@op: a general answer would be to tell you you must send a package to tell the server that a certain plaer has accomplished the action. if you explained in more details what you want to do i could give a better explanation. but youre going to need to send a packet.

also, you DONT need the editBlocks thing

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Ok, I've been trying to do work on the packet for a few days now using the Forge packet handling page, but for some reason the packet handler always excecutes on the client side (I've confirmed this by getting the side in the debugger and also using

@SideOnly(Side.SERVER)

). And the code for the packet calls are written exactly following the tutorial... here are the files in question: BlockStargateController.java, line 127, PacketHandler.java, line 18

 

Does this have something to do with me only testing this on SP? I though Minecraft ran a server even for that gamemode anyway...

 

PS: I also did use

[url=https://github.com/jwosty/Minecraft-SpaceDistortionMod/blob/develop/common/SpaceDistortion.java#L15]serverSide=true[/url]

in the mod class

@NetworkMod

annotation

 

EDIT: I'm using this for a similar effect to the Nether portal stuff, but to called from a GUI instead of a block tick or whatever.

I like to make mods, just like you. Here's one worth checking out

Posted

This code

Minecraft.getMinecraft()

is client side only.

You will crash on server if you use it in a class which isn't client side only.

 

Use player.openGui(args) to open a GUI, and handle it with a IGuiHandler.

  Quote

PS: I also did use serverSide=true in the mod class @NetworkMod annotation

You can leave it to false, it probably isn't necessary. On the contrary, clientSide=true is necessary.

Posted

I'm not trying to write the open GUI code: I already have that. Essentially I'm trying to place some blocks from the GUI, usin a packet. The recieving end of the packet handler is only executing on the client server instead of the server side when I send the packet to the server...

 

And thanks for pointing out that

Minecraft.getMinecraft()

doesn't work on server side, which means that that part, ironically, should cause a crash when the packet sends correctly and the server receives it instead of the client... I guess that's how I'll know when it works!

I like to make mods, just like you. Here's one worth checking out

Posted

If you don't crash, that means your PacketHandler class doesn't even initialize.

Which means you don't have packethandler=PacketHandler.class in your @NetworkMod annotation.

By the way, correctly opening the GUI is essential, and might well be the source of your problem.

It is impossible to send a packet from client to client without going through a server.

Posted

I've got the packet initialization code; the packet info is actually even correct! And maybe the problem _is_ the GUI; I close it from within itself by using

player.displayGuiScreen((GuiScreen) null)

. Is this the correct way? I've seen it uses in the vanilla code

I like to make mods, just like you. Here's one worth checking out

Posted
  On 8/24/2013 at 6:42 PM, Jwosty said:

And thanks for pointing out that

Minecraft.getMinecraft()

doesn't work on server side, which means that that part, ironically, should cause a crash when the packet sends correctly and the server receives it instead of the client... I guess that's how I'll know when it works!

Be careful -- if you're testing in single player mode, all the client side methods are accessible, even from server-only parts of the code, which means it's possible to write code that works fine in single player, but crashes when run on a real server.

 

Concerning the packet handler, if you use packethandler = ... in @NetworkMod, it uses the same packet handler class for both client and server, so it's possible that your packet *is* being received on the server side but you're not noticing.

 

Also, the earlier reply concerning isRemote got it backwards -- isRemote == true on the client side and false on the server side. You might be getting confused by that.

Posted
  On 8/24/2013 at 4:53 PM, Jwosty said:

for some reason the packet handler always excecutes on the client side (I've confirmed this by getting the side in the debugger and also using

@SideOnly(Side.SERVER)

).

I think the side is always reported as client side in single player. It's probably more reliable to check world.isRemote.

 

Also, I don't think the @SideOnly annotations do anything in mod code. All methods are compiled in, so that the same jar can be used on client and server.

  • 4 weeks later...
Posted

After a long break from this project then finally another debugging session, I discovered a few days ago that the problem was in the code that opens the GUI... I guess it was a simple as changing this:

 

 

  Reveal hidden contents

 

 

to:

 

 

  Reveal hidden contents

 

I like to make mods, just like you. Here's one worth checking out

Posted
  On 8/18/2013 at 4:13 AM, StrangeOne101 said:

No, just make sure your doing it client side. That's what the

if (!world.isRemote)

is for. If isRemote returns true, it's running the code from the server (it runs from both client and server though). So the code only runs when the client runs the code.

 

And I have no idea about GUIs. There's bound to be a method for when you close them though.

 

Wow, this is hilariously bad.

 

/** This is set to true for client worlds, and false for server worlds. */
    public boolean isRemote;

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.

Posted

The way that you're opening the GUI is really not optimal. I tried doing that when I first started doing GUIs, and it always ended in horrible server/client desyncing. The way you have it set now, like Draco said, shouldn't even be working. You're telling the server to open a GUI, and I bet that would crash instantly on a real server.

 

Look up stuff concerning IGuiHandler. That is the way that you are "supposed" to do it in Forge. It takes care of making sure that both the server and the client know what the player is doing, and that you can get the relevant code running for both sides.

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

    • Honestly just want to play with my brother but LAN won't work for us so we have to try this.. Anyone?
    • Got modded, shit ton custom pack. Tried making a world, and it kicked me out saying that. Singelplayer. https://pastesio.com/crash-3317
    • I received an unexpected email claiming that a long-lost relative had left me a substantial inheritance $140,000 in cryptocurrency At first I was skeptical The message came with a lot of convincing documents legal jargon and even a supposed lawyer’s contact information They insisted everything was legitimate and the funds were waiting to be transferred All I needed to do they said was cover a few minor processing and transfer fees It seemed like a small price to pay for such a large windfall Against my better judgment I paid the fees Then more fees followed They kept assuring me the payout was right around the corner Weeks went by and the excuses kept coming Eventually it became clear this was a sophisticated scam The $140K inheritance was never real and I had been tricked into sending thousands of dollars to fraudsters embarrassed I started researching online and came across Byte phantom cyber services I was hesitant at first after all I had just been scammed But their website had positive reviews and they specialized in cryptocurrency fraud I reached out not expecting much To my surprise they responded quickly and professionally They were incredibly understanding and didn't make me feel foolish Their team walked me through the process step by step They used digital forensics and blockchain tracing techniques to track down the wallet addresses involved in the scam Within weeks they identified the fraudsters and began recovery efforts To my amazement Byte phantom cyber services recovered 100% of my lost funds Every cent I honestly couldn’t believe it They taught me how to recognize red flags avoid similar traps in the future and protect my digital identity I now feel empowered and informed not just lucky If you've been scammed or even suspect it don't stay silent Reach out to Byte phantom cyber services I got my money back
    • abro el juego pero al tocar un solo jugador me tira la de   [02:23:30] [Render thread/FATAL] [ne.mi.co.ForgeMod/]: Preparing crash report with UUID c3ff08d5-d285-458d-a3b5-fbba17743dff #@!@# Game crashed! Crash report saved to: #@!@# C:\juegos\Minecraft\instances\1.20.1 forge\.minecraft\crash-reports\crash-2025-05-02_02.23.30-client.txt Process exited with code -1 (0xffffffffffffffff). ¡Por favor, ten en cuenta que normalmente ni el código de salida ni su descripción son suficientes para diagnosticar problemas! Sube siempre el registro entero y no solo el código de salida.
    • So, First of I am new to modding so bare with me I am creating a 1.20.1 forge mod that needs Oculus/Embeddium as a dependancy because later on I need to add custom shaders in for lights and such. I am using ParchmentMC as I've heard its better because of namings of things but that doesn't seem to like it when I run it alongside Oculus (Its a very barebones script adding two blocks and an item, and tested it before I did this) The 4 errors I get when I run 'runClient' is Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered Caused by: org.spongepowered.asm.mixin.throwables.MixinApplyError: Mixin [mixins.oculus.json:texture.MixinAbstractTexture] from phase [DEFAULT] in config [mixins.oculus.json] FAILED during APPLY Caused by: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: Critical injection failure: @Inject annotation on iris$afterGenerateId could not find any targets matching 'Lnet/minecraft/client/renderer/texture/AbstractTexture;m_117963_()I' in net.minecraft.client.renderer.texture.AbstractTexture. Using refmap oculus-mixins-refmap.json [PREINJECT Applicator Phase -> mixins.oculus.json:texture.MixinAbstractTexture -> Prepare Injections ->  -> handler$zgm000$iris$afterGenerateId(Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfoReturnable;)V -> Parse] And then a "Execution failed for task ':runClient'." error My dependancies are just these with latest forge for 1.20.1 implementation fg.deobf('curse.maven:oculus-581495:6020952') // Oculus for 1.20.1 - 1.8.0  implementation fg.deobf('curse.maven:embeddium-908741:5681725') // Embeddium for 1.20.1 - 0.3.31 I have tested these mods & forge in a different modpack alone and it works fine Any help is much appreciated!
  • Topics

×
×
  • Create New...

Important Information

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