Jump to content

How to get current world so i can use .setBlockState() [1.15.2]


Recommended Posts

I am currently working on one of my first mods as i'm quite new to modding.

I have run into an issue when i am trying to place blocks. I need to have a world varible however i do not know how to get current world.

my code is as follows:

		  Block blk = Blocks.STONE;
		  BlockState block0 = blk.getDefaultState();
		  BlockPos pos1 = new BlockPos(100000, 255 , 100000);
		      World.this.setBlockState(pos1, block0);
			  ArrayList<Integer> posflat = getflat();
			  int x = posflat.get(0);
			  int z = posflat.get(1);
			  int y = get_y(x, z);
			  for(int i=10; i>1; i--){ 
				  for(int j=10; j>1; j--){ 
					  for(int k=10; k>1; k--){ 
						  BlockPos pos0 = new BlockPos(j+x, i+y , k+z);
						  World.this.setBlockState(pos0, block0);

I apologise ahead of time for any inefficiencies in my code

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.

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.

  • Create New...

Important Information

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