Jump to content

Recommended Posts

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.

 

Posted

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

Posted (edited)
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
Posted
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...

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