Jump to content

Recommended Posts

Posted

Hi all,

 

I'm fairly new to minecraft modding, but I have been struggling with the following issue for a while and couldn't find an answer. I would like to use my mod to create some structures. I have two possible ways of doing this, and as an example I apply both in the following code snippet (which is executed when a key is pressed)

           

            EntityPlayerSP player = Minecraft.getMinecraft().player; 
            
            int x = 16 * player.chunkCoordX + 5;
            int y = 16 * player.chunkCoordY + 10;
            int z = 16 * player.chunkCoordZ + 5;
            
            player.world.setBlockState(new BlockPos(x,y,z), Blocks.STONE.getDefaultState() );
            player.sendChatMessage( "/setblock "+ (x) + " " + (y+15) + " " + z + " stone");

 

When I run minecraft with this mod, open a world, press the relevant key, indeed two blocks appear. Next, I 'save and quite to title' and after that I load the world again. Then only one block (the one created by sendChatMessage) is left. In other words, the blocks created by "player.world.setBlockState" are not saved. I have a preference for using the setBlockState method, but it I would like to know how to save the blocks in that case. Does anybody know what is going on?

 

Posted

Actually, that chat message looks like a clever workaround. The server will decide whether the player has the power to use the command, so you don't need to reinvent that wheel. Between setblock and fill, you ought to be able to encode quite a bit of power into your keystroke(s).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.