Spirfire972 Posted March 25, 2020 Share Posted March 25, 2020 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 Quote Link to comment Share on other sites More sharing options...
TheGreyGhost Posted March 25, 2020 Share Posted March 25, 2020 Hi Where is this code located? i.e. in which method, or which event? -TGG Quote Link to comment Share on other sites More sharing options...
Spirfire972 Posted March 25, 2020 Author Share Posted March 25, 2020 sorry its in: @Mod("hobbit") public class EventHandlerCommon { @SubscribeEvent public void serverLoad(FMLServerStartingEvent event){ Quote Link to comment Share on other sites More sharing options...
TheGreyGhost Posted March 25, 2020 Share Posted March 25, 2020 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 Quote Link to comment Share on other sites More sharing options...
Spirfire972 Posted March 25, 2020 Author Share Posted March 25, 2020 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 Quote Link to comment Share on other sites More sharing options...
Spirfire972 Posted March 25, 2020 Author Share Posted March 25, 2020 So surely the event i've used is the best one if you don't know when the player will join Quote Link to comment Share on other sites More sharing options...
Spirfire972 Posted March 25, 2020 Author Share Posted March 25, 2020 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 Quote Link to comment Share on other sites More sharing options...
Spirfire972 Posted March 25, 2020 Author Share Posted March 25, 2020 Sorry i meant when all players log out and when a player joins thank you but how do i get the current overworld Quote Link to comment Share on other sites More sharing options...
Spirfire972 Posted March 25, 2020 Author Share Posted March 25, 2020 Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.