Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • Author

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:)

If it's loaded I have no idea. Sorry!

 

EDIT: Wait - shouldn't the Blocks in Blocks.stone.getDefaultState() be capatalized?

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.

  • Author

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.

  • Author

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.

  • Author

..... ugh...

 

It's spawning the block in the nether.  Anyone know the cause of this?

  • Author

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

  • Author

If it's loaded I have no idea. Sorry!

 

Turns out that it will force a chunk to load if it's going to place a block down:)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.