Jump to content

Placing a block?


Atijaf

Recommended Posts

I am trying to understand why this event is not working.

 

Event

 

 

@SubscribeEvent

public void onWorldTick(TickEvent.WorldTickEvent event){

 

if(event.side.isServer()){

tick++;

            if(tick == 1000){

                                event.world.setBlockState(new BlockPos(0,4,0), blocks.stone.getDefaultState();

                            }

 

    if(tick >= maxTick){

        tick = 0;

            }

}

 

 

The code looks silly and without purpose, but this is a small example of what my code looks like.

When it gets to event.world.setBlockState... It returns false, and doesn't place the block.

 

I also get the message when it comes time to place the block, [18:01:19] [server thread/INFO] [FML]: Unloading dimension 1

Link to comment
Share on other sites

It's trying to replace the block at 0, 4, 0 - if that's not loaded, it won't work.

Also, what do I know, but I'd use !event.work.isRemote() instead of event.side.isServer().

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Link to comment
Share on other sites

It's trying to replace the block at 0, 4, 0 - if that's not loaded, it won't work.

Also, what do I know, but I'd use !event.work.isRemote() instead of event.side.isServer().

 

I'm standing 2 blocks away from the location.  Would you know if there'd be a way to force load it?

Thanks:)

Link to comment
Share on other sites

After further debugging, I found this bit of code.

 

 

 

if (iblockstate1 == null)

            {

                if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot);

                return false;

            }

 

 

iblockstate1 is null.

blockSnapshot is not null.\

 

it returns false.

 

The code that defines iblockstate1

 

 

IBlockState iblockstate1 = chunk.setBlockState(pos, newState);

 

 

 

as for capitalizing blocks.  Yes.  Just a typo on this end.  I didn't copy and paste.

Link to comment
Share on other sites

Alright, after further debugging...  The client side seems to not update, so what I am seeing is not what the server is seeing.  The server apparently already placed the block.  It returns false if the block it is going to place down is the same block that is already there... or rather, null.

 

I suppose I'm stuck at trying to figure out why the client side is not updating.

Link to comment
Share on other sites

Well, I changed a little bit of code, but nothing much.  Improved the way information is stored, and now it works.  Still am unsure as to why the blocks were respawning in the nether and I wish I knew why.

 

Thanks for the help

Link to comment
Share on other sites

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.