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

		  System.out.println("Testing");;
		  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

  • Author

sorry its in:

@Mod("hobbit")
public class EventHandlerCommon {
	@SubscribeEvent
	public void serverLoad(FMLServerStartingEvent event){

 

Hi

That's way too early to be writing to the world, it won't have been loaded yet.  Also, there is more than one world (eg the nether).

 

When do you want to do this writing of blocks into the world?  i.e. at what time, in response to what?

 

Cheers

 TGG

 

  • Author

Huh this code worked in 1.12 and it generated fine.

i want to write blocks into the over world before the player joins ideally as soon as possible

  • Author

To generate a structure (right now substituted for a cube) When the player joins somewhere random on the map with loot inside it.

Then it gets destroyed when the player leaves and a new one generates somewhere random

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.