Posted January 23, 20187 yr Hello, Today I made a method that uses 2 for loops to change the floor in front of you to 5x5 square filled with my own block (ModBlocks.houseFundaments). But whenever I rightclick with the item (which is the trigger event for my method), the world seems to jigger more than usual. Is this normal or am I doing something wrong? private EnumActionResult buildHouse(World w, EntityPlayer p, BlockPos pos, ItemStack s) { final int xRows = 5; final int zRows = 5; BlockPos negStartPos = new BlockPos(-1, 0, 0); BlockPos prevBlockPos = pos.add(negStartPos); for(int i=1; i<=xRows; i++){ BlockPos newBlockPos = new BlockPos(prevBlockPos.getX()+ 1, prevBlockPos.getY(), prevBlockPos.getZ()); w.setBlockState(newBlockPos, ModBlocks.houseFundaments.getDefaultState()); for (int j=1; j<=zRows; j++) { BlockPos zAddPos = new BlockPos(newBlockPos.getX(), newBlockPos.getY(), newBlockPos.getZ()+ 1); w.setBlockState(zAddPos, ModBlocks.houseFundaments.getDefaultState()); } prevBlockPos = newBlockPos; } //w.setBlockState(pos, ModBlocks.houseFundaments.getDefaultState()); return EnumActionResult.PASS; } P.S. Does any one know why this codes only places in a 5x2? I just don't understand. Thanks in advance, NeusAap
January 23, 20187 yr Well... 1) Use BlockPos.allInBox(...) instead of new BlockPos(...); and iterate over the list it returns instead 2) The more blocks you change all in one go, the longer the hitch will be 3) Look at the flag parameter to setBlockState() and see if you can avoid doing lighting recalculations until you're done 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.