Jump to content

Recommended Posts

Posted

Hello everyone,

 

I made a mod than replace a block with another own block, by right-clicking on it, with the follow function:

 

 

  Reveal hidden contents

 

 

This work fine in SSP but in SMP the block seems replaced but when I reload the chunk or I right-click the block, this return back to the previous block. as if nothing had happened.

 

Now i know than i need to send to the server a custom package to notify the changes, and i've made the ServerPacketHandler class:

 

 

  Reveal hidden contents

 

 

And i initialized it in main mod class declaration network section:

 

 

  Reveal hidden contents

 

 

Now i dont know what i must put into ServerPacketHandler or into right-click event to notify the replaced block to the server.

 

Plese any suggestions ...

Posted

Yes, i tried but unfortunately the problem happen also in SSP (client side).  :-\

 

Also I tried using this:

 

MinecraftServer mcServer =  MinecraftServer.getServer();

mcServer.worldServerForDimension(player.dimension).setBlockWithNotify(X, Y, Z, mymod.mymod.blockID);

or

mcServer.worldServerForDimension(player.dimension).setBlock(X, Y, Z, mymod.mymod.blockID);

 

but mc give me "java.lang.NullPointerException". I dont know why ...

Posted

As you wish:

 

 

  Reveal hidden contents

 

Posted

oh god, i put it in randomDisplayTick because previously it was in GUIscreen button (cliente side only too).

 

In fact the boolean mymod.ReplaceBlock = true when pressed OK button from a GUI ...

 

Now I really dont know where i can put that code. :'(

 

any suggestion?

Posted

seems cant run updatetick function:

 

 

  Reveal hidden contents

 

 

also I added setRequiresSelfNotify as in wheat (you mean BlockCorp, right?) but wont work.

Posted

if (player.getCurrentEquippedItem().getItemName().equals("item.My Block"))

it's not best practice to use strings to identify items, use IDs.

 

         if (par1World.isRemote)
          {
            if (mymod.ReplaceBlock)
            {
               par1World.setBlockWithNotify(par2, par3, par4, mymod.myblockID);
               
               mymod.ReplaceBlock = false;
            }
          }

so, your block-replacing code is supposed to run only on client? also take a look at mymod.ReplaceBlock if it does really what you wanted. if it's only set here then it means that only once after mod initialization (if its default value is true) one block changes ~ only 1 block after launching minecraft will be affected.

 

 

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Posted
  On 2/21/2013 at 8:21 PM, mnn said:

so, your block-replacing code is supposed to run only on client? also take a look at mymod.ReplaceBlock if it does really what you wanted. if it's only set here then it means that only once after mod initialization (if its default value is true) one block changes ~ only 1 block after launching minecraft will be affected.

 

No, the block-replacing code should run both client & server. the mymod.ReplaceBlock = true everytime the player press OK  on a GUI mask ;)

Posted
  On 2/22/2013 at 9:12 AM, diesieben07 said:

You don't change blocks on the client. Only change them on the server, it will then tell the client. That how it works ;) If you want a button to trigger a block change, you need to send a custom packet (There is a tutorial on the wiki) that tells the server when the button is pressed and then make the block change. Only on the server.

 

Yes, but i cant found a specific tutorial to do it. (If you have one can you show me?)

on wiki i found very roughly guide line to handle the packet.

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.