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

The mod I am coding is a client-side only mod. Additionally, the block is not a naturally spawned block.

I need to loop through all the currently loaded chunks, and get all blocks of the type i am looking for (barrier block).

In the end, I should have a list with the barrier blocks in it.

public static List<BlockPos> barrierBlocks = new ArrayList<>();

Does anyone know how to do this?

there is nothing in Minecraft.getMinecraft().world for getting all loaded chunks.

 

  • Author

the lag is fine, as this action will only be performed upon running a command, if it freezes the game for like 5- 10 seconds thats completely fine. 

 

 

I am trying to get the location of all barrier blocks, then ill tp each player to a random barrier block

  • Author

ho boi time to learn reflection.

what property of ClientChunkProvider do i need to access? 

Thanks for the help.

  • Author
38 minutes ago, diesieben07 said:

Should be pretty obvious if you look at what its getChunk method does.

 

according to the source code, i should be looking to access the chunkMapping

thank you once again

Edited by ajGeneric

5 hours ago, diesieben07 said:

This is a bad idea. There are a lot of blocks to look through and this will lag the game horribly.

Having actually benchmarked this, not really.

 

Scanning a whole chunk from 0 to 64 takes 600,000 nanos provided you're doing virtually nothing else (e.g. don't find a matching block). Adding a position to a list is going to be pretty small as well (my benchmarking involved more complicated stuff, which included setting block states, and even for a bunch of matching blocks I never exceeded 1,200,000 nanos for a single chunk). For a full 11x11 chunk area around the player and the full chunk height you're looking at 290ms +/- 15%.

 

It's still not a great idea, but the actual time on checking blocks is tiny.

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.

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.