Posted March 25, 20205 yr 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
March 25, 20205 yr Author sorry its in: @Mod("hobbit") public class EventHandlerCommon { @SubscribeEvent public void serverLoad(FMLServerStartingEvent event){
March 25, 20205 yr 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
March 25, 20205 yr 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
March 25, 20205 yr Author So surely the event i've used is the best one if you don't know when the player will join
March 25, 20205 yr 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
March 25, 20205 yr Author Sorry i meant when all players log out and when a player joins thank you but how do i get the current overworld
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.